Skip to content

Commit

Permalink
Example output commented out
Browse files Browse the repository at this point in the history
  • Loading branch information
frankkopp committed Jan 21, 2023
1 parent 40f8c9b commit c50a306
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 44 deletions.
82 changes: 41 additions & 41 deletions src/extra-backend/src/Modules/Example/ExampleModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,49 +27,49 @@ bool ExampleModule::initialize() {

// Event with Callback example
toggleFlightDirectorEventPtr = dataManager->make_event("TOGGLE_FLIGHT_DIRECTOR");
toggleFlightDirectorEventPtr->subscribeToSim();
toggleFlightDirectorCallbackID = toggleFlightDirectorEventPtr
->addCallback([&](int number, DWORD param0, DWORD param1, DWORD param2, DWORD param3,
DWORD param4) {
LOG_DEBUG("Callback 1: TOGGLE_FLIGHT_DIRECTOR event received with " + std::to_string(number)
+ " params:"
+ " 0: " + std::to_string(param0)
+ " 1: " + std::to_string(param1)
+ " 2: " + std::to_string(param2)
+ " 3: " + std::to_string(param3)
+ " 4: " + std::to_string(param4)
);
});
// toggleFlightDirectorEventPtr->subscribeToSim();
// toggleFlightDirectorCallbackID = toggleFlightDirectorEventPtr
// ->addCallback([&](int number, DWORD param0, DWORD param1, DWORD param2, DWORD param3,
// DWORD param4) {
// LOG_DEBUG("Callback 1: TOGGLE_FLIGHT_DIRECTOR event received with " + std::to_string(number)
// + " params:"
// + " 0: " + std::to_string(param0)
// + " 1: " + std::to_string(param1)
// + " 2: " + std::to_string(param2)
// + " 3: " + std::to_string(param3)
// + " 4: " + std::to_string(param4)
// );
// });

// Event with Callback example - twice to see multiple callbacks added to a single event
lightPotentiometerSetEventPtr = dataManager->make_event("LIGHT_POTENTIOMETER_SET");
lightPotentiometerSetCallbackID = lightPotentiometerSetEventPtr
->addCallback([&](int number, DWORD param0, DWORD param1, DWORD param2, DWORD param3,
DWORD param4) {
LOG_DEBUG("Callback 1: LIGHT_POTENTIOMETER_SET event received with " + std::to_string(number)
+ " params:"
+ " 0: " + std::to_string(param0)
+ " 1: " + std::to_string(param1)
+ " 2: " + std::to_string(param2)
+ " 3: " + std::to_string(param3)
+ " 4: " + std::to_string(param4)
);
});
lightPotentiometerSetEventPtr->subscribeToSim();
// lightPotentiometerSetCallbackID = lightPotentiometerSetEventPtr
// ->addCallback([&](int number, DWORD param0, DWORD param1, DWORD param2, DWORD param3,
// DWORD param4) {
// LOG_DEBUG("Callback 1: LIGHT_POTENTIOMETER_SET event received with " + std::to_string(number)
// + " params:"
// + " 0: " + std::to_string(param0)
// + " 1: " + std::to_string(param1)
// + " 2: " + std::to_string(param2)
// + " 3: " + std::to_string(param3)
// + " 4: " + std::to_string(param4)
// );
// });
// lightPotentiometerSetEventPtr->subscribeToSim();

lightPotentiometerSetEvent2Ptr = dataManager->make_event("LIGHT_POTENTIOMETER_SET");
lightPotentiometerSetCallback2ID = lightPotentiometerSetEvent2Ptr
->addCallback([&](int number, DWORD param0, DWORD param1, DWORD param2, DWORD param3,
DWORD param4) {
LOG_DEBUG("Callback 2: LIGHT_POTENTIOMETER_SET event received with " + std::to_string(number)
+ " params:"
+ " 0: " + std::to_string(param0)
+ " 1: " + std::to_string(param1)
+ " 2: " + std::to_string(param2)
+ " 3: " + std::to_string(param3)
+ " 4: " + std::to_string(param4)
);
});
// lightPotentiometerSetCallback2ID = lightPotentiometerSetEvent2Ptr
// ->addCallback([&](int number, DWORD param0, DWORD param1, DWORD param2, DWORD param3,
// DWORD param4) {
// LOG_DEBUG("Callback 2: LIGHT_POTENTIOMETER_SET event received with " + std::to_string(number)
// + " params:"
// + " 0: " + std::to_string(param0)
// + " 1: " + std::to_string(param1)
// + " 2: " + std::to_string(param2)
// + " 3: " + std::to_string(param3)
// + " 4: " + std::to_string(param4)
// );
// });

// LVARS
// requested twice to demonstrate de-duplication - also shows optional parameters
Expand Down Expand Up @@ -134,7 +134,7 @@ bool ExampleModule::update([[maybe_unused]] sGaugeDrawData* pData) {
if (msfsHandler->getTickCounter() % 100 == 0) {

// difference if using different units
// debugLVAR3Ptr->setAndWriteToSim(msfsHandler->getTickCounter());
// debugLVAR3Ptr->setAndWriteToSim(msfsHandler->getTickCounter());
// LOG_INFO("ticks " + std::to_string(msfsHandler->getTickCounter()));
// LOG_INFO("debugLVARPtr DEBUG_LVAR " + std::to_string(debugLVARPtr->rawReadFromSim()));
// LOG_INFO("debugLVAR2Ptr DEBUG_LVAR " + std::to_string(debugLVAR2Ptr->rawReadFromSim()));
Expand All @@ -152,8 +152,8 @@ bool ExampleModule::update([[maybe_unused]] sGaugeDrawData* pData) {
// }

// testing doubled LVARs
// std::cout << debugLVARPtr->str() << std::endl;
// std::cout << debugLVAR2Ptr->str() << std::endl;
std::cout << debugLVARPtr << std::endl;
std::cout << debugLVAR2Ptr << std::endl;

// testing aircraft variables
// std::cout << beaconLightSwitchPtr->str() << std::endl;
Expand Down
6 changes: 3 additions & 3 deletions src/extra-backend/src/Modules/Example/ExampleModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ class ExampleModule : public Module {
// Events
EventPtr beaconLightSetEventPtr;
EventPtr toggleFlightDirectorEventPtr;
CallbackID toggleFlightDirectorCallbackID{};
// CallbackID toggleFlightDirectorCallbackID{};
EventPtr lightPotentiometerSetEventPtr;
CallbackID lightPotentiometerSetCallbackID{};
// CallbackID lightPotentiometerSetCallbackID{};
EventPtr lightPotentiometerSetEvent2Ptr;
CallbackID lightPotentiometerSetCallback2ID{};
// CallbackID lightPotentiometerSetCallback2ID{};

public:
ExampleModule() = delete;
Expand Down

0 comments on commit c50a306

Please sign in to comment.