Skip to content

Commit

Permalink
Add fbw A380
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Vincent committed Nov 11, 2024
1 parent 50708bc commit f667883
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 74 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@

#ifndef _LVARS_A32NX_H_
#define _LVARS_A32NX_H_
#ifndef _LVARS_FBW_H_
#define _LVARS_FBW_H_

#include <stdio.h>

// LVars for FBW Airbus A320
// LVars for FBW Airbus A320 & A380
const char A32NX_APU_MASTER_SW[] = "L:A32NX_OVHD_APU_MASTER_SW_PB_IS_ON, bool";
const char A32NX_APU_START[] = "L:A32NX_OVHD_APU_START_PB_IS_ON, bool";
const char A32NX_APU_START_AVAIL[] = "L:A32NX_OVHD_APU_START_PB_IS_AVAILABLE, bool";
const char A32NX_APU_BLEED[] = "L:A32NX_OVHD_PNEU_APU_BLEED_PB_IS_ON, bool";
const char A32NX_ELEC_BAT1[] = "L:A32NX_OVHD_ELEC_BAT_1_PB_IS_AUTO, bool";
const char A32NX_ELEC_BAT2[] = "L:A32NX_OVHD_ELEC_BAT_2_PB_IS_AUTO, bool";
const char A32NX_ELEC_BAT_ESS[] = "L:A32NX_OVHD_ELEC_BAT_ESS_PB_IS_AUTO, bool";
const char A32NX_ELEC_BAT_APU[] = "L:A32NX_OVHD_ELEC_BAT_APU_PB_IS_AUTO, bool";
const char A32NX_PARK_BRAKE_POS[] = "L:A32NX_PARK_BRAKE_LEVER_POS, bool";
const char A32NX_XPNDR_MODE[] = "L:A32NX_TRANSPONDER_MODE, enum";
const char A32NX_AUTOPILOT_1[] = "L:A32NX_AUTOPILOT_1_ACTIVE, bool";
Expand Down Expand Up @@ -42,7 +44,7 @@ const char A32NX_ENGINE_FUEL_FLOW2[] = "L:A32NX_ENGINE_FF:2, number";
const char A32NX_FLAPS_INDEX[] = "L:A32NX_FLAPS_HANDLE_INDEX, number";
const char A32NX_SPOILERS_HANDLE_POS[] = "L:A32NX_SPOILERS_HANDLE_POSITION, number";

struct LVars_A320
struct LVars_FBW
{
double apuStart = 0;
double apuStartAvail = 0;
Expand All @@ -65,4 +67,4 @@ struct LVars_A320
double engineFuelFlow2 = 0;
};

