Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Proxies/TrainingAreaBase/exm_handler.cpp
T
berrux-dev 598fc2560e Complete Qt6 migration: full clean build green across groups G1-G12 incl. runtime plugin set
new_docker_build.sh gains Group 12 (212 GUI/Data plugins); fixes LtsUtilsGuiDds visibility (LTO-stripped exports), LtsProjectionWorkstation unity name shadow, 6 unity-off dirs (dup file-scope statics, ddsftc INTERFACE sources) and reconfigures BUILD_FILTERMANAGEMENT/BUILD_PLUGINS_SERVICEMONITOR=ON
2026-10-20 09:36:57 +02:00

74 lines
1.8 KiB
C++
Executable File

#include "exm_handler.h"
#include "main_handler.h"
#include <NGLLogger/NGLLoggerBootstrap.h>
namespace TrainingAreaBase
{
ExmHandler::ExmHandler(MainHandler *mainHandler)
: m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger())
, m_mainHandler(mainHandler)
{}
bool ExmHandler::init()
{
m_exmDtc = ExerciseManagement::Interface::Dtc::create(m_mainHandler->ddsHandler()->ddsConnector());
connect(m_exmDtc.get(), &ExerciseManagement::Interface::Dtc::exerciseChanged,
this, &ExmHandler::onExerciseChanged);
connect(m_exmDtc.get(), &ExerciseManagement::Interface::Dtc::exerciseChanged,
this, &ExmHandler::exerciseChanged);
if (!m_exmDtc->enableExercise())
{
ERROR_LOG(m_logger) << "Can not read equipment/exercise mappings from PPM";
return false;
}
return true;
}
ExerciseManagement::Exercise ExmHandler::exercise(int exerciseId)
{
m_exmDtc->waitForHistoricalDataExercise(10 * 1000);
return m_exmDtc->exercise(exerciseId);
}
void ExmHandler::onExerciseChanged(const ExerciseManagement::Exercise &data, DataModification modType)
{
if (!data.radioGroupId.has_value() || data.radioGroupId.get() == 0)
modType = DataModification::eRemoved;
bool bExercise2RadioGroupChanged = false;
switch (modType)
{
case DataModification::eAdded:
case DataModification::eModified:
{
auto &val = m_exercise2RadioGroup[data.id];
if (val != data.radioGroupId.get())
{
bExercise2RadioGroupChanged = true;
val = data.radioGroupId.get();
}
break;
}
case DataModification::eRemoved:
{
auto it = m_exercise2RadioGroup.find(data.id);
if (it != m_exercise2RadioGroup.end())
{
bExercise2RadioGroupChanged = true;
m_exercise2RadioGroup.erase(it);
}
break;
}
}
if (bExercise2RadioGroupChanged)
emit exercise2RadioGroupChanged();
}
}