Skip to content

Commit

Permalink
Introduced verbose LVAR for AircraftPresets
Browse files Browse the repository at this point in the history
  • Loading branch information
frankkopp committed Feb 3, 2023
1 parent 9c78319 commit 1592933
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,14 @@ bool AircraftPresets::update(sGaugeDrawData* pData) {
ivalue = 0;
svalue = "";
if (!currentStepPtr->expectedStateCheckCode.empty()) {
if (aircraftPresetVerbose) {
if (aircraftPresetVerbose->getAsBool()) {
std::cout << "AircraftPresets: Aircraft Preset Step " << currentStep << " Test: "
<< currentStepPtr->description << " TEST: \""
<< currentStepPtr->expectedStateCheckCode << "\"" << std::endl;
}
execute_calculator_code(currentStepPtr->expectedStateCheckCode.c_str(), &fvalue, &ivalue, &svalue);
if (static_cast<bool>(fvalue)) {
if (aircraftPresetVerbose) {
if (aircraftPresetVerbose->getAsBool()) {
std::cout << "AircraftPresets: Aircraft Preset Step " << currentStep << " Skipping: "
<< currentStepPtr->description << " TEST: \""
<< currentStepPtr->expectedStateCheckCode << "\"" << std::endl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ bool AircraftPresets::initialize() {
dataManager = &msfsHandler->getDataManager();

// LVARs
loadAircraftPresetRequest = dataManager->make_named_var("AIRCRAFT_PRESET_LOAD", UNITS.Bool, true, true);
aircraftPresetVerbose = dataManager->make_named_var("AIRCRAFT_PRESET_VERBOSE", UNITS.Bool, true);
loadAircraftPresetRequest = dataManager->make_named_var("AIRCRAFT_PRESET_LOAD", UNITS.Number, true, true);
progressAircraftPreset = dataManager->make_named_var("AIRCRAFT_PRESET_LOAD_PROGRESS");
progressAircraftPresetId = dataManager->make_named_var("AIRCRAFT_PRESET_LOAD_CURRENT_ID");
loadAircraftPresetRequest->setAndWriteToSim(0); // reset to 0 on startup
Expand All @@ -61,8 +62,10 @@ bool AircraftPresets::update(sGaugeDrawData* pData) {
return false;
}

// TODO: not yet available in the A380X
// if (!msfsHandler->getA32NxIsReady()) return true;
if (!msfsHandler->getA32NxIsReady()) return true;

const FLOAT64 timeStamp = msfsHandler->getTimeStamp();
const UINT64 tickCounter = msfsHandler->getTickCounter();

// has request to load a preset been received?
if (loadAircraftPresetRequest->get() > 0) {
Expand All @@ -76,8 +79,8 @@ bool AircraftPresets::update(sGaugeDrawData* pData) {
}

// read the progress vars once to get the current state
progressAircraftPreset->readFromSim();
progressAircraftPresetId->readFromSim();
progressAircraftPreset->updateFromSim(timeStamp, tickCounter);
progressAircraftPresetId->updateFromSim(timeStamp, tickCounter);

// check if we already have an active loading process or if this is a new request which
// needs to be initialized
Expand Down Expand Up @@ -159,14 +162,14 @@ bool AircraftPresets::update(sGaugeDrawData* pData) {
ivalue = 0;
svalue = "";
if (!currentStepPtr->expectedStateCheckCode.empty()) {
if (msfsHandler->getA32NxIsDevelopmentState() > 0) {
if (aircraftPresetVerbose->getAsBool()) {
std::cout << "AircraftPresets: Aircraft Preset Step " << currentStep << " Test: "
<< currentStepPtr->description << " TEST: \""
<< currentStepPtr->expectedStateCheckCode << "\"" << std::endl;
}
execute_calculator_code(currentStepPtr->expectedStateCheckCode.c_str(), &fvalue, &ivalue, &svalue);
if (static_cast<bool>(fvalue)) {
if (msfsHandler->getA32NxIsDevelopmentState() > 0) {
if (aircraftPresetVerbose->getAsBool()) {
std::cout << "AircraftPresets: Aircraft Preset Step " << currentStep << " Skipping: "
<< currentStepPtr->description << " TEST: \""
<< currentStepPtr->expectedStateCheckCode << "\"" << std::endl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class AircraftPresets : public Module {
DataManager* dataManager{};

// LVARs
NamedVariablePtr aircraftPresetVerbose{};
NamedVariablePtr loadAircraftPresetRequest{};
NamedVariablePtr progressAircraftPreset{};
NamedVariablePtr progressAircraftPresetId{};
Expand Down

0 comments on commit 1592933

Please sign in to comment.