Пример #1
0
// ***************** IAS Button and light ******************
void process_ias_button()
{

    if (loaded737 == 1) {
         if (multires > 0) {
             if (testbit(multibuf, IAS_BUTTON)) {
                 if (xpanelsfnbutton == 1) {
                     XPLMCommandOnce(x737mcp_spd_changeover);
                 }
                 if (xpanelsfnbutton == 0) {
                     XPLMCommandOnce(x737mcp_lvlchange_toggle);
                     lastappos = 1;
                 }
             }
         }

         // Always match x737 glareshield LED
         switch (XPLMGetDatai(x737mcp_lvlchange_led)) {
             case 1:
                 btnleds |= (1<<3);
                 break;
             case 0:
                 btnleds &= ~(1<<3);
                 break;
         }
     } else {
        if (multires > 0) {
          if(testbit(multibuf,IAS_BUTTON)) {
            if(xpanelsfnbutton == 1) {
                 if (XPLMGetDatai(AirspeedIsMach) == 1) {
                     XPLMSetDatai(AirspeedIsMach, 0);
                 } else {
                     XPLMSetDatai(AirspeedIsMach, 1);
                 }
             }
             if(xpanelsfnbutton == 0) {
                 XPLMCommandOnce(ApIasBtn);
                 lastappos = 1;
             }

          }
        }
        switch(XPLMGetDatai(ApIasStat)){
          case 2:
            btnleds |= (1<<3);   // * set bit 3 in btnleds to 1 *
            break;
          case 1:
            if (flashon == 1) {
              btnleds |= (1<<3);   // * set bit 3 in btnleds to 1 *
            }
            if (flashon == 0) {
              btnleds &= ~(1<<3);   // * clear bit 3 in btnleds to 0 *
            }
            break;
          case 0:
            btnleds &= ~(1<<3);   // * clear bit 3 in btnleds to 0 *
            break;
        }
    }
}
Пример #2
0
// ***************** HDG Button and light *******************
void process_hdg_button()
{

    if (loaded737 == 1) {
        if (multires > 0) {
            if (testbit(multibuf, HDG_BUTTON)) {
                XPLMCommandOnce(x737mcp_hdg_toggle);
                lastappos = 1;
            }
        }

        // Always match x737 glareshield LED
        switch (XPLMGetDatai(x737mcp_hdg_led)) {
            case 1:
                btnleds |= (1<<1);
                break;
            case 0:
                btnleds &= ~(1<<1);
                break;
        }
    } else {
        if (multires > 0) {
          if(testbit(multibuf,HDG_BUTTON)) {

            if(xpanelsfnbutton == 1) {
                rhdgf = XPLMGetDataf(MHdg);
                XPLMSetDataf(ApHdg, rhdgf);
            }
            if(xpanelsfnbutton == 0) {
                XPLMCommandOnce(ApHdgBtn);
                lastappos = 1;
            }
          }
        }
        
        switch(XPLMGetDatai(ApHdgStat)){
          case 2:
            btnleds |= (1<<1);   // * set bit 1 in btnleds to 1 *
            break;
          case 1:
            if (flashon == 1) {
              btnleds |= (1<<1);   // * set bit 1 in btnleds to 1 *
	    }else{   
              btnleds &= ~(1<<1);   // * clear bit 1 in btnleds to 0 *
	    }
            break;
          case 0:
            btnleds &= ~(1<<1);   // * clear bit 1 in btnleds to 0 *
            break;
        }
	if (XPLMGetDatai(ApMstrStat) == 0) {
          btnleds &= ~(1<<1);   // * clear bit 1 in btnleds to 0 *
	}
    }
}
Пример #3
0
// ***************** REV Button and light *******************
void process_rev_button()
{
    if (revbuttonremap == 1) {
        if (multires > 0) {
          if(testbit(multibuf,REV_BUTTON)) {
            XPLMCommandOnce(RevButtonRemapableCmd);
            lastappos = 1;
          }
        }
	switch(XPLMGetDatai(ApRevStat)){
	  case 2:
            btnleds |= (1<<7);   // * set bit 7 in btnleds to 1 *
            break;
          case 1:
	    if (flashon == 1) {
              btnleds |= (1<<7);   // * set bit 7 in btnleds to 1 *
	    }else{    
              btnleds &= ~(1<<7);   // * clear bit 7 in btnleds to 0 *
	    }
            break;
          case 0:
            btnleds &= ~(1<<7);   // * clear bit 7 in btnleds to 0 *
            break;
	} 
    } else {

        if (multires > 0) {
          if(testbit(multibuf,REV_BUTTON)) {
            XPLMCommandOnce(ApRevBtn);
            lastappos = 1;
          }
        }
        switch(XPLMGetDatai(ApRevStat)){
          case 2:
            btnleds |= (1<<7);   // * set bit 7 in btnleds to 1 *
            break;
          case 1:
            if (flashon == 1) {
              btnleds |= (1<<7);   // * set bit 7 in btnleds to 1 *
            }else{
              btnleds &= ~(1<<7);   // * clear bit 7 in btnleds to 0 *
            }
            break;
          case 0:
            btnleds &= ~(1<<7);   // * clear bit 7 in btnleds to 0 *
            break;
        }

    }

}
Пример #4
0
// ***************** VS Button and light *******************
void process_vs_button()
{

    if (loaded737 == 1) {
        if (multires > 0) {
            if (testbit(multibuf, VS_BUTTON)) {
                XPLMCommandOnce(x737mcp_vs_toggle);
                lastappos = 1;
            }
        }
        switch (XPLMGetDatai(x737mcp_vvi_led)) {
            case 1:
                btnleds |= (1<<5);
                break;
            case 0:
                if (XPLMGetDatai(x737mcp_vvi_armed_led)) {
                    if (flashon == 0) {
                        btnleds |= (1<<5);
                    } else {
                        btnleds &= ~(1<<5);
                    }
                } else {
                    btnleds &= ~(1<<5);
                }
                break;
        }
    } else {
        if (multires > 0) {
          if(testbit(multibuf,VS_BUTTON)) {
            XPLMCommandOnce(ApVsBtn);
            lastappos = 1;
          }
        }
	switch(XPLMGetDatai(ApVsStat)){
	  case 2:
            btnleds |= (1<<5);   // * set bit 5 in btnleds to 1 *
            break;
          case 1:
	    if (flashon == 0) {
              btnleds |= (1<<5);   // * set bit 5 in btnleds to 1 *
	    }else{   
              btnleds &= ~(1<<5);   // * clear bit 5 in btnleds to 0 *
	    }
            break;
          case 0:
            btnleds &= ~(1<<5);   // * clear bit 5 in btnleds to 0 *
            break;
        }
    }
}
Пример #5
0
// ***************** Flaps Switch *******************
void process_flaps_switch()
{
    if (XPLMGetDatai(BatPwrOn) == 1) {

        if (multires > 0) {
	  if(testbit(multibuf,FLAPS_UP_SWITCH)) {
	    XPLMCommandOnce(FlapsUp);	 
          }
	  if(testbit(multibuf,FLAPS_DN_SWITCH)) {
	    XPLMCommandOnce(FlapsDn);	 
	  }
        }
   }
}
Пример #6
0
// ***************** ALT Button and light *******************
void process_alt_button()
{

    if (loaded737 == 1) {
        if (multires > 0) {
            if (testbit(multibuf, ALT_BUTTON)) {
                XPLMCommandOnce(x737mcp_alt_toggle);
                lastappos = 1;
            }
        }

        // Always match x737 glareshield LED
        switch (XPLMGetDatai(x737mcp_alt_led)) {
            case 1:
                btnleds |= (1<<4);
                break;
            case 0:
                btnleds &= ~(1<<4);
                break;
        }
    } else {
        if (multires > 0) {
          if(testbit(multibuf,ALT_BUTTON)) {
           XPLMCommandOnce(ApAltBtn);
           lastappos = 1;
          }
        }
	switch(XPLMGetDatai(ApAltStat)){
	  case 2:
            btnleds |= (1<<4);   // * set bit 4 in btnleds to 1 *
            break;
          case 1:
	    if (flashon == 1) {
              btnleds |= (1<<4);   // * set bit 4 in btnleds to 1 *
	    }else{    
              btnleds &= ~(1<<4);   // * clear bit 4 in btnleds to 0 *
	    }
            break;
          case 0:
            btnleds &= ~(1<<4);   // * clear bit 4 in btnleds to 0 *
            break;
	} 
	
	if (XPLMGetDatai(ApMstrStat) == 0) {
          btnleds &= ~(1<<4);   // * clear bit 4 in btnleds to 0 *
	}
    }
}
Пример #7
0
// *************** Trim Wheel *********************
void process_trim_wheel()
{

  int i;
        if (multires > 0) {
	  if(testbit(multibuf,TRIM_WHEEL_UP)) {
	    for(i = 0; i < trimspeed; ++i){
              XPLMCommandOnce(PitchTrimUp);
	    }
	  }	
	  if(testbit(multibuf,TRIM_WHEEL_DN)) {
	    for(i = 0; i < trimspeed; ++i){
              XPLMCommandOnce(PitchTrimDn);
            }
	  }
	}
}
Пример #8
0
void Command::perform(std::string command) {

  if (ptr == NULL) return;
	
	if (!command.empty()) {
		if (strncmp(command.c_str(),ser_code.c_str(),ser_code.size()) == 0) {
		XPLMCommandOnce(ptr);
		}
	}


}
Пример #9
0
// ***************** NAV Button and light *******************
void process_nav_button()
{

    if (loaded737 == 1) {
        if (multires > 0) {
            if (testbit(multibuf, NAV_BUTTON)) {
                switch (XPLMGetDatai(HsiSelector)) {
                    case 0:
                    case 1:
                        XPLMCommandOnce(x737mcp_vorloc_toggle);
                        break;
                    case 2:
                        XPLMCommandOnce(x737mcp_lnav_toggle);
                        break;
                }
                lastappos = 1;
            }
        }

        switch (XPLMGetDatai(HsiSelector)) {
            case 0:
            case 1:
                // Use LED to match power state
                switch (XPLMGetDatai(x737mcp_vorloc_led)) {
                    case 1:
                        btnleds |= (1<<2);
                        break;
                    case 0:
                        // Although x737 LED has no armed status, the PFD does
                        if (XPLMGetDatai(x737mcp_vorloc_armed)) {
                            if (flashon == 1) {
                                btnleds |= (1<<2);
                            } else {
                                btnleds &= ~(1<<2);
                            }
                        } else {
                            btnleds &= ~(1<<2);
                        }
                        break;
                }
                break;
            case 2:
                switch (XPLMGetDatai(x737mcp_lnav)) {
                    case 1:
                        btnleds |= (1<<2);
                        break;
                    case 0:
                        if (XPLMGetDatai(x737mcp_lnav_armed)) {
                            if (flashon == 1) {
                                btnleds |= (1<<2);
                            } else {
                                btnleds &= ~(1<<2);
                            }
                        } else {
                            btnleds &= ~(1<<2);
                        }
                        break;
                }
                break;
        }

    } else if (navbuttonremap == 1){
        if (multires > 0) {
          if(testbit(multibuf,NAV_BUTTON)) {
             XPLMCommandOnce(NavButtonRemapableCmd);
             lastappos = 1;
          }
        }

        switch(XPLMGetDatai(ApNavStat)){
          case 2:
            btnleds |= (1<<2);   // * set bit 2 in btnleds to 1 *
            break;
          case 1:
            if (flashon == 1) {
              btnleds |= (1<<2);   // * set bit 1 in btnleds to 1 *
            }else{
              btnleds &= ~(1<<2);   // * clear bit 2 in btnleds to 0 *
            }
            break;
          case 0:
            btnleds &= ~(1<<2);   // * clear bit 2 in btnleds to 0 *
            break;
        }


    } else {
        if (multires > 0) {
          if(testbit(multibuf,NAV_BUTTON)) {
            if(xpanelsfnbutton == 1) {
                xpanelscrstoggle = !xpanelscrstoggle;
            }
            if(xpanelsfnbutton == 0) {
                XPLMCommandOnce(ApNavBtn);
                lastappos = 1;
            }

          }
        }

	switch(XPLMGetDatai(ApNavStat)){
	  case 2:
            btnleds |= (1<<2);   // * set bit 2 in btnleds to 1 *
            break;
          case 1:
	    if (flashon == 1) {
              btnleds |= (1<<2);   // * set bit 1 in btnleds to 1 *
	    }else{
              btnleds &= ~(1<<2);   // * clear bit 2 in btnleds to 0 *
	    }
	    break;
	  case 0:
            btnleds &= ~(1<<2);   // * clear bit 2 in btnleds to 0 *
	    break;
	}
   }




}
Пример #10
0
// ***************** AP Master Button and light *******************
void process_ap_master_switch()
{

    if (loaded737 == 1) {
        if (appushed == 0) {
            if (testbit(multibuf, AP_MASTER_BUTTON)) {
                XPLMCommandOnce(x737mcp_cmd_a_toggle);
                appushed = 1;
                lastappos = 1;
            }
        }

        if (appushed == 1){
           aploop++;
            if (aploop == 50){
               appushed = 0;
               aploop = 0;
            }

        }

        switch (XPLMGetDatai(x737mcp_cmd_a_led)) {
            case 0:
                btnleds &= ~(1<<0);
                break;
            case 1:
                btnleds |= (1<<0);
                break;
        }
    } else {
        if (appushed == 0) {
          switch(XPLMGetDatai(ApMstrStat)){
            case 0:
             if(testbit(multibuf, AP_MASTER_BUTTON)) {
                XPLMSetDatai(ApMstrStat, 1);
                appushed = 1;
                lastappos = 1;
              }
              break;
            case 1:
             if(testbit(multibuf, AP_MASTER_BUTTON)) {
                 if (lastappos == 1){
                   XPLMSetDatai(ApMstrStat, 2);
                   appushed = 1;
                 }
                 if (lastappos == 2){
                     XPLMSetDatai(ApMstrStat, 0);
                     appushed = 1;
                 }
              }
              break;
            case 2:
              if(testbit(multibuf, AP_MASTER_BUTTON)) {
                 XPLMSetDatai(ApMstrStat, 1);
                 appushed = 1;
                 lastappos = 2;
              }
              break;
          }
        }

        if (appushed == 1){
           aploop++;
            if (aploop == 50){
               appushed = 0;
               aploop = 0;
            }

        }
        
        switch(XPLMGetDatai(ApMstrStat)){
          case 0:
            btnleds &= ~(1<<0);   // * clear bit 0 in btnleds to 0 *
            break;
          case 1:
	    if (flashon == 1) {
              btnleds |= (1<<0);   // * set bit 0 in btnleds to 1 *
	    }else{   
              btnleds &= ~(1<<0);   // * clear bit 0 in btnleds to 0 *
	    }
            break;
          case 2:
            btnleds |= (1<<0);   // * set bit 0 in btnleds to 1 *
            break;
        }
    }
}
Пример #11
0
int sp_process(uint32_t msg) {
    //sprintf(tmp, "-> CP: sp_controller.sp_process: msg: %d\n", msg);
	//XPLMDebugString(tmp);
	int res = 0;
    gEngineKnob = msg & SP_READ_ENGINES_KNOB_MASK;
    uint32_t landingGearUp = msg & SP_READ_GEARLEVER_UP_MASK;
    uint32_t landingGearDown = msg & SP_READ_GEARLEVER_DOWN_MASK;
    uint32_t lightsLanding = msg & SP_READ_LIGHTS_LANDING_MASK;
    uint32_t lightsTaxi = msg & SP_READ_LIGHTS_TAXI_MASK;
    uint32_t lightsStrobe = msg & SP_READ_LIGHTS_STROBE_MASK;
    uint32_t lightsNav = msg & SP_READ_LIGHTS_NAV_MASK;
    uint32_t lightsBeacon = msg & SP_READ_LIGHTS_BEACON_MASK;
    uint32_t lightsPanel = msg & SP_READ_LIGHTS_PANEL_MASK;
    uint32_t cowl = msg & SP_READ_COWL_MASK;
    uint32_t pitot = msg & SP_READ_PITOT_HEAT_MASK;
    uint32_t deice = msg & SP_READ_DE_ICE_MASK;
    uint32_t fuelPump = msg & SP_READ_FUEL_PUMP_MASK;
    uint32_t avionicsMaster = msg & SP_READ_AVIONICS_MASTER_MASK;
    uint32_t masterBattery = msg & SP_READ_MASTER_BAT_MASK;
    uint32_t masterAltBattery = msg & SP_READ_MASTER_ALT_MASK;

    if (gEngineKnob) {
    	gEngineKnobState = gEngineKnob;
    	sp_process_knob(gEngineKnob);
    }
    if (landingGearUp) {
    	gSpGearSwitchUp = 1;
    	XPLMCommandOnce(gSpLandingGearUpCmdRef);
    } else if (landingGearDown) {
    	gSpGearSwitchUp = 0;
    	XPLMCommandOnce(gSpLandingGearDownCmdRef);
    }

    if (lightsLanding) {
    	XPLMCommandOnce(gSpLightsLandingOnCmdRef);
    } else {
    	XPLMCommandOnce(gSpLightsLandingOffCmdRef);
    }
    if (lightsTaxi) {
    	XPLMCommandOnce(gSpLightsTaxiOnCmdRef);
    } else {
    	XPLMCommandOnce(gSpLightsTaxiOffCmdRef);
    }
    if (lightsPanel) {
    	XPLMSetDataf(gSpCockpitLightsDataRef, 1);
    } else {
    	XPLMSetDataf(gSpCockpitLightsDataRef, 0);
    }
    if (lightsBeacon) {
    	XPLMCommandOnce(gSpLightsBeaconOnCmdRef);
    } else {
    	XPLMCommandOnce(gSpLightsBeaconOffCmdRef);
    }
    if (lightsNav) {
    	XPLMCommandOnce(gSpLightsNavOnCmdRef);
    } else {
    	XPLMCommandOnce(gSpLightsNavOffCmdRef);
    }
    if (lightsStrobe) {
    	XPLMCommandOnce(gSpLightsStrobeOnCmdRef);
    } else {
    	XPLMCommandOnce(gSpLightsStrobeOffCmdRef);
    }
    if (masterBattery) {
    	if (gSpNumberOfBatteries == 1) {
    		gSpBatArrayOn[0] = 1;
    	} else if (gSpNumberOfBatteries == 2) {
    		gSpBatArrayOn[0] = 1;
    		gSpBatArrayOn[1] = 1;
    	} else if (gSpNumberOfBatteries == 3) {
    		gSpBatArrayOn[0] = 1;
    		gSpBatArrayOn[1] = 1;
    		gSpBatArrayOn[2] = 1;
    	} else if (gSpNumberOfBatteries == 4) {
    		gSpBatArrayOn[0] = 1;
    		gSpBatArrayOn[1] = 1;
    		gSpBatArrayOn[2] = 1;
    		gSpBatArrayOn[3] = 1;
    	} else if (gSpNumberOfBatteries == 5) {
    		gSpBatArrayOn[0] = 1;
    		gSpBatArrayOn[1] = 1;
    		gSpBatArrayOn[2] = 1;
    		gSpBatArrayOn[3] = 1;
    		gSpBatArrayOn[4] = 1;
    	} else if (gSpNumberOfBatteries == 6) {
    		gSpBatArrayOn[0] = 1;
    		gSpBatArrayOn[1] = 1;
    		gSpBatArrayOn[2] = 1;
    		gSpBatArrayOn[3] = 1;
    		gSpBatArrayOn[4] = 1;
    		gSpBatArrayOn[5] = 1;
    	} else if (gSpNumberOfBatteries == 7) {
    		gSpBatArrayOn[0] = 1;
    		gSpBatArrayOn[1] = 1;
    		gSpBatArrayOn[2] = 1;
    		gSpBatArrayOn[3] = 1;
    		gSpBatArrayOn[4] = 1;
    		gSpBatArrayOn[5] = 1;
    		gSpBatArrayOn[6] = 1;
    	} else if (gSpNumberOfBatteries == 8) {
    		gSpBatArrayOn[0] = 1;
    		gSpBatArrayOn[1] = 1;
    		gSpBatArrayOn[2] = 1;
    		gSpBatArrayOn[3] = 1;
    		gSpBatArrayOn[4] = 1;
    		gSpBatArrayOn[5] = 1;
    		gSpBatArrayOn[6] = 1;
    		gSpBatArrayOn[7] = 1;
    	}
    	XPLMSetDatavi(gSpBatteryArrayOnDataRef, gSpBatArrayOn, 0, 8);
    } else {
    	if (gSpNumberOfBatteries == 1) {
    		gSpBatArrayOn[0] = 0;
    	} else if (gSpNumberOfBatteries == 2) {
    		gSpBatArrayOn[0] = 0;
    		gSpBatArrayOn[1] = 0;
    	} else if (gSpNumberOfBatteries == 3) {
    		gSpBatArrayOn[0] = 0;
    		gSpBatArrayOn[1] = 0;
    		gSpBatArrayOn[2] = 0;
    	} else if (gSpNumberOfBatteries == 4) {
    		gSpBatArrayOn[0] = 0;
    		gSpBatArrayOn[1] = 0;
    		gSpBatArrayOn[2] = 0;
    		gSpBatArrayOn[3] = 0;
    	} else if (gSpNumberOfBatteries == 5) {
    		gSpBatArrayOn[0] = 0;
    		gSpBatArrayOn[1] = 0;
    		gSpBatArrayOn[2] = 0;
    		gSpBatArrayOn[3] = 0;
    		gSpBatArrayOn[4] = 0;
    	} else if (gSpNumberOfBatteries == 6) {
    		gSpBatArrayOn[0] = 0;
    		gSpBatArrayOn[1] = 0;
    		gSpBatArrayOn[2] = 0;
    		gSpBatArrayOn[3] = 0;
    		gSpBatArrayOn[4] = 0;
    		gSpBatArrayOn[5] = 0;
    	} else if (gSpNumberOfBatteries == 7) {
    		gSpBatArrayOn[0] = 0;
    		gSpBatArrayOn[1] = 0;
    		gSpBatArrayOn[2] = 0;
    		gSpBatArrayOn[3] = 0;
    		gSpBatArrayOn[4] = 0;
    		gSpBatArrayOn[5] = 0;
    		gSpBatArrayOn[6] = 0;
    	} else if (gSpNumberOfBatteries == 8) {
    		gSpBatArrayOn[0] = 0;
    		gSpBatArrayOn[1] = 0;
    		gSpBatArrayOn[2] = 0;
    		gSpBatArrayOn[3] = 0;
    		gSpBatArrayOn[4] = 0;
    		gSpBatArrayOn[5] = 0;
    		gSpBatArrayOn[6] = 0;
    		gSpBatArrayOn[7] = 0;
    	}
    	XPLMSetDatavi(gSpBatteryArrayOnDataRef, gSpBatArrayOn, 0, 8);
    }
    if (masterAltBattery) {
    	XPLMCommandOnce(gSpMasterAltBatteryOnCmdRef);
    	if (gSpNumberOfGenerators == 1) {
        	XPLMCommandOnce(gSpGeneratorOn1CmdRef);
    	} else if (gSpNumberOfGenerators == 2) {
        	XPLMCommandOnce(gSpGeneratorOn1CmdRef);
        	XPLMCommandOnce(gSpGeneratorOn2CmdRef);
    	} else if (gSpNumberOfGenerators == 3) {
        	XPLMCommandOnce(gSpGeneratorOn1CmdRef);
        	XPLMCommandOnce(gSpGeneratorOn2CmdRef);
        	XPLMCommandOnce(gSpGeneratorOn3CmdRef);
    	} else if (gSpNumberOfGenerators == 4) {
        	XPLMCommandOnce(gSpGeneratorOn1CmdRef);
        	XPLMCommandOnce(gSpGeneratorOn2CmdRef);
        	XPLMCommandOnce(gSpGeneratorOn3CmdRef);
        	XPLMCommandOnce(gSpGeneratorOn4CmdRef);
    	}
    } else {
    	XPLMCommandOnce(gSpMasterAltBatteryOffCmdRef);
    	if (gSpNumberOfGenerators == 1) {
        	XPLMCommandOnce(gSpGeneratorOff1CmdRef);
    	} else if (gSpNumberOfGenerators == 2) {
        	XPLMCommandOnce(gSpGeneratorOff1CmdRef);
        	XPLMCommandOnce(gSpGeneratorOff2CmdRef);
    	} else if (gSpNumberOfGenerators == 3) {
        	XPLMCommandOnce(gSpGeneratorOff1CmdRef);
        	XPLMCommandOnce(gSpGeneratorOff2CmdRef);
        	XPLMCommandOnce(gSpGeneratorOff3CmdRef);
    	} else if (gSpNumberOfGenerators == 4) {
        	XPLMCommandOnce(gSpGeneratorOff1CmdRef);
        	XPLMCommandOnce(gSpGeneratorOff2CmdRef);
        	XPLMCommandOnce(gSpGeneratorOff3CmdRef);
        	XPLMCommandOnce(gSpGeneratorOff4CmdRef);
    	}
    }
    if (avionicsMaster) {
    	XPLMCommandOnce(gSpMasterAvionicsOnCmdRef);
    } else {
    	XPLMCommandOnce(gSpMasterAvionicsOffCmdRef);
    }
    if (fuelPump) {
    	if (gSpNumberOfEngines == 1) {
        	XPLMCommandOnce(gSpFuelPumpOn1CmdRef);
    	} else if (gSpNumberOfEngines == 2) {
        	XPLMCommandOnce(gSpFuelPumpOn1CmdRef);
        	XPLMCommandOnce(gSpFuelPumpOn2CmdRef);
    	} else if (gSpNumberOfEngines == 3) {
        	XPLMCommandOnce(gSpFuelPumpOn1CmdRef);
        	XPLMCommandOnce(gSpFuelPumpOn2CmdRef);
        	XPLMCommandOnce(gSpFuelPumpOn3CmdRef);
    	} else if (gSpNumberOfEngines == 4) {
        	XPLMCommandOnce(gSpFuelPumpOn1CmdRef);
        	XPLMCommandOnce(gSpFuelPumpOn2CmdRef);
        	XPLMCommandOnce(gSpFuelPumpOn3CmdRef);
        	XPLMCommandOnce(gSpFuelPumpOn4CmdRef);
    	}
    } else {
    	if (gSpNumberOfEngines == 1) {
        	XPLMCommandOnce(gSpFuelPumpOff1CmdRef);
    	} else if (gSpNumberOfEngines == 2) {
        	XPLMCommandOnce(gSpFuelPumpOff1CmdRef);
        	XPLMCommandOnce(gSpFuelPumpOff2CmdRef);
    	} else if (gSpNumberOfEngines == 3) {
        	XPLMCommandOnce(gSpFuelPumpOff1CmdRef);
        	XPLMCommandOnce(gSpFuelPumpOff2CmdRef);
        	XPLMCommandOnce(gSpFuelPumpOff3CmdRef);
    	} else if (gSpNumberOfEngines == 4) {
        	XPLMCommandOnce(gSpFuelPumpOff1CmdRef);
        	XPLMCommandOnce(gSpFuelPumpOff2CmdRef);
        	XPLMCommandOnce(gSpFuelPumpOff3CmdRef);
        	XPLMCommandOnce(gSpFuelPumpOff4CmdRef);
    	}
    }
    if (deice) {
    	XPLMSetDatai(gSpAntiIceDataRef, 1);
    } else {
    	XPLMSetDatai(gSpAntiIceDataRef, 0);
    }
    if (pitot) {
    	XPLMCommandOnce(gSpPitotHeatOnCmdRef);
    } else {
    	XPLMCommandOnce(gSpPitotHeatOffCmdRef);
    }
    if (cowl) {
    	if (gSpNumberOfEngines == 1) {
    		gSpOpencowl[0] = 1;
    	} else if (gSpNumberOfEngines == 2) {
    		gSpOpencowl[0] = 1;
    		gSpOpencowl[1] = 1;
    	} else if (gSpNumberOfEngines == 3) {
    		gSpOpencowl[0] = 1;
    		gSpOpencowl[1] = 1;
    		gSpOpencowl[2] = 1;
    	} else if (gSpNumberOfEngines == 4) {
    		gSpOpencowl[0] = 1;
    		gSpOpencowl[1] = 1;
    		gSpOpencowl[2] = 1;
    		gSpOpencowl[3] = 1;
    	}
    	XPLMSetDatavf(gSpCowlFlapsDataRef, gSpOpencowl, 0, 8);
    } else {
    	if (gSpNumberOfEngines == 1) {
    		gSpClosecowl[0] = 1;
    	} else if (gSpNumberOfEngines == 2) {
    		gSpClosecowl[0] = 1;
    		gSpClosecowl[1] = 1;
    	} else if (gSpNumberOfEngines == 3) {
    		gSpClosecowl[0] = 1;
    		gSpClosecowl[1] = 1;
    		gSpClosecowl[2] = 1;
    	} else if (gSpNumberOfEngines == 4) {
    		gSpClosecowl[0] = 1;
    		gSpClosecowl[1] = 1;
    		gSpClosecowl[2] = 1;
    		gSpClosecowl[3] = 1;
    	}
    	XPLMSetDatavf(gSpCowlFlapsDataRef, gSpClosecowl, 0, 8);
    }

    return res;
}
Пример #12
0
// ***************** IAS Switch Position *******************
void process_ias_switch()
{
   if (testbit(multibuf,IAS_SWITCH)) {
      multiseldis = 2;
      upapasf = XPLMGetDataf(ApAs);
      upapas = (int)(upapasf);
      if (testbit(multibuf,ADJUSTMENT_UP)) {
         iasdbncinc++;
         if (iasdbncinc > multispeed) {
            n = multimul;
            if (xpanelsfnbutton == 1) {
               if (loaded737 == 1) {
                  XPLMCommandOnce(x737mcp_spd_up_fast);
               } else {
                  while (n>0) {
                     if (XPLMGetDatai(AirspeedIsMach) == 1) {
                        XPLMSetDataf(Airspeed, XPLMGetDataf(Airspeed) + 0.01);
                     } else {
                        //XPLMCommandOnce(ApAsUp);
                        upapas = upapas + 1;
                     }
                     --n;
                  }
               }
               iasdbncinc = 0;
            }
            if (xpanelsfnbutton == 0) {
               if (loaded737 == 1) {
                  XPLMCommandOnce(x737mcp_spd_up);
               } else {
                  if (XPLMGetDatai(AirspeedIsMach) == 1) {
                     XPLMSetDataf(Airspeed, XPLMGetDataf(Airspeed) + 0.01);
                  } else {
                     //XPLMCommandOnce(ApAsUp);
                     upapas = upapas + 1;
                  }
               }
               iasdbncinc = 0;
            }
         }
      }
      if (testbit(multibuf,ADJUSTMENT_DN)) {
         iasdbncdec++;
         if (iasdbncdec > multispeed) {
            n = multimul;
            if (xpanelsfnbutton == 1) {
               if (loaded737 == 1) {
                  XPLMCommandOnce(x737mcp_spd_down_fast);
               } else {
                  while (n>0) {
                     if (XPLMGetDatai(AirspeedIsMach) == 1) {
                        XPLMSetDataf(Airspeed, XPLMGetDataf(Airspeed) - 0.01);
                     } else {
                        //XPLMCommandOnce(ApAsDn);
                        upapas = upapas - 1;
                     }
                     --n;
                  }
               }
               iasdbncdec = 0;
            }
            if (xpanelsfnbutton == 0) {
               if (loaded737 == 1) {
                  XPLMCommandOnce(x737mcp_spd_down);
               } else {
                  if (XPLMGetDatai(AirspeedIsMach) == 1) {
                     XPLMSetDataf(Airspeed, XPLMGetDataf(Airspeed) - 0.01);
                  } else {
                     //XPLMCommandOnce(ApAsDn);
                     upapas = upapas - 1;
                  }
               }
               iasdbncdec = 0;
            }
         }
      }
      upapasf = upapas;
      XPLMSetDataf(ApAs, upapasf);
      upapasf = XPLMGetDataf(ApAs);
      if (XPLMGetDatai(AirspeedIsMach) == 1) {
         upapasf = (upapasf * 100);
      }
      upapas = (int)(upapasf);
   }
}
Пример #13
0
// ***************** VS Switch Position *******************
void process_vs_switch()
{

   if(testbit(multibuf,VS_SWITCH)) {
      multiseldis = 1;
      upapvsf = XPLMGetDataf(ApVs);
      upapvs = (int)(upapvsf);
	  if(testbit(multibuf,ADJUSTMENT_UP)) {
         vsdbncinc++;
         if (vsdbncinc > multispeed) {
            n = multimul;
            if (xpanelsfnbutton == 1) {
               if (loaded737 == 1) {
                  XPLMCommandOnce(x737mcp_vvi_up_fast);
               } else {
                   while (n>0) {
                       //XPLMCommandOnce(ApVsUp);
                       upapvs = upapvs + 100;
                       --n;
                   }
                }
                vsdbncinc = 0;
            }

            if (xpanelsfnbutton == 0) {
               if (loaded737 == 1) {
                  XPLMCommandOnce(x737mcp_vvi_up);
               } else if (apvsupremap == 1) {
                  XPLMCommandOnce(ApVsUpRemapableCmd);
                } else {
                   //XPLMCommandOnce(ApVsUp);
                   upapvs = upapvs + 100;
                }
                vsdbncinc = 0;
            }
         }
	  }
	  if(testbit(multibuf,ADJUSTMENT_DN)) {
         vsdbncdec++;
         if (vsdbncdec > multispeed) {
            n = multimul;
            if(xpanelsfnbutton == 1) {
               if (loaded737 == 1) {
                  XPLMCommandOnce(x737mcp_vvi_down_fast);
               } else {
                   while (n>0) {
                      //XPLMCommandOnce(ApVsUp);
                      upapvs = upapvs - 100;
                      --n;
                   }
                }
            }
            vsdbncdec = 0;
            if(xpanelsfnbutton == 0) {
               if (loaded737 == 1){
                  XPLMCommandOnce(x737mcp_vvi_down);
               } else if (apvsdnremap == 1) {
                  XPLMCommandOnce(ApVsDnRemapableCmd);
               } else {
                  //XPLMCommandOnce(ApVsUp);
                  upapvs = upapvs - 100;
               }
               vsdbncdec = 0;
            }
         }
	  }
      upapvsf = upapvs;
      XPLMSetDataf(ApVs, upapvsf);
      upapaltf = XPLMGetDataf(ApAlt);
	  upapvsf = XPLMGetDataf(ApVs);
	  upapalt = (int)(upapaltf);
	  upapvs = (int)(upapvsf);
	  if (upapvs < 0){
	    upapvs = (upapvs * -1);
	    neg = 1;
      } else {
	    neg = 0;
	  }
   }
}
Пример #14
0
void *spRun(void *ptr_thread_data) {
	int inReportBytesCount = 0;

#if IBM
		Sleep(SLEEP_TIME * 3);
#else
		usleep(SLEEP_TIME * 3);
#endif

	sp_init();

	gPtrThreadData = (struct sp_thread_data *) ptr_thread_data;

	int result = sp_panel_open();
	if (result < 0) {
		XPLMDebugString("-> CP: sp_controller.spRun: shutdown thread.\n");
		pthread_exit(NULL);
		return 0;
	}
	XPLMDebugString("-> CP: sp_controller.spRun: panel opened.\n");

	last_mainloop_idle = sys_time_clock_get_time_usec();
	// while stop == 0 calculate position.
	while (gPtrThreadData->stop == 0) {
		long loop_start_time = sys_time_clock_get_time_usec();

		///////////////////////////////////////////////////////////////////////////
		/// Read panel for new messages. CRITICAL FAST 100 Hz functions
		///////////////////////////////////////////////////////////////////////////
		if (us_run_every(10000, COUNTER3, loop_start_time)) {
			// read/write board
			sp_led_update();
			inReportBytesCount = sp_panel_read_non_blocking(buf);
			if (inReportBytesCount > 0) {
				if (inReportBytesCount > 3) {
					sprintf(tmp, "-> CP: sp_controller.run: bytes in report %d: %#0x,%#0x,%#0x\n", inReportBytesCount, buf[2], buf[1], buf[0]);
					XPLMDebugString(tmp);
				}
				uint32_t msg = 0;
				msg += buf[2] << 16;
				msg += buf[1] << 8;
				msg += buf[0];
				sp_process(msg);
			}
		}
		///////////////////////////////////////////////////////////////////////////

		///////////////////////////////////////////////////////////////////////////
		/// Update Panel. CRITICAL 20 Hz functions:
		///////////////////////////////////////////////////////////////////////////
		if (us_run_every(50000, COUNTER4, loop_start_time)) {
			// Update local DataRefs.
			sp_update_datarefs();
			// update Panel.
			inReportBytesCount = sp_panel_read_non_blocking(buf);
			if (inReportBytesCount > 0) {
				if (inReportBytesCount > 3) {
					sprintf(tmp, "-> CP: sp_controller.run: bytes in report %d: %#0x,%#0x,%#0x\n", inReportBytesCount, buf[2], buf[1], buf[0]);
					XPLMDebugString(tmp);
				}
				uint32_t msg = 0;
				msg += buf[2] << 16;
				msg += buf[1] << 8;
				msg += buf[0];
				sp_process(msg);
			}
		    if (gEngineKnobState == 0x020000) {
		    	// Start engine
		    	if (gSpNumberOfEngines == 1) {
					XPLMCommandOnce(gSpEngineStart1CmdRef);
		    	} else if (gSpNumberOfEngines == 2) {
					XPLMCommandOnce(gSpEngineStart1CmdRef);
					XPLMCommandOnce(gSpEngineStart2CmdRef);
		    	} else if (gSpNumberOfEngines == 3) {
					XPLMCommandOnce(gSpEngineStart1CmdRef);
					XPLMCommandOnce(gSpEngineStart2CmdRef);
					XPLMCommandOnce(gSpEngineStart3CmdRef);
		    	} else if (gSpNumberOfEngines == 4) {
					XPLMCommandOnce(gSpEngineStart1CmdRef);
					XPLMCommandOnce(gSpEngineStart2CmdRef);
					XPLMCommandOnce(gSpEngineStart3CmdRef);
					XPLMCommandOnce(gSpEngineStart4CmdRef);
		    	}
		    }
		    if (gSpGearRetract > 0) {
		    	if (gearledPrev != gearled) {
		    		gearledPrev = gearled;
			    	writeBuf[1] = gearled;
					sp_panel_write(writeBuf);
		    	}
		    }
		}
		///////////////////////////////////////////////////////////////////////////

		if (loop_start_time - last_mainloop_idle >= MAX_DELAY_TIME) {
			XPLMDebugString("-> CP: sp_controller.run: CRITICAL WARNING! CPU LOAD TOO HIGH.\n");
			last_mainloop_idle = loop_start_time;//reset to prevent multiple messages
		} else {
			//writeConsole(0, 0, "CPU LOAD OK.");
		}

		// wait 1 milliseconds
#if IBM
		Sleep(SLEEP_TIME * 3);
#else
		usleep(SLEEP_TIME * 3);
#endif
	}
	sp_panel_close();
#if IBM
		Sleep(SLEEP_TIME * 3);
#else
		usleep(SLEEP_TIME * 3);
#endif
	pthread_exit(NULL);
	return 0;
}
Пример #15
0
// ***************** APR Button and light *******************
void process_apr_button()
{

    if (loaded737 == 1) {
        if (multires > 0) {
            if (testbit(multibuf, APR_BUTTON)) {
                XPLMCommandOnce(x737mcp_app_toggle);
                lastappos = 1;
            }
        }

        // Always match x737 glareshield LED
        switch (XPLMGetDatai(x737mcp_app_led)) {
            case 1:
                btnleds |= (1<<6);
                break;
            case 0:
                btnleds &= ~(1<<6);
                break;
        }

    } else if (aprbuttonremap == 1){
        if (multires > 0) {
          if(testbit(multibuf,APR_BUTTON)) {
             XPLMCommandOnce(AprButtonRemapableCmd);
             lastappos = 1;
          }
        }
        switch(XPLMGetDatai(ApAprStat)){
          case 2:
            btnleds |= (1<<6);   // * set bit 6 in btnleds to 1 *
            break;
          case 1:
            if (flashon == 1) {
              btnleds |= (1<<6);   // * set bit 6 in btnleds to 1 *
            }else{
              btnleds &= ~(1<<6);   // * clear bit 6 in btnleds to 0 *
            }
            break;
          case 0:
            btnleds &= ~(1<<6);   // * clear bit 6 in btnleds to 0 *
            break;
        }

    } else {
        if (multires > 0) {
          if(testbit(multibuf,APR_BUTTON)) {
            if(xpanelsfnbutton == 1) {
                rhdgf = XPLMGetDataf(MHdg);
                XPLMSetDataf(ApCrs, rhdgf);
            }
            if(xpanelsfnbutton == 0) {
                XPLMCommandOnce(ApAprBtn);
                lastappos = 1;
            }
          }
        }
	switch(XPLMGetDatai(ApAprStat)){
	  case 2:
            btnleds |= (1<<6);   // * set bit 6 in btnleds to 1 *
            break;
          case 1:
	    if (flashon == 1) {
              btnleds |= (1<<6);   // * set bit 6 in btnleds to 1 *
	    }else{   
              btnleds &= ~(1<<6);   // * clear bit 6 in btnleds to 0 *
	    }
            break;
          case 0:
            btnleds &= ~(1<<6);   // * clear bit 6 in btnleds to 0 *
            break;
        }
    }
}
Пример #16
0
// ***************** HDG Switch Position *******************
void process_hdg_switch()
{


	if(testbit(multibuf,HDG_SWITCH)) {
          multiseldis = 3;
          upaphdgf = XPLMGetDataf(ApHdg);
          upaphdg = (int)(upaphdgf);
	  if(testbit(multibuf,ADJUSTMENT_UP)) {
	    hdgdbncinc++;
            if (hdgdbncinc > multispeed) {
                 if(xpanelsfnbutton == 1) {
                     if (loaded737 == 1) {
                         XPLMCommandOnce(x737mcp_hdg_up_fast);
                     } else {
                         upaphdg = upaphdg + multimul;
                     }
                     hdgdbncinc = 0;
                 }
                 if(xpanelsfnbutton == 0) {

                     if (loaded737 == 1) {
                         XPLMCommandOnce(x737mcp_hdg_up);
                     } else {
                         upaphdg = upaphdg + 1;
                     }
                     hdgdbncinc = 0;
                 }
	    }
	  }
	  if(testbit(multibuf,ADJUSTMENT_DN)) {
	    hdgdbncdec++;
            if (hdgdbncdec > multispeed) {
                if(xpanelsfnbutton == 1) {
                    if (loaded737 == 1) {
                        XPLMCommandOnce(x737mcp_hdg_down_fast);
                    } else {
                        upaphdg = upaphdg - multimul;
                    }
                    hdgdbncdec = 0;
                }
                if(xpanelsfnbutton == 0) {
                    if (loaded737 == 1) {
                        XPLMCommandOnce(x737mcp_hdg_down);
                    } else {
                        upaphdg = upaphdg - 1;
                    }
                    hdgdbncdec = 0;
                }
	    }
	  }

          if (loaded737 != 1) {
              if(upaphdg > 360){
                  upaphdg = 1;
              }
              if(upaphdg < 0){
                  upaphdg = 359;
              }
              upaphdgf = upaphdg;
              XPLMSetDataf(ApHdg, upaphdgf);

	}
    }
}
Пример #17
0
void sp_process_knob(uint32_t knobSelection) {
	switch (knobSelection) {
	case 0x002000:
		if (gSpNumberOfEngines == 1) {
			XPLMCommandOnce(gSpMagnetosOff1CmdRef);
		} else if (gSpNumberOfEngines == 2) {
			XPLMCommandOnce(gSpMagnetosOff1CmdRef);
			XPLMCommandOnce(gSpMagnetosOff2CmdRef);
		} else if (gSpNumberOfEngines == 3) {
			XPLMCommandOnce(gSpMagnetosOff1CmdRef);
			XPLMCommandOnce(gSpMagnetosOff2CmdRef);
			XPLMCommandOnce(gSpMagnetosOff3CmdRef);
		} else if (gSpNumberOfEngines == 4) {
			XPLMCommandOnce(gSpMagnetosOff1CmdRef);
			XPLMCommandOnce(gSpMagnetosOff2CmdRef);
			XPLMCommandOnce(gSpMagnetosOff3CmdRef);
			XPLMCommandOnce(gSpMagnetosOff4CmdRef);
		}
		break;
	case 0x004000:
		if (gSpNumberOfEngines == 1) {
			XPLMCommandOnce(gSpMagnetosRight1CmdRef);
		} else if (gSpNumberOfEngines == 2) {
			XPLMCommandOnce(gSpMagnetosOff1CmdRef);
			XPLMCommandOnce(gSpMagnetosRight2CmdRef);
		} else if (gSpNumberOfEngines == 3) {
			XPLMCommandOnce(gSpMagnetosOff1CmdRef);
			XPLMCommandOnce(gSpMagnetosRight2CmdRef);
			XPLMCommandOnce(gSpMagnetosRight3CmdRef);
		} else if (gSpNumberOfEngines == 4) {
			XPLMCommandOnce(gSpMagnetosOff1CmdRef);
			XPLMCommandOnce(gSpMagnetosOff2CmdRef);
			XPLMCommandOnce(gSpMagnetosRight3CmdRef);
			XPLMCommandOnce(gSpMagnetosRight4CmdRef);
		}
		break;
	case 0x008000:
		if (gSpNumberOfEngines == 1) {
			XPLMCommandOnce(gSpMagnetosLeft1CmdRef);
		} else if (gSpNumberOfEngines == 2) {
			XPLMCommandOnce(gSpMagnetosLeft1CmdRef);
			XPLMCommandOnce(gSpMagnetosOff2CmdRef);
		} else if (gSpNumberOfEngines == 3) {
			XPLMCommandOnce(gSpMagnetosLeft1CmdRef);
			XPLMCommandOnce(gSpMagnetosOff2CmdRef);
			XPLMCommandOnce(gSpMagnetosOff3CmdRef);
		} else if (gSpNumberOfEngines == 4) {
			XPLMCommandOnce(gSpMagnetosLeft1CmdRef);
			XPLMCommandOnce(gSpMagnetosLeft2CmdRef);
			XPLMCommandOnce(gSpMagnetosOff3CmdRef);
			XPLMCommandOnce(gSpMagnetosOff4CmdRef);
		}
		break;
	case 0x010000:
		if (gSpNumberOfEngines == 1) {
			XPLMCommandOnce(gSpMagnetosBoth1CmdRef);
		} else if (gSpNumberOfEngines == 2) {
			XPLMCommandOnce(gSpMagnetosBoth1CmdRef);
			XPLMCommandOnce(gSpMagnetosBoth2CmdRef);
		} else if (gSpNumberOfEngines == 3) {
			XPLMCommandOnce(gSpMagnetosBoth1CmdRef);
			XPLMCommandOnce(gSpMagnetosBoth2CmdRef);
			XPLMCommandOnce(gSpMagnetosBoth3CmdRef);
		} else if (gSpNumberOfEngines == 4) {
			XPLMCommandOnce(gSpMagnetosBoth1CmdRef);
			XPLMCommandOnce(gSpMagnetosBoth2CmdRef);
			XPLMCommandOnce(gSpMagnetosBoth3CmdRef);
			XPLMCommandOnce(gSpMagnetosBoth4CmdRef);
		}
		break;
	case 0x020000:
		if (gSpNumberOfEngines == 1) {
			XPLMCommandOnce(gSpEngineStart1CmdRef);
		} else if (gSpNumberOfEngines == 2) {
			XPLMCommandOnce(gSpEngineStart1CmdRef);
			XPLMCommandOnce(gSpEngineStart2CmdRef);
		} else if (gSpNumberOfEngines == 3) {
			XPLMCommandOnce(gSpEngineStart1CmdRef);
			XPLMCommandOnce(gSpEngineStart2CmdRef);
			XPLMCommandOnce(gSpEngineStart3CmdRef);
		} else if (gSpNumberOfEngines == 4) {
			XPLMCommandOnce(gSpEngineStart1CmdRef);
			XPLMCommandOnce(gSpEngineStart2CmdRef);
			XPLMCommandOnce(gSpEngineStart3CmdRef);
			XPLMCommandOnce(gSpEngineStart4CmdRef);
		}
		break;
	default:
		break;
	}
}