]> git.mxchange.org Git - flightgear.git/commitdiff
Begin interfacing with the electrical model.
authorcurt <curt>
Thu, 26 Sep 2002 04:45:45 +0000 (04:45 +0000)
committercurt <curt>
Thu, 26 Sep 2002 04:45:45 +0000 (04:45 +0000)
src/Network/atc610x.cxx
src/Network/atc610x.hxx
src/Network/raw_ctrls.hxx

index 65b70125bfd299906fc2fb1f75cff90cd1b19d0b..e70c0eff469c741a7787bf60a41d0f1b1e43c757 100644 (file)
@@ -398,8 +398,13 @@ bool FGATC610x::open() {
     dme_kt = fgGetNode( "/radios/dme/speed-kt", true );
     dme_nm = fgGetNode( "/radios/dme/distance-nm", true );
 
     dme_kt = fgGetNode( "/radios/dme/speed-kt", true );
     dme_nm = fgGetNode( "/radios/dme/distance-nm", true );
 
-    navcom1_power = fgGetNode( "/radios/comm[0]/inputs/power-btn", true );
-    navcom2_power = fgGetNode( "/radios/comm[1]/inputs/power-btn", true );
+    navcom1_bus_power = fgGetNode( "/systems/electrical/outputs/navcomm[0]",
+                                   true );
+    navcom2_bus_power = fgGetNode( "/systems/electrical/outputs/navcomm[1]",
+                                   true );
+
+    navcom1_power_btn = fgGetNode( "/radios/comm[0]/inputs/power-btn", true );
+    navcom2_power_btn = fgGetNode( "/radios/comm[1]/inputs/power-btn", true );
 
     com1_freq = fgGetNode( "/radios/comm[0]/frequencies/selected-mhz", true );
     com1_stby_freq
 
     com1_freq = fgGetNode( "/radios/comm[0]/frequencies/selected-mhz", true );
     com1_stby_freq
@@ -674,7 +679,7 @@ bool FGATC610x::do_radio_switches() {
     fgSetBool( "/radios/comm[0]/inputs/power-btn",
                radio_switch_data[7] & 0x01 );
 
     fgSetBool( "/radios/comm[0]/inputs/power-btn",
                radio_switch_data[7] & 0x01 );
 
-    if ( navcom1_power->getBoolValue() ) {
+    if ( navcom1_has_power() ) {
         // Com1 Swap
         int com1_swap = !((radio_switch_data[7] >> 1) & 0x01);
         static int last_com1_swap;
         // Com1 Swap
         int com1_swap = !((radio_switch_data[7] >> 1) & 0x01);
         static int last_com1_swap;
@@ -691,7 +696,7 @@ bool FGATC610x::do_radio_switches() {
     fgSetBool( "/radios/comm[1]/inputs/power-btn",
                radio_switch_data[15] & 0x01 );
 
     fgSetBool( "/radios/comm[1]/inputs/power-btn",
                radio_switch_data[15] & 0x01 );
 
-    if ( navcom2_power->getBoolValue() ) {
+    if ( navcom2_has_power() ) {
         // Com2 Swap
         int com2_swap = !((radio_switch_data[15] >> 1) & 0x01);
         static int last_com2_swap;
         // Com2 Swap
         int com2_swap = !((radio_switch_data[15] >> 1) & 0x01);
         static int last_com2_swap;
@@ -704,7 +709,7 @@ bool FGATC610x::do_radio_switches() {
         last_com2_swap = com2_swap;
     }
 
         last_com2_swap = com2_swap;
     }
 
-    if ( navcom1_power->getBoolValue() ) {
+    if ( navcom1_has_power() ) {
         // Nav1 Swap
         int nav1_swap = radio_switch_data[11] & 0x01;
         static int last_nav1_swap;
         // Nav1 Swap
         int nav1_swap = radio_switch_data[11] & 0x01;
         static int last_nav1_swap;
@@ -717,7 +722,7 @@ bool FGATC610x::do_radio_switches() {
         last_nav1_swap = nav1_swap;
     }
 
         last_nav1_swap = nav1_swap;
     }
 
-    if ( navcom2_power->getBoolValue() ) {
+    if ( navcom2_has_power() ) {
         // Nav2 Swap
         int nav2_swap = !(radio_switch_data[19] & 0x01);
         static int last_nav2_swap;
         // Nav2 Swap
         int nav2_swap = !(radio_switch_data[19] & 0x01);
         static int last_nav2_swap;
@@ -730,7 +735,7 @@ bool FGATC610x::do_radio_switches() {
         last_nav2_swap = nav2_swap;
     }
 
         last_nav2_swap = nav2_swap;
     }
 
-    if ( navcom1_power->getBoolValue() ) {
+    if ( navcom1_has_power() ) {
         // Com1 Tuner
         int com1_tuner_fine = ((radio_switch_data[5] >> 4) & 0x0f) - 1;
         int com1_tuner_coarse = (radio_switch_data[5] & 0x0f) - 1;
         // Com1 Tuner
         int com1_tuner_fine = ((radio_switch_data[5] >> 4) & 0x0f) - 1;
         int com1_tuner_coarse = (radio_switch_data[5] & 0x0f) - 1;
@@ -782,7 +787,7 @@ bool FGATC610x::do_radio_switches() {
                     coarse_freq + fine_freq / 40.0 );
     }
 
                     coarse_freq + fine_freq / 40.0 );
     }
 
-    if ( navcom2_power->getBoolValue() ) {
+    if ( navcom2_has_power() ) {
         // Com2 Tuner
         int com2_tuner_fine = ((radio_switch_data[13] >> 4) & 0x0f) - 1;
         int com2_tuner_coarse = (radio_switch_data[13] & 0x0f) - 1;
         // Com2 Tuner
         int com2_tuner_fine = ((radio_switch_data[13] >> 4) & 0x0f) - 1;
         int com2_tuner_coarse = (radio_switch_data[13] & 0x0f) - 1;
@@ -834,7 +839,7 @@ bool FGATC610x::do_radio_switches() {
                     coarse_freq + fine_freq / 40.0 );
     }
 
                     coarse_freq + fine_freq / 40.0 );
     }
 
-    if ( navcom1_power->getBoolValue() ) {
+    if ( navcom1_has_power() ) {
         // Nav1 Tuner
         int nav1_tuner_fine = ((radio_switch_data[9] >> 4) & 0x0f) - 1;
         int nav1_tuner_coarse = (radio_switch_data[9] & 0x0f) - 1;
         // Nav1 Tuner
         int nav1_tuner_fine = ((radio_switch_data[9] >> 4) & 0x0f) - 1;
         int nav1_tuner_coarse = (radio_switch_data[9] & 0x0f) - 1;
@@ -886,7 +891,7 @@ bool FGATC610x::do_radio_switches() {
                     coarse_freq + fine_freq / 20.0 );
     }
 
                     coarse_freq + fine_freq / 20.0 );
     }
 
-    if ( navcom2_power->getBoolValue() ) {
+    if ( navcom2_has_power() ) {
         // Nav2 Tuner
         int nav2_tuner_fine = ((radio_switch_data[17] >> 4) & 0x0f) - 1;
         int nav2_tuner_coarse = (radio_switch_data[17] & 0x0f) - 1;
         // Nav2 Tuner
         int nav2_tuner_fine = ((radio_switch_data[17] >> 4) & 0x0f) - 1;
         int nav2_tuner_coarse = (radio_switch_data[17] & 0x0f) - 1;
@@ -1152,7 +1157,7 @@ bool FGATC610x::do_radio_display() {
        }
     }
 
        }
     }
 
-    if ( navcom1_power->getBoolValue() ) {
+    if ( navcom1_has_power() ) {
         // Com1 standby frequency
         float com1_stby = com1_stby_freq->getFloatValue();
         if ( fabs(com1_stby) > 999.99 ) {
         // Com1 standby frequency
         float com1_stby = com1_stby_freq->getFloatValue();
         if ( fabs(com1_stby) > 999.99 ) {
@@ -1189,7 +1194,7 @@ bool FGATC610x::do_radio_display() {
         radio_display_data[11] = 0xff;
     }
 
         radio_display_data[11] = 0xff;
     }
 
-    if ( navcom2_power->getBoolValue() ) {
+    if ( navcom2_has_power() ) {
         // Com2 standby frequency
         float com2_stby = com2_stby_freq->getFloatValue();
         if ( fabs(com2_stby) > 999.99 ) {
         // Com2 standby frequency
         float com2_stby = com2_stby_freq->getFloatValue();
         if ( fabs(com2_stby) > 999.99 ) {
@@ -1226,7 +1231,7 @@ bool FGATC610x::do_radio_display() {
         radio_display_data[23] = 0xff;
     }
 
         radio_display_data[23] = 0xff;
     }
 
-    if ( navcom1_power->getBoolValue() ) {
+    if ( navcom1_has_power() ) {
         // Nav1 standby frequency
         float nav1_stby = nav1_stby_freq->getFloatValue();
         if ( fabs(nav1_stby) > 999.99 ) {
         // Nav1 standby frequency
         float nav1_stby = nav1_stby_freq->getFloatValue();
         if ( fabs(nav1_stby) > 999.99 ) {
@@ -1263,7 +1268,7 @@ bool FGATC610x::do_radio_display() {
         radio_display_data[17] = 0xff;
     }
 
         radio_display_data[17] = 0xff;
     }
 
-    if ( navcom2_power->getBoolValue() ) {
+    if ( navcom2_has_power() ) {
         // Nav2 standby frequency
         float nav2_stby = nav2_stby_freq->getFloatValue();
         if ( fabs(nav2_stby) > 999.99 ) {
         // Nav2 standby frequency
         float nav2_stby = nav2_stby_freq->getFloatValue();
         if ( fabs(nav2_stby) > 999.99 ) {
@@ -1537,11 +1542,11 @@ bool FGATC610x::do_switches() {
 
     // other toggle switches
     fgSetBool( "/controls/fuel-pump[0]", switch_matrix[board][0][2] );
 
     // other toggle switches
     fgSetBool( "/controls/fuel-pump[0]", switch_matrix[board][0][2] );
-    fgSetBool( "/controls/switches/landing-light", switch_matrix[board][1][2] );
     fgSetBool( "/controls/switches/flashing-beacon",
     fgSetBool( "/controls/switches/flashing-beacon",
-               switch_matrix[board][2][2] );
-    fgSetBool( "/controls/switches/map-lights", switch_matrix[board][3][2] );
-    fgSetBool( "/controls/switches/instrument-lights",
+               switch_matrix[board][1][2] );
+    fgSetBool( "/controls/switches/landing-light", switch_matrix[board][2][2] );
+    fgSetBool( "/controls/switches/taxi-lights", switch_matrix[board][3][2] );
+    fgSetBool( "/controls/switches/nav-lights",
                switch_matrix[board][4][2] );
     fgSetBool( "/controls/switches/strobe-lights", switch_matrix[board][5][2] );
     fgSetBool( "/controls/switches/pitot-heat", switch_matrix[board][6][2] );
                switch_matrix[board][4][2] );
     fgSetBool( "/controls/switches/strobe-lights", switch_matrix[board][5][2] );
     fgSetBool( "/controls/switches/pitot-heat", switch_matrix[board][6][2] );
index 256398a12f9df2c152b42433a9c8c60fcbe1841f..f3561f24493e9409eb1b7b71ada9e2f1572031bd 100644 (file)
@@ -73,7 +73,8 @@ class FGATC610x : public FGProtocol {
 
     SGPropertyNode *mag_compass;
     SGPropertyNode *dme_min, *dme_kt, *dme_nm;
 
     SGPropertyNode *mag_compass;
     SGPropertyNode *dme_min, *dme_kt, *dme_nm;
-    SGPropertyNode *navcom1_power, *navcom2_power;
+    SGPropertyNode *navcom1_bus_power, *navcom2_bus_power;
+    SGPropertyNode *navcom1_power_btn, *navcom2_power_btn;
     SGPropertyNode *com1_freq, *com1_stby_freq;
     SGPropertyNode *com2_freq, *com2_stby_freq;
     SGPropertyNode *nav1_freq, *nav1_stby_freq;
     SGPropertyNode *com1_freq, *com1_stby_freq;
     SGPropertyNode *com2_freq, *com2_stby_freq;
     SGPropertyNode *nav1_freq, *nav1_stby_freq;
@@ -111,6 +112,16 @@ class FGATC610x : public FGProtocol {
     bool do_steppers();
     bool do_switches();
 
     bool do_steppers();
     bool do_switches();
 
+    // convenience
+    inline bool navcom1_has_power() const {
+        return (navcom1_bus_power->getDoubleValue() > 1.0)
+            && navcom1_power_btn->getBoolValue();
+    }
+    inline bool navcom2_has_power() const {
+        return (navcom2_bus_power->getDoubleValue() > 1.0)
+            && navcom2_power_btn->getBoolValue();
+    }
+
 public:
 
     FGATC610x() { }
 public:
 
     FGATC610x() { }
index 5b7e29f45f77539adcb7f9cca386a9bf8572dc70..69bb3968327b60f6b91f5d373fefca33cce11f72 100644 (file)
@@ -30,7 +30,7 @@
 # error This library requires C++
 #endif                                   
 
 # error This library requires C++
 #endif                                   
 
-const int FG_RAW_CTRLS_VERSION = 10;
+const int FG_RAW_CTRLS_VERSION = 11;
 
 
 // Define a structure containing the control parameters
 
 
 // Define a structure containing the control parameters
@@ -53,14 +53,15 @@ public:
     double elevator_trim;               // -1 ... 1
     double rudder;                      // -1 ... 1
     double flaps;                       //  0 ... 1
     double elevator_trim;               // -1 ... 1
     double rudder;                      // -1 ... 1
     double flaps;                       //  0 ... 1
+    bool flaps_power;                    //  true = power available
 
     // Engine controls
     int num_engines;                    // number of valid engines
     int magnetos[FG_MAX_ENGINES];
 
     // Engine controls
     int num_engines;                    // number of valid engines
     int magnetos[FG_MAX_ENGINES];
-    bool starter[FG_MAX_ENGINES];        // true = starter engauged
+    bool starter_power[FG_MAX_ENGINES];  // true = starter power
     double throttle[FG_MAX_ENGINES];     //  0 ... 1
     double mixture[FG_MAX_ENGINES];      //  0 ... 1
     double throttle[FG_MAX_ENGINES];     //  0 ... 1
     double mixture[FG_MAX_ENGINES];      //  0 ... 1
-    bool fuel_pump[FG_MAX_ENGINES];      // true = on
+    bool fuel_pump_power[FG_MAX_ENGINES];// true = on
     double prop_advance[FG_MAX_ENGINES]; //  0 ... 1
 
     // Fuel management
     double prop_advance[FG_MAX_ENGINES]; //  0 ... 1
 
     // Fuel management