#endif // _LVARS_A32NX_H_
#endif // _LVARS_FBW_H_
89 changes: 53 additions & 36 deletions instrument-data-link/instrument-data-link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <thread>
#include "simvarDefs.h"
#include "LVars-A310.h"
#include "LVars-A32NX.h"
#include "LVars-Fbw.h"
#include "LVars-Kodiak100.h"
#include "jetbridge.h"
#include "vjoy.h"
Expand Down Expand Up @@ -81,7 +81,9 @@ bool hasFlown = false;
int onStandState = 0;
double skytrackState = 0;
bool isA310 = false;
bool isFbw = false;
bool isA320 = false;
bool isA380 = false;
bool is747 = false;
bool isK100 = false;
bool isPA28 = false;
Expand All @@ -92,7 +94,7 @@ double lastHeading = 0;
int seatBeltsReplicateDelay = 0;
int fixedPushback = -1;
LVars_A310 a310Vars;
LVars_A320 a320Vars;
LVars_FBW fbwVars;
HANDLE hSimConnect = NULL;
extern const char* versionString;
extern const char* SimVarDefs[][2];
Expand Down Expand Up @@ -157,8 +159,8 @@ void pollJetbridge()
readA310Jetbridge();
Sleep(loopMillis);
}
else if (simVars.connected && isA320) {
readA320Jetbridge();
else if (simVars.connected && isFbw) {
readFbwJetbridge();
Sleep(loopMillis);
}
else {
Expand Down Expand Up @@ -225,7 +227,9 @@ void CALLBACK MyDispatchProc(SIMCONNECT_RECV* pData, DWORD cbData, void* pContex
// Populate internal variables
simVars.skytrackState = skytrackState;
isA310 = false;
isFbw = false;
isA320 = false;
isA380 = false;
is747 = false;
isK100 = false;
isPA28 = false;
Expand All @@ -237,15 +241,25 @@ void CALLBACK MyDispatchProc(SIMCONNECT_RECV* pData, DWORD cbData, void* pContex
isNewAircraft = true;
}

if (strncmp(simVars.aircraft, "A310", 4) == 0 || strncmp(simVars.aircraft, "Airbus A310", 11) == 0) {
isA310 = true;
isAirliner = true;
}
else if (strncmp(simVars.aircraft, "FBW", 3) == 0 || strncmp(simVars.aircraft, "Airbus A320", 11) == 0) {
isA320 = true;
isAirliner = true;
char* pos = strchr(simVars.aircraft, '3');
if (pos && *(pos - 1) == 'A') {
if (*(pos + 1) == '1') {
isA310 = true;
isAirliner = true;
}
else if (*(pos + 1) == '2') {
isFbw = true;
isA320 = true;
isAirliner = true;
}
else if (*(pos + 1) == '8') {
isFbw = true;
isA380 = true;
isAirliner = true;
}
}
else if (strncmp(simVars.aircraft, "Salty", 5) == 0 || strncmp(simVars.aircraft, "Boeing 747-8", 12) == 0) {

if (strncmp(simVars.aircraft, "Salty", 5) == 0 || strncmp(simVars.aircraft, "Boeing 747-8", 12) == 0) {
is747 = true;
isAirliner = true;
}
Expand Down Expand Up @@ -318,51 +332,51 @@ void CALLBACK MyDispatchProc(SIMCONNECT_RECV* pData, DWORD cbData, void* pContex
simVars.nav1Standby = a310Vars.ilsFrequency / 100;
simVars.vor1Obs = a310Vars.ilsCourse;
}
else if (simVars.connected && isA320) {
// Map A32NX vars to real vars
simVars.apuStartSwitch = a320Vars.apuStart;
if (a320Vars.apuStartAvail) {
else if (simVars.connected && isFbw) {
// Map FBW vars to real vars
simVars.apuStartSwitch = fbwVars.apuStart;
if (fbwVars.apuStartAvail) {
simVars.apuPercentRpm = 100;
}
else {
simVars.apuPercentRpm = 0;
}
simVars.tfFlapsIndex = a320Vars.flapsIndex;
simVars.parkingBrakeOn = a320Vars.parkBrakePos;
simVars.tfSpoilersPosition = a320Vars.spoilersHandlePos;
simVars.brakeLeftPedal = a320Vars.leftBrakePedal;
simVars.brakeRightPedal = a320Vars.rightBrakePedal;
simVars.rudderPosition = a320Vars.rudderPedalPos / 100.0;
simVars.autopilotEngaged = (a320Vars.autopilot1 == 0 && a320Vars.autopilot2 == 0) ? 0 : 1;
if (a320Vars.autothrust == 0) {
simVars.tfFlapsIndex = fbwVars.flapsIndex;
simVars.parkingBrakeOn = fbwVars.parkBrakePos;
simVars.tfSpoilersPosition = fbwVars.spoilersHandlePos;
simVars.brakeLeftPedal = fbwVars.leftBrakePedal;
simVars.brakeRightPedal = fbwVars.rightBrakePedal;
simVars.rudderPosition = fbwVars.rudderPedalPos / 100.0;
simVars.autopilotEngaged = (fbwVars.autopilot1 == 0 && fbwVars.autopilot2 == 0) ? 0 : 1;
if (fbwVars.autothrust == 0) {
simVars.autothrottleActive = 0;
}
else {
simVars.autothrottleActive = 1;
}
simVars.transponderState = a320Vars.xpndrMode;
simVars.autopilotHeading = a320Vars.autopilotHeading;
simVars.transponderState = fbwVars.xpndrMode;
simVars.autopilotHeading = fbwVars.autopilotHeading;
simVars.autopilotAltitude = simVars.autopilotAltitude3;
simVars.autopilotVerticalSpeed = a320Vars.autopilotVerticalSpeed;
simVars.autopilotVerticalSpeed = fbwVars.autopilotVerticalSpeed;
if (simVars.jbVerticalMode == 14) {
// V/S mode engaged
simVars.autopilotVerticalHold = 1;
}
else if (simVars.jbVerticalMode == 15) {
// FPA mode engaged
simVars.autopilotVerticalHold = -1;
simVars.autopilotVerticalSpeed = a320Vars.autopilotFpa;
simVars.autopilotVerticalSpeed = fbwVars.autopilotFpa;
}
else {
simVars.autopilotVerticalHold = 0;
}
simVars.autopilotApproachHold = simVars.jbLocMode;
simVars.autopilotGlideslopeHold = simVars.jbApprMode;
simVars.tfAutoBrake = simVars.jbAutobrake + 1;
simVars.exhaustGasTemp1 = a320Vars.engineEgt1;
simVars.exhaustGasTemp2 = a320Vars.engineEgt2;
simVars.engineFuelFlow1 = a320Vars.engineFuelFlow1;
simVars.engineFuelFlow2 = a320Vars.engineFuelFlow2;
simVars.exhaustGasTemp1 = fbwVars.engineEgt1;
simVars.exhaustGasTemp2 = fbwVars.engineEgt2;
simVars.engineFuelFlow1 = fbwVars.engineFuelFlow1;
simVars.engineFuelFlow2 = fbwVars.engineFuelFlow2;
}
else if (is747) {
// Map Salty 747 vars to real vars
Expand Down Expand Up @@ -502,8 +516,8 @@ void CALLBACK MyDispatchProc(SIMCONNECT_RECV* pData, DWORD cbData, void* pContex
if (isA310) {
updateA310FromJetbridge(packet->data);
}
else if (isA320) {
updateA320FromJetbridge(packet->data);
else if (isFbw) {
updateFbwFromJetbridge(packet->data);
}
}
break;
Expand Down Expand Up @@ -962,9 +976,12 @@ void processRequest(int bytes)

//// For testing only - Leave commented out
//if (request.writeData.eventId == KEY_CABIN_SEATBELTS_ALERT_SWITCH_TOGGLE) {
// request.writeData.eventId = EVENT_RESET_DRONE_FOV;
// request.writeData.eventId = KEY_FLAPS_INCR;
// request.writeData.value = 0;
// printf("Intercepted event - Changed to: %d = %f\n", request.writeData.eventId, request.writeData.value);
// printf("Flaps: %f\n", simVars.tfFlapsIndex);
// readJetbridgeVar("L:A32NX_RMP_L_VHF2_STANDBY");
// writeJetbridgeVar("K:FLAPS HANDLE INDEX, number", simVars.tfFlapsIndex + 1.0f);
//}
//else {
// printf("Unintercepted event: %d (%d) = %f\n", request.writeData.eventId, KEY_CABIN_SEATBELTS_ALERT_SWITCH_TOGGLE, request.writeData.value);
Expand Down Expand Up @@ -1001,7 +1018,7 @@ void processRequest(int bytes)
if (isA310 && jetbridgeA310ButtonPress(request.writeData.eventId, request.writeData.value)) {
return;
}
else if (isA320 && jetbridgeA320ButtonPress(request.writeData.eventId, request.writeData.value)) {
else if (isFbw && jetbridgeFbwButtonPress(request.writeData.eventId, request.writeData.value)) {
return;
}
else if (isK100 && jetbridgeK100ButtonPress(request.writeData.eventId, request.writeData.value)) {
Expand Down
2 changes: 1 addition & 1 deletion instrument-data-link/instrument-data-link.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
<ClInclude Include="jetbridge\Client.h" />
<ClInclude Include="jetbridge\Protocol.h" />
<ClInclude Include="LVars-A310.h" />
<ClInclude Include="LVars-A32NX.h" />
<ClInclude Include="LVars-Fbw.h" />
<ClInclude Include="LVars-Kodiak100.h" />
<ClInclude Include="LVars-PA28.h" />
<ClInclude Include="simvarDefs.h" />
Expand Down
2 changes: 1 addition & 1 deletion instrument-data-link/instrument-data-link.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
<Filter>Jetbridge</Filter>
</ClInclude>
<ClInclude Include="LVars-A310.h" />
<ClInclude Include="LVars-A32NX.h" />
<ClInclude Include="LVars-Kodiak100.h" />
<ClInclude Include="jetbridge.h" />
<ClInclude Include="vjoy.h" />
<ClInclude Include="LVars-PA28.h" />
<ClInclude Include="LVars-Fbw.h" />
</ItemGroup>
<ItemGroup>
<None Include="C:\MSFS SDK\SimConnect SDK\VS\SimConnectClient-static.props" />
Expand Down
Loading

0 comments on commit f667883

Please sign in to comment.