Skip to content

Commit

Permalink
feat: added assistance information to FDR (#7147)
Browse files Browse the repository at this point in the history
* feat: added assistance information to FDR
* fix: missing header info for fdr2csv
  • Loading branch information
aguther authored May 2, 2022
1 parent c4713a4 commit d74dbb0
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 24 deletions.
3 changes: 3 additions & 0 deletions src/fbw/src/AdditionalData.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@ struct AdditionalData {
double throttle_lever_2_pos;
double corrected_engine_N1_1_percent;
double corrected_engine_N1_2_percent;
unsigned long long assistanceTakeoffEnabled;
unsigned long long assistanceLandingEnabled;
unsigned long long aiAutoTrimActive;
};
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 = 19;
const uint64_t INTERFACE_VERSION = 20;

void initialize();

Expand Down
3 changes: 3 additions & 0 deletions src/fbw/src/FlyByWireInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,9 @@ bool FlyByWireInterface::updateAdditionalData(double sampleTime) {
additionalData.throttle_lever_2_pos = simData.throttle_lever_2_pos;
additionalData.corrected_engine_N1_1_percent = simData.corrected_engine_N1_1_percent;
additionalData.corrected_engine_N1_2_percent = simData.corrected_engine_N1_2_percent;
additionalData.assistanceTakeoffEnabled = simData.assistanceTakeoffEnabled;
additionalData.assistanceLandingEnabled = simData.assistanceLandingEnabled;
additionalData.aiAutoTrimActive = simData.aiAutoTrimActive;

return true;
}
Expand Down
3 changes: 3 additions & 0 deletions src/fbw/src/interface/SimConnectData.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ struct SimData {
double brakeRightPosition;
double flapsHandleIndex;
double gearHandlePosition;
unsigned long long assistanceTakeoffEnabled;
unsigned long long assistanceLandingEnabled;
unsigned long long aiAutoTrimActive;
};

struct SimInput {
Expand Down
3 changes: 3 additions & 0 deletions src/fbw/src/interface/SimConnectInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ bool SimConnectInterface::prepareSimDataSimConnectDataDefinitions() {
result &= addDataDefinition(hSimConnect, 0, SIMCONNECT_DATATYPE_FLOAT64, "BRAKE RIGHT POSITION", "POSITION");
result &= addDataDefinition(hSimConnect, 0, SIMCONNECT_DATATYPE_FLOAT64, "FLAPS HANDLE INDEX", "NUMBER");
result &= addDataDefinition(hSimConnect, 0, SIMCONNECT_DATATYPE_FLOAT64, "GEAR HANDLE POSITION", "POSITION");
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");

return result;
}
Expand Down
39 changes: 17 additions & 22 deletions src/fdr2csv/src/FlightDataRecorderConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@

using namespace std;

void FlightDataRecorderConverter::writeHeader(
ofstream &out,
const string &delimiter
) {
void FlightDataRecorderConverter::writeHeader(ofstream& out, const string& delimiter) {
fmt::print(out, "ap_sm.time.dt{}", delimiter);
fmt::print(out, "ap_sm.time.simulation_time{}", delimiter);
fmt::print(out, "ap_sm.data.aircraft_position.lat{}", delimiter);
Expand Down Expand Up @@ -571,19 +568,20 @@ void FlightDataRecorderConverter::writeHeader(
fmt::print(out, "data.throttle_lever_2_pos{}", delimiter);
fmt::print(out, "data.corrected_engine_N1_1_percent{}", delimiter);
fmt::print(out, "data.corrected_engine_N1_2_percent{}", delimiter);
fmt::print(out, "data.assistanceTakeoffEnabled{}", delimiter);
fmt::print(out, "data.assistanceLandingEnabled{}", delimiter);
fmt::print(out, "data.aiAutoTrimActive{}", delimiter);
fmt::print(out, "\n");
}

void FlightDataRecorderConverter::writeStruct(
ofstream &out,
const string &delimiter,
const ap_sm_output &ap_sm,
const ap_raw_output &ap_law,
const athr_out &athr,
const fbw_output &fbw,
const EngineData &engine,
const AdditionalData &data
) {
void FlightDataRecorderConverter::writeStruct(ofstream& out,
const string& delimiter,
const ap_sm_output& ap_sm,
const ap_raw_output& ap_law,
const athr_out& athr,
const fbw_output& fbw,
const EngineData& engine,
const AdditionalData& data) {
fmt::print(out, "{}{}", ap_sm.time.dt, delimiter);
fmt::print(out, "{}{}", ap_sm.time.simulation_time, delimiter);
fmt::print(out, "{}{}", ap_sm.data.aircraft_position.lat, delimiter);
Expand Down Expand Up @@ -803,16 +801,10 @@ void FlightDataRecorderConverter::writeStruct(
fmt::print(out, "{}{}", static_cast<unsigned int>(ap_sm.vertical_previous.output.EXPED_mode_active), delimiter);
fmt::print(out, "{}{}", static_cast<unsigned int>(ap_sm.vertical_previous.output.FD_disconnect), delimiter);
fmt::print(out, "{}{}", static_cast<unsigned int>(ap_sm.vertical_previous.output.TCAS_sub_mode), delimiter);
fmt::print(out,
"{}{}",
static_cast<unsigned int>(ap_sm.vertical_previous.output.TCAS_sub_mode_compatible),
delimiter);
fmt::print(out, "{}{}", static_cast<unsigned int>(ap_sm.vertical_previous.output.TCAS_sub_mode_compatible), delimiter);
fmt::print(out, "{}{}", static_cast<unsigned int>(ap_sm.vertical_previous.output.TCAS_message_disarm), delimiter);
fmt::print(out, "{}{}", static_cast<unsigned int>(ap_sm.vertical_previous.output.TCAS_message_RA_inhibit), delimiter);
fmt::print(out,
"{}{}",
static_cast<unsigned int>(ap_sm.vertical_previous.output.TCAS_message_TRK_FPA_deselection),
delimiter);
fmt::print(out, "{}{}", static_cast<unsigned int>(ap_sm.vertical_previous.output.TCAS_message_TRK_FPA_deselection), delimiter);
fmt::print(out, "{}{}", ap_sm.output.enabled_AP1, delimiter);
fmt::print(out, "{}{}", ap_sm.output.enabled_AP2, delimiter);
fmt::print(out, "{}{}", ap_sm.output.lateral_law, delimiter);
Expand Down Expand Up @@ -1152,5 +1144,8 @@ void FlightDataRecorderConverter::writeStruct(
fmt::print(out, "{}{}", data.throttle_lever_2_pos, delimiter);
fmt::print(out, "{}{}", data.corrected_engine_N1_1_percent, delimiter);
fmt::print(out, "{}{}", data.corrected_engine_N1_2_percent, delimiter);
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, "\n");
}
2 changes: 1 addition & 1 deletion src/fdr2csv/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
using namespace std;

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

int main(int argc, char *argv[]) {
// variables for command line parameters
Expand Down

0 comments on commit d74dbb0

Please sign in to comment.