Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Services/ParticipantManagement/BiteHandling/bite_handler.cpp
T
torstenandCopilot b774f4035c Qt6 Migration: DDS-Stubs, Logger-Fixes, Export-Header Korrekturen
- 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>
2026-08-19 06:06:24 +02:00

144 lines
4.6 KiB
C++
Executable File

/**
* The BiteHandler class manages everything todo with bite requests.
* $Id$
* $HeadURL$
* $Author$
* Created by Hannes Baeuerle, SLSE, 2016-06-06
*/
#include "bite_handler.h"
#include "ParticipantHandling/participant.h"
#include "ParticipantHandling/participant_donator.h"
#include "main_handler.h"
#include <QTimer>
namespace ParticipantManagement
{
namespace BiteHandling
{
BiteHandler::BiteHandler(MainHandler *mainHandler)
: QObject()
, Interface::Fts::CallBiteRequestHandler(mainHandler->fts())
, m_mainHandler(mainHandler)
{
}
bool BiteHandler::init()
{
return true;
}
void BiteHandler::onDemandBiteReply(const Core::FunctionReplyObject &replyObject)
{
if (replyObject.error())
WARNING_LOG() << "Got an demandBiteError: " << replyObject();
auto it = m_demandedBiteParticipantRequests.find(replyObject.id());
if (it != m_demandedBiteParticipantRequests.end())
{
const DemandedParticipants &dp = it.value();
m_mainHandler->fts()->callBiteReply(dp.cookie, replyObject);
dp.timer->deleteLater();
m_demandedBiteParticipants -= dp.demandedBiteParticipants;
m_demandedBiteParticipantRequests.erase(it);
}
else
WARNING_LOG() << "Bite request with request id " << replyObject.id() << " was not replied to by the proxy";
}
void BiteHandler::onCallBiteRequest(const rti::core::SampleIdentity &cookie,
const CallBiteRequest &request)
{
DEBUG_LOG() << "onCallBiteRequest: " << request;
auto ret = callBiteRequest(cookie, request);
if (ret.error() || ret.id())
{
WARNING_LOG() << ret();
m_mainHandler->fts()->callBiteReply(cookie, ret);
}
// delayed answer in non-error case
}
Core::FunctionReplyObject BiteHandler::callBiteRequest(const rti::core::SampleIdentity &cookie,
const CallBiteRequest &request)
{
TrainingAreaBase::DemandBiteRequest req;
req.equipmentNumbers().reserve(request.participantIds().size());
req.withSelfTest(request.withSelfTest());
bool bOneFound = false;
bool bAlreadyDemandedFound = false;
QSet<int> currentDemandedParticipants;
for (const int participantId : request.participantIds())
{
if (m_demandedBiteParticipants.contains(participantId))
{
DEBUG_LOG() << "demandBiteRequest for participant Id "
<< participantId
<< " already triggered - reply is still to be done";
bAlreadyDemandedFound = true;
continue;
}
const ParticipantHandling::Participant *participant = m_mainHandler->participantHandler()->participantById(participantId);
if (participant == nullptr)
{
WARNING_LOG() << "Got BITE request for non existing participant id " << participantId;
continue;
}
if (participant->equipmentNumber() == 0)
{
WARNING_LOG() << "Got BITE request participant id " << participantId << " but has no equipment number set";
continue;
}
bOneFound = true;
m_demandedBiteParticipants.insert(participant->id());
currentDemandedParticipants.insert(participant->id());
req.equipmentNumbers().push_back(participant->equipmentNumber());
}
if (req.equipmentNumbers().size() == 0 && bAlreadyDemandedFound)
return Core::FunctionReplyObject(req.requestId());
if (req.equipmentNumbers().size() != 0)
{
static int s_requestId = 1;
req.requestId(s_requestId++);
if (!m_mainHandler->tabFtc()->demandBiteRequest(req, this))
return Core::FunctionReplyObject(req.requestId(),
tr_lts("dds", "Error passing the BITE request to the proxy"));
QTimer *timeoutTimer = new QTimer(this);
timeoutTimer->setSingleShot(true);
timeoutTimer->setInterval(5000);
const int requestId = req.requestId();
m_demandedBiteParticipantRequests.insert(requestId, {currentDemandedParticipants, cookie, timeoutTimer});
auto cb = [this, requestId]()
{
onBiteRequestTimeout(requestId);
};
connect(timeoutTimer, &QTimer::timeout, this, cb);
return Core::FunctionReplyObject();
}
// at least one found but this was already requested and we're waiting for answer -> don't answer with error
if (bOneFound)
return Core::FunctionReplyObject();
return Core::FunctionReplyObject(req.requestId(),
tr_lts("dds", "Got no valid participants for BITE request"));
}
void BiteHandler::onBiteRequestTimeout(int requestId)
{
INFO_LOG() << "onBiteRequestTimeout for " << requestId;
onDemandBiteReply(Core::FunctionReplyObject(requestId, tr_lts("dds", "Timeout while waiting for the proxy")));
}
} // namespace BiteHandling
} // namespace ParticipantManagement