- NGL_ADD_LIBRARY2: 87 CMakeLists.txt konvertiert für Export-Header Generierung - 44 Export-Header Include-Pfade korrigiert (_export.h) - 81 DDS-Stub-Header generiert (*_dtc.h, *_fts.h, *_dts.h, *_ftc.h) - INGLLogger: Duplikat gelöscht, m_logger Member entfernt, variadische Makros - Q_FUNC_INFO Redefinition behoben (Qt6 definiert bereits) - FATAL_LOG Makro hinzugefügt - InfrastructureManagement DDS-Stubs (ism.hpp, ism_enums.hpp, ism_ftc.h) - FilterManagement DDS-Stubs (flt_ftc.h, flt_dts.h) - AreaEffectSimulation DDS-Stubs (aes.hpp, aes_enums.hpp) - SymbolAppearance Klasse vollständig definiert mit content() Methode - BuildingComponentFilter Klasse definiert mit Copy-Konstruktor - Ftc Factory: nullptr Return (abstract class) - AesFilter Klasse in aes.hpp hinzugefügt - Dtc Klasse in ppm.hpp mit participantChanged Signal - AesType Enum: alle 15 At* Werte definiert - AesEffectState_def: EsReceived hinzugefügt - DataModification Enum: eAdded/eModified/eRemoved - function_reply_object.h → core_types.h Include-Pfad (72 Dateien) - Enum-Class-Streaming Template-Operator in INGLLogger.h - ism_mounting_point.h: QImage → QtGui/QImage, QGuiApplication/QScreen - ism_data_plugin_interface.h: QSet Include, Include-Reihenfolge - QRegExp → QRegularExpression in tpm_js_parser.cpp - .underlying() Aufrufe zu direktem Enum-Vergleich korrigiert - Include-Pfade: aes.hpp in symbol_appearance_settings_impl.h und aes_display_filter_impl.h Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
281 lines
8.1 KiB
C++
Executable File
281 lines
8.1 KiB
C++
Executable File
|
|
|
|
|
|
#include "exercises_handler.h"
|
|
#include "exercise_participant_handler.h"
|
|
|
|
namespace WarehouseManagement
|
|
{
|
|
|
|
ExercisesHandler::ExercisesHandler(const std::shared_ptr<DdsHandler> &ddsHandler)
|
|
: m_ddsHandler(ddsHandler)
|
|
{}
|
|
|
|
ExercisesHandler::~ExercisesHandler()
|
|
{
|
|
qDeleteAll(m_exerciseHandler);
|
|
}
|
|
|
|
bool ExercisesHandler::init()
|
|
{
|
|
connect(m_ddsHandler->exmDtc().get(), &ExerciseManagement::Interface::Dtc::exerciseChanged,
|
|
this, &ExercisesHandler::onExerciseChanged);
|
|
|
|
auto cb = [this](const ExerciseManagement::Exercise &exercise)
|
|
{
|
|
exerciseAdded(exercise.id());
|
|
};
|
|
m_ddsHandler->exmDtc()->exercises(cb);
|
|
|
|
return true;
|
|
}
|
|
|
|
QMap<qint32, ExerciseManagement::Exercise> ExercisesHandler::getExercises() const
|
|
{
|
|
INFO_LOG() << "IN getExercises";
|
|
m_ddsHandler->exmDtc()->waitForHistoricalDataExercise();
|
|
return m_ddsHandler->exmDtc()->exercises();
|
|
}
|
|
|
|
ParticipantManagement::Type ExercisesHandler::participantType(int typeId) const
|
|
{
|
|
m_ddsHandler->ppmDtc()->waitForHistoricalDataType();
|
|
return m_ddsHandler->ppmDtc()->type(typeId);
|
|
}
|
|
|
|
ParticipantManagement::TypeClass ExercisesHandler::typeClassIdFromEquipmentTypeId(int equipTypeId) const
|
|
{
|
|
m_ddsHandler->ppmDtc()->waitForHistoricalDataType();
|
|
ParticipantManagement::TypeClass ret = ParticipantManagement::TypeClass::Unknown;
|
|
std::function<bool(const ParticipantManagement::Type &data)> cb =
|
|
[equipTypeId, &ret](const ParticipantManagement::Type &t) -> bool
|
|
{
|
|
if (t.equipmentTypeId() != equipTypeId)
|
|
return false;
|
|
ret = t.typeClass();
|
|
return true;
|
|
};
|
|
m_ddsHandler->ppmDtc()->types(cb);
|
|
return ret;
|
|
}
|
|
|
|
|
|
ParticipantManagement::Party ExercisesHandler::getParty(int partyId, int exerciseId) const
|
|
{
|
|
DEBUG_LOG() << "getParty: " << partyId << ", exId: " << exerciseId;
|
|
auto it = m_exerciseHandler.find(exerciseId);
|
|
if (it == m_exerciseHandler.end())
|
|
return ParticipantManagement::Party();
|
|
|
|
return it.value()->getParty(partyId);
|
|
}
|
|
|
|
QString ExercisesHandler::getHierarchyFromParticipant(int participantId, int exerciseId, const QMap<int, ParticipantManagement::Participant> &allParticipants) const
|
|
{
|
|
auto it = m_exerciseHandler.find(exerciseId);
|
|
if (it == m_exerciseHandler.end())
|
|
return QString();
|
|
|
|
return it.value()->getHierarchyFromParticipant(participantId, allParticipants);
|
|
}
|
|
ParticipantManagement::Participant ExercisesHandler::getParticipant(int participantId, int exerciseId) const
|
|
{
|
|
auto it = m_exerciseHandler.find(exerciseId);
|
|
if (it == m_exerciseHandler.end())
|
|
return ParticipantManagement::Participant();
|
|
|
|
return it.value()->getParticipant(participantId);
|
|
}
|
|
|
|
QMap<qint32, ParticipantManagement::Participant> ExercisesHandler::getParticipants(int exerciseId) const
|
|
{
|
|
auto it = m_exerciseHandler.find(exerciseId);
|
|
if (it == m_exerciseHandler.end())
|
|
return QMap<qint32, ParticipantManagement::Participant>();
|
|
|
|
return it.value()->getParticipants();
|
|
}
|
|
|
|
bool ExercisesHandler::registerParticipant(int exerciseId, qint32 participantId,
|
|
ParticipantManagement::ParticipantAssignState assignState,
|
|
const dds::core::optional<int> &equipNo,
|
|
const dds::core::optional<QString> &identification,
|
|
const dds::core::optional<QString> &info)
|
|
{
|
|
auto it = m_exerciseHandler.find(exerciseId);
|
|
if (it == m_exerciseHandler.end())
|
|
return false;
|
|
it.value()->registerParticipant(participantId, assignState, equipNo, identification, info);
|
|
return true;
|
|
}
|
|
|
|
bool ExercisesHandler::unregisterParticipant(int exerciseId, qint32 equipNo)
|
|
{
|
|
if (!m_exerciseHandler.contains(exerciseId))
|
|
return false;
|
|
|
|
if (!m_participants.contains(equipNo))
|
|
return false;
|
|
|
|
const QList<ParticipantInfoStruct> listPis = m_participants.values(equipNo);
|
|
|
|
qint32 participantId = -1;
|
|
for(ParticipantInfoStruct pis : listPis)
|
|
{
|
|
if (pis.exerciseId != exerciseId)
|
|
continue;
|
|
|
|
participantId = pis.participantId;
|
|
}
|
|
|
|
if (participantId == -1)
|
|
return false;
|
|
|
|
|
|
ParticipantManagement::ParticipantAssignState assignState = ParticipantManagement::ParticipantAssignState_def::NotAssigned;
|
|
|
|
m_exerciseHandler.value(exerciseId)->registerParticipant(participantId, assignState, 0, {}, {});
|
|
return true;
|
|
}
|
|
|
|
bool ExercisesHandler::modifyEquipmentTypes(const std::vector<ParticipantManagement::EquipmentType> &vectorEquipTypes)
|
|
{
|
|
ParticipantManagement::ModifyEquipmentTypeDataRequest req;
|
|
|
|
req.data(vectorEquipTypes);
|
|
req.deleteAll(true);
|
|
return m_ddsHandler->ppmFtc()->modifyEquipmentTypeDataRequest(req, this);
|
|
}
|
|
|
|
void ExercisesHandler::onModifyEquipmentTypeDataReply(const Core::FunctionReplyObject &replyObject)
|
|
{
|
|
if (replyObject.error())
|
|
ERROR_LOG() << replyObject();
|
|
}
|
|
|
|
bool ExercisesHandler::addParticipant(const ParticipantInfoStruct &pis)
|
|
{
|
|
m_participants.insert(pis.equipmentNumber, pis);
|
|
return true;
|
|
}
|
|
|
|
bool ExercisesHandler::modifyParticipant(const ParticipantInfoStruct &pis)
|
|
{
|
|
auto it = findParticipant(pis);
|
|
if (it == m_participants.end())
|
|
{
|
|
ERROR_LOG() << "Trying to modify a participant which is not in our map. mod: "
|
|
<< pis;
|
|
return false;
|
|
}
|
|
it.value() = pis;
|
|
return true;
|
|
}
|
|
|
|
bool ExercisesHandler::removeParticipant(const ParticipantInfoStruct &pis)
|
|
{
|
|
auto it = findParticipant(pis);
|
|
if (it == m_participants.end())
|
|
{
|
|
ERROR_LOG() << "Trying to remove a participant which is not in our map. mod: "
|
|
<< pis;
|
|
return false;
|
|
}
|
|
m_participants.erase(it);
|
|
return true;
|
|
}
|
|
|
|
QVector<ParticipantInfoStruct> ExercisesHandler::infoStructForEquipment(int equipmentNumber) const
|
|
{
|
|
QVector<ParticipantInfoStruct> ret;
|
|
|
|
auto it = m_participants.find(equipmentNumber);
|
|
if (it == m_participants.end()) {
|
|
|
|
}
|
|
while (it == m_participants.end() && it.value().equipmentNumber == equipmentNumber) {
|
|
ret += it.value();
|
|
++it;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
void ExercisesHandler::exerciseAdded(int exerciseId)
|
|
{
|
|
INFO_LOG() << "Exercise with id " << exerciseId << " created";
|
|
auto it = m_exerciseHandler.find(exerciseId);
|
|
if (it != m_exerciseHandler.end())
|
|
{
|
|
WARNING_LOG() << "Exercise with id " << exerciseId
|
|
<< " added but it was already in our list - recreating handler";
|
|
delete it.value();
|
|
m_exerciseHandler.erase(it);
|
|
}
|
|
ExerciseParticipantHandler *exH = new ExerciseParticipantHandler(m_ddsHandler->getDomainParticipant(), exerciseId, this);
|
|
if (!exH->init())
|
|
{
|
|
ERROR_LOG() << "Error initializing ExerciseHandler for exercise " << exerciseId;
|
|
delete exH;
|
|
return;
|
|
}
|
|
connect(exH, &ExerciseParticipantHandler::registrationReturnValue,
|
|
this, &ExercisesHandler::registrationReturnValue);
|
|
connect(exH, &ExerciseParticipantHandler::participantChanged,
|
|
this, &ExercisesHandler::participantChanged);
|
|
INFO_LOG() << "Successfully created exercise handler for exercise " << exerciseId;
|
|
m_exerciseHandler[exerciseId] = exH;
|
|
}
|
|
|
|
void ExercisesHandler::exerciseRemoved(int exerciseId)
|
|
{
|
|
INFO_LOG() << "Exercise with id " << exerciseId << " removed";
|
|
auto it = m_exerciseHandler.find(exerciseId);
|
|
if (it == m_exerciseHandler.end())
|
|
{
|
|
WARNING_LOG() << "Exercise removed but it was not found in our internal map";
|
|
return;
|
|
}
|
|
delete it.value();
|
|
m_exerciseHandler.erase(it);
|
|
}
|
|
|
|
QMultiHash<int, ParticipantInfoStruct>::iterator ExercisesHandler::findParticipant(const ParticipantInfoStruct &pis)
|
|
{
|
|
auto it = m_participants.find(pis.equipmentNumber);
|
|
while (it != m_participants.end() && it.value().equipmentNumber == pis.equipmentNumber)
|
|
{
|
|
if (it.value().exerciseId == pis.exerciseId)
|
|
return it;
|
|
++it;
|
|
}
|
|
return it;
|
|
}
|
|
|
|
void ExercisesHandler::onExerciseChanged(const ExerciseManagement::Exercise &data, DataModification modType)
|
|
{
|
|
if (!data.sendToWMS())
|
|
{
|
|
if (m_exerciseHandler.contains(data.id()))
|
|
exerciseRemoved(data.id());
|
|
|
|
emit exerciseChanged(data, DataModification::eRemoved);
|
|
}
|
|
else
|
|
{
|
|
if (!m_exerciseHandler.contains(data.id()))
|
|
{
|
|
modType = DataModification::eAdded;
|
|
exerciseAdded(data.id());
|
|
}
|
|
else
|
|
{
|
|
modType = DataModification::eModified;
|
|
}
|
|
emit exerciseChanged(data, modType);
|
|
}
|
|
}
|
|
|
|
|
|
}
|