Adds immediate migration results in progress
This commit is contained in:
2102 files changed
+17482
-15071
No files matched your search
@@ -13,12 +13,11 @@
|
||||
namespace TrainingAreaBaseOC
|
||||
{
|
||||
|
||||
TxDdlHandler::TxDdlHandler()
|
||||
: m_state(DdlState::NotStarted)
|
||||
TxDdlHandler::TxDdlHandler() : m_state(DdlState::NotStarted)
|
||||
, m_segmentToggle(0)
|
||||
, m_sentCnt(0)
|
||||
, m_responseTimer(new QTimer(this))
|
||||
{
|
||||
, m_responseTimer(new QTimer(this)),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
m_responseTimer->setInterval(1000);
|
||||
m_responseTimer->setSingleShot(true);
|
||||
connect(m_responseTimer, &QTimer::timeout, this, &TxDdlHandler::sendAbortOrRestartTimeout);
|
||||
@@ -46,13 +45,13 @@ void TxDdlHandler::process(const QByteArray &data)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
DEBUG_LOG() << "Segment download confirmation received";
|
||||
DEBUG_LOG(m_logger) << "Segment download confirmation received";
|
||||
|
||||
qint32 toggle = ((data[0] & 0x10) >> 4);
|
||||
|
||||
if (m_segmentToggle != toggle)
|
||||
{
|
||||
ERROR_LOG() << "Toggle bit of confirmation not equal to request";
|
||||
ERROR_LOG(m_logger) << "Toggle bit of confirmation not equal to request";
|
||||
sendAbort(130);
|
||||
}
|
||||
|
||||
@@ -62,14 +61,14 @@ void TxDdlHandler::process(const QByteArray &data)
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
DEBUG_LOG() << "Initiate download confirmation received";
|
||||
DEBUG_LOG(m_logger) << "Initiate download confirmation received";
|
||||
|
||||
if (m_dataToSend.isEmpty())
|
||||
break;
|
||||
|
||||
if (DdlState::Initiated != m_state)
|
||||
{
|
||||
ERROR_LOG() << "Initiate download confirmation received but ddl wasn't startet yet.";
|
||||
ERROR_LOG(m_logger) << "Initiate download confirmation received but ddl wasn't startet yet.";
|
||||
sendAbort();
|
||||
break;
|
||||
}
|
||||
@@ -78,7 +77,7 @@ void TxDdlHandler::process(const QByteArray &data)
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
WARNING_LOG() << "Error during domain download";
|
||||
WARNING_LOG(m_logger) << "Error during domain download";
|
||||
|
||||
m_state = DdlState::NotStarted;
|
||||
if (m_dataToSend.isEmpty())
|
||||
@@ -90,7 +89,7 @@ void TxDdlHandler::process(const QByteArray &data)
|
||||
}
|
||||
default:
|
||||
|
||||
ERROR_LOG() << "unknown scs value received: " << scs;
|
||||
ERROR_LOG(m_logger) << "unknown scs value received: " << scs;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -115,13 +114,13 @@ void TxDdlHandler::initiateDomainDownload()
|
||||
{
|
||||
if (m_dataToSend.isEmpty())
|
||||
{
|
||||
ERROR_LOG() << "::initiateDomainDownload called, but no data to send available";
|
||||
ERROR_LOG(m_logger) << "::initiateDomainDownload called, but no data to send available";
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_sentCnt >= s_maxResendCnt)
|
||||
{
|
||||
ERROR_LOG() << "Maximum trys of resending DDL exceeded. ";
|
||||
ERROR_LOG(m_logger) << "Maximum trys of resending DDL exceeded. ";
|
||||
m_dataToSend.removeFirst();
|
||||
m_sentCnt = 0;
|
||||
startNextDomainDownload();
|
||||
@@ -137,7 +136,7 @@ void TxDdlHandler::initiateDomainDownload()
|
||||
data[6] = ((dataSize >> 16) & 0xFF);
|
||||
data[7] = ((dataSize >> 24) & 0xFF);
|
||||
|
||||
DEBUG_LOG() << "Initiate DDL Req";
|
||||
DEBUG_LOG(m_logger) << "Initiate DDL Req";
|
||||
|
||||
m_state = DdlState::Initiated;
|
||||
m_sentCnt++;
|
||||
@@ -149,7 +148,7 @@ void TxDdlHandler::domainDownload()
|
||||
{
|
||||
if (m_dataToSend.isEmpty())
|
||||
{
|
||||
ERROR_LOG() << "::domainDownload called, but no data to send available";
|
||||
ERROR_LOG(m_logger) << "::domainDownload called, but no data to send available";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -202,7 +201,7 @@ void TxDdlHandler::domainDownload()
|
||||
|
||||
m_dataToSend.first().offset = newOffset;
|
||||
|
||||
DEBUG_LOG() << "Segment DDL Req";
|
||||
DEBUG_LOG(m_logger) << "Segment DDL Req";
|
||||
m_state = DdlState::Downloading;
|
||||
|
||||
emit send(data);
|
||||
@@ -214,7 +213,7 @@ void TxDdlHandler::sendAbort(quint8 error)
|
||||
QByteArray data(8, '\0');
|
||||
data[0] = 0x80;
|
||||
data[1] = error;
|
||||
DEBUG_LOG() << "Abort DDL Req";
|
||||
DEBUG_LOG(m_logger) << "Abort DDL Req";
|
||||
|
||||
m_state = DdlState::NotStarted;
|
||||
m_dataToSend.first().offset = 0;
|
||||
@@ -235,7 +234,7 @@ void RxDdlHandler::process(const QByteArray &data)
|
||||
|
||||
case 1:
|
||||
{
|
||||
DEBUG_LOG() << "initiate download received";
|
||||
DEBUG_LOG(m_logger) << "initiate download received";
|
||||
if (m_isMultiplexed)
|
||||
m_multiplexer = (((data[1] & 0xFF) << 16) | ((data[2] & 0xFF) << 8) | (data[3] & 0xFF));
|
||||
|
||||
@@ -251,10 +250,10 @@ void RxDdlHandler::process(const QByteArray &data)
|
||||
|
||||
case 0:
|
||||
{
|
||||
DEBUG_LOG() << "download segment received";
|
||||
DEBUG_LOG(m_logger) << "download segment received";
|
||||
if (m_state == DdlState::NotStarted)
|
||||
{
|
||||
WARNING_LOG() << "download segment and data m_state == DdlState::NotStarted, something went wrong!";
|
||||
WARNING_LOG(m_logger) << "download segment and data m_state == DdlState::NotStarted, something went wrong!";
|
||||
sendDPConfirmation(4, 0);
|
||||
return;
|
||||
}
|
||||
@@ -284,14 +283,14 @@ void RxDdlHandler::process(const QByteArray &data)
|
||||
|
||||
case 4:
|
||||
{
|
||||
DEBUG_LOG() << "abort download received";
|
||||
DEBUG_LOG(m_logger) << "abort download received";
|
||||
m_messageData.clear();
|
||||
m_state = DdlState::NotStarted;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
WARNING_LOG() << "Unknown ccs ID: " << ccs;
|
||||
WARNING_LOG(m_logger) << "Unknown ccs ID: " << ccs;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -315,7 +314,7 @@ void RxDdlHandler::sendDPConfirmation(const quint32 ccs, const quint32 toggle, c
|
||||
else if (1 == toggle)
|
||||
data[0] = 0x30;
|
||||
else
|
||||
WARNING_LOG() << "Unknown toggle state: " << toggle;
|
||||
WARNING_LOG(m_logger) << "Unknown toggle state: " << toggle;
|
||||
m_state = DdlState::Downloading;
|
||||
}
|
||||
else if (4 == ccs)
|
||||
@@ -365,7 +364,7 @@ bool CanagHandler::init()
|
||||
|
||||
if (!m_handlerAesData->init())
|
||||
{
|
||||
ERROR_LOG() << "Could not initialise HandlerAesData.";
|
||||
ERROR_LOG(m_logger) << "Could not initialise HandlerAesData.";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -459,19 +458,19 @@ bool CanagHandler::txData(const TrainingAreaBase::TetraIcd::OpaquePayloadDataBas
|
||||
{
|
||||
case TrainingAreaBase::TetraIcd::OpaquePayloadDataBase::Type::OC:
|
||||
{
|
||||
INFO_LOG() << "adding DDL CanId::CAN_ID_DATENVERKEHR_SRT_KOPPELRECHNER_TX";
|
||||
INFO_LOG(m_logger) << "adding DDL CanId::CAN_ID_DATENVERKEHR_SRT_KOPPELRECHNER_TX";
|
||||
m_txDdlHandler[CanId::OcExconDataTx]->addData(LtsUtils::toQByteArray(data.payload));
|
||||
break;
|
||||
}
|
||||
case TrainingAreaBase::TetraIcd::OpaquePayloadDataBase::Type::FireSmokeMarker:
|
||||
{
|
||||
INFO_LOG() << "adding DDL CanId::CAN_ID_DATENVERKEHR_DMF_KOPPELRECHNER_TX";
|
||||
INFO_LOG(m_logger) << "adding DDL CanId::CAN_ID_DATENVERKEHR_DMF_KOPPELRECHNER_TX";
|
||||
m_txDdlHandler[CanId::FireSmokeMarkerExconDataTx]->addData(LtsUtils::toQByteArray(data.payload));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
ERROR_LOG() << "Tryed to send unhandled TrainingAreaBase::TetraIcd::OpaquePayloadDataBase::Type " << static_cast<int>(data.payloadType);
|
||||
ERROR_LOG(m_logger) << "Tryed to send unhandled TrainingAreaBase::TetraIcd::OpaquePayloadDataBase::Type " << static_cast<int>(data.payloadType);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -483,22 +482,22 @@ void CanagHandler::handleSfmTelegram(const LtsUtils::SfmMessage &message)
|
||||
{
|
||||
if (message.id() == 0)
|
||||
{
|
||||
ERROR_LOG() << "Error while receiving data from sfm.";
|
||||
ERROR_LOG(m_logger) << "Error while receiving data from sfm.";
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG_LOG() << "Received new CAN-Message with ID: " << message.id() << " RTR: " << message.rtr() << " data: " << message.payload().toHex(' ');
|
||||
DEBUG_LOG(m_logger) << "Received new CAN-Message with ID: " << message.id() << " RTR: " << message.rtr() << " data: " << message.payload().toHex(' ');
|
||||
switch (message.id())
|
||||
{
|
||||
case CanId::DemandDeviceId:
|
||||
{
|
||||
INFO_LOG() << "Received CanId::DemandDeviceId";
|
||||
INFO_LOG(m_logger) << "Received CanId::DemandDeviceId";
|
||||
m_deviceMessageTimer->start();
|
||||
break;
|
||||
}
|
||||
case CanId::Time:
|
||||
{
|
||||
DEBUG_LOG() << "Received CanId::Time";
|
||||
DEBUG_LOG(m_logger) << "Received CanId::Time";
|
||||
QByteArray data = message.payload();
|
||||
OcTelegrams::TimeSync outData;
|
||||
|
||||
@@ -506,7 +505,7 @@ void CanagHandler::handleSfmTelegram(const LtsUtils::SfmMessage &message)
|
||||
LtsUtils::get4Byte(data, gpsTime);
|
||||
outData.gpsTimeMsec = gpsTime * 1000ULL;
|
||||
outData.timezone = data[4];
|
||||
DEBUG_LOG() << "Received " << gpsTime;
|
||||
DEBUG_LOG(m_logger) << "Received " << gpsTime;
|
||||
sendSyncTime(gpsTime);
|
||||
|
||||
m_rxHandler->rxData(outData);
|
||||
@@ -514,7 +513,7 @@ void CanagHandler::handleSfmTelegram(const LtsUtils::SfmMessage &message)
|
||||
}
|
||||
case CanId::EnterLeaveAes:
|
||||
{
|
||||
INFO_LOG() << "Received CanId::EnterLeaveAes";
|
||||
INFO_LOG(m_logger) << "Received CanId::EnterLeaveAes";
|
||||
QByteArray data = message.payload();
|
||||
OcTelegrams::EnterLeaveAes outData;
|
||||
|
||||
@@ -535,13 +534,13 @@ void CanagHandler::handleSfmTelegram(const LtsUtils::SfmMessage &message)
|
||||
}
|
||||
case CanId::ParameterOcRx:
|
||||
{
|
||||
INFO_LOG() << "Received CanId::ParameterOcRx";
|
||||
INFO_LOG(m_logger) << "Received CanId::ParameterOcRx";
|
||||
send(*m_messages[CanId::ParameterOcTx]);
|
||||
break;
|
||||
}
|
||||
case CanId::TechnicalStateSfm:
|
||||
{
|
||||
INFO_LOG() << "Received CanId::TechnicalStateSfm";
|
||||
INFO_LOG(m_logger) << "Received CanId::TechnicalStateSfm";
|
||||
QByteArray data = message.payload();
|
||||
OcTelegrams::TechnicalStateSfm outData;
|
||||
|
||||
@@ -566,7 +565,7 @@ void CanagHandler::handleSfmTelegram(const LtsUtils::SfmMessage &message)
|
||||
}
|
||||
case CanId::TechnicalStateOc:
|
||||
{
|
||||
INFO_LOG() << "Received CanId::TechnicalStateOc";
|
||||
INFO_LOG(m_logger) << "Received CanId::TechnicalStateOc";
|
||||
|
||||
if (message.rtr())
|
||||
send(*m_messages[CanId::TechnicalStateOc]);
|
||||
@@ -574,42 +573,42 @@ void CanagHandler::handleSfmTelegram(const LtsUtils::SfmMessage &message)
|
||||
}
|
||||
case CanId::ExconOcDataRx:
|
||||
{
|
||||
INFO_LOG() << "Received CanId::ExconOcDataRx";
|
||||
INFO_LOG(m_logger) << "Received CanId::ExconOcDataRx";
|
||||
QByteArray data = message.payload();
|
||||
m_rxDdlHandler[CanId::ExconOcDataTx]->process(data);
|
||||
break;
|
||||
}
|
||||
case CanId::OcExconDataRx:
|
||||
{
|
||||
INFO_LOG() << "Received CanId::OcExconDataRx";
|
||||
INFO_LOG(m_logger) << "Received CanId::OcExconDataRx";
|
||||
QByteArray data = message.payload();
|
||||
m_txDdlHandler[CanId::OcExconDataTx]->process(data);
|
||||
break;
|
||||
}
|
||||
case CanId::ExconFireSmokeMarkerDataRx:
|
||||
{
|
||||
INFO_LOG() << "Received CanId::ExconFireSmokeMarkerDataRx";
|
||||
INFO_LOG(m_logger) << "Received CanId::ExconFireSmokeMarkerDataRx";
|
||||
QByteArray data = message.payload();
|
||||
m_rxDdlHandler[CanId::ExconFireSmokeMarkerDataTx]->process(data);
|
||||
break;
|
||||
}
|
||||
case CanId::FireSmokeMarkerExconDataRx:
|
||||
{
|
||||
INFO_LOG() << "Received CanId::FireSmokeMarkerExconDataRx";
|
||||
INFO_LOG(m_logger) << "Received CanId::FireSmokeMarkerExconDataRx";
|
||||
QByteArray data = message.payload();
|
||||
m_txDdlHandler[CanId::FireSmokeMarkerExconDataTx]->process(data);
|
||||
break;
|
||||
}
|
||||
case CanId::AwesDataRx:
|
||||
{
|
||||
INFO_LOG() << "Received CanId::AwesDataRx";
|
||||
INFO_LOG(m_logger) << "Received CanId::AwesDataRx";
|
||||
QByteArray data = message.payload();
|
||||
m_rxDdlHandler[CanId::AwesDataTx]->process(data);
|
||||
break;
|
||||
}
|
||||
case CanId::Position:
|
||||
{
|
||||
INFO_LOG() << "Received CanId::Position";
|
||||
INFO_LOG(m_logger) << "Received CanId::Position";
|
||||
QByteArray data = message.payload();
|
||||
OcTelegrams::OwnPosition outData;
|
||||
|
||||
@@ -626,7 +625,7 @@ void CanagHandler::handleSfmTelegram(const LtsUtils::SfmMessage &message)
|
||||
}
|
||||
case CanId::DisplayMessage:
|
||||
{
|
||||
INFO_LOG() << "Received CanId::DisplayMessage";
|
||||
INFO_LOG(m_logger) << "Received CanId::DisplayMessage";
|
||||
|
||||
handleDisplayMessage(message);
|
||||
|
||||
@@ -634,7 +633,7 @@ void CanagHandler::handleSfmTelegram(const LtsUtils::SfmMessage &message)
|
||||
}
|
||||
case CanId::SpecificsExercise:
|
||||
{
|
||||
INFO_LOG() << "Received CanId::SpecificsExercise";
|
||||
INFO_LOG(m_logger) << "Received CanId::SpecificsExercise";
|
||||
QByteArray data = message.payload();
|
||||
OcTelegrams::SpecificsExercise outData;
|
||||
|
||||
@@ -662,7 +661,7 @@ void CanagHandler::handleSfmTelegram(const LtsUtils::SfmMessage &message)
|
||||
}
|
||||
case CanId::SpecificsOc:
|
||||
{
|
||||
INFO_LOG() << "Received CanId::SpecificsOc";
|
||||
INFO_LOG(m_logger) << "Received CanId::SpecificsOc";
|
||||
|
||||
if (message.rtr())
|
||||
send(*m_messages[CanId::SpecificsOc]);
|
||||
@@ -670,7 +669,7 @@ void CanagHandler::handleSfmTelegram(const LtsUtils::SfmMessage &message)
|
||||
}
|
||||
case CanId::SpecificsEquipment:
|
||||
{
|
||||
INFO_LOG() << "Received CanId::SpecificsEquipment";
|
||||
INFO_LOG(m_logger) << "Received CanId::SpecificsEquipment";
|
||||
QByteArray data = message.payload();
|
||||
OcTelegrams::SpecificsEquipment outData;
|
||||
|
||||
@@ -695,13 +694,13 @@ void CanagHandler::handleSfmTelegram(const LtsUtils::SfmMessage &message)
|
||||
}
|
||||
case CanId::ParameterSfmRx:
|
||||
{
|
||||
INFO_LOG() << "Received CanId::ParameterSfmRx";
|
||||
INFO_LOG(m_logger) << "Received CanId::ParameterSfmRx";
|
||||
|
||||
break;
|
||||
}
|
||||
case CanId::ConnectionTestSfmReply:
|
||||
{
|
||||
INFO_LOG() << "Received CanId::TestConnectionSfmReply";
|
||||
INFO_LOG(m_logger) << "Received CanId::TestConnectionSfmReply";
|
||||
if (!m_sfmConnectionEstablished)
|
||||
sendDemandDeviceId();
|
||||
else
|
||||
@@ -710,21 +709,21 @@ void CanagHandler::handleSfmTelegram(const LtsUtils::SfmMessage &message)
|
||||
break;
|
||||
}
|
||||
default:
|
||||
DEBUG_LOG() << "message id " << message.id() << " is not handled!";
|
||||
DEBUG_LOG(m_logger) << "message id " << message.id() << " is not handled!";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CanagHandler::sendDemandDeviceId()
|
||||
{
|
||||
INFO_LOG() << "Requesting Device ID.";
|
||||
INFO_LOG(m_logger) << "Requesting Device ID.";
|
||||
send(*m_messages[CanId::DemandDeviceId]);
|
||||
m_deviceMessageTimer->start();
|
||||
}
|
||||
|
||||
void CanagHandler::sendDeviceMessage()
|
||||
{
|
||||
INFO_LOG() << "Sending Device ID.";
|
||||
INFO_LOG(m_logger) << "Sending Device ID.";
|
||||
send(*m_messages[CanId::DeviceId]);
|
||||
if (!m_technicalStateSfm.sfmConnected)
|
||||
demandInitialSfmData();
|
||||
@@ -816,12 +815,12 @@ void CanagHandler::sendFreeText()
|
||||
|
||||
void CanagHandler::sendSyncTime(uint32_t syncTimeSec)
|
||||
{
|
||||
INFO_LOG() << "sendSyncTime " << syncTimeSec;
|
||||
INFO_LOG(m_logger) << "sendSyncTime " << syncTimeSec;
|
||||
|
||||
if (syncTimeSec > QDateTime::currentSecsSinceEpoch() - 3 &&
|
||||
syncTimeSec < QDateTime::currentSecsSinceEpoch() + 3)
|
||||
{
|
||||
DEBUG_LOG() << "PartitionTime is Still valid";
|
||||
DEBUG_LOG(m_logger) << "PartitionTime is Still valid";
|
||||
return;
|
||||
}
|
||||
if (!m_syncSocket->isOpen())
|
||||
@@ -831,7 +830,7 @@ void CanagHandler::sendSyncTime(uint32_t syncTimeSec)
|
||||
{
|
||||
m_syncSocket->write(QByteArray::number(syncTimeSec));
|
||||
m_syncSocket->flush();
|
||||
DEBUG_LOG() << "Send: " << syncTimeSec << " " << QByteArray::number(syncTimeSec);
|
||||
DEBUG_LOG(m_logger) << "Send: " << syncTimeSec << " " << QByteArray::number(syncTimeSec);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -839,13 +838,13 @@ void CanagHandler::send(const LtsUtils::SfmMessage &message)
|
||||
{
|
||||
|
||||
|
||||
DEBUG_LOG() << "send message - " << message.id() << " RTR: " << message.rtr();
|
||||
DEBUG_LOG(m_logger) << "send message - " << message.id() << " RTR: " << message.rtr();
|
||||
if (!message.payload().isEmpty())
|
||||
DEBUG_LOG() << " size: " << message.payload().size() << " data: " << message.payload().toHex(' ');
|
||||
DEBUG_LOG(m_logger) << " size: " << message.payload().size() << " data: " << message.payload().toHex(' ');
|
||||
|
||||
|
||||
if (!m_connectionHandler->send(message))
|
||||
ERROR_LOG() << "Could not send message!";
|
||||
ERROR_LOG(m_logger) << "Could not send message!";
|
||||
else
|
||||
emit sendMessage(message);
|
||||
}
|
||||
@@ -865,15 +864,15 @@ void CanagHandler::openSocket()
|
||||
|
||||
m_syncSocket->connectToHost(Settings::hostName(), 13777);
|
||||
if (!m_syncSocket->waitForConnected())
|
||||
WARNING_LOG() << "Could not (re)open tcp destination " << m_syncSocket->peerName() << ":" << m_syncSocket->peerPort() << ", error: " << m_syncSocket->errorString();
|
||||
WARNING_LOG(m_logger) << "Could not (re)open tcp destination " << m_syncSocket->peerName() << ":" << m_syncSocket->peerPort() << ", error: " << m_syncSocket->errorString();
|
||||
else
|
||||
{
|
||||
connect(m_syncSocket, &QTcpSocket::disconnected, this, [this]
|
||||
{
|
||||
DEBUG_LOG() << "Disconnected from Host";
|
||||
DEBUG_LOG(m_logger) << "Disconnected from Host";
|
||||
m_syncSocket->close();
|
||||
});
|
||||
DEBUG_LOG() << "(re)open tcp destination " << m_syncSocket->peerName() << ":" << m_syncSocket->peerPort();
|
||||
DEBUG_LOG(m_logger) << "(re)open tcp destination " << m_syncSocket->peerName() << ":" << m_syncSocket->peerPort();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,6 +53,8 @@ private slots:
|
||||
void sendAbortOrRestartTimeout();
|
||||
|
||||
private:
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
const qint32 s_maxResendCnt = 5;
|
||||
|
||||
struct DdlData
|
||||
|
||||
@@ -21,6 +21,7 @@ class ConnectionHandler : public ConnectionHandlerTcpTtci
|
||||
|
||||
public:
|
||||
explicit ConnectionHandler();
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
|
||||
}
|
||||
+13
-14
@@ -10,10 +10,9 @@
|
||||
namespace TrainingAreaBaseOC
|
||||
{
|
||||
|
||||
ConnectionHandlerSerial::ConnectionHandlerSerial()
|
||||
: m_spQuerry(new LtsSerialPortQuerry::LtsSerialPortQuerry(this))
|
||||
, m_receiveTimeoutTimer(new QTimer(this))
|
||||
{
|
||||
ConnectionHandlerSerial::ConnectionHandlerSerial() : m_spQuerry(new LtsSerialPortQuerry::LtsSerialPortQuerry(this))
|
||||
, m_receiveTimeoutTimer(new QTimer(this)),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
connect(m_spQuerry, &LtsSerialPortQuerry::LtsSerialPortQuerry::connectionEstablished, this, &ConnectionHandlerSerial::open);
|
||||
m_spQuerry->restartQuerry();
|
||||
m_receiveTimeoutTimer->setInterval(5000);
|
||||
@@ -34,25 +33,25 @@ bool ConnectionHandlerSerial::send(const LtsUtils::SfmMessage &message)
|
||||
|
||||
if (!m_serialPort->isOpen())
|
||||
{
|
||||
ERROR_LOG() << "Port is not opened!";
|
||||
ERROR_LOG(m_logger) << "Port is not opened!";
|
||||
return false;
|
||||
}
|
||||
|
||||
QByteArray data = LtsUtils::byteStreamFromSfmMessage(message);
|
||||
|
||||
DEBUG_LOG() << "Sending frame: " << data.toHex(' ');
|
||||
DEBUG_LOG(m_logger) << "Sending frame: " << data.toHex(' ');
|
||||
|
||||
const qint64 byteswritten = m_serialPort->write(data);
|
||||
m_serialPort->flush();
|
||||
|
||||
if (byteswritten == -1)
|
||||
{
|
||||
ERROR_LOG() << "Failed to write data to port " << m_serialPort->portName() << " error: " << m_serialPort->errorString();
|
||||
ERROR_LOG(m_logger) << "Failed to write data to port " << m_serialPort->portName() << " error: " << m_serialPort->errorString();
|
||||
return false;
|
||||
}
|
||||
else if (byteswritten != data.size())
|
||||
{
|
||||
ERROR_LOG() << "Failed to write all data to port " << m_serialPort->portName() << " error: " << m_serialPort->errorString();
|
||||
ERROR_LOG(m_logger) << "Failed to write all data to port " << m_serialPort->portName() << " error: " << m_serialPort->errorString();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -83,7 +82,7 @@ void ConnectionHandlerSerial::read()
|
||||
const QByteArray ba = m_serialPort->readAll();
|
||||
m_currentDataRead.append(ba);
|
||||
|
||||
DEBUG_LOG() << "Binary data from sfm: " << ba.toHex(' ');
|
||||
DEBUG_LOG(m_logger) << "Binary data from sfm: " << ba.toHex(' ');
|
||||
|
||||
int idxStart = -1;
|
||||
int idxEnd = -1;
|
||||
@@ -94,21 +93,21 @@ void ConnectionHandlerSerial::read()
|
||||
QByteArray message = m_currentDataRead.mid(idxStart, (idxEnd - idxStart) + 1);
|
||||
|
||||
LtsUtils::SfmMessage sfmMsg;
|
||||
DEBUG_LOG() << "Frame from sfm as binary " << message.toHex();
|
||||
DEBUG_LOG(m_logger) << "Frame from sfm as binary " << message.toHex();
|
||||
try
|
||||
{
|
||||
sfmMsg = LtsUtils::byteStreamToSfmMessage(message);
|
||||
}
|
||||
catch (const LtsUtils::ConversionError &ex)
|
||||
{
|
||||
ERROR_LOG() << "Error converting QByteArray into LtsUtils::SfmMessage: " << ex.what();
|
||||
ERROR_LOG() << "Faulty Data from sfm as binary " << message.toHex();
|
||||
ERROR_LOG(m_logger) << "Error converting QByteArray into LtsUtils::SfmMessage: " << ex.what();
|
||||
ERROR_LOG(m_logger) << "Faulty Data from sfm as binary " << message.toHex();
|
||||
m_currentDataRead = m_currentDataRead.mid(idxEnd + 1);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
INFO_LOG() << "Decoded message from sfm Id: " << sfmMsg.id() << " RTR: " << sfmMsg.rtr() << " Data: " << sfmMsg.payload().toHex();
|
||||
INFO_LOG(m_logger) << "Decoded message from sfm Id: " << sfmMsg.id() << " RTR: " << sfmMsg.rtr() << " Data: " << sfmMsg.payload().toHex();
|
||||
|
||||
m_receiveTimeoutTimer->start();
|
||||
|
||||
@@ -118,7 +117,7 @@ void ConnectionHandlerSerial::read()
|
||||
}
|
||||
|
||||
if (m_serialPort->bytesAvailable() > 0)
|
||||
DEBUG_LOG() << "Still " << m_serialPort->bytesAvailable() << " available to be read";
|
||||
DEBUG_LOG(m_logger) << "Still " << m_serialPort->bytesAvailable() << " available to be read";
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
@@ -37,6 +37,7 @@ private slots:
|
||||
void read();
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
LtsSerialPortQuerry::LtsSerialPortQuerry *m_spQuerry = nullptr;
|
||||
QSerialPort *m_serialPort = nullptr;
|
||||
QTimer *m_receiveTimeoutTimer = nullptr;
|
||||
|
||||
+18
-19
@@ -10,9 +10,8 @@
|
||||
namespace TrainingAreaBaseOC
|
||||
{
|
||||
|
||||
ConnectionHandlerTcp::ConnectionHandlerTcp()
|
||||
: m_timer(new QTimer(this))
|
||||
{
|
||||
ConnectionHandlerTcp::ConnectionHandlerTcp() : m_timer(new QTimer(this)),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
m_timer->setInterval(5000);
|
||||
connect(m_timer, &QTimer::timeout, this, &ConnectionHandlerTcp::open);
|
||||
}
|
||||
@@ -44,25 +43,25 @@ bool ConnectionHandlerTcp::send(const LtsUtils::SfmMessage &message)
|
||||
|
||||
if (!m_socket->isOpen())
|
||||
{
|
||||
ERROR_LOG() << "Port is not opened!";
|
||||
ERROR_LOG(m_logger) << "Port is not opened!";
|
||||
return false;
|
||||
}
|
||||
|
||||
QByteArray data = LtsUtils::byteStreamFromSfmMessage(message);
|
||||
|
||||
DEBUG_LOG() << "Sending frame: " << data.toHex(' ');
|
||||
DEBUG_LOG(m_logger) << "Sending frame: " << data.toHex(' ');
|
||||
|
||||
const qint64 byteswritten = m_socket->write(data);
|
||||
|
||||
if (byteswritten == -1)
|
||||
{
|
||||
ERROR_LOG() << "Failed to write data to port " << m_socket->peerPort() << " error: " << m_socket->errorString();
|
||||
ERROR_LOG(m_logger) << "Failed to write data to port " << m_socket->peerPort() << " error: " << m_socket->errorString();
|
||||
m_timer->start();
|
||||
return false;
|
||||
}
|
||||
else if (byteswritten != data.size())
|
||||
{
|
||||
ERROR_LOG() << "Failed to write all data to port " << m_socket->peerPort() << " error: " << m_socket->errorString();
|
||||
ERROR_LOG(m_logger) << "Failed to write all data to port " << m_socket->peerPort() << " error: " << m_socket->errorString();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -75,10 +74,10 @@ bool ConnectionHandlerTcp::open()
|
||||
m_socket->connectToHost(Settings::hostName(), Settings::port());
|
||||
if (!m_socket->waitForConnected())
|
||||
{
|
||||
ERROR_LOG() << "Could not (re)open tcp destination " << m_socket->peerName() << ":" << m_socket->peerPort() << ", error: " << m_socket->errorString();
|
||||
ERROR_LOG(m_logger) << "Could not (re)open tcp destination " << m_socket->peerName() << ":" << m_socket->peerPort() << ", error: " << m_socket->errorString();
|
||||
return false;
|
||||
}
|
||||
INFO_LOG() << "(Re)openend tcp destination " << m_socket->peerName() << ":" << Settings::port();
|
||||
INFO_LOG(m_logger) << "(Re)openend tcp destination " << m_socket->peerName() << ":" << Settings::port();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -97,7 +96,7 @@ void ConnectionHandlerTcp::read()
|
||||
const QByteArray ba = m_socket->readAll();
|
||||
m_currentDataRead.append(ba);
|
||||
|
||||
DEBUG_LOG() << "Binary data from sfm: " << ba.toHex(' ');
|
||||
DEBUG_LOG(m_logger) << "Binary data from sfm: " << ba.toHex(' ');
|
||||
|
||||
int idxStart = -1;
|
||||
int idxEnd = -1;
|
||||
@@ -107,7 +106,7 @@ void ConnectionHandlerTcp::read()
|
||||
QByteArray message = m_currentDataRead.mid(idxStart, (idxEnd - idxStart) + 1);
|
||||
|
||||
LtsUtils::SfmMessage sfmMsg;
|
||||
DEBUG_LOG() << "Frame from sfm as binary " << message.toHex();
|
||||
DEBUG_LOG(m_logger) << "Frame from sfm as binary " << message.toHex();
|
||||
|
||||
try
|
||||
{
|
||||
@@ -115,11 +114,11 @@ void ConnectionHandlerTcp::read()
|
||||
}
|
||||
catch (const LtsUtils::ConversionError &ex)
|
||||
{
|
||||
ERROR_LOG() << "Error converting QByteArray into LtsUtils::SfmMessage: " << ex.what();
|
||||
ERROR_LOG() << "Faulty Data from sfm as binary " << message.toHex();
|
||||
ERROR_LOG(m_logger) << "Error converting QByteArray into LtsUtils::SfmMessage: " << ex.what();
|
||||
ERROR_LOG(m_logger) << "Faulty Data from sfm as binary " << message.toHex();
|
||||
}
|
||||
|
||||
INFO_LOG() << "Decoded message from sfm Id: " << sfmMsg.id() << " RTR: " << sfmMsg.rtr() << " Data: " << sfmMsg.payload().toHex();
|
||||
INFO_LOG(m_logger) << "Decoded message from sfm Id: " << sfmMsg.id() << " RTR: " << sfmMsg.rtr() << " Data: " << sfmMsg.payload().toHex();
|
||||
|
||||
m_currentDataRead = m_currentDataRead.mid(idxEnd + 1);
|
||||
|
||||
@@ -127,12 +126,12 @@ void ConnectionHandlerTcp::read()
|
||||
}
|
||||
|
||||
if (m_socket->bytesAvailable() > 0)
|
||||
DEBUG_LOG() << "Still " << m_socket->bytesAvailable() << " available to be read";
|
||||
DEBUG_LOG(m_logger) << "Still " << m_socket->bytesAvailable() << " available to be read";
|
||||
}
|
||||
|
||||
void ConnectionHandlerTcp::handleError(QAbstractSocket::SocketError error)
|
||||
{
|
||||
DEBUG_LOG() << "Spontaneous error " << error << " doesn't have to be an error ...";
|
||||
DEBUG_LOG(m_logger) << "Spontaneous error " << error << " doesn't have to be an error ...";
|
||||
|
||||
const QString errStr(QStringLiteral("QTcpSocket::SocketError ") + QString::number(error) +
|
||||
QStringLiteral(" from tcp port ") + QString::number(m_socket->peerPort()) +
|
||||
@@ -144,20 +143,20 @@ void ConnectionHandlerTcp::handleError(QAbstractSocket::SocketError error)
|
||||
case QTcpSocket::SocketError::SocketAccessError:
|
||||
case QTcpSocket::SocketError::SocketResourceError:
|
||||
{
|
||||
ERROR_LOG() << "Closing port trying to reopen it.";
|
||||
ERROR_LOG(m_logger) << "Closing port trying to reopen it.";
|
||||
close();
|
||||
m_timer->start();
|
||||
Q_FALLTHROUGH();
|
||||
}
|
||||
case QTcpSocket::SocketError::RemoteHostClosedError:
|
||||
{
|
||||
ERROR_LOG() << "Host closed trying to reopen.";
|
||||
ERROR_LOG(m_logger) << "Host closed trying to reopen.";
|
||||
m_timer->start();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
ERROR_LOG() << errStr;
|
||||
ERROR_LOG(m_logger) << errStr;
|
||||
close();
|
||||
m_timer->start();
|
||||
break;
|
||||
|
||||
@@ -38,6 +38,7 @@ private slots:
|
||||
void handleError(QAbstractSocket::SocketError error);
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
QTcpSocket *m_socket = nullptr;
|
||||
QTimer *m_timer = nullptr;
|
||||
QByteArray m_currentDataRead;
|
||||
|
||||
+19
-20
@@ -13,15 +13,14 @@ using namespace NGL;
|
||||
|
||||
namespace TrainingAreaBaseOC
|
||||
{
|
||||
ConnectionHandlerTcpTtci::ConnectionHandlerTcpTtci()
|
||||
: m_messageDataStart(true)
|
||||
ConnectionHandlerTcpTtci::ConnectionHandlerTcpTtci() : m_messageDataStart(true)
|
||||
, m_wirkfeldDataStart(true)
|
||||
, m_wirkfeldMultiplex(0)
|
||||
, m_sendingData(false)
|
||||
, m_segmentToggle(0)
|
||||
, m_canDevice(new Device(this))
|
||||
, m_canChannel(new Channel(QLatin1Char('@'), true, this))
|
||||
{
|
||||
, m_canChannel(new Channel(QLatin1Char('@'), true, this)),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
connect(m_canChannel, &Channel::dataAvailable, this, &ConnectionHandlerTcpTtci::slotReadCanFrame);
|
||||
connect(m_canChannel, &Channel::disconnectedFromEq, this, &ConnectionHandlerTcpTtci::disconnectedFromEq);
|
||||
}
|
||||
@@ -42,7 +41,7 @@ bool ConnectionHandlerTcpTtci::init()
|
||||
|
||||
void ConnectionHandlerTcpTtci::initCanSocket()
|
||||
{
|
||||
ERROR_LOG() << "InitCantSOcket";
|
||||
ERROR_LOG(m_logger) << "InitCantSOcket";
|
||||
|
||||
m_canChannel->setDevice(m_canDevice);
|
||||
m_canDevice->open();
|
||||
@@ -53,10 +52,10 @@ bool ConnectionHandlerTcpTtci::findNextSyncByte(int &iCurReadPos) const
|
||||
{
|
||||
if (iCurReadPos == m_buffer.size())
|
||||
{
|
||||
DEBUG_LOG() << "No more data available";
|
||||
DEBUG_LOG(m_logger) << "No more data available";
|
||||
return false;
|
||||
}
|
||||
DEBUG_LOG() << "Searching for next sync byte, start at: " << iCurReadPos;
|
||||
DEBUG_LOG(m_logger) << "Searching for next sync byte, start at: " << iCurReadPos;
|
||||
NGL::NGLLoggerHelper::hexDumpHelper(m_logger, NGL::LogLevel::Debug, m_buffer);
|
||||
|
||||
while (iCurReadPos < m_buffer.size())
|
||||
@@ -70,7 +69,7 @@ bool ConnectionHandlerTcpTtci::findNextSyncByte(int &iCurReadPos) const
|
||||
|
||||
if (m_buffer.size() < 4 + iCurReadPos)
|
||||
{
|
||||
DEBUG_LOG() << "Could not find sync byte in stream";
|
||||
DEBUG_LOG(m_logger) << "Could not find sync byte in stream";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -83,11 +82,11 @@ void ConnectionHandlerTcpTtci::slotReadCanFrame(const QByteArray &data)
|
||||
int iCurReadPos = 0;
|
||||
while (findNextSyncByte(iCurReadPos))
|
||||
{
|
||||
DEBUG_LOG() << "Found Sync byte at " << iCurReadPos;
|
||||
DEBUG_LOG(m_logger) << "Found Sync byte at " << iCurReadPos;
|
||||
|
||||
|
||||
unsigned int len = (m_buffer.at(iCurReadPos + 1) & 0xF0) >> 4;
|
||||
DEBUG_LOG() << "Payload size: " << len;
|
||||
DEBUG_LOG(m_logger) << "Payload size: " << len;
|
||||
|
||||
if (len > 8)
|
||||
{
|
||||
@@ -96,22 +95,22 @@ void ConnectionHandlerTcpTtci::slotReadCanFrame(const QByteArray &data)
|
||||
{
|
||||
case 9:
|
||||
|
||||
DEBUG_LOG() << "Read status data - skipping ";
|
||||
DEBUG_LOG(m_logger) << "Read status data - skipping ";
|
||||
iCurReadPos += 4;
|
||||
break;
|
||||
case 11:
|
||||
|
||||
DEBUG_LOG() << "Read communication SFM - PAN - skipping ";
|
||||
DEBUG_LOG(m_logger) << "Read communication SFM - PAN - skipping ";
|
||||
iCurReadPos += 5;
|
||||
break;
|
||||
case 12:
|
||||
|
||||
DEBUG_LOG() << "Read parameter request - skipping ";
|
||||
DEBUG_LOG(m_logger) << "Read parameter request - skipping ";
|
||||
iCurReadPos += 5;
|
||||
break;
|
||||
default:
|
||||
|
||||
WARNING_LOG() << "Invalid payload size (" << len << " - skipping";
|
||||
WARNING_LOG(m_logger) << "Invalid payload size (" << len << " - skipping";
|
||||
++iCurReadPos;
|
||||
break;
|
||||
}
|
||||
@@ -124,7 +123,7 @@ void ConnectionHandlerTcpTtci::slotReadCanFrame(const QByteArray &data)
|
||||
int neededBytes = 4 + len + iCurReadPos;
|
||||
if (m_buffer.size() < neededBytes)
|
||||
{
|
||||
INFO_LOG() << "To few bytes in buffer - waiting for more (want: "
|
||||
INFO_LOG(m_logger) << "To few bytes in buffer - waiting for more (want: "
|
||||
<< neededBytes << " have: " << m_buffer.size() << ")";
|
||||
|
||||
break;
|
||||
@@ -134,7 +133,7 @@ void ConnectionHandlerTcpTtci::slotReadCanFrame(const QByteArray &data)
|
||||
unsigned char id2 = m_buffer.at(iCurReadPos + 2);
|
||||
id = ((id << 8) + id2);
|
||||
bool rtr = ((m_buffer.at(iCurReadPos + 1) & 0x08) == 0x08);
|
||||
DEBUG_LOG() << "CAN ID: " << id << " rtr: " << rtr;
|
||||
DEBUG_LOG(m_logger) << "CAN ID: " << id << " rtr: " << rtr;
|
||||
|
||||
|
||||
unsigned char crc = 0;
|
||||
@@ -146,7 +145,7 @@ void ConnectionHandlerTcpTtci::slotReadCanFrame(const QByteArray &data)
|
||||
if (crc != crcSent)
|
||||
{
|
||||
|
||||
WARNING_LOG() << "CRC checksum missmatch (is: " << crcSent
|
||||
WARNING_LOG(m_logger) << "CRC checksum missmatch (is: " << crcSent
|
||||
<< " - calculated: " << crc << ") - skipping";
|
||||
iCurReadPos++;
|
||||
continue;
|
||||
@@ -179,7 +178,7 @@ bool ConnectionHandlerTcpTtci::send(const LtsUtils::SfmMessage &message)
|
||||
if (message.payload().size() > 8)
|
||||
return false;
|
||||
|
||||
INFO_LOG() << "start write";
|
||||
INFO_LOG(m_logger) << "start write";
|
||||
NGL::NGLLoggerHelper::hexDumpHelper(m_logger, NGL::LogLevel::Debug, message.payload());
|
||||
|
||||
QByteArray data(message.payload().size() + 4, Qt::Uninitialized);
|
||||
@@ -196,10 +195,10 @@ bool ConnectionHandlerTcpTtci::send(const LtsUtils::SfmMessage &message)
|
||||
crc += data.at(i);
|
||||
crc = ~crc;
|
||||
data[message.payload().size() + 3] = crc;
|
||||
INFO_LOG() << "end write ";
|
||||
INFO_LOG(m_logger) << "end write ";
|
||||
|
||||
if (!m_canChannel->writeData(data))
|
||||
ERROR_LOG() << "Error writing data to can channel";
|
||||
ERROR_LOG(m_logger) << "Error writing data to can channel";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
+2
@@ -40,6 +40,7 @@ signals:
|
||||
void disconnectedFromEq();
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void initCanSocket();
|
||||
void newDataAvailable(const QByteArray &);
|
||||
bool findNextSyncByte(int &iCurReadPos) const;
|
||||
@@ -49,6 +50,7 @@ private slots:
|
||||
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
QByteArray m_messageData;
|
||||
bool m_messageDataStart;
|
||||
QByteArray m_wirkfeldData;
|
||||
|
||||
@@ -8,17 +8,16 @@
|
||||
namespace TrainingAreaBaseOC
|
||||
{
|
||||
|
||||
DdsHandler::DdsHandler(int domainId, int exerciseId)
|
||||
: m_ddsConnector(new DDSConnector::DdsConnector(domainId, IDL::PartitionType::Exercise, exerciseId))
|
||||
{
|
||||
DEBUG_LOG() << "DdsHandler(" << domainId << ") for partition: " << m_ddsConnector->getDefaultPartition();
|
||||
DdsHandler::DdsHandler(int domainId, int exerciseId) : m_ddsConnector(new DDSConnector::DdsConnector(domainId, IDL::PartitionType::Exercise, exerciseId)),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
DEBUG_LOG(m_logger) << "DdsHandler(" << domainId << ") for partition: " << m_ddsConnector->getDefaultPartition();
|
||||
}
|
||||
|
||||
bool DdsHandler::init(const QStringList &qosFileList)
|
||||
{
|
||||
if (!m_ddsConnector->init(qosFileList))
|
||||
{
|
||||
ERROR_LOG() << "Error initializing dds connections - aborting";
|
||||
ERROR_LOG(m_logger) << "Error initializing dds connections - aborting";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -33,23 +32,23 @@ bool DdsHandler::init(const QStringList &qosFileList)
|
||||
|
||||
m_dtsTaboc = Interface::Dts::create(m_ddsConnector);
|
||||
bRet &= m_dtsTaboc->enableAll();
|
||||
INFO_LOG() << "Dts TrainingAreaBaseOc initialised";
|
||||
INFO_LOG(m_logger) << "Dts TrainingAreaBaseOc initialised";
|
||||
|
||||
m_dtcTaboc = Interface::Dtc::create(m_ddsConnector);
|
||||
bRet &= m_dtsTaboc->enableSpecificsEquipment();
|
||||
INFO_LOG() << "Dtc TrainingAreaBaseOc initialised";
|
||||
INFO_LOG(m_logger) << "Dtc TrainingAreaBaseOc initialised";
|
||||
|
||||
m_ftsTaboc = Interface::Fts::create(m_ddsConnector);
|
||||
bRet &= m_ftsTaboc->enableAll();
|
||||
INFO_LOG() << "Fts TrainingAreaBaseOc initialised";
|
||||
INFO_LOG(m_logger) << "Fts TrainingAreaBaseOc initialised";
|
||||
|
||||
m_dtsTab = TrainingAreaBase::Interface::Dts::create(m_ddsConnector);
|
||||
bRet &= (m_dtsTab->enableOcData() && m_dtsTab->enableFireSmokeMarkerData());
|
||||
INFO_LOG() << "Dts TrainingAreaBase initialised";
|
||||
INFO_LOG(m_logger) << "Dts TrainingAreaBase initialised";
|
||||
|
||||
m_ftsTab = TrainingAreaBase::Interface::Fts::create(m_ddsConnector);
|
||||
bRet &= (m_ftsTab->enableSendOcData() && m_ftsTab->enableSendFireSmokeMarkerData());
|
||||
INFO_LOG() << "Fts TrainingAreaBase initialised";
|
||||
INFO_LOG(m_logger) << "Fts TrainingAreaBase initialised";
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
@@ -68,6 +68,7 @@ public:
|
||||
qint64 currentPartitionTime() const;
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
|
||||
std::shared_ptr<Core::Pacemaker> m_pacemaker;
|
||||
std::shared_ptr<Core::Interface::Dtc> m_dtcCore;
|
||||
|
||||
+68
-68
@@ -41,7 +41,7 @@ bool HandlerAesData::init()
|
||||
if (!m_aesDtc->enableBCContamination() || !m_aesDtc->enableExplosionArea() || !m_aesDtc->enableExplosionSingle() || !m_aesDtc->enableFunctionalArea()
|
||||
|| !m_aesDtc->enableNContamination() || !m_aesDtc->enableMineArea() || !m_aesDtc->enableExplosionCluster())
|
||||
{
|
||||
ERROR_LOG() << "Error enabling AES Data-Topics.";
|
||||
ERROR_LOG(m_logger) << "Error enabling AES Data-Topics.";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ bool HandlerAesData::init()
|
||||
|| !m_aesFtc->enableMineAreaRemove() || !m_aesFtc->enableExplosionClusterRemove() || !m_aesFtc->enableExplosionAreaPauseResume()
|
||||
|| !m_aesFtc->enableMineAreaReferenceModify())
|
||||
{
|
||||
ERROR_LOG() << "Error enabling AES Function-Topics.";
|
||||
ERROR_LOG(m_logger) << "Error enabling AES Function-Topics.";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ bool HandlerAesData::init()
|
||||
|
||||
if (!m_pdmDtc->enableChargeType() || !m_pdmDtc->enableGearTypeChargeType() || !m_pdmDtc->enableGearType())
|
||||
{
|
||||
ERROR_LOG() << "Error enabling PDM Data-Topic.";
|
||||
ERROR_LOG(m_logger) << "Error enabling PDM Data-Topic.";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -70,11 +70,11 @@ bool HandlerAesData::init()
|
||||
|| !m_aesDtc->waitForHistoricalDataNContamination(10000) || !m_aesDtc->waitForHistoricalDataMineArea(10000)
|
||||
|| !m_aesDtc->waitForHistoricalDataExplosionCluster(10000))
|
||||
{
|
||||
ERROR_LOG() << "Error waiting for historical data AES.";
|
||||
ERROR_LOG(m_logger) << "Error waiting for historical data AES.";
|
||||
return false;
|
||||
}
|
||||
|
||||
DEBUG_LOG() << "Initialisation successful";
|
||||
DEBUG_LOG(m_logger) << "Initialisation successful";
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ void HandlerAesData::process(const QByteArray &data, int multiplexer)
|
||||
break;
|
||||
}
|
||||
default:
|
||||
WARNING_LOG() << "Got unknown multiplexer.";
|
||||
WARNING_LOG(m_logger) << "Got unknown multiplexer.";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,121 +139,121 @@ void HandlerAesData::specificsExercise(const OcTelegrams::SpecificsExercise &dat
|
||||
void HandlerAesData::onMineAreaModifyFromCtaDataReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
if (reply.error())
|
||||
ERROR_LOG() << "Mine area modify failed: " << reply.translated();
|
||||
ERROR_LOG(m_logger) << "Mine area modify failed: " << reply.translated();
|
||||
else
|
||||
DEBUG_LOG() << "Mine area modify successfull. Id: " << reply.id();
|
||||
DEBUG_LOG(m_logger) << "Mine area modify successfull. Id: " << reply.id();
|
||||
}
|
||||
|
||||
void HandlerAesData::onNContaminationModifyReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
if (reply.error())
|
||||
ERROR_LOG() << "N contamination modify failed: " << reply.translated();
|
||||
ERROR_LOG(m_logger) << "N contamination modify failed: " << reply.translated();
|
||||
else
|
||||
DEBUG_LOG() << "N contamination modify successfull. Id: " << reply.id();
|
||||
DEBUG_LOG(m_logger) << "N contamination modify successfull. Id: " << reply.id();
|
||||
}
|
||||
|
||||
void HandlerAesData::onFunctionalAreaModifyReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
if (reply.error())
|
||||
ERROR_LOG() << "Functional area modify failed: " << reply.translated();
|
||||
ERROR_LOG(m_logger) << "Functional area modify failed: " << reply.translated();
|
||||
else
|
||||
DEBUG_LOG() << "Functional area modify successfull. Id: " << reply.id();
|
||||
DEBUG_LOG(m_logger) << "Functional area modify successfull. Id: " << reply.id();
|
||||
}
|
||||
|
||||
void HandlerAesData::onExplosionSingleModifyReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
if (reply.error())
|
||||
ERROR_LOG() << "Explosion single modify failed: " << reply.translated();
|
||||
ERROR_LOG(m_logger) << "Explosion single modify failed: " << reply.translated();
|
||||
else
|
||||
DEBUG_LOG() << "Explosion single modify successfull. Id: " << reply.id();
|
||||
DEBUG_LOG(m_logger) << "Explosion single modify successfull. Id: " << reply.id();
|
||||
}
|
||||
|
||||
void HandlerAesData::onExplosionAreaModifyReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
if (reply.error())
|
||||
ERROR_LOG() << "Explosion area modify failed: " << reply.translated();
|
||||
ERROR_LOG(m_logger) << "Explosion area modify failed: " << reply.translated();
|
||||
else
|
||||
DEBUG_LOG() << "Explosion area modify successfull. Id: " << reply.id();
|
||||
DEBUG_LOG(m_logger) << "Explosion area modify successfull. Id: " << reply.id();
|
||||
}
|
||||
|
||||
void HandlerAesData::onBCContaminationModifyReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
if (reply.error())
|
||||
ERROR_LOG() << "BC contamination modify failed: " << reply.translated();
|
||||
ERROR_LOG(m_logger) << "BC contamination modify failed: " << reply.translated();
|
||||
else
|
||||
DEBUG_LOG() << "BC contamination modify successfull. Id: " << reply.id();
|
||||
DEBUG_LOG(m_logger) << "BC contamination modify successfull. Id: " << reply.id();
|
||||
}
|
||||
|
||||
void HandlerAesData::onExplosionClusterOcModifyReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
if (reply.error())
|
||||
ERROR_LOG() << "ExplosionCluster modify failed: " << reply.translated();
|
||||
ERROR_LOG(m_logger) << "ExplosionCluster modify failed: " << reply.translated();
|
||||
else
|
||||
DEBUG_LOG() << "ExplosionCluster successfull. Id: " << reply.id();
|
||||
DEBUG_LOG(m_logger) << "ExplosionCluster successfull. Id: " << reply.id();
|
||||
}
|
||||
|
||||
void HandlerAesData::onMineAreaRemoveReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
if (reply.error())
|
||||
ERROR_LOG() << "Mine area remove failed: " << reply.translated();
|
||||
ERROR_LOG(m_logger) << "Mine area remove failed: " << reply.translated();
|
||||
else
|
||||
DEBUG_LOG() << "Mine area remove successfull. Id: " << reply.id();
|
||||
DEBUG_LOG(m_logger) << "Mine area remove successfull. Id: " << reply.id();
|
||||
}
|
||||
|
||||
void HandlerAesData::onNContaminationRemoveReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
if (reply.error())
|
||||
ERROR_LOG() << "N contamination remove failed: " << reply.translated();
|
||||
ERROR_LOG(m_logger) << "N contamination remove failed: " << reply.translated();
|
||||
else
|
||||
DEBUG_LOG() << "N contamination remove successfull. Id: " << reply.id();
|
||||
DEBUG_LOG(m_logger) << "N contamination remove successfull. Id: " << reply.id();
|
||||
}
|
||||
|
||||
void HandlerAesData::onFunctionalAreaRemoveReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
if (reply.error())
|
||||
ERROR_LOG() << "Functional area remove failed: " << reply.translated();
|
||||
ERROR_LOG(m_logger) << "Functional area remove failed: " << reply.translated();
|
||||
else
|
||||
DEBUG_LOG() << "Functional area remove successfull. Id: " << reply.id();
|
||||
DEBUG_LOG(m_logger) << "Functional area remove successfull. Id: " << reply.id();
|
||||
}
|
||||
|
||||
void HandlerAesData::onExplosionSingleRemoveReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
if (reply.error())
|
||||
ERROR_LOG() << "Explosion single remove failed: " << reply.translated();
|
||||
ERROR_LOG(m_logger) << "Explosion single remove failed: " << reply.translated();
|
||||
else
|
||||
DEBUG_LOG() << "Explosion single remove successfull. Id: " << reply.id();
|
||||
DEBUG_LOG(m_logger) << "Explosion single remove successfull. Id: " << reply.id();
|
||||
}
|
||||
|
||||
void HandlerAesData::onExplosionAreaRemoveReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
if (reply.error())
|
||||
ERROR_LOG() << "Explosion area remove failed: " << reply.translated();
|
||||
ERROR_LOG(m_logger) << "Explosion area remove failed: " << reply.translated();
|
||||
else
|
||||
DEBUG_LOG() << "Explosion area remove successfull. Id: " << reply.id();
|
||||
DEBUG_LOG(m_logger) << "Explosion area remove successfull. Id: " << reply.id();
|
||||
}
|
||||
|
||||
void HandlerAesData::onBCContaminationRemoveReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
if (reply.error())
|
||||
ERROR_LOG() << "BC contamination remove failed: " << reply.translated();
|
||||
ERROR_LOG(m_logger) << "BC contamination remove failed: " << reply.translated();
|
||||
else
|
||||
DEBUG_LOG() << "BC contamination remove successfull. Id: " << reply.id();
|
||||
DEBUG_LOG(m_logger) << "BC contamination remove successfull. Id: " << reply.id();
|
||||
}
|
||||
|
||||
void HandlerAesData::onExplosionClusterRemoveReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
if (reply.error())
|
||||
ERROR_LOG() << "ExplosionCluster remove failed: " << reply.translated();
|
||||
ERROR_LOG(m_logger) << "ExplosionCluster remove failed: " << reply.translated();
|
||||
else
|
||||
DEBUG_LOG() << "ExplosionCluster remove successfull. Id: " << reply.id();
|
||||
DEBUG_LOG(m_logger) << "ExplosionCluster remove successfull. Id: " << reply.id();
|
||||
}
|
||||
|
||||
void HandlerAesData::onExplosionAreaPauseResumeReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
if (reply.error())
|
||||
ERROR_LOG() << "Explosion area pause/resume failed: " << reply.translated();
|
||||
ERROR_LOG(m_logger) << "Explosion area pause/resume failed: " << reply.translated();
|
||||
else
|
||||
DEBUG_LOG() << "Explosion area pause/resume successfull. Id: " << reply.id();
|
||||
DEBUG_LOG(m_logger) << "Explosion area pause/resume successfull. Id: " << reply.id();
|
||||
}
|
||||
|
||||
template <typename T> static inline void getBasicData(const QByteArray &data, size_t &pos, T &req, bool withoutEffectStart = false)
|
||||
@@ -300,8 +300,8 @@ static inline double mathToCompassAngle(int mathDegree)
|
||||
|
||||
void HandlerAesData::bcContaminations(const QByteArray &data)
|
||||
{
|
||||
INFO_LOG() << "Got new BC contamination data";
|
||||
DEBUG_LOG() << "Binary data: " << data.toHex(' ');
|
||||
INFO_LOG(m_logger) << "Got new BC contamination data";
|
||||
DEBUG_LOG(m_logger) << "Binary data: " << data.toHex(' ');
|
||||
|
||||
QList<int> aesToBeDeleted = m_aesDtc->bCContaminations().keys();
|
||||
|
||||
@@ -340,7 +340,7 @@ void HandlerAesData::bcContaminations(const QByteArray &data)
|
||||
req.chargeTypeId(chargeTypeIdFromChargeTasCode(ProjectDataManagement::GearClass_def::Biological, tmp));
|
||||
LtsUtils::get1Byte(data, pos, tmp);
|
||||
|
||||
DEBUG_LOG() << (aesToBeDeleted.contains(req.id()) ? "Modifying " : "Creating ") << "BC contamination: " << req;
|
||||
DEBUG_LOG(m_logger) << (aesToBeDeleted.contains(req.id()) ? "Modifying " : "Creating ") << "BC contamination: " << req;
|
||||
|
||||
aesToBeDeleted.removeAll(req.id());
|
||||
req.id(req.id() * -1);
|
||||
@@ -354,7 +354,7 @@ void HandlerAesData::bcContaminations(const QByteArray &data)
|
||||
continue;
|
||||
if (m_aesDtc->bCContamination(id).effectStateId().underlying() > AreaEffectSimulation::AesEffectState::EsRemoved)
|
||||
{
|
||||
DEBUG_LOG() << "Removing BC contamination id: " << id;
|
||||
DEBUG_LOG(m_logger) << "Removing BC contamination id: " << id;
|
||||
m_aesFtc->bCContaminationRemoveRequest(Core::RemoveElementRequest(id), this);
|
||||
}
|
||||
}
|
||||
@@ -362,8 +362,8 @@ void HandlerAesData::bcContaminations(const QByteArray &data)
|
||||
|
||||
void HandlerAesData::explosionAreas(const QByteArray &data)
|
||||
{
|
||||
INFO_LOG() << "Got new explosion cluster data";
|
||||
DEBUG_LOG() << "Binary data: " << data.toHex(' ');
|
||||
INFO_LOG(m_logger) << "Got new explosion cluster data";
|
||||
DEBUG_LOG(m_logger) << "Binary data: " << data.toHex(' ');
|
||||
|
||||
QList<int> aesToBeDeleted = m_aesDtc->explosionClusters().keys();
|
||||
|
||||
@@ -441,12 +441,12 @@ void HandlerAesData::explosionAreas(const QByteArray &data)
|
||||
LtsUtils::get3Byte(data, pos, tmp);
|
||||
}
|
||||
|
||||
DEBUG_LOG() << "New ExplosionClusterOcModifyRequest: "
|
||||
DEBUG_LOG(m_logger) << "New ExplosionClusterOcModifyRequest: "
|
||||
<< "\nid:" << req.id() << "\nname:" << req.name() << "\neffectStart:" << req.effectStart() << "\neffectDuration:" << req.effectDuration()
|
||||
<< "\narea:" << req.area() << "\nmhpCount:" << req.mhpCount() << "\nmhpRotation:" << req.mhpRotation() << "\nimpactCount:" << req.impactCount()
|
||||
<< "\nchargeTypeId:" << req.chargeStruct().chargeTypeId() << "\npartyId:" << req.partyId();
|
||||
|
||||
DEBUG_LOG() << (aesToBeDeleted.contains(req.id()) ? "Modifying " : "Creating ") << "explosion cluster: " << req;
|
||||
DEBUG_LOG(m_logger) << (aesToBeDeleted.contains(req.id()) ? "Modifying " : "Creating ") << "explosion cluster: " << req;
|
||||
aesToBeDeleted.removeOne(req.id());
|
||||
req.id(req.id() * -1);
|
||||
|
||||
@@ -466,7 +466,7 @@ void HandlerAesData::explosionAreas(const QByteArray &data)
|
||||
||
|
||||
(exp.effectStateId().underlying() == AreaEffectSimulation::AesEffectState::EsPaused))))
|
||||
{
|
||||
DEBUG_LOG() << "Removing explosion cluster with id: " << id;
|
||||
DEBUG_LOG(m_logger) << "Removing explosion cluster with id: " << id;
|
||||
m_aesFtc->explosionClusterRemoveRequest(Core::RemoveElementRequest(id), this);
|
||||
}
|
||||
}
|
||||
@@ -474,8 +474,8 @@ void HandlerAesData::explosionAreas(const QByteArray &data)
|
||||
|
||||
void HandlerAesData::explosionSingles(const QByteArray &data)
|
||||
{
|
||||
INFO_LOG() << "Got new explosion single data";
|
||||
DEBUG_LOG() << "Binary data: " << data.toHex(' ');
|
||||
INFO_LOG(m_logger) << "Got new explosion single data";
|
||||
DEBUG_LOG(m_logger) << "Binary data: " << data.toHex(' ');
|
||||
|
||||
QList<int> aesToBeDeleted = m_aesDtc->explosionSingles().keys();
|
||||
|
||||
@@ -502,7 +502,7 @@ void HandlerAesData::explosionSingles(const QByteArray &data)
|
||||
req.chargeTypeId(chargeTypeIdFromChargeTasCode(ProjectDataManagement::GearClass_def::Artillery, tmp));
|
||||
if (req.chargeTypeId() == 0)
|
||||
req.chargeTypeId(chargeTypeIdFromChargeTasCode(ProjectDataManagement::GearClass_def::Mortar, tmp));
|
||||
DEBUG_LOG() << (aesToBeDeleted.contains(req.id()) ? "Modifying " : "Creating ") << "explosion single: " << req;
|
||||
DEBUG_LOG(m_logger) << (aesToBeDeleted.contains(req.id()) ? "Modifying " : "Creating ") << "explosion single: " << req;
|
||||
|
||||
aesToBeDeleted.removeAll(req.id());
|
||||
req.id(req.id() * -1);
|
||||
@@ -517,7 +517,7 @@ void HandlerAesData::explosionSingles(const QByteArray &data)
|
||||
if ((exp.effectStateId().underlying() > AreaEffectSimulation::AesEffectState::EsRemoved)
|
||||
&& (exp.effectStart().is_set() && (exp.effectStart().get() > (m_dds->currentPartitionTime() + 5000))))
|
||||
{
|
||||
DEBUG_LOG() << "Removing explosion single id: " << id;
|
||||
DEBUG_LOG(m_logger) << "Removing explosion single id: " << id;
|
||||
m_aesFtc->explosionSingleRemoveRequest(Core::RemoveElementRequest(id), this);
|
||||
}
|
||||
}
|
||||
@@ -525,8 +525,8 @@ void HandlerAesData::explosionSingles(const QByteArray &data)
|
||||
|
||||
void HandlerAesData::functionalAreas(const QByteArray &data)
|
||||
{
|
||||
INFO_LOG() << "Got functional area data";
|
||||
DEBUG_LOG() << "Binary data: " << data.toHex(' ');
|
||||
INFO_LOG(m_logger) << "Got functional area data";
|
||||
DEBUG_LOG(m_logger) << "Binary data: " << data.toHex(' ');
|
||||
|
||||
QList<int> aesToBeDeleted = m_aesDtc->functionalAreas().keys();
|
||||
|
||||
@@ -571,7 +571,7 @@ void HandlerAesData::functionalAreas(const QByteArray &data)
|
||||
req.medicTime(tmp * 10 * 60 * 1000);
|
||||
req.chargeTypeId(411);
|
||||
|
||||
DEBUG_LOG() << (aesToBeDeleted.contains(req.id()) ? "Modifying " : "Creating ") << "functional area: " << req;
|
||||
DEBUG_LOG(m_logger) << (aesToBeDeleted.contains(req.id()) ? "Modifying " : "Creating ") << "functional area: " << req;
|
||||
|
||||
aesToBeDeleted.removeAll(req.id());
|
||||
req.id(req.id() * -1);
|
||||
@@ -585,7 +585,7 @@ void HandlerAesData::functionalAreas(const QByteArray &data)
|
||||
continue;
|
||||
if (m_aesDtc->functionalArea(id).effectStateId().underlying() > AreaEffectSimulation::AesEffectState::EsRemoved)
|
||||
{
|
||||
DEBUG_LOG() << "Removing functional area id: " << id;
|
||||
DEBUG_LOG(m_logger) << "Removing functional area id: " << id;
|
||||
m_aesFtc->functionalAreaRemoveRequest(Core::RemoveElementRequest(id), this);
|
||||
}
|
||||
}
|
||||
@@ -593,8 +593,8 @@ void HandlerAesData::functionalAreas(const QByteArray &data)
|
||||
|
||||
void HandlerAesData::nContaminations(const QByteArray &data)
|
||||
{
|
||||
INFO_LOG() << "Got new N contamination data";
|
||||
DEBUG_LOG() << "Binary data: " << data.toHex(' ');
|
||||
INFO_LOG(m_logger) << "Got new N contamination data";
|
||||
DEBUG_LOG(m_logger) << "Binary data: " << data.toHex(' ');
|
||||
|
||||
QList<int> aesToBeDeleted = m_aesDtc->nContaminations().keys();
|
||||
|
||||
@@ -628,7 +628,7 @@ void HandlerAesData::nContaminations(const QByteArray &data)
|
||||
|
||||
req.chargeTypeId(chargeTypeIdFromChargeTasCode(ProjectDataManagement::GearClass_def::Nuclear, 1));
|
||||
|
||||
DEBUG_LOG() << (aesToBeDeleted.contains(req.id()) ? "Modifying " : "Creating ") << "N contamination: " << req;
|
||||
DEBUG_LOG(m_logger) << (aesToBeDeleted.contains(req.id()) ? "Modifying " : "Creating ") << "N contamination: " << req;
|
||||
|
||||
aesToBeDeleted.removeAll(req.id());
|
||||
req.id(req.id() * -1);
|
||||
@@ -642,7 +642,7 @@ void HandlerAesData::nContaminations(const QByteArray &data)
|
||||
continue;
|
||||
if (m_aesDtc->nContamination(id).effectStateId().underlying() > AreaEffectSimulation::AesEffectState::EsRemoved)
|
||||
{
|
||||
DEBUG_LOG() << "Removing N contamination id: " << id;
|
||||
DEBUG_LOG(m_logger) << "Removing N contamination id: " << id;
|
||||
m_aesFtc->nContaminationRemoveRequest(Core::RemoveElementRequest(id), this);
|
||||
}
|
||||
}
|
||||
@@ -650,8 +650,8 @@ void HandlerAesData::nContaminations(const QByteArray &data)
|
||||
|
||||
void HandlerAesData::mineAreas(const QByteArray &data)
|
||||
{
|
||||
INFO_LOG() << "Got new mine area data";
|
||||
DEBUG_LOG() << "Binary data: " << data.toHex(' ');
|
||||
INFO_LOG(m_logger) << "Got new mine area data";
|
||||
DEBUG_LOG(m_logger) << "Binary data: " << data.toHex(' ');
|
||||
|
||||
QList<int> aesToBeDeleted = m_aesDtc->mineAreas().keys();
|
||||
|
||||
@@ -700,7 +700,7 @@ void HandlerAesData::mineAreas(const QByteArray &data)
|
||||
|
||||
req.isCenterLine(true);
|
||||
|
||||
DEBUG_LOG() << (aesToBeDeleted.contains(req.id()) ? "Modifying " : "Creating ") << "mine area: " << req;
|
||||
DEBUG_LOG(m_logger) << (aesToBeDeleted.contains(req.id()) ? "Modifying " : "Creating ") << "mine area: " << req;
|
||||
|
||||
aesToBeDeleted.removeAll(req.id());
|
||||
req.id(req.id() * -1);
|
||||
@@ -715,7 +715,7 @@ void HandlerAesData::mineAreas(const QByteArray &data)
|
||||
continue;
|
||||
if (m_aesDtc->mineArea(id).effectStateId().underlying() > AreaEffectSimulation::AesEffectState::EsRemoved)
|
||||
{
|
||||
DEBUG_LOG() << "Removing mine area id: " << id;
|
||||
DEBUG_LOG(m_logger) << "Removing mine area id: " << id;
|
||||
m_aesFtc->mineAreaRemoveRequest(Core::RemoveElementRequest(id), this);
|
||||
}
|
||||
}
|
||||
@@ -723,8 +723,8 @@ void HandlerAesData::mineAreas(const QByteArray &data)
|
||||
|
||||
void HandlerAesData::explosionAreasPause(const QByteArray &data)
|
||||
{
|
||||
INFO_LOG() << "Got new explosion area pause data";
|
||||
DEBUG_LOG() << "Binary data: " << data.toHex(' ');
|
||||
INFO_LOG(m_logger) << "Got new explosion area pause data";
|
||||
DEBUG_LOG(m_logger) << "Binary data: " << data.toHex(' ');
|
||||
|
||||
size_t pos = 0;
|
||||
int cnt;
|
||||
@@ -734,7 +734,7 @@ void HandlerAesData::explosionAreasPause(const QByteArray &data)
|
||||
for (int i = 0; i < cnt; ++i)
|
||||
{
|
||||
LtsUtils::get2Byte(data, pos, id);
|
||||
DEBUG_LOG() << "Pausing ID: " << id;
|
||||
DEBUG_LOG(m_logger) << "Pausing ID: " << id;
|
||||
m_aesFtc->explosionAreaPauseResumeRequest(AreaEffectSimulation::ExplosionAreaPauseResumeRequest(id,
|
||||
false,
|
||||
dds::core::optional<rti::core::int64>(),
|
||||
@@ -746,8 +746,8 @@ void HandlerAesData::explosionAreasPause(const QByteArray &data)
|
||||
|
||||
void HandlerAesData::explosionAreasResume(const QByteArray &data)
|
||||
{
|
||||
INFO_LOG() << "Got new explosion area resume data";
|
||||
DEBUG_LOG() << "Binary data: " << data.toHex(' ');
|
||||
INFO_LOG(m_logger) << "Got new explosion area resume data";
|
||||
DEBUG_LOG(m_logger) << "Binary data: " << data.toHex(' ');
|
||||
|
||||
size_t pos = 0;
|
||||
int cnt;
|
||||
@@ -766,7 +766,7 @@ void HandlerAesData::explosionAreasResume(const QByteArray &data)
|
||||
req.timeToResume(dds::core::optional<rti::core::int64>(tmp * 1000));
|
||||
LtsUtils::get2Byte(data, pos, tmp);
|
||||
req.remainingDuration(dds::core::optional<int32_t>(tmp));
|
||||
DEBUG_LOG() << "Resuming: " << req;
|
||||
DEBUG_LOG(m_logger) << "Resuming: " << req;
|
||||
m_aesFtc->explosionAreaPauseResumeRequest(req, this);
|
||||
}
|
||||
}
|
||||
@@ -779,7 +779,7 @@ int HandlerAesData::chargeTypeIdFromChargeTasCode(ProjectDataManagement::GearCla
|
||||
{
|
||||
if (!m_pdmDtc->waitForHistoricalDataChargeType(20000))
|
||||
{
|
||||
ERROR_LOG() << "Can not read charge types from PDM";
|
||||
ERROR_LOG(m_logger) << "Can not read charge types from PDM";
|
||||
QCoreApplication::exit(-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -9,8 +9,7 @@
|
||||
namespace TrainingAreaBaseOC
|
||||
{
|
||||
|
||||
MainHandler::MainHandler(QObject *parent)
|
||||
: QObject(parent)
|
||||
MainHandler::MainHandler(QObject *parent) : QObject(parent)
|
||||
, m_aesDtc(nullptr)
|
||||
, m_aesFtc(nullptr)
|
||||
, m_pdmDtc(nullptr)
|
||||
@@ -19,8 +18,8 @@ MainHandler::MainHandler(QObject *parent)
|
||||
, m_ddsHandler(nullptr)
|
||||
, m_rxHandler(nullptr)
|
||||
, m_ftsHandler(nullptr)
|
||||
, m_websocketHandler(nullptr)
|
||||
{}
|
||||
, m_websocketHandler(nullptr),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {}
|
||||
|
||||
MainHandler::~MainHandler()
|
||||
{
|
||||
@@ -40,28 +39,28 @@ bool MainHandler::init(int domainId, int exerciseId)
|
||||
m_ddsHandler = std::make_shared<DdsHandler>(domainId, exerciseId);
|
||||
if (!m_ddsHandler->init())
|
||||
{
|
||||
ERROR_LOG() << "Could not initialise DdsHandler.";
|
||||
ERROR_LOG(m_logger) << "Could not initialise DdsHandler.";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
m_aesDtc = AreaEffectSimulation::Interface::Dtc::create(m_ddsHandler->ddsConnector());
|
||||
DEBUG_LOG() << "Created AES Dtc";
|
||||
DEBUG_LOG(m_logger) << "Created AES Dtc";
|
||||
|
||||
|
||||
m_aesFtc = AreaEffectSimulation::Interface::Ftc::create(m_ddsHandler->ddsConnector());
|
||||
DEBUG_LOG() << "Created AES Ftc";
|
||||
DEBUG_LOG(m_logger) << "Created AES Ftc";
|
||||
|
||||
|
||||
m_pdmDtc = ProjectDataManagement::Interface::Dtc::create(m_ddsHandler->ddsConnector());
|
||||
DEBUG_LOG() << "Created PDM Dtc";
|
||||
DEBUG_LOG(m_logger) << "Created PDM Dtc";
|
||||
|
||||
|
||||
m_connectionHandler = std::make_shared<ConnectionHandler>();
|
||||
|
||||
if (!m_connectionHandler->init())
|
||||
{
|
||||
ERROR_LOG() << "Could not initialise ConnectionHandler.";
|
||||
ERROR_LOG(m_logger) << "Could not initialise ConnectionHandler.";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -73,7 +72,7 @@ bool MainHandler::init(int domainId, int exerciseId)
|
||||
|
||||
if (!m_canagHandler->init())
|
||||
{
|
||||
ERROR_LOG() << "Could not initialise CanagHandler.";
|
||||
ERROR_LOG(m_logger) << "Could not initialise CanagHandler.";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ public:
|
||||
int exerciseId() const { return m_ddsHandler->ddsConnector()->getPartitionId(); }
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_aesDtc;
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Ftc> m_aesFtc;
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
|
||||
|
||||
@@ -28,6 +28,8 @@ public:
|
||||
void onSendFireSmokeMarkerDataRequest(const rti::core::SampleIdentity &cookie, const TrainingAreaBase::SendFireSmokeMarkerDataRequest &request) override;
|
||||
|
||||
private:
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
static Core::FunctionReplyObject fillFro(bool bSuccess);
|
||||
|
||||
private:
|
||||
|
||||
@@ -10,12 +10,11 @@
|
||||
namespace TrainingAreaBaseOC
|
||||
{
|
||||
|
||||
SendToDds::SendToDds(MainHandler *mainHandler)
|
||||
: m_dtsTaboc(mainHandler->dds()->dtsTaboc())
|
||||
SendToDds::SendToDds(MainHandler *mainHandler) : m_dtsTaboc(mainHandler->dds()->dtsTaboc())
|
||||
, m_dtsTab(mainHandler->dds()->dtsTab())
|
||||
, m_utmCoord(LtsCoordTrans::UtmCoordinate())
|
||||
, m_idToSend(1)
|
||||
{}
|
||||
, m_idToSend(1),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {}
|
||||
|
||||
void SendToDds::rxData(const OcTelegrams::Display &inData)
|
||||
{
|
||||
@@ -162,7 +161,7 @@ void SendToDds::rxData(const TrainingAreaBase::TetraIcd::OpaquePayloadDataBase &
|
||||
}
|
||||
default:
|
||||
{
|
||||
ERROR_LOG() << "Received unhandled TrainingAreaBase::TetraIcd::OpaquePayloadDataBase::Type " << static_cast<int>(inData.payloadType);
|
||||
ERROR_LOG(m_logger) << "Received unhandled TrainingAreaBase::TetraIcd::OpaquePayloadDataBase::Type " << static_cast<int>(inData.payloadType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ public:
|
||||
void rxData(const TrainingAreaBase::TetraIcd::OpaquePayloadDataBase &inData);
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::shared_ptr<Interface::Dts> m_dtsTaboc;
|
||||
std::shared_ptr<TrainingAreaBase::Interface::Dts> m_dtsTab;
|
||||
|
||||
|
||||
@@ -9,13 +9,12 @@
|
||||
namespace TrainingAreaBaseOC
|
||||
{
|
||||
|
||||
Channel::Channel(QChar channel, bool bIsBinary, QObject *parent)
|
||||
: QObject(parent)
|
||||
Channel::Channel(QChar channel, bool bIsBinary, QObject *parent) : QObject(parent)
|
||||
, m_channel(channel)
|
||||
, m_bIsBinary(bIsBinary)
|
||||
, m_device(nullptr)
|
||||
.getNGLLogger("SCTT.Channel"))
|
||||
{}
|
||||
.getNGLLogger("SCTT.Channel")),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {}
|
||||
|
||||
void Channel::setDevice(Device *dev)
|
||||
{
|
||||
@@ -34,7 +33,7 @@ bool Channel::writeData(const QByteArray &data)
|
||||
{
|
||||
if (!m_device || !m_device->isOpen())
|
||||
{
|
||||
WARNING_LOG() << "Error writing data - device is not open" ;
|
||||
WARNING_LOG(m_logger) << "Error writing data - device is not open" ;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -61,7 +60,7 @@ void Channel::onDeviceDestroyed()
|
||||
|
||||
void Channel::onDataAvailable(const QByteArray &data)
|
||||
{
|
||||
TRACE_LOG() << "Data available from "
|
||||
TRACE_LOG(m_logger) << "Data available from "
|
||||
<< ", we are: " << m_channel
|
||||
<< ", data: '" << data << "'" ;
|
||||
emit dataAvailable(data);
|
||||
|
||||
@@ -36,6 +36,8 @@ protected slots:
|
||||
void onDataAvailable(const QByteArray &data);
|
||||
|
||||
protected:
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
QChar m_channel;
|
||||
bool m_bIsBinary;
|
||||
Device *m_device;
|
||||
|
||||
@@ -10,15 +10,14 @@
|
||||
|
||||
namespace TrainingAreaBaseOC
|
||||
{
|
||||
Device::Device(QObject *parent, bool tcpMode)
|
||||
: QObject(parent)
|
||||
Device::Device(QObject *parent, bool tcpMode) : QObject(parent)
|
||||
, m_spQuerry(new LtsSerialPortQuerry::LtsSerialPortQuerry(this))
|
||||
, m_socket(new QTcpSocket(this))
|
||||
, m_restartTimer(new QTimer(this))
|
||||
, m_receiveTimeoutTimer(new QTimer(this))
|
||||
, m_tcpMode(tcpMode)
|
||||
.getNGLLogger("TTCI.Device"))
|
||||
{
|
||||
.getNGLLogger("TTCI.Device")),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
connect(m_spQuerry, &LtsSerialPortQuerry::LtsSerialPortQuerry::connectionEstablished, this, &Device::open);
|
||||
m_spQuerry->restartQuerry();
|
||||
|
||||
@@ -36,7 +35,7 @@ Device::~Device()
|
||||
|
||||
void Device::reOpen()
|
||||
{
|
||||
DEBUG_LOG() << "ConnectionHandlerSerial::reOpen";
|
||||
DEBUG_LOG(m_logger) << "ConnectionHandlerSerial::reOpen";
|
||||
close();
|
||||
QTimer::singleShot(2000, this, &Device::open);
|
||||
}
|
||||
@@ -52,19 +51,19 @@ bool Device::open()
|
||||
m_socket->connectToHost(Settings::hostName(), Settings::portTtci());
|
||||
if (!m_socket->waitForConnected())
|
||||
{
|
||||
ERROR_LOG() << "Could not (re)open tcp destination " << m_socket->peerName() << ":" << m_socket->peerPort() << ", error: " << m_socket->errorString();
|
||||
ERROR_LOG(m_logger) << "Could not (re)open tcp destination " << m_socket->peerName() << ":" << m_socket->peerPort() << ", error: " << m_socket->errorString();
|
||||
return false;
|
||||
}
|
||||
connect(m_socket, &QTcpSocket::readyRead, this, &Device::onDataAvailable);
|
||||
connect(m_socket, QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error), this, &Device::handleError);
|
||||
connect(m_socket, &QTcpSocket::disconnected, this, &Device::open);
|
||||
DEBUG_LOG() << "(Re)openend tcp destination " << m_socket->peerName() << ":" << Settings::portTtci();
|
||||
DEBUG_LOG(m_logger) << "(Re)openend tcp destination " << m_socket->peerName() << ":" << Settings::portTtci();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
m_serialPort = m_spQuerry->currentSerialPort();
|
||||
DEBUG_LOG() << "(Re)openend serial destination " << m_serialPort->portName() << ":";
|
||||
DEBUG_LOG(m_logger) << "(Re)openend serial destination " << m_serialPort->portName() << ":";
|
||||
|
||||
connect(m_serialPort, &QSerialPort::readyRead, this, &Device::onDataAvailable);
|
||||
|
||||
@@ -79,7 +78,7 @@ bool Device::close()
|
||||
{
|
||||
if (m_socket->isOpen())
|
||||
m_socket->close();
|
||||
DEBUG_LOG() << "Closing TCP Port";
|
||||
DEBUG_LOG(m_logger) << "Closing TCP Port";
|
||||
delete m_socket;
|
||||
m_socket = nullptr;
|
||||
m_receiveTimeoutTimer->stop();
|
||||
@@ -110,7 +109,7 @@ void Device::onDataAvailable()
|
||||
|
||||
void Device::parseBuffer()
|
||||
{
|
||||
DEBUG_LOG() << "Buffer - size: " << m_buffer.size()
|
||||
DEBUG_LOG(m_logger) << "Buffer - size: " << m_buffer.size()
|
||||
<< ", data: " << m_buffer.toHex() ;
|
||||
|
||||
|
||||
@@ -118,21 +117,21 @@ void Device::parseBuffer()
|
||||
int idxStart = -1;
|
||||
while ((idxStart = m_buffer.indexOf(0x02)) >= 0)
|
||||
{
|
||||
TRACE_LOG() << "idxStart: " << idxStart ;
|
||||
TRACE_LOG(m_logger) << "idxStart: " << idxStart ;
|
||||
|
||||
int idxLen = idxStart + 1;
|
||||
if (idxLen >= m_buffer.size())
|
||||
return;
|
||||
|
||||
unsigned char len = static_cast<unsigned char>(m_buffer.at(idxLen));
|
||||
TRACE_LOG() << "idxLen: " << idxLen
|
||||
TRACE_LOG(m_logger) << "idxLen: " << idxLen
|
||||
<< ", len: " << len
|
||||
<< " = 0x" << QByteArray::number(len, 16);
|
||||
int idxCrc = idxLen + len + 1;
|
||||
int idxEnd = idxCrc + 1;
|
||||
if (idxEnd >= m_buffer.size())
|
||||
return;
|
||||
TRACE_LOG() << "idxCrc: " << idxCrc
|
||||
TRACE_LOG(m_logger) << "idxCrc: " << idxCrc
|
||||
<< ", idxEnd: " << idxEnd ;
|
||||
if (idxEnd >= m_buffer.size())
|
||||
return;
|
||||
@@ -141,7 +140,7 @@ void Device::parseBuffer()
|
||||
if (m_buffer.at(idxEnd) != 0x03)
|
||||
{
|
||||
|
||||
WARNING_LOG() << "Could not find valid end marker - searching new start marker"
|
||||
WARNING_LOG(m_logger) << "Could not find valid end marker - searching new start marker"
|
||||
;
|
||||
m_buffer = m_buffer.mid(1);
|
||||
continue;
|
||||
@@ -149,12 +148,12 @@ void Device::parseBuffer()
|
||||
|
||||
unsigned char crc = static_cast<unsigned char>(m_buffer.at(idxCrc));
|
||||
unsigned char crcCalc = calcChecksum(m_buffer.mid(idxStart, idxCrc - idxStart));
|
||||
TRACE_LOG() << "crc: " << crc
|
||||
TRACE_LOG(m_logger) << "crc: " << crc
|
||||
<< ", calculated: " << crcCalc
|
||||
;
|
||||
if (crc != crcCalc)
|
||||
{
|
||||
WARNING_LOG() << "Invalid checksum - is: " << crcCalc
|
||||
WARNING_LOG(m_logger) << "Invalid checksum - is: " << crcCalc
|
||||
<< " - should be: " << crc ;
|
||||
}
|
||||
|
||||
@@ -163,15 +162,15 @@ void Device::parseBuffer()
|
||||
|
||||
if (len == 255 || !m_payload.isEmpty())
|
||||
{
|
||||
DEBUG_LOG() << "telegram with more than 254 bytes ..." ;
|
||||
DEBUG_LOG(m_logger) << "telegram with more than 254 bytes ..." ;
|
||||
|
||||
if (len == 255 && m_payload.isEmpty())
|
||||
DEBUG_LOG() << "Remember the payload destination: " << destination ;
|
||||
DEBUG_LOG(m_logger) << "Remember the payload destination: " << destination ;
|
||||
m_payload += payload;
|
||||
if (len != 255)
|
||||
{
|
||||
|
||||
DEBUG_LOG() << "destination: " << destination
|
||||
DEBUG_LOG(m_logger) << "destination: " << destination
|
||||
<< ", data: " << m_payload.toHex() ;
|
||||
emit dataAvailable(m_payload);
|
||||
m_payload.clear();
|
||||
@@ -180,7 +179,7 @@ void Device::parseBuffer()
|
||||
else
|
||||
{
|
||||
|
||||
DEBUG_LOG() << "destination: " << destination
|
||||
DEBUG_LOG(m_logger) << "destination: " << destination
|
||||
<< ", data: " << payload.toHex() ;
|
||||
emit dataAvailable(payload);
|
||||
}
|
||||
@@ -197,7 +196,7 @@ bool Device::writeData(const QChar destination, const QByteArray &payload)
|
||||
if ((m_tcpMode && !m_socket->isOpen()) || (!m_tcpMode && !m_serialPort->isOpen()))
|
||||
return false;
|
||||
|
||||
DEBUG_LOG() << "Writing " << payload.size()
|
||||
DEBUG_LOG(m_logger) << "Writing " << payload.size()
|
||||
<< " Bytes to channel " << destination ;
|
||||
|
||||
QByteArray data = payload;
|
||||
@@ -215,7 +214,7 @@ bool Device::writeData(const QChar destination, const QByteArray &payload)
|
||||
buf.append(calcChecksum(buf));
|
||||
buf.append(0x03);
|
||||
|
||||
DEBUG_LOG() << "Writing: " << buf.toHex() ;
|
||||
DEBUG_LOG(m_logger) << "Writing: " << buf.toHex() ;
|
||||
if (m_tcpMode)
|
||||
m_socket->write(buf);
|
||||
else
|
||||
@@ -245,7 +244,7 @@ unsigned char Device::calcChecksum(const QByteArray &checksumData)
|
||||
|
||||
void Device::handleError(QAbstractSocket::SocketError error)
|
||||
{
|
||||
DEBUG_LOG() << "Spontaneous error " << error << " doesn't have to be an error ...";
|
||||
DEBUG_LOG(m_logger) << "Spontaneous error " << error << " doesn't have to be an error ...";
|
||||
|
||||
const QString errStr(QStringLiteral("QTcpSocket::SocketError ") + QString::number(error) +
|
||||
QStringLiteral(" from tcp port ") + QString::number(m_socket->peerPort()) +
|
||||
@@ -257,20 +256,20 @@ void Device::handleError(QAbstractSocket::SocketError error)
|
||||
case QTcpSocket::SocketError::SocketAccessError:
|
||||
case QTcpSocket::SocketError::SocketResourceError:
|
||||
{
|
||||
ERROR_LOG() << "Closing port trying to reopen it.";
|
||||
ERROR_LOG(m_logger) << "Closing port trying to reopen it.";
|
||||
close();
|
||||
m_restartTimer->start();
|
||||
Q_FALLTHROUGH();
|
||||
}
|
||||
case QTcpSocket::SocketError::RemoteHostClosedError:
|
||||
{
|
||||
ERROR_LOG() << "Host closed trying to reopen.";
|
||||
ERROR_LOG(m_logger) << "Host closed trying to reopen.";
|
||||
m_restartTimer->start();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
ERROR_LOG() << errStr;
|
||||
ERROR_LOG(m_logger) << errStr;
|
||||
close();
|
||||
m_restartTimer->start();
|
||||
break;
|
||||
@@ -280,7 +279,7 @@ void Device::handleError(QAbstractSocket::SocketError error)
|
||||
|
||||
void Device::handleSerialError(QSerialPort::SerialPortError error)
|
||||
{
|
||||
DEBUG_LOG() << "Spontaneous error " << error << " doesn't have to be an error ...";
|
||||
DEBUG_LOG(m_logger) << "Spontaneous error " << error << " doesn't have to be an error ...";
|
||||
|
||||
const QString errStr(QStringLiteral("QSerialPort::SerialPortError ") + QString::number(error) +
|
||||
QStringLiteral(" error: ") + m_serialPort->errorString());
|
||||
@@ -293,13 +292,13 @@ void Device::handleSerialError(QSerialPort::SerialPortError error)
|
||||
case QSerialPort::SerialPortError::PermissionError:
|
||||
case QSerialPort::SerialPortError::WriteError:
|
||||
{
|
||||
WARNING_LOG() << "Closing port trying to reopen it.";
|
||||
WARNING_LOG(m_logger) << "Closing port trying to reopen it.";
|
||||
m_restartTimer->start();
|
||||
Q_FALLTHROUGH();
|
||||
}
|
||||
default:
|
||||
{
|
||||
WARNING_LOG() << errStr;
|
||||
WARNING_LOG(m_logger) << errStr;
|
||||
m_restartTimer->start();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -44,6 +44,8 @@ public slots:
|
||||
void handleSerialError(QSerialPort::SerialPortError error);
|
||||
|
||||
protected:
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void parseBuffer();
|
||||
static unsigned char calcChecksum(const QByteArray &checksumData);
|
||||
private:
|
||||
|
||||
+12
-13
@@ -12,12 +12,11 @@
|
||||
namespace TrainingAreaBaseOC {
|
||||
|
||||
WebsocketHandler::WebsocketHandler(QObject *parent, int exerciseId,
|
||||
const std::shared_ptr<Interface::Dts> dtsTabOc, const std::shared_ptr<Interface::Dtc> dtcTabOc)
|
||||
: QObject(parent)
|
||||
const std::shared_ptr<Interface::Dts> dtsTabOc, const std::shared_ptr<Interface::Dtc> dtcTabOc) : QObject(parent)
|
||||
, m_exerciseId(exerciseId)
|
||||
, m_dtsTaboc(dtsTabOc)
|
||||
, m_dtcTaboc(dtcTabOc)
|
||||
{
|
||||
, m_dtcTaboc(dtcTabOc),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
m_tryConnectionTimer = new QTimer(this);
|
||||
connect(m_tryConnectionTimer, &QTimer::timeout, this, &WebsocketHandler::onTryConnectionTimerTimeout);
|
||||
m_tryConnectionTimer->start(10 * 1000);
|
||||
@@ -131,12 +130,12 @@ void WebsocketHandler::onSendOwnPosition(const QString &message)
|
||||
QJsonDocument doc = QJsonDocument::fromJson(message.toUtf8());
|
||||
if (!doc.isObject())
|
||||
{
|
||||
WARNING_LOG() << "No Valid Object in " << message;
|
||||
WARNING_LOG(m_logger) << "No Valid Object in " << message;
|
||||
return;
|
||||
}
|
||||
if (doc.object().value(QStringLiteral("data")).toObject().isEmpty())
|
||||
{
|
||||
WARNING_LOG() << "No Data Array in" << message;
|
||||
WARNING_LOG(m_logger) << "No Data Array in" << message;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -149,7 +148,7 @@ void WebsocketHandler::onSendOwnPosition(const QString &message)
|
||||
|
||||
if (obj.contains(QStringLiteral("lon")) && obj.contains(QStringLiteral("lat")))
|
||||
{
|
||||
DEBUG_LOG() << "Got message with position";
|
||||
DEBUG_LOG(m_logger) << "Got message with position";
|
||||
outData.position(Core::GeoPosition(obj.value(QStringLiteral("lon")).toDouble(),obj.value(QStringLiteral("lat")).toDouble(),obj.value(QStringLiteral("height")).toDouble()));
|
||||
outData.timeStamp(QDateTime::currentMSecsSinceEpoch());
|
||||
if (obj.contains(QStringLiteral("buildingId")) && obj.contains(QStringLiteral("roomId")) )
|
||||
@@ -168,32 +167,32 @@ void WebsocketHandler::onSendOwnPosition(const QString &message)
|
||||
void WebsocketHandler::connectToServer()
|
||||
{
|
||||
|
||||
DEBUG_LOG() << "Try connect to servicemanagement " << QUrl(QStringLiteral("ws://")+Settings::remoteServerHostname()+QStringLiteral(":")+ QString::number(7300)).toString();
|
||||
DEBUG_LOG(m_logger) << "Try connect to servicemanagement " << QUrl(QStringLiteral("ws://")+Settings::remoteServerHostname()+QStringLiteral(":")+ QString::number(7300)).toString();
|
||||
m_socket->open(QUrl(QStringLiteral("ws://")+Settings::remoteServerHostname()+QStringLiteral(":")+ QString::number(7300)));
|
||||
}
|
||||
|
||||
void WebsocketHandler::sendServicePortRequest()
|
||||
{
|
||||
m_socket->sendTextMessage(QStringLiteral("{\"type\": \"servicePortsInformationRequest\",\"uuid\": \"7777\"}"));
|
||||
DEBUG_LOG() << "Wait For Services Reply";
|
||||
DEBUG_LOG(m_logger) << "Wait For Services Reply";
|
||||
}
|
||||
|
||||
void WebsocketHandler::parseServices(const QString &message)
|
||||
{
|
||||
m_tryConnectionTimer->stop();
|
||||
|
||||
DEBUG_LOG() << "Received SERVICES MESSAGE: " << message;
|
||||
DEBUG_LOG(m_logger) << "Received SERVICES MESSAGE: " << message;
|
||||
m_socket->close();
|
||||
int exPort = -1;
|
||||
QJsonDocument doc = QJsonDocument::fromJson(message.toUtf8());
|
||||
if (!doc.isObject())
|
||||
{
|
||||
WARNING_LOG() << "No Valid Object in " << message;
|
||||
WARNING_LOG(m_logger) << "No Valid Object in " << message;
|
||||
return;
|
||||
}
|
||||
if (!doc.object().value(QStringLiteral("data")).isArray())
|
||||
{
|
||||
WARNING_LOG() << "No Data Array in" << message;
|
||||
WARNING_LOG(m_logger) << "No Data Array in" << message;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -227,7 +226,7 @@ void WebsocketHandler::parseServices(const QString &message)
|
||||
|
||||
if (exPort > 0)
|
||||
{
|
||||
DEBUG_LOG() << "Connect To ppm ON: " << exPort;
|
||||
DEBUG_LOG(m_logger) << "Connect To ppm ON: " << exPort;
|
||||
connectToExPPM(exPort);
|
||||
m_state = WebSocketState::CONNECTTOPPM;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user