Skip to content

Commit

Permalink
feat: do no longer force disable assistance (#7176)
Browse files Browse the repository at this point in the history
  • Loading branch information
aguther committed May 9, 2022
1 parent 6ca1c91 commit a5b6a8e
Show file tree
Hide file tree
Showing 16 changed files with 68 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ FoldingWingsHandle=False
FoldingWingsState=0, 0

[LocalVars.0]
A32NX_IS_READY=0
A32NX_START_STATE=7
A32NX_RMP_L_TOGGLE_SWITCH=1
A32NX_RMP_R_TOGGLE_SWITCH=1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ FoldingWingsState=0, 0
ExternalPowerSwitch=False

[LocalVars.0]
A32NX_IS_READY=0
A32NX_START_STATE=2
A32NX_RMP_L_TOGGLE_SWITCH=1
A32NX_RMP_R_TOGGLE_SWITCH=1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ FoldingWingsHandle=False
FoldingWingsState=0, 0

[LocalVars.0]
A32NX_IS_READY=0
A32NX_START_STATE=6
A32NX_RMP_L_TOGGLE_SWITCH=1
A32NX_RMP_R_TOGGLE_SWITCH=1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ LaunchBarSwitch=False
SeatBeltsSwitch = True

[LocalVars.0]
A32NX_IS_READY=0
A32NX_START_STATE=8
A32NX_RMP_L_TOGGLE_SWITCH=1
A32NX_RMP_R_TOGGLE_SWITCH=1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,8 @@ lift_coef_at_drag_zero_flaps = 0.10000
;fuselage_lateral_cx = 0.5; Defines fuselage lift and side force vs fuselage angle-of-attack and beta

[FLIGHT_TUNING]

modern_fm_only = 1; 1 (true) forces use of modern flight model regardless of what user selected in MSFS options menu. 0 (false) allows use of user-selected flight model
disable_assistances = 1; 1(true) disables all AI assistance settings as they are not compatible with the addon
disable_assistances = 0; 1(true) disables all AI assistance settings as they are not compatible with the addon
;empty_cg_deviation_limit = 20 ; Maximum deviation of empty weight cg allowed in wegiht & balance UI menu (in feet)
;icing_scalar = 1 ; Scales effect of icing on lift and weight
cruise_lift_scalar = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ FoldingWingsState=0, 0
ExternalPowerSwitch=False

[LocalVars.0]
A32NX_IS_READY=0
A32NX_START_STATE=1
A32NX_RMP_L_TOGGLE_SWITCH=1
A32NX_RMP_R_TOGGLE_SWITCH=1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ LaunchBarSwitch=False
SeatBeltsSwitch = True

[LocalVars.0]
A32NX_IS_READY=0
A32NX_START_STATE=4
A32NX_RMP_L_TOGGLE_SWITCH=1
A32NX_RMP_R_TOGGLE_SWITCH=1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ class A32NX_TipsManager {
constructor() {
this.notif = new NXNotif();
this.checkThrottleCalibration();
this.updateThrottler = new UpdateThrottler(30000);
this.updateThrottler = new UpdateThrottler(15000);
this.wasAnyAssistanceActive = false;
}

update(deltaTime) {
Expand Down Expand Up @@ -44,15 +45,25 @@ class A32NX_TipsManager {

checkAssistenceConfiguration() {
// only check when actually flying, otherwise return
if (SimVar.GetSimVarValue("CAMERA STATE", "Number") >= 10) {
if (SimVar.GetSimVarValue("L:A32NX_IS_READY", "Number") !== 1) {
this.wasAnyAssistanceActive = false;
return;
}
const assistenceTakeOffEnabled = SimVar.GetSimVarValue("ASSISTANCE TAKEOFF ENABLED", "Bool");
const assistenceLandingEnabled = SimVar.GetSimVarValue("ASSISTANCE LANDING ENABLED", "Bool");
const assistenceAutotrimActive = SimVar.GetSimVarValue("AI AUTOTRIM ACTIVE", "Bool");
if (assistenceTakeOffEnabled || assistenceLandingEnabled || assistenceAutotrimActive) {
this.notif.showNotification({message: "Ensure you have turned off all assistance functions:\n\n• AUTO-RUDDER\n• ASSISTED YOKE\n• ASSISTED LANDING\n• ASSISTED TAKEOFF\n• AI ANTI-STALL PROTECTION\n• AI AUTO-TRIM\n• ASSISTED CONTROLLER SENSITIVITY\n\nThey cause serious incompatibility!", timeout: 20000});

// determine if any assistance is active
const assistanceAiControls = SimVar.GetSimVarValue("AI CONTROLS", "Bool");
const assistanceTakeOffEnabled = SimVar.GetSimVarValue("ASSISTANCE TAKEOFF ENABLED", "Bool");
const assistanceLandingEnabled = SimVar.GetSimVarValue("ASSISTANCE LANDING ENABLED", "Bool");
const assistanceAutotrimActive = SimVar.GetSimVarValue("AI AUTOTRIM ACTIVE", "Bool");
const isAnyAssistanceActive = (assistanceAiControls || assistanceTakeOffEnabled || assistanceLandingEnabled || assistanceAutotrimActive);

// show popup when an enabled assistance is detected and it was not active before
if (!this.wasAnyAssistanceActive && isAnyAssistanceActive) {
this.notif.showNotification({message: "Ensure you have turned off all assistance functions:\n\n• AUTO-RUDDER\n• ASSISTED YOKE\n• ASSISTED LANDING\n• ASSISTED TAKEOFF\n• AI ANTI-STALL PROTECTION\n• AI AUTO-TRIM\n• ASSISTED CONTROLLER SENSITIVITY\n\nThey cause serious incompatibility!", timeout: 15000});
}

// remember if any assistance was active
this.wasAnyAssistanceActive = isAnyAssistanceActive;
}

}
4 changes: 4 additions & 0 deletions src/fbw/src/AdditionalData.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ struct AdditionalData {
unsigned long long assistanceTakeoffEnabled;
unsigned long long assistanceLandingEnabled;
unsigned long long aiAutoTrimActive;
unsigned long long aiControlsActive;
unsigned long long realisticTillerEnabled;
double tillerHandlePosition;
double noseWheelPosition;
};
2 changes: 1 addition & 1 deletion src/fbw/src/FlightDataRecorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class FlightDataRecorder {
public:
// IMPORTANT: this constant needs to increased with every interface change
const uint64_t INTERFACE_VERSION = 20;
const uint64_t INTERFACE_VERSION = 21;

void initialize();

Expand Down
8 changes: 8 additions & 0 deletions src/fbw/src/FlyByWireInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,10 @@ void FlyByWireInterface::setupLocalVariables() {
idRadioReceiverLocalizerDistance = make_unique<LocalVariable>("A32NX_RADIO_RECEIVER_LOC_DISTANCE");
idRadioReceiverGlideSlopeValid = make_unique<LocalVariable>("A32NX_RADIO_RECEIVER_GS_IS_VALID");
idRadioReceiverGlideSlopeDeviation = make_unique<LocalVariable>("A32NX_RADIO_RECEIVER_GS_DEVIATION");

idRealisticTillerEnabled = make_unique<LocalVariable>("A32NX_REALISTIC_TILLER_ENABLED");
idTillerHandlePosition = make_unique<LocalVariable>("A32NX_TILLER_HANDLE_POSITION");
idNoseWheelPosition = make_unique<LocalVariable>("A32NX_NOSE_WHEEL_POSITION");
}

bool FlyByWireInterface::handleFcuInitialization(double sampleTime) {
Expand Down Expand Up @@ -744,6 +748,10 @@ bool FlyByWireInterface::updateAdditionalData(double sampleTime) {
additionalData.assistanceTakeoffEnabled = simData.assistanceTakeoffEnabled;
additionalData.assistanceLandingEnabled = simData.assistanceLandingEnabled;
additionalData.aiAutoTrimActive = simData.aiAutoTrimActive;
additionalData.aiControlsActive = simData.aiControlsActive;
additionalData.realisticTillerEnabled = idRealisticTillerEnabled->get() == 1;
additionalData.tillerHandlePosition = idTillerHandlePosition->get();
additionalData.noseWheelPosition = idNoseWheelPosition->get();

return true;
}
Expand Down
4 changes: 4 additions & 0 deletions src/fbw/src/FlyByWireInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,10 @@ class FlyByWireInterface {
std::unique_ptr<LocalVariable> idRadioReceiverGlideSlopeValid;
std::unique_ptr<LocalVariable> idRadioReceiverGlideSlopeDeviation;

std::unique_ptr<LocalVariable> idRealisticTillerEnabled;
std::unique_ptr<LocalVariable> idTillerHandlePosition;
std::unique_ptr<LocalVariable> idNoseWheelPosition;

void loadConfiguration();
void setupLocalVariables();

Expand Down
1 change: 1 addition & 0 deletions src/fbw/src/interface/SimConnectData.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ struct SimData {
unsigned long long assistanceTakeoffEnabled;
unsigned long long assistanceLandingEnabled;
unsigned long long aiAutoTrimActive;
unsigned long long aiControlsActive;
};

struct SimInput {
Expand Down
1 change: 1 addition & 0 deletions src/fbw/src/interface/SimConnectInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ bool SimConnectInterface::prepareSimDataSimConnectDataDefinitions() {
result &= addDataDefinition(hSimConnect, 0, SIMCONNECT_DATATYPE_INT64, "ASSISTANCE TAKEOFF ENABLED", "BOOL");
result &= addDataDefinition(hSimConnect, 0, SIMCONNECT_DATATYPE_INT64, "ASSISTANCE LANDING ENABLED", "BOOL");
result &= addDataDefinition(hSimConnect, 0, SIMCONNECT_DATATYPE_INT64, "AI AUTOTRIM ACTIVE", "BOOL");
result &= addDataDefinition(hSimConnect, 0, SIMCONNECT_DATATYPE_INT64, "AI CONTROLS", "BOOL");

return result;
}
Expand Down
8 changes: 8 additions & 0 deletions src/fdr2csv/src/FlightDataRecorderConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,10 @@ void FlightDataRecorderConverter::writeHeader(ofstream& out, const string& delim
fmt::print(out, "data.assistanceTakeoffEnabled{}", delimiter);
fmt::print(out, "data.assistanceLandingEnabled{}", delimiter);
fmt::print(out, "data.aiAutoTrimActive{}", delimiter);
fmt::print(out, "data.aiControlsActive{}", delimiter);
fmt::print(out, "data.realisticTillerEnabled{}", delimiter);
fmt::print(out, "data.tillerHandlePosition{}", delimiter);
fmt::print(out, "data.noseWheelPosition{}", delimiter);
fmt::print(out, "\n");
}

Expand Down Expand Up @@ -1147,5 +1151,9 @@ void FlightDataRecorderConverter::writeStruct(ofstream& out,
fmt::print(out, "{}{}", static_cast<unsigned int>(data.assistanceTakeoffEnabled), delimiter);
fmt::print(out, "{}{}", static_cast<unsigned int>(data.assistanceLandingEnabled), delimiter);
fmt::print(out, "{}{}", static_cast<unsigned int>(data.aiAutoTrimActive), delimiter);
fmt::print(out, "{}{}", static_cast<unsigned int>(data.aiControlsActive), delimiter);
fmt::print(out, "{}{}", data.realisticTillerEnabled, delimiter);
fmt::print(out, "{}{}", data.tillerHandlePosition, delimiter);
fmt::print(out, "{}{}", data.noseWheelPosition, delimiter);
fmt::print(out, "\n");
}
52 changes: 16 additions & 36 deletions src/fdr2csv/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
using namespace std;

// IMPORTANT: this constant needs to increased with every interface change
const uint64_t INTERFACE_VERSION = 20;
const uint64_t INTERFACE_VERSION = 21;

int main(int argc, char *argv[]) {
int main(int argc, char* argv[]) {
// variables for command line parameters
string inFilePath;
string outFilePath;
Expand All @@ -34,15 +34,13 @@ int main(int argc, char *argv[]) {
args.addArgument({"-d", "--delimiter"}, &delimiter, "Delimiter");
args.addArgument({"-n", "--no-compression"}, &noCompression, "Input file is not compressed");
args.addArgument({"-p", "--print-struct-size"}, &printStructSize, "Print struct size");
args.addArgument({"-g", "--get-input-file-version"},
&printGetFileInterfaceVersion,
"Print interface version of input file");
args.addArgument({"-g", "--get-input-file-version"}, &printGetFileInterfaceVersion, "Print interface version of input file");
args.addArgument({"-h", "--help"}, &oPrintHelp, "Print help message");

// parse command line
try {
args.parse(argc, argv);
} catch (runtime_error const &e) {
} catch (runtime_error const& e) {
fmt::print("{}\n", e.what());
return -1;
}
Expand Down Expand Up @@ -74,7 +72,7 @@ int main(int argc, char *argv[]) {
}

// create input stream
istream *in;
istream* in;
if (!noCompression) {
in = new gzifstream(inFilePath.c_str());
} else {
Expand All @@ -89,29 +87,20 @@ int main(int argc, char *argv[]) {

// read file version
uint64_t fileFormatVersion = {};
in->read(reinterpret_cast<char *>(&fileFormatVersion), sizeof(INTERFACE_VERSION));
in->read(reinterpret_cast<char*>(&fileFormatVersion), sizeof(INTERFACE_VERSION));

// print file version if requested and return
if (printGetFileInterfaceVersion) {
cout << fileFormatVersion << endl;
return 0;
} else if (INTERFACE_VERSION != fileFormatVersion) {
fmt::print(
"ERROR: mismatch between converter and file version (expected {}, got {})\n",
INTERFACE_VERSION,
fileFormatVersion
);
fmt::print("ERROR: mismatch between converter and file version (expected {}, got {})\n", INTERFACE_VERSION, fileFormatVersion);
return 1;
}

// print information on convert
fmt::print(
"Converting from '{}' to '{}' with interface version '{}' and delimiter '{}'\n",
inFilePath,
outFilePath,
fileFormatVersion,
delimiter
);
fmt::print("Converting from '{}' to '{}' with interface version '{}' and delimiter '{}'\n", inFilePath, outFilePath, fileFormatVersion,
delimiter);

// output stream
ofstream out;
Expand Down Expand Up @@ -141,23 +130,14 @@ int main(int argc, char *argv[]) {
// read one struct from the file
while (!in->eof()) {
// read data into structs
in->read(reinterpret_cast<char *>(&data_ap_sm), sizeof(ap_sm_output));
in->read(reinterpret_cast<char *>(&data_ap_laws), sizeof(ap_raw_output));
in->read(reinterpret_cast<char *>(&data_athr), sizeof(athr_out));
in->read(reinterpret_cast<char *>(&data_fbw), sizeof(fbw_output));
in->read(reinterpret_cast<char *>(&data_engine), sizeof(EngineData));
in->read(reinterpret_cast<char *>(&data_additional), sizeof(AdditionalData));
in->read(reinterpret_cast<char*>(&data_ap_sm), sizeof(ap_sm_output));
in->read(reinterpret_cast<char*>(&data_ap_laws), sizeof(ap_raw_output));
in->read(reinterpret_cast<char*>(&data_athr), sizeof(athr_out));
in->read(reinterpret_cast<char*>(&data_fbw), sizeof(fbw_output));
in->read(reinterpret_cast<char*>(&data_engine), sizeof(EngineData));
in->read(reinterpret_cast<char*>(&data_additional), sizeof(AdditionalData));
// write struct to csv file
FlightDataRecorderConverter::writeStruct(
out,
delimiter,
data_ap_sm,
data_ap_laws,
data_athr,
data_fbw,
data_engine,
data_additional
);
FlightDataRecorderConverter::writeStruct(out, delimiter, data_ap_sm, data_ap_laws, data_athr, data_fbw, data_engine, data_additional);
// print progress
if (++counter % 1000 == 0) {
fmt::print("Processed {} entries...\r", counter);
Expand Down

0 comments on commit a5b6a8e

Please sign in to comment.