]> git.mxchange.org Git - flightgear.git/blobdiff - src/Network/atc610x.cxx
Moved random ground cover object management code (userdata.[ch]xx) over
[flightgear.git] / src / Network / atc610x.cxx
index 96471bcb69e2c8a4b0e1fc376ef57b3d20570984..70cf20cbcc3692b8d81c0f4eb57ebf38092adfff 100644 (file)
@@ -43,8 +43,8 @@
 #include <simgear/debug/logstream.hxx>
 #include <simgear/io/iochannel.hxx>
 #include <simgear/math/sg_types.hxx>
-#include <simgear/misc/props.hxx>
 #include <simgear/misc/sg_path.hxx>
+#include <simgear/props/props.hxx>
 
 #include <Main/fg_props.hxx>
 #include <Main/globals.hxx>
@@ -662,7 +662,7 @@ static int tony_magic( int raw, int obs[3] ) {
            }
        }
         result = obs[1] - obs[2];
-        if ( abs(result) > 200 ) {
+        if ( abs(result) > 400 ) {
             // ignore
             result = 0;
         }
@@ -679,7 +679,7 @@ static int tony_magic( int raw, int obs[3] ) {
 
 
 static double instr_pot_filter( double ave, double val ) {
-    if ( fabs(ave - val) < 200 || fabs(val) < fabs(ave) ) {
+    if ( fabs(ave - val) < 400 || fabs(val) < fabs(ave) ) {
         return 0.5 * ave + 0.5 * val;
     } else {
         return ave;
@@ -706,45 +706,49 @@ bool FGATC610x::do_analog_in() {
     // aileron
     tmp = scale( ailerons_center->getIntValue(), ailerons_min->getIntValue(),
                  ailerons_max->getIntValue(), analog_in_data[0] );
-    fgSetFloat( "/controls/aileron", tmp );
+    fgSetFloat( "/controls/flight/aileron", tmp );
     // cout << "aileron = " << analog_in_data[0] << " = " << tmp;
     // elevator
     tmp = -scale( elevator_center->getIntValue(), elevator_min->getIntValue(),
                   elevator_max->getIntValue(), analog_in_data[5] );
-    fgSetFloat( "/controls/elevator", tmp );
+    fgSetFloat( "/controls/flight/elevator", tmp * 0.5 );
     // cout << "trim = " << analog_in_data[4] << " = " << tmp;
 
     // elevator trim
     tmp = scale( trim_center->getIntValue(), trim_min->getIntValue(),
                  trim_max->getIntValue(), analog_in_data[4] );
-    fgSetFloat( "/controls/elevator-trim", tmp );
+    fgSetFloat( "/controls/flight/elevator-trim", tmp );
     // cout << " elev = " << analog_in_data[5] << " = " << tmp << endl;
 
     // mixture
     tmp = scale( mixture_min->getIntValue(), mixture_max->getIntValue(),
                  analog_in_data[6] );
-    fgSetFloat( "/controls/mixture[0]", tmp );
-    fgSetFloat( "/controls/mixture[1]", tmp );
+    fgSetFloat( "/controls/engines/engine[0]/mixture", tmp );
+    fgSetFloat( "/controls/engines/engine[1]/mixture", tmp );
 
     // throttle
     tmp = scale( throttle_min->getIntValue(), throttle_max->getIntValue(),
                  analog_in_data[8] );
-    fgSetFloat( "/controls/throttle[0]", tmp );
-    fgSetFloat( "/controls/throttle[1]", tmp );
+    fgSetFloat( "/controls/engines/engine[0]/throttle", tmp );
+    fgSetFloat( "/controls/engines/engine[1]/throttle", tmp );
     // cout << "throttle = " << tmp << endl;
 
-    // rudder
-    tmp = scale( rudder_center->getIntValue(), rudder_min->getIntValue(),
-                 rudder_max->getIntValue(), analog_in_data[10] );
-    fgSetFloat( "/controls/rudder", -tmp );
-
-    // toe brakes
-    tmp = scale( brake_left_min->getIntValue(), brake_left_max->getIntValue(),
-                 analog_in_data[20] );
-    fgSetFloat( "/controls/brakes[0]", tmp );
-    tmp = scale( brake_right_min->getIntValue(), brake_right_max->getIntValue(),
-                 analog_in_data[21] );
-    fgSetFloat( "/controls/brakes[1]", tmp );
+    if ( use_rudder ) {
+        // rudder
+        tmp = scale( rudder_center->getIntValue(), rudder_min->getIntValue(),
+                     rudder_max->getIntValue(), analog_in_data[10] );
+        fgSetFloat( "/controls/flight/rudder", -tmp );
+
+        // toe brakes
+        tmp = scale( brake_left_min->getIntValue(),
+                     brake_left_max->getIntValue(),
+                     analog_in_data[20] );
+        fgSetFloat( "/controls/gear/wheel[0]/brake", tmp );
+        tmp = scale( brake_right_min->getIntValue(),
+                     brake_right_max->getIntValue(),
+                     analog_in_data[21] );
+        fgSetFloat( "/controls/gear/wheel[1]/brake", tmp );
+    }
 
     // nav1 volume
     tmp = (float)analog_in_data[25] / 1024.0f;
@@ -788,29 +792,29 @@ bool FGATC610x::do_analog_in() {
     diff4_ave = instr_pot_filter( diff4_ave, diff4 );
     diff5_ave = instr_pot_filter( diff5_ave, diff5 );
 
-    tmp = alt_press->getDoubleValue() + (diff1_ave * (0.25/880.0) );
+    tmp = alt_press->getDoubleValue() + (diff1_ave * (0.25/888.0) );
     if ( tmp < 27.9 ) { tmp = 27.9; }
     if ( tmp > 31.4 ) { tmp = 31.4; }
     fgSetFloat( "/instrumentation/altimeter/setting-inhg", tmp );
 
-    tmp = ati_bird->getDoubleValue() + (diff2_ave * (20.0/880.0) );
+    tmp = ati_bird->getDoubleValue() + (diff2_ave * (20.0/888.0) );
     if ( tmp < -10.0 ) { tmp = -10.0; }
     if ( tmp > 10.0 ) { tmp = 10.0; }
     fgSetFloat( "/instrumentation/attitude-indicator/horizon-offset-deg", tmp );
 
-    tmp = nav1_obs->getDoubleValue() + (diff3_ave * (72.0/880.0) );
+    tmp = nav1_obs->getDoubleValue() + (diff3_ave * (72.0/888.0) );
     while ( tmp >= 360.0 ) { tmp -= 360.0; }
     while ( tmp < 0.0 ) { tmp += 360.0; }
     // cout << " obs = " << tmp << endl;
     fgSetFloat( "/radios/nav[0]/radials/selected-deg", tmp );
 
-    tmp = nav2_obs->getDoubleValue() + (diff4_ave * (72.0/880.0) );
+    tmp = nav2_obs->getDoubleValue() + (diff4_ave * (72.0/888.0) );
     while ( tmp >= 360.0 ) { tmp -= 360.0; }
     while ( tmp < 0.0 ) { tmp += 360.0; }
     // cout << " obs = " << tmp << endl;
     fgSetFloat( "/radios/nav[1]/radials/selected-deg", tmp );
 
-    tmp = adf_hdg->getDoubleValue() + (diff5_ave * (72.0/880.0) );
+    tmp = adf_hdg->getDoubleValue() + (diff5_ave * (72.0/888.0) );
     while ( tmp >= 360.0 ) { tmp -= 360.0; }
     while ( tmp < 0.0 ) { tmp += 360.0; }
     // cout << " obs = " << tmp << endl;
@@ -1375,9 +1379,12 @@ bool FGATC610x::do_radio_display() {
             // display turns on the decimal point
         } else {
             // out of range
-            for ( i = 0; i < 6; ++i ) {
-                radio_display_data[i] = 0xee;
-            }
+            radio_display_data[0] = 0xbb;
+            radio_display_data[1] = 0xfb;
+            radio_display_data[2] = 0xbb;
+            radio_display_data[3] = 0xfb;
+            radio_display_data[4] = 0xbb;
+            radio_display_data[5] = 0x0b;
         }
     } else {
        // blank dem display
@@ -1735,8 +1742,8 @@ bool FGATC610x::do_switches() {
     update_switch_matrix( board, switch_data, switch_matrix );
 
     // master switches
-    fgSetBool( "/controls/switches/master-bat", switch_matrix[board][4][1] );
-    fgSetBool( "/controls/switches/master-alt", switch_matrix[board][5][1] );
+    fgSetBool( "/controls/switches/master-bat", switch_matrix[board][5][1] );
+    fgSetBool( "/controls/switches/master-alt", switch_matrix[board][4][1] );
     fgSetBool( "/controls/switches/master-avionics",
                switch_matrix[board][0][3] );
 
@@ -1767,18 +1774,19 @@ bool FGATC610x::do_switches() {
     mag2 = mag1;
     mag1 = magnetos;
     if ( mag1 == mag2 && mag2 == mag3 ) {
-        fgSetInt( "/controls/magnetos[0]", magnetos );
+        fgSetInt( "/controls/engines/engine[0]/magnetos", magnetos );
     }
     static bool start1, start2, start3;
     start3 = start2;
     start2 = start1;
     start1 = starter;
     if ( start1 == start2 && start2 == start3 ) {
-        fgSetBool( "/controls/starter[0]", starter );
+        fgSetBool( "/controls/engines/engine[0]/starter", starter );
     }
 
     // other toggle switches
-    fgSetBool( "/controls/fuel-pump[0]", switch_matrix[board][0][2] );
+    fgSetBool( "/controls/engines/engine[0]/fuel-pump",
+               switch_matrix[board][0][2] );
     fgSetBool( "/controls/switches/flashing-beacon",
                switch_matrix[board][1][2] );
     fgSetBool( "/controls/switches/landing-light", switch_matrix[board][2][2] );
@@ -1807,7 +1815,7 @@ bool FGATC610x::do_switches() {
     flap2 = flap1;
     flap1 = flaps;
     if ( flap1 == flap2 && flap2 == flap3 ) {
-        fgSetFloat( "/controls/flaps", flaps );
+        fgSetFloat( "/controls/flight/flaps", flaps );
     }
 
     // fuel selector (also filtered)
@@ -1831,8 +1839,8 @@ bool FGATC610x::do_switches() {
     fuel2 = fuel1;
     fuel1 = fuel;
     if ( fuel1 == fuel2 && fuel2 == fuel3 ) {
-        fgSetBool( "/controls/fuel-selector[0]", (fuel & 0x01) > 0 );
-        fgSetBool( "/controls/fuel-selector[1]", (fuel & 0x02) > 0 );
+        fgSetBool( "/controls/fuel/tank[0]/fuel-selector", (fuel & 0x01) > 0 );
+        fgSetBool( "/controls/fuel/tank[1]/fuel-selector", (fuel & 0x02) > 0 );
     }
 
     // circuit breakers
@@ -1864,7 +1872,7 @@ bool FGATC610x::do_switches() {
     fgSetBool( "/controls/circuit-breakers/annunciators", true );
 #endif
 
-    fgSetDouble( "/controls/parking-brake",
+    fgSetDouble( "/controls/gear/parking-brake",
                  switch_matrix[board][7][3] );
     fgSetDouble( "/radios/marker-beacon/power-btn",
                  switch_matrix[board][6][1] );