XPLMDataRef myXPLMFindDataRef(const char * inDataRefName) { XPLMDataRef DataRef=XPLMFindDataRef(inDataRefName); if (DataRef==NULL) { logMessageEx("*** Cannot find data reference [%s]", inDataRefName); } return DataRef; }
void GyroModel::setEQOff(){ if(XPlaneData->equalizer()==1) { float nav1=XPLMGetDataf(XPLMFindDataRef("sim/cockpit2/radios/actuators/nav1_obs_deg_mag_pilot")); float nav2=XPLMGetDataf(XPLMFindDataRef("sim/cockpit2/radios/actuators/nav2_obs_deg_mag_pilot")); if(nav2<nav1){ XPLMSetDataf(XPLMFindDataRef("sim/cockpit2/radios/actuators/nav2_obs_deg_mag_pilot"),XPLMGetDataf(XPLMFindDataRef("sim/cockpit2/radios/actuators/nav2_obs_deg_mag_pilot"))+0.5); } else { XPLMSetDataf(XPLMFindDataRef("sim/cockpit2/radios/actuators/nav2_obs_deg_mag_pilot"),XPLMGetDataf(XPLMFindDataRef("sim/cockpit2/radios/actuators/nav2_obs_deg_mag_pilot"))-0.5); } if(round(nav2)==round(nav1)) { XPlaneData->setEqualizerOff(); } } }
PLUGIN_API int XPluginStart( char * outName, char * outSig, char * outDesc) { strcpy(outName, "SDK210Tests"); strcpy(outSig, "sandybarbour.projects.SDK210Tests"); strcpy(outDesc, "A plug-in to test the new SDK210 API's."); // Register the callback for errors XPLMSetErrorCallback(SDK210TestsErrorCB); // Datarefs to get the aicraft position SDK210Tests_refx = XPLMFindDataRef("sim/flightmodel/position/local_x"); SDK210Tests_refy = XPLMFindDataRef("sim/flightmodel/position/local_y"); SDK210Tests_refz = XPLMFindDataRef("sim/flightmodel/position/local_z"); XPLMRegisterFlightLoopCallback(SDK210TestsMainLoopCB, 1.0, NULL); return 1; }
PLUGIN_API int XPluginStart( char * outName, char * outSig, char * outDesc) { char outputPath[255]; strcpy(outName, "TimedProcessing"); strcpy(outSig, "xplanesdk.examples.timedprocessing"); strcpy(outDesc, "A plugin that records sim data."); vis_amount = 5000; /* Open a file to write to. We locate the X-System directory * and then concatenate our file name. This makes us save in * the X-System directory. Open the file. */ XPLMGetSystemPath(outputPath); strcat(outputPath, "TimedProcessing.txt"); gOutputFile = fopen(outputPath, "w"); /* Find the data refs we want to record. */ gPlaneLat = XPLMFindDataRef("sim/flightmodel/position/latitude"); gPlaneLon = XPLMFindDataRef("sim/flightmodel/position/longitude"); gPlaneEl = XPLMFindDataRef("sim/flightmodel/position/elevation"); gPlaneVis = XPLMFindDataRef("sim/weather/visibility_reported_m"); /* Register our callback for once a second. Positive intervals * are in seconds, negative are the negative of sim frames. Zero * registers but does not schedule a callback for time. */ XPLMRegisterFlightLoopCallback( MyFlightLoopCallback, /* Callback */ 1.0, /* Interval */ NULL); /* refcon not used. */ return 1; }
// This routine draws the actual planes. int XPMPRenderMultiplayerPlanes( XPLMDrawingPhase inPhase, int inIsBefore, void * inRefcon) { static int is_blend = 0; static XPLMDataRef wrt = XPLMFindDataRef("sim/graphics/view/world_render_type"); static XPLMDataRef prt = XPLMFindDataRef("sim/graphics/view/plane_render_type"); int is_shadow = wrt != NULL && XPLMGetDatai(wrt) != 0; if(prt) is_blend = XPLMGetDatai(prt) == 2; if (gRenderer) gRenderer(is_shadow ? 0 : is_blend,gRendererRef); else XPMPDefaultPlaneRenderer(is_shadow ? 0 : is_blend); if(!is_shadow) is_blend = 1 - is_blend; return 1; }
float weather_callback ( float inElapsedSinceLastCall, float inElapsedTimeSinceLastFlightLoop, int inCounter, void * inRefcon) { XPLMDataRef visible_range; visible_range = XPLMFindDataRef("sim/weather/visibility_reported_m"); XPLMSetDataf(visible_range, plugin_weather_visibility); return 1.0; }
void Drawing::AddWaypoints(Waypoint points[], size_t numPoints) { if (numWaypoints + numPoints > WAYPOINT_MAX) { numPoints = WAYPOINT_MAX - numWaypoints; } size_t finalNumWaypoints = numPoints + numWaypoints; for (size_t i = 0; i < numPoints; ++i) { waypoints[numWaypoints + i] = points[i]; } numWaypoints = finalNumWaypoints; if (!routeEnabled) { XPLMRegisterDrawCallback(RouteDrawCallback, xplm_Phase_Objects, 0, NULL); } if (!planeXref) { planeXref = XPLMFindDataRef("sim/flightmodel/position/local_x"); planeYref = XPLMFindDataRef("sim/flightmodel/position/local_y"); planeZref = XPLMFindDataRef("sim/flightmodel/position/local_z"); } }
PLUGIN_API int XPluginEnable(void) { // Load the setup file on enable. This allows the user to modify the file without exit of XPlane SetupFile Setup; Setup.LoadSetupFile(ControlSurfaces, CommPortString, CommPortSpeed, OverString); // Open the setup file and parse it into the control surface list OpenComms(); SetupDefaultServoZeros(); // Setup the servo defaults. drOverRide = XPLMFindDataRef(OverString.data()); // Get the latest overide reference XPLMSetDatai(drOverRide, 1); // Overide from the setup file XPLMSetDatai(drThrOverRide, 1); memset(&CamPath, 0, sizeof(float) * 3 * CamPathLength); return 1; }
DataRef* XPlanePlugin::subscribeRef(QString name) { DEBUG << name; // Search in list of already subscribed datarefs - if found return that foreach(DataRef *ref, refs) { if(ref->name()==name) { DEBUG << "Already subscribed to " << name; ref->setSubscribers(ref->subscribers() + 1); return ref; } } // Not yet subscribed - create a new dataref XPLMDataRef ref = XPLMFindDataRef(name.toLatin1()); if(ref) { XPLMDataTypeID refType = XPLMGetDataRefTypes(ref); DataRef *dr = 0; if(refType & xplmType_Double) { dr = new DoubleDataRef(this, name, ref); } else if(refType & xplmType_Float) { dr = new FloatDataRef(this, name, ref); } else if(refType & xplmType_Int) { dr = new IntDataRef(this, name, ref); } else if (refType & xplmType_FloatArray) { dr = new FloatArrayDataRef(this, name, ref); } else if (refType & xplmType_IntArray) { dr = new IntArrayDataRef(this, name, ref); } else if (refType & xplmType_Data) { dr = new DataDataRef(this, name, ref); } if(dr) { dr->setSubscribers(1); dr->setWritable(XPLMCanWriteDataRef(ref) != 0); DEBUG << "Subscribed to ref " << dr->name() << ", type: " << dr->typeString() << ", writable:" << dr->isWritable(); refs.append(dr); return dr; } else { INFO << "Dataref type " << refType << "not supported"; } } else { INFO << "Can't find dataref " << name; } return 0; }
void process_multi_find_xplane_commands() { // ************ Find Multi Panel Commands Ref *************** ApAltDn = XPLMFindCommand("sim/autopilot/altitude_down"); ApAltUp = XPLMFindCommand("sim/autopilot/altitude_up"); ApVsDn = XPLMFindCommand("sim/autopilot/vertical_speed_down"); ApVsUp = XPLMFindCommand("sim/autopilot/vertical_speed_up"); ApAsDn = XPLMFindCommand("sim/autopilot/airspeed_down"); ApAsUp = XPLMFindCommand("sim/autopilot/airspeed_up"); ApHdgDn = XPLMFindCommand("sim/autopilot/heading_down"); ApHdgUp = XPLMFindCommand("sim/autopilot/heading_up"); ApCrsDn = XPLMFindCommand("sim/radios/obs1_down"); ApCrsUp = XPLMFindCommand("sim/radios/obs1_up"); ApCrsDn2 = XPLMFindCommand("sim/radios/obs2_down"); ApCrsUp2 = XPLMFindCommand("sim/radios/obs2_up"); ApMstrBtnUp = XPLMFindCommand("sim/autopilot/fdir_servos_up_one"); ApMstrBtnDn = XPLMFindCommand("sim/autopilot/fdir_servos_down_one"); ApMstrBtnOff = XPLMFindCommand("sim/autopilot/servos_and_flight_dir_off"); ApHdgBtn = XPLMFindCommand("sim/autopilot/heading"); ApNavBtn = XPLMFindCommand("sim/autopilot/NAV"); ApIasBtn = XPLMFindCommand("sim/autopilot/level_change"); ApAltBtn = XPLMFindCommand("sim/autopilot/altitude_hold"); ApAltArmBtn = XPLMFindCommand("sim/autopilot/altitude_arm"); ApVsBtn = XPLMFindCommand("sim/autopilot/vertical_speed"); ApAprBtn = XPLMFindCommand("sim/autopilot/approach"); ApRevBtn = XPLMFindCommand("sim/autopilot/back_course"); ApKnotsMachTgl = XPLMFindCommand("sim/autopilot/knots_mach_toggle"); PitchTrimDn = XPLMFindCommand("sim/flight_controls/pitch_trim_down"); PitchTrimUp = XPLMFindCommand("sim/flight_controls/pitch_trim_up"); PitchTrimTkOff = XPLMFindCommand("sim/flight_controls/pitch_trim_takeoff"); FlapsDn = XPLMFindCommand("sim/flight_controls/flaps_down"); FlapsUp = XPLMFindCommand("sim/flight_controls/flaps_up"); HsiSelector = XPLMFindDataRef("sim/cockpit/switches/HSI_selector"); return; }
PLUGIN_API int XPluginEnable(void) { PortNum = 0; pendingElapsedTime = 0; // Load the setup file on enable. This allows the user to modify the file without exit of XPlane SetupFile Setup; // Open the setup file and parse it into the control surface list Setup.LoadSetupFile(ControlSurfaces, CommPortString, CommPortSpeed, PortNum, OverString); // Don't attempt a conection until we're done starting up // AttemptConnection(); SetupDefaultServoZeros(); // Setup the servo defaults. drOverRide = XPLMFindDataRef(OverString.data()); // Get the latest overide reference XPLMSetDatai(drOverRide, 1); // Overide from the setup file XPLMSetDatai(drThrOverRide, 1); XPLMSetDatai(drBrakeOverRide, 1); memset(&CamPath, 0, sizeof(float) * 3 * CamPathLength); return 1; }
// Parse a Control string in the setup file void SetupFile::ParseControlString(string& ValueString, int Index, ChannelSetup* pSetup) { // string WriteStr; LoggingFile.mLogFile << Index; LoggingFile.mLogFile << ":"; LoggingFile.mLogFile << ValueString; LoggingFile.mLogFile << " "; switch (Index) { case DATAPOS_CONTROL_DATATYPE: pSetup->mControlType = CONTROL_TYPE_SURFACE; break; case DATAPOS_CONTROL_SERVO_CHAN: pSetup->mServoChannel = strtol(ValueString.data(), NULL, 10) - 1; break; case DATAPOS_CONTROL_IDENTITY: pSetup->mControlSurfaceRef = XPLMFindDataRef(ValueString.data()); break; case DATAPOS_CONTROL_SERVO_ZERO: pSetup->mChannelOffset = strtol(ValueString.data(), NULL, 10); break; case DATAPOS_CONTROL_SERVO_HI_TRAVEL: pSetup->mChannelHiTravel = strtol(ValueString.data(), NULL, 10); break; case DATAPOS_CONTROL_SERVO_LO_TRAVEL: pSetup->mChannelLoTravel = strtol(ValueString.data(), NULL, 10); break; case DATAPOS_CONTROL_SURFACE_MAX: pSetup->mMaxDeflection = (float)strtod(ValueString.data(), NULL); break; case DATAPOS_CONTROL_SURFACE_MIN: pSetup->mMinDeflection = (float)strtod(ValueString.data(), NULL); break; default: break; } }
/* * XPluginStart */ PLUGIN_API int XPluginStart( char * outName, char * outSig, char * outDesc) { int rc; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); /* Inform X-Plane about the plugin */ strcpy(outName, "AP Interface " VERSION); strcpy(outSig, COMPANY "." PACKAGE "." PLUGIN); strcpy(outDesc, "Interface for autopilot"); /* Create buffer for console */ lines = (char **) malloc (sizeof(char *) * LINECOUNT); for(int i = 0; i < LINECOUNT; i++) { lines[i] = (char *) calloc (256, sizeof(char)); } pthread_mutex_init(&lines_m, NULL); /* Create Main Window */ gWindow = XPLMCreateWindow( 50, /* left */ 900, /* top */ 300, /* right */ 800, /* bottom */ 1, /* visible */ MyDrawWindowCallback, /* draw callback */ MyHandleKeyCallback, /* key handling callback */ MyHandleMouseClickCallback, /* mouseclick handling callback */ NULL); indicated_airspeed2 = XPLMFindDataRef("sim/flightmodel/position/indicated_airspeed2"); if(indicated_airspeed2 != NULL) printMsg("Indicated Airspeed 2 initialized"); alpha = XPLMFindDataRef("sim/flightmodel/position/alpha"); if(alpha != NULL) printMsg("AOA initialized"); phi = XPLMFindDataRef("sim/flightmodel/position/phi"); if(phi != NULL) printMsg("Roll initialized"); magpsi = XPLMFindDataRef("sim/flightmodel/position/magpsi"); if(magpsi != NULL) printMsg("Magnetometer initialized"); theta = XPLMFindDataRef("sim/flightmodel/position/theta"); if(theta != NULL) printMsg("Pitch initialized"); elevation = XPLMFindDataRef("sim/flightmodel/position/elevation"); if(elevation != NULL) printMsg("Elevation initialized"); throttle_ref = XPLMFindDataRef("sim/flightmodel/engine/ENGN_thro"); if(throttle_ref != NULL) printMsg("Throttle initialized"); override = XPLMFindDataRef("sim/operation/override/override_control_surfaces");
gRpTransponderTensUpCmdRef = XPLMFindCommand(sRP_TRANSPONDER_TENS_UP_CR); gRpTransponderTensDownCmdRef = XPLMFindCommand(sRP_TRANSPONDER_TENS_DOWN_CR); gRpTransponderOnesUpCmdRef = XPLMFindCommand(sRP_TRANSPONDER_ONES_UP_CR); gRpTransponderOnesDownCmdRef = XPLMFindCommand(sRP_TRANSPONDER_ONES_DOWN_CR); gRpBarometerUpCmdRef = XPLMFindCommand(sRP_BAROMETER_UP_CR); gRpBarometerDownCmdRef = XPLMFindCommand(sRP_BAROMETER_DOWN_CR); gRpBarometer2992CmdRef = XPLMFindCommand(sRP_BAROMETER_2992_CR); gRpCOM1StandbyFlipCmdRef = XPLMFindCommand(sRP_COM1_STANDBY_FLIP_CR); gRpCOM2StandbyFlipCmdRef = XPLMFindCommand(sRP_COM2_STANDBY_FLIP_CR); gRpNAV1StandbyFlipCmdRef = XPLMFindCommand(sRP_NAV1_STANDBY_FLIP_CR); gRpNAV2StandbyFlipCmdRef = XPLMFindCommand(sRP_NAV2_STANDBY_FLIP_CR); gRpADF1StandbyFlipCmdRef = XPLMFindCommand(sRP_ADF1_STANDBY_FLIP_CR); gRpADF2StandbyFlipCmdRef = XPLMFindCommand(sRP_ADF2_STANDBY_FLIP_CR); /*----- RadioPanel Data Ref Assignment -----*/ gRpCOM1FreqHzDataRef = XPLMFindDataRef(sRP_COM1_FREQ_HZ_DR); gRpCOM2FreqHzDataRef = XPLMFindDataRef(sRP_COM2_FREQ_HZ_DR); gRpNAV1FreqHzDataRef = XPLMFindDataRef(sRP_NAV1_FREQ_HZ_DR); gRpNAV2FreqHzDataRef = XPLMFindDataRef(sRP_NAV2_FREQ_HZ_DR); gRpCOM1StdbyFreqHzDataRef = XPLMFindDataRef(sRP_COM1_STDBY_FREQ_HZ_DR); gRpCOM2StdbyFreqHzDataRef = XPLMFindDataRef(sRP_COM2_STDBY_FREQ_HZ_DR); gRpNAV1StdbyFreqHzDataRef = XPLMFindDataRef(sRP_NAV1_STDBY_FREQ_HZ_DR); gRpNAV2StdbyFreqHzDataRef = XPLMFindDataRef(sRP_NAV2_STDBY_FREQ_HZ_DR); gRpADF1StdbyFreqHzDataRef = XPLMFindDataRef(sRP_ADF1_STDBY_FREQ_HZ_DR); gRpADF2StdbyFreqHzDataRef = XPLMFindDataRef(sRP_ADF2_STDBY_FREQ_HZ_DR); gRpADF1FreqHzDataRef = XPLMFindDataRef(sRP_ADF1_FREQ_HZ_DR); gRpADF2FreqHzDataRef = XPLMFindDataRef(sRP_ADF2_FREQ_HZ_DR); gRpTransponderCodeDataRef = XPLMFindDataRef(sRP_TRANSPONDER_CODE_DR); gRpTransponderModeDataRef = XPLMFindDataRef(sRP_TRANSPONDER_MODE_DR); gRpBarometerSettingDataRef = XPLMFindDataRef(sRP_BAROMETER_SETTING_DR); gRpDMEDataRef = XPLMFindDataRef(sRP_DME_MODE_DR);
int htmlUniSet( char *header, char *html ){ header200OK_HTM( header ); char drefName[1024]; char drefType[4]; char drefValueFormatString[64]; parseQuerystringForString( "dref", drefName, 1024 ); parseQuerystringForString( "type", drefType, 4 ); XPLMDataRef tmpDr = XPLMFindDataRef( drefName ); switch( drefType[0] ){ case 'i': { int tmp = parseQuerystringForInt("val"); XPLMSetDatai( tmpDr, tmp ); sprintf( drefValueFormatString, "Int Value: (%i)<br/>\n", tmp ); } break; case 'f': { float tmp = parseQuerystringForFloat("val"); XPLMSetDataf( tmpDr, tmp ); sprintf( drefValueFormatString, "Float Value: (%f)<br/>\n", tmp ); } break; case 'c': { sprintf( drefValueFormatString, "String Value: (%s)<br/>\n", "foo" ); } break; } sprintf( html, //"Uni Set<br/>\n" "Dataref: (%s)<br/>\n" "Type: (%s)<br/>\n" "%s<br/>" //"<hr/>" //"<form action='/set' method='GET'>" // "dref: <input type='text' name='dref' value='%s'/><br/>" // "type: <input type='text' name='type' value='%s'/><br/>" // "val: <input type='text' name='val'/></br>" // "<input type='submit'/><br/>" //"</form>" , drefName, drefType, drefValueFormatString//, //drefName, //form field 1 //drefType //form field 2 ); return strlen( html ); }
void process_multi_find_xplane_datareference() { // **************** Find Multi Panel Data Ref ******************** ApAlt = XPLMFindDataRef("sim/cockpit/autopilot/altitude"); ApVs = XPLMFindDataRef("sim/cockpit/autopilot/vertical_velocity"); ApAs = XPLMFindDataRef("sim/cockpit/autopilot/airspeed"); ApHdg = XPLMFindDataRef("sim/cockpit/autopilot/heading_mag"); ApCrs = XPLMFindDataRef("sim/cockpit/radios/nav1_obs_degm"); ApCrs2 = XPLMFindDataRef("sim/cockpit/radios/nav2_obs_degm"); ApMstrStat = XPLMFindDataRef("sim/cockpit2/autopilot/flight_director_mode"); ApState = XPLMFindDataRef("sim/cockpit/autopilot/autopilot_state"); ApHdgStat = XPLMFindDataRef("sim/cockpit2/autopilot/heading_status"); ApNavStat = XPLMFindDataRef("sim/cockpit2/autopilot/nav_status"); ApIasStat = XPLMFindDataRef("sim/cockpit2/autopilot/speed_status"); ApAltStat = XPLMFindDataRef("sim/cockpit2/autopilot/altitude_hold_status"); ApVsStat = XPLMFindDataRef("sim/cockpit2/autopilot/vvi_status"); ApAprStat = XPLMFindDataRef("sim/cockpit2/autopilot/approach_status"); ApRevStat = XPLMFindDataRef("sim/cockpit2/autopilot/backcourse_status"); Frp = XPLMFindDataRef("sim/operation/misc/frame_rate_period"); MHdg = XPLMFindDataRef("sim/flightmodel/position/magpsi"); AirspeedIsMach = XPLMFindDataRef("sim/cockpit/autopilot/airspeed_is_mach"); Airspeed = XPLMFindDataRef("sim/cockpit/autopilot/airspeed"); ApAutThr = XPLMFindDataRef("sim/cockpit2/autopilot/autothrottle_enabled"); return; }
void process_switch_find_xplane_datareference() { // **************** Find Switch Panel Data Ref ******************* AntiIce = XPLMFindDataRef("sim/cockpit/switches/anti_ice_on"); CockpitLights = XPLMFindDataRef("sim/cockpit/electrical/cockpit_lights"); CowlFlaps = XPLMFindDataRef("sim/flightmodel/engine/ENGN_cowl"); GearRetract = XPLMFindDataRef("sim/aircraft/gear/acf_gear_retract"); LandingGearStatus = XPLMFindDataRef("sim/aircraft/parts/acf_gear_deploy"); Gear1Fail = XPLMFindDataRef("sim/operation/failures/rel_lagear1"); Gear2Fail = XPLMFindDataRef("sim/operation/failures/rel_lagear2"); Gear3Fail = XPLMFindDataRef("sim/operation/failures/rel_lagear3"); OnGround = XPLMFindDataRef("sim/flightmodel/failures/onground_any"); BatNum = XPLMFindDataRef("sim/aircraft/electrical/num_batteries"); GenNum = XPLMFindDataRef("sim/aircraft/electrical/num_generators"); EngNum = XPLMFindDataRef("sim/aircraft/engine/acf_num_engines"); BatArrayOnDR = XPLMFindDataRef("sim/cockpit/electrical/battery_array_on"); IgnSwitchArray = XPLMFindDataRef("sim/cockpit2/engine/actuators/ignition_key"); EngnMixt = XPLMFindDataRef("sim/flightmodel/engine/ENGN_mixt"); IgniterOn = XPLMFindDataRef("sim/cockpit2/engine/actuators/igniter_on"); AcfEnType = XPLMFindDataRef("sim/aircraft/prop/acf_en_type"); return; }
void DataRef::assign(const std::string name, const std::string ser_code) { //std::cerr << "LCDxpl: Called assign with " << name << ", " << ser_code << std::endl; this->ser_code = ser_code; ptr = XPLMFindDataRef(name.c_str()); changed = false; }
PLUGIN_API int XPluginStart(char* outName, char* outSig, char* outDesc) { szString[0] = '\0'; strcpy(outName, "UDB HILSIM"); strcpy(outSig, "UDB.HardwareInLoop"); strcpy(outDesc, "UDB Hardware-In-Loop Simulator"); // P, Q, and R are roll, pitch, and yaw rates, degrees per second, // in the NED coordinate system, in "flight" (not body) frame of reference drP = XPLMFindDataRef("sim/flightmodel/position/P"); drQ = XPLMFindDataRef("sim/flightmodel/position/Q"); drR = XPLMFindDataRef("sim/flightmodel/position/R"); // standard GPS lat, long, and elevation drLat = XPLMFindDataRef("sim/flightmodel/position/latitude"); drLon = XPLMFindDataRef("sim/flightmodel/position/longitude"); drElev = XPLMFindDataRef("sim/flightmodel/position/elevation"); // acceleration, meters/sec/sec, in OGL frame of reference // note: this is NOT the same as what the accelerometers read drLocal_ax = XPLMFindDataRef("sim/flightmodel/position/local_ax"); drLocal_ay = XPLMFindDataRef("sim/flightmodel/position/local_ay"); drLocal_az = XPLMFindDataRef("sim/flightmodel/position/local_az"); // velocity, meters/sec, in OGL frame of reference drLocal_vx = XPLMFindDataRef("sim/flightmodel/position/local_vx"); drLocal_vy = XPLMFindDataRef("sim/flightmodel/position/local_vy"); drLocal_vz = XPLMFindDataRef("sim/flightmodel/position/local_vz"); drLocalDays = XPLMFindDataRef("sim/time/local_date_days"); drLocalSecs = XPLMFindDataRef("sim/time/local_time_sec"); // 3D true airspeed, meters/second drAirSpeedTrue = XPLMFindDataRef("sim/flightmodel/position/true_airspeed"); // location in OGL frame drLocal_x = XPLMFindDataRef("sim/flightmodel/position/local_x"); drLocal_y = XPLMFindDataRef("sim/flightmodel/position/local_y"); drLocal_z = XPLMFindDataRef("sim/flightmodel/position/local_z"); // Euler roll, pitch, and yaw angles, degrees, using NED // + phi is roll to the right (CCW around NED_x) // + theta is pitch up (CCW around NED_y) // + psi is yaw to the right (CCW around NED_z) drPhi = XPLMFindDataRef("sim/flightmodel/position/phi"); drTheta = XPLMFindDataRef("sim/flightmodel/position/theta"); drPsi = XPLMFindDataRef("sim/flightmodel/position/psi"); // Euler angles of attack and sideslip, degrees, using NED // These are angles of body frame with respect to fight path // + alpha is pitch up (CCW around NED_y) // + beta is yaw right (CCW around NED_z) drAlpha = XPLMFindDataRef("sim/flightmodel/position/alpha"); drBeta = XPLMFindDataRef("sim/flightmodel/position/beta"); drThrOverRide = XPLMFindDataRef("sim/operation/override/override_throttles"); drPitchAxis = XPLMFindDataRef("sim/joystick/FC_ptch"); drRollAxis = XPLMFindDataRef("sim/joystick/FC_roll"); drYawAxis = XPLMFindDataRef("sim/joystick/FC_hdng"); drThro = XPLMFindDataRef("sim/flightmodel/engine/ENGN_thro_use"); // sim/operation/override/override_gearbrake int y boolean Override gear and brake staus // sim/flightmodel/controls/parkbrake float y ??? Parking Brake drBrakeOverRide = XPLMFindDataRef("sim/operation/override/override_gearbrake"); drBrake = XPLMFindDataRef("sim/flightmodel/controls/parkbrake"); // These are the values that the accelerometers read, in multiples of gravity // g_nrml is UDB_z // g_axil is UDB_y // g_side is UDB_x drg_nrml = XPLMFindDataRef("sim/flightmodel/forces/g_nrml"); drg_axil = XPLMFindDataRef("sim/flightmodel/forces/g_axil"); drg_side = XPLMFindDataRef("sim/flightmodel/forces/g_side"); fTextColour[0] = 1.0; fTextColour[1] = 1.0; fTextColour[2] = 1.0; XPLMRegisterFlightLoopCallback(GetBodyRates, 1.0, NULL); XPLMRegisterDrawCallback( DrawStrings, xplm_Phase_Window, // Draw when sim is doing objects 0, // After objects NULL); // No refcon needed // XPLMSetDatai(drOverRide, 1);// Now overide surfaces, not yaw, roll, pitch // Register our hot key for the new view gHotKey = XPLMRegisterHotKey( XPLM_VK_F8, xplm_DownFlag, "Circling External View", MyHotKeyCallback, NULL); XPLMRegisterDrawCallback( MyDrawCallback, xplm_Phase_Objects, // Draw when sim is doing objects 0, // After objects NULL); // No refcon needed XPLMRegisterKeySniffer( MyKeySniffer, // Our callback 1, // Receive input before plugin windows 0); // Refcon - not used memset(&CamPath, 0, sizeof(float) * 3 * CamPathLength); return 1; }
XPLMDataRef XPlaneInterface::findDataRefByName(char * datarefName) { return XPLMFindDataRef(datarefName); }
void GyroModel::addYawDeviation() { cageGyro.yaw = cageGyro.yaw+0.000111111; // 15p alatt 3 fok XPLMSetDataf(XPLMFindDataRef("sim/cockpit2/radios/actuators/nav2_obs_deg_mag_pilot"),XPLMGetDataf(XPLMFindDataRef("sim/cockpit2/radios/actuators/nav2_obs_deg_mag_pilot"))+0.000055555); // 30p alatt 3 fok }
PLUGIN_API int XPluginStart(char *outName, char *outSig, char *outDesc) { /* First set up our plugin info. */ strcpy(outName, "SmoothSailing 0.1"); strcpy(outSig, "Smooth Sailing by Colin Lieberman"); strcpy(outDesc, "Simple weather and visibility controls for convenience"); initConfig(); /* datarefs used for the transponder setting & checks to determine if i want to set it */ ref_xpndr_mode = XPLMFindDataRef("sim/cockpit/radios/transponder_mode"); ref_xpndr_setting = XPLMFindDataRef("sim/cockpit/radios/transponder_code"); ref_alt_agl = XPLMFindDataRef("sim/flightmodel/position/y_agl"); ref_grnd_spd = XPLMFindDataRef("sim/flightmodel/position/groundspeed"); /* dataref for visibility */ ref_visibility = XPLMFindDataRef("sim/weather/visibility_reported_m"); /* datarefs for cloud base */ ref_cloud_base0 = XPLMFindDataRef("sim/weather/cloud_base_msl_m[0]"); ref_cloud_base1 = XPLMFindDataRef("sim/weather/cloud_base_msl_m[1]"); ref_cloud_base2 = XPLMFindDataRef("sim/weather/cloud_base_msl_m[2]"); ref_cloud_tops0 = XPLMFindDataRef("sim/weather/cloud_tops_msl_m[0]"); ref_cloud_tops1 = XPLMFindDataRef("sim/weather/cloud_tops_msl_m[1]"); ref_cloud_tops2 = XPLMFindDataRef("sim/weather/cloud_tops_msl_m[2]"); ref_alt_msl = XPLMFindDataRef("sim/flightmodel/position/elevation"); /* datarefs for setting time */ ref_use_sys_time = XPLMFindDataRef("sim/time/use_system_time"); ref_local_time = XPLMFindDataRef("sim/time/local_time_sec"); ref_zulu_time = XPLMFindDataRef("sim/time/zulu_time_sec"); /* datarefs for wind */ ref_heading = XPLMFindDataRef("sim/flightmodel/position/psi"); ref_wind_speed0 = XPLMFindDataRef("sim/weather/wind_speed_kt[0]"); ref_wind_speed1 = XPLMFindDataRef("sim/weather/wind_speed_kt[1]"); ref_wind_speed2 = XPLMFindDataRef("sim/weather/wind_speed_kt[2]"); ref_wind_direction0 = XPLMFindDataRef("sim/weather/wind_direction_degt[0]"); ref_wind_direction1 = XPLMFindDataRef("sim/weather/wind_direction_degt[1]"); ref_wind_direction2 = XPLMFindDataRef("sim/weather/wind_direction_degt[2]"); ref_wind_altitude = XPLMFindDataRef("sim/weather/wind_altitude_msl_m[0]"); ref_wind_turb0 = XPLMFindDataRef("sim/weather/turbulence[0]"); if( DEBUG ) { debug_window = XPLMCreateWindow( 50, 600, 400, 200, /* Area of the window. */ 1, /* Start visible. */ MyDrawWindowCallback, /* Callbacks */ MyHandleKeyCallback, MyHandleMouseClickCallback, NULL); /* Refcon - not used. */ } // * Register our callback for every loop. Positive intervals // * are in seconds, negative are the negative of sim frames. Zero // * registers but does not schedule a callback for time. XPLMRegisterFlightLoopCallback( SmoothSailingCallback, // * Callback * CALLBACK_INTERVAL, // * Interval -1 every loop* NULL); // * refcon not used. * return 1; }
PLUGIN_API int XPluginStart( char * outName, char * outSig, char * outDesc) { strcpy(outName, "UDB HILSIM"); strcpy(outSig, "UDB.HardwareInLoop"); strcpy(outDesc, "UDB Hardware-In-Loop Simulator"); drP = XPLMFindDataRef("sim/flightmodel/position/P"); drQ = XPLMFindDataRef("sim/flightmodel/position/Q"); drR = XPLMFindDataRef("sim/flightmodel/position/R"); drLat = XPLMFindDataRef("sim/flightmodel/position/latitude"); drLon = XPLMFindDataRef("sim/flightmodel/position/longitude"); drElev = XPLMFindDataRef("sim/flightmodel/position/elevation"); drLocal_ax = XPLMFindDataRef("sim/flightmodel/position/local_ax"); drLocal_ay = XPLMFindDataRef("sim/flightmodel/position/local_ay"); drLocal_az = XPLMFindDataRef("sim/flightmodel/position/local_az"); drLocal_vx = XPLMFindDataRef("sim/flightmodel/position/local_vx"); drLocal_vy = XPLMFindDataRef("sim/flightmodel/position/local_vy"); drLocal_vz = XPLMFindDataRef("sim/flightmodel/position/local_vz"); drLocalDays = XPLMFindDataRef("sim/time/local_date_days"); drLocalSecs = XPLMFindDataRef("sim/time/local_time_sec"); drGroundSpeed = XPLMFindDataRef("sim/flightmodel/position/groundspeed"); drAirSpeedTrue = XPLMFindDataRef("sim/flightmodel/position/true_airspeed"); drHeading = XPLMFindDataRef("sim/flightmodel/position/psi"); drLocal_x = XPLMFindDataRef("sim/flightmodel/position/local_x"); drLocal_y = XPLMFindDataRef("sim/flightmodel/position/local_y"); drLocal_z = XPLMFindDataRef("sim/flightmodel/position/local_z"); drPhi = XPLMFindDataRef("sim/flightmodel/position/phi"); drTheta = XPLMFindDataRef("sim/flightmodel/position/theta"); drPsi = XPLMFindDataRef("sim/flightmodel/position/psi"); drAlpha = XPLMFindDataRef("sim/flightmodel/position/alpha"); drBeta = XPLMFindDataRef("sim/flightmodel/position/beta"); drThrOverRide = XPLMFindDataRef("sim/operation/override/override_throttles"); drPitchAxis = XPLMFindDataRef("sim/joystick/FC_ptch"); drRollAxis = XPLMFindDataRef("sim/joystick/FC_roll"); drYawAxis = XPLMFindDataRef("sim/joystick/FC_hdng"); drThro = XPLMFindDataRef("sim/flightmodel/engine/ENGN_thro_use"); fTextColour[0] = 1.0; fTextColour[1] = 1.0; fTextColour[2] = 1.0; XPLMRegisterFlightLoopCallback(GetBodyRates, 1.0, NULL); XPLMRegisterDrawCallback( DrawStrings, xplm_Phase_Window, /* Draw when sim is doing objects */ 0, /* After objects */ NULL); /* No refcon needed */ // XPLMSetDatai(drOverRide, 1); // Now overide surfaces, not yaw,roll,pitch /* Register our hot key for the new view. */ gHotKey = XPLMRegisterHotKey(XPLM_VK_F8, xplm_DownFlag, "Circling External View", MyHotKeyCallback, NULL); XPLMRegisterDrawCallback( MyDrawCallback, xplm_Phase_Objects, /* Draw when sim is doing objects */ 0, /* After objects */ NULL); /* No refcon needed */ memset(&CamPath, 0, sizeof(float) * 3 * CamPathLength); return 1; }
int dep_XPluginStart( char * outName, char * outSig, char * outDesc) { xpdr_Lat = XPLMFindDataRef("sim/flightmodel/position/latitude"); xpdr_Lon = XPLMFindDataRef("sim/flightmodel/position/longitude"); xpdr_AltMSL = XPLMFindDataRef("sim/flightmodel/position/elevation"); xpdr_AltAGL = XPLMFindDataRef("sim/flightmodel/position/y_agl"); xpdr_X = XPLMFindDataRef("sim/flightmodel/position/local_x"); xpdr_Y = XPLMFindDataRef("sim/flightmodel/position/local_y"); xpdr_Z = XPLMFindDataRef("sim/flightmodel/position/local_z"); xpdr_Heading = XPLMFindDataRef("sim/flightmodel/position/psi"); xpdr_HeadingMag = XPLMFindDataRef("sim/flightmodel/position/magpsi"); xpdr_HeadingTrack = XPLMFindDataRef("sim/flightmodel/position/hpath"); xpdr_Kias = XPLMFindDataRef("sim/flightmodel/position/indicated_airspeed"); //knots xpdr_Ktas = XPLMFindDataRef("sim/flightmodel/position/true_airspeed"); //mtrs/sec xpdr_Kgs = XPLMFindDataRef("sim/flightmodel/position/groundspeed"); //mtrs/sec xpdr_WindDirection = XPLMFindDataRef("sim/weather/wind_direction_degt"); //direction at acf xpdr_WindSpeed = XPLMFindDataRef("sim/weather/wind_speed_kt"); //speed at acf xpdr_Nav1 = XPLMFindDataRef("sim/cockpit/radios/nav1_freq_hz"); xpdr_Nav1s = XPLMFindDataRef("sim/cockpit/radios/nav1_stdby_freq_hz"); xpdr_Com1 = XPLMFindDataRef("sim/cockpit/radios/com1_freq_hz"); xpdr_Com1s = XPLMFindDataRef("sim/cockpit/radios/com1_stdby_freq_hz"); //misc-state.xml data refs. xpdr_windAltHigh = XPLMFindDataRef("sim/weather/wind_altitude_msl_m[2]"); xpdr_windSpeedHigh = XPLMFindDataRef("sim/weather/wind_speed_kt[2]"); xpdr_windDirHigh = XPLMFindDataRef("sim/weather/wind_direction_degt[2]"); xpdr_windSheerSpeedHigh = XPLMFindDataRef("sim/weather/shear_speed_kt[2]"); xpdr_windSheerDirectionHigh = XPLMFindDataRef("sim/weather/shear_direction_degt[2]"); xpdr_windTurbulenceHigh = XPLMFindDataRef("sim/weather/turbulence[2]"); xpdr_windAltMed = XPLMFindDataRef("sim/weather/wind_altitude_msl_m[1]"); xpdr_windSpeedMed = XPLMFindDataRef("sim/weather/wind_speed_kt[1]"); xpdr_windDirMed = XPLMFindDataRef("sim/weather/wind_direction_degt[1]"); xpdr_windSheerSpeedMed = XPLMFindDataRef("sim/weather/shear_speed_kt[1]"); xpdr_windSheerDirectionMed = XPLMFindDataRef("sim/weather/shear_direction_degt[1]"); xpdr_windTurbulenceMed = XPLMFindDataRef("sim/weather/turbulence[1]"); xpdr_windAltLow = XPLMFindDataRef("sim/weather/wind_altitude_msl_m[0]"); xpdr_windSpeedLow = XPLMFindDataRef("sim/weather/wind_speed_kt[0]"); xpdr_windDirLow = XPLMFindDataRef("sim/weather/wind_direction_degt[0]"); xpdr_windSheerSpeedLow = XPLMFindDataRef("sim/weather/shear_speed_kt[0]"); xpdr_windSheerDirectionLow = XPLMFindDataRef("sim/weather/shear_direction_degt[0]"); xpdr_windTurbulenceLow = XPLMFindDataRef("sim/weather/turbulence[0]"); //need to add the rest of the weather screen! return 1; }
void sendRepositionedAtAirport() { XPLMDebugString("XData: sendRepositionedAtAirport called.\n"); // where are we? float inLat; float inLon; XPLMDataRef dataref_latitude = XPLMFindDataRef("sim/flightmodel/position/latitude"); inLat = XPLMGetDataf(dataref_latitude); XPLMDataRef dataref_longitude = XPLMFindDataRef("sim/flightmodel/position/longitude"); inLon = XPLMGetDataf(dataref_longitude); XPLMNavRef navref = XPLMFindNavAid( NULL, NULL, &inLat, &inLon, NULL, xplm_Nav_Airport); float apt_lat; float apt_lon; float apt_height; char apt_id[32]; char apt_name[256]; XPLMGetNavAidInfo( navref, NULL, &apt_lat, &apt_lon, &apt_height, NULL, NULL, &apt_id, &apt_name, NULL); int i; int res; char msg[256]; sprintf(msg, "Repositioned at airport: %s (name: %s) height=%f lat=%f lon=%f\n", apt_id, apt_name, apt_height, apt_lat, apt_lon); XPLMDebugString(msg); // make endian corrections // COMMENTED OUT - THIS CRASHES X-PLANE. WHY? // apt_lat = custom_htonf(apt_lat); // apt_lon = custom_htonf(apt_lon); // apt_height = custom_htonf(apt_height); strncpy(airport_packet.apt_id, apt_id, 32); strncpy(airport_packet.apt_name, apt_name, 256); airport_packet.apt_height = apt_height; airport_packet.apt_lat = apt_lat; airport_packet.apt_lon = apt_lon; if (xdata_plugin_enabled && xdata_send_enabled && xdata_socket_open) { strncpy(airport_packet.packet_id, "RAPT", 4); for (i=0; i<NUM_DEST; i++) { if (dest_enable[i]) { res = sendto(sockfd, (const char*)&airport_packet, sizeof(airport_packet), 0, (struct sockaddr *)&dest_sockaddr[i], sizeof(struct sockaddr)); #if IBM if ( res == SOCKET_ERROR ) { XPLMDebugString("XData: caught error while sending RAPT packet! ("); sprintf(msg, "%d", WSAGetLastError()); XPLMDebugString(msg); XPLMDebugString(")\n"); } #else if ( res < 0 ) { XPLMDebugString("XData: caught error while sending RAPT packet! ("); XPLMDebugString((char * const) strerror(GET_ERRNO)); XPLMDebugString(")\n"); } #endif } } } }
void registerDataRefs() { XPLMDebugString("Registering datarefs\n"); dataref_acf_desc = XPLMFindDataRef("sim/aircraft/view/acf_descrip"); dataref_acf_tailnum = XPLMFindDataRef("sim/aircraft/view/acf_tailnum"); }
PLUGIN_API int XPluginStart( char * outName, char * outSig, char * outDesc) { int PluginSubMenuItem; int ChecklistsSubMenuItem; xcDebug("Xchecklist: ver " VERSION_NUMBER "\n"); /* First set up our plugin info. */ strcpy(outName, "Xchecklist ver " VERSION_NUMBER); strcpy(outSig, "Michal_Bill.Example.Xchecklist"); strcpy(outDesc, "A plugin to display checklists in a widget window."); ext_view = XPLMFindDataRef("sim/graphics/view/view_is_external"); // Create our menu PluginSubMenuItem = XPLMAppendMenuItem( XPLMFindPluginsMenu(), "Xchecklist", NULL, 1); PluginMenu = XPLMCreateMenu( "Xchecklist", XPLMFindPluginsMenu(), PluginSubMenuItem, xCheckListMenuHandler, (void *)0); XPLMAppendMenuItem(PluginMenu, "Open CheckList", (void *) "checklist", 1); XPLMAppendMenuItem(PluginMenu, "Open Setup", (void *) "setup", 1); ChecklistsSubMenuItem = XPLMAppendMenuItem( PluginMenu, "CheckLists", NULL, 1); checklistsMenu = XPLMCreateMenu( "CheckLists", PluginMenu, ChecklistsSubMenuItem, xCheckListMenuHandler, (void *)1); XPLMAppendMenuItem(checklistsMenu, "CheckList1", (void *) 0, 1); XPLMAppendMenuItem(checklistsMenu, "CheckList2", (void *) 1, 1); cmdcheckitem = XPLMCreateCommand("bgood/xchecklist/check_item","Check Item"); cmdnextchecklist = XPLMCreateCommand("bgood/xchecklist/next_checklist","Next Checklist"); cmdprevchecklist = XPLMCreateCommand("bgood/xchecklist/prev_checklist","Prev Checklist"); cmdhidechecklist = XPLMCreateCommand("bgood/xchecklist/hide_checklist","Hide Checklist"); XPLMRegisterCommandHandler( cmdcheckitem, MyCommandCallback, true, (void *)CHECK_ITEM_COMMAND); XPLMRegisterCommandHandler( cmdnextchecklist, MyCommandCallback, true, (void *)NEXT_CHECKLIST_COMMAND); XPLMRegisterCommandHandler( cmdprevchecklist, MyCommandCallback, true, (void *)PREV_CHECKLIST_COMMAND); XPLMRegisterCommandHandler( cmdhidechecklist, MyCommandCallback, true, (void *)HIDE_CHECKLIST_COMMAND); return 1; }
void sp_init() { // XPLMDebugString("-> CP: sp_controller.sp_init.\n"); gSpMagnetosOff1CmdRef = XPLMFindCommand(sSP_MAGNETOS_OFF_1_CR); gSpMagnetosOff2CmdRef = XPLMFindCommand(sSP_MAGNETOS_OFF_2_CR); gSpMagnetosOff3CmdRef = XPLMFindCommand(sSP_MAGNETOS_OFF_3_CR); gSpMagnetosOff4CmdRef = XPLMFindCommand(sSP_MAGNETOS_OFF_4_CR); gSpMagnetosOff5CmdRef = XPLMFindCommand(sSP_MAGNETOS_OFF_5_CR); gSpMagnetosOff6CmdRef = XPLMFindCommand(sSP_MAGNETOS_OFF_6_CR); gSpMagnetosOff7CmdRef = XPLMFindCommand(sSP_MAGNETOS_OFF_7_CR); gSpMagnetosOff8CmdRef = XPLMFindCommand(sSP_MAGNETOS_OFF_8_CR); gSpMagnetosRight1CmdRef = XPLMFindCommand(sSP_MAGNETOS_RIGHT_1_CR); gSpMagnetosRight2CmdRef = XPLMFindCommand(sSP_MAGNETOS_RIGHT_2_CR); gSpMagnetosRight3CmdRef = XPLMFindCommand(sSP_MAGNETOS_RIGHT_3_CR); gSpMagnetosRight4CmdRef = XPLMFindCommand(sSP_MAGNETOS_RIGHT_4_CR); gSpMagnetosRight5CmdRef = XPLMFindCommand(sSP_MAGNETOS_RIGHT_5_CR); gSpMagnetosRight6CmdRef = XPLMFindCommand(sSP_MAGNETOS_RIGHT_6_CR); gSpMagnetosRight7CmdRef = XPLMFindCommand(sSP_MAGNETOS_RIGHT_7_CR); gSpMagnetosRight8CmdRef = XPLMFindCommand(sSP_MAGNETOS_RIGHT_8_CR); gSpMagnetosLeft1CmdRef = XPLMFindCommand(sSP_MAGNETOS_LEFT_1_CR); gSpMagnetosLeft2CmdRef = XPLMFindCommand(sSP_MAGNETOS_LEFT_2_CR); gSpMagnetosLeft3CmdRef = XPLMFindCommand(sSP_MAGNETOS_LEFT_3_CR); gSpMagnetosLeft4CmdRef = XPLMFindCommand(sSP_MAGNETOS_LEFT_4_CR); gSpMagnetosLeft5CmdRef = XPLMFindCommand(sSP_MAGNETOS_LEFT_5_CR); gSpMagnetosLeft6CmdRef = XPLMFindCommand(sSP_MAGNETOS_LEFT_6_CR); gSpMagnetosLeft7CmdRef = XPLMFindCommand(sSP_MAGNETOS_LEFT_7_CR); gSpMagnetosLeft8CmdRef = XPLMFindCommand(sSP_MAGNETOS_LEFT_8_CR); gSpMagnetosBoth1CmdRef = XPLMFindCommand(sSP_MAGNETOS_BOTH_1_CR); gSpMagnetosBoth2CmdRef = XPLMFindCommand(sSP_MAGNETOS_BOTH_2_CR); gSpMagnetosBoth3CmdRef = XPLMFindCommand(sSP_MAGNETOS_BOTH_3_CR); gSpMagnetosBoth4CmdRef = XPLMFindCommand(sSP_MAGNETOS_BOTH_4_CR); gSpMagnetosBoth5CmdRef = XPLMFindCommand(sSP_MAGNETOS_BOTH_5_CR); gSpMagnetosBoth6CmdRef = XPLMFindCommand(sSP_MAGNETOS_BOTH_6_CR); gSpMagnetosBoth7CmdRef = XPLMFindCommand(sSP_MAGNETOS_BOTH_7_CR); gSpMagnetosBoth8CmdRef = XPLMFindCommand(sSP_MAGNETOS_BOTH_8_CR); gSpEngineStart1CmdRef = XPLMFindCommand(sSP_ENGINE_START_1_CR); gSpEngineStart2CmdRef = XPLMFindCommand(sSP_ENGINE_START_2_CR); gSpEngineStart3CmdRef = XPLMFindCommand(sSP_ENGINE_START_3_CR); gSpEngineStart4CmdRef = XPLMFindCommand(sSP_ENGINE_START_4_CR); gSpEngineStart5CmdRef = XPLMFindCommand(sSP_ENGINE_START_5_CR); gSpEngineStart6CmdRef = XPLMFindCommand(sSP_ENGINE_START_6_CR); gSpEngineStart7CmdRef = XPLMFindCommand(sSP_ENGINE_START_7_CR); gSpEngineStart8CmdRef = XPLMFindCommand(sSP_ENGINE_START_8_CR); // battery gSpMasterBatteryOnCmdRef = XPLMFindCommand(sSP_MASTER_BATTERY_ON_CR); gSpMasterBatteryOffCmdRef = XPLMFindCommand(sSP_MASTER_BATTERY_OFF_CR); gSpMasterAltBatteryOnCmdRef = XPLMFindCommand(sSP_MASTER_ALT_BATTERY_ON_CR); gSpMasterAltBatteryOffCmdRef = XPLMFindCommand(sSP_MASTER_ALT_BATTERY_OFF_CR); gSpGeneratorOn1CmdRef = XPLMFindCommand(sSP_GENERATOR_ON_1_CR); gSpGeneratorOff1CmdRef = XPLMFindCommand(sSP_GENERATOR_OFF_1_CR); gSpGeneratorOn2CmdRef = XPLMFindCommand(sSP_GENERATOR_ON_2_CR); gSpGeneratorOff2CmdRef = XPLMFindCommand(sSP_GENERATOR_OFF_2_CR); gSpGeneratorOn3CmdRef = XPLMFindCommand(sSP_GENERATOR_ON_3_CR); gSpGeneratorOff3CmdRef = XPLMFindCommand(sSP_GENERATOR_OFF_3_CR); gSpGeneratorOn4CmdRef = XPLMFindCommand(sSP_GENERATOR_ON_4_CR); gSpGeneratorOff4CmdRef = XPLMFindCommand(sSP_GENERATOR_OFF_4_CR); gSpGeneratorOn5CmdRef = XPLMFindCommand(sSP_GENERATOR_ON_5_CR); gSpGeneratorOff5CmdRef = XPLMFindCommand(sSP_GENERATOR_OFF_5_CR); gSpGeneratorOn6CmdRef = XPLMFindCommand(sSP_GENERATOR_ON_6_CR); gSpGeneratorOff6CmdRef = XPLMFindCommand(sSP_GENERATOR_OFF_6_CR); gSpGeneratorOn7CmdRef = XPLMFindCommand(sSP_GENERATOR_ON_7_CR); gSpGeneratorOff7CmdRef = XPLMFindCommand(sSP_GENERATOR_OFF_7_CR); gSpGeneratorOn8CmdRef = XPLMFindCommand(sSP_GENERATOR_ON_8_CR); gSpGeneratorOff8CmdRef = XPLMFindCommand(sSP_GENERATOR_OFF_8_CR); // various gSpMasterAvionicsOnCmdRef = XPLMFindCommand(sSP_MASTER_AVIONICS_ON_CR); gSpMasterAvionicsOffCmdRef = XPLMFindCommand(sSP_MASTER_AVIONICS_OFF_CR); gSpFuelPumpOn1CmdRef = XPLMFindCommand(sSP_FUEL_PUMP_ON_1_CR); gSpFuelPumpOff1CmdRef = XPLMFindCommand(sSP_FUEL_PUMP_OFF_1_CR); gSpFuelPumpOn2CmdRef = XPLMFindCommand(sSP_FUEL_PUMP_ON_2_CR); gSpFuelPumpOff2CmdRef = XPLMFindCommand(sSP_FUEL_PUMP_OFF_2_CR); gSpFuelPumpOn3CmdRef = XPLMFindCommand(sSP_FUEL_PUMP_ON_3_CR); gSpFuelPumpOff3CmdRef = XPLMFindCommand(sSP_FUEL_PUMP_OFF_3_CR); gSpFuelPumpOn4CmdRef = XPLMFindCommand(sSP_FUEL_PUMP_ON_4_CR); gSpFuelPumpOff4CmdRef = XPLMFindCommand(sSP_FUEL_PUMP_OFF_4_CR); gSpFuelPumpOn5CmdRef = XPLMFindCommand(sSP_FUEL_PUMP_ON_5_CR); gSpFuelPumpOff5CmdRef = XPLMFindCommand(sSP_FUEL_PUMP_OFF_5_CR); gSpFuelPumpOn6CmdRef = XPLMFindCommand(sSP_FUEL_PUMP_ON_6_CR); gSpFuelPumpOff6CmdRef = XPLMFindCommand(sSP_FUEL_PUMP_OFF_6_CR); gSpFuelPumpOn7CmdRef = XPLMFindCommand(sSP_FUEL_PUMP_ON_7_CR); gSpFuelPumpOff7CmdRef = XPLMFindCommand(sSP_FUEL_PUMP_OFF_7_CR); gSpFuelPumpOn8CmdRef = XPLMFindCommand(sSP_FUEL_PUMP_ON_8_CR); gSpFuelPumpOff8CmdRef = XPLMFindCommand(sSP_FUEL_PUMP_OFF_8_CR); gSpDeIceOnCmdRef = XPLMFindCommand(sSP_DE_ICE_ON_CR); gSpDeIceOffCmdRef = XPLMFindCommand(sSP_DE_ICE_OFF_CR); gSpPitotHeatOnCmdRef = XPLMFindCommand(sSP_PITOT_HEAT_ON_CR); gSpPitotHeatOffCmdRef = XPLMFindCommand(sSP_PITOT_HEAT_OFF_CR); gSpCowlClosedCmdRef = XPLMFindCommand(sSP_COWL_CLOSED_CR); gSpCowlOpenCmdRef = XPLMFindCommand(sSP_COWL_OPEN_CR); // lights gSpLightsPanelOnCmdRef = XPLMFindCommand(sSP_LIGHTS_PANEL_ON_CR); gSpLightsPanelOffCmdRef = XPLMFindCommand(sSP_LIGHTS_PANEL_OFF_CR); gSpLightsBeaconOnCmdRef = XPLMFindCommand(sSP_LIGHTS_BEACON_ON_CR); gSpLightsBeaconOffCmdRef = XPLMFindCommand(sSP_LIGHTS_BEACON_OFF_CR); gSpLightsNavOnCmdRef = XPLMFindCommand(sSP_LIGHTS_NAV_ON_CR); gSpLightsNavOffCmdRef = XPLMFindCommand(sSP_LIGHTS_NAV_OFF_CR); gSpLightsStrobeOnCmdRef = XPLMFindCommand(sSP_LIGHTS_STROBE_ON_CR); gSpLightsStrobeOffCmdRef = XPLMFindCommand(sSP_LIGHTS_STROBE_OFF_CR); gSpLightsTaxiOnCmdRef = XPLMFindCommand(sSP_LIGHTS_TAXI_ON_CR); gSpLightsTaxiOffCmdRef = XPLMFindCommand(sSP_LIGHTS_TAXI_OFF_CR); gSpLightsLandingOnCmdRef = XPLMFindCommand(sSP_LIGHTS_LANDING_ON_CR); gSpLightsLandingOffCmdRef = XPLMFindCommand(sSP_LIGHTS_LANDING_OFF_CR); // landing gear gSpLandingGearUpCmdRef = XPLMFindCommand(sSP_LANDING_GEAR_UP_CR); gSpLandingGearDownCmdRef = XPLMFindCommand(sSP_LANDING_GEAR_DOWN_CR); XPLMRegisterCommandHandler(gSpMagnetosOff1CmdRef, SwitchPanelCommandHandler, CMD_HNDLR_PROLOG, (void *) SP_CMD_MAGNETOS_OFF); XPLMRegisterCommandHandler(gSpMagnetosRight1CmdRef, SwitchPanelCommandHandler, CMD_HNDLR_PROLOG, (void *) SP_CMD_MAGNETOS_RIGHT); XPLMRegisterCommandHandler(gSpMagnetosLeft1CmdRef, SwitchPanelCommandHandler, CMD_HNDLR_PROLOG, (void *) SP_CMD_MAGNETOS_LEFT); XPLMRegisterCommandHandler(gSpMagnetosBoth1CmdRef, SwitchPanelCommandHandler, CMD_HNDLR_PROLOG, (void *) SP_CMD_MAGNETOS_BOTH); XPLMRegisterCommandHandler(gSpEngineStart1CmdRef, SwitchPanelCommandHandler, CMD_HNDLR_PROLOG, (void *) SP_CMD_ENGINE_START); XPLMRegisterCommandHandler(gSpMasterBatteryOnCmdRef, SwitchPanelCommandHandler, CMD_HNDLR_PROLOG, (void *) SP_CMD_MASTER_BATTERY_ON); XPLMRegisterCommandHandler(gSpMasterBatteryOffCmdRef, SwitchPanelCommandHandler, CMD_HNDLR_PROLOG, (void *) SP_CMD_MASTER_BATTERY_OFF); XPLMRegisterCommandHandler(gSpMasterAltBatteryOnCmdRef, SwitchPanelCommandHandler, CMD_HNDLR_PROLOG, (void *) SP_CMD_MASTER_ALT_BATTERY_ON); XPLMRegisterCommandHandler(gSpMasterAltBatteryOffCmdRef, SwitchPanelCommandHandler, CMD_HNDLR_PROLOG, (void *) SP_CMD_MASTER_ALT_BATTERY_OFF); XPLMRegisterCommandHandler(gSpGeneratorOn1CmdRef, SwitchPanelCommandHandler, CMD_HNDLR_PROLOG, (void *) SP_CMD_GENERATOR_ON); XPLMRegisterCommandHandler(gSpGeneratorOff1CmdRef, SwitchPanelCommandHandler, CMD_HNDLR_PROLOG, (void *) SP_CMD_GENERATOR_OFF); XPLMRegisterCommandHandler(gSpMasterAvionicsOnCmdRef, SwitchPanelCommandHandler, CMD_HNDLR_PROLOG, (void *) SP_CMD_MASTER_AVIONICS_ON); XPLMRegisterCommandHandler(gSpMasterAvionicsOffCmdRef, SwitchPanelCommandHandler, CMD_HNDLR_PROLOG, (void *) SP_CMD_MASTER_AVIONICS_OFF); XPLMRegisterCommandHandler(gSpFuelPumpOn1CmdRef, SwitchPanelCommandHandler, CMD_HNDLR_PROLOG, (void *) SP_CMD_FUEL_PUMP_ON); XPLMRegisterCommandHandler(gSpFuelPumpOff1CmdRef, SwitchPanelCommandHandler, CMD_HNDLR_PROLOG, (void *) SP_CMD_FUEL_PUMP_OFF); XPLMRegisterCommandHandler(gSpDeIceOnCmdRef, SwitchPanelCommandHandler, CMD_HNDLR_PROLOG, (void *) SP_CMD_DEICE_ON); XPLMRegisterCommandHandler(gSpDeIceOffCmdRef, SwitchPanelCommandHandler, CMD_HNDLR_PROLOG, (void *) SP_CMD_DEICE_OFF); XPLMRegisterCommandHandler(gSpPitotHeatOnCmdRef, SwitchPanelCommandHandler, CMD_HNDLR_PROLOG, (void *) SP_CMD_PITOT_HEAT_ON); XPLMRegisterCommandHandler(gSpPitotHeatOffCmdRef, SwitchPanelCommandHandler, CMD_HNDLR_PROLOG, (void *) SP_CMD_PITOT_HEAT_OFF); XPLMRegisterCommandHandler(gSpCowlClosedCmdRef, SwitchPanelCommandHandler, CMD_HNDLR_PROLOG, (void *) SP_CMD_COWL_CLOSED); XPLMRegisterCommandHandler(gSpCowlOpenCmdRef, SwitchPanelCommandHandler, CMD_HNDLR_PROLOG, (void *) SP_CMD_COWL_OPEN); XPLMRegisterCommandHandler(gSpLightsPanelOnCmdRef, SwitchPanelCommandHandler, CMD_HNDLR_PROLOG, (void *) SP_CMD_LIGHTS_PANEL_ON); XPLMRegisterCommandHandler(gSpLightsPanelOffCmdRef, SwitchPanelCommandHandler, CMD_HNDLR_PROLOG, (void *) SP_CMD_LIGHTS_PANEL_OFF); XPLMRegisterCommandHandler(gSpLightsBeaconOnCmdRef, SwitchPanelCommandHandler, CMD_HNDLR_PROLOG, (void *) SP_CMD_LIGHTS_BEACON_ON); XPLMRegisterCommandHandler(gSpLightsBeaconOffCmdRef, SwitchPanelCommandHandler, CMD_HNDLR_PROLOG, (void *) SP_CMD_LIGHTS_BEACON_OFF); XPLMRegisterCommandHandler(gSpLightsNavOnCmdRef, SwitchPanelCommandHandler, CMD_HNDLR_PROLOG, (void *) SP_CMD_LIGHTS_NAV_ON); XPLMRegisterCommandHandler(gSpLightsNavOffCmdRef, SwitchPanelCommandHandler, CMD_HNDLR_PROLOG, (void *) SP_CMD_LIGHTS_NAV_OFF); XPLMRegisterCommandHandler(gSpLightsStrobeOnCmdRef, SwitchPanelCommandHandler, CMD_HNDLR_PROLOG, (void *) SP_CMD_LIGHTS_STROBE_ON); XPLMRegisterCommandHandler(gSpLightsStrobeOffCmdRef, SwitchPanelCommandHandler, CMD_HNDLR_PROLOG, (void *) SP_CMD_LIGHTS_STROBE_OFF); XPLMRegisterCommandHandler(gSpLightsTaxiOnCmdRef, SwitchPanelCommandHandler, CMD_HNDLR_PROLOG, (void *) SP_CMD_LIGHTS_TAXI_ON); XPLMRegisterCommandHandler(gSpLightsTaxiOffCmdRef, SwitchPanelCommandHandler, CMD_HNDLR_PROLOG, (void *) SP_CMD_LIGHTS_TAXI_OFF); XPLMRegisterCommandHandler(gSpLightsLandingOnCmdRef, SwitchPanelCommandHandler, CMD_HNDLR_PROLOG, (void *) SP_CMD_LIGHTS_LANDING_ON); XPLMRegisterCommandHandler(gSpLightsLandingOffCmdRef, SwitchPanelCommandHandler, CMD_HNDLR_PROLOG, (void *) SP_CMD_LIGHTS_LANDING_OFF); XPLMRegisterCommandHandler(gSpLandingGearUpCmdRef, SwitchPanelCommandHandler, CMD_HNDLR_PROLOG, (void *) SP_CMD_LANDING_GEAR_UP); XPLMRegisterCommandHandler(gSpLandingGearDownCmdRef, SwitchPanelCommandHandler, CMD_HNDLR_PROLOG, (void *) SP_CMD_LANDING_GEAR_DOWN); /*----- SwitchPanel Data Ref Assignment -----*/ gSpNumberOfBatteriesDataRef = XPLMFindDataRef(sSP_NUMBER_OF_BATTERIES_DR); gSpNumberOfGeneratorsDataRef = XPLMFindDataRef(sSP_NUMBER_OF_GENERATORS_DR); gSpNumberOfEnginesDataRef = XPLMFindDataRef(sSP_NUMBER_OF_ENGINES_DR); gSpGearRetractDataRef = XPLMFindDataRef(sSP_GEAR_RETRACT_DR); gSpOnGroundDataRef = XPLMFindDataRef(sSP_ON_GROUND_DR); gSpLandingGearStatusDataRef = XPLMFindDataRef(sSP_LANDING_GEAR_STATUS_DR); gSpGear1FailDataRef = XPLMFindDataRef(sSP_GEAR_1_FAIL_DR); gSpGear2FailDataRef = XPLMFindDataRef(sSP_GEAR_2_FAIL_DR); gSpGear3FailDataRef = XPLMFindDataRef(sSP_GEAR_3_FAIL_DR); gSpAntiIceDataRef = XPLMFindDataRef(sSP_ANTI_ICE_DR); gSpCowlFlapsDataRef = XPLMFindDataRef(sSP_COWL_FLAPS_DR); gSpCockpitLightsDataRef = XPLMFindDataRef(sSP_COCKPIT_LIGHTS_DR); gSpBatteryArrayOnDataRef = XPLMFindDataRef(sSP_BATTERY_ARRAY_ON_DR); sp_update_datarefs(); }