Adds immediate migration results in progress
This commit is contained in:
2102 files changed
+17482
-15071
No files matched your search
+3
-3
@@ -33,7 +33,7 @@ bool Api::init(const BuildingBsmConfig &bsmConfig)
|
||||
|
||||
bool Api::triggerFlashlight(int bsmId, const QString &hostname, int numberOfFlashes, int pauseBetweenFlashesSec)
|
||||
{
|
||||
DEBUG_LOG() << "triggerFlashlight bsmId=" << bsmId
|
||||
DEBUG_LOG(m_logger) << "triggerFlashlight bsmId=" << bsmId
|
||||
<< " hostname=" << hostname
|
||||
<< " numberOfFlashes=" << numberOfFlashes
|
||||
<< " pauseBetweenFlashesSec=" << pauseBetweenFlashesSec;
|
||||
@@ -46,7 +46,7 @@ bool Api::triggerFlashlightPulse(int bsmId, const QString &hostname,
|
||||
int choppedConfiguration,
|
||||
int flashDuration)
|
||||
{
|
||||
DEBUG_LOG() << "triggerFlashlightPulse bsmId=" << bsmId
|
||||
DEBUG_LOG(m_logger) << "triggerFlashlightPulse bsmId=" << bsmId
|
||||
<< " hostname=" << hostname
|
||||
<< " numberOfFlashes=" << numberOfFlashes
|
||||
<< " pauseDuration=" << pauseDuration
|
||||
@@ -60,7 +60,7 @@ bool Api::triggerFlashlights( int numberOfFlashes,
|
||||
int choppedConfiguration,
|
||||
int flashDuration)
|
||||
{
|
||||
DEBUG_LOG() << "triggerFlashlights numberOfFlashes=" << numberOfFlashes
|
||||
DEBUG_LOG(m_logger) << "triggerFlashlights numberOfFlashes=" << numberOfFlashes
|
||||
<< " pauseDuration=" << pauseDuration
|
||||
<< " choppedConfiguration" << choppedConfiguration
|
||||
<< " flashDuration=" << flashDuration;
|
||||
|
||||
@@ -50,6 +50,7 @@ Q_SIGNALS:
|
||||
DamageState damageState);
|
||||
void bsmStateChanged(const QVector<BsmState> &bsmStates);
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
SocketHandler *m_socketHandler;
|
||||
};
|
||||
}
|
||||
|
||||
+8
-8
@@ -45,10 +45,10 @@ bool Socket::sendData(const QByteArray &data)
|
||||
{
|
||||
if (!isConnected())
|
||||
{
|
||||
WARNING_LOG() << "BSM " << m_config.id << ": Trying to send data but not connected!";
|
||||
WARNING_LOG(m_logger) << "BSM " << m_config.id << ": Trying to send data but not connected!";
|
||||
return false;
|
||||
}
|
||||
DEBUG_LOG() << "BSM " << m_config.id << ": sending data: 0x" << data.toHex();
|
||||
DEBUG_LOG(m_logger) << "BSM " << m_config.id << ": sending data: 0x" << data.toHex();
|
||||
m_tcpSocket->write(data);
|
||||
m_tcpSocket->flush();
|
||||
return true;
|
||||
@@ -57,7 +57,7 @@ bool Socket::sendData(const QByteArray &data)
|
||||
void Socket::setVersionInformation(int verMajor, int verMinor, int verRev, const QString &manufacturer)
|
||||
{
|
||||
m_versionInfo = QStringLiteral("%1.%2-%3 (%4)").arg(verMajor).arg(verMinor).arg(verRev).arg(manufacturer);
|
||||
INFO_LOG() << "BSM " << m_config.id
|
||||
INFO_LOG(m_logger) << "BSM " << m_config.id
|
||||
<< ": version = " << m_versionInfo;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ void Socket::gotAlive()
|
||||
|
||||
void Socket::onConnected()
|
||||
{
|
||||
INFO_LOG() << "BSM " << m_config.id << " is connected to "
|
||||
INFO_LOG(m_logger) << "BSM " << m_config.id << " is connected to "
|
||||
<< m_tcpSocket->peerAddress().toString() << ":" << m_tcpSocket->peerPort();
|
||||
Telegrams::PanConfigurationSetup tele;
|
||||
tele.m_aliveMessage = s_aliveTimeout;
|
||||
@@ -83,7 +83,7 @@ void Socket::onConnected()
|
||||
|
||||
void Socket::onDisconnected()
|
||||
{
|
||||
INFO_LOG() << "BSM " << m_config.id << " is disconnected";
|
||||
INFO_LOG(m_logger) << "BSM " << m_config.id << " is disconnected";
|
||||
m_versionInfo.clear();
|
||||
startReconnectTimer();
|
||||
emit disconnected(m_config.id);
|
||||
@@ -91,7 +91,7 @@ void Socket::onDisconnected()
|
||||
|
||||
void Socket::onError(QAbstractSocket::SocketError error)
|
||||
{
|
||||
DEBUG_LOG() << "BSM " << m_config.id
|
||||
DEBUG_LOG(m_logger) << "BSM " << m_config.id
|
||||
<< " can not connect to " << m_config.hostname << ":" << m_config.port
|
||||
<< ": " << m_tcpSocket->errorString()
|
||||
<< " (" << error << ");";
|
||||
@@ -100,7 +100,7 @@ void Socket::onError(QAbstractSocket::SocketError error)
|
||||
|
||||
void Socket::onConnect()
|
||||
{
|
||||
DEBUG_LOG() << "BSM " << m_config.id
|
||||
DEBUG_LOG(m_logger) << "BSM " << m_config.id
|
||||
<< " trying to connect to " << m_config.hostname << ":" << m_config.port;
|
||||
m_tcpSocket->connectToHost(m_config.hostname, m_config.port);
|
||||
}
|
||||
@@ -112,7 +112,7 @@ void Socket::onReadyRead()
|
||||
|
||||
void Socket::onAliveTimeout()
|
||||
{
|
||||
WARNING_LOG() << "BSM " << m_config.id
|
||||
WARNING_LOG(m_logger) << "BSM " << m_config.id
|
||||
<< " alive timeout! Reconnecting";
|
||||
|
||||
}
|
||||
|
||||
+1
@@ -39,6 +39,7 @@ private Q_SLOTS:
|
||||
void onReadyRead();
|
||||
void onAliveTimeout();
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void startReconnectTimer();
|
||||
private:
|
||||
BuildingControlUnit::Bsm m_config;
|
||||
|
||||
+15
-15
@@ -66,7 +66,7 @@ bool SocketHandler::triggerFlashlight(int bsmId, const QString &hostname, int nu
|
||||
Socket *s = hostname.isEmpty() ? getSocketForBsm(bsmId) : getSocketForBsm(hostname);
|
||||
if (!s)
|
||||
return false;
|
||||
DEBUG_LOG() << "triggerFlashlight BSM Socket with socketId " << bsmId;
|
||||
DEBUG_LOG(m_logger) << "triggerFlashlight BSM Socket with socketId " << bsmId;
|
||||
Telegrams::PanChoppedSignalFlashlight flash;
|
||||
flash.m_noOfFlashes = qBound(0, numberOfFlashes, 255);
|
||||
flash.m_pauseDuration = qBound(1, pauseBetweenFlashesSec, 10);
|
||||
@@ -83,7 +83,7 @@ bool SocketHandler::triggerFlashlightPulse(int bsmId, const QString &hostname,
|
||||
Socket *s = hostname.isEmpty() ? getSocketForBsm(bsmId) : getSocketForBsm(hostname);
|
||||
if (!s)
|
||||
return false;
|
||||
DEBUG_LOG() << "triggerFlashlightPulse BSM Socket with socketId " << bsmId
|
||||
DEBUG_LOG(m_logger) << "triggerFlashlightPulse BSM Socket with socketId " << bsmId
|
||||
<< " hostname=" << hostname
|
||||
<< " numberOfFlashes=" << numberOfFlashes
|
||||
<< " pauseDuration=" << pauseDuration
|
||||
@@ -118,12 +118,12 @@ bool SocketHandler::triggerFlashlights(int numberOfFlashes,
|
||||
++cntSocketsActive;
|
||||
}
|
||||
else
|
||||
WARNING_LOG() << "BSM " << s->bsmConfig().id
|
||||
WARNING_LOG(m_logger) << "BSM " << s->bsmConfig().id
|
||||
<< " is not connected - can not activate flash light";
|
||||
}
|
||||
if (cntSocketsActive == 0)
|
||||
{
|
||||
WARNING_LOG() << "No active bsm - can not trigger flash light for all bsm";
|
||||
WARNING_LOG(m_logger) << "No active bsm - can not trigger flash light for all bsm";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -184,13 +184,13 @@ void SocketHandler::onDataAvailable(int id, const QByteArray &data)
|
||||
void SocketHandler::onSocketConnected(int id)
|
||||
{
|
||||
requestVersion(id);
|
||||
DEBUG_LOG() << "BSM Socket with id " << id << " connected";
|
||||
DEBUG_LOG(m_logger) << "BSM Socket with id " << id << " connected";
|
||||
m_bsmStateTimer.start();
|
||||
}
|
||||
|
||||
void SocketHandler::onSocketDisconnected(int id)
|
||||
{
|
||||
DEBUG_LOG() << "BSM Socket with id " << id << " disconnected";
|
||||
DEBUG_LOG(m_logger) << "BSM Socket with id " << id << " disconnected";
|
||||
m_socketData[id].clear();
|
||||
m_bsmStateTimer.start();
|
||||
}
|
||||
@@ -216,12 +216,12 @@ Socket *SocketHandler::getSocketForBsm(int bsmId)
|
||||
Socket *s = m_sockets.value(bsmId);
|
||||
if (!s)
|
||||
{
|
||||
WARNING_LOG() << "Got invalid bsm id (" << bsmId << ") to trigger flashlight";
|
||||
WARNING_LOG(m_logger) << "Got invalid bsm id (" << bsmId << ") to trigger flashlight";
|
||||
return nullptr;
|
||||
}
|
||||
if (!s->isConnected())
|
||||
{
|
||||
WARNING_LOG() << "Bsm with id " << bsmId
|
||||
WARNING_LOG(m_logger) << "Bsm with id " << bsmId
|
||||
<< " is not connected - can not activate flash light";
|
||||
return nullptr;
|
||||
}
|
||||
@@ -269,7 +269,7 @@ void SocketHandler::parseBsmTelegram(int id, const QByteArray &baTele)
|
||||
if (!tele)
|
||||
return;
|
||||
if (tele->telId() != Telegrams::PanTelegramId::ALIVE)
|
||||
DEBUG_LOG() << "Got tele from bsm with id " << id << ": " << tele->print();
|
||||
DEBUG_LOG(m_logger) << "Got tele from bsm with id " << id << ": " << tele->print();
|
||||
switch (tele->telId())
|
||||
{
|
||||
case Telegrams::PanTelegramId::ALIVE:
|
||||
@@ -317,7 +317,7 @@ void SocketHandler::parseBsmTelegram(int id, const QByteArray &baTele)
|
||||
|
||||
bool SocketHandler::requestVersion(int id)
|
||||
{
|
||||
DEBUG_LOG() << "Requesting version for BSM " << id;
|
||||
DEBUG_LOG(m_logger) << "Requesting version for BSM " << id;
|
||||
Socket *s = m_sockets.value(id);
|
||||
if (!s || !s->isConnected())
|
||||
return false;
|
||||
@@ -333,7 +333,7 @@ void SocketHandler::handleDirectFire(int id, const Telegrams::PanDirectFire *tel
|
||||
|
||||
if (tele->m_ammunitionId == 0)
|
||||
{
|
||||
WARNING_LOG() << "Got direct fire without valid ammunition - ignoring: " << tele->print();
|
||||
WARNING_LOG(m_logger) << "Got direct fire without valid ammunition - ignoring: " << tele->print();
|
||||
return;
|
||||
}
|
||||
OpticalShot osNew;
|
||||
@@ -351,21 +351,21 @@ void SocketHandler::handleDirectFire(int id, const Telegrams::PanDirectFire *tel
|
||||
|
||||
void SocketHandler::handleDirectFireSummray()
|
||||
{
|
||||
DEBUG_LOG() << "handleDirectFireSummray m_lastShots.size=" << m_lastShots.size();
|
||||
DEBUG_LOG(m_logger) << "handleDirectFireSummray m_lastShots.size=" << m_lastShots.size();
|
||||
OpticalShot osNew;
|
||||
if ( m_lastShots.size() == 0)
|
||||
return;
|
||||
int distance = 3000;
|
||||
DEBUG_LOG() << "distance=" << distance;
|
||||
DEBUG_LOG(m_logger) << "distance=" << distance;
|
||||
for (const OpticalShot &os : std::as_const(m_lastShots))
|
||||
{
|
||||
int act_distance = os.deposition1 * os.deposition1 + os.deposition2 * os.deposition2;
|
||||
DEBUG_LOG() << "act_distance=" << act_distance << " BSM-ID=" << os.id
|
||||
DEBUG_LOG(m_logger) << "act_distance=" << act_distance << " BSM-ID=" << os.id
|
||||
<< " ammunitionId=" << os.ammunitionId;
|
||||
if ( act_distance < distance)
|
||||
{
|
||||
distance = act_distance;
|
||||
DEBUG_LOG() << "distance=" << distance << " BSM-ID=" << os.id;
|
||||
DEBUG_LOG(m_logger) << "distance=" << distance << " BSM-ID=" << os.id;
|
||||
osNew = os;
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -69,6 +69,8 @@ private Q_SLOTS:
|
||||
void handleDirectFireSummray();
|
||||
|
||||
private:
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
Socket *getSocketForBsm(int bsmId);
|
||||
Socket *getSocketForBsm(const QString &hostname);
|
||||
QByteArray parseBuffer(int id, const QByteArray &buffer);
|
||||
|
||||
+8
-8
@@ -61,22 +61,22 @@ void HandelEffect::handleEffect()
|
||||
switch (m_currentAction->aclass)
|
||||
{
|
||||
case AC_Unset:
|
||||
DEBUG_LOG() << "---- This is unset ----";
|
||||
DEBUG_LOG(m_logger) << "---- This is unset ----";
|
||||
break;
|
||||
case AC_Standard:
|
||||
{
|
||||
DEBUG_LOG() << "---- This is a standard Action ----";
|
||||
DEBUG_LOG(m_logger) << "---- This is a standard Action ----";
|
||||
if (!m_currentAction->url.isEmpty())
|
||||
{
|
||||
|
||||
DEBUG_LOG() << "---- emit newHttpRequest(a->url):" << m_currentAction->url.toString();
|
||||
DEBUG_LOG(m_logger) << "---- emit newHttpRequest(a->url):" << m_currentAction->url.toString();
|
||||
emit newHttpRequest(m_currentAction->url);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case AC_Repeat:
|
||||
{
|
||||
DEBUG_LOG() << "---- This is a Repeat Action";
|
||||
DEBUG_LOG(m_logger) << "---- This is a Repeat Action";
|
||||
const RepeatAction *ra = static_cast<const RepeatAction *>(m_currentAction);
|
||||
|
||||
HandelEffect *he = new HandelEffect(this);
|
||||
@@ -92,7 +92,7 @@ void HandelEffect::handleEffect()
|
||||
case AC_Pause:
|
||||
{
|
||||
const PauseAction *pa = static_cast<const PauseAction *>(m_currentAction);
|
||||
DEBUG_LOG() << "---- This is a Pause Action Pause=" << pa->pause
|
||||
DEBUG_LOG(m_logger) << "---- This is a Pause Action Pause=" << pa->pause
|
||||
<< " comment=" << pa->comment;
|
||||
|
||||
QTimer::singleShot(pa->pause, this, &HandelEffect::handleEffect);
|
||||
@@ -102,11 +102,11 @@ void HandelEffect::handleEffect()
|
||||
}
|
||||
case AC_Bsm:
|
||||
{
|
||||
DEBUG_LOG() << "---- This is a Bsm Action ";
|
||||
DEBUG_LOG(m_logger) << "---- This is a Bsm Action ";
|
||||
const BsmAction *ba = static_cast<const BsmAction*>(m_currentAction);
|
||||
if (!ba->isNull())
|
||||
{
|
||||
DEBUG_LOG() << "emit triggerAllFlashlights ------ atype=" << m_currentAction->atype
|
||||
DEBUG_LOG(m_logger) << "emit triggerAllFlashlights ------ atype=" << m_currentAction->atype
|
||||
<< " pause=" << ba->pause
|
||||
<< " choplength=" << ba->choplength
|
||||
<< " pulses=" << ba->pulses
|
||||
@@ -120,7 +120,7 @@ void HandelEffect::handleEffect()
|
||||
default:
|
||||
break;
|
||||
}
|
||||
DEBUG_LOG() << "--- End Action ";
|
||||
DEBUG_LOG(m_logger) << "--- End Action ";
|
||||
|
||||
|
||||
QTimer::singleShot(0, this, &HandelEffect::handleEffect);
|
||||
|
||||
+33
-33
@@ -22,7 +22,7 @@ HandelEffects::HandelEffects(QObject *parent, const QString &loggerchannel)
|
||||
, m_getRelayStateTimer(new QTimer(this))
|
||||
, m_logger(getLogger(QStringLiteral("HandelEffects.") + loggerchannel))
|
||||
{
|
||||
DEBUG_LOG() << "HandelEffects::init loggerchannel=" << loggerchannel;
|
||||
DEBUG_LOG(m_logger) << "HandelEffects::init loggerchannel=" << loggerchannel;
|
||||
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ void HandelEffects::init(const QString &controlEffectsCfg, const QString &hostna
|
||||
{
|
||||
m_xmlReader.init(controlEffectsCfg);
|
||||
|
||||
DEBUG_LOG() << "HandelEffects::init";
|
||||
DEBUG_LOG(m_logger) << "HandelEffects::init";
|
||||
m_hostname = hostname;
|
||||
m_lastDamage = -1;
|
||||
m_effectType = et;
|
||||
@@ -53,7 +53,7 @@ void HandelEffects::startEffects(int damagePercent)
|
||||
{
|
||||
if (m_lastDamage == damagePercent)
|
||||
{
|
||||
DEBUG_LOG() << "damagePercent=" << damagePercent
|
||||
DEBUG_LOG(m_logger) << "damagePercent=" << damagePercent
|
||||
<< " m_lastDamage=" << m_lastDamage
|
||||
<< " return";
|
||||
return;
|
||||
@@ -73,7 +73,7 @@ void HandelEffects::startEffects(int damagePercent)
|
||||
if (e->effectType == ET_Relay && m_effectType == ET_BsmFlash)
|
||||
continue;
|
||||
|
||||
DEBUG_LOG() << "- HandelEffects::Starting Effect " << e << " of Type " << e->effectType << ". ----"
|
||||
DEBUG_LOG(m_logger) << "- HandelEffects::Starting Effect " << e << " of Type " << e->effectType << ". ----"
|
||||
<< " name=" << e->name;
|
||||
for (const Range *range : e->constRanges())
|
||||
{
|
||||
@@ -87,7 +87,7 @@ void HandelEffects::startEffects(int damagePercent)
|
||||
|
||||
createEffectHandler(e, range);
|
||||
}
|
||||
DEBUG_LOG() << "- End Effect ";
|
||||
DEBUG_LOG(m_logger) << "- End Effect ";
|
||||
}
|
||||
m_lastDamage = damagePercent;
|
||||
}
|
||||
@@ -103,7 +103,7 @@ void HandelEffects::createEffectHandler(Effect *e, const Range *range)
|
||||
{
|
||||
if (m_effectType == ET_BsmFlash)
|
||||
{
|
||||
INFO_LOG() << "setOverrides connect Flashes" ;
|
||||
INFO_LOG(m_logger) << "setOverrides connect Flashes" ;
|
||||
connect(handelEffect, &HandelEffect::triggerAllFlashlights, this, &HandelEffects::triggerAllFlashlights, Qt::UniqueConnection);
|
||||
}
|
||||
else
|
||||
@@ -112,15 +112,15 @@ void HandelEffects::createEffectHandler(Effect *e, const Range *range)
|
||||
|
||||
connect(handelEffect, &HandelEffect::effectReady, this, &HandelEffects::onEffectReady);
|
||||
|
||||
DEBUG_LOG() << "-- HandelEffects::Starting Range " << range->min << " - " << range->max
|
||||
DEBUG_LOG(m_logger) << "-- HandelEffects::Starting Range " << range->min << " - " << range->max
|
||||
<< ". ----";
|
||||
|
||||
DEBUG_LOG() << "-- Range has " << range->actions.count() << " actions";
|
||||
DEBUG_LOG(m_logger) << "-- Range has " << range->actions.count() << " actions";
|
||||
|
||||
handelEffect->init(range->actions, 1);
|
||||
|
||||
QTimer::singleShot(0, handelEffect, &HandelEffect::handleEffect);
|
||||
DEBUG_LOG() << "-- End Range ";
|
||||
DEBUG_LOG(m_logger) << "-- End Range ";
|
||||
}
|
||||
|
||||
void HandelEffects::playHitSound(const int hitSoundId)
|
||||
@@ -162,18 +162,18 @@ void HandelEffects::switchRelay(const SwitchRelayValues &switchRelayValues)
|
||||
void HandelEffects::setOverrides(const QVector<BcuEffectState> &effectStates)
|
||||
{
|
||||
m_effectStates = effectStates;
|
||||
DEBUG_LOG() << "In set overrides for " << m_hostname << ", effectStates.size: " << effectStates.size();
|
||||
DEBUG_LOG(m_logger) << "In set overrides for " << m_hostname << ", effectStates.size: " << effectStates.size();
|
||||
for(const auto &es : std::as_const(m_effectStates))
|
||||
{
|
||||
DEBUG_LOG() << "m_effectStates: es.id=" << es.id
|
||||
DEBUG_LOG(m_logger) << "m_effectStates: es.id=" << es.id
|
||||
<< ", es.type=" << es.type
|
||||
<< ", es.override=" << es.effectOverride;
|
||||
}
|
||||
m_sounds = EffectOverride::EO_Auto;
|
||||
DEBUG_LOG() << "Nun die Schleife:";
|
||||
DEBUG_LOG(m_logger) << "Nun die Schleife:";
|
||||
for(const auto &es : std::as_const(effectStates))
|
||||
{
|
||||
DEBUG_LOG() << "es.id=" << es.id
|
||||
DEBUG_LOG(m_logger) << "es.id=" << es.id
|
||||
<< ", es.type=" << es.type
|
||||
<< ", es.override=" << es.effectOverride;
|
||||
switch (es.type) {
|
||||
@@ -194,14 +194,14 @@ void HandelEffects::setOverrides(const QVector<BcuEffectState> &effectStates)
|
||||
if (e->effectHandler)
|
||||
{
|
||||
disconnect(e->effectHandler, &HandelEffect::newHttpRequest, this, &HandelEffects::sendHttpRequest);
|
||||
INFO_LOG() << "setOverrides emit triggerAllFlashlights(0,0,0,0)" ;
|
||||
INFO_LOG(m_logger) << "setOverrides emit triggerAllFlashlights(0,0,0,0)" ;
|
||||
emit triggerAllFlashlights(0,0,0,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (es.effectOverride == BEO_Off )
|
||||
{
|
||||
DEBUG_LOG() << "BEO_Off";
|
||||
DEBUG_LOG(m_logger) << "BEO_Off";
|
||||
|
||||
QUrl url = XmlReader::createPreparedUrl(contents(), m_hostname);
|
||||
QUrlQuery query;
|
||||
@@ -260,7 +260,7 @@ void HandelEffects::setOverrides(const QVector<BcuEffectState> &effectStates)
|
||||
{
|
||||
if (e->effectHandler)
|
||||
{
|
||||
INFO_LOG() << "setOverrides disconnect Flashes" ;
|
||||
INFO_LOG(m_logger) << "setOverrides disconnect Flashes" ;
|
||||
disconnect (e->effectHandler, &HandelEffect::triggerAllFlashlights, this, &HandelEffects::triggerAllFlashlights);
|
||||
}
|
||||
}
|
||||
@@ -309,7 +309,7 @@ QVector<BcuEffectState> HandelEffects::getOverrides()
|
||||
break;
|
||||
|
||||
}
|
||||
DEBUG_LOG() << "getOverrides "
|
||||
DEBUG_LOG(m_logger) << "getOverrides "
|
||||
<< " id=" << override.id
|
||||
<< " type=" << override.type
|
||||
<< " override" << override.effectOverride;
|
||||
@@ -335,7 +335,7 @@ void HandelEffects::sendHttpRequest(const QUrl &url)
|
||||
{
|
||||
QUrl copy = url;
|
||||
copy.setHost(m_hostname);
|
||||
DEBUG_LOG() << "sendHttpRequest" << copy.toString();
|
||||
DEBUG_LOG(m_logger) << "sendHttpRequest" << copy.toString();
|
||||
emit newHttpRequest(copy, HandleHttpQueueMessageStatus::MS_Single);
|
||||
}
|
||||
|
||||
@@ -349,7 +349,7 @@ void HandelEffects::onRelayStateTimerTimeout()
|
||||
emit sendRelayState(m_relayState);
|
||||
m_overridesSend = false;
|
||||
}
|
||||
DEBUG_LOG() << "send get relay-State contents()=" << contents().toString()
|
||||
DEBUG_LOG(m_logger) << "send get relay-State contents()=" << contents().toString()
|
||||
<< " m_offlineCounter=" << m_offlineCounter;
|
||||
QUrl url = XmlReader::createPreparedUrl(contents(), m_hostname);
|
||||
url.setPath(QStringLiteral("/relay.php"));
|
||||
@@ -364,12 +364,12 @@ void HandelEffects::onRelayStateTimerTimeout()
|
||||
void HandelEffects::handleEgcuReplyObject(const QString &host, const QByteArray &data)
|
||||
{
|
||||
bool relayStateChanged = false;
|
||||
TRACE_LOG() << "handleEgcuReply Object:" << data
|
||||
TRACE_LOG(m_logger) << "handleEgcuReply Object:" << data
|
||||
<< " m_offlineState=" << m_offlineState;
|
||||
|
||||
if (m_offlineState)
|
||||
{
|
||||
DEBUG_LOG() << "State wiederherstellen !!!!!!!!!!! m_offlineState=" << m_offlineState;
|
||||
DEBUG_LOG(m_logger) << "State wiederherstellen !!!!!!!!!!! m_offlineState=" << m_offlineState;
|
||||
m_offlineState = false;
|
||||
setOverrides(m_effectStates);
|
||||
}
|
||||
@@ -384,7 +384,7 @@ void HandelEffects::handleEgcuReplyObject(const QString &host, const QByteArray
|
||||
rsi.id = it.key().toInt();
|
||||
rsi.state = it.value().isString() ? (it.value().toString().compare(QLatin1String("on"), Qt::CaseInsensitive) == 0) : it.value().toBool(false);
|
||||
m_relayState.relayStates.append(rsi);
|
||||
TRACE_LOG() << "id=" << rsi.id
|
||||
TRACE_LOG(m_logger) << "id=" << rsi.id
|
||||
<< " state=" << rsi.state;
|
||||
}
|
||||
if ( m_relayState.relayStates.size() == lastRelayState.relayStates.size())
|
||||
@@ -393,19 +393,19 @@ void HandelEffects::handleEgcuReplyObject(const QString &host, const QByteArray
|
||||
{
|
||||
if (m_relayState.relayStates[i].state != lastRelayState.relayStates[i].state)
|
||||
{
|
||||
TRACE_LOG() << "Values relayStateChanged = true";
|
||||
TRACE_LOG(m_logger) << "Values relayStateChanged = true";
|
||||
relayStateChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TRACE_LOG() << "Size relayStateChanged = true";
|
||||
TRACE_LOG(m_logger) << "Size relayStateChanged = true";
|
||||
relayStateChanged = true;
|
||||
}
|
||||
if ( m_offlineCounter > 1)
|
||||
{
|
||||
TRACE_LOG() << "m_offlineCounter=" << m_offlineCounter;
|
||||
TRACE_LOG(m_logger) << "m_offlineCounter=" << m_offlineCounter;
|
||||
relayStateChanged = true;
|
||||
}
|
||||
|
||||
@@ -413,7 +413,7 @@ void HandelEffects::handleEgcuReplyObject(const QString &host, const QByteArray
|
||||
m_relayState.stateTime = QDateTime::currentMSecsSinceEpoch();
|
||||
m_relayState.offlineTime = 0;
|
||||
m_offlineCounter=0;
|
||||
DEBUG_LOG() << "host=" << host.toLower()
|
||||
DEBUG_LOG(m_logger) << "host=" << host.toLower()
|
||||
<< " relayStateChanged=" << relayStateChanged
|
||||
<< " m_overridesSend=" << m_overridesSend
|
||||
<< " m_offlineState=" << m_offlineState;
|
||||
@@ -427,7 +427,7 @@ void HandelEffects::handleEgcuReplyObject(const QString &host, const QByteArray
|
||||
|
||||
if ( m_relayState.hostname.toLower() == host.toLower() && relayStateChanged)
|
||||
{
|
||||
DEBUG_LOG() << "emit sendRelayState(m_relayState) relayStateChanged";
|
||||
DEBUG_LOG(m_logger) << "emit sendRelayState(m_relayState) relayStateChanged";
|
||||
emit sendRelayState(m_relayState);
|
||||
}
|
||||
}
|
||||
@@ -435,7 +435,7 @@ void HandelEffects::handleEgcuReplyObject(const QString &host, const QByteArray
|
||||
void HandelEffects::handleEgcuReplyArray(const QString &host, const QByteArray &data)
|
||||
{
|
||||
Q_UNUSED (host);
|
||||
TRACE_LOG() << "handleEgcuReply Array:" << data;
|
||||
TRACE_LOG(m_logger) << "handleEgcuReply Array:" << data;
|
||||
m_relayState.relayStates.clear();
|
||||
|
||||
const QJsonObject jsonObject = QJsonDocument::fromJson(data).object();
|
||||
@@ -449,7 +449,7 @@ void HandelEffects::handleEgcuReplyArray(const QString &host, const QByteArray &
|
||||
rsi.id = i;
|
||||
rsi.state = stateArray[i].isString() ? (stateArray[i].toString().compare(QLatin1String("on"), Qt::CaseInsensitive)== 0 ): stateArray[i].toBool(false);
|
||||
m_relayState.relayStates.append(rsi);
|
||||
TRACE_LOG() << "id=" << rsi.id
|
||||
TRACE_LOG(m_logger) << "id=" << rsi.id
|
||||
<< " state=" << rsi.state;
|
||||
}
|
||||
|
||||
@@ -466,7 +466,7 @@ void HandelEffects::handleEgcuReplyArray(const QString &host, const QByteArray &
|
||||
void HandelEffects::handleEgcuReply(const QString &host, const QByteArray &data)
|
||||
{
|
||||
|
||||
DEBUG_LOG() << "HandelEffects::handleEgcuReply host=" << host
|
||||
DEBUG_LOG(m_logger) << "HandelEffects::handleEgcuReply host=" << host
|
||||
<< " m_hostname=" << m_hostname
|
||||
<< " m_overridesSend=" << m_overridesSend;
|
||||
|
||||
@@ -477,18 +477,18 @@ void HandelEffects::handleEgcuReply(const QString &host, const QByteArray &data)
|
||||
if (!jsonObject.contains(QStringLiteral("State")) )
|
||||
{
|
||||
m_overridesSend = true;
|
||||
TRACE_LOG() << "No State return";
|
||||
TRACE_LOG(m_logger) << "No State return";
|
||||
return;
|
||||
}
|
||||
const QJsonValue jsonValue = jsonObject[QStringLiteral("State")];
|
||||
if (jsonValue.isArray())
|
||||
{
|
||||
TRACE_LOG() << "data isArray\n";
|
||||
TRACE_LOG(m_logger) << "data isArray\n";
|
||||
handleEgcuReplyArray(host, data);
|
||||
}
|
||||
else
|
||||
{
|
||||
TRACE_LOG() << "data isObject\n";
|
||||
TRACE_LOG(m_logger) << "data isObject\n";
|
||||
handleEgcuReplyObject(host, data);
|
||||
}
|
||||
|
||||
|
||||
+25
-25
@@ -21,11 +21,11 @@ bool XmlReader::init(const QString &effectConfigFile)
|
||||
m_contents.effects.clear();
|
||||
|
||||
QFile file(effectConfigFile);
|
||||
DEBUG_LOG() << "open effectConfigFile: " << effectConfigFile;
|
||||
DEBUG_LOG(m_logger) << "open effectConfigFile: " << effectConfigFile;
|
||||
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
{
|
||||
WARNING_LOG() << "Couldn't open EffectConfigFile: " << effectConfigFile;
|
||||
WARNING_LOG(m_logger) << "Couldn't open EffectConfigFile: " << effectConfigFile;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -63,18 +63,18 @@ bool XmlReader::init(const QString &effectConfigFile)
|
||||
|
||||
if (xml.hasError())
|
||||
{
|
||||
ERROR_LOG() << "Effect Config File had XML Errors:\n" << xml.errorString();
|
||||
ERROR_LOG(m_logger) << "Effect Config File had XML Errors:\n" << xml.errorString();
|
||||
return false;
|
||||
}
|
||||
|
||||
DEBUG_LOG() << "Effect Config File Contents: " << m_contents.toString();
|
||||
DEBUG_LOG(m_logger) << "Effect Config File Contents: " << m_contents.toString();
|
||||
createHttpRequests();
|
||||
return true;
|
||||
}
|
||||
|
||||
Effect *XmlReader::parseEffect(QXmlStreamReader &xml)
|
||||
{
|
||||
DEBUG_LOG() << "- parseEffect Start";
|
||||
DEBUG_LOG(m_logger) << "- parseEffect Start";
|
||||
|
||||
if (xml.tokenType() != QXmlStreamReader::StartElement ||
|
||||
xml.name() != QStringLiteral("effect"))
|
||||
@@ -125,12 +125,12 @@ Effect *XmlReader::parseEffect(QXmlStreamReader &xml)
|
||||
}
|
||||
xml.readNext();
|
||||
}
|
||||
DEBUG_LOG() << "- parseEffect: Name: " << e->id
|
||||
DEBUG_LOG(m_logger) << "- parseEffect: Name: " << e->id
|
||||
<< ", Type: " << e->effectType
|
||||
<< ", Category: " << e->category
|
||||
<< ", Name: " << e->name
|
||||
<< ", override: " << e->override;
|
||||
DEBUG_LOG() << "- parseEffect End. It has " << e->ranges.size() << " ranges";
|
||||
DEBUG_LOG(m_logger) << "- parseEffect End. It has " << e->ranges.size() << " ranges";
|
||||
return e;
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ Range *XmlReader::parseRange(QXmlStreamReader &xml)
|
||||
xml.name() != QStringLiteral("range"))
|
||||
return {};
|
||||
|
||||
DEBUG_LOG() << "-- parseRange Start";
|
||||
DEBUG_LOG(m_logger) << "-- parseRange Start";
|
||||
Range *r = new Range();
|
||||
|
||||
QXmlStreamAttributes attributes = xml.attributes();
|
||||
@@ -164,10 +164,10 @@ Range *XmlReader::parseRange(QXmlStreamReader &xml)
|
||||
|
||||
xml.readNext();
|
||||
}
|
||||
DEBUG_LOG() << "-- parseRange: [" << r->min << "-" << r->max << "]"
|
||||
DEBUG_LOG(m_logger) << "-- parseRange: [" << r->min << "-" << r->max << "]"
|
||||
<< ", restartOnChange: " <<r->restartOnChange
|
||||
<< ", ActionCount: " << r->actions.count();
|
||||
DEBUG_LOG() << "-- parseRange End";
|
||||
DEBUG_LOG(m_logger) << "-- parseRange End";
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ Action *XmlReader::parseAction(QXmlStreamReader &xml)
|
||||
if (xml.name() == QStringLiteral("bsm"))
|
||||
return parseBsmAction(xml);
|
||||
|
||||
WARNING_LOG() << "--- parseUnknownAction with name '" << xml.name().string() << "'cannot be handled.";
|
||||
WARNING_LOG(m_logger) << "--- parseUnknownAction with name '" << xml.name().string() << "'cannot be handled.";
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -198,18 +198,18 @@ PauseAction *XmlReader::parsePauseAction(QXmlStreamReader &xml)
|
||||
xml.name() != QLatin1String("pause"))
|
||||
return {};
|
||||
|
||||
DEBUG_LOG() << "--- parsePauseAction Start";
|
||||
DEBUG_LOG(m_logger) << "--- parsePauseAction Start";
|
||||
QXmlStreamAttributes attributes = xml.attributes();
|
||||
PauseAction *p = new PauseAction();
|
||||
p->atype = static_cast<ActionType>(attributes.value(QStringLiteral("type")).toInt());
|
||||
if (attributes.hasAttribute(QStringLiteral("comment")))
|
||||
p->comment = attributes.value(QStringLiteral("comment")).toString();
|
||||
p->pause = xml.readElementText().toInt();
|
||||
DEBUG_LOG() << "--- parsePauseAction: "
|
||||
DEBUG_LOG(m_logger) << "--- parsePauseAction: "
|
||||
<< " Pause: " << p->pause
|
||||
<< ", Comment: " << p->comment;
|
||||
|
||||
DEBUG_LOG() << "--- parsePauseAction End";
|
||||
DEBUG_LOG(m_logger) << "--- parsePauseAction End";
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ RepeatAction *XmlReader::parseRepeatAction(QXmlStreamReader &xml)
|
||||
if (xml.tokenType() != QXmlStreamReader::StartElement ||
|
||||
xml.name() != QStringLiteral("repeat"))
|
||||
return {};
|
||||
DEBUG_LOG() << "--- parseRepeatAction Start";
|
||||
DEBUG_LOG(m_logger) << "--- parseRepeatAction Start";
|
||||
RepeatAction *ra = new RepeatAction();
|
||||
QXmlStreamAttributes attributes = xml.attributes();
|
||||
|
||||
@@ -244,8 +244,8 @@ RepeatAction *XmlReader::parseRepeatAction(QXmlStreamReader &xml)
|
||||
QString repetitions = QString::number(ra->count);
|
||||
if (ra->count < 0)
|
||||
repetitions = QLatin1String("Infinite");
|
||||
DEBUG_LOG() << "--- parseRepeatAction: Repetitions: " << repetitions << ", Comment: " << ra->comment;
|
||||
DEBUG_LOG() << "--- parseRepeatAction End";
|
||||
DEBUG_LOG(m_logger) << "--- parseRepeatAction: Repetitions: " << repetitions << ", Comment: " << ra->comment;
|
||||
DEBUG_LOG(m_logger) << "--- parseRepeatAction End";
|
||||
return ra;
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ Action *XmlReader::parseStandardAction(QXmlStreamReader &xml)
|
||||
xml.name() != QStringLiteral("action"))
|
||||
return {};
|
||||
|
||||
DEBUG_LOG() << "--- parseStandardAction Start";
|
||||
DEBUG_LOG(m_logger) << "--- parseStandardAction Start";
|
||||
|
||||
QXmlStreamAttributes attributes = xml.attributes();
|
||||
|
||||
@@ -269,9 +269,9 @@ Action *XmlReader::parseStandardAction(QXmlStreamReader &xml)
|
||||
a->atype = static_cast<ActionType>(attributes.value(QStringLiteral("type")).toInt());
|
||||
if (attributes.hasAttribute(QStringLiteral("comment")))
|
||||
a->comment = attributes.value(QStringLiteral("comment")).toString();
|
||||
DEBUG_LOG() << "--- parseStandardAction: Type: " << a->atype
|
||||
DEBUG_LOG(m_logger) << "--- parseStandardAction: Type: " << a->atype
|
||||
<< ", Comment: " << a->comment;
|
||||
DEBUG_LOG() << "--- parseStandardAction End";
|
||||
DEBUG_LOG(m_logger) << "--- parseStandardAction End";
|
||||
return a;
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ BsmAction *XmlReader::parseBsmAction(QXmlStreamReader &xml)
|
||||
QXmlStreamAttributes attributes = xml.attributes();
|
||||
|
||||
|
||||
DEBUG_LOG() << "--- parseBsmAction Start";
|
||||
DEBUG_LOG(m_logger) << "--- parseBsmAction Start";
|
||||
BsmAction *a = new BsmAction();
|
||||
a->atype = static_cast<ActionType>(attributes.value(QStringLiteral("type")).toInt());
|
||||
if (attributes.hasAttribute(QStringLiteral("comment")))
|
||||
@@ -302,14 +302,14 @@ BsmAction *XmlReader::parseBsmAction(QXmlStreamReader &xml)
|
||||
xml.readNext();
|
||||
}
|
||||
|
||||
DEBUG_LOG() << "--- parseBsmAction: Type: " << a->atype
|
||||
DEBUG_LOG(m_logger) << "--- parseBsmAction: Type: " << a->atype
|
||||
<< ", Pause: " << a->pause
|
||||
<< ", Choplength: " << a->choplength
|
||||
<< ", Count: " << a->count
|
||||
<< ", Pulses: " << a->pulses
|
||||
<< ", Pulseduration: " << a->pulseduration
|
||||
<< ", Comment: " << a->comment;
|
||||
DEBUG_LOG() << "--- parseBsmAction End";
|
||||
DEBUG_LOG(m_logger) << "--- parseBsmAction End";
|
||||
return a;
|
||||
}
|
||||
|
||||
@@ -384,7 +384,7 @@ void XmlReader::generateUrl(const Effect *e, Action *a)
|
||||
}
|
||||
url.setQuery(query);
|
||||
a->url = url;
|
||||
DEBUG_LOG() << "Effect " << e->name << ", Action '" << a->comment << "' now has URL: " << url.toString();
|
||||
DEBUG_LOG(m_logger) << "Effect " << e->name << ", Action '" << a->comment << "' now has URL: " << url.toString();
|
||||
break;
|
||||
}
|
||||
case AC_Repeat:
|
||||
@@ -397,7 +397,7 @@ void XmlReader::generateUrl(const Effect *e, Action *a)
|
||||
case AC_Pause:
|
||||
case AC_Bsm:
|
||||
default:
|
||||
DEBUG_LOG() << "Effect " << e->name << ", Action '" << a->comment << "' of Type " << a->aclass << " needs no URL";
|
||||
DEBUG_LOG(m_logger) << "Effect " << e->name << ", Action '" << a->comment << "' of Type " << a->aclass << " needs no URL";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -178,6 +178,7 @@ public:
|
||||
XmlContents contents() const { return m_contents; }
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void createHttpRequests();
|
||||
static QString categoryName(Category c);
|
||||
|
||||
|
||||
+3
-3
@@ -65,7 +65,7 @@ void Api::sendHitResult(const HitResult &hitResult, const QMap <int, Contaminati
|
||||
tele.hitResult.contaminations += csi;
|
||||
}
|
||||
|
||||
DEBUG_LOG() << Q_FUNC_INFO << ", tele = " << tele.toJson();
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << ", tele = " << tele.toJson();
|
||||
|
||||
m_webSocketHandler->sendTelegram(&tele, ws);
|
||||
}
|
||||
@@ -141,7 +141,7 @@ void Api::sendEffectOverrides(const QString &segment,
|
||||
|
||||
void Api::onTelegramReceived(const std::shared_ptr<Telegrams::BaseTelegram> &tele)
|
||||
{
|
||||
DEBUG_LOG() << "tele->telegramId(): " << tele->telegramId();
|
||||
DEBUG_LOG(m_logger) << "tele->telegramId(): " << tele->telegramId();
|
||||
|
||||
if (tele->telegramId() == Telegrams::SetDamageState::telegramId())
|
||||
{
|
||||
@@ -271,7 +271,7 @@ void Api::onTelegramReceived(const std::shared_ptr<Telegrams::BaseTelegram> &tel
|
||||
emit getBsmTechnicalStatus(tel->sensorId);
|
||||
return;
|
||||
}
|
||||
WARNING_LOG() << "Received unhandled telegram " << tele->telegramId();
|
||||
WARNING_LOG(m_logger) << "Received unhandled telegram " << tele->telegramId();
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
@@ -76,6 +76,7 @@ Q_SIGNALS:
|
||||
private Q_SLOTS:
|
||||
void onTelegramReceived(const std::shared_ptr<Telegrams::BaseTelegram> &tele);
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
WebSocketHandler *m_webSocketHandler;
|
||||
};
|
||||
}
|
||||
|
||||
+8
-9
@@ -11,10 +11,9 @@ namespace BuildingControlUnit
|
||||
{
|
||||
namespace Json
|
||||
{
|
||||
WebSocketHandler::WebSocketHandler(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_webSocketServer(new QWebSocketServer(QStringLiteral("BCU"), QWebSocketServer::NonSecureMode, this))
|
||||
{}
|
||||
WebSocketHandler::WebSocketHandler(QObject *parent) : QObject(parent)
|
||||
, m_webSocketServer(new QWebSocketServer(QStringLiteral("BCU"), QWebSocketServer::NonSecureMode, this)),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {}
|
||||
|
||||
WebSocketHandler::~WebSocketHandler()
|
||||
{
|
||||
@@ -30,7 +29,7 @@ bool WebSocketHandler::init(quint16 listenPort)
|
||||
{
|
||||
if (!m_webSocketServer->listen(QHostAddress::Any, listenPort))
|
||||
{
|
||||
WARNING_LOG() << "Can not listen on port " << listenPort << " - aborting";
|
||||
WARNING_LOG(m_logger) << "Can not listen on port " << listenPort << " - aborting";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -48,7 +47,7 @@ bool WebSocketHandler::sendTelegram(const Telegrams::BaseTelegram *tele, QWebSoc
|
||||
return false;
|
||||
|
||||
const QString jsonStr = QString::fromUtf8(tele->toJson());
|
||||
DEBUG_LOG() << "jsonStr" << jsonStr;
|
||||
DEBUG_LOG(m_logger) << "jsonStr" << jsonStr;
|
||||
|
||||
bool bOk = false;
|
||||
for (QWebSocket *ws : std::as_const(m_webSockets))
|
||||
@@ -68,7 +67,7 @@ void WebSocketHandler::onNewConnection()
|
||||
QWebSocket *ws = m_webSocketServer->nextPendingConnection();
|
||||
if (!ws)
|
||||
return;
|
||||
DEBUG_LOG() << "New websocket connection from " << ws->peerAddress().toString() << ":" << ws->peerPort();
|
||||
DEBUG_LOG(m_logger) << "New websocket connection from " << ws->peerAddress().toString() << ":" << ws->peerPort();
|
||||
|
||||
connect(ws, &QWebSocket::textMessageReceived,
|
||||
this, &WebSocketHandler::onTextMessageReceived);
|
||||
@@ -82,11 +81,11 @@ void WebSocketHandler::onNewConnection()
|
||||
|
||||
void WebSocketHandler::onTextMessageReceived(const QString &msg)
|
||||
{
|
||||
DEBUG_LOG() << "new text message: " << msg;
|
||||
DEBUG_LOG(m_logger) << "new text message: " << msg;
|
||||
auto tele = std::shared_ptr<Telegrams::BaseTelegram>(Telegrams::BaseTelegram::telegramFromJson(msg.toUtf8()));
|
||||
if (!tele)
|
||||
{
|
||||
WARNING_LOG() << "Error parsing incoming json data: '" << msg << "'";
|
||||
WARNING_LOG(m_logger) << "Error parsing incoming json data: '" << msg << "'";
|
||||
return;
|
||||
}
|
||||
emit telegramReceived(tele);
|
||||
|
||||
+1
@@ -41,6 +41,7 @@ private Q_SLOTS:
|
||||
void onWebSocketDisconnected();
|
||||
void onTextMessageReceived(const QString &msg);
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
QWebSocketServer *m_webSocketServer;
|
||||
QSet<QWebSocket *> m_webSockets;
|
||||
};
|
||||
|
||||
+7
-8
@@ -13,10 +13,9 @@
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
|
||||
Test::Test()
|
||||
: m_api(new BuildingControlUnit::VWM::Api(this))
|
||||
.getNGLLogger("BCU.VWM.Test"))
|
||||
{
|
||||
Test::Test() : m_api(new BuildingControlUnit::VWM::Api(this))
|
||||
.getNGLLogger("BCU.VWM.Test")),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
connect(m_api, &BuildingControlUnit::VWM::Api::hitResult,
|
||||
this, &Test::hitResult);
|
||||
QTimer::singleShot(0, this, &Test::test1);
|
||||
@@ -29,7 +28,7 @@ Test::~Test()
|
||||
|
||||
void Test::hitResult(const BuildingControlUnit::HitResult &result)
|
||||
{
|
||||
INFO_LOG() << "Hit Result: sensorId = " << result.sensorId
|
||||
INFO_LOG(m_logger) << "Hit Result: sensorId = " << result.sensorId
|
||||
<< ", originatorId = " << result.originatorId
|
||||
<< ", chargeTypeId = " << result.chargeTypeId
|
||||
<< ", dmgPercentOld = " << result.damagePercentOld
|
||||
@@ -54,18 +53,18 @@ void Test::test1()
|
||||
const auto hitPos = BuildingControlUnit::VWM::Math::checkBsmPosition(bsm.position, bsm.direction, rooms);
|
||||
if (hitPos.state != BuildingControlUnit::VWM::HitPosition::State::OuterWall)
|
||||
{
|
||||
WARNING_LOG() << "Effect on bsm " << bsm.id << " does not hit building ! - position: "
|
||||
WARNING_LOG(m_logger) << "Effect on bsm " << bsm.id << " does not hit building ! - position: "
|
||||
<< bsm.position << ", direction: " << bsm.direction;
|
||||
}
|
||||
else if (hitPos.distance < 0)
|
||||
{
|
||||
WARNING_LOG() << "Effect on bsm " << bsm.id << " results in hit pos behind a wall ("
|
||||
WARNING_LOG(m_logger) << "Effect on bsm " << bsm.id << " results in hit pos behind a wall ("
|
||||
<< hitPos.distance << "m) instead in front - BSM is not modelled in the correct place: "
|
||||
<< bsm.position << ", direction: " << bsm.direction << ", roomId which was hit: " << hitPos.roomId;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_LOG() << "BSM with id " << bsm.id << " looks fine - room which will be hit: " << hitPos.roomId;
|
||||
DEBUG_LOG(m_logger) << "BSM with id " << bsm.id << " looks fine - room which will be hit: " << hitPos.roomId;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -24,4 +24,5 @@ private Q_SLOTS:
|
||||
void test5();
|
||||
void test6();
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
+49
-49
@@ -38,7 +38,7 @@ bool Api::init(const QString &chargesConfig,
|
||||
const BuildingBsmConfig &bsmConfig,
|
||||
const bool initBuilding)
|
||||
{
|
||||
DEBUG_LOG() << "chargesConfig=" << chargesConfig;
|
||||
DEBUG_LOG(m_logger) << "chargesConfig=" << chargesConfig;
|
||||
if (!XmlReader::readCharges(chargesConfig, m_chargeMap))
|
||||
return false;
|
||||
if (!XmlReader::readBuilding(vulBuildingConfig, m_building))
|
||||
@@ -48,21 +48,21 @@ bool Api::init(const QString &chargesConfig,
|
||||
QString fltXml = QString(QStringLiteral("/opt/BuildingModels/StaticMeshes/%1.flt.xml")).arg(m_building.name());
|
||||
if (!XmlReader::readBuildingGeometry(fltXml, m_buildingRoomGeometry ))
|
||||
{
|
||||
ERROR_LOG() << "Error reading buildingRoomGeometry from file: " << fltXml << "'";
|
||||
ERROR_LOG(m_logger) << "Error reading buildingRoomGeometry from file: " << fltXml << "'";
|
||||
|
||||
}
|
||||
|
||||
DEBUG_LOG() << "Building buildingRoomGeometry read successfully from file: " << fltXml << "'";
|
||||
DEBUG_LOG(m_logger) << "Building buildingRoomGeometry read successfully from file: " << fltXml << "'";
|
||||
|
||||
|
||||
|
||||
int numberOfRemoved = m_building.cleanupPolygons();
|
||||
int numberOfDuplicates = m_building.checkPolygons();
|
||||
DEBUG_LOG() << "Building cleanupPolygons: " << m_building.name() << "' -> " << numberOfRemoved << " points removed";
|
||||
DEBUG_LOG(m_logger) << "Building cleanupPolygons: " << m_building.name() << "' -> " << numberOfRemoved << " points removed";
|
||||
if (numberOfDuplicates > 0)
|
||||
ERROR_LOG() << "Building checkPolygons: " << m_building.name() << "' -> " << numberOfDuplicates << " duplicates";
|
||||
ERROR_LOG(m_logger) << "Building checkPolygons: " << m_building.name() << "' -> " << numberOfDuplicates << " duplicates";
|
||||
else
|
||||
DEBUG_LOG() << "Building checkPolygons: " << m_building.name() << "' -> " << numberOfDuplicates << " duplicates";
|
||||
DEBUG_LOG(m_logger) << "Building checkPolygons: " << m_building.name() << "' -> " << numberOfDuplicates << " duplicates";
|
||||
|
||||
|
||||
m_bsmMap = bsmConfig.bsmMap;
|
||||
@@ -85,7 +85,7 @@ void Api::onHitOptical(qint64 timeMSec, int sensorId, int originatorId, int char
|
||||
|
||||
if (!bsm.isValid())
|
||||
{
|
||||
WARNING_LOG() << "Given bsm id " << sensorId << " is not in our internal bsm list!";
|
||||
WARNING_LOG(m_logger) << "Given bsm id " << sensorId << " is not in our internal bsm list!";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ void Api::onHitOptical(qint64 timeMSec, int sensorId, int originatorId, int char
|
||||
|
||||
void Api::onSetEffectStatesRequest(const QString &hostname, const QVector<BcuEffectState> &effectStates)
|
||||
{
|
||||
DEBUG_LOG() << "onSetEffectStatesRequest:"
|
||||
DEBUG_LOG(m_logger) << "onSetEffectStatesRequest:"
|
||||
<< " hostname= " << hostname
|
||||
<< " effectStes.zize=" << effectStates.size();
|
||||
|
||||
@@ -120,7 +120,7 @@ void Api::onSetEffectStatesRequest(const QString &hostname, const QVector<BcuEff
|
||||
if (es.effectOverride == BcuEffectOverride::BEO_Off)
|
||||
{
|
||||
overridesObj.insert(QStringLiteral("flash"), 0);
|
||||
DEBUG_LOG() << "flash = 0";
|
||||
DEBUG_LOG(m_logger) << "flash = 0";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -137,14 +137,14 @@ void Api::onSetEffectStatesRequest(const QString &hostname, const QVector<BcuEff
|
||||
{
|
||||
QJsonObject relayStateObj;
|
||||
relayStateObj[QString::number(es.id)]=es.effectOverride;
|
||||
DEBUG_LOG() << "relay = " << QString::number(es.id)
|
||||
DEBUG_LOG(m_logger) << "relay = " << QString::number(es.id)
|
||||
<< " " << es.effectOverride;
|
||||
relayStateArray.append(relayStateObj);
|
||||
}
|
||||
else if (es.type == BcuEffectType::BET_BackgroundSound)
|
||||
{
|
||||
overridesObj.insert(QStringLiteral("sound"), es.effectOverride);
|
||||
DEBUG_LOG() << "sound=" << es.effectOverride;
|
||||
DEBUG_LOG(m_logger) << "sound=" << es.effectOverride;
|
||||
}
|
||||
}
|
||||
overridesObj.insert(QStringLiteral("relays"), relayStateArray);
|
||||
@@ -154,7 +154,7 @@ void Api::onSetEffectStatesRequest(const QString &hostname, const QVector<BcuEff
|
||||
propertiesObj[QStringLiteral("Overrides")] = overridesObj;
|
||||
|
||||
QString totalString = QString::fromLatin1(QJsonDocument(propertiesObj).toJson(QJsonDocument::Compact));
|
||||
DEBUG_LOG() << "totalString=" << totalString;
|
||||
DEBUG_LOG(m_logger) << "totalString=" << totalString;
|
||||
m_building.setSegmentProperties(hostname,totalString);
|
||||
StateStore::saveState(m_building, m_lastHitResult, m_contaminationStates);
|
||||
}
|
||||
@@ -264,15 +264,15 @@ void Api::onHitEcc(int originatorId, DamageState damageState, const QVector<int>
|
||||
|
||||
void Api::onSetContaminationState(const std::vector<ContaminationState> &contaminationStates)
|
||||
{
|
||||
DEBUG_LOG() << "contaminationStates.size=" << contaminationStates.size();
|
||||
DEBUG_LOG(m_logger) << "contaminationStates.size=" << contaminationStates.size();
|
||||
|
||||
for (const auto &newcs : contaminationStates)
|
||||
{
|
||||
DEBUG_LOG() << "newcs.damagePercentNew=" << newcs.damagePercentNew
|
||||
DEBUG_LOG(m_logger) << "newcs.damagePercentNew=" << newcs.damagePercentNew
|
||||
<< " m_lastHitResult.damagePercentNew=" << m_lastHitResult.damagePercentNew;
|
||||
if ( newcs.damagePercentNew > m_lastHitResult.damagePercentNew)
|
||||
{
|
||||
DEBUG_LOG() << "newcs.damagePercentNew=" << newcs.damagePercentNew;
|
||||
DEBUG_LOG(m_logger) << "newcs.damagePercentNew=" << newcs.damagePercentNew;
|
||||
m_lastHitResult.damagePercentNew = newcs.damagePercentNew;
|
||||
}
|
||||
if (m_contaminationStates.contains(newcs.aesId))
|
||||
@@ -302,7 +302,7 @@ void Api::onSetContaminationState(const std::vector<ContaminationState> &contami
|
||||
else
|
||||
m_contaminationStates.insert(newcs.aesId, newcs);
|
||||
}
|
||||
DEBUG_LOG() << "onSetContaminationState emit hitResult "
|
||||
DEBUG_LOG(m_logger) << "onSetContaminationState emit hitResult "
|
||||
<< " m_lastHitResult.damagePercentNew=" << m_lastHitResult.damagePercentNew;
|
||||
emit hitResult(m_lastHitResult, m_contaminationStates, false);
|
||||
StateStore::saveState(m_building, m_lastHitResult, m_contaminationStates);
|
||||
@@ -311,7 +311,7 @@ void Api::onSetContaminationState(const std::vector<ContaminationState> &contami
|
||||
void Api::onResetContaminations()
|
||||
{
|
||||
m_contaminationStates.clear();
|
||||
DEBUG_LOG() << "onResetContaminations emit hitResult";
|
||||
DEBUG_LOG(m_logger) << "onResetContaminations emit hitResult";
|
||||
m_lastHitResult.chargeTypeId = 0;
|
||||
m_lastHitResult.originatorId = 0;
|
||||
m_lastHitResult.originatorType = BuildingControlUnit::OriginatorType::ECC;
|
||||
@@ -338,7 +338,7 @@ void Api::onHitCes(const qint64 effectTimeMSec, const int chargeTypeId,
|
||||
|
||||
hit.position.setZ(1);
|
||||
|
||||
INFO_LOG() << "XXXXX CES Hit = " << hit;
|
||||
INFO_LOG(m_logger) << "XXXXX CES Hit = " << hit;
|
||||
|
||||
|
||||
|
||||
@@ -349,7 +349,7 @@ void Api::onHitCes(const qint64 effectTimeMSec, const int chargeTypeId,
|
||||
posTmp.setZ(10000);
|
||||
const LtsUtils::QPoint3D direction(0,0,1);
|
||||
const auto hitPosTmp = BuildingControlUnit::VWM::Math::checkBsmPosition(posTmp, direction, m_building.rooms());
|
||||
INFO_LOG() << "XXXXX hitPosTmp after checkBsmPosition = " << hitPosTmp;
|
||||
INFO_LOG(m_logger) << "XXXXX hitPosTmp after checkBsmPosition = " << hitPosTmp;
|
||||
if (hitPosTmp.state != BuildingControlUnit::VWM::HitPosition::State::NoHit)
|
||||
{
|
||||
auto room = m_building.rooms().value(hitPosTmp.roomId);
|
||||
@@ -382,7 +382,7 @@ void Api::onHitCes(const qint64 effectTimeMSec, const int chargeTypeId,
|
||||
NearestWall nearestWall;
|
||||
if (hitPos.state == BuildingControlUnit::VWM::HitPosition::State::NoHit)
|
||||
{
|
||||
INFO_LOG() << "XXXXX CES Hit outside building - searching nearest wall ...";
|
||||
INFO_LOG(m_logger) << "XXXXX CES Hit outside building - searching nearest wall ...";
|
||||
|
||||
double distanceOut = 0;
|
||||
LtsUtils::QPoint3D directionWallElementPointToDetonationOut;
|
||||
@@ -399,14 +399,14 @@ void Api::onHitCes(const qint64 effectTimeMSec, const int chargeTypeId,
|
||||
|
||||
if (hitPos.state == BuildingControlUnit::VWM::HitPosition::State::NoHit)
|
||||
{
|
||||
WARNING_LOG() << "Internal error - could not find impact position on building "
|
||||
WARNING_LOG(m_logger) << "Internal error - could not find impact position on building "
|
||||
<< m_building.name() << " with impact pos " << posImpactOnGround;
|
||||
}
|
||||
INFO_LOG() << "XXXXX Aes hit - hit pos: " << posImpactOnGround << " direction: " << hit.direction
|
||||
INFO_LOG(m_logger) << "XXXXX Aes hit - hit pos: " << posImpactOnGround << " direction: " << hit.direction
|
||||
<< " (p=" << hit.direction+posImpactOnGround << ")"
|
||||
<< " ; nearestWall.roomId=" << nearestWall.roomId;
|
||||
for (auto item : std::as_const(nearestWall.wallElement))
|
||||
DEBUG_LOG() << "Aes hit - hit pos: " << posImpactOnGround << " direction: " << hit.direction
|
||||
DEBUG_LOG(m_logger) << "Aes hit - hit pos: " << posImpactOnGround << " direction: " << hit.direction
|
||||
<< " (p=" << hit.direction+posImpactOnGround
|
||||
<< " - " << item;
|
||||
|
||||
@@ -417,7 +417,7 @@ void Api::onHitCes(const qint64 effectTimeMSec, const int chargeTypeId,
|
||||
|
||||
const LtsUtils::QPoint3D ¢er = centerOfWallElement3D(nearestWall.wallElement);
|
||||
|
||||
INFO_LOG() << "XXXXX Aes hit - hit pos: " << posImpactOnGround << " direction: " << hit.direction
|
||||
INFO_LOG(m_logger) << "XXXXX Aes hit - hit pos: " << posImpactOnGround << " direction: " << hit.direction
|
||||
<< ", m_building.name=" << m_building.name()
|
||||
<< ", m_building.modelId=" << m_building.modelId()
|
||||
<< ", nearestWall.roomId=" << nearestWall.roomId
|
||||
@@ -436,7 +436,7 @@ NearestWall Api::findNearestWall(const LtsUtils::QPoint3D &detonationLocation, d
|
||||
NearestWall nearestWall;
|
||||
distanceOut = std::numeric_limits<double>::max();
|
||||
|
||||
INFO_LOG() << "XXXXX searching nearest wall ...";
|
||||
INFO_LOG(m_logger) << "XXXXX searching nearest wall ...";
|
||||
for (const Room &room : std::as_const(m_building.rooms()))
|
||||
{
|
||||
for (const OuterWall &wall : std::as_const(room.outerWalls()))
|
||||
@@ -446,13 +446,13 @@ NearestWall Api::findNearestWall(const LtsUtils::QPoint3D &detonationLocation, d
|
||||
for (const LtsUtils::QPoint3D &p : std::as_const(we))
|
||||
{
|
||||
const double dist = (detonationLocation - p).length();
|
||||
DEBUG_LOG() << "Room[" << room.id() << "]: " << p << ", dist = " << dist;
|
||||
DEBUG_LOG(m_logger) << "Room[" << room.id() << "]: " << p << ", dist = " << dist;
|
||||
if (dist >= distanceOut)
|
||||
continue;
|
||||
|
||||
|
||||
distanceOut = dist;
|
||||
INFO_LOG() << "New min distance " << dist << " Room[" << room.id() << "]: " << p;
|
||||
INFO_LOG(m_logger) << "New min distance " << dist << " Room[" << room.id() << "]: " << p;
|
||||
directionWallElementPointToDetonationOut = p - detonationLocation;
|
||||
|
||||
nearestWall.roomId = room.id();
|
||||
@@ -486,7 +486,7 @@ void Api::onHitCes3D_Evaluation(const qint64 effectTimeMSec,
|
||||
|
||||
|
||||
|
||||
INFO_LOG() << "XXXXXXXXXX CES Hit 3D = " << hit
|
||||
INFO_LOG(m_logger) << "XXXXXXXXXX CES Hit 3D = " << hit
|
||||
<< ", detonationLocation = " << detonationLocation
|
||||
<< ", detonationDistance = " << detonationDistance
|
||||
<< ", chargeTypeId = " << chargeTypeId
|
||||
@@ -514,16 +514,16 @@ void Api::onHitCes3D_Evaluation(const qint64 effectTimeMSec,
|
||||
roomsWithDetonation = m_buildingRoomGeometry.pointIsInWhichRooms(detonationLocation);
|
||||
if (roomsWithDetonation.isEmpty())
|
||||
{
|
||||
INFO_LOG() << "XXXX Building '" << m_building.name() << "'"
|
||||
INFO_LOG(m_logger) << "XXXX Building '" << m_building.name() << "'"
|
||||
<< ", detonationLocation = " << detonationLocation
|
||||
<< " -> found no room";
|
||||
} else {
|
||||
if (roomsWithDetonation.size() == 1)
|
||||
INFO_LOG() << "XXXX Building '" << m_building.name() << "'"
|
||||
INFO_LOG(m_logger) << "XXXX Building '" << m_building.name() << "'"
|
||||
<< ", detonationLocation = " << detonationLocation
|
||||
<< " -> found just one room: " << roomsWithDetonation.first();
|
||||
else
|
||||
INFO_LOG() << "XXXX Building '" << m_building.name() << "'"
|
||||
INFO_LOG(m_logger) << "XXXX Building '" << m_building.name() << "'"
|
||||
<< ", detonationLocation = " << detonationLocation
|
||||
<< " -> found several rooms, choose first: " << roomsWithDetonation.first();
|
||||
|
||||
@@ -541,7 +541,7 @@ void Api::onHitCes3D_Evaluation(const qint64 effectTimeMSec,
|
||||
LtsUtils::QPoint3D directionWallElementPointToDetonationOut;
|
||||
NearestWall nearestWall = findNearestWall(detonationLocation, distanceOut, directionWallElementPointToDetonationOut);
|
||||
|
||||
INFO_LOG() << "XXXXX CES Hit outside building - searching nearest wall ..."
|
||||
INFO_LOG(m_logger) << "XXXXX CES Hit outside building - searching nearest wall ..."
|
||||
<< ", detonationDistance = " << detonationDistance
|
||||
<< ", nearestWall.roomId = " << nearestWall.roomId;
|
||||
|
||||
@@ -588,7 +588,7 @@ void Api::onHitCes3D_Evaluation(const qint64 effectTimeMSec,
|
||||
bool hitSuccess = m_building.hit(LtsUtils::QPoint3D(), LtsUtils::QPoint3D(),
|
||||
charge, &hitPosPreCalculated);
|
||||
|
||||
INFO_LOG() << "onHitCes3D_Evaluation hitSuccess=" << hitSuccess;
|
||||
INFO_LOG(m_logger) << "onHitCes3D_Evaluation hitSuccess=" << hitSuccess;
|
||||
|
||||
result.rooms = m_building.roomStates();
|
||||
result.damageState = m_building.damageState();
|
||||
@@ -627,7 +627,7 @@ void Api::onFortifyFactorRequest(int originatorId, const QVector<FortifyInfo> &f
|
||||
|
||||
void Api::onRelayStatesRequest(const QString &hostname, const QVector<RelayStateInfo> &relayStateInfos)
|
||||
{
|
||||
DEBUG_LOG() << "onRelayStateRequest hostname=" << hostname
|
||||
DEBUG_LOG(m_logger) << "onRelayStateRequest hostname=" << hostname
|
||||
<< " only hanlde in svcBuildings"
|
||||
<< " relayStateInfos.size()=" << relayStateInfos.size();
|
||||
}
|
||||
@@ -649,14 +649,14 @@ void Api::sendOverrides()
|
||||
|
||||
QJsonObject docObj = QJsonObject(doc.object());
|
||||
|
||||
DEBUG_LOG() << "sendOverrides hostname=" << hostname
|
||||
DEBUG_LOG(m_logger) << "sendOverrides hostname=" << hostname
|
||||
<< " properties=" << properties;
|
||||
|
||||
|
||||
|
||||
|
||||
{
|
||||
DEBUG_LOG() << "sendOverrides hostname=" << hostname
|
||||
DEBUG_LOG(m_logger) << "sendOverrides hostname=" << hostname
|
||||
<< " properties=" << properties << "BCU-Flash";
|
||||
BcuEffectState bcuEffectState;
|
||||
bcuEffectState.id = 1;
|
||||
@@ -677,7 +677,7 @@ void Api::sendOverrides()
|
||||
}
|
||||
if (eo != BcuEffectOverride::BEO_Auto)
|
||||
{
|
||||
DEBUG_LOG() << "bcuEffectState.effectOverride = eo" << eo;
|
||||
DEBUG_LOG(m_logger) << "bcuEffectState.effectOverride = eo" << eo;
|
||||
bcuEffectState.effectOverride = eo;
|
||||
emit newOverrides({}, {bcuEffectState});
|
||||
}
|
||||
@@ -726,7 +726,7 @@ void Api::sendHitToVwm(const Hit &hit)
|
||||
{
|
||||
m_hitsSinceLastInit += hit;
|
||||
|
||||
INFO_LOG() << " XXXXX sendHitToVwm, Incoming hit=" << hit
|
||||
INFO_LOG(m_logger) << " XXXXX sendHitToVwm, Incoming hit=" << hit
|
||||
<< " hit.chargeTypeId=" << hit.chargeTypeId
|
||||
<< " originatorId=" << hit.originatorId
|
||||
<< " typeOfHit=" << hit.typeOfHit;
|
||||
@@ -753,7 +753,7 @@ void Api::sendHitToVwm(const Hit &hit)
|
||||
charge.penetrationEffect = hit.penetrationFactor;
|
||||
}
|
||||
|
||||
DEBUG_LOG() << "charge=" << charge.chargeTypeId
|
||||
DEBUG_LOG(m_logger) << "charge=" << charge.chargeTypeId
|
||||
<< " destructiveFactor" << charge.destructiveFactor
|
||||
<< " penetrationEffect" << charge.penetrationEffect;
|
||||
chargeOrg = charge;
|
||||
@@ -770,23 +770,23 @@ void Api::sendHitToVwm(const Hit &hit)
|
||||
|
||||
LtsUtils::QPoint3D dummyDist = hit.position - hit.direction;
|
||||
|
||||
INFO_LOG() << " XXXX CES outside bulding, reduce charge: " << charge
|
||||
INFO_LOG(m_logger) << " XXXX CES outside bulding, reduce charge: " << charge
|
||||
<< ", hit.position " << hit.position
|
||||
<< ", hit.direction " << hit.direction
|
||||
<< ", dummyDist " << dummyDist.length();
|
||||
charge.destructiveFactor *= 0.5;
|
||||
charge.penetrationEffect *= 0.5;
|
||||
INFO_LOG() << " XXXX CES outside bulding, reduce charge: " << charge;
|
||||
INFO_LOG(m_logger) << " XXXX CES outside bulding, reduce charge: " << charge;
|
||||
}
|
||||
|
||||
if (!charge.isValid())
|
||||
{
|
||||
if (hit.originatorType == OriginatorType::CesHit)
|
||||
WARNING_LOG() << "Charge with id " << hit.chargeTypeId
|
||||
WARNING_LOG(m_logger) << "Charge with id " << hit.chargeTypeId
|
||||
<< " not configured - can not caluclate impact effect for this charge";
|
||||
else
|
||||
{
|
||||
WARNING_LOG() << "Direct charge with id " << hit.chargeTypeId
|
||||
WARNING_LOG(m_logger) << "Direct charge with id " << hit.chargeTypeId
|
||||
<< " not configured - can not caluclate impact effect for this charge";
|
||||
emit unknownDirectHit(hit.sensorId);
|
||||
}
|
||||
@@ -794,7 +794,7 @@ void Api::sendHitToVwm(const Hit &hit)
|
||||
}
|
||||
if (!m_building.hit(hit.position, hit.direction, charge))
|
||||
{
|
||||
WARNING_LOG() << "Detected hit was outside of the building - ignored";
|
||||
WARNING_LOG(m_logger) << "Detected hit was outside of the building - ignored";
|
||||
break;
|
||||
}
|
||||
result.rooms = m_building.roomStates();
|
||||
@@ -832,7 +832,7 @@ void Api::sendHitToVwm(const Hit &hit)
|
||||
{
|
||||
case DamageState::NoDamage:
|
||||
{
|
||||
DEBUG_LOG() << "Hit OC/ECC with NoDamage";
|
||||
DEBUG_LOG(m_logger) << "Hit OC/ECC with NoDamage";
|
||||
m_building.init();
|
||||
|
||||
result.effectSoundId = Settings::effectSoundIdEccActivate();
|
||||
@@ -855,7 +855,7 @@ void Api::sendHitToVwm(const Hit &hit)
|
||||
}
|
||||
case DamageState::Destroyed:
|
||||
{
|
||||
DEBUG_LOG() << "Hit OC/ECC with Destroyed";
|
||||
DEBUG_LOG(m_logger) << "Hit OC/ECC with Destroyed";
|
||||
const DamageState dsOld = m_building.damageState();
|
||||
|
||||
m_building.destroyAllRooms();
|
||||
@@ -879,14 +879,14 @@ void Api::sendHitToVwm(const Hit &hit)
|
||||
break;
|
||||
}
|
||||
default:
|
||||
WARNING_LOG() << "Invalid damage state override given: " << hit.damageStateOverride;
|
||||
WARNING_LOG(m_logger) << "Invalid damage state override given: " << hit.damageStateOverride;
|
||||
result = HitResult();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case OriginatorType::Unknown:
|
||||
WARNING_LOG() << "Unknown originator type given: " << hit.originatorType;
|
||||
WARNING_LOG(m_logger) << "Unknown originator type given: " << hit.originatorType;
|
||||
result = HitResult();
|
||||
break;
|
||||
}
|
||||
@@ -905,7 +905,7 @@ const Charge Api::chargeFromChargeTypeId(int chargeTypeId) const
|
||||
|
||||
for (auto i = m_chargeMap.cbegin(), end = m_chargeMap.cend(); i != end; ++i)
|
||||
{
|
||||
TRACE_LOG() << "key=" << i.key() << " value=" << i.value();
|
||||
TRACE_LOG(m_logger) << "key=" << i.key() << " value=" << i.value();
|
||||
if ( chargeTypeId == i.value().id)
|
||||
return m_chargeMap.value(i.key());
|
||||
}
|
||||
|
||||
@@ -77,6 +77,7 @@ Q_SIGNALS:
|
||||
void newOverrides( const QString &hostname, const QVector<BcuEffectState> &effectStates);
|
||||
void unknownDirectHit(int sensorId);
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void sendHitToVwm(const Hit &hit);
|
||||
private:
|
||||
QMap<int, Bsm> m_bsmMap;
|
||||
|
||||
+12
-12
@@ -354,7 +354,7 @@ int Building::cleanupDublicatePointsInPolygon(int roomId, int idx, int subIdx, c
|
||||
auto p2 = points.at(j);
|
||||
if (qFuzzyCompare(p1, p2))
|
||||
{
|
||||
DEBUG_LOG() << "Building '" << m_name << "' -> "
|
||||
DEBUG_LOG(m_logger) << "Building '" << m_name << "' -> "
|
||||
<< "Polygon point " << i << " (" << p1 << ") and " << j << " (" << p2
|
||||
<< ") in room " << roomId << ", " << type << "[" << idx
|
||||
<< "], element[" << subIdx << "] are the same! -> REMOVE";
|
||||
@@ -410,7 +410,7 @@ QVector<HitRoom> Building::roomStates() const
|
||||
hr.fortifyFactor = room.fortifyFactor();
|
||||
hr.directHit = room.isDirectHit();
|
||||
ret += hr;
|
||||
DEBUG_LOG() << "HitRoom " << hr.roomId
|
||||
DEBUG_LOG(m_logger) << "HitRoom " << hr.roomId
|
||||
<< " damage: " << hr.damagePercent
|
||||
<< "%, remainEffect: " << hr.remainingEffectPercent << "%"
|
||||
<< ", remainingEffectChargeTypeId: " << hr.remainingEffectChargeTypeId << "%"
|
||||
@@ -448,7 +448,7 @@ void Building::setRoomState(DamageState damageState, const QVector<int> &afffect
|
||||
auto it = m_rooms.find(roomId);
|
||||
if (it == m_rooms.end())
|
||||
{
|
||||
WARNING_LOG() << "Could not find room with id " << roomId;
|
||||
WARNING_LOG(m_logger) << "Could not find room with id " << roomId;
|
||||
continue;
|
||||
}
|
||||
if (damageState == DamageState::Destroyed)
|
||||
@@ -465,7 +465,7 @@ void Building::setFortifyInfo(const QVector<FortifyInfo> &foritfyInfos)
|
||||
auto it = m_rooms.find(info.roomId);
|
||||
if (it == m_rooms.end())
|
||||
{
|
||||
WARNING_LOG() << "Could not find room with id " << info.roomId;
|
||||
WARNING_LOG(m_logger) << "Could not find room with id " << info.roomId;
|
||||
continue;
|
||||
}
|
||||
Room &room = it.value();
|
||||
@@ -538,14 +538,14 @@ bool Building::hit(const LtsUtils::QPoint3D &pos, const LtsUtils::QPoint3D &dir,
|
||||
const bool bBelowGround = isLastHitPositionBelowGroundHack();
|
||||
if (bBelowGround)
|
||||
{
|
||||
INFO_LOG() << " XXXX CES belowGround, reduce charge: " << charge;
|
||||
INFO_LOG(m_logger) << " XXXX CES belowGround, reduce charge: " << charge;
|
||||
charge.destructiveFactor *= 0.25;
|
||||
charge.penetrationEffect *= 0.25;
|
||||
INFO_LOG() << " XXXX CES belowGround, reduce charge: " << charge;
|
||||
INFO_LOG(m_logger) << " XXXX CES belowGround, reduce charge: " << charge;
|
||||
}
|
||||
|
||||
|
||||
INFO_LOG() << "XXXXX HitPosition: state=" << m_lastHitPosition.state
|
||||
INFO_LOG(m_logger) << "XXXXX HitPosition: state=" << m_lastHitPosition.state
|
||||
<< ", m_name=" << m_name
|
||||
<< ", m_modelId=" << m_modelId
|
||||
<< ", roomId=" << m_lastHitPosition.roomId
|
||||
@@ -560,7 +560,7 @@ bool Building::hit(const LtsUtils::QPoint3D &pos, const LtsUtils::QPoint3D &dir,
|
||||
Room &hitRoom = m_rooms[m_lastHitPosition.roomId];
|
||||
if (!hitRoom.isValid())
|
||||
{
|
||||
ERROR_LOG() << "Internal error in hit calculation - could not find room with id " << m_lastHitPosition.roomId;
|
||||
ERROR_LOG(m_logger) << "Internal error in hit calculation - could not find room with id " << m_lastHitPosition.roomId;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -651,7 +651,7 @@ QMap<int, Building::NeighboursToCheck> Building::checkHitNeighbours(const QMap<i
|
||||
auto itRoom = m_rooms.find(neighbourRoomId);
|
||||
if (itRoom == m_rooms.end())
|
||||
{
|
||||
WARNING_LOG() << "Could not find room with id " << neighbourRoomId;
|
||||
WARNING_LOG(m_logger) << "Could not find room with id " << neighbourRoomId;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -670,7 +670,7 @@ QMap<int, Building::NeighboursToCheck> Building::checkHitNeighbours(const QMap<i
|
||||
|
||||
const double oldRe = neighbour.remainingEffect();
|
||||
neighbour.setRemainingEffect(neighbourRoom.remainEffect * TF);
|
||||
DEBUG_LOG() << "room " << neighbourRoomId << " remaining effect old: "
|
||||
DEBUG_LOG(m_logger) << "room " << neighbourRoomId << " remaining effect old: "
|
||||
<< oldRe << " -> new: " << neighbour.remainingEffect();
|
||||
|
||||
|
||||
@@ -740,7 +740,7 @@ int Building::checkDublicatePointsInPolygon(int roomId, int idx, int subIdx, con
|
||||
if (qFuzzyCompare(p1, p2))
|
||||
{
|
||||
++numberOfDuplicates;
|
||||
WARNING_LOG() << "Building '" << m_name << "' -> "
|
||||
WARNING_LOG(m_logger) << "Building '" << m_name << "' -> "
|
||||
<< "Polygon point " << i << " (" << p1 << ") and " << j << " (" << p2
|
||||
<< ") in room " << roomId << ", " << type << "[" << idx
|
||||
<< "], element[" << subIdx << "] are the same! (size=" << points.size() << ")";
|
||||
@@ -750,7 +750,7 @@ int Building::checkDublicatePointsInPolygon(int roomId, int idx, int subIdx, con
|
||||
|
||||
if (numberOfDuplicates > 0)
|
||||
for (auto point : points)
|
||||
WARNING_LOG() << "Building '" << m_name << "' -> " << "point =" << point << " (same points)";
|
||||
WARNING_LOG(m_logger) << "Building '" << m_name << "' -> " << "point =" << point << " (same points)";
|
||||
return numberOfDuplicates;
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -29,6 +29,8 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
int m_id = 0;
|
||||
double m_transitionFactor = 0;
|
||||
};
|
||||
|
||||
+11
-11
@@ -17,30 +17,30 @@ namespace VWM
|
||||
BuildingRoomGeometry::BuildingRoomGeometry()
|
||||
: m_logger(BuildingControlUnit::getLogger("VWM.BuildingRoomGeometry"))
|
||||
{
|
||||
TRACE_LOG() << Q_FUNC_INFO << " START";
|
||||
TRACE_LOG() << Q_FUNC_INFO << " END";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
}
|
||||
|
||||
BuildingRoomGeometry::~BuildingRoomGeometry()
|
||||
{
|
||||
TRACE_LOG() << Q_FUNC_INFO << " START";
|
||||
TRACE_LOG() << Q_FUNC_INFO << " END";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
}
|
||||
|
||||
bool BuildingRoomGeometry::init(const QDomElement &domRoot)
|
||||
{
|
||||
TRACE_LOG() << Q_FUNC_INFO << " START";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
|
||||
parse(domRoot);
|
||||
|
||||
TRACE_LOG() << Q_FUNC_INFO << " END";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QVector<int> BuildingRoomGeometry::pointIsInWhichRooms(const LtsUtils::QPoint3D &pointToFind)
|
||||
{
|
||||
TRACE_LOG() << Q_FUNC_INFO << " START, pointToFind" << pointToFind
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START, pointToFind" << pointToFind
|
||||
<< ", m_roomOutlines.size() " << m_roomOutlines.size();
|
||||
|
||||
QVector<int> roomtIds;
|
||||
@@ -52,26 +52,26 @@ QVector<int> BuildingRoomGeometry::pointIsInWhichRooms(const LtsUtils::QPoint3D
|
||||
const int roomId = it.key();
|
||||
const RoomOutlineData &rod = it.value();
|
||||
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " check room " << roomId << " (check maxZ " << rod.maxZ << " ; minZ " << rod.minZ;
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " check room " << roomId << " (check maxZ " << rod.maxZ << " ; minZ " << rod.minZ;
|
||||
if (m_logger.isDebugEnabled())
|
||||
qCritical() << " check room " << roomId << ", outline: " << rod.outline;
|
||||
|
||||
|
||||
if (rod.outline.containsPoint( {pointToFind.x(), pointToFind.y()}, Qt::OddEvenFill))
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " within room " << roomId;
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " within room " << roomId;
|
||||
|
||||
if ((rod.maxZ > pointToFind.z()) &&
|
||||
(pointToFind.z() > rod.minZ))
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " found roomId: " << roomId
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " found roomId: " << roomId
|
||||
<< " pointToFind: " << pointToFind.x() << " , " << pointToFind.y();
|
||||
roomtIds.append(roomId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TRACE_LOG() << Q_FUNC_INFO << " END, roomtIds.size() " << roomtIds.size();
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END, roomtIds.size() " << roomtIds.size();
|
||||
return roomtIds;
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -36,6 +36,8 @@ public:
|
||||
QVector<int> pointIsInWhichRooms(const LtsUtils::QPoint3D &pointToFind);
|
||||
|
||||
private:
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
bool parse(const QDomElement &domGroup);
|
||||
|
||||
|
||||
|
||||
+20
-21
@@ -9,12 +9,11 @@
|
||||
|
||||
namespace BuildingControlUnit
|
||||
{
|
||||
HandleHttpRequest::HandleHttpRequest(bool useQueue, QObject *parent)
|
||||
: QObject(parent)
|
||||
HandleHttpRequest::HandleHttpRequest(bool useQueue, QObject *parent) : QObject(parent)
|
||||
, m_nam(new QNetworkAccessManager(this))
|
||||
, m_bUseQueue(useQueue)
|
||||
{
|
||||
INFO_LOG() << "Using Queue: " << m_bUseQueue;
|
||||
, m_bUseQueue(useQueue),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
INFO_LOG(m_logger) << "Using Queue: " << m_bUseQueue;
|
||||
connect(m_nam, &QNetworkAccessManager::finished,
|
||||
this, &HandleHttpRequest::onReplyFinished);
|
||||
connect(m_nam, &QNetworkAccessManager::authenticationRequired,
|
||||
@@ -41,7 +40,7 @@ void HandleHttpRequest::enqueue(const QUrl &url, HandleHttpQueueMessageStatus st
|
||||
if ((HandleHttpQueueMessageStatus::MS_Cyclic == status) &&
|
||||
m_queueMap[host].uniquenessChecker.contains(url.toString()))
|
||||
{
|
||||
WARNING_LOG() << "Discarding duplicate url \"" << url.toString() << "\" due to slow message handling.";
|
||||
WARNING_LOG(m_logger) << "Discarding duplicate url \"" << url.toString() << "\" due to slow message handling.";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -49,7 +48,7 @@ void HandleHttpRequest::enqueue(const QUrl &url, HandleHttpQueueMessageStatus st
|
||||
networkRequest.request = QNetworkRequest(url);
|
||||
m_queueMap[host].uniquenessChecker.insert(url.toString());
|
||||
m_queueMap[host].requests.enqueue(networkRequest);
|
||||
DEBUG_LOG() << "Added '" << url.toString() << " to queue for host: " << host
|
||||
DEBUG_LOG(m_logger) << "Added '" << url.toString() << " to queue for host: " << host
|
||||
<< " Queue has " << m_queueMap[host].requests.count() << " elements";
|
||||
trySendNextRequest();
|
||||
}
|
||||
@@ -59,21 +58,21 @@ void HandleHttpRequest::onAuthenticationRequired(QNetworkReply *reply, QAuthenti
|
||||
{
|
||||
if (!reply || !authenticator)
|
||||
{
|
||||
ERROR_LOG() << "Internal error - Nullptr exception!";
|
||||
ERROR_LOG(m_logger) << "Internal error - Nullptr exception!";
|
||||
}
|
||||
else if (!m_queueMap.contains(reply->url().host()))
|
||||
{
|
||||
WARNING_LOG() << "Internal error - got auth reply from unknown host!";
|
||||
WARNING_LOG(m_logger) << "Internal error - got auth reply from unknown host!";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_bUseQueue && reply != m_queueMap[reply->url().host()].activeReply)
|
||||
WARNING_LOG() << "Internal error - got auth reply from unknown request!";
|
||||
WARNING_LOG(m_logger) << "Internal error - got auth reply from unknown request!";
|
||||
|
||||
|
||||
if (m_queueMap[reply->url().host()].bAuthAlreadyRequested)
|
||||
return;
|
||||
DEBUG_LOG() << "Authentication request";
|
||||
DEBUG_LOG(m_logger) << "Authentication request";
|
||||
authenticator->setUser(m_username);
|
||||
authenticator->setPassword(m_passwd);
|
||||
m_queueMap[reply->url().host()].bAuthAlreadyRequested = true;
|
||||
@@ -89,17 +88,17 @@ void HandleHttpRequest::onReplyFinished(QNetworkReply *reply)
|
||||
}
|
||||
if (!reply)
|
||||
{
|
||||
ERROR_LOG() << "Internal error - Nullptr exception!";
|
||||
ERROR_LOG(m_logger) << "Internal error - Nullptr exception!";
|
||||
}
|
||||
else if (!m_queueMap.contains(reply->url().host()))
|
||||
{
|
||||
reply->deleteLater();
|
||||
WARNING_LOG() << "Internal error - got reply from unknown host!";
|
||||
WARNING_LOG(m_logger) << "Internal error - got reply from unknown host!";
|
||||
}
|
||||
else if (m_bUseQueue && reply != m_queueMap[reply->url().host()].activeReply)
|
||||
{
|
||||
reply->deleteLater();
|
||||
WARNING_LOG() << "Internal error - got reply from unknown request!";
|
||||
WARNING_LOG(m_logger) << "Internal error - got reply from unknown request!";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -109,16 +108,16 @@ void HandleHttpRequest::onReplyFinished(QNetworkReply *reply)
|
||||
if ( m_newConnection)
|
||||
{
|
||||
m_newConnection = false;
|
||||
DEBUG_LOG() << "emit newEgcuConnection host=" << reply->url().host();
|
||||
DEBUG_LOG(m_logger) << "emit newEgcuConnection host=" << reply->url().host();
|
||||
emit newEgcuConnection(reply->url().host());
|
||||
}
|
||||
DEBUG_LOG() << "Request successfull";
|
||||
DEBUG_LOG(m_logger) << "Request successfull";
|
||||
}
|
||||
else
|
||||
WARNING_LOG() << "Invalid request for host " << reply->url().host() << ", response code: " << responseCode << ", query: " << reply->url().toString();
|
||||
WARNING_LOG(m_logger) << "Invalid request for host " << reply->url().host() << ", response code: " << responseCode << ", query: " << reply->url().toString();
|
||||
|
||||
QByteArray replyData = reply->readAll();
|
||||
DEBUG_LOG() << "Got reply (" << reply->url().toString() << "): " << replyData
|
||||
DEBUG_LOG(m_logger) << "Got reply (" << reply->url().toString() << "): " << replyData
|
||||
<< " host=" << reply->url().host();
|
||||
emit egcuReply(reply->url().host(), replyData);
|
||||
|
||||
@@ -133,7 +132,7 @@ void HandleHttpRequest::sendNextRequest(HandleHttpQueue& queue)
|
||||
{
|
||||
if (m_bUseQueue && queue.activeReply != nullptr)
|
||||
{
|
||||
WARNING_LOG() << "Internal error - active reply not yet finished!";
|
||||
WARNING_LOG(m_logger) << "Internal error - active reply not yet finished!";
|
||||
}
|
||||
else if (!queue.requests.isEmpty())
|
||||
{
|
||||
@@ -144,11 +143,11 @@ void HandleHttpRequest::sendNextRequest(HandleHttpQueue& queue)
|
||||
if ( networkRequest.time.secsTo(QTime::currentTime()) < 5)
|
||||
{
|
||||
queue.activeReply = m_nam->get(request);
|
||||
DEBUG_LOG() << "Send request " << request.url().toString() << " and waiting for reply (" << queue.activeReply << ")";
|
||||
DEBUG_LOG(m_logger) << "Send request " << request.url().toString() << " and waiting for reply (" << queue.activeReply << ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_LOG() << "remove request " << request.url().toString()
|
||||
DEBUG_LOG(m_logger) << "remove request " << request.url().toString()
|
||||
<< " because it's too old" << networkRequest.time.secsTo(QTime::currentTime());
|
||||
sendNextRequest(queue);
|
||||
m_newConnection = true;
|
||||
|
||||
+1
@@ -68,6 +68,7 @@ private Q_SLOTS:
|
||||
void trySendNextRequest();
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
QNetworkAccessManager *m_nam;
|
||||
bool m_bUseQueue;
|
||||
QString m_username;
|
||||
|
||||
+24
-25
@@ -11,15 +11,14 @@
|
||||
|
||||
namespace BuildingControlUnit
|
||||
{
|
||||
MainHandler::MainHandler()
|
||||
: QObject()
|
||||
MainHandler::MainHandler() : QObject()
|
||||
, m_bsmApi(nullptr)
|
||||
, m_jsonApi(nullptr)
|
||||
, m_vwmApi(nullptr)
|
||||
, m_handelEffectsBsm(nullptr)
|
||||
, m_handleHttpRequest(nullptr)
|
||||
, m_bsmFlash(BEO_Auto)
|
||||
{}
|
||||
, m_bsmFlash(BEO_Auto),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {}
|
||||
|
||||
MainHandler::~MainHandler()
|
||||
{
|
||||
@@ -59,17 +58,17 @@ bool MainHandler::init(const QString &ammuXml,
|
||||
}
|
||||
if (!m_vwmApi->init(ammuXml, vwmXml, bsmConfig, initBuilding))
|
||||
{
|
||||
ERROR_LOG() << "Can not initialize VWM API - aborting";
|
||||
ERROR_LOG(m_logger) << "Can not initialize VWM API - aborting";
|
||||
return false;
|
||||
}
|
||||
if (!m_jsonApi->init(listenPort))
|
||||
{
|
||||
ERROR_LOG() << "Can not initialize Json API - aborting";
|
||||
ERROR_LOG(m_logger) << "Can not initialize Json API - aborting";
|
||||
return false;
|
||||
}
|
||||
if (!m_bsmApi->init(bsmConfig))
|
||||
{
|
||||
ERROR_LOG() << "Can not initialize BSM API - aborting";
|
||||
ERROR_LOG(m_logger) << "Can not initialize BSM API - aborting";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -135,16 +134,16 @@ bool MainHandler::init(const QString &ammuXml,
|
||||
|
||||
void MainHandler::setInitialOverrides(const QString &hostname)
|
||||
{
|
||||
DEBUG_LOG() << "setInitialOverrides m_handelEffectsVec.size()=" << m_handelEffectsVec.size();
|
||||
DEBUG_LOG(m_logger) << "setInitialOverrides m_handelEffectsVec.size()=" << m_handelEffectsVec.size();
|
||||
|
||||
for ( int i = 0; i < m_handelEffectsVec.size(); i++)
|
||||
{
|
||||
QString hostnameLocal = m_handelEffectsVec.at(i)->hostname();
|
||||
const QVector<BcuEffectState> effectStates = m_handelEffectsVec.at(i)->getOverrides();
|
||||
DEBUG_LOG() << "setInitialOverrides host=" << hostnameLocal
|
||||
DEBUG_LOG(m_logger) << "setInitialOverrides host=" << hostnameLocal
|
||||
<< " effectStates.size=" << effectStates.size();
|
||||
for (int j = 0; j < effectStates.size(); j++)
|
||||
DEBUG_LOG() << "setInitialOverrides j=" << j
|
||||
DEBUG_LOG(m_logger) << "setInitialOverrides j=" << j
|
||||
<< " id=" << effectStates[j].id
|
||||
<< " type=" << effectStates[j].type
|
||||
<< " override=" << effectStates[j].effectOverride;
|
||||
@@ -171,7 +170,7 @@ void MainHandler::onHitResult(const HitResult &result, const QMap<int, Contamina
|
||||
{
|
||||
Q_UNUSED(contaminationStates)
|
||||
const VWM::Charge charge = m_vwmApi->chargeFromChargeTypeId(result.chargeTypeId);
|
||||
DEBUG_LOG() << "onHitResult chargeTypeId=" << result.chargeTypeId
|
||||
DEBUG_LOG(m_logger) << "onHitResult chargeTypeId=" << result.chargeTypeId
|
||||
<< " result.effectSoundId=" << result.effectSoundId
|
||||
<< " damagePercentNew=" << result.damagePercentNew
|
||||
<< " destructiveFactor=" << charge.destructiveFactor;
|
||||
@@ -182,15 +181,15 @@ void MainHandler::onHitResult(const HitResult &result, const QMap<int, Contamina
|
||||
{
|
||||
for (HandelEffects *he : std::as_const(m_handelEffectsVec))
|
||||
{
|
||||
DEBUG_LOG() << "playHitSound @EGCU " << he->hostname() << ", SoundId: " << result.effectSoundId;
|
||||
DEBUG_LOG(m_logger) << "playHitSound @EGCU " << he->hostname() << ", SoundId: " << result.effectSoundId;
|
||||
he->playHitSound(result.effectSoundId);
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_LOG() << "HitResult: " << result;
|
||||
DEBUG_LOG(m_logger) << "HitResult: " << result;
|
||||
if (result.sensorId != 0 && result.originatorId != 0 && m_bsmFlash != BEO_Off && charge.destructiveFactor > 1 )
|
||||
{
|
||||
DEBUG_LOG() << "BSM Flash";
|
||||
DEBUG_LOG(m_logger) << "BSM Flash";
|
||||
m_bsmApi->triggerFlashlight(result.sensorId);
|
||||
m_bsmApi->triggerFlashlightPulse(result.sensorId,
|
||||
QString(),
|
||||
@@ -200,7 +199,7 @@ void MainHandler::onHitResult(const HitResult &result, const QMap<int, Contamina
|
||||
Settings::flashDuration());
|
||||
}
|
||||
else
|
||||
DEBUG_LOG() << "Kein BSM Flash";
|
||||
DEBUG_LOG(m_logger) << "Kein BSM Flash";
|
||||
|
||||
|
||||
|
||||
@@ -210,14 +209,14 @@ void MainHandler::onHitResult(const HitResult &result, const QMap<int, Contamina
|
||||
|
||||
for (int i = 0; i < m_egcuConfig.egcus.size(); i++)
|
||||
{
|
||||
DEBUG_LOG() << "segmentDamage.size=" << segmentDamage.size();
|
||||
DEBUG_LOG(m_logger) << "segmentDamage.size=" << segmentDamage.size();
|
||||
if ( i < segmentDamage.size() )
|
||||
{
|
||||
DEBUG_LOG() << "segmentDamage[" << i <<"]=" << segmentDamage[i];
|
||||
DEBUG_LOG(m_logger) << "segmentDamage[" << i <<"]=" << segmentDamage[i];
|
||||
m_handelEffectsVec[i]->startEffects(segmentDamage[i]);
|
||||
}
|
||||
else
|
||||
DEBUG_LOG() << "No segment Damage for egcu:" << m_egcuConfig.egcus[i].hostname;
|
||||
DEBUG_LOG(m_logger) << "No segment Damage for egcu:" << m_egcuConfig.egcus[i].hostname;
|
||||
}
|
||||
m_handelEffectsBsm->startEffects(result.damagePercentNew);
|
||||
}
|
||||
@@ -231,22 +230,22 @@ void MainHandler::onUnknownDirectHit(int sensorId)
|
||||
|
||||
void MainHandler::onSetEffectStatesRequest(const QString &hostname, const QVector<BcuEffectState> &effectStates)
|
||||
{
|
||||
DEBUG_LOG() << "1 BSM flash hostname='" << hostname
|
||||
DEBUG_LOG(m_logger) << "1 BSM flash hostname='" << hostname
|
||||
<< "' isEmpty:"<< hostname.isEmpty()
|
||||
<<" isNull:" << hostname.isNull();
|
||||
m_effectStates.insert(hostname, effectStates);
|
||||
if (hostname.isEmpty())
|
||||
{
|
||||
m_bsmFlash = BEO_Auto;
|
||||
DEBUG_LOG() << "2 BSM flash =" << m_bsmFlash;
|
||||
DEBUG_LOG(m_logger) << "2 BSM flash =" << m_bsmFlash;
|
||||
m_handelEffectsBsm->setOverrides(effectStates);
|
||||
for ( int i = 0; i < effectStates.size(); i++)
|
||||
{
|
||||
DEBUG_LOG() << "3 BSM flash =" << m_bsmFlash;
|
||||
DEBUG_LOG(m_logger) << "3 BSM flash =" << m_bsmFlash;
|
||||
if ( effectStates.at(i).type == BET_BsmFlash)
|
||||
{
|
||||
m_bsmFlash = effectStates.at(i).effectOverride;
|
||||
DEBUG_LOG() << "4 BSM flash =" << m_bsmFlash;
|
||||
DEBUG_LOG(m_logger) << "4 BSM flash =" << m_bsmFlash;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -266,7 +265,7 @@ void MainHandler::onSwitchRelayRequest(const QString &hostname, const SwitchRela
|
||||
{
|
||||
if (m_handelEffectsVec[i]->hostname() == hostname )
|
||||
{
|
||||
DEBUG_LOG() << "switchRelay "
|
||||
DEBUG_LOG(m_logger) << "switchRelay "
|
||||
<< " id=" << switchRelayValues.id
|
||||
<< " bcuRelayState=" << switchRelayValues.bcuRelayState;
|
||||
m_handelEffectsVec[i]->switchRelay(switchRelayValues);
|
||||
@@ -328,7 +327,7 @@ QVector<int> MainHandler::getSegmentDamage(const QVector<HitRoom> &allHitRooms,
|
||||
if (egcu.roomIds.size() > 0 )
|
||||
averageDamage = damagePercentSegment / egcu.roomIds.size();
|
||||
result.append(averageDamage);
|
||||
INFO_LOG() << "getSegmentDamage[" << egcu.hostname << "]=" << averageDamage;
|
||||
INFO_LOG(m_logger) << "getSegmentDamage[" << egcu.hostname << "]=" << averageDamage;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -337,7 +336,7 @@ QVector<int> MainHandler::getSegmentDamage(const QVector<HitRoom> &allHitRooms,
|
||||
void MainHandler::flashBuildingDestructionIndicator(int egcu)
|
||||
{
|
||||
|
||||
ERROR_LOG() << "TODO flashBuildingDestructionIndicator egcu=" << egcu;
|
||||
ERROR_LOG(m_logger) << "TODO flashBuildingDestructionIndicator egcu=" << egcu;
|
||||
|
||||
|
||||
|
||||
|
||||
+2
@@ -37,12 +37,14 @@ private Q_SLOTS:
|
||||
void onSwitchRelayRequest(const QString &hostname, const SwitchRelayValues &switchRelayValues);
|
||||
void webSocketSendInitialData(QWebSocket *ws);
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
QVector<int> getAffectedRoomIds(const QVector<HitRoom> &allHitRooms) const;
|
||||
QVector<int> getSegmentDamage(const QVector<HitRoom> &allHitRooms, const int damagePercentNew) const;
|
||||
int getHitRoomId(const QVector<HitRoom> &allHitRooms) const;
|
||||
void flashBuildingDestructionIndicator(int egcu);
|
||||
void cleanup();
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
BSM::Api *m_bsmApi;
|
||||
|
||||
Json::Api *m_jsonApi;
|
||||
|
||||
@@ -40,13 +40,13 @@ BuildingControlHandler::~BuildingControlHandler()
|
||||
|
||||
bool BuildingControlHandler::init()
|
||||
{
|
||||
DEBUG_LOG()<<"BuildingControlHandler::init exerciseId="<<m_mainHandler->exerciseId();
|
||||
DEBUG_LOG(m_logger)<<"BuildingControlHandler::init exerciseId="<<m_mainHandler->exerciseId();
|
||||
|
||||
const QString bcuName = QStringLiteral("BuildingControlUnit");
|
||||
m_bcuExecutableName = QStandardPaths::findExecutable(bcuName, { QCoreApplication::applicationDirPath()});
|
||||
if (m_bcuExecutableName.isEmpty())
|
||||
{
|
||||
WARNING_LOG() << "Executable " << bcuName << " not found - can not start building control unit processes!";
|
||||
WARNING_LOG(m_logger) << "Executable " << bcuName << " not found - can not start building control unit processes!";
|
||||
return false;
|
||||
}
|
||||
if (m_mainHandler->exerciseId() > 0)
|
||||
@@ -61,18 +61,18 @@ bool BuildingControlHandler::init()
|
||||
|
||||
const QMultiMap<qint64, Buildings::HistoryState> latestStates = recordReplay.getHistoryStateMap();
|
||||
|
||||
DEBUG_LOG() << "Starting to read HistoryStatedata from record replay. Size: "
|
||||
DEBUG_LOG(m_logger) << "Starting to read HistoryStatedata from record replay. Size: "
|
||||
<< latestStates.size();
|
||||
for (auto it = latestStates.begin(); it != latestStates.end(); ++it)
|
||||
{
|
||||
const Buildings::HistoryState &historyState = it.value();
|
||||
if (!m_mainHandler->ismHandler()->isElementAssignedToExercise(historyState.mseId(),m_mainHandler->exerciseId() ))
|
||||
{
|
||||
DEBUG_LOG()<<"[INIT] [recordReplay]>>>>>>> mseId=" << historyState.mseId() << " not in execise";
|
||||
DEBUG_LOG(m_logger)<<"[INIT] [recordReplay]>>>>>>> mseId=" << historyState.mseId() << " not in execise";
|
||||
continue;
|
||||
}
|
||||
m_historyStates.insert(historyState.mseId(), historyState);
|
||||
DEBUG_LOG()<<"[INIT] [recordReplay]>>>>>>> "<<historyState;
|
||||
DEBUG_LOG(m_logger)<<"[INIT] [recordReplay]>>>>>>> "<<historyState;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -92,7 +92,7 @@ void BuildingControlHandler::onBuildingRemoved(int buildingId)
|
||||
|
||||
void BuildingControlHandler::onBuildingChanged(const BuildingInfo &buildingInfo, bool damageInit = false)
|
||||
{
|
||||
DEBUG_LOG() << "onBuildingChanged damageInit=" << damageInit
|
||||
DEBUG_LOG(m_logger) << "onBuildingChanged damageInit=" << damageInit
|
||||
<< " mseId=" << buildingInfo.mseId;
|
||||
auto it = m_buildings.find(buildingInfo.mseId);
|
||||
BuildingProcess *bldg = nullptr;
|
||||
@@ -103,7 +103,7 @@ void BuildingControlHandler::onBuildingChanged(const BuildingInfo &buildingInfo,
|
||||
buildingInfo,
|
||||
damageInit,
|
||||
this);
|
||||
DEBUG_LOG() << "onBuildingChanged m_buildings.insert mseId=" << buildingInfo.mseId;
|
||||
DEBUG_LOG(m_logger) << "onBuildingChanged m_buildings.insert mseId=" << buildingInfo.mseId;
|
||||
m_buildings.insert(buildingInfo.mseId, bldg);
|
||||
bldg->newRelayInfos(m_relayInfos);
|
||||
bldg->start();
|
||||
@@ -118,17 +118,17 @@ void BuildingControlHandler::onBuildingChanged(const BuildingInfo &buildingInfo,
|
||||
if ( m_historyStates.contains(buildingInfo.mseId))
|
||||
{
|
||||
historyState = m_historyStates.value(buildingInfo.mseId);
|
||||
DEBUG_LOG() << "onBuildingChanged setHistoryState contains historyState.mseId=" << historyState.mseId()
|
||||
DEBUG_LOG(m_logger) << "onBuildingChanged setHistoryState contains historyState.mseId=" << historyState.mseId()
|
||||
<< " buildingInfo.mseId=" << buildingInfo.mseId;
|
||||
}
|
||||
else
|
||||
{
|
||||
historyState.mseId (buildingInfo.mseId);
|
||||
DEBUG_LOG() << "onBuildingChanged setHistoryState insert historyState.mseId=" << historyState.mseId()
|
||||
DEBUG_LOG(m_logger) << "onBuildingChanged setHistoryState insert historyState.mseId=" << historyState.mseId()
|
||||
<< " buildingInfo.mseId=" << buildingInfo.mseId;
|
||||
m_historyStates.insert(historyState.mseId(), historyState);
|
||||
}
|
||||
DEBUG_LOG() << "onBuildingChanged setHistoryState historyState.mseId=" << historyState.mseId()
|
||||
DEBUG_LOG(m_logger) << "onBuildingChanged setHistoryState historyState.mseId=" << historyState.mseId()
|
||||
<< " buildingInfo.mseId=" << buildingInfo.mseId;
|
||||
bldg->setHistoryState(m_historyStates.value(buildingInfo.mseId));
|
||||
}
|
||||
@@ -136,59 +136,59 @@ void BuildingControlHandler::onBuildingChanged(const BuildingInfo &buildingInfo,
|
||||
void BuildingControlHandler::onSetBuildingContaminationStateRequest(const rti::core::SampleIdentity &cookie,
|
||||
const SetBuildingContaminationStateRequest &request)
|
||||
{
|
||||
DEBUG_LOG() << "onSetBuildingContaminationStateRequest " << request;
|
||||
DEBUG_LOG(m_logger) << "onSetBuildingContaminationStateRequest " << request;
|
||||
const Core::FunctionReplyObject fro = onSetBuildingContaminationStateRequestInternal(request);
|
||||
if (fro.error())
|
||||
WARNING_LOG() << fro();
|
||||
WARNING_LOG(m_logger) << fro();
|
||||
m_mainHandler->ddsHandler()->fts()->setBuildingContaminationStateReply(cookie, fro);
|
||||
}
|
||||
|
||||
void BuildingControlHandler::onSetBuildingStatesRequest(const rti::core::SampleIdentity &cookie,
|
||||
const SetBuildingStatesRequest &request)
|
||||
{
|
||||
DEBUG_LOG() << "onSetBuildingStatesRequest " << request;
|
||||
DEBUG_LOG(m_logger) << "onSetBuildingStatesRequest " << request;
|
||||
const Core::FunctionReplyObject fro = onSetBuildingStatesRequestInternal(request);
|
||||
if (fro.error())
|
||||
WARNING_LOG() << fro();
|
||||
WARNING_LOG(m_logger) << fro();
|
||||
m_mainHandler->ddsHandler()->fts()->setBuildingStatesReply(cookie, fro);
|
||||
}
|
||||
|
||||
void BuildingControlHandler::onSetFortifyFactorRequest(const rti::core::SampleIdentity &cookie,
|
||||
const SetFortifyFactorRequest &request)
|
||||
{
|
||||
DEBUG_LOG() << "onSetFortifyFactorRequest " << request;
|
||||
DEBUG_LOG(m_logger) << "onSetFortifyFactorRequest " << request;
|
||||
const Core::FunctionReplyObject fro = onSetFortifyFactorRequestInternal(request);
|
||||
if (fro.error())
|
||||
WARNING_LOG() << fro();
|
||||
WARNING_LOG(m_logger) << fro();
|
||||
m_mainHandler->ddsHandler()->fts()->setFortifyFactorReply(cookie, fro);
|
||||
}
|
||||
|
||||
void BuildingControlHandler::onSendCesHitOnBuildingRequest(const rti::core::SampleIdentity &cookie,
|
||||
const SendCesHitOnBuildingRequest &request)
|
||||
{
|
||||
DEBUG_LOG() << "onSendCesHitOnBuildingRequest " << request;
|
||||
DEBUG_LOG(m_logger) << "onSendCesHitOnBuildingRequest " << request;
|
||||
const Core::FunctionReplyObject fro = onSendCesHitOnBuildingRequestInternal(request);
|
||||
if (fro.error())
|
||||
WARNING_LOG() << fro();
|
||||
WARNING_LOG(m_logger) << fro();
|
||||
m_mainHandler->ddsHandler()->fts()->sendCesHitOnBuildingReply(cookie, fro);
|
||||
}
|
||||
|
||||
void BuildingControlHandler::onSendCesHit3DonBuildingRequest(const rti::core::SampleIdentity &cookie, const SendCesHit3DonBuildingRequest &request)
|
||||
{
|
||||
DEBUG_LOG() << "onSendCesHit3DonBuildingRequest " << request;
|
||||
DEBUG_LOG(m_logger) << "onSendCesHit3DonBuildingRequest " << request;
|
||||
const Core::FunctionReplyObject fro = onSendCesHit3DonBuildingRequestInternal(request);
|
||||
if (fro.error())
|
||||
WARNING_LOG() << fro();
|
||||
WARNING_LOG(m_logger) << fro();
|
||||
m_mainHandler->ddsHandler()->fts()->sendCesHit3DonBuildingReply(cookie, fro);
|
||||
}
|
||||
|
||||
void BuildingControlHandler::onTriggerBsmFlashRequest(const rti::core::SampleIdentity &cookie,
|
||||
const TriggerBsmFlashRequest &request)
|
||||
{
|
||||
DEBUG_LOG() << "onTriggerBsmFlashRequest " << request;
|
||||
DEBUG_LOG(m_logger) << "onTriggerBsmFlashRequest " << request;
|
||||
const Core::FunctionReplyObject fro = onTriggerBsmFlashInternal(request);
|
||||
if (fro.error())
|
||||
WARNING_LOG() << fro();
|
||||
WARNING_LOG(m_logger) << fro();
|
||||
m_mainHandler->ddsHandler()->fts()->triggerBsmFlashReply(cookie, fro);
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ Core::FunctionReplyObject BuildingControlHandler::onSetFortifyFactorRequestInter
|
||||
|
||||
void BuildingControlHandler::setEffectStates(const int buildingId, const int assetId, const QByteArray &properties)
|
||||
{
|
||||
DEBUG_LOG() << "BuildingControlHandler::setEffectStates"
|
||||
DEBUG_LOG(m_logger) << "BuildingControlHandler::setEffectStates"
|
||||
<< " buildingId=" << buildingId
|
||||
<< " assetId=" << assetId
|
||||
<< " properties=" << properties;
|
||||
@@ -282,11 +282,11 @@ void BuildingControlHandler::onRelayInfoChanged(const AssetManagement::RelayInfo
|
||||
|
||||
Core::FunctionReplyObject BuildingControlHandler::onSendCesHitOnBuildingRequestInternal(const SendCesHitOnBuildingRequest &data)
|
||||
{
|
||||
DEBUG_LOG() << "onSendCesHitOnBuildingRequestInternal";
|
||||
DEBUG_LOG(m_logger) << "onSendCesHitOnBuildingRequestInternal";
|
||||
auto it = m_buildings.find(data.buildingId());
|
||||
if (it == m_buildings.end())
|
||||
{
|
||||
DEBUG_LOG() << "onSendCesHitOnBuildingRequestInternal return";
|
||||
DEBUG_LOG(m_logger) << "onSendCesHitOnBuildingRequestInternal return";
|
||||
return Core::FunctionReplyObject(data.buildingId(), tr_lts("dds", "Building with id %1 not found.")).arg(data.buildingId());
|
||||
}
|
||||
|
||||
@@ -295,21 +295,21 @@ Core::FunctionReplyObject BuildingControlHandler::onSendCesHitOnBuildingRequestI
|
||||
data.aesId(), data.impactPosition(),
|
||||
QString::fromStdString(data.properties())))
|
||||
{
|
||||
DEBUG_LOG() << "onSendCesHitOnBuildingRequestInternal return Can not send ces hit to building control process";
|
||||
DEBUG_LOG(m_logger) << "onSendCesHitOnBuildingRequestInternal return Can not send ces hit to building control process";
|
||||
return Core::FunctionReplyObject(data.buildingId(), tr_lts("dds", "Can not send ces hit to building control process."));
|
||||
}
|
||||
DEBUG_LOG() << "FunctionReplyObject";
|
||||
DEBUG_LOG(m_logger) << "FunctionReplyObject";
|
||||
return Core::FunctionReplyObject();
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject BuildingControlHandler::onSendCesHit3DonBuildingRequestInternal(const SendCesHit3DonBuildingRequest &data)
|
||||
{
|
||||
|
||||
DEBUG_LOG() << "onSendCesHit3DonBuildingRequestInternal";
|
||||
DEBUG_LOG(m_logger) << "onSendCesHit3DonBuildingRequestInternal";
|
||||
auto it = m_buildings.find(data.buildingId());
|
||||
if (it == m_buildings.end())
|
||||
{
|
||||
DEBUG_LOG() << "onSendCesHit3DonBuildingRequestInternal return";
|
||||
DEBUG_LOG(m_logger) << "onSendCesHit3DonBuildingRequestInternal return";
|
||||
return Core::FunctionReplyObject(data.buildingId(), tr_lts("dds", "Building with id %1 not found.")).arg(data.buildingId());
|
||||
}
|
||||
|
||||
@@ -318,16 +318,16 @@ Core::FunctionReplyObject BuildingControlHandler::onSendCesHit3DonBuildingReques
|
||||
data.aesId(), data.impactPosition(), data.detonationLocation(), data.detonationDistance(),
|
||||
QString::fromStdString(data.properties())))
|
||||
{
|
||||
DEBUG_LOG() << "onSendCesHit3DonBuildingRequestInternal return Can not send ces hit to building control process";
|
||||
DEBUG_LOG(m_logger) << "onSendCesHit3DonBuildingRequestInternal return Can not send ces hit to building control process";
|
||||
return Core::FunctionReplyObject(data.buildingId(), tr_lts("dds", "Can not send ces hit to building control process."));
|
||||
}
|
||||
DEBUG_LOG() << "FunctionReplyObject";
|
||||
DEBUG_LOG(m_logger) << "FunctionReplyObject";
|
||||
return Core::FunctionReplyObject();
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject BuildingControlHandler::onTriggerBsmFlashInternal(const TriggerBsmFlashRequest &data)
|
||||
{
|
||||
DEBUG_LOG() << "onTriggerBsmFlashInternal";
|
||||
DEBUG_LOG(m_logger) << "onTriggerBsmFlashInternal";
|
||||
|
||||
|
||||
{
|
||||
@@ -340,34 +340,34 @@ Core::FunctionReplyObject BuildingControlHandler::onTriggerBsmFlashInternal(cons
|
||||
BuildingInfo buildingInfo= bldg->buildingInfo();
|
||||
BsmInfo bsmInfo = buildingInfo.bsms.value(data.assetId());
|
||||
|
||||
DEBUG_LOG() << " BuildingId=" << data.buildingId()
|
||||
DEBUG_LOG(m_logger) << " BuildingId=" << data.buildingId()
|
||||
<< " assetId=" << bsmInfo.assetId
|
||||
<< " hostname=" << bsmInfo.hostname;
|
||||
|
||||
if (!bldg->triggerFlashlight(data))
|
||||
{
|
||||
DEBUG_LOG() << "onTriggerBsmFlashInternal return Can not send trigger flashlight to building control process";
|
||||
DEBUG_LOG(m_logger) << "onTriggerBsmFlashInternal return Can not send trigger flashlight to building control process";
|
||||
return Core::FunctionReplyObject(data.buildingId(), tr_lts("dds", "Can not send trigger flashlight to building control process"));
|
||||
}
|
||||
}
|
||||
DEBUG_LOG() << "FunctionReplyObject";
|
||||
DEBUG_LOG(m_logger) << "FunctionReplyObject";
|
||||
return Core::FunctionReplyObject();
|
||||
}
|
||||
|
||||
void BuildingControlHandler::onSwitchRelayRequest(const rti::core::SampleIdentity &cookie,
|
||||
const SwitchRelayRequest &request)
|
||||
{
|
||||
DEBUG_LOG() << "SwitchRelayRequest " << request;
|
||||
DEBUG_LOG(m_logger) << "SwitchRelayRequest " << request;
|
||||
|
||||
const Core::FunctionReplyObject fro = onSwitchRelayInternal(request);
|
||||
if (fro.error())
|
||||
WARNING_LOG() << fro();
|
||||
WARNING_LOG(m_logger) << fro();
|
||||
m_mainHandler->ddsHandler()->fts()->switchRelayReply(cookie, fro);
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject BuildingControlHandler::onSwitchRelayInternal(const SwitchRelayRequest &data)
|
||||
{
|
||||
DEBUG_LOG() << "onSwitchRelayInternal " << data;
|
||||
DEBUG_LOG(m_logger) << "onSwitchRelayInternal " << data;
|
||||
auto it = m_buildings.find(data.buildingId());
|
||||
if (it == m_buildings.end())
|
||||
return Core::FunctionReplyObject(data.buildingId(), tr_lts("dds", "Building with id %1 not found.")).arg(data.buildingId());
|
||||
|
||||
@@ -39,6 +39,7 @@ public Q_SLOTS:
|
||||
void setEffectStates(const int buildingId, const int assetId, const QByteArray &properties);
|
||||
void onRelayInfoChanged(const AssetManagement::RelayInfo &info, const DataModification mod);
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void onSetBuildingContaminationStateRequest(const rti::core::SampleIdentity &cookie,
|
||||
const SetBuildingContaminationStateRequest &request) override;
|
||||
void onSetBuildingStatesRequest(const rti::core::SampleIdentity &cookie,
|
||||
@@ -63,6 +64,7 @@ private:
|
||||
Core::FunctionReplyObject onSwitchRelayInternal(const SwitchRelayRequest &data);
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
QMap<int, BuildingProcess *> m_buildings;
|
||||
QMap<int, Buildings::HistoryState> m_historyStates;
|
||||
QMap<int, AssetManagement::RelayInfo> m_relayInfos;
|
||||
|
||||
@@ -80,22 +80,22 @@ void BuildingProcess::setBuildingInfo(const BuildingInfo &info)
|
||||
|
||||
void BuildingProcess::onStructureElementUpdateEffectOverrideReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
DEBUG_LOG() << "onSendCesHitReply for id " << replyObject.id() << " success= " << replyObject.error();
|
||||
DEBUG_LOG(m_logger) << "onSendCesHitReply for id " << replyObject.id() << " success= " << replyObject.error();
|
||||
}
|
||||
|
||||
bool BuildingProcess::start()
|
||||
{
|
||||
DEBUG_LOG() << "BuildingProcess::start mseId = " << m_buildingInfo.mseId
|
||||
DEBUG_LOG(m_logger) << "BuildingProcess::start mseId = " << m_buildingInfo.mseId
|
||||
<< " m_historyState.size() = " << m_historyState.stateHistory().size()
|
||||
<< " m_initBuilding=" << m_initBuilding;
|
||||
if (m_buildingInfo.mseId <= 0)
|
||||
{
|
||||
WARNING_LOG() << "No valid building information set - can not start building process";
|
||||
WARNING_LOG(m_logger) << "No valid building information set - can not start building process";
|
||||
return false;
|
||||
}
|
||||
if (m_proc.state() != QProcess::NotRunning)
|
||||
{
|
||||
WARNING_LOG() << "Process for building " << m_buildingInfo.mseId << " is already running!";
|
||||
WARNING_LOG(m_logger) << "Process for building " << m_buildingInfo.mseId << " is already running!";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -120,13 +120,13 @@ bool BuildingProcess::start()
|
||||
const QByteArray bldCfgData = generateBuildingConfigData();
|
||||
|
||||
const QString effectConfigFilename = NGL::findFile(NGL::FileType::ConfigFile, QStringLiteral("effect_config.xml"));
|
||||
WARNING_LOG() << "(effectConfigFilename) = " << effectConfigFilename;
|
||||
WARNING_LOG(m_logger) << "(effectConfigFilename) = " << effectConfigFilename;
|
||||
|
||||
|
||||
const QString bldDataFilename = tmpPath + QStringLiteral("bldg_%1_building_config.xml").arg(m_buildingInfo.mseId);
|
||||
if (!writeFile(bldDataFilename, bldCfgData))
|
||||
{
|
||||
WARNING_LOG() << "(!writeFile(bldDataFilename, bldCfgData)";
|
||||
WARNING_LOG(m_logger) << "(!writeFile(bldDataFilename, bldCfgData)";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ bool BuildingProcess::start()
|
||||
const QString chargesDataFilename = tmpPath + QStringLiteral("bldg_%1_charges.xml").arg(m_buildingInfo.mseId);
|
||||
if (!writeFile(chargesDataFilename, chargesData))
|
||||
{
|
||||
WARNING_LOG() << "(!writeFile(chargesDataFilename, chargesData)";
|
||||
WARNING_LOG(m_logger) << "(!writeFile(chargesDataFilename, chargesData)";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ bool BuildingProcess::start()
|
||||
if (!effectPtr)
|
||||
continue;
|
||||
|
||||
DEBUG_LOG() << "effect->id=" << effectPtr->id
|
||||
DEBUG_LOG(m_logger) << "effect->id=" << effectPtr->id
|
||||
<< " effect->category=" << effectPtr->category
|
||||
<< " effect->effectType=" << effectPtr->effectType
|
||||
<< " effect->override=" << static_cast<int>(effectPtr->override);
|
||||
@@ -201,9 +201,9 @@ void BuildingProcess::shutdown()
|
||||
|
||||
void BuildingProcess::setHistoryState(const Buildings::HistoryState &historyState)
|
||||
{
|
||||
DEBUG_LOG() << "BuildingProcess::setHistoryState size =" << historyState.stateHistory().size();
|
||||
DEBUG_LOG(m_logger) << "BuildingProcess::setHistoryState size =" << historyState.stateHistory().size();
|
||||
|
||||
ERROR_LOG() << "[BuildingProcess::setHistoryState]>>> history =" << historyState;
|
||||
ERROR_LOG(m_logger) << "[BuildingProcess::setHistoryState]>>> history =" << historyState;
|
||||
m_historyState = historyState;
|
||||
m_historyState.sampleTime(QDateTime::currentMSecsSinceEpoch());
|
||||
m_mainHandler->ddsHandler()->dts()->publish(m_historyState);
|
||||
@@ -211,7 +211,7 @@ void BuildingProcess::setHistoryState(const Buildings::HistoryState &historyStat
|
||||
|
||||
bool BuildingProcess::setVulnerabilityState(ProjectDataManagement::VulnerabilityState state, const std::vector<int> &roomIds)
|
||||
{
|
||||
DEBUG_LOG() << "BuildingProcess::setVulnerabilityState:" << state;
|
||||
DEBUG_LOG(m_logger) << "BuildingProcess::setVulnerabilityState:" << state;
|
||||
if (!m_wsSocket || !m_wsSocket->isValid())
|
||||
return false;
|
||||
BuildingControlUnit::Json::Telegrams::SetDamageState tele;
|
||||
@@ -223,7 +223,7 @@ bool BuildingProcess::setVulnerabilityState(ProjectDataManagement::Vulnerability
|
||||
tele.roomIds += m_buildingInfo.roomId2SubId.value(id);
|
||||
|
||||
tele.originatorId = 0;
|
||||
DEBUG_LOG() << "setVulnerabilityState websocket send: " << QString::fromUtf8(tele.toJson());
|
||||
DEBUG_LOG(m_logger) << "setVulnerabilityState websocket send: " << QString::fromUtf8(tele.toJson());
|
||||
m_wsSocket->sendTextMessage(QString::fromUtf8(tele.toJson()));
|
||||
|
||||
return true;
|
||||
@@ -231,7 +231,7 @@ bool BuildingProcess::setVulnerabilityState(ProjectDataManagement::Vulnerability
|
||||
|
||||
bool BuildingProcess::setContaminationState(const int &bldId, const ContaminationState &contaminationState)
|
||||
{
|
||||
DEBUG_LOG() << "BuildingProcess::setContaminationState bldId: "<<bldId;
|
||||
DEBUG_LOG(m_logger) << "BuildingProcess::setContaminationState bldId: "<<bldId;
|
||||
if (!m_wsSocket || !m_wsSocket->isValid())
|
||||
return false;
|
||||
BuildingControlUnit::Json::Telegrams::SetContaminationState tele;
|
||||
@@ -244,18 +244,18 @@ bool BuildingProcess::setContaminationState(const int &bldId, const Contaminatio
|
||||
contState.rooms = contaminationState.rooms();
|
||||
tele.contaminationStates.push_back(contState);
|
||||
|
||||
DEBUG_LOG() << "SetContaminationState websocket send: " << QString::fromUtf8(tele.toJson());
|
||||
DEBUG_LOG(m_logger) << "SetContaminationState websocket send: " << QString::fromUtf8(tele.toJson());
|
||||
m_wsSocket->sendTextMessage(QString::fromUtf8(tele.toJson()));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BuildingProcess::resetContaminationState()
|
||||
{
|
||||
DEBUG_LOG() << "BuildingProcess::resetContaminationState" ;
|
||||
DEBUG_LOG(m_logger) << "BuildingProcess::resetContaminationState" ;
|
||||
if (!m_wsSocket || !m_wsSocket->isValid())
|
||||
return false;
|
||||
BuildingControlUnit::Json::Telegrams::ResetContaminationState tele;
|
||||
DEBUG_LOG() << "ResetContaminationState websocket send: " << QString::fromUtf8(tele.toJson());
|
||||
DEBUG_LOG(m_logger) << "ResetContaminationState websocket send: " << QString::fromUtf8(tele.toJson());
|
||||
m_wsSocket->sendTextMessage(QString::fromUtf8(tele.toJson()));
|
||||
|
||||
return true;
|
||||
@@ -276,7 +276,7 @@ bool BuildingProcess::setFortifyFactors(const std::vector<Buildings::FortifyFact
|
||||
|
||||
tele.fortifyFactors.push_back(info);
|
||||
}
|
||||
DEBUG_LOG() << "setFortifyFactors websocket send: " << QString::fromUtf8(tele.toJson());
|
||||
DEBUG_LOG(m_logger) << "setFortifyFactors websocket send: " << QString::fromUtf8(tele.toJson());
|
||||
m_wsSocket->sendTextMessage(QString::fromUtf8(tele.toJson()));
|
||||
return true;
|
||||
}
|
||||
@@ -293,7 +293,7 @@ bool BuildingProcess::setEffectStates( const int assetId, const QByteArray &prop
|
||||
|
||||
if (!m_wsSocket || !m_wsSocket->isValid())
|
||||
return false;
|
||||
DEBUG_LOG() << "setEffectStates"
|
||||
DEBUG_LOG(m_logger) << "setEffectStates"
|
||||
<< " assetId=" << assetId
|
||||
<< " properties=" << properties;
|
||||
|
||||
@@ -301,24 +301,24 @@ bool BuildingProcess::setEffectStates( const int assetId, const QByteArray &prop
|
||||
{
|
||||
for (const EgcuInfo &egcu : std::as_const(m_buildingInfo.egcus))
|
||||
{
|
||||
DEBUG_LOG() << "EGCU: " << egcu.assetName
|
||||
DEBUG_LOG(m_logger) << "EGCU: " << egcu.assetName
|
||||
<< " assetId=" << egcu.assetId
|
||||
<< " egcu.assetId=" << egcu.assetId
|
||||
<< " hostname=" << egcu.hostname;
|
||||
if ( assetId == egcu.assetId)
|
||||
{
|
||||
DEBUG_LOG() << "segment=" << egcu.hostname;
|
||||
DEBUG_LOG(m_logger) << "segment=" << egcu.hostname;
|
||||
tele.segment = egcu.hostname;
|
||||
}
|
||||
}
|
||||
if (tele.segment.isEmpty())
|
||||
{
|
||||
WARNING_LOG() << "Asset with id " << assetId << " not found in this building";
|
||||
WARNING_LOG(m_logger) << "Asset with id " << assetId << " not found in this building";
|
||||
return false;
|
||||
}
|
||||
if (tele.segment == QString())
|
||||
{
|
||||
ERROR_LOG() << "Asset with id=" << assetId << " has no Hostname!!!!";
|
||||
ERROR_LOG(m_logger) << "Asset with id=" << assetId << " has no Hostname!!!!";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -385,9 +385,9 @@ bool BuildingProcess::setEffectStates( const int assetId, const QByteArray &prop
|
||||
}
|
||||
|
||||
QString valueStr = QString::fromUtf8(tele.toJson());
|
||||
DEBUG_LOG() << "setEffectStates websocket send: " << valueStr;
|
||||
DEBUG_LOG(m_logger) << "setEffectStates websocket send: " << valueStr;
|
||||
qint64 sendBytesCount = m_wsSocket->sendTextMessage(valueStr);
|
||||
DEBUG_LOG() << "sendBytesCount= " << sendBytesCount;
|
||||
DEBUG_LOG(m_logger) << "sendBytesCount= " << sendBytesCount;
|
||||
m_effectStates.insert(assetId, valueStr);
|
||||
|
||||
return true;
|
||||
@@ -408,7 +408,7 @@ bool BuildingProcess::relayState(const std::vector<Buildings::RelayStateItem> &r
|
||||
tele.relayStates.push_back(info);
|
||||
}
|
||||
|
||||
DEBUG_LOG() << "relayState websocket send: " << QString::fromUtf8(tele.toJson());
|
||||
DEBUG_LOG(m_logger) << "relayState websocket send: " << QString::fromUtf8(tele.toJson());
|
||||
m_wsSocket->sendTextMessage(QString::fromUtf8(tele.toJson()));
|
||||
|
||||
return true;
|
||||
@@ -455,7 +455,7 @@ bool BuildingProcess::sendCesHitOnBuilding(const qint64 effectTimeMSec,
|
||||
tele.relPosition.z = relPos.offsetZ();
|
||||
tele.properties = properties;
|
||||
|
||||
DEBUG_LOG() << "sendCesHitOnBuilding websocket send: " << QString::fromUtf8(tele.toJson());
|
||||
DEBUG_LOG(m_logger) << "sendCesHitOnBuilding websocket send: " << QString::fromUtf8(tele.toJson());
|
||||
m_wsSocket->sendTextMessage(QString::fromUtf8(tele.toJson()));
|
||||
return true;
|
||||
}
|
||||
@@ -525,7 +525,7 @@ bool BuildingProcess::sendCesHit3DonBuilding(const qint64 effectTimeMSec, const
|
||||
tele.detonationDistance = detonationDistance;
|
||||
tele.properties = properties;
|
||||
|
||||
DEBUG_LOG() << "sendCesHit3DonBuilding websocket send: " << QString::fromUtf8(tele.toJson());
|
||||
DEBUG_LOG(m_logger) << "sendCesHit3DonBuilding websocket send: " << QString::fromUtf8(tele.toJson());
|
||||
m_wsSocket->sendTextMessage(QString::fromUtf8(tele.toJson()));
|
||||
return true;
|
||||
}
|
||||
@@ -536,7 +536,7 @@ bool BuildingProcess::switchRelay(const SwitchRelayRequest &data)
|
||||
|
||||
if (!m_wsSocket || !m_wsSocket->isValid())
|
||||
return false;
|
||||
DEBUG_LOG() << "switchRelay"
|
||||
DEBUG_LOG(m_logger) << "switchRelay"
|
||||
<< " buildingId=" << data.buildingId()
|
||||
<< " assetId=" << data.assetId()
|
||||
<< data.state();
|
||||
@@ -544,10 +544,10 @@ bool BuildingProcess::switchRelay(const SwitchRelayRequest &data)
|
||||
|
||||
for (const EgcuInfo &egcu : std::as_const(m_buildingInfo.egcus))
|
||||
{
|
||||
DEBUG_LOG() << "EGCU: " << egcu.assetName
|
||||
DEBUG_LOG(m_logger) << "EGCU: " << egcu.assetName
|
||||
<< " assetId=" << egcu.assetId
|
||||
<< " hostname=" << egcu.hostname;
|
||||
DEBUG_LOG() << "data.assetId()=" << data.assetId()
|
||||
DEBUG_LOG(m_logger) << "data.assetId()=" << data.assetId()
|
||||
<< "egcu.assetId=" << egcu.assetId;
|
||||
if ( data.assetId() != egcu.assetId)
|
||||
continue;
|
||||
@@ -561,7 +561,7 @@ bool BuildingProcess::switchRelay(const SwitchRelayRequest &data)
|
||||
tele.switchRelayValues.delay = data.pulseAttributes().get().delay();
|
||||
tele.switchRelayValues.pulse = data.pulseAttributes().get().pulse();
|
||||
}
|
||||
DEBUG_LOG() << "switchRelay websocket send: " << QString::fromUtf8(tele.toJson());
|
||||
DEBUG_LOG(m_logger) << "switchRelay websocket send: " << QString::fromUtf8(tele.toJson());
|
||||
m_wsSocket->sendTextMessage(QString::fromUtf8(tele.toJson()));
|
||||
return true;
|
||||
}
|
||||
@@ -574,7 +574,7 @@ bool BuildingProcess::triggerFlashlight(const TriggerBsmFlashRequest data)
|
||||
|
||||
if (!m_wsSocket || !m_wsSocket->isValid())
|
||||
return false;
|
||||
DEBUG_LOG() << "triggerFlashlight"
|
||||
DEBUG_LOG(m_logger) << "triggerFlashlight"
|
||||
<< " BuildingId=" << data.buildingId()
|
||||
<< " assetId=" << data.assetId()
|
||||
<< " m_buildingInfo.bsms.size()" << m_buildingInfo.bsms.size();
|
||||
@@ -582,7 +582,7 @@ bool BuildingProcess::triggerFlashlight(const TriggerBsmFlashRequest data)
|
||||
QMapIterator<int, BsmInfo> i(m_buildingInfo.bsms);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
DEBUG_LOG() << "key=" << i.key()
|
||||
DEBUG_LOG(m_logger) << "key=" << i.key()
|
||||
<< " assetId=" << i.value().assetId
|
||||
<< " bsmId=" << i.value().bsmId
|
||||
<< " hostname=" << i.value().hostname
|
||||
@@ -592,7 +592,7 @@ bool BuildingProcess::triggerFlashlight(const TriggerBsmFlashRequest data)
|
||||
if ( m_buildingInfo.bsms.contains(data.assetId()))
|
||||
{
|
||||
BsmInfo bsmInfo = m_buildingInfo.bsms.value(data.assetId());
|
||||
DEBUG_LOG() << " BuildingId=" << data.buildingId()
|
||||
DEBUG_LOG(m_logger) << " BuildingId=" << data.buildingId()
|
||||
<< " assetId=" << bsmInfo.assetId
|
||||
<< " hostname=" << bsmInfo.hostname;
|
||||
|
||||
@@ -601,7 +601,7 @@ bool BuildingProcess::triggerFlashlight(const TriggerBsmFlashRequest data)
|
||||
tele.pauseBetweenFlashesSec = 0;
|
||||
tele.sensorId = 0;
|
||||
|
||||
DEBUG_LOG() << "triggerFlashlight websocket send: " << QString::fromUtf8(tele.toJson());
|
||||
DEBUG_LOG(m_logger) << "triggerFlashlight websocket send: " << QString::fromUtf8(tele.toJson());
|
||||
m_wsSocket->sendTextMessage(QString::fromUtf8(tele.toJson()));
|
||||
return true;
|
||||
}
|
||||
@@ -615,7 +615,7 @@ void BuildingProcess::onReadyRead()
|
||||
if (data.contains(strToSearch))
|
||||
{
|
||||
m_wsUrl = data.split(strToSearch).at(1).split(QLatin1Char('\n')).at(0).trimmed();
|
||||
INFO_LOG() << "Using web socket url '" << m_wsUrl << "' for building " << m_buildingInfo.mseId;
|
||||
INFO_LOG(m_logger) << "Using web socket url '" << m_wsUrl << "' for building " << m_buildingInfo.mseId;
|
||||
openWebSocket();
|
||||
}
|
||||
}
|
||||
@@ -626,12 +626,12 @@ void BuildingProcess::onProcessFinished(int exitCode, QProcess::ExitStatus exitS
|
||||
if (exitCode == 0 && exitStatus == QProcess::NormalExit)
|
||||
return;
|
||||
const char *what = exitStatus == QProcess::NormalExit ? "stopped" : "crashed";
|
||||
WARNING_LOG() << "building control process for building " << m_buildingInfo.mseId
|
||||
WARNING_LOG(m_logger) << "building control process for building " << m_buildingInfo.mseId
|
||||
<< " " << what << " with exit code " << exitCode << " - restarting in 1 second";
|
||||
if (exitCode != 0)
|
||||
{
|
||||
WARNING_LOG() << "stdout: " << m_proc.readAllStandardOutput();
|
||||
WARNING_LOG() << "stderr: " << m_proc.readAllStandardError();
|
||||
WARNING_LOG(m_logger) << "stdout: " << m_proc.readAllStandardOutput();
|
||||
WARNING_LOG(m_logger) << "stderr: " << m_proc.readAllStandardError();
|
||||
}
|
||||
closeWebSocket();
|
||||
QTimer::singleShot(1000, this, &BuildingProcess::start);
|
||||
@@ -639,12 +639,12 @@ void BuildingProcess::onProcessFinished(int exitCode, QProcess::ExitStatus exitS
|
||||
|
||||
void BuildingProcess::onTextMessageReceived(const QString &message)
|
||||
{
|
||||
TRACE_LOG() << "Got message from building control process: " << message;
|
||||
TRACE_LOG(m_logger) << "Got message from building control process: " << message;
|
||||
BuildingControlUnit::Json::Telegrams::BaseTelegram *tel =
|
||||
BuildingControlUnit::Json::Telegrams::BaseTelegram::telegramFromJson(message.toUtf8());
|
||||
if (!tel)
|
||||
{
|
||||
WARNING_LOG() << "Can not convert '" << message << "' to a valid telegram!";
|
||||
WARNING_LOG(m_logger) << "Can not convert '" << message << "' to a valid telegram!";
|
||||
return;
|
||||
}
|
||||
if (tel->telegramId() == BuildingControlUnit::Json::Telegrams::BsmState::telegramId())
|
||||
@@ -656,7 +656,7 @@ void BuildingProcess::onTextMessageReceived(const QString &message)
|
||||
else if (tel->telegramId() == BuildingControlUnit::Json::Telegrams::EffectOverride::telegramId())
|
||||
handleEffectOverride(static_cast<BuildingControlUnit::Json::Telegrams::EffectOverride *>(tel));
|
||||
else
|
||||
WARNING_LOG() << "Unhandled incoming telegram with id '" << tel->telegramId() << "'";
|
||||
WARNING_LOG(m_logger) << "Unhandled incoming telegram with id '" << tel->telegramId() << "'";
|
||||
|
||||
delete tel;
|
||||
}
|
||||
@@ -692,7 +692,7 @@ void BuildingProcess::historyState(const BuildingState &state)
|
||||
&& state.originatorParticipantId() == 0
|
||||
&& state.contaminationStates().size() == 0)
|
||||
{
|
||||
DEBUG_LOG() << "setVulnerabilityState->removeHistoryStateByKey:" << state.id();
|
||||
DEBUG_LOG(m_logger) << "setVulnerabilityState->removeHistoryStateByKey:" << state.id();
|
||||
m_historyState.stateHistory().resize(0);
|
||||
}
|
||||
|
||||
@@ -708,10 +708,10 @@ void BuildingProcess::historyState(const BuildingState &state)
|
||||
historyStateItem.contaminationStates() = state.contaminationStates();
|
||||
|
||||
m_historyState.stateHistory().push_back(std::move(historyStateItem));
|
||||
DEBUG_LOG() << "BuildingProcess::historyState contaminationStates:" << state;
|
||||
DEBUG_LOG(m_logger) << "BuildingProcess::historyState contaminationStates:" << state;
|
||||
|
||||
m_historyState.mseId(state.id());
|
||||
DEBUG_LOG() << "setVulnerabilityState->removeHistoryStateByKey:" << m_historyState.mseId();
|
||||
DEBUG_LOG(m_logger) << "setVulnerabilityState->removeHistoryStateByKey:" << m_historyState.mseId();
|
||||
m_historyState.sampleTime(QDateTime::currentMSecsSinceEpoch());
|
||||
m_mainHandler->ddsHandler()->dts()->publish(m_historyState);
|
||||
}
|
||||
@@ -721,16 +721,16 @@ void BuildingProcess::handleHitResult(BuildingControlUnit::Json::Telegrams::HitR
|
||||
const BuildingControlUnit::Json::Telegrams::HitResult::HitResultInfo &data = tel->hitResult;
|
||||
BuildingState state;
|
||||
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " data.hitOnRoomId=" << data.hitOnRoomId;
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " data.hitOnRoomId=" << data.hitOnRoomId;
|
||||
state.id(m_buildingInfo.mseId);
|
||||
|
||||
int assetId = m_mainHandler->ddsHandler()->dtcIsm()->getAssetIdFromMountingPointId(m_buildingInfo.mseId, data.sensorId);
|
||||
DEBUG_LOG() << "handleHitResult assetId=" << assetId;
|
||||
DEBUG_LOG(m_logger) << "handleHitResult assetId=" << assetId;
|
||||
state.assetId(assetId);
|
||||
|
||||
InfrastructureManagement::StructureElement se;
|
||||
m_mainHandler->ddsHandler()->dtcIsm()->getStructureElementInMntPointAssetByAssetId(assetId, se);
|
||||
DEBUG_LOG() << "handleHitResult structureElementId=" << se.id();
|
||||
DEBUG_LOG(m_logger) << "handleHitResult structureElementId=" << se.id();
|
||||
state.structureElementId(se.id());
|
||||
state.sampleTime(QDateTime::currentMSecsSinceEpoch());
|
||||
if (data.originatorType == BuildingControlUnit::OriginatorType::DirectHit)
|
||||
@@ -808,7 +808,7 @@ void BuildingProcess::handleReconnectEgcu(const QString &segment)
|
||||
|
||||
|
||||
|
||||
DEBUG_LOG() << "handleReconnectEgcu segment =" << segment;
|
||||
DEBUG_LOG(m_logger) << "handleReconnectEgcu segment =" << segment;
|
||||
|
||||
for (const EgcuInfo &egcu : std::as_const(m_buildingInfo.egcus))
|
||||
{
|
||||
@@ -817,7 +817,7 @@ void BuildingProcess::handleReconnectEgcu(const QString &segment)
|
||||
const auto keys = m_effectOverridesReconnect.keys();
|
||||
for (const int &relayId : keys)
|
||||
{
|
||||
DEBUG_LOG() << "RelayId=" << relayId
|
||||
DEBUG_LOG(m_logger) << "RelayId=" << relayId
|
||||
<< " Override=" << m_effectOverridesReconnect.value(relayId);
|
||||
|
||||
if (m_effectOverridesReconnect.value(relayId) >= 0)
|
||||
@@ -827,7 +827,7 @@ void BuildingProcess::handleReconnectEgcu(const QString &segment)
|
||||
|
||||
int structureElementIdMp = m_mainHandler->ddsHandler()->dtcIsm()->getStructueElementIdFromAssetId(egcu.assetId);
|
||||
|
||||
DEBUG_LOG() << "EGCU: " << egcu.assetName
|
||||
DEBUG_LOG(m_logger) << "EGCU: " << egcu.assetName
|
||||
<< " assetId=" << egcu.assetId
|
||||
<< " hostname='" << egcu.hostname
|
||||
<< "' buildingName=" << egcu.buildingName
|
||||
@@ -840,9 +840,9 @@ void BuildingProcess::handleReconnectEgcu(const QString &segment)
|
||||
request.structureElementId(structureElementIdMp);
|
||||
request.effectId(relayId);
|
||||
request.effectOverride(override);
|
||||
DEBUG_LOG() << "Vor structureElementUpdateEffectOverrideRequest";
|
||||
DEBUG_LOG(m_logger) << "Vor structureElementUpdateEffectOverrideRequest";
|
||||
int result = m_mainHandler->ismHandler()->ftcIsm()->structureElementUpdateEffectOverrideRequest(request, this);
|
||||
DEBUG_LOG() << "Nach structureElementUpdateEffectOverrideRequest result=" << result;
|
||||
DEBUG_LOG(m_logger) << "Nach structureElementUpdateEffectOverrideRequest result=" << result;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -855,7 +855,7 @@ void BuildingProcess::handleRelayState(BuildingControlUnit::Json::Telegrams::Rel
|
||||
{
|
||||
RelayState state;
|
||||
|
||||
DEBUG_LOG() << "handleRelayState EGCU:" << tel->segment
|
||||
DEBUG_LOG(m_logger) << "handleRelayState EGCU:" << tel->segment
|
||||
<< " m_buildingInfo.egcus.size()=" << m_buildingInfo.egcus.size()
|
||||
<< " stateTime=" << tel->stateTime
|
||||
<< " offlineTime=" << tel->offlineTime;
|
||||
@@ -871,7 +871,7 @@ void BuildingProcess::handleRelayState(BuildingControlUnit::Json::Telegrams::Rel
|
||||
{
|
||||
if (QString::compare(egcu.hostname,tel->segment, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
DEBUG_LOG() << "EGCU: " << egcu.assetName
|
||||
DEBUG_LOG(m_logger) << "EGCU: " << egcu.assetName
|
||||
<< " assetId=" << egcu.assetId
|
||||
<< " hostname='" << egcu.hostname
|
||||
<< "' buildingName=" << egcu.buildingName;
|
||||
@@ -897,18 +897,18 @@ void BuildingProcess::handleRelayState(BuildingControlUnit::Json::Telegrams::Rel
|
||||
|
||||
void BuildingProcess::handleEffectOverride(BuildingControlUnit::Json::Telegrams::EffectOverride *tel)
|
||||
{
|
||||
DEBUG_LOG() << "BuildingProcess::handleEffectOverride"
|
||||
DEBUG_LOG(m_logger) << "BuildingProcess::handleEffectOverride"
|
||||
<< " tel->overrides.size=" << tel->overrides.size();
|
||||
|
||||
InfrastructureManagement::StructureElementUpdateEffectOverrideRequest request;
|
||||
for ( int i = 0; i < m_buildingInfo.egcus.size(); i++)
|
||||
{
|
||||
DEBUG_LOG() << "BuildingProcess::handleEffectOverride i=" << i;
|
||||
DEBUG_LOG(m_logger) << "BuildingProcess::handleEffectOverride i=" << i;
|
||||
if ( m_buildingInfo.egcus[i].hostname.toLower() == tel->segment)
|
||||
{
|
||||
int structureElementIdMp = m_mainHandler->ddsHandler()->dtcIsm()->getStructueElementIdFromAssetId( m_buildingInfo.egcus.at(i).assetId);
|
||||
|
||||
DEBUG_LOG() << "BuildingProcess::handleEffectOverride i=" << i
|
||||
DEBUG_LOG(m_logger) << "BuildingProcess::handleEffectOverride i=" << i
|
||||
<< " mountPointId=" << m_buildingInfo.egcus.at(i).mountPointId
|
||||
<< " assetId=" << m_buildingInfo.egcus.at(i).assetId
|
||||
<< " structureElementId=" << m_buildingInfo.structureElementId
|
||||
@@ -938,14 +938,14 @@ void BuildingProcess::handleEffectOverride(BuildingControlUnit::Json::Telegrams:
|
||||
break;
|
||||
}
|
||||
}
|
||||
DEBUG_LOG() << "Send Override Request"
|
||||
DEBUG_LOG(m_logger) << "Send Override Request"
|
||||
<< " structureElementId=" << request.structureElementId()
|
||||
<< " effectId=" << request.effectId()
|
||||
<< " effectOverride=" << request.effectOverride();
|
||||
if ( request.structureElementId() > 0)
|
||||
m_mainHandler->ddsHandler()->ftcIsm()->structureElementUpdateEffectOverrideRequest(request, this);
|
||||
else
|
||||
ERROR_LOG() << "request.structureElementId() =" << request.structureElementId() << " NOT VALID!!!";
|
||||
ERROR_LOG(m_logger) << "request.structureElementId() =" << request.structureElementId() << " NOT VALID!!!";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1016,12 +1016,12 @@ bool BuildingProcess::writeFile(const QString &fn, const QByteArray &data)
|
||||
QFile f(fn);
|
||||
if (!f.open(QIODevice::WriteOnly | QIODevice::Truncate))
|
||||
{
|
||||
WARNING_LOG() << "Can not open file '" << fn << "' - error: " << f.errorString();
|
||||
WARNING_LOG(m_logger) << "Can not open file '" << fn << "' - error: " << f.errorString();
|
||||
return false;
|
||||
}
|
||||
if (f.write(data) != data.size())
|
||||
{
|
||||
WARNING_LOG() << "Can not write data to file '" << fn << "' - error: " << f.errorString();
|
||||
WARNING_LOG(m_logger) << "Can not write data to file '" << fn << "' - error: " << f.errorString();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -1112,7 +1112,7 @@ QByteArray BuildingProcess::generateChargesData() const
|
||||
auto it = chargeTypes.find(charge.chargeTypeId());
|
||||
if (it == chargeTypes.end())
|
||||
{
|
||||
WARNING_LOG() << "Could not find charge type with id " << charge.chargeTypeId() << " - skipping";
|
||||
WARNING_LOG(m_logger) << "Could not find charge type with id " << charge.chargeTypeId() << " - skipping";
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1154,7 +1154,7 @@ void BuildingProcess::openWebSocket()
|
||||
this, &BuildingProcess::onWebSocketDisconnected);
|
||||
connect(m_wsSocket, &QWebSocket::textMessageReceived,
|
||||
this, &BuildingProcess::onTextMessageReceived);
|
||||
WARNING_LOG() << "openWebSocket:" << m_wsUrl.toLocal8Bit()
|
||||
WARNING_LOG(m_logger) << "openWebSocket:" << m_wsUrl.toLocal8Bit()
|
||||
<< " (buildingId: " << m_buildingInfo.mseId << ") - socket: " << m_wsSocket;
|
||||
m_wsSocket->open(QUrl::fromEncoded(m_wsUrl.toLocal8Bit()));
|
||||
}
|
||||
@@ -1163,7 +1163,7 @@ void BuildingProcess::closeWebSocket()
|
||||
{
|
||||
if (m_wsSocket)
|
||||
{
|
||||
WARNING_LOG() << "closeWebSocket (buildingId : " << m_buildingInfo.mseId << ") - socket: " << m_wsSocket
|
||||
WARNING_LOG(m_logger) << "closeWebSocket (buildingId : " << m_buildingInfo.mseId << ") - socket: " << m_wsSocket
|
||||
<< " localPort=" << m_wsSocket->localPort() << ", error: " << ", " << m_wsSocket->errorString();
|
||||
m_wsSocket->disconnect(this);
|
||||
m_wsSocket->close();
|
||||
@@ -1177,7 +1177,7 @@ void BuildingProcess::onWebSocketError(QAbstractSocket::SocketError error)
|
||||
{
|
||||
if (!m_wsSocket)
|
||||
return;
|
||||
WARNING_LOG() << "Error connecting to " << m_wsSocket->peerAddress().toString() << ": " << error
|
||||
WARNING_LOG(m_logger) << "Error connecting to " << m_wsSocket->peerAddress().toString() << ": " << error
|
||||
<< " (buildingId: " << m_buildingInfo.mseId << ") - socket: " << m_wsSocket;
|
||||
closeWebSocket();
|
||||
m_wsReconnectTimer->start(1000);
|
||||
@@ -1185,22 +1185,22 @@ void BuildingProcess::onWebSocketError(QAbstractSocket::SocketError error)
|
||||
|
||||
void BuildingProcess::onWebSocketConnected()
|
||||
{
|
||||
INFO_LOG() << "connected to building control process " << m_buildingInfo.mseId << " via websockets localPort="<<m_wsSocket->localPort();
|
||||
INFO_LOG(m_logger) << "connected to building control process " << m_buildingInfo.mseId << " via websockets localPort="<<m_wsSocket->localPort();
|
||||
|
||||
QMapIterator<int, QString> i(m_effectStates);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
|
||||
DEBUG_LOG() << "setEffectStates websocket send: " << i.value();
|
||||
DEBUG_LOG(m_logger) << "setEffectStates websocket send: " << i.value();
|
||||
qint64 sendBytesCount = m_wsSocket->sendTextMessage(i.value());
|
||||
DEBUG_LOG() << "sendBytesCount= " << sendBytesCount;
|
||||
DEBUG_LOG(m_logger) << "sendBytesCount= " << sendBytesCount;
|
||||
}
|
||||
m_wsReconnectTimer->stop();
|
||||
}
|
||||
|
||||
void BuildingProcess::onWebSocketDisconnected()
|
||||
{
|
||||
WARNING_LOG() << "Websocket to " << m_wsUrl << " closed - trying to reconnect in 1 sec"
|
||||
WARNING_LOG(m_logger) << "Websocket to " << m_wsUrl << " closed - trying to reconnect in 1 sec"
|
||||
<< " (buildingId : " << m_buildingInfo.mseId << ") - socket: " << m_wsSocket
|
||||
<< " localPort=" << m_wsSocket->localPort();
|
||||
closeWebSocket();
|
||||
|
||||
@@ -36,6 +36,7 @@ public:
|
||||
quint16 getWebsocketPort() {return QUrl::fromEncoded(m_wsUrl.toLocal8Bit()).port();}
|
||||
|
||||
protected:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void onStructureElementUpdateEffectOverrideReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Buildings
|
||||
DdsHandler::DdsHandler(int domainId, int exerciseId)
|
||||
: m_ddsConnector(std::make_shared<DDSConnector::DdsConnector>(domainId, IDL::PartitionType::Exercise, exerciseId))
|
||||
{
|
||||
DEBUG_LOG() << "DdsHandler(" << domainId << ") for partition: " << m_ddsConnector->getDefaultPartition();
|
||||
DEBUG_LOG(m_logger) << "DdsHandler(" << domainId << ") for partition: " << m_ddsConnector->getDefaultPartition();
|
||||
}
|
||||
|
||||
DdsHandler::~DdsHandler()
|
||||
@@ -27,7 +27,7 @@ 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;
|
||||
}
|
||||
|
||||
@@ -47,16 +47,16 @@ bool DdsHandler::init(const QStringList &qosFileList)
|
||||
|
||||
bool bRet = m_ddsDts->enableAll();
|
||||
|
||||
DEBUG_LOG() << "Dts initialised";
|
||||
DEBUG_LOG(m_logger) << "Dts initialised";
|
||||
|
||||
bRet &= m_ddsFts->enableAll();
|
||||
INFO_LOG() << "Fts initialised";
|
||||
INFO_LOG(m_logger) << "Fts initialised";
|
||||
|
||||
bRet &= m_ftcIsm->enableStructureElementUpdateEffectOverride();
|
||||
INFO_LOG() << "ISM Ftc initialised";
|
||||
INFO_LOG(m_logger) << "ISM Ftc initialised";
|
||||
|
||||
bRet &= m_dtcPdm->enableChargeType();
|
||||
INFO_LOG() << "ISM Ftc initialised";
|
||||
INFO_LOG(m_logger) << "ISM Ftc initialised";
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ public:
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> dtcPdm() const { return m_dtcPdm; }
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
|
||||
std::shared_ptr<Core::Pacemaker> m_pacemaker;
|
||||
std::shared_ptr<Buildings::Interface::Dts> m_ddsDts;
|
||||
|
||||
@@ -16,13 +16,12 @@
|
||||
namespace Buildings
|
||||
{
|
||||
|
||||
IsmHandler::IsmHandler(MainHandler *mainHandler)
|
||||
: m_mainHandler(mainHandler)
|
||||
IsmHandler::IsmHandler(MainHandler *mainHandler) : m_mainHandler(mainHandler)
|
||||
, m_dtcIsm(nullptr)
|
||||
, m_ftcIsm(nullptr)
|
||||
, m_changeTimeoutTimer(new QTimer(this))
|
||||
, m_changeTimeoutTimerInit(new QTimer(this))
|
||||
{
|
||||
, m_changeTimeoutTimerInit(new QTimer(this)),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
connect(m_changeTimeoutTimer, &QTimer::timeout,
|
||||
this, &IsmHandler::onBuildingsChanged);
|
||||
m_changeTimeoutTimer->setInterval(3 * 1000);
|
||||
@@ -57,13 +56,13 @@ bool IsmHandler::init()
|
||||
!m_dtcIsm->enableMountingPointAsset() ||
|
||||
!m_dtcIsm->enableBridgeChangeStatus())
|
||||
{
|
||||
ERROR_LOG() << "Can not read data from ISM";
|
||||
ERROR_LOG(m_logger) << "Can not read data from ISM";
|
||||
return false;
|
||||
}
|
||||
m_ftcIsm = InfrastructureManagement::Interface::Ftc::create(m_mainHandler->ddsHandler()->ddsConnector());
|
||||
if (!m_ftcIsm->enableStructureElementUpdateEffectOverride())
|
||||
{
|
||||
ERROR_LOG() << "Can not read data from ISM";
|
||||
ERROR_LOG(m_logger) << "Can not read data from ISM";
|
||||
return false;
|
||||
}
|
||||
m_changeTimeoutTimerInit->start();
|
||||
@@ -105,14 +104,14 @@ void IsmHandler::onInstrumentationAssetChanged(const InfrastructureManagement::I
|
||||
case DataModification::eModified:
|
||||
{
|
||||
const int exerciseId = data.availableInExercise().size() == 0 ? 0 : data.availableInExercise().at(0);
|
||||
DEBUG_LOG() << "setting asset " << data.id() << " available in exercise " << exerciseId;
|
||||
DEBUG_LOG(m_logger) << "setting asset " << data.id() << " available in exercise " << exerciseId;
|
||||
m_assetMainStructureElementInExercise.insert(data.id(), exerciseId);
|
||||
break;
|
||||
}
|
||||
case DataModification::eRemoved:
|
||||
{
|
||||
const int exerciseId = data.availableInExercise().size() == 0 ? 0 : data.availableInExercise().at(0);
|
||||
DEBUG_LOG() << "removing asset " << data.id() << " from exercise " << exerciseId;
|
||||
DEBUG_LOG(m_logger) << "removing asset " << data.id() << " from exercise " << exerciseId;
|
||||
m_assetMainStructureElementInExercise.remove(data.id());
|
||||
break;
|
||||
}
|
||||
@@ -127,11 +126,11 @@ void IsmHandler::onMountingPointAssetChanged(const InfrastructureManagement::Mou
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
case DataModification::eModified:
|
||||
DEBUG_LOG() << "mounting asset " << data.assetId() << " on structure element id " << data.structureElementId();
|
||||
DEBUG_LOG(m_logger) << "mounting asset " << data.assetId() << " on structure element id " << data.structureElementId();
|
||||
m_structureElementId2AssetId.insert(data.structureElementId(), data.assetId());
|
||||
break;
|
||||
case DataModification::eRemoved:
|
||||
DEBUG_LOG() << "unmounting asset " << m_structureElementId2AssetId.value(data.structureElementId()) << " from structure element " << data.structureElementId();
|
||||
DEBUG_LOG(m_logger) << "unmounting asset " << m_structureElementId2AssetId.value(data.structureElementId()) << " from structure element " << data.structureElementId();
|
||||
m_structureElementId2AssetId.remove(data.structureElementId());
|
||||
break;
|
||||
}
|
||||
@@ -140,7 +139,7 @@ void IsmHandler::onMountingPointAssetChanged(const InfrastructureManagement::Mou
|
||||
|
||||
void IsmHandler::onMainStructureElementChanged(const InfrastructureManagement::MainStructureElement &data, DataModification modType)
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO;
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO;
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
@@ -149,10 +148,10 @@ void IsmHandler::onMainStructureElementChanged(const InfrastructureManagement::M
|
||||
if (!isElementAssignedToExercise (data.id(),m_mainHandler->exerciseId() ) )
|
||||
{
|
||||
m_mainStructureElements.remove(data.id());
|
||||
DEBUG_LOG() << "Building not in exercise id=" << data.id();
|
||||
DEBUG_LOG(m_logger) << "Building not in exercise id=" << data.id();
|
||||
return;
|
||||
}
|
||||
DEBUG_LOG() << "Building=" << data.name()
|
||||
DEBUG_LOG(m_logger) << "Building=" << data.name()
|
||||
<< " properties=" << data.properties();
|
||||
QJsonParseError parserError;
|
||||
QByteArray content = QByteArray::fromStdString(data.properties());
|
||||
@@ -160,24 +159,24 @@ void IsmHandler::onMainStructureElementChanged(const InfrastructureManagement::M
|
||||
const QJsonDocument doc(QJsonDocument::fromJson(content, &parserError));
|
||||
if (parserError.error != QJsonParseError::NoError)
|
||||
{
|
||||
WARNING_LOG() << "Error parsing json document: " << parserError.errorString();
|
||||
WARNING_LOG(m_logger) << "Error parsing json document: " << parserError.errorString();
|
||||
return;
|
||||
}
|
||||
DEBUG_LOG() << "json to parse: " << doc.toJson();
|
||||
DEBUG_LOG(m_logger) << "json to parse: " << doc.toJson();
|
||||
const QJsonObject objProperties(doc.object());
|
||||
if ( objProperties.contains(QStringLiteral("start_building_process")))
|
||||
{
|
||||
DEBUG_LOG() << "properties contains start_building_process";
|
||||
DEBUG_LOG(m_logger) << "properties contains start_building_process";
|
||||
bool startBuildingProcess = objProperties.value(QStringLiteral("start_building_process")).toBool();
|
||||
if (!startBuildingProcess)
|
||||
{
|
||||
DEBUG_LOG() << "Building=" << data.name()
|
||||
DEBUG_LOG(m_logger) << "Building=" << data.name()
|
||||
<< " start_building_process = false ";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_LOG() << "##### onMainStructureElementChanged - ID = " << data.id();
|
||||
DEBUG_LOG(m_logger) << "##### onMainStructureElementChanged - ID = " << data.id();
|
||||
checkOverride( m_mainStructureElements[data.id()], data);
|
||||
m_mainStructureElements[data.id()] = data;
|
||||
break;
|
||||
@@ -192,13 +191,13 @@ void IsmHandler::onMainStructureElementChanged(const InfrastructureManagement::M
|
||||
void IsmHandler::onBridgeStatusChanged(const InfrastructureManagement::BridgeChangeStatus &data, DataModification modType)
|
||||
{
|
||||
static int s_id = 1;
|
||||
DEBUG_LOG() << Q_FUNC_INFO << "s_id=" << s_id;
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << "s_id=" << s_id;
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
case DataModification::eModified:
|
||||
{
|
||||
DEBUG_LOG() << "##### onBridgeStatusChanged - buildingId = " << data.buildingId();
|
||||
DEBUG_LOG(m_logger) << "##### onBridgeStatusChanged - buildingId = " << data.buildingId();
|
||||
BridgeStatus bs;
|
||||
bs.id(s_id++);
|
||||
bs.buildingId(data.buildingId());
|
||||
@@ -215,17 +214,17 @@ void IsmHandler::onBridgeStatusChanged(const InfrastructureManagement::BridgeCha
|
||||
|
||||
void IsmHandler::getEgcuToRoom(const InfrastructureManagement::MainStructureElement &mse, QVector<EgcuInfo> &eis)
|
||||
{
|
||||
INFO_LOG() << "properties=" << mse.properties();
|
||||
INFO_LOG(m_logger) << "properties=" << mse.properties();
|
||||
QJsonParseError parserError;
|
||||
QByteArray content = QByteArray::fromStdString(mse.properties());
|
||||
|
||||
const QJsonDocument doc(QJsonDocument::fromJson(content, &parserError));
|
||||
if (parserError.error != QJsonParseError::NoError)
|
||||
{
|
||||
WARNING_LOG() << "Error parsing json document: " << parserError.errorString();
|
||||
WARNING_LOG(m_logger) << "Error parsing json document: " << parserError.errorString();
|
||||
return;
|
||||
}
|
||||
DEBUG_LOG() << "json to parse: " << doc.toJson();
|
||||
DEBUG_LOG(m_logger) << "json to parse: " << doc.toJson();
|
||||
const QJsonObject objEgcus(doc.object());
|
||||
const QJsonArray arrEgcus(objEgcus.value(QStringLiteral("egcusToRooms")).toArray());
|
||||
for (int i = 0; i < arrEgcus.size(); ++i)
|
||||
@@ -233,19 +232,19 @@ void IsmHandler::getEgcuToRoom(const InfrastructureManagement::MainStructureElem
|
||||
|
||||
const QJsonObject objRooms(arrEgcus.at(i).toObject());
|
||||
const int mountpointEgcuId = objRooms[QStringLiteral("mountpointEgcu")].toInt();
|
||||
INFO_LOG() << "mountpointEgcu=" << mountpointEgcuId;
|
||||
INFO_LOG() << "i=" <<i;
|
||||
INFO_LOG(m_logger) << "mountpointEgcu=" << mountpointEgcuId;
|
||||
INFO_LOG(m_logger) << "i=" <<i;
|
||||
const QJsonArray arrRooms(objRooms.value(QStringLiteral("rooms")).toArray());
|
||||
INFO_LOG() << "bi.egcus.size()=" << eis.size();
|
||||
INFO_LOG(m_logger) << "bi.egcus.size()=" << eis.size();
|
||||
|
||||
|
||||
for (EgcuInfo &egcuInfo : eis)
|
||||
{
|
||||
DEBUG_LOG() << "bi.egcus.at(k).mountPointId=" << egcuInfo.mountPointId
|
||||
DEBUG_LOG(m_logger) << "bi.egcus.at(k).mountPointId=" << egcuInfo.mountPointId
|
||||
<< " mountpointEgcu=" << mountpointEgcuId;
|
||||
if (egcuInfo.mountPointId == mountpointEgcuId)
|
||||
{
|
||||
DEBUG_LOG() << "mountpointEgcu=" << mountpointEgcuId;
|
||||
DEBUG_LOG(m_logger) << "mountpointEgcu=" << mountpointEgcuId;
|
||||
|
||||
egcuInfo.roomIds.clear();
|
||||
egcuInfo.roomIds.reserve(arrRooms.size());
|
||||
@@ -273,10 +272,10 @@ void IsmHandler::buildingsChanged(bool init)
|
||||
QSet<int> availableBuildingIds;
|
||||
QMap<int, BuildingInfo> newBuildingConfiguration;
|
||||
availableBuildingIds.reserve(m_mainStructureElements.size());
|
||||
INFO_LOG() << "Updating building config m_mainStructureElements.size=" << m_mainStructureElements.size();
|
||||
INFO_LOG(m_logger) << "Updating building config m_mainStructureElements.size=" << m_mainStructureElements.size();
|
||||
for (const InfrastructureManagement::MainStructureElement &mse : std::as_const(m_mainStructureElements))
|
||||
{
|
||||
DEBUG_LOG() << "Checking building " << mse.id() << " - " << mse.name();
|
||||
DEBUG_LOG(m_logger) << "Checking building " << mse.id() << " - " << mse.name();
|
||||
BuildingInfo bi;
|
||||
bi.mseId = mse.id();
|
||||
bi.modelId = mse.modelId();
|
||||
@@ -300,7 +299,7 @@ void IsmHandler::buildingsChanged(bool init)
|
||||
bi.subId2RoomId.insert(se.mountingPointId(), se.id());
|
||||
bi.roomId2SubId.insert(se.id(), se.mountingPointId());
|
||||
bi.roomName2RoomId.insert(QString::fromStdString(se.name()), se.mountingPointId());
|
||||
INFO_LOG() << " Room: mountingPointId: " << se.mountingPointId()
|
||||
INFO_LOG(m_logger) << " Room: mountingPointId: " << se.mountingPointId()
|
||||
<< ", roomId: " << se.id()
|
||||
<< ", Name: " << se.name();
|
||||
m_roomId2RoomName.insert(se.id(), QString::fromStdString(se.name()));
|
||||
@@ -308,13 +307,13 @@ void IsmHandler::buildingsChanged(bool init)
|
||||
}
|
||||
if (m_mainHandler->exerciseId() != bi.currentExerciseId)
|
||||
{
|
||||
DEBUG_LOG() << "Exercise id of building does not match current exercise: " << bi.currentExerciseId
|
||||
DEBUG_LOG(m_logger) << "Exercise id of building does not match current exercise: " << bi.currentExerciseId
|
||||
<< " != " << m_mainHandler->exerciseId()
|
||||
<< " buildingId=" << bi.mseId
|
||||
<< " buildingName" << bi.name;
|
||||
continue;
|
||||
}
|
||||
INFO_LOG() << "Adding building configuration for " << mse.id() << " - " << mse.name();
|
||||
INFO_LOG(m_logger) << "Adding building configuration for " << mse.id() << " - " << mse.name();
|
||||
availableBuildingIds += mse.id();
|
||||
getEgcuToRoom(mse, bi.egcus);
|
||||
newBuildingConfiguration.insert(bi.mseId, bi);
|
||||
@@ -325,7 +324,7 @@ void IsmHandler::buildingsChanged(bool init)
|
||||
if (!availableBuildingIds.contains(buildingId))
|
||||
{
|
||||
|
||||
INFO_LOG() << "Building " << buildingId << " no longer exists in this exercise - removing";
|
||||
INFO_LOG(m_logger) << "Building " << buildingId << " no longer exists in this exercise - removing";
|
||||
emit buildingRemoved(buildingId);
|
||||
continue;
|
||||
}
|
||||
@@ -333,11 +332,11 @@ void IsmHandler::buildingsChanged(bool init)
|
||||
const BuildingInfo &biNew = newBuildingConfiguration.value(buildingId);
|
||||
if (biOld == biNew)
|
||||
{
|
||||
INFO_LOG() << "Building " << buildingId << " did not change - nothing to do";
|
||||
INFO_LOG(m_logger) << "Building " << buildingId << " did not change - nothing to do";
|
||||
}
|
||||
else
|
||||
{
|
||||
INFO_LOG() << "setHistoryState Building " << buildingId << " changed -> updating configuration"
|
||||
INFO_LOG(m_logger) << "setHistoryState Building " << buildingId << " changed -> updating configuration"
|
||||
<< " biNew mseId=" << biNew.mseId
|
||||
<< " init=" << init;
|
||||
bool initBuildingChanged = true;
|
||||
@@ -348,7 +347,7 @@ void IsmHandler::buildingsChanged(bool init)
|
||||
{
|
||||
if (m_currentBuildingConfiguration.contains(it.key()))
|
||||
continue;
|
||||
INFO_LOG() << "setHistoryState New building added key= " << it.key()
|
||||
INFO_LOG(m_logger) << "setHistoryState New building added key= " << it.key()
|
||||
<< " init=" << init;
|
||||
emit buildingChanged(it.value(), init);
|
||||
}
|
||||
@@ -372,7 +371,7 @@ void IsmHandler::handleBuildingSensorModule(const InfrastructureManagement::Stru
|
||||
bsi.port = getBsmPortFromJSon(ia.properties());
|
||||
bsi.relPosition = se.relPosition();
|
||||
bsi.orientation = se.orientation();
|
||||
DEBUG_LOG() << "adding bsm sensor module to building " << bi.mseId << ": " << bsi.assetId << ", " << bsi.bsmId << ", " << bsi.hostname;
|
||||
DEBUG_LOG(m_logger) << "adding bsm sensor module to building " << bi.mseId << ": " << bsi.assetId << ", " << bsi.bsmId << ", " << bsi.hostname;
|
||||
bi.bsms.insert(bsi.assetId, bsi);
|
||||
}
|
||||
|
||||
@@ -387,7 +386,7 @@ void IsmHandler::handleBuildingControlUnit(const InfrastructureManagement::Struc
|
||||
auto itMpa = m_structureElementId2AssetId.find(se.id());
|
||||
if (itMpa == m_structureElementId2AssetId.end())
|
||||
{
|
||||
INFO_LOG() << "structure element id " << se.id() << " not (yet)found"
|
||||
INFO_LOG(m_logger) << "structure element id " << se.id() << " not (yet)found"
|
||||
<< " bi.mseId=" << bi.mseId
|
||||
<< " bi.assetId=" << bi.assetId
|
||||
<< " bi.egcus.size=" << bi.egcus.size()
|
||||
@@ -398,31 +397,31 @@ void IsmHandler::handleBuildingControlUnit(const InfrastructureManagement::Struc
|
||||
const auto itAsset = m_assetMainStructureElementInExercise.find(assetId);
|
||||
if (itAsset == m_assetMainStructureElementInExercise.end())
|
||||
{
|
||||
ERROR_LOG() << "asset id " << assetId << " not found";
|
||||
ERROR_LOG(m_logger) << "asset id " << assetId << " not found";
|
||||
Q_ASSERT(false);
|
||||
return;
|
||||
}
|
||||
bi.currentExerciseId = itAsset.value();
|
||||
bi.assetId = itAsset.key();
|
||||
|
||||
DEBUG_LOG() << "adding bsm control unit (virtual) to building " << bi.mseId << ": " << bi.assetId << ", " << bi.currentExerciseId;
|
||||
DEBUG_LOG(m_logger) << "adding bsm control unit (virtual) to building " << bi.mseId << ": " << bi.assetId << ", " << bi.currentExerciseId;
|
||||
}
|
||||
|
||||
void IsmHandler::handleEffectGenerationControlUnit(const InfrastructureManagement::StructureElement &se, BuildingInfo &bi) const
|
||||
{
|
||||
DEBUG_LOG() << "BuildingId=" << bi.mseId
|
||||
DEBUG_LOG(m_logger) << "BuildingId=" << bi.mseId
|
||||
<< " se.id=" << se.id();
|
||||
auto itMpa = m_structureElementId2AssetId.find(se.id());
|
||||
if (itMpa == m_structureElementId2AssetId.end())
|
||||
{
|
||||
INFO_LOG() << "Return m_structureElementId2AssetId.size()=" << m_structureElementId2AssetId.size();
|
||||
INFO_LOG(m_logger) << "Return m_structureElementId2AssetId.size()=" << m_structureElementId2AssetId.size();
|
||||
return;
|
||||
}
|
||||
const int assetId = itMpa.value();
|
||||
const auto itAsset = m_instAssets.find(assetId);
|
||||
if (itAsset == m_instAssets.end())
|
||||
{
|
||||
INFO_LOG() << "Return m_instAssets.size()=" << m_instAssets.size();
|
||||
INFO_LOG(m_logger) << "Return m_instAssets.size()=" << m_instAssets.size();
|
||||
return;
|
||||
}
|
||||
const InfrastructureManagement::InstrumentationAsset &ia = itAsset.value();
|
||||
@@ -433,12 +432,12 @@ void IsmHandler::handleEffectGenerationControlUnit(const InfrastructureManagemen
|
||||
egcu.mountPointId = se.mountingPointId();
|
||||
egcu.hostname = QString::fromStdString(ia.hostname());
|
||||
egcu.assetId = assetId;
|
||||
DEBUG_LOG() << "Egcu.hostname=" << egcu.hostname;
|
||||
INFO_LOG() << "properties=" << ia.properties();
|
||||
DEBUG_LOG(m_logger) << "Egcu.hostname=" << egcu.hostname;
|
||||
INFO_LOG(m_logger) << "properties=" << ia.properties();
|
||||
|
||||
bi.egcus.push_back(egcu);
|
||||
|
||||
DEBUG_LOG() << "adding egcu to building " << bi.mseId << ": " << egcu.hostname
|
||||
DEBUG_LOG(m_logger) << "adding egcu to building " << bi.mseId << ": " << egcu.hostname
|
||||
<< " name=" << egcu.buildingName
|
||||
<< " mountPointName=" << egcu.mountPointName
|
||||
<< " mountPointId=" << egcu.mountPointId
|
||||
@@ -470,37 +469,37 @@ void IsmHandler::checkOverride(const InfrastructureManagement::MainStructureElem
|
||||
const InfrastructureManagement::MainStructureElement &mseNew)
|
||||
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO;
|
||||
DEBUG_LOG() << "mseOld.elements().size()=" << mseOld.elements().size()
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO;
|
||||
DEBUG_LOG(m_logger) << "mseOld.elements().size()=" << mseOld.elements().size()
|
||||
<< " mseNew.elements().size()=" << mseNew.elements().size();
|
||||
|
||||
|
||||
for (const InfrastructureManagement::StructureElement &se : mseNew.elements())
|
||||
{
|
||||
DEBUG_LOG() << "se=" << se.id()
|
||||
DEBUG_LOG(m_logger) << "se=" << se.id()
|
||||
<< " name=" << se.name()
|
||||
<< " displayName=" << se.displayName()
|
||||
<< " properties=" << se.properties();
|
||||
|
||||
for (const InfrastructureManagement::StructureElement &seOld : mseOld.elements())
|
||||
{
|
||||
DEBUG_LOG() << "seOld.id=" << seOld.id()
|
||||
DEBUG_LOG(m_logger) << "seOld.id=" << seOld.id()
|
||||
<< " se.id=" << se.id();
|
||||
if ( seOld.id() == se.id())
|
||||
{
|
||||
DEBUG_LOG() << "Properties =" << se.properties()
|
||||
DEBUG_LOG(m_logger) << "Properties =" << se.properties()
|
||||
<< " se.id=" << se.id()
|
||||
<< " se.name=" << se.name()
|
||||
<< " mountingPointId=" << se.mountingPointId();
|
||||
DEBUG_LOG() << "se.properties()=" << se.properties()
|
||||
DEBUG_LOG(m_logger) << "se.properties()=" << se.properties()
|
||||
<< " seOld.properties()=" << seOld.properties();
|
||||
if (se.properties() != seOld.properties() )
|
||||
{
|
||||
DEBUG_LOG() << "HandleOverrides"
|
||||
DEBUG_LOG(m_logger) << "HandleOverrides"
|
||||
"<< m_currentBuildingConfiguration.size=" << m_currentBuildingConfiguration.size();
|
||||
if ( se.structureElementTypeId() == InfrastructureManagement::StructureElementType::Building)
|
||||
{
|
||||
DEBUG_LOG() << "BSM-Flash, no EGCU";
|
||||
DEBUG_LOG(m_logger) << "BSM-Flash, no EGCU";
|
||||
QByteArray properties = QByteArray::fromStdString(se.properties());
|
||||
emit setEffectStates(mseNew.id(), 0, properties );
|
||||
continue;
|
||||
@@ -508,13 +507,13 @@ void IsmHandler::checkOverride(const InfrastructureManagement::MainStructureElem
|
||||
for (auto it = m_currentBuildingConfiguration.begin(); it != m_currentBuildingConfiguration.end(); ++it)
|
||||
{
|
||||
BuildingInfo &bi = it.value();
|
||||
DEBUG_LOG() << "key=" << it.key()
|
||||
DEBUG_LOG(m_logger) << "key=" << it.key()
|
||||
<< " id=" << bi.mseId
|
||||
<< " assetId=" << bi.assetId
|
||||
<< " egcus.size=" << bi.egcus.size();
|
||||
for (const auto &egcu : std::as_const(bi.egcus))
|
||||
{
|
||||
DEBUG_LOG() << "AssetId=" << egcu.assetId
|
||||
DEBUG_LOG(m_logger) << "AssetId=" << egcu.assetId
|
||||
<< " assetName=" << egcu.assetName
|
||||
<< " hostname=" << egcu.hostname
|
||||
<< " egcu.mountPointId=" << egcu.mountPointId
|
||||
@@ -522,7 +521,7 @@ void IsmHandler::checkOverride(const InfrastructureManagement::MainStructureElem
|
||||
if (egcu.mountPointId == se.mountingPointId())
|
||||
{
|
||||
QByteArray properties = QByteArray::fromStdString(se.properties());
|
||||
DEBUG_LOG() << "Send Json SetEffectStates to BuildingProcess"
|
||||
DEBUG_LOG(m_logger) << "Send Json SetEffectStates to BuildingProcess"
|
||||
<< " buildingId="
|
||||
<< " assetId="<< egcu.assetId
|
||||
<< " properties =" << properties;
|
||||
@@ -535,7 +534,7 @@ void IsmHandler::checkOverride(const InfrastructureManagement::MainStructureElem
|
||||
}
|
||||
else
|
||||
{
|
||||
TRACE_LOG() << "No changes do not HandleOverrides";
|
||||
TRACE_LOG(m_logger) << "No changes do not HandleOverrides";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -549,7 +548,7 @@ void IsmHandler::checkOverride(const InfrastructureManagement::MainStructureElem
|
||||
|
||||
int assetId;
|
||||
bool foundAssetId = m_dtcIsm->getAssetIdFromMountingPoint(se.id(), se.mountingPointId(), assetId);
|
||||
DEBUG_LOG() << "Send Overrides to BuildingProcess (EGCU)"
|
||||
DEBUG_LOG(m_logger) << "Send Overrides to BuildingProcess (EGCU)"
|
||||
<< " foundAssetId=" << foundAssetId
|
||||
<< " structureElementId=" << mseNew.id()
|
||||
<< " se.id=" << se.id()
|
||||
|
||||
@@ -170,6 +170,7 @@ private Q_SLOTS:
|
||||
void onBuildingsChangedInit();
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void handleBuildingSensorModule(const InfrastructureManagement::StructureElement &se, BuildingInfo &bi) const;
|
||||
void handleBuildingControlUnit(const InfrastructureManagement::StructureElement &se, BuildingInfo &bi) const;
|
||||
void handleEffectGenerationControlUnit(const InfrastructureManagement::StructureElement &se, BuildingInfo &bi) const;
|
||||
|
||||
@@ -9,9 +9,8 @@
|
||||
|
||||
namespace Buildings
|
||||
{
|
||||
MainHandler::MainHandler(QObject *parent)
|
||||
: QObject(parent)
|
||||
{}
|
||||
MainHandler::MainHandler(QObject *parent) : QObject(parent),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {}
|
||||
|
||||
MainHandler::~MainHandler()
|
||||
{
|
||||
@@ -30,17 +29,17 @@ bool MainHandler::init(int domainId, int exerciseId)
|
||||
bool bRet = initInternal(domainId, exerciseId);
|
||||
|
||||
|
||||
DEBUG_LOG() << "WebSocketInterfaceHandler initialized Port=" << m_webSocketHandler->listenPort();
|
||||
DEBUG_LOG(m_logger) << "WebSocketInterfaceHandler initialized Port=" << m_webSocketHandler->listenPort();
|
||||
m_ddsHandler->pacemaker()->addPort(m_webSocketHandler->listenPort(), Core::PortType::WebSocketServer);
|
||||
|
||||
if (bRet)
|
||||
{
|
||||
DEBUG_LOG() << "svcBuildings successfully initialized";
|
||||
DEBUG_LOG(m_logger) << "svcBuildings successfully initialized";
|
||||
m_ddsHandler->pacemaker()->setNewState(Core::RunningState::Running);
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG() << "Error initializing svcBuildings...";
|
||||
ERROR_LOG(m_logger) << "Error initializing svcBuildings...";
|
||||
if (m_ddsHandler && m_ddsHandler->pacemaker())
|
||||
m_ddsHandler->pacemaker()->setNewState(Core::RunningState::StartingError);
|
||||
}
|
||||
@@ -49,16 +48,16 @@ bool MainHandler::init(int domainId, int exerciseId)
|
||||
|
||||
bool MainHandler::initInternal(int domainId, int exerciseId)
|
||||
{
|
||||
INFO_LOG() << "MainHandler::init domainId = " << domainId
|
||||
INFO_LOG(m_logger) << "MainHandler::init domainId = " << domainId
|
||||
<< " exerciseId = " << exerciseId;
|
||||
|
||||
m_dbHandler = std::make_shared<DbHandler>();
|
||||
if (!m_dbHandler->init(exerciseId, Settings::settings()))
|
||||
{
|
||||
ERROR_LOG() << "Could not init DbHandler";
|
||||
ERROR_LOG(m_logger) << "Could not init DbHandler";
|
||||
return false;
|
||||
}
|
||||
INFO_LOG() << "DbHandler initialized";
|
||||
INFO_LOG(m_logger) << "DbHandler initialized";
|
||||
|
||||
|
||||
m_ddsHandler = std::make_shared<DdsHandler>(domainId, exerciseId);
|
||||
|
||||
@@ -54,6 +54,7 @@ public:
|
||||
private slots:
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
bool initInternal(int domainId, int exerciseId);
|
||||
std::shared_ptr<BuildingControlHandler> m_bcHandler;
|
||||
std::shared_ptr<DdsHandler> m_ddsHandler;
|
||||
|
||||
@@ -7,10 +7,9 @@
|
||||
|
||||
namespace Buildings
|
||||
{
|
||||
PdmHandler::PdmHandler(MainHandler *mainHandler)
|
||||
: m_mainHandler(mainHandler)
|
||||
, m_bPdmInitialized(false)
|
||||
{}
|
||||
PdmHandler::PdmHandler(MainHandler *mainHandler) : m_mainHandler(mainHandler)
|
||||
, m_bPdmInitialized(false),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {}
|
||||
|
||||
PdmHandler::~PdmHandler()
|
||||
{}
|
||||
@@ -26,7 +25,7 @@ void PdmHandler::initializePdm()
|
||||
!dtcPdm->waitForHistoricalDataChargeType(20000) ||
|
||||
!dtcPdm->waitForHistoricalDataBuildingChargeEffect(20000))
|
||||
{
|
||||
ERROR_LOG() << "Can not read charge/gear types from PDM";
|
||||
ERROR_LOG(m_logger) << "Can not read charge/gear types from PDM";
|
||||
m_bPdmInitialized = false;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -18,8 +18,10 @@ public:
|
||||
QMap<int, ProjectDataManagement::BuildingChargeEffect> buildingChargeEffects();
|
||||
QMap<int, ProjectDataManagement::ChargeType> chargeTypes();
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void initializePdm();
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
QMap<int, ProjectDataManagement::ChargeType> m_chargeTypes;
|
||||
QMap<int, ProjectDataManagement::BuildingChargeEffect> m_buildingChargeEffects;
|
||||
MainHandler *m_mainHandler;
|
||||
|
||||
@@ -6,9 +6,8 @@
|
||||
|
||||
namespace Buildings
|
||||
{
|
||||
PpmHandler::PpmHandler(MainHandler *mainHandler)
|
||||
: m_mainHandler(mainHandler)
|
||||
{}
|
||||
PpmHandler::PpmHandler(MainHandler *mainHandler) : m_mainHandler(mainHandler),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {}
|
||||
|
||||
PpmHandler::~PpmHandler()
|
||||
{}
|
||||
@@ -22,12 +21,12 @@ bool PpmHandler::init()
|
||||
this, &PpmHandler::onParticipantPositionChanged);
|
||||
if (!m_ppmDtc->enableEquipmentExerciseMapping())
|
||||
{
|
||||
ERROR_LOG() << "Can not read equipment/exercise mappings from PPM";
|
||||
ERROR_LOG(m_logger) << "Can not read equipment/exercise mappings from PPM";
|
||||
return false;
|
||||
}
|
||||
if (!m_ppmDtc->enableParticipantPosition())
|
||||
{
|
||||
ERROR_LOG() << "Can not read ParticipantPositions from PPM";
|
||||
ERROR_LOG(m_logger) << "Can not read ParticipantPositions from PPM";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -37,7 +36,7 @@ int PpmHandler::equipmentNumberToParticipantId(int equipmentNumber) const
|
||||
{
|
||||
const int ret = m_equipmentNumber2ParticipantId.value(equipmentNumber, -1);
|
||||
if (ret < 0)
|
||||
WARNING_LOG() << "Can not map equipment number " << equipmentNumber << " to a valid participant id - using -1";
|
||||
WARNING_LOG(m_logger) << "Can not map equipment number " << equipmentNumber << " to a valid participant id - using -1";
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ private Q_SLOTS:
|
||||
void onEquipmentExerciseMappingChanged(const ParticipantManagement::EquipmentExerciseMapping &data, DataModification modType);
|
||||
void onParticipantPositionChanged(const ParticipantManagement::ParticipantPosition &data, DataModification modType);
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
QHash<int, int> m_equipmentNumber2ParticipantId;
|
||||
QHash<int, ParticipantManagement::ParticipantPosition> m_participantPositions;
|
||||
|
||||
@@ -23,10 +23,10 @@ bool RelayInfoHandler::init()
|
||||
void RelayInfoHandler::onSetRelayInfoRequest(const rti::core::SampleIdentity &cookie,
|
||||
const SetRelayInfoRequest &request)
|
||||
{
|
||||
DEBUG_LOG() << "onSetRelayInfoRequest " << request;
|
||||
DEBUG_LOG(m_logger) << "onSetRelayInfoRequest " << request;
|
||||
const Core::FunctionReplyObject fro = onSetRelayInfoRequestInternal(request);
|
||||
if (fro.error())
|
||||
WARNING_LOG() << fro();
|
||||
WARNING_LOG(m_logger) << fro();
|
||||
m_mainHandler->ddsHandler()->fts()->setRelayInfoReply(cookie, fro);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ public:
|
||||
|
||||
private Q_SLOTS:
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void onSetRelayInfoRequest(const rti::core::SampleIdentity &cookie,
|
||||
const SetRelayInfoRequest &request) override;
|
||||
Core::FunctionReplyObject onSetRelayInfoRequestInternal(const SetRelayInfoRequest &data);
|
||||
|
||||
@@ -33,10 +33,10 @@ WebSocketHandler::~WebSocketHandler()
|
||||
|
||||
bool WebSocketHandler::init(quint16 listenPort)
|
||||
{
|
||||
DEBUG_LOG() << "init";
|
||||
DEBUG_LOG(m_logger) << "init";
|
||||
if (!m_webSocketServer->listen(QHostAddress::Any, listenPort))
|
||||
{
|
||||
WARNING_LOG() << "Can not listen on port " << listenPort << " - aborting";
|
||||
WARNING_LOG(m_logger) << "Can not listen on port " << listenPort << " - aborting";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ bool WebSocketHandler::init(quint16 listenPort)
|
||||
this, &WebSocketHandler::onNewConnection);
|
||||
|
||||
|
||||
INFO_LOG() << "Listening on port " << m_webSocketServer->serverPort();
|
||||
INFO_LOG(m_logger) << "Listening on port " << m_webSocketServer->serverPort();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ bool WebSocketHandler::init(const QPair<quint16, quint16> &portRange)
|
||||
|
||||
bool WebSocketHandler::sendTelegramInternal() const
|
||||
{
|
||||
DEBUG_LOG() << "sendTelegramInternal";
|
||||
DEBUG_LOG(m_logger) << "sendTelegramInternal";
|
||||
QJsonObject obj;
|
||||
obj[QStringLiteral("participantId")] = 1;
|
||||
obj[QStringLiteral("equipmentNumber")] = 2;
|
||||
@@ -82,7 +82,7 @@ bool WebSocketHandler::sendTelegramInternal() const
|
||||
|
||||
bool WebSocketHandler::sendbuildingInfos() const
|
||||
{
|
||||
DEBUG_LOG() << "sendbuildingInfos";
|
||||
DEBUG_LOG(m_logger) << "sendbuildingInfos";
|
||||
QJsonObject obj;
|
||||
QJsonArray arr;
|
||||
|
||||
@@ -93,7 +93,7 @@ bool WebSocketHandler::sendbuildingInfos() const
|
||||
BuildingProcess* buildingProcess = i.value();
|
||||
BuildingInfo buildingInfo = buildingProcess->buildingInfo();
|
||||
quint16 port = buildingProcess->getWebsocketPort();
|
||||
DEBUG_LOG() << "key=" << i.key()
|
||||
DEBUG_LOG(m_logger) << "key=" << i.key()
|
||||
<< " port= " << port
|
||||
<< " buildingInfo.name=" << buildingInfo.name;
|
||||
QJsonObject objIter;
|
||||
@@ -119,8 +119,8 @@ bool WebSocketHandler::sendbuildingInfos() const
|
||||
|
||||
void WebSocketHandler::onNewMessage(const QString &message)
|
||||
{
|
||||
DEBUG_LOG() << "onNewMessage='" << message << "'";
|
||||
DEBUG_LOG() << "m_buildingControlHandler->m_buildings.size()=" << m_buildingControlHandler->getBuildings().size();
|
||||
DEBUG_LOG(m_logger) << "onNewMessage='" << message << "'";
|
||||
DEBUG_LOG(m_logger) << "m_buildingControlHandler->m_buildings.size()=" << m_buildingControlHandler->getBuildings().size();
|
||||
|
||||
if (message.indexOf(QStringLiteral("buildingRequest")) > 0)
|
||||
{
|
||||
@@ -128,7 +128,7 @@ void WebSocketHandler::onNewMessage(const QString &message)
|
||||
}
|
||||
if (message.indexOf(QStringLiteral("triggerFlashlight")) > 0)
|
||||
{
|
||||
DEBUG_LOG() << "triggerFlashlight" ;
|
||||
DEBUG_LOG(m_logger) << "triggerFlashlight" ;
|
||||
triggerFlashlight(message);
|
||||
}
|
||||
}
|
||||
@@ -148,12 +148,12 @@ QJsonObject WebSocketHandler::ObjectFromString(const QString& in)
|
||||
}
|
||||
else
|
||||
{
|
||||
WARNING_LOG() << "Document is not an object";
|
||||
WARNING_LOG(m_logger) << "Document is not an object";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WARNING_LOG() << "Invalid JSON...\n" << in ;
|
||||
WARNING_LOG(m_logger) << "Invalid JSON...\n" << in ;
|
||||
}
|
||||
|
||||
return obj;
|
||||
@@ -162,20 +162,20 @@ QJsonObject WebSocketHandler::ObjectFromString(const QString& in)
|
||||
|
||||
void WebSocketHandler::triggerFlashlight(const QString &message)
|
||||
{
|
||||
DEBUG_LOG() << "triggerFlashlight message=" << message;
|
||||
DEBUG_LOG(m_logger) << "triggerFlashlight message=" << message;
|
||||
QJsonObject obj = ObjectFromString(message);
|
||||
QJsonObject dataObj = obj.value(QStringLiteral("data")).toObject();
|
||||
int structureElementId = dataObj.value(QStringLiteral("structureElementId")).toInt();
|
||||
QString hostnameBsm = dataObj.value(QStringLiteral("hostnameBsm")).toString();
|
||||
|
||||
DEBUG_LOG() << "hostnameBsm=" << hostnameBsm
|
||||
DEBUG_LOG(m_logger) << "hostnameBsm=" << hostnameBsm
|
||||
<< " structureElementId=" << structureElementId;
|
||||
|
||||
}
|
||||
|
||||
void WebSocketHandler::onNewConnection()
|
||||
{
|
||||
DEBUG_LOG() << "onNewConnection";
|
||||
DEBUG_LOG(m_logger) << "onNewConnection";
|
||||
QWebSocket *ws = m_webSocketServer->nextPendingConnection();
|
||||
|
||||
if (!ws)
|
||||
@@ -188,12 +188,12 @@ void WebSocketHandler::onNewConnection()
|
||||
|
||||
m_webSockets += ws;
|
||||
|
||||
INFO_LOG() << "New websocket connected";
|
||||
INFO_LOG(m_logger) << "New websocket connected";
|
||||
}
|
||||
|
||||
void WebSocketHandler::onWebSocketDisconnected()
|
||||
{
|
||||
DEBUG_LOG() << "onWebSocketDisconnected";
|
||||
DEBUG_LOG(m_logger) << "onWebSocketDisconnected";
|
||||
QWebSocket *ws = qobject_cast<QWebSocket *>(sender());
|
||||
if (!ws)
|
||||
return;
|
||||
@@ -201,7 +201,7 @@ void WebSocketHandler::onWebSocketDisconnected()
|
||||
m_webSockets.removeAll(ws);
|
||||
ws->deleteLater();
|
||||
|
||||
INFO_LOG() << "A websocket disconnected";
|
||||
INFO_LOG(m_logger) << "A websocket disconnected";
|
||||
}
|
||||
|
||||
bool WebSocketHandler::sendPosition()
|
||||
|
||||
@@ -28,6 +28,7 @@ public:
|
||||
bool sendPosition();
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
bool sendTelegramInternal() const;
|
||||
bool sendbuildingInfos() const;
|
||||
QJsonObject ObjectFromString(const QString& in);
|
||||
@@ -39,6 +40,7 @@ private Q_SLOTS:
|
||||
void onWebSocketDisconnected();
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::shared_ptr<BuildingControlHandler> m_buildingControlHandler;
|
||||
QWebSocketServer* m_webSocketServer = nullptr;
|
||||
QVector<QWebSocket*> m_webSockets;
|
||||
|
||||
+7
-7
@@ -30,7 +30,7 @@ bool ClientConnection::init()
|
||||
{
|
||||
if (m_socket == nullptr)
|
||||
{
|
||||
ERROR_LOG() << "Initialisation failed due to an invalid socket";
|
||||
ERROR_LOG(m_logger) << "Initialisation failed due to an invalid socket";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -51,17 +51,17 @@ void ClientConnection::addMessage(const CombatNetRadio::WebSocketInterface::Mess
|
||||
if (!m_socket || m_socket->state() != QAbstractSocket::ConnectedState)
|
||||
{
|
||||
m_messageQueue.enqueue(message);
|
||||
DEBUG_LOG() << "Adding message to queue, size: " << m_messageQueue.size();
|
||||
DEBUG_LOG(m_logger) << "Adding message to queue, size: " << m_messageQueue.size();
|
||||
return;
|
||||
}
|
||||
const QString msg(message.toJsonString());
|
||||
DEBUG_LOG() << "Send msg: " << msg;
|
||||
DEBUG_LOG(m_logger) << "Send msg: " << msg;
|
||||
m_socket->sendTextMessage(msg);
|
||||
}
|
||||
|
||||
void ClientConnection::onNewTextMessageFromSocket(const QString &message)
|
||||
{
|
||||
DEBUG_LOG() << "Recv msg: " << message;
|
||||
DEBUG_LOG(m_logger) << "Recv msg: " << message;
|
||||
emit newTextMessage(this, message);
|
||||
}
|
||||
|
||||
@@ -73,15 +73,15 @@ void ClientConnection::sendMessagesFromQueue()
|
||||
{
|
||||
Messages::ReplyMessage message = m_messageQueue.dequeue();
|
||||
const QString msg(message.toJsonString());
|
||||
TRACE_LOG() << "Send msg: " << msg;
|
||||
TRACE_LOG(m_logger) << "Send msg: " << msg;
|
||||
m_socket->sendTextMessage(msg);
|
||||
DEBUG_LOG() << "Sent message from queue, new size: " << m_messageQueue.size();
|
||||
DEBUG_LOG(m_logger) << "Sent message from queue, new size: " << m_messageQueue.size();
|
||||
}
|
||||
}
|
||||
|
||||
void ClientConnection::onSocketDisconnect()
|
||||
{
|
||||
DEBUG_LOG() << "Client with ip "
|
||||
DEBUG_LOG(m_logger) << "Client with ip "
|
||||
<< m_ip.toString()
|
||||
<< " disconnected";
|
||||
emit disconnected(this);
|
||||
|
||||
+2
@@ -40,9 +40,11 @@ private Q_SLOTS:
|
||||
void onSocketDisconnect();
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void sendMessages();
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
QWebSocket *m_socket;
|
||||
QQueue<Messages::ReplyMessage> m_messageQueue;
|
||||
QHostAddress m_ip;
|
||||
|
||||
+8
-9
@@ -10,9 +10,8 @@
|
||||
|
||||
using namespace CombatNetRadio::WebSocketInterface::Connection;
|
||||
|
||||
ConnectionHandler::ConnectionHandler()
|
||||
: m_server(nullptr)
|
||||
{
|
||||
ConnectionHandler::ConnectionHandler() : m_server(nullptr),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
}
|
||||
|
||||
ConnectionHandler::~ConnectionHandler()
|
||||
@@ -38,13 +37,13 @@ bool ConnectionHandler::init()
|
||||
|
||||
|
||||
quint16 port = 2081;
|
||||
DEBUG_LOG() << "Trying to listen to port " << port;
|
||||
DEBUG_LOG(m_logger) << "Trying to listen to port " << port;
|
||||
if (!m_server->listen(QHostAddress::Any, port))
|
||||
{
|
||||
ERROR_LOG() << "Not possible to listen to port " << port;
|
||||
ERROR_LOG(m_logger) << "Not possible to listen to port " << port;
|
||||
return false;
|
||||
}
|
||||
DEBUG_LOG() << "... ok";
|
||||
DEBUG_LOG(m_logger) << "... ok";
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -63,7 +62,7 @@ void ConnectionHandler::onNewMessage(CombatNetRadio::WebSocketInterface::Message
|
||||
|
||||
void ConnectionHandler::onServerError(QWebSocketProtocol::CloseCode closeCode)
|
||||
{
|
||||
ERROR_LOG() << "Got server error with close code " << closeCode;
|
||||
ERROR_LOG(m_logger) << "Got server error with close code " << closeCode;
|
||||
}
|
||||
|
||||
void ConnectionHandler::onNewConnection()
|
||||
@@ -75,7 +74,7 @@ void ConnectionHandler::onNewConnection()
|
||||
|
||||
if (!newConnection->init())
|
||||
{
|
||||
ERROR_LOG() << "Failed to initialise new client";
|
||||
ERROR_LOG(m_logger) << "Failed to initialise new client";
|
||||
delete newConnection;
|
||||
newConnection = nullptr;
|
||||
continue;
|
||||
@@ -85,7 +84,7 @@ void ConnectionHandler::onNewConnection()
|
||||
connect(newConnection, &ClientConnection::disconnected, this, &ConnectionHandler::onDisconnected);
|
||||
|
||||
m_connections.append(newConnection);
|
||||
DEBUG_LOG() << "New client with ip " << newConnection->ip().toString() << " connected";
|
||||
DEBUG_LOG(m_logger) << "New client with ip " << newConnection->ip().toString() << " connected";
|
||||
emit newClientConnection((qint64) static_cast<WebSocketInterface::Connection::ClientConnection::MessageTransmitter*>(newConnection));
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -50,6 +50,7 @@ private Q_SLOTS:
|
||||
void onDisconnected(ClientConnection *conn);
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
QWebSocketServer *m_server;
|
||||
QVector<ClientConnection *> m_connections;
|
||||
};
|
||||
|
||||
+2
-3
@@ -12,9 +12,8 @@ namespace WebSocketInterface
|
||||
namespace Messages
|
||||
{
|
||||
|
||||
MessageHandler::MessageHandler(ExerciseManager *exerciseManager)
|
||||
: m_exerciseManager(exerciseManager)
|
||||
{
|
||||
MessageHandler::MessageHandler(ExerciseManager *exerciseManager) : m_exerciseManager(exerciseManager),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
Q_ASSERT(exerciseManager);
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -28,6 +28,8 @@ public Q_SLOTS:
|
||||
void onNewTextMessage(MessageTransmitter *transmitter, const QString &message);
|
||||
|
||||
private:
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
ExerciseManager *m_exerciseManager;
|
||||
};
|
||||
}
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ bool WebSocketInterfaceHandler::init()
|
||||
|
||||
if (!m_connectionHandler->init())
|
||||
{
|
||||
ERROR_LOG() << "Failed to initialise ConnectionHandler";
|
||||
ERROR_LOG(m_logger) << "Failed to initialise ConnectionHandler";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,12 +16,11 @@
|
||||
namespace CombatNetRadio
|
||||
{
|
||||
|
||||
ConfigCnr::ConfigCnr(int exerciseId, AudioVideoManagement::Interface::Dtc *avmDtc, InfrastructureManagement::Interface::Dtc *ismDtc)
|
||||
: m_exerciseId(exerciseId)
|
||||
ConfigCnr::ConfigCnr(int exerciseId, AudioVideoManagement::Interface::Dtc *avmDtc, InfrastructureManagement::Interface::Dtc *ismDtc) : m_exerciseId(exerciseId)
|
||||
, m_avmDtc(avmDtc)
|
||||
, m_ismDtc(ismDtc)
|
||||
, m_loggerJson(getLogger("ConfigCnr.Json"))
|
||||
{
|
||||
, m_loggerJson(getLogger("ConfigCnr.Json")),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
Q_ASSERT(avmDtc);
|
||||
Q_ASSERT(ismDtc);
|
||||
|
||||
@@ -199,7 +198,7 @@ boost::optional<AudioVideoManagement::FrequencyPlanning> ConfigCnr::activePlan()
|
||||
|
||||
void ConfigCnr::onActiveFrequencyPlanningChanged(const AudioVideoManagement::ActiveFrequencyPlanning &data, DataModification modType)
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO << ": " << data;
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << ": " << data;
|
||||
|
||||
Q_UNUSED(modType);
|
||||
if (data.exerciseId() == m_exerciseId)
|
||||
@@ -208,7 +207,7 @@ void ConfigCnr::onActiveFrequencyPlanningChanged(const AudioVideoManagement::Act
|
||||
|
||||
void ConfigCnr::onFrequencyPlanningChanged(const AudioVideoManagement::FrequencyPlanning &data, DataModification modType)
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO << ": " << data;
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << ": " << data;
|
||||
|
||||
Q_UNUSED(modType);
|
||||
|
||||
@@ -223,7 +222,7 @@ void ConfigCnr::onFrequencyPlanningChanged(const AudioVideoManagement::Frequency
|
||||
|
||||
void ConfigCnr::onCnrConfigChanged(const AudioVideoManagement::CnrConfig &data, DataModification modType)
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO << ": " << data;
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << ": " << data;
|
||||
|
||||
Q_UNUSED(modType);
|
||||
bool isGlobal = !data.exerciseId().is_set();
|
||||
|
||||
@@ -15,16 +15,16 @@ namespace CombatNetRadio
|
||||
DdsHandler::DdsHandler(int domainId)
|
||||
: m_ddsConnector(std::make_shared<DDSConnector::DdsConnector>(domainId, IDL::PartitionType::Global))
|
||||
{
|
||||
DEBUG_LOG() << "DdsHandler(" << domainId << ") for partition: " << m_ddsConnector->getDefaultPartition();
|
||||
DEBUG_LOG(m_logger) << "DdsHandler(" << domainId << ") for partition: " << m_ddsConnector->getDefaultPartition();
|
||||
}
|
||||
|
||||
bool DdsHandler::init(const QStringList &qosFileList)
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO;
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO;
|
||||
|
||||
if (!m_ddsConnector->init(qosFileList))
|
||||
{
|
||||
ERROR_LOG() << "Error initializing dds connections - aborting";
|
||||
ERROR_LOG(m_logger) << "Error initializing dds connections - aborting";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -76,6 +76,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
|
||||
std::unique_ptr<Core::Pacemaker> m_pacemaker;
|
||||
std::shared_ptr<AssetManagement::Interface::Dtc> m_asmDtc;
|
||||
|
||||
@@ -111,13 +111,13 @@ std::vector<WebSocketInterface::Messages::ReplyMessage> ExerciseManager::radioSt
|
||||
|
||||
WebSocketInterface::Messages::ReplyMessage ExerciseManager::configCnr(const QString &uuid)
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO;
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO;
|
||||
|
||||
const WebSocketInterface::Messages::ErrorMessage noActivePlanning(1, uuid, QStringLiteral("No active frequency planning found"));
|
||||
|
||||
if (m_parts.empty())
|
||||
{
|
||||
DEBUG_LOG() << "No active frequency planning due to empty m_parts.";
|
||||
DEBUG_LOG(m_logger) << "No active frequency planning due to empty m_parts.";
|
||||
|
||||
return noActivePlanning;
|
||||
}
|
||||
@@ -141,7 +141,7 @@ WebSocketInterface::Messages::ReplyMessage ExerciseManager::configCnr(const QStr
|
||||
|
||||
if (configCnrData.radioCircuit.empty())
|
||||
{
|
||||
DEBUG_LOG() << "No active frequency planning due to empty radio circuits.";
|
||||
DEBUG_LOG(m_logger) << "No active frequency planning due to empty radio circuits.";
|
||||
|
||||
return noActivePlanning;
|
||||
}
|
||||
@@ -182,25 +182,25 @@ WebSocketInterface::Messages::ReplyMessage ExerciseManager::positionsCnr(const Q
|
||||
void ExerciseManager::onModifyFrequencyPlanningStatusReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
if (replyObject.error())
|
||||
ERROR_LOG() << "Error while modifying FrequencyPlanningStatus: " << replyObject.str();
|
||||
ERROR_LOG(m_logger) << "Error while modifying FrequencyPlanningStatus: " << replyObject.str();
|
||||
else
|
||||
INFO_LOG() << "onModifyFrequencyPlanningStatusReply ok";
|
||||
INFO_LOG(m_logger) << "onModifyFrequencyPlanningStatusReply ok";
|
||||
}
|
||||
|
||||
void ExerciseManager::onClearFrequencyPlanningStatusReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
if (replyObject.error())
|
||||
ERROR_LOG() << "Error while clearing FrequencyPlanningStatus: " << replyObject.str();
|
||||
ERROR_LOG(m_logger) << "Error while clearing FrequencyPlanningStatus: " << replyObject.str();
|
||||
else
|
||||
INFO_LOG() << "onClearFrequencyPlanningStatusReply ok";
|
||||
INFO_LOG(m_logger) << "onClearFrequencyPlanningStatusReply ok";
|
||||
}
|
||||
|
||||
void ExerciseManager::onRemoveFrequencyPlanningStatusByClientReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
if (replyObject.error())
|
||||
ERROR_LOG() << "Error while removing FrequencyPlanningStatus: " << replyObject.str();
|
||||
ERROR_LOG(m_logger) << "Error while removing FrequencyPlanningStatus: " << replyObject.str();
|
||||
else
|
||||
INFO_LOG() << "onRemoveFrequencyPlanningStatusByClientReply ok";
|
||||
INFO_LOG(m_logger) << "onRemoveFrequencyPlanningStatusByClientReply ok";
|
||||
}
|
||||
|
||||
void ExerciseManager::setPositionsUpdateInterval(std::chrono::milliseconds interval)
|
||||
|
||||
@@ -68,6 +68,7 @@ signals:
|
||||
void positionsUpdate(const WebSocketInterface::Messages::ReplyMessage &positionsCnr);
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void onExerciseActivated(int exerciseId);
|
||||
void onExerciseDeactivated(int exerciseId);
|
||||
void onPositionsUpdateTimeout();
|
||||
|
||||
@@ -19,12 +19,12 @@ MainHandler::~MainHandler() = default;
|
||||
|
||||
bool MainHandler::init(int domainId)
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO;
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO;
|
||||
|
||||
m_ddsHandler.reset(new DdsHandler(domainId));
|
||||
if (!m_ddsHandler->init())
|
||||
{
|
||||
ERROR_LOG() << "Initialisation DdsHandler failed.";
|
||||
ERROR_LOG(m_logger) << "Initialisation DdsHandler failed.";
|
||||
m_ddsHandler->pacemaker()->setNewState(Core::RunningState::StartingError);
|
||||
return false;
|
||||
}
|
||||
@@ -35,7 +35,7 @@ bool MainHandler::init(int domainId)
|
||||
m_webSocketInterfaceHandler.reset(new WebSocketInterface::WebSocketInterfaceHandler(m_exerciseManager.get()));
|
||||
if (!m_webSocketInterfaceHandler->init())
|
||||
{
|
||||
ERROR_LOG() << "Initialisation WebSocketInterfaceHandler failed.";
|
||||
ERROR_LOG(m_logger) << "Initialisation WebSocketInterfaceHandler failed.";
|
||||
m_ddsHandler->pacemaker()->setNewState(Core::RunningState::StartingError);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ void TrainingArea::getRadioStations(InfrastructureManagement::Interface::Dtc *is
|
||||
data.id = stationId(mse);
|
||||
if (data.id == 0)
|
||||
{
|
||||
WARNING_LOG() << "Got MainStructureElement of type 'RadioStation' but property 'stationId' was not set"
|
||||
WARNING_LOG(m_logger) << "Got MainStructureElement of type 'RadioStation' but property 'stationId' was not set"
|
||||
<< " - database id: " << mse.id() << " - ignoring!";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -14,27 +14,26 @@
|
||||
namespace ComponentMonitor
|
||||
{
|
||||
|
||||
CheckmkHandler::CheckmkHandler()
|
||||
: QObject()
|
||||
, m_socket(new QTcpSocket(this))
|
||||
{
|
||||
TRACE_LOG() << Q_FUNC_INFO << " START";
|
||||
TRACE_LOG() << Q_FUNC_INFO << " END";
|
||||
CheckmkHandler::CheckmkHandler() : QObject()
|
||||
, m_socket(new QTcpSocket(this)),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
}
|
||||
|
||||
CheckmkHandler::~CheckmkHandler()
|
||||
{
|
||||
TRACE_LOG() << Q_FUNC_INFO << " START";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
if (m_timer)
|
||||
m_timer->stop();
|
||||
delete m_socket;
|
||||
TRACE_LOG() << Q_FUNC_INFO << " END";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
}
|
||||
|
||||
bool CheckmkHandler::initialize(const QString &checkMkServerHostname, int checkMkServerPort,
|
||||
int checkIntervalSec)
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " START"
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " START"
|
||||
<< " , hostname=" << checkMkServerHostname
|
||||
<< " , port=" << checkMkServerPort
|
||||
<< " , m_checkIntervalSec=" << checkIntervalSec;
|
||||
@@ -58,22 +57,22 @@ bool CheckmkHandler::initialize(const QString &checkMkServerHostname, int checkM
|
||||
this, &CheckmkHandler::onConnected);
|
||||
connect(m_socket, &QTcpSocket::readyRead, this, &CheckmkHandler::readData);
|
||||
|
||||
INFO_LOG() << Q_FUNC_INFO << " END";
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
return true;
|
||||
}
|
||||
|
||||
void CheckmkHandler::run()
|
||||
{
|
||||
INFO_LOG() << Q_FUNC_INFO << " START";
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
m_timer->start();
|
||||
INFO_LOG() << Q_FUNC_INFO << " END";
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
}
|
||||
|
||||
void CheckmkHandler::stop()
|
||||
{
|
||||
INFO_LOG() << Q_FUNC_INFO << " START";
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
m_timer->stop();
|
||||
INFO_LOG() << Q_FUNC_INFO << " END";
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
}
|
||||
|
||||
void CheckmkHandler::onTimeout()
|
||||
@@ -86,7 +85,7 @@ void CheckmkHandler::onTimeout()
|
||||
m_timer->setInterval(m_checkIntervalSec*1000);
|
||||
}
|
||||
|
||||
INFO_LOG() << Q_FUNC_INFO << " Timeout, m_highFrequencyCheck=" << m_highFrequencyCheck
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " Timeout, m_highFrequencyCheck=" << m_highFrequencyCheck
|
||||
<< ", current Interval=" << m_timer->interval() << " [msec]";
|
||||
|
||||
if (m_socket->state() == QAbstractSocket::SocketState::ConnectedState)
|
||||
@@ -99,37 +98,37 @@ void CheckmkHandler::onTimeout()
|
||||
|
||||
bool CheckmkHandler::doConnect()
|
||||
{
|
||||
INFO_LOG() << Q_FUNC_INFO << " START, (int)m_socket->state()=" << (int)m_socket->state();
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " START, (int)m_socket->state()=" << (int)m_socket->state();
|
||||
|
||||
|
||||
m_socket->connectToHost(m_checkMkHost, m_checkMkPort);
|
||||
if (!m_socket->waitForConnected(5000))
|
||||
{
|
||||
ERROR_LOG() << Q_FUNC_INFO << " Could not (re)open tcp destination " << m_checkMkHost << ":" << m_checkMkPort << ", error: " << m_socket->errorString();
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " Could not (re)open tcp destination " << m_checkMkHost << ":" << m_checkMkPort << ", error: " << m_socket->errorString();
|
||||
return false;
|
||||
}
|
||||
INFO_LOG() << Q_FUNC_INFO << " (Re)openend tcp destination " << m_checkMkHost << ":" << m_checkMkPort;
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " (Re)openend tcp destination " << m_checkMkHost << ":" << m_checkMkPort;
|
||||
|
||||
INFO_LOG() << Q_FUNC_INFO << " END";
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
return true;
|
||||
}
|
||||
|
||||
void CheckmkHandler::onImmediateGetStateRequested()
|
||||
{
|
||||
INFO_LOG() << Q_FUNC_INFO << " START";
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
|
||||
|
||||
m_highFrequencyCheck = 3;
|
||||
onTimeout();
|
||||
|
||||
INFO_LOG() << Q_FUNC_INFO << " END";
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
}
|
||||
|
||||
bool CheckmkHandler::writeGetStateRequest()
|
||||
{
|
||||
if (!m_socket->isOpen())
|
||||
{
|
||||
ERROR_LOG() << Q_FUNC_INFO << " socket not open";
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " socket not open";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -160,16 +159,16 @@ bool CheckmkHandler::writeGetStateRequest()
|
||||
|
||||
const char* cmdCheck = "GET hosts\nResponseHeader: fixed16\nColumns: name state last_check \nKeepAlive: on\n\n";
|
||||
int bWritten = m_socket->write(cmdCheck);
|
||||
INFO_LOG() << Q_FUNC_INFO << " cmdCheck= '" << cmdCheck << "'";
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " cmdCheck= '" << cmdCheck << "'";
|
||||
|
||||
|
||||
INFO_LOG() << Q_FUNC_INFO << " bWritten= " << bWritten;
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " bWritten= " << bWritten;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CheckmkHandler::readData()
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
|
||||
|
||||
while (m_socket->canReadLine())
|
||||
processLine(m_socket->readLine().trimmed());
|
||||
@@ -204,10 +203,10 @@ bool CheckmkHandler::processLine(const QByteArray &line)
|
||||
if (sl.size() < 2)
|
||||
{
|
||||
if (str.startsWith(QStringLiteral("200")))
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " size to small " << sl.size()
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " size to small " << sl.size()
|
||||
<< ", line='" << str << "'";
|
||||
else
|
||||
WARNING_LOG() << Q_FUNC_INFO << " size to small " << sl.size()
|
||||
WARNING_LOG(m_logger) << Q_FUNC_INFO << " size to small " << sl.size()
|
||||
<< ", line='" << str << "'";
|
||||
return false;
|
||||
}
|
||||
@@ -238,7 +237,7 @@ bool CheckmkHandler::processLine(const QByteArray &line)
|
||||
lastCheck = lastCheckStr.toLongLong();
|
||||
}
|
||||
|
||||
DEBUG_LOG() << Q_FUNC_INFO
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO
|
||||
<< " name: '" << name << "'"
|
||||
<< ", stateInt: '" << stateInt << "'"
|
||||
<< ", reachable: '" << reachable << "'"
|
||||
|
||||
@@ -56,6 +56,7 @@ private Q_SLOTS:
|
||||
|
||||
|
||||
protected:
|
||||
NGL::INGLLogger &m_logger;
|
||||
bool processLine(const QByteArray &line);
|
||||
|
||||
private:
|
||||
|
||||
+27
-27
@@ -17,17 +17,17 @@ CheckmkHandlerScheduleCheck::CheckmkHandlerScheduleCheck(const std::shared_ptr<D
|
||||
, m_socket(new QTcpSocket(this))
|
||||
, m_ddsHandler(ddsHandler)
|
||||
{
|
||||
TRACE_LOG() << Q_FUNC_INFO << " START";
|
||||
TRACE_LOG() << Q_FUNC_INFO << " END";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
}
|
||||
|
||||
CheckmkHandlerScheduleCheck::~CheckmkHandlerScheduleCheck()
|
||||
{
|
||||
TRACE_LOG() << Q_FUNC_INFO << " START";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
if (m_timer)
|
||||
m_timer->stop();
|
||||
delete m_socket;
|
||||
TRACE_LOG() << Q_FUNC_INFO << " END";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
}
|
||||
|
||||
bool CheckmkHandlerScheduleCheck::initialize(const QString &checkMkServerHostname, int checkMkServerPort)
|
||||
@@ -36,7 +36,7 @@ bool CheckmkHandlerScheduleCheck::initialize(const QString &checkMkServerHostnam
|
||||
<< " , hostname=" << checkMkServerHostname
|
||||
<< " , port=" << checkMkServerPort;
|
||||
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " ddsHandler referenced";
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " ddsHandler referenced";
|
||||
|
||||
m_checkMkHost = checkMkServerHostname;
|
||||
m_checkMkPort = checkMkServerPort;
|
||||
@@ -55,22 +55,22 @@ bool CheckmkHandlerScheduleCheck::initialize(const QString &checkMkServerHostnam
|
||||
connect(m_socket, &QTcpSocket::connected,
|
||||
this, &CheckmkHandlerScheduleCheck::onConnected);
|
||||
|
||||
INFO_LOG() << Q_FUNC_INFO << " END";
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
return true;
|
||||
}
|
||||
|
||||
void CheckmkHandlerScheduleCheck::run(int timoutMsec)
|
||||
{
|
||||
INFO_LOG() << Q_FUNC_INFO << " START, timoutMsec=" << timoutMsec;
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " START, timoutMsec=" << timoutMsec;
|
||||
m_timer->start(timoutMsec);
|
||||
INFO_LOG() << Q_FUNC_INFO << " END";
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
}
|
||||
|
||||
void CheckmkHandlerScheduleCheck::stop()
|
||||
{
|
||||
INFO_LOG() << Q_FUNC_INFO << " START";
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
m_timer->stop();
|
||||
INFO_LOG() << Q_FUNC_INFO << " END";
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
}
|
||||
|
||||
void CheckmkHandlerScheduleCheck::onTimeout()
|
||||
@@ -85,7 +85,7 @@ void CheckmkHandlerScheduleCheck::onTimeout()
|
||||
|
||||
bool CheckmkHandlerScheduleCheck::doConnect()
|
||||
{
|
||||
INFO_LOG() << Q_FUNC_INFO << " START, (int)m_socket->state()=" << (int)m_socket->state();
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " START, (int)m_socket->state()=" << (int)m_socket->state();
|
||||
|
||||
|
||||
|
||||
@@ -93,30 +93,30 @@ bool CheckmkHandlerScheduleCheck::doConnect()
|
||||
m_socket->connectToHost(m_checkMkHost, m_checkMkPort);
|
||||
if (!m_socket->waitForConnected(5000))
|
||||
{
|
||||
ERROR_LOG() << Q_FUNC_INFO << " Could not (re)open tcp destination " << m_checkMkHost << ":" << m_checkMkPort << ", error: " << m_socket->errorString();
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " Could not (re)open tcp destination " << m_checkMkHost << ":" << m_checkMkPort << ", error: " << m_socket->errorString();
|
||||
return false;
|
||||
}
|
||||
INFO_LOG() << Q_FUNC_INFO << " (Re)openend tcp destination " << m_checkMkHost << ":" << m_checkMkPort;
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " (Re)openend tcp destination " << m_checkMkHost << ":" << m_checkMkPort;
|
||||
|
||||
INFO_LOG() << Q_FUNC_INFO << " END";
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
return true;
|
||||
}
|
||||
|
||||
void CheckmkHandlerScheduleCheck::addScheduleCheckHostnames(const QStringList &hostnames)
|
||||
{
|
||||
INFO_LOG() << Q_FUNC_INFO << " hostnames: " << hostnames.join(QStringLiteral(";"));
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " hostnames: " << hostnames.join(QStringLiteral(";"));
|
||||
m_scheduleCheckHostnames += hostnames;
|
||||
}
|
||||
|
||||
bool CheckmkHandlerScheduleCheck::writeScheduleUpdateRequest()
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO
|
||||
<< " state " << (int)m_socket->state()
|
||||
<< ", isOpen " << m_socket->isOpen();
|
||||
|
||||
if (!m_socket->isOpen() || (m_socket->state() != QAbstractSocket::SocketState::ConnectedState))
|
||||
{
|
||||
ERROR_LOG() << Q_FUNC_INFO << " socket not open or connected "
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " socket not open or connected "
|
||||
<< " host/port: " << m_checkMkHost << ":" << m_checkMkPort;
|
||||
return false;
|
||||
}
|
||||
@@ -137,13 +137,13 @@ bool CheckmkHandlerScheduleCheck::writeScheduleUpdateRequest()
|
||||
qint64 now = QDateTime::currentSecsSinceEpoch();
|
||||
|
||||
const QString cmd = QString(QStringLiteral("COMMAND [%1] SCHEDULE_FORCED_HOST_CHECK;%2;%3")).arg(now).arg(hostname.toUpper()).arg(now);
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " cmd= '" << cmd << "'";
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " cmd= '" << cmd << "'";
|
||||
int bWritten = m_socket->write(cmd.toUtf8()) + m_socket->write("\n\n");
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " bWritten= " << bWritten;
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " bWritten= " << bWritten;
|
||||
bWrittenAll += bWritten;
|
||||
}
|
||||
|
||||
INFO_LOG() << Q_FUNC_INFO << " bWrittenAll= " << bWrittenAll;
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " bWrittenAll= " << bWrittenAll;
|
||||
|
||||
|
||||
m_scheduleCheckHostnames.clear();
|
||||
@@ -165,7 +165,7 @@ void CheckmkHandlerScheduleCheck::onConnected()
|
||||
|
||||
void CheckmkHandlerScheduleCheck::onStateChanged(const QAbstractSocket::SocketState &newState)
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " SocketState changed to: " << newState;
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " SocketState changed to: " << newState;
|
||||
qInfo() << " CheckmkHandlerScheduleCheck: SocketState changed to: " << newState;
|
||||
}
|
||||
|
||||
@@ -177,8 +177,8 @@ void CheckmkHandlerScheduleCheck::onSocketError(const QAbstractSocket::SocketErr
|
||||
|
||||
void CheckmkHandlerScheduleCheck::onTriggerUpdateRequest(const rti::core::SampleIdentity &cookie, const TriggerUpdate &request)
|
||||
{
|
||||
INFO_LOG() << Q_FUNC_INFO << " request=" << request;
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " m_socket->state=" << (int)m_socket->state();
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " request=" << request;
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " m_socket->state=" << (int)m_socket->state();
|
||||
|
||||
|
||||
|
||||
@@ -230,7 +230,7 @@ void CheckmkHandlerScheduleCheck::onTriggerUpdateRequest(const rti::core::Sample
|
||||
}
|
||||
} else {
|
||||
|
||||
WARNING_LOG() << Q_FUNC_INFO << " socket not connected"
|
||||
WARNING_LOG(m_logger) << Q_FUNC_INFO << " socket not connected"
|
||||
<< ", (int)m_socket->state()=" << (int)m_socket->state()
|
||||
<< ", destination " << m_checkMkHost << ":" << m_checkMkPort
|
||||
<< ", -> queued cmd/request: " << request;
|
||||
@@ -238,13 +238,13 @@ void CheckmkHandlerScheduleCheck::onTriggerUpdateRequest(const rti::core::Sample
|
||||
|
||||
}
|
||||
|
||||
INFO_LOG() << Q_FUNC_INFO << " m_ddsHandler = " << m_ddsHandler;
|
||||
INFO_LOG() << Q_FUNC_INFO << " m_ddsHandler->fts() = " << m_ddsHandler->fts();
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " m_ddsHandler = " << m_ddsHandler;
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " m_ddsHandler->fts() = " << m_ddsHandler->fts();
|
||||
|
||||
if (m_ddsHandler && m_ddsHandler->fts())
|
||||
m_ddsHandler->fts()->triggerUpdateReply(cookie, ret);
|
||||
else
|
||||
ERROR_LOG() << Q_FUNC_INFO << " no m_ddsHandler or m_ddsHandler->fts()";
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " no m_ddsHandler or m_ddsHandler->fts()";
|
||||
|
||||
|
||||
if (!connected)
|
||||
|
||||
+1
@@ -60,6 +60,7 @@ private:
|
||||
|
||||
|
||||
protected:
|
||||
NGL::INGLLogger &m_logger;
|
||||
bool processLine(const QByteArray &line);
|
||||
|
||||
private:
|
||||
|
||||
+41
-42
@@ -12,35 +12,34 @@
|
||||
namespace ComponentMonitor
|
||||
{
|
||||
|
||||
ComponentStatusHandler::ComponentStatusHandler()
|
||||
: QObject()
|
||||
{
|
||||
TRACE_LOG() << Q_FUNC_INFO << " START";
|
||||
TRACE_LOG() << Q_FUNC_INFO << " END";
|
||||
ComponentStatusHandler::ComponentStatusHandler() : QObject(),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
}
|
||||
|
||||
ComponentStatusHandler::~ComponentStatusHandler()
|
||||
{
|
||||
TRACE_LOG() << Q_FUNC_INFO << " START";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
m_ddsHandler = nullptr;
|
||||
TRACE_LOG() << Q_FUNC_INFO << " END";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
}
|
||||
|
||||
bool ComponentStatusHandler::initialize(const std::shared_ptr<DdsHandler> &ddsHandler)
|
||||
{
|
||||
INFO_LOG() << Q_FUNC_INFO << " START initialize ComponentStatusHandler";
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " START initialize ComponentStatusHandler";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
m_ddsHandler = ddsHandler;
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " ddsHandler referenced";
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " ddsHandler referenced";
|
||||
|
||||
m_ismDtc = m_ddsHandler->ismDtc();
|
||||
if (!m_ismDtc)
|
||||
{
|
||||
ERROR_LOG() << Q_FUNC_INFO << " Failure: no ismDtc";
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " Failure: no ismDtc";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -48,7 +47,7 @@ bool ComponentStatusHandler::initialize(const std::shared_ptr<DdsHandler> &ddsHa
|
||||
m_ismDtc->enableInstrumentationAsset();
|
||||
m_ismDtc->waitForHistoricalDataInstrumentationAsset(2000);
|
||||
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " instrumentationAssets-size = " << m_ismDtc->instrumentationAssets().size();
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " instrumentationAssets-size = " << m_ismDtc->instrumentationAssets().size();
|
||||
|
||||
|
||||
|
||||
@@ -65,8 +64,8 @@ bool ComponentStatusHandler::initialize(const std::shared_ptr<DdsHandler> &ddsHa
|
||||
QTimer::singleShot(35000, this, &ComponentStatusHandler::dump);
|
||||
|
||||
|
||||
DEBUG_LOG() << Q_FUNC_INFO << "initialize succesful, statusMapSize=" << statusMapSize();
|
||||
INFO_LOG() << Q_FUNC_INFO << " END initialize ComponentStatusHandler, statusMapSize=" << statusMapSize();
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << "initialize succesful, statusMapSize=" << statusMapSize();
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " END initialize ComponentStatusHandler, statusMapSize=" << statusMapSize();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -95,7 +94,7 @@ void ComponentStatusHandler::onInstrumentationAssetChanged(const InfrastructureM
|
||||
static int assetChangedCounter = 0;
|
||||
|
||||
const int iAssetId = iAsset.id();
|
||||
DEBUG_LOG() << Q_FUNC_INFO
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO
|
||||
<< ", iAssetId=" << iAssetId
|
||||
<< " (assetChangedCounter=" << ++assetChangedCounter << ")";
|
||||
|
||||
@@ -139,62 +138,62 @@ void ComponentStatusHandler::onInstrumentationAssetChanged(const InfrastructureM
|
||||
|
||||
void ComponentStatusHandler::dump()
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " +++++++++++++++++++++++++++++++++++++++++++++";
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " +++++++++++++++++++++++++++++++++++++++++++++";
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " DUMP START";
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " +++++++++++++++++++++++++++++++++++++++++++++";
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " +++++++++++++++++++++++++++++++++++++++++++++";
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " DUMP START";
|
||||
|
||||
int counter = 0;
|
||||
|
||||
|
||||
counter = 0;
|
||||
DEBUG_LOG() << " +++++++++++++++++++++++++++++++++++++++++++++";
|
||||
DEBUG_LOG() << " REACHABLE:";
|
||||
DEBUG_LOG(m_logger) << " +++++++++++++++++++++++++++++++++++++++++++++";
|
||||
DEBUG_LOG(m_logger) << " REACHABLE:";
|
||||
for (const ComponentStatus &status : std::as_const(m_statusMap))
|
||||
{
|
||||
if (status.state().underlying() == ComponentState_def::Reachable)
|
||||
{
|
||||
DEBUG_LOG() << " id=" << status.id() << ", host '" << status.hostname().c_str() << " -> Reachable";
|
||||
DEBUG_LOG(m_logger) << " id=" << status.id() << ", host '" << status.hostname().c_str() << " -> Reachable";
|
||||
++counter;
|
||||
}
|
||||
}
|
||||
DEBUG_LOG() << " REACHABLE hostCounter = " << counter;
|
||||
DEBUG_LOG(m_logger) << " REACHABLE hostCounter = " << counter;
|
||||
|
||||
|
||||
counter = 0;
|
||||
DEBUG_LOG() << " +++++++++++++++++++++++++++++++++++++++++++++";
|
||||
DEBUG_LOG() << " UNREACHABLE:";
|
||||
DEBUG_LOG(m_logger) << " +++++++++++++++++++++++++++++++++++++++++++++";
|
||||
DEBUG_LOG(m_logger) << " UNREACHABLE:";
|
||||
for (const ComponentStatus &status : std::as_const(m_statusMap))
|
||||
{
|
||||
if (status.state().underlying() == ComponentState_def::Unreachable)
|
||||
{
|
||||
DEBUG_LOG() << " id=" << status.id() << ", host '" << status.hostname().c_str() << " -> Unreachable";
|
||||
DEBUG_LOG(m_logger) << " id=" << status.id() << ", host '" << status.hostname().c_str() << " -> Unreachable";
|
||||
++counter;
|
||||
}
|
||||
}
|
||||
DEBUG_LOG() << " UNREACHABLE hostCounter = " << counter;
|
||||
DEBUG_LOG(m_logger) << " UNREACHABLE hostCounter = " << counter;
|
||||
|
||||
|
||||
counter = 0;
|
||||
DEBUG_LOG() << " +++++++++++++++++++++++++++++++++++++++++++++";
|
||||
DEBUG_LOG() << " UNDEFINED:";
|
||||
DEBUG_LOG(m_logger) << " +++++++++++++++++++++++++++++++++++++++++++++";
|
||||
DEBUG_LOG(m_logger) << " UNDEFINED:";
|
||||
for (const ComponentStatus &status : std::as_const(m_statusMap))
|
||||
{
|
||||
if (status.state().underlying() == ComponentState_def::Undefined)
|
||||
{
|
||||
DEBUG_LOG() << " id=" << status.id() << ", host '" << status.hostname().c_str() << " -> Undefined";
|
||||
DEBUG_LOG(m_logger) << " id=" << status.id() << ", host '" << status.hostname().c_str() << " -> Undefined";
|
||||
++counter;
|
||||
}
|
||||
}
|
||||
DEBUG_LOG() << " UNDEFINED hostCounter = " << counter;
|
||||
DEBUG_LOG(m_logger) << " UNDEFINED hostCounter = " << counter;
|
||||
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " DUMP END";
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " +++++++++++++++++++++++++++++++++++++++++++++";
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " +++++++++++++++++++++++++++++++++++++++++++++";
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " DUMP END";
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " +++++++++++++++++++++++++++++++++++++++++++++";
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " +++++++++++++++++++++++++++++++++++++++++++++";
|
||||
}
|
||||
|
||||
void ComponentStatusHandler::onNewState(const QString &hostname, bool reachable, long long lastCheckSec)
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " hostname=" << hostname
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " hostname=" << hostname
|
||||
<< ", reachable=" << reachable
|
||||
<< ", lastCheckSec=" << lastCheckSec;
|
||||
|
||||
@@ -219,7 +218,7 @@ void ComponentStatusHandler::onNewState(const QString &hostname, bool reachable,
|
||||
|
||||
void ComponentStatusHandler::onUpdateLastCheckTimeDirect(const QStringList &hostnamesForUpdateLastCheckTime, qint64 lastCheckSec)
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " START hostnamesForLastCheckTime=" << hostnamesForUpdateLastCheckTime.join(QStringLiteral(";"));
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " START hostnamesForLastCheckTime=" << hostnamesForUpdateLastCheckTime.join(QStringLiteral(";"));
|
||||
|
||||
for (ITERATOR_T it = m_statusMap.begin(); it != m_statusMap.end(); ++it)
|
||||
{
|
||||
@@ -236,12 +235,12 @@ void ComponentStatusHandler::onUpdateLastCheckTimeDirect(const QStringList &host
|
||||
if ((curState == ComponentState_def::Reachable) ||
|
||||
(curState == ComponentState_def::Unreachable))
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " updateLastCheckTimeDirect"
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " updateLastCheckTimeDirect"
|
||||
<< " host: '" << curHostname << "'"
|
||||
<< " newLastCheck= " << lastCheckSec;
|
||||
INFO_LOG() << Q_FUNC_INFO << " DIFF_2a (*it) " << (*it);
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " DIFF_2a (*it) " << (*it);
|
||||
cs.last_check(lastCheckSec);
|
||||
INFO_LOG() << Q_FUNC_INFO << " DIFF_2b (*it) " << (*it);
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " DIFF_2b (*it) " << (*it);
|
||||
m_ddsHandler->dts()->publish(cs);
|
||||
}
|
||||
}
|
||||
@@ -250,7 +249,7 @@ void ComponentStatusHandler::onUpdateLastCheckTimeDirect(const QStringList &host
|
||||
bool ComponentStatusHandler::addUpdateInstrumentationAsset(ComponentStatusHandler::ITERATOR_T it,
|
||||
const ComponentStatus &cs)
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " START add/Update: cs=" << cs
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " START add/Update: cs=" << cs
|
||||
<< ", curSize=" << m_statusMap.size() << ")";
|
||||
const int id = cs.id();
|
||||
|
||||
@@ -260,8 +259,8 @@ bool ComponentStatusHandler::addUpdateInstrumentationAsset(ComponentStatusHandle
|
||||
|
||||
if ((*it) != cs)
|
||||
{
|
||||
INFO_LOG() << Q_FUNC_INFO << " DIFF (*it) " << (*it);
|
||||
INFO_LOG() << Q_FUNC_INFO << " DIFF cs " << cs;
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " DIFF (*it) " << (*it);
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " DIFF cs " << cs;
|
||||
|
||||
(*it) = cs;
|
||||
m_ddsHandler->dts()->publish(cs);
|
||||
@@ -274,7 +273,7 @@ bool ComponentStatusHandler::addUpdateInstrumentationAsset(ComponentStatusHandle
|
||||
m_statusMap.insert(id, cs);
|
||||
m_ddsHandler->dts()->publish(cs);
|
||||
}
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " END add/Update: cs=" << cs
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " END add/Update: cs=" << cs
|
||||
<< ", curSize=" << m_statusMap.size() << ")";
|
||||
return true;
|
||||
}
|
||||
@@ -282,7 +281,7 @@ bool ComponentStatusHandler::addUpdateInstrumentationAsset(ComponentStatusHandle
|
||||
bool ComponentStatusHandler::removeInstrumentationAsset(ComponentStatusHandler::ITERATOR_T it)
|
||||
{
|
||||
const int id = it.value().id();
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " remove: id=" << id;
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " remove: id=" << id;
|
||||
m_statusMap.remove(id);
|
||||
m_ddsHandler->dts()->removeComponentStatusByKey(id);
|
||||
return true;
|
||||
|
||||
@@ -49,6 +49,7 @@ private Q_SLOTS:
|
||||
void dump();
|
||||
|
||||
protected:
|
||||
NGL::INGLLogger &m_logger;
|
||||
bool addUpdateInstrumentationAsset(ITERATOR_T it, const ComponentStatus &cs);
|
||||
bool removeInstrumentationAsset(ITERATOR_T it);
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace ComponentMonitor
|
||||
DdsHandler::DdsHandler(int domainId, int exerciseId)
|
||||
: m_ddsConnector(std::make_shared<DDSConnector::DdsConnector>(domainId, IDL::PartitionType::Global, exerciseId))
|
||||
{
|
||||
DEBUG_LOG() << "DdsHandler(" << domainId << ") for partition: " << m_ddsConnector->getDefaultPartition();
|
||||
DEBUG_LOG(m_logger) << "DdsHandler(" << domainId << ") for partition: " << m_ddsConnector->getDefaultPartition();
|
||||
}
|
||||
|
||||
DdsHandler::~DdsHandler()
|
||||
@@ -27,7 +27,7 @@ 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;
|
||||
}
|
||||
|
||||
@@ -45,10 +45,10 @@ bool DdsHandler::init(const QStringList &qosFileList)
|
||||
m_ddsFts = ComponentMonitor::Interface::Fts::create(m_ddsConnector);
|
||||
|
||||
bool bRet = m_ddsDts->enableAll();
|
||||
INFO_LOG() << "Dts initialised";
|
||||
INFO_LOG(m_logger) << "Dts initialised";
|
||||
|
||||
bRet &= m_ddsFts->enableAll();
|
||||
INFO_LOG() << "Fts initialised";
|
||||
INFO_LOG(m_logger) << "Fts initialised";
|
||||
|
||||
m_ismDtc = InfrastructureManagement::Interface::Dtc::create(m_ddsConnector);
|
||||
|
||||
@@ -60,9 +60,9 @@ bool DdsHandler::init(const QStringList &qosFileList)
|
||||
|
||||
void DdsHandler::enableDtcs()
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " START Enable DTCs(" << m_ddsConnector->getDomainId() << ") for partition: " << m_ddsConnector->getDefaultPartition();
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " START Enable DTCs(" << m_ddsConnector->getDomainId() << ") for partition: " << m_ddsConnector->getDefaultPartition();
|
||||
m_ismDtc->enableInstrumentationAsset();
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " END Enable DTCs(" << m_ddsConnector->getDomainId() << ") for partition: " << m_ddsConnector->getDefaultPartition();
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " END Enable DTCs(" << m_ddsConnector->getDomainId() << ") for partition: " << m_ddsConnector->getDefaultPartition();
|
||||
}
|
||||
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> DdsHandler::ismDtc() const
|
||||
|
||||
@@ -53,6 +53,7 @@ public:
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> ismDtc() const;
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
|
||||
std::shared_ptr<DTS::CurrentRunningState> m_dtsCurrentRunningState;
|
||||
std::shared_ptr<Core::Pacemaker> m_pacemaker;
|
||||
|
||||
@@ -14,29 +14,29 @@ namespace ComponentMonitor
|
||||
Initialization::Initialization()
|
||||
: m_logger(getLogger("Initialization"))
|
||||
{
|
||||
TRACE_LOG() << Q_FUNC_INFO << " START";
|
||||
TRACE_LOG() << Q_FUNC_INFO << " END";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
}
|
||||
|
||||
Initialization::~Initialization()
|
||||
{
|
||||
TRACE_LOG() << Q_FUNC_INFO << " START";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
m_checkmkHandler = nullptr;
|
||||
m_componentStatusHandler = nullptr;
|
||||
m_ddsHandler = nullptr;
|
||||
TRACE_LOG() << Q_FUNC_INFO << " END";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
}
|
||||
|
||||
bool Initialization::initialize(const std::shared_ptr<DdsHandler> &ddsHandler)
|
||||
{
|
||||
INFO_LOG() << Q_FUNC_INFO << " START";
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
m_ddsHandler = ddsHandler;
|
||||
DEBUG_LOG() << Q_FUNC_INFO << "ddsHandler referenced";
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << "ddsHandler referenced";
|
||||
|
||||
|
||||
|
||||
@@ -73,10 +73,10 @@ bool Initialization::initialize(const std::shared_ptr<DdsHandler> &ddsHandler)
|
||||
|
||||
if (!m_checkmkHandler->initialize(host, port, intervalSec))
|
||||
{
|
||||
ERROR_LOG() << Q_FUNC_INFO << " CheckmkHandler::initialize failed";
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " CheckmkHandler::initialize failed";
|
||||
return false;
|
||||
}
|
||||
INFO_LOG() << Q_FUNC_INFO << " CheckmkHandler:initialize succesful";
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " CheckmkHandler:initialize succesful";
|
||||
|
||||
QObject::connect(m_checkmkHandler.get(), &CheckmkHandler::newState,
|
||||
m_componentStatusHandler.get(), &ComponentStatusHandler::onNewState, Qt::UniqueConnection);
|
||||
@@ -88,10 +88,10 @@ bool Initialization::initialize(const std::shared_ptr<DdsHandler> &ddsHandler)
|
||||
m_checkmkHandlerScheduleCheck = std::make_shared<CheckmkHandlerScheduleCheck>(m_ddsHandler);
|
||||
if (!m_checkmkHandlerScheduleCheck->initialize(host, port))
|
||||
{
|
||||
ERROR_LOG() << Q_FUNC_INFO << " CheckmkHandlerScheduleCheck::initialize failed";
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " CheckmkHandlerScheduleCheck::initialize failed";
|
||||
return false;
|
||||
}
|
||||
INFO_LOG() << Q_FUNC_INFO << " CheckmkHandlerScheduleCheck:initialize succesful";
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " CheckmkHandlerScheduleCheck:initialize succesful";
|
||||
|
||||
|
||||
#ifdef LTS_DEBUG
|
||||
@@ -110,21 +110,21 @@ bool Initialization::initialize(const std::shared_ptr<DdsHandler> &ddsHandler)
|
||||
#endif
|
||||
|
||||
|
||||
INFO_LOG() << Q_FUNC_INFO << " END";
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Initialization::delayedInit()
|
||||
{
|
||||
INFO_LOG() << Q_FUNC_INFO << " START";
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
bool success = true;
|
||||
if (!m_componentStatusHandler->initialize(m_ddsHandler))
|
||||
{
|
||||
ERROR_LOG() << Q_FUNC_INFO << " initialize failed for ComponentStatusHandler";
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " initialize failed for ComponentStatusHandler";
|
||||
success = false;
|
||||
}
|
||||
|
||||
INFO_LOG() << Q_FUNC_INFO << " ComponentStatusHandler, statusMapSize=" << m_componentStatusHandler->getHostnames().size();
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " ComponentStatusHandler, statusMapSize=" << m_componentStatusHandler->getHostnames().size();
|
||||
|
||||
m_checkmkHandler->run();
|
||||
|
||||
@@ -144,7 +144,7 @@ bool Initialization::delayedInit()
|
||||
|
||||
|
||||
|
||||
INFO_LOG() << Q_FUNC_INFO << " END";
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
private:
|
||||
std::shared_ptr<DdsHandler> m_ddsHandler;
|
||||
std::shared_ptr<ComponentStatusHandler> m_componentStatusHandler;
|
||||
|
||||
@@ -11,19 +11,18 @@
|
||||
namespace ComponentMonitor
|
||||
{
|
||||
|
||||
MainHandler::MainHandler(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
TRACE_LOG() << Q_FUNC_INFO << " START";
|
||||
TRACE_LOG() << Q_FUNC_INFO << " END";
|
||||
MainHandler::MainHandler(QObject *parent) : QObject(parent),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
}
|
||||
|
||||
MainHandler::~MainHandler()
|
||||
{
|
||||
TRACE_LOG() << Q_FUNC_INFO << " START";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
m_cmoService = nullptr;
|
||||
m_ddsHandler = nullptr;
|
||||
TRACE_LOG() << Q_FUNC_INFO << " END";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
}
|
||||
|
||||
bool MainHandler::init(int domainId)
|
||||
@@ -33,11 +32,11 @@ bool MainHandler::init(int domainId)
|
||||
m_ddsHandler = std::make_shared<DdsHandler>(domainId, excerciseId);
|
||||
if (!m_ddsHandler->init())
|
||||
{
|
||||
ERROR_LOG() << "Initialisation ddsHandler failed.";
|
||||
ERROR_LOG(m_logger) << "Initialisation ddsHandler failed.";
|
||||
m_ddsHandler->pacemaker()->setNewState(Core::RunningState::StartingError);
|
||||
return false;
|
||||
}
|
||||
DEBUG_LOG() << "Initialisation ddsHandler succesful.";
|
||||
DEBUG_LOG(m_logger) << "Initialisation ddsHandler succesful.";
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ public:
|
||||
std::shared_ptr<DdsHandler> dds() const { return m_ddsHandler; }
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::shared_ptr<DdsHandler> m_ddsHandler;
|
||||
std::shared_ptr<ComponentMonitor::Initialization> m_cmoService;
|
||||
};
|
||||
|
||||
@@ -10,18 +10,18 @@ namespace DifferentialGPS
|
||||
DdsHandler::DdsHandler(int domainId)
|
||||
: m_ddsConnector(std::make_shared<DDSConnector::DdsConnector>(domainId, IDL::PartitionType::Global))
|
||||
{
|
||||
DEBUG_LOG() << "DdsHandler(" << domainId << ") for partition: " << m_ddsConnector->getDefaultPartition();
|
||||
DEBUG_LOG(m_logger) << "DdsHandler(" << domainId << ") for partition: " << m_ddsConnector->getDefaultPartition();
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool DdsHandler::init(const QStringList &qosFileList)
|
||||
{
|
||||
INFO_LOG() << "--- Start DifferentialGPS DDSHandler.";
|
||||
INFO_LOG(m_logger) << "--- Start DifferentialGPS DDSHandler.";
|
||||
|
||||
if (!m_ddsConnector->init(qosFileList))
|
||||
{
|
||||
ERROR_LOG() << "Error initializing dds connections - aborting";
|
||||
ERROR_LOG(m_logger) << "Error initializing dds connections - aborting";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
|
||||
std::shared_ptr<Core::Pacemaker> m_pacemaker;
|
||||
};
|
||||
|
||||
@@ -59,7 +59,7 @@ bool MainThread::init(int domainId)
|
||||
m_ddsHandler.reset(new DdsHandler(domainId));
|
||||
if (!m_ddsHandler->init())
|
||||
{
|
||||
ERROR_LOG() << "Initialisation DdsHandler failed.";
|
||||
ERROR_LOG(m_logger) << "Initialisation DdsHandler failed.";
|
||||
m_ddsHandler->pacemaker()->setNewState(Core::RunningState::StartingError);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ public:
|
||||
Q_SIGNALS:
|
||||
void newDataAvailable();
|
||||
protected:
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::shared_ptr<DdsHandler> m_ddsHandler;
|
||||
QByteArray m_dgpsData;
|
||||
QTimer *m_dgpsTimer;
|
||||
|
||||
@@ -33,7 +33,7 @@ void TcpSocket::startThreadInternal(const QString &hostName, quint16 port)
|
||||
|
||||
void TcpSocket::run()
|
||||
{
|
||||
DEBUG_LOG() << "Starting thread";
|
||||
DEBUG_LOG(m_logger) << "Starting thread";
|
||||
m_reconnectTimer = new QTimer(this);
|
||||
doConnect();
|
||||
exec();
|
||||
@@ -54,14 +54,14 @@ void TcpSocket::doConnect()
|
||||
connect(m_socket, &QTcpSocket::readyRead,
|
||||
this, &TcpSocket::onReadyRead);
|
||||
|
||||
INFO_LOG() << "Connecting to tcp server at "
|
||||
INFO_LOG(m_logger) << "Connecting to tcp server at "
|
||||
<< m_hostName << ":" << m_hostPort;
|
||||
m_socket->connectToHost(m_hostName, m_hostPort);
|
||||
}
|
||||
|
||||
void TcpSocket::onConnected()
|
||||
{
|
||||
INFO_LOG() << "Connected to "
|
||||
INFO_LOG(m_logger) << "Connected to "
|
||||
<< m_socket->peerAddress().toString()
|
||||
<< ":" << m_socket->peerPort();
|
||||
m_waitTime = 1;
|
||||
@@ -69,13 +69,13 @@ void TcpSocket::onConnected()
|
||||
|
||||
void TcpSocket::onDisconnected()
|
||||
{
|
||||
INFO_LOG() << "Disconnected from " << m_socket->peerAddress().toString()
|
||||
INFO_LOG(m_logger) << "Disconnected from " << m_socket->peerAddress().toString()
|
||||
<< ":" << m_socket->peerPort();
|
||||
}
|
||||
|
||||
void TcpSocket::onError(QAbstractSocket::SocketError err)
|
||||
{
|
||||
ERROR_LOG() << "Socket error: " << err
|
||||
ERROR_LOG(m_logger) << "Socket error: " << err
|
||||
<< " " << m_socket->errorString()
|
||||
<< ":" << m_socket->peerPort()
|
||||
<< " - trying to reconnect in " << m_waitTime << " seconds";
|
||||
|
||||
@@ -19,6 +19,7 @@ public:
|
||||
~TcpSocket();
|
||||
|
||||
protected:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void startThreadInternal(const QString &hostName, quint16 port);
|
||||
|
||||
void run() override;
|
||||
@@ -33,6 +34,7 @@ protected Q_SLOTS:
|
||||
virtual void onError(QAbstractSocket::SocketError);
|
||||
virtual void onReadyRead() = 0;
|
||||
protected:
|
||||
NGL::INGLLogger &m_logger;
|
||||
QString m_hostName;
|
||||
quint16 m_hostPort;
|
||||
QTcpSocket *m_socket;
|
||||
|
||||
@@ -17,11 +17,10 @@
|
||||
namespace FeedGeoJson
|
||||
{
|
||||
|
||||
FeedGeoJson::FeedGeoJson(QObject *parent)
|
||||
: QObject(parent)
|
||||
FeedGeoJson::FeedGeoJson(QObject *parent) : QObject(parent)
|
||||
, m_bTestsSuccessful(true)
|
||||
, m_refPos(LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32UMD8000090000")))
|
||||
{}
|
||||
, m_refPos(LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32UMD8000090000"))),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {}
|
||||
|
||||
FeedGeoJson::~FeedGeoJson()
|
||||
{}
|
||||
@@ -30,7 +29,7 @@ bool FeedGeoJson::init(const int domainId, const int exerciseId, WebSocketServe
|
||||
{
|
||||
m_websocketServer = &webSocketServer;
|
||||
bool bRet = true;
|
||||
INFO_LOG() << "init begin";
|
||||
INFO_LOG(m_logger) << "init begin";
|
||||
|
||||
m_ddsConnector42 = std::make_shared<DDSConnector::DdsConnector>(domainId, IDL::PartitionType::Exercise, exerciseId);
|
||||
m_ddsConnector42->init();
|
||||
@@ -104,15 +103,15 @@ return message;
|
||||
void FeedGeoJson::onParticipantPositionChanged(const ParticipantManagement::ParticipantPosition &data, DataModification modType)
|
||||
{
|
||||
NOTICE_LOG(m_logger) << "onParticipantPositionChanged: " << data;
|
||||
DEBUG_LOG() << "onParticipantPositionChanged: " << data;
|
||||
DEBUG_LOG(m_logger) << "onParticipantPositionChanged: " << data;
|
||||
if (modType == DataModification::eRemoved)
|
||||
{
|
||||
DEBUG_LOG() << "m_participantsOutsideMap.remove participantId: " << data.participantId();
|
||||
DEBUG_LOG(m_logger) << "m_participantsOutsideMap.remove participantId: " << data.participantId();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_LOG() << "Handle ParticipantPosition";
|
||||
DEBUG_LOG(m_logger) << "Handle ParticipantPosition";
|
||||
QString posGeoJson = getGeoJsonPosition(data);
|
||||
m_websocketServer->sendMessage(posGeoJson);
|
||||
}
|
||||
@@ -120,7 +119,7 @@ void FeedGeoJson::onParticipantPositionChanged(const ParticipantManagement::Part
|
||||
|
||||
void FeedGeoJson::onDynamicParticipantDataChanged(const ParticipantManagement::DynamicParticipantData &data, DataModification modType)
|
||||
{
|
||||
DEBUG_LOG() << "onDynamicParticipantDataChanged";
|
||||
DEBUG_LOG(m_logger) << "onDynamicParticipantDataChanged";
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
|
||||
@@ -129,14 +128,14 @@ void FeedGeoJson::onDynamicParticipantDataChanged(const ParticipantManagement::D
|
||||
|
||||
void FeedGeoJson::failExit()
|
||||
{
|
||||
DEBUG_LOG() << "FailExit";
|
||||
DEBUG_LOG(m_logger) << "FailExit";
|
||||
m_bTestsSuccessful = false;
|
||||
QTimer::singleShot(50, qApp, QCoreApplication::quit);
|
||||
}
|
||||
|
||||
void FeedGeoJson::ExitSuccess()
|
||||
{
|
||||
DEBUG_LOG() << "ExitSuccess";
|
||||
DEBUG_LOG(m_logger) << "ExitSuccess";
|
||||
m_bTestsSuccessful = true;
|
||||
QTimer::singleShot(200, qApp, &QCoreApplication::quit);
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ protected Q_SLOTS:
|
||||
|
||||
protected:
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
private:
|
||||
QString getGeoJsonPosition(const ParticipantManagement::ParticipantPosition &data);
|
||||
|
||||
|
||||
@@ -41,16 +41,16 @@ void AbstractSocketHandler::textMessageReceived(const QByteArray &msg)
|
||||
{
|
||||
if (msg.isEmpty())
|
||||
{
|
||||
ERROR_LOG() << "Empty message received";
|
||||
ERROR_LOG(m_logger) << "Empty message received";
|
||||
return;
|
||||
}
|
||||
const QJsonObject obj = QJsonDocument::fromJson(msg).object();
|
||||
DEBUG_LOG() << "incoming telegram: " << msg;
|
||||
DEBUG_LOG(m_logger) << "incoming telegram: " << msg;
|
||||
|
||||
const QJsonValue type = obj.value(QStringLiteral("type"));
|
||||
if (!type.isString())
|
||||
{
|
||||
ERROR_LOG() << "Can not read type id: " << msg;
|
||||
ERROR_LOG(m_logger) << "Can not read type id: " << msg;
|
||||
return;
|
||||
}
|
||||
const QString typeStr = type.toString();
|
||||
@@ -66,11 +66,11 @@ void AbstractSocketHandler::textMessageReceived(const QByteArray &msg)
|
||||
else if (typeStr.compare(Constraints<NasatSimulationStatus>::type(), Qt::CaseInsensitive) == 0)
|
||||
emit simulationStatusReceived(NasatSimulationStatus::fromJson(data));
|
||||
else
|
||||
ERROR_LOG() << "Got unknown json telegram: " << msg;
|
||||
ERROR_LOG(m_logger) << "Got unknown json telegram: " << msg;
|
||||
}
|
||||
catch (const JsonException &ex)
|
||||
{
|
||||
ERROR_LOG() << "Could not parse json telegram: " << msg
|
||||
ERROR_LOG(m_logger) << "Could not parse json telegram: " << msg
|
||||
<< ", error: " << ex.what();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,11 +30,13 @@ Q_SIGNALS:
|
||||
void simulationStatusReceived(const NasatSimulationStatus &data);
|
||||
|
||||
protected:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void textMessageReceived(const QByteArray &msg);
|
||||
bool sendTelegram(const NasatBase *tele);
|
||||
virtual bool sendTelegramInternal(const QByteArray &tele) = 0;
|
||||
|
||||
protected:
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -26,22 +26,22 @@ Participant2Dds::Participant2Dds(const dds::domain::DomainParticipant &domainPar
|
||||
|
||||
|
||||
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " create FTC..." << " exerciseId=" << exerciseId;
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " create FTC..." << " exerciseId=" << exerciseId;
|
||||
|
||||
m_aesFtc = AreaEffectSimulation::Interface::Ftc::create(m_ddsConnector);
|
||||
if (!m_aesFtc->enableAirSupportImpactModify())
|
||||
{
|
||||
ERROR_LOG() << "Could not enable AES AirSupportImpactModify FTC for"
|
||||
ERROR_LOG(m_logger) << "Could not enable AES AirSupportImpactModify FTC for"
|
||||
<< " exerciseId=" << exerciseId;
|
||||
m_aesFtc = nullptr;
|
||||
}
|
||||
if (!m_aesFtc->enableExplosionClusterModify())
|
||||
{
|
||||
ERROR_LOG() << "Could not enable AES enableExplosionClusterModify FTC for"
|
||||
ERROR_LOG(m_logger) << "Could not enable AES enableExplosionClusterModify FTC for"
|
||||
<< " exerciseId=" << exerciseId;
|
||||
m_aesFtc = nullptr;
|
||||
}
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " create FTC..." << " exerciseId=" << exerciseId << " Done: " << m_aesFtc.get();
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " create FTC..." << " exerciseId=" << exerciseId << " Done: " << m_aesFtc.get();
|
||||
}
|
||||
|
||||
bool Participant2Dds::publish(const TrainingAreaBase::EquipmentPosition &pos)
|
||||
@@ -51,7 +51,7 @@ bool Participant2Dds::publish(const TrainingAreaBase::EquipmentPosition &pos)
|
||||
m_tabDts = TrainingAreaBase::Interface::Dts::create(m_ddsConnector);
|
||||
if (!m_tabDts->enableEquipmentPosition())
|
||||
{
|
||||
ERROR_LOG() << "Could not enable TAB equipment position DTS for "
|
||||
ERROR_LOG(m_logger) << "Could not enable TAB equipment position DTS for "
|
||||
<< m_ddsConnector->getDefaultPartition();
|
||||
m_tabDts = nullptr;
|
||||
return false;
|
||||
@@ -80,7 +80,7 @@ bool Participant2Dds::publish(const GuezNasat::Nasat9Liner &nl)
|
||||
m_gnaDts = GuezNasat::Interface::Dts::create(m_ddsConnector);
|
||||
if (!m_gnaDts->enableNasat9Liner())
|
||||
{
|
||||
ERROR_LOG() << "Could not enable GNA Nasat9Liner DTS for "
|
||||
ERROR_LOG(m_logger) << "Could not enable GNA Nasat9Liner DTS for "
|
||||
<< m_ddsConnector->getDefaultPartition();
|
||||
m_gnaDts = nullptr;
|
||||
return false;
|
||||
@@ -92,13 +92,13 @@ bool Participant2Dds::publish(const GuezNasat::Nasat9Liner &nl)
|
||||
|
||||
void Participant2Dds::addParticipantToWatch(int participantId)
|
||||
{
|
||||
DEBUG_LOG() << "addParticipantToWatch: " << participantId;
|
||||
DEBUG_LOG(m_logger) << "addParticipantToWatch: " << participantId;
|
||||
m_participantsToWatch += participantId;
|
||||
}
|
||||
|
||||
void Participant2Dds::removeParticipantToWatch(int participantId)
|
||||
{
|
||||
DEBUG_LOG() << "removeParticipantToWatch: " << participantId;
|
||||
DEBUG_LOG(m_logger) << "removeParticipantToWatch: " << participantId;
|
||||
m_participantsToWatch -= participantId;
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ void Participant2Dds::onParticipantChanged(const ParticipantManagement::Particip
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
DEBUG_LOG() << "onParticipantChanged: " << data.id()
|
||||
DEBUG_LOG(m_logger) << "onParticipantChanged: " << data.id()
|
||||
<< ", " << m_participantsToWatch.contains(data.id())
|
||||
<< ", " << m_participantsToWatch.size()
|
||||
<< ", " << m_participantsToWatch.contains(data.id())
|
||||
@@ -138,16 +138,16 @@ void Participant2Dds::onParticipantChanged(const ParticipantManagement::Particip
|
||||
DdsHandler::DdsHandler(const std::shared_ptr<DDSConnector::DdsConnector> &ddsConnector)
|
||||
: m_ddsConnector(std::make_shared<DDSConnector::DdsConnector>(ddsConnector->getDomainParticipant(), IDL::PartitionType::AllExercises))
|
||||
{
|
||||
DEBUG_LOG() << "DdsHandler(" << m_ddsConnector->getDomainId() << ") for partition: " << m_ddsConnector->getDefaultPartition();
|
||||
DEBUG_LOG(m_logger) << "DdsHandler(" << m_ddsConnector->getDomainId() << ") for partition: " << m_ddsConnector->getDefaultPartition();
|
||||
}
|
||||
|
||||
bool DdsHandler::init(const QStringList &qosFileList)
|
||||
{
|
||||
INFO_LOG() << "--- Start GuezNasat DDSHandler.";
|
||||
INFO_LOG(m_logger) << "--- Start GuezNasat DDSHandler.";
|
||||
|
||||
if (!m_ddsConnector->init(qosFileList))
|
||||
{
|
||||
ERROR_LOG() << "Error initializing dds connections - aborting";
|
||||
ERROR_LOG(m_logger) << "Error initializing dds connections - aborting";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -158,22 +158,22 @@ bool DdsHandler::init(const QStringList &qosFileList)
|
||||
m_ddsDts = GuezNasat::Interface::Dts::create(m_ddsConnector);
|
||||
bool bRet = m_ddsDts->enableNasatAircraft() &&
|
||||
m_ddsDts->enableNasatAircraftParticipant();
|
||||
INFO_LOG() << "Dts initialised: " << bRet;
|
||||
INFO_LOG(m_logger) << "Dts initialised: " << bRet;
|
||||
|
||||
|
||||
m_ddsFts = GuezNasat::Interface::Fts::create(m_ddsConnector);
|
||||
bRet &= m_ddsFts->enableAll();
|
||||
INFO_LOG() << "Fts initialised: " << bRet;
|
||||
INFO_LOG(m_logger) << "Fts initialised: " << bRet;
|
||||
|
||||
|
||||
m_exmDtc = ExerciseManagement::Interface::Dtc::create(m_ddsConnector);
|
||||
bRet &= m_exmDtc->enableExercise();
|
||||
INFO_LOG() << "EXM Dtc initialised: " << bRet;
|
||||
INFO_LOG(m_logger) << "EXM Dtc initialised: " << bRet;
|
||||
|
||||
|
||||
m_pdmDtc = ProjectDataManagement::Interface::Dtc::create(m_ddsConnector);
|
||||
bRet &= m_pdmDtc->enableChargeType();
|
||||
INFO_LOG() << "PDM Dtc initialised: " << bRet;
|
||||
INFO_LOG(m_logger) << "PDM Dtc initialised: " << bRet;
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ public:
|
||||
Q_SIGNALS:
|
||||
void participantRemoved(int exerciseId, int participantId);
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void onParticipantChanged(const ParticipantManagement::Participant &data, DataModification modType);
|
||||
private:
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
|
||||
|
||||
@@ -84,16 +84,16 @@ void HandlerNasatAircraft::flaFluSimulationChanged(int nasatId, bool bSimulation
|
||||
m_dts->publish(na);
|
||||
return;
|
||||
}
|
||||
WARNING_LOG() << "Got a flaFluSimulationChanged information but aircraft with id " << nasatId << " is not available";
|
||||
WARNING_LOG(m_logger) << "Got a flaFluSimulationChanged information but aircraft with id " << nasatId << " is not available";
|
||||
}
|
||||
|
||||
void HandlerNasatAircraft::onModifyNasatAircraftRequest(const rti::core::SampleIdentity &cookie,
|
||||
const NasatAircraft &request)
|
||||
{
|
||||
DEBUG_LOG() << "onModifyNasatAircraftRequest: " << request;
|
||||
DEBUG_LOG(m_logger) << "onModifyNasatAircraftRequest: " << request;
|
||||
auto ret = request.id() > 0 ? modifyNasatAircraftRequest(request) : createNasatAircraftRequest(request);
|
||||
if (ret.error())
|
||||
WARNING_LOG() << ret();
|
||||
WARNING_LOG(m_logger) << ret();
|
||||
m_fts->modifyNasatAircraftReply(cookie, ret);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ Q_SIGNALS:
|
||||
void activateNasatAircraftSimulation(int nasatId, bool bActivateSimulation);
|
||||
void nasatIdChanged(int oldNasatId, int newNasatId);
|
||||
protected:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void onModifyNasatAircraftRequest(const rti::core::SampleIdentity &cookie,
|
||||
const NasatAircraft &request) override;
|
||||
Core::FunctionReplyObject createNasatAircraftRequest(const NasatAircraft &request);
|
||||
|
||||
+31
-31
@@ -40,26 +40,26 @@ HandlerNasatAircraftParticipant::HandlerNasatAircraftParticipant(Initialization
|
||||
, m_fts(mainHandler->dds()->fts())
|
||||
, m_db(mainHandler->db())
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " START";
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " END";
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
}
|
||||
|
||||
HandlerNasatAircraftParticipant::~HandlerNasatAircraftParticipant()
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " START";
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
for (const auto &data : std::as_const(m_nasatAircraftParticipants))
|
||||
m_dts->removeNasatAircraftByKey(data.id());
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " END";
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
}
|
||||
|
||||
bool HandlerNasatAircraftParticipant::init()
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " START";
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
|
||||
auto cb = [this](const Database::NasatAircraftParticipant & data)
|
||||
{
|
||||
const auto dds(fromDb(data));
|
||||
DEBUG_LOG() << "m_nasatAircraftParticipants.insert(" << dds.id() << ")";
|
||||
DEBUG_LOG(m_logger) << "m_nasatAircraftParticipants.insert(" << dds.id() << ")";
|
||||
m_nasatAircraftParticipants.insert(dds.id(), dds);
|
||||
m_dts->publish(dds);
|
||||
m_mainHandler->handlerParticipant()->onNasatAircraftParticipantCreated(dds);
|
||||
@@ -85,16 +85,16 @@ bool HandlerNasatAircraftParticipant::init()
|
||||
dumpExercises();
|
||||
});
|
||||
|
||||
DEBUG_LOG() << "HandlerNasatAircraftParticipant init done";
|
||||
DEBUG_LOG(m_logger) << "HandlerNasatAircraftParticipant init done";
|
||||
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " START";
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
return true;
|
||||
}
|
||||
|
||||
void HandlerNasatAircraftParticipant::dumpNasatAircraftParticipants()
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " START, size=" << m_nasatAircraftParticipants.size();
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " --------------------------------------";
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " START, size=" << m_nasatAircraftParticipants.size();
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " --------------------------------------";
|
||||
|
||||
auto it = m_nasatAircraftParticipants.begin();
|
||||
while (it != m_nasatAircraftParticipants.end())
|
||||
@@ -102,17 +102,17 @@ void HandlerNasatAircraftParticipant::dumpNasatAircraftParticipants()
|
||||
const auto &id = it.key();
|
||||
const auto &nap = it.value();
|
||||
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " id=" << id << " - nap=" << nap;
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " id=" << id << " - nap=" << nap;
|
||||
++it;
|
||||
}
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " --------------------------------------";
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " END, size=" << m_nasatAircraftParticipants.size();
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " --------------------------------------";
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " END, size=" << m_nasatAircraftParticipants.size();
|
||||
}
|
||||
|
||||
void HandlerNasatAircraftParticipant::dumpExercises()
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " START, size=" << m_exercises.size();
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " --------------------------------------";
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " START, size=" << m_exercises.size();
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " --------------------------------------";
|
||||
|
||||
auto it = m_exercises.begin();
|
||||
while (it != m_exercises.end())
|
||||
@@ -120,11 +120,11 @@ void HandlerNasatAircraftParticipant::dumpExercises()
|
||||
const auto &id = it.key();
|
||||
const auto &nasatAircraftParticipant = it.value();
|
||||
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " id=" << id << " - nasatAircraftParticipant=" << nasatAircraftParticipant;
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " id=" << id << " - nasatAircraftParticipant=" << nasatAircraftParticipant;
|
||||
++it;
|
||||
}
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " --------------------------------------";
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " END, size=" << m_exercises.size();
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " --------------------------------------";
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " END, size=" << m_exercises.size();
|
||||
}
|
||||
|
||||
void HandlerNasatAircraftParticipant::aircraftRemoved(int nasatAircraftId)
|
||||
@@ -145,7 +145,7 @@ void HandlerNasatAircraftParticipant::aircraftRemoved(int nasatAircraftId)
|
||||
|
||||
void HandlerNasatAircraftParticipant::participantRemoved(int exerciseId, int participantId)
|
||||
{
|
||||
DEBUG_LOG() << "participantRemoved: " << exerciseId << ", " << participantId;
|
||||
DEBUG_LOG(m_logger) << "participantRemoved: " << exerciseId << ", " << participantId;
|
||||
auto it = m_nasatAircraftParticipants.begin();
|
||||
while (it != m_nasatAircraftParticipants.end())
|
||||
{
|
||||
@@ -179,7 +179,7 @@ bool isExerciseStateValid(ExerciseManagement::ExerciseState_def::type state)
|
||||
|
||||
void HandlerNasatAircraftParticipant::onExerciseChanged(const ExerciseManagement::Exercise &exercise, DataModification modType)
|
||||
{
|
||||
INFO_LOG() << Q_FUNC_INFO << " START" << " , exercise" << exercise << " , modType" << modType;
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " START" << " , exercise" << exercise << " , modType" << modType;
|
||||
|
||||
const int exId = exercise.id();
|
||||
switch (modType)
|
||||
@@ -190,10 +190,10 @@ void HandlerNasatAircraftParticipant::onExerciseChanged(const ExerciseManagement
|
||||
const bool valid = isExerciseStateValid(exercise.state().underlying());
|
||||
if (!valid)
|
||||
{
|
||||
INFO_LOG() << Q_FUNC_INFO << " STATE of exId=" << exId
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " STATE of exId=" << exId
|
||||
<< " , state=" << exercise.state();
|
||||
int cnt = removeNapsOfExercise(exId);
|
||||
INFO_LOG() << Q_FUNC_INFO << " STATE of exId=" << exId << " not valid : counter of removed naps=" << cnt;
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " STATE of exId=" << exId << " not valid : counter of removed naps=" << cnt;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -205,11 +205,11 @@ void HandlerNasatAircraftParticipant::onExerciseChanged(const ExerciseManagement
|
||||
const bool valid = isExerciseStateValid(exercise.state().underlying());
|
||||
if (!valid)
|
||||
{
|
||||
INFO_LOG() << Q_FUNC_INFO << " STATE change of exId=" << exId
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " STATE change of exId=" << exId
|
||||
<< " , old state=" << exerciseRef.state()
|
||||
<< " , new state=" << exercise.state();
|
||||
int cnt = removeNapsOfExercise(exId);
|
||||
INFO_LOG() << Q_FUNC_INFO << " STATE change of exId=" << exId << " : counter of removed naps=" << cnt;
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " STATE change of exId=" << exId << " : counter of removed naps=" << cnt;
|
||||
}
|
||||
}
|
||||
m_exercises[exId] = exercise;
|
||||
@@ -218,13 +218,13 @@ void HandlerNasatAircraftParticipant::onExerciseChanged(const ExerciseManagement
|
||||
case DataModification::eRemoved:
|
||||
{
|
||||
int cnt = removeNapsOfExercise(exId);
|
||||
INFO_LOG() << Q_FUNC_INFO << " STATE change of Exercise, counter of removed naps=" << cnt;
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " STATE change of Exercise, counter of removed naps=" << cnt;
|
||||
|
||||
m_exercises.remove(exId);
|
||||
}
|
||||
break;
|
||||
}
|
||||
INFO_LOG() << Q_FUNC_INFO << " END" << " , exercise" << exercise << " , modType" << modType;
|
||||
INFO_LOG(m_logger) << Q_FUNC_INFO << " END" << " , exercise" << exercise << " , modType" << modType;
|
||||
}
|
||||
|
||||
void HandlerNasatAircraftParticipant::removeNasatAircraftParticipant(const NasatAircraftParticipant &val)
|
||||
@@ -238,10 +238,10 @@ void HandlerNasatAircraftParticipant::removeNasatAircraftParticipant(const Nasat
|
||||
void HandlerNasatAircraftParticipant::onModifyNasatAircraftParticipantRequest(const rti::core::SampleIdentity &cookie,
|
||||
const NasatAircraftParticipant &request)
|
||||
{
|
||||
DEBUG_LOG() << "onModifyNasatAircraftParticipantRequest: " << request;
|
||||
DEBUG_LOG(m_logger) << "onModifyNasatAircraftParticipantRequest: " << request;
|
||||
auto ret = request.id() <= 0 ? createNasatAircraftParticipantRequest(request) : modifyNasatAircraftParticipantRequest(request);
|
||||
if (ret.error())
|
||||
WARNING_LOG() << ret();
|
||||
WARNING_LOG(m_logger) << ret();
|
||||
m_fts->modifyNasatAircraftParticipantReply(cookie, ret);
|
||||
}
|
||||
|
||||
@@ -299,7 +299,7 @@ Core::FunctionReplyObject HandlerNasatAircraftParticipant::modifyNasatAircraftPa
|
||||
|
||||
int HandlerNasatAircraftParticipant::removeNapsOfExercise(int exerciseId)
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " START, exerciseId=" << exerciseId
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " START, exerciseId=" << exerciseId
|
||||
<< ", m_nasatAircraftParticipants.size()" << m_nasatAircraftParticipants.size();
|
||||
int count = 0;
|
||||
QHash<int, NasatAircraftParticipant> napsCopy = m_nasatAircraftParticipants;
|
||||
@@ -308,7 +308,7 @@ int HandlerNasatAircraftParticipant::removeNapsOfExercise(int exerciseId)
|
||||
{
|
||||
if (nap.exerciseId() == exerciseId)
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " nap has to be removed: nap=" << nap;
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " nap has to be removed: nap=" << nap;
|
||||
|
||||
NasatAircraftParticipant napToTriggerRemoving;
|
||||
napToTriggerRemoving.id(nap.id());
|
||||
@@ -319,7 +319,7 @@ int HandlerNasatAircraftParticipant::removeNapsOfExercise(int exerciseId)
|
||||
++count;
|
||||
}
|
||||
}
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " END, exerciseId=" << exerciseId
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " END, exerciseId=" << exerciseId
|
||||
<< ", m_nasatAircraftParticipants.size()" << m_nasatAircraftParticipants.size()
|
||||
<< ", counter=" << count;
|
||||
return count;
|
||||
|
||||
+1
@@ -38,6 +38,7 @@ public Q_SLOTS:
|
||||
void dumpExercises();
|
||||
|
||||
protected:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void removeNasatAircraftParticipant(const NasatAircraftParticipant &val);
|
||||
void onModifyNasatAircraftParticipantRequest(const rti::core::SampleIdentity &cookie,
|
||||
const NasatAircraftParticipant &request) override;
|
||||
|
||||
@@ -23,7 +23,7 @@ HandlerNasatImpact::HandlerNasatImpact(Initialization *mainHandler)
|
||||
: AreaEffectSimulation::Interface::Ftc::AirSupportImpactModifyReplyHandler()
|
||||
, m_mainHandler(mainHandler)
|
||||
{
|
||||
TRACE_LOG() << Q_FUNC_INFO << " START";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
auto pdmDtc = m_mainHandler->dds()->pdmDtc();
|
||||
connect(pdmDtc.get(), &ProjectDataManagement::Interface::Dtc::chargeTypeChanged,
|
||||
this, &HandlerNasatImpact::onChargeTypeChanged);
|
||||
@@ -59,32 +59,32 @@ HandlerNasatImpact::HandlerNasatImpact(Initialization *mainHandler)
|
||||
|
||||
#endif
|
||||
|
||||
TRACE_LOG() << Q_FUNC_INFO << " END";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
}
|
||||
|
||||
void HandlerNasatImpact::onAirSupportImpactModifyReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
if (reply.error())
|
||||
WARNING_LOG() << "Could not create single explosion for nasat impact: " << reply();
|
||||
WARNING_LOG(m_logger) << "Could not create single explosion for nasat impact: " << reply();
|
||||
|
||||
#ifdef NLDEVCTRL_844
|
||||
testing.replyCounter++;
|
||||
INFO_LOG() << "Got create reply: " << reply() << "(id=" << reply.id() << ")"
|
||||
INFO_LOG(m_logger) << "Got create reply: " << reply() << "(id=" << reply.id() << ")"
|
||||
<< ", this=" << this
|
||||
<< " - replyCounter=" << testing.replyCounter;
|
||||
#else
|
||||
INFO_LOG() << "Got create reply: " << reply() << "(id=" << reply.id() << ")"
|
||||
INFO_LOG(m_logger) << "Got create reply: " << reply() << "(id=" << reply.id() << ")"
|
||||
<< ", this=" << this;
|
||||
#endif
|
||||
}
|
||||
|
||||
void HandlerNasatImpact::onExplosionClusterModifyReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
INFO_LOG() << "Got create reply: " << reply() << "(id=" << reply.id() << ")"
|
||||
INFO_LOG(m_logger) << "Got create reply: " << reply() << "(id=" << reply.id() << ")"
|
||||
<< ", this=" << this
|
||||
<< ", reply.error()=" << reply.error();
|
||||
if (reply.error())
|
||||
ERROR_LOG() << "onExplosionClusterModifyReply: Got reply: " << reply() << "(id=" << reply.id() << ")"
|
||||
ERROR_LOG(m_logger) << "onExplosionClusterModifyReply: Got reply: " << reply() << "(id=" << reply.id() << ")"
|
||||
<< " '" << reply.translated() << "'";
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ void HandlerNasatImpact::nasatImpact(int nasatId, const Core::GeoPosition &pos,
|
||||
return;
|
||||
#endif
|
||||
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " START, nasatId=" << nasatId
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " START, nasatId=" << nasatId
|
||||
<< ", pos=" << pos
|
||||
<< ", flightTimeMsec = " << flightTimeMsec
|
||||
<< ", impactTimeMsec = " << impactTimeMsec;
|
||||
@@ -121,7 +121,7 @@ void HandlerNasatImpact::nasatImpact(int nasatId, const Core::GeoPosition &pos,
|
||||
const auto participants = m_mainHandler->handlerParticipant()->participantsForNasatId(nasatId);
|
||||
if (participants.isEmpty())
|
||||
{
|
||||
WARNING_LOG() << "Can not find a valid participant for nasat aircraft with id " << nasatId;
|
||||
WARNING_LOG(m_logger) << "Can not find a valid participant for nasat aircraft with id " << nasatId;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ void HandlerNasatImpact::nasatImpact(int nasatId, const Core::GeoPosition &pos,
|
||||
if (m_logger.isDebugEnabled())
|
||||
{
|
||||
const Core::GeoPosition &nasatPos = m_mainHandler->handlerParticipant()->nasatPosition(nasatId);
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " START, nasatId=" << nasatId
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " START, nasatId=" << nasatId
|
||||
<< ", pos=" << nasatPos
|
||||
<< ", flightTimeMsec = " << flightTimeMsec
|
||||
<< ", impactTimeMsec=" << impactTimeMsec;
|
||||
@@ -191,7 +191,7 @@ void HandlerNasatImpact::nasatImpact(int nasatId, const Core::GeoPosition &pos,
|
||||
|
||||
|
||||
|
||||
DEBUG_LOG() << " Sending air support impact: number of participant= " << participants.size();
|
||||
DEBUG_LOG(m_logger) << " Sending air support impact: number of participant= " << participants.size();
|
||||
for (const NasatAircraftParticipantEx *nap : participants)
|
||||
{
|
||||
|
||||
@@ -205,17 +205,17 @@ void HandlerNasatImpact::nasatImpact(int nasatId, const Core::GeoPosition &pos,
|
||||
|
||||
int success = nap->publisher()->publish(ecCommonModifyRequest, this);
|
||||
if (success)
|
||||
DEBUG_LOG() << "Sending air support impact create request: " << ecReq << " to exercise " << nap->exerciseId()
|
||||
DEBUG_LOG(m_logger) << "Sending air support impact create request: " << ecReq << " to exercise " << nap->exerciseId()
|
||||
<< ", nap=" << nap->participant()
|
||||
<< " -> success = " << success;
|
||||
else
|
||||
ERROR_LOG() << "Error on Sending air support impact create request: " << ecReq << " to exercise " << nap->exerciseId()
|
||||
ERROR_LOG(m_logger) << "Error on Sending air support impact create request: " << ecReq << " to exercise " << nap->exerciseId()
|
||||
<< ", nap=" << nap->participant()
|
||||
<< " -> success = " << success;
|
||||
|
||||
#ifdef NLDEVCTRL_844
|
||||
testing.requestCounter++;
|
||||
INFO_LOG() << " requestCounter = " << testing.requestCounter;
|
||||
INFO_LOG(m_logger) << " requestCounter = " << testing.requestCounter;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -254,7 +254,7 @@ void HandlerNasatImpact::onChargeTypeChanged(const ProjectDataManagement::Charge
|
||||
int nasatId = obj.value(QLatin1String("nasatId")).toInt();
|
||||
if (nasatId == 0)
|
||||
{
|
||||
WARNING_LOG() << "Found charge with an invalid property 'nasatId', id: " << ct.id();
|
||||
WARNING_LOG(m_logger) << "Found charge with an invalid property 'nasatId', id: " << ct.id();
|
||||
return;
|
||||
}
|
||||
m_chargeMapping.insert(nasatId, ct.id());
|
||||
@@ -266,7 +266,7 @@ int HandlerNasatImpact::chargeTypeFromMunitionCode(int nasatChargeCode) const
|
||||
auto it = m_chargeMapping.find(nasatChargeCode);
|
||||
if (it != m_chargeMapping.end())
|
||||
return it.value();
|
||||
WARNING_LOG() << "Got unmapped nasat charge code " << nasatChargeCode;
|
||||
WARNING_LOG(m_logger) << "Got unmapped nasat charge code " << nasatChargeCode;
|
||||
Q_ASSERT(false);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -30,9 +30,11 @@ public Q_SLOTS:
|
||||
void nasatImpact(int nasatId, const Core::GeoPosition &pos, qint64 flightTimeMsec, qint64 impactTimeMsec, int munitionCode, FuseType fuseType = FuseType::Instant);
|
||||
void onChargeTypeChanged(const ProjectDataManagement::ChargeType &ct);
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
int chargeTypeFromMunitionCode(int nasatChargeCode) const;
|
||||
int fuseTypeToPdmIgniterType(FuseType fusetype) const;
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
Initialization *m_mainHandler;
|
||||
QHash<int, int> m_chargeMapping;
|
||||
#ifdef NLDEVCTRL_844
|
||||
|
||||
@@ -25,7 +25,7 @@ bool HandlerNasatNineLiner::init() const
|
||||
connect(m_mainHandler->handlerParticipant().get(), &HandlerParticipant::nasatAircraftParticipantRemoved,
|
||||
this, &HandlerNasatNineLiner::onNasatAircraftParticipantRemoved, Qt::DirectConnection);
|
||||
|
||||
DEBUG_LOG() << "HandlerNasatNineLiner init done";
|
||||
DEBUG_LOG(m_logger) << "HandlerNasatNineLiner init done";
|
||||
|
||||
|
||||
return true;
|
||||
@@ -108,18 +108,18 @@ static Nasat9Liner createDds9Liner(const NasatNineLiner &nasatNineLiner)
|
||||
void HandlerNasatNineLiner::nineLinerReceived(const NasatNineLiner &nasatNineLiner)
|
||||
{
|
||||
|
||||
DEBUG_LOG() << "nineLinerReceived, aircraftId=" << nasatNineLiner.aircraftId
|
||||
DEBUG_LOG(m_logger) << "nineLinerReceived, aircraftId=" << nasatNineLiner.aircraftId
|
||||
<< " - nasatNineLiner.aircraftId is aka nasatId";
|
||||
|
||||
const auto participants = m_mainHandler->handlerParticipant()->participantsForNasatId(nasatNineLiner.aircraftId);
|
||||
if (participants.isEmpty())
|
||||
{
|
||||
INFO_LOG() << "No exercise participants found to publish 9-liner for nasat aircraft with id "
|
||||
INFO_LOG(m_logger) << "No exercise participants found to publish 9-liner for nasat aircraft with id "
|
||||
<< nasatNineLiner.aircraftId;
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG_LOG() << "nineLinerReceived, publishing to exercises";
|
||||
DEBUG_LOG(m_logger) << "nineLinerReceived, publishing to exercises";
|
||||
|
||||
static int s_id = 1;
|
||||
Nasat9Liner nl = createDds9Liner(nasatNineLiner);
|
||||
@@ -129,7 +129,7 @@ void HandlerNasatNineLiner::nineLinerReceived(const NasatNineLiner &nasatNineLin
|
||||
const auto &exerciseParticipantId = it.key();
|
||||
auto nape = it.value();
|
||||
|
||||
DEBUG_LOG() << "nineLinerReceived, publishing to exercises, s_id=" << s_id
|
||||
DEBUG_LOG(m_logger) << "nineLinerReceived, publishing to exercises, s_id=" << s_id
|
||||
<< ", exerciseParticipantId.exerciseId=" << exerciseParticipantId.exerciseId
|
||||
<< ", exerciseParticipantId.participantId=" << exerciseParticipantId.participantId;
|
||||
|
||||
@@ -171,17 +171,17 @@ void HandlerNasatNineLiner::onNasatAircraftParticipantRemoved(const NasatAircraf
|
||||
|
||||
|
||||
const int nasatId = m_mainHandler->nasatAircraft()->nasatIdFromNasatAircraftId(nap.nasatAircraftId());
|
||||
INFO_LOG() << " onNasatAircraftParticipantRemoved, nap = " << nap << ", nasatId = " << nasatId;
|
||||
INFO_LOG(m_logger) << " onNasatAircraftParticipantRemoved, nap = " << nap << ", nasatId = " << nasatId;
|
||||
if (nasatId < 0)
|
||||
{
|
||||
WARNING_LOG() << " nasatIdFromNasatAircraftId failed, nap=" << nap;
|
||||
WARNING_LOG(m_logger) << " nasatIdFromNasatAircraftId failed, nap=" << nap;
|
||||
return;
|
||||
}
|
||||
|
||||
const auto participants = m_mainHandler->handlerParticipant()->participantsForNasatId(nasatId);
|
||||
if (participants.isEmpty())
|
||||
{
|
||||
INFO_LOG() << "No exercise participants found to publish 9-liner for nasat aircraft with id "
|
||||
INFO_LOG(m_logger) << "No exercise participants found to publish 9-liner for nasat aircraft with id "
|
||||
<< nap.nasatAircraftId();
|
||||
return;
|
||||
}
|
||||
@@ -192,7 +192,7 @@ void HandlerNasatNineLiner::onNasatAircraftParticipantRemoved(const NasatAircraf
|
||||
auto nape = it.value();
|
||||
auto &nineLinerParticipant = m_nineLiner[exerciseParticipantId];
|
||||
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " updating for removing "
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " updating for removing "
|
||||
<< ", exerciseParticipantId.exerciseId=" << exerciseParticipantId.exerciseId
|
||||
<< ", exerciseParticipantId.participantId=" << exerciseParticipantId.participantId
|
||||
<< ", nineLinerParticipant.isEmpty()=" << nineLinerParticipant.isEmpty();
|
||||
@@ -202,7 +202,7 @@ void HandlerNasatNineLiner::onNasatAircraftParticipantRemoved(const NasatAircraf
|
||||
auto &oldLast = nineLinerParticipant.last();
|
||||
if (oldLast.isCurrent())
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " updating for removing "
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " updating for removing "
|
||||
<< ", exerciseParticipantId.exerciseId=" << exerciseParticipantId.exerciseId
|
||||
<< ", exerciseParticipantId.participantId=" << exerciseParticipantId.participantId;
|
||||
oldLast.sampleTime(QDateTime::currentMSecsSinceEpoch());
|
||||
|
||||
@@ -26,6 +26,7 @@ public Q_SLOTS:
|
||||
void onNasatAircraftParticipantRemoved(const NasatAircraftParticipant &nap);
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
QHash<ExerciseParticipantKey, QVector<Nasat9Liner>> m_nineLiner;
|
||||
Initialization *m_mainHandler;
|
||||
};
|
||||
|
||||
@@ -20,24 +20,24 @@ namespace GuezNasat
|
||||
NasatAircraftParticipantEx::NasatAircraftParticipantEx()
|
||||
: m_logger(getLogger("NasatAircraftParticipantEx"))
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " START";
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " END";
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
}
|
||||
|
||||
NasatAircraftParticipantEx::NasatAircraftParticipantEx(const NasatAircraftParticipant &nap, const std::shared_ptr<Participant2Dds> &publisher)
|
||||
: m_nap(nap)
|
||||
, m_publisher(publisher)
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " START";
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
m_publisher->addParticipantToWatch(m_nap.participantId());
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " END";
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
}
|
||||
|
||||
NasatAircraftParticipantEx::~NasatAircraftParticipantEx()
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " START";
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
m_publisher->removeParticipantToWatch(m_nap.participantId());
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " END";
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
}
|
||||
|
||||
int NasatAircraftParticipantEx::partyId() const
|
||||
@@ -82,23 +82,23 @@ void HandlerParticipant::onNasatAircraftParticipantRemoved(const NasatAircraftPa
|
||||
auto it = m_activePublisher.find(nasatId);
|
||||
if (it == m_activePublisher.end())
|
||||
{
|
||||
WARNING_LOG() << "No publisher for NasatAircraftParticipant " << nasatId << "(" << nap.nasatAircraftId() << ") found !?";
|
||||
WARNING_LOG(m_logger) << "No publisher for NasatAircraftParticipant " << nasatId << "(" << nap.nasatAircraftId() << ") found !?";
|
||||
return;
|
||||
}
|
||||
auto itParticipants = it.value().find(ExerciseParticipantKey(nap.exerciseId(), nap.participantId()));
|
||||
if (itParticipants == it.value().end())
|
||||
{
|
||||
WARNING_LOG() << "No participant entry for NasatAircraftParticipant " << nasatId << "("
|
||||
WARNING_LOG(m_logger) << "No participant entry for NasatAircraftParticipant " << nasatId << "("
|
||||
<< nap.exerciseId() << "," << nap.participantId() << ") found !?";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
DEBUG_LOG() << " emit nasatAircraftParticipantRemoved, nap = " << nap;
|
||||
DEBUG_LOG(m_logger) << " emit nasatAircraftParticipantRemoved, nap = " << nap;
|
||||
emit nasatAircraftParticipantRemoved(nap);
|
||||
|
||||
|
||||
DEBUG_LOG() << "Remove position publisher for " << nap;
|
||||
DEBUG_LOG(m_logger) << "Remove position publisher for " << nap;
|
||||
|
||||
|
||||
NasatAircraftParticipantEx* napeCopy= itParticipants.value();
|
||||
@@ -119,11 +119,11 @@ void HandlerParticipant::onNasatAircraftParticipantRemoved(const NasatAircraftPa
|
||||
|
||||
Core::GeoPosition HandlerParticipant::nasatPosition(int nasatId) const
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " START, nasatId=" << nasatId;
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " START, nasatId=" << nasatId;
|
||||
auto it = m_lastNasatPositionsAsCoreGeoposition.find(nasatId);
|
||||
if (it == m_lastNasatPositionsAsCoreGeoposition.end())
|
||||
{
|
||||
INFO_LOG() << "No NasatPosition for nasat id " << nasatId << " found";
|
||||
INFO_LOG(m_logger) << "No NasatPosition for nasat id " << nasatId << " found";
|
||||
return {};
|
||||
}
|
||||
return *it;
|
||||
@@ -131,7 +131,7 @@ Core::GeoPosition HandlerParticipant::nasatPosition(int nasatId) const
|
||||
|
||||
void HandlerParticipant::onNasatPosition(const NasatPosition &position)
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " START, position.aircraftId=" << position.aircraftId;
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " START, position.aircraftId=" << position.aircraftId;
|
||||
const Core::GeoPosition geoPos(position.position.lon * LtsCoordTrans::deg2rad(),
|
||||
position.position.lat * LtsCoordTrans::deg2rad(),
|
||||
position.position.height);
|
||||
@@ -144,11 +144,11 @@ void HandlerParticipant::onNasatPosition(const NasatPosition &position)
|
||||
|
||||
void HandlerParticipant::onNasatAircraftPosition(int nasatId, const Core::GeoPosition &pos, qint64 ts)
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " START, nasatId=" << nasatId;
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " START, nasatId=" << nasatId;
|
||||
auto it = m_activePublisher.find(nasatId);
|
||||
if (it == m_activePublisher.end())
|
||||
{
|
||||
INFO_LOG() << "No position publisher for nasat id " << nasatId << " found - ignoring " << m_activePublisher.size();
|
||||
INFO_LOG(m_logger) << "No position publisher for nasat id " << nasatId << " found - ignoring " << m_activePublisher.size();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -161,11 +161,11 @@ void HandlerParticipant::onNasatAircraftPosition(int nasatId, const Core::GeoPos
|
||||
tabPos.equipmentNumber(-napEx->participantId());
|
||||
int success = napEx->publisher()->publish(tabPos);
|
||||
if (success)
|
||||
DEBUG_LOG() << "Publishing positon: " << tabPos << " to exercise " << napEx->exerciseId()
|
||||
DEBUG_LOG(m_logger) << "Publishing positon: " << tabPos << " to exercise " << napEx->exerciseId()
|
||||
<< ", napEx: " << napEx->participant()
|
||||
<< " -> success = " << success;
|
||||
else
|
||||
ERROR_LOG() << "Error on Publishing positon: " << tabPos << " to exercise " << napEx->exerciseId()
|
||||
ERROR_LOG(m_logger) << "Error on Publishing positon: " << tabPos << " to exercise " << napEx->exerciseId()
|
||||
<< ", napEx: " << napEx->participant()
|
||||
<< " -> success = " << success;
|
||||
|
||||
@@ -180,7 +180,7 @@ void HandlerParticipant::onNasatIdChanged(int oldNasatId, int newNasatId)
|
||||
|
||||
void HandlerParticipant::createNasatAircraftParticipant(const NasatAircraftParticipant &nap, int nasatId)
|
||||
{
|
||||
DEBUG_LOG() << "Creating position publisher for " << nap
|
||||
DEBUG_LOG(m_logger) << "Creating position publisher for " << nap
|
||||
<< ", nasatId=" << nasatId;
|
||||
auto *napEx = new NasatAircraftParticipantEx(nap,
|
||||
m_mainHandler->dds()->ddsParticipant(nap.exerciseId()));
|
||||
|
||||
@@ -31,6 +31,7 @@ struct NasatAircraftParticipantEx final
|
||||
|
||||
Q_DISABLE_COPY(NasatAircraftParticipantEx)
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
NasatAircraftParticipant m_nap;
|
||||
std::shared_ptr<Participant2Dds> m_publisher;
|
||||
};
|
||||
|
||||
@@ -43,13 +43,13 @@ Initialization::~Initialization()
|
||||
bool Initialization::initialize(const std::shared_ptr<DDSConnector::DdsConnector> &ddsConnector,
|
||||
const QSqlDatabase &)
|
||||
{
|
||||
INFO_LOG() << "Start GuezNasat Initialization.";
|
||||
INFO_LOG(m_logger) << "Start GuezNasat Initialization.";
|
||||
|
||||
|
||||
m_ddsHandler = std::make_shared<DdsHandler>(ddsConnector);
|
||||
if (!m_ddsHandler->init())
|
||||
{
|
||||
ERROR_LOG() << "Initialisation DdsHandler failed.";
|
||||
ERROR_LOG(m_logger) << "Initialisation DdsHandler failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ bool Initialization::initialize(const std::shared_ptr<DDSConnector::DdsConnector
|
||||
if (!m_dbHandler->init(ddsConnector->getPartitionId(), Settings::settings()))
|
||||
|
||||
{
|
||||
ERROR_LOG() << "Initialisation DbHandler failed.";
|
||||
ERROR_LOG(m_logger) << "Initialisation DbHandler failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -80,16 +80,16 @@ bool Initialization::initialize(const std::shared_ptr<DDSConnector::DdsConnector
|
||||
|
||||
if (Settings::useWebSocket())
|
||||
{
|
||||
INFO_LOG() << "Using WebSocket";
|
||||
INFO_LOG(m_logger) << "Using WebSocket";
|
||||
m_jsonSocketHandler.reset(new WebSocketHandler);
|
||||
}
|
||||
else
|
||||
{
|
||||
INFO_LOG() << "Using TcpSocket";
|
||||
INFO_LOG(m_logger) << "Using TcpSocket";
|
||||
m_jsonSocketHandler.reset(new TcpSocketHandler);
|
||||
}
|
||||
|
||||
INFO_LOG() << "GuezNasat Initialization initialized";
|
||||
INFO_LOG(m_logger) << "GuezNasat Initialization initialized";
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -97,7 +97,7 @@ bool Initialization::initialize(const std::shared_ptr<DDSConnector::DdsConnector
|
||||
|
||||
bool Initialization::loadFromDatabase()
|
||||
{
|
||||
TRACE_LOG() << Q_FUNC_INFO << "START";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << "START";
|
||||
|
||||
if (!m_ddsHandler ||
|
||||
!m_dbHandler ||
|
||||
@@ -111,27 +111,27 @@ bool Initialization::loadFromDatabase()
|
||||
|
||||
if (!m_handlerNasatAircraft->init())
|
||||
{
|
||||
ERROR_LOG() << "Initialisation HandlerNasatAircraft failed.";
|
||||
ERROR_LOG(m_logger) << "Initialisation HandlerNasatAircraft failed.";
|
||||
return false;
|
||||
}
|
||||
if (!m_handlerNasatAircraftParticipant->init())
|
||||
{
|
||||
ERROR_LOG() << "Initialisation HandlerNasatAircraftParticipant failed.";
|
||||
ERROR_LOG(m_logger) << "Initialisation HandlerNasatAircraftParticipant failed.";
|
||||
return false;
|
||||
}
|
||||
if (!m_handlerNasatImpact->init())
|
||||
{
|
||||
ERROR_LOG() << "Initialisation HandlerNasatImpact failed.";
|
||||
ERROR_LOG(m_logger) << "Initialisation HandlerNasatImpact failed.";
|
||||
return false;
|
||||
}
|
||||
if (!m_handlerNasatNineLiner->init())
|
||||
{
|
||||
ERROR_LOG() << "Initialisation HandlerNasatNineLiner failed.";
|
||||
ERROR_LOG(m_logger) << "Initialisation HandlerNasatNineLiner failed.";
|
||||
return false;
|
||||
}
|
||||
if (!m_handlerParticipant->init())
|
||||
{
|
||||
ERROR_LOG() << "Initialisation ParticipantPositionPublisher failed.";
|
||||
ERROR_LOG(m_logger) << "Initialisation ParticipantPositionPublisher failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -147,13 +147,13 @@ bool Initialization::loadFromDatabase()
|
||||
NOTICE_LOG(m_logger) << "Initialisation SocketHandler ....";
|
||||
if (!m_jsonSocketHandler->init(Settings::socketListenPort()))
|
||||
{
|
||||
ERROR_LOG() << "Initialisation WebSocketHandler failed.";
|
||||
ERROR_LOG(m_logger) << "Initialisation WebSocketHandler failed.";
|
||||
}
|
||||
});
|
||||
#else
|
||||
if (!m_jsonSocketHandler->init(Settings::socketListenPort()))
|
||||
{
|
||||
ERROR_LOG() << "Initialisation WebSocketHandler failed.";
|
||||
ERROR_LOG(m_logger) << "Initialisation WebSocketHandler failed.";
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
@@ -171,7 +171,7 @@ bool Initialization::loadFromDatabase()
|
||||
QObject::connect(m_jsonSocketHandler.get(), &AbstractSocketHandler::nineLinerReceived,
|
||||
m_handlerNasatNineLiner.get(), &HandlerNasatNineLiner::nineLinerReceived);
|
||||
|
||||
TRACE_LOG() << Q_FUNC_INFO << "END";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << "END";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ public:
|
||||
std::shared_ptr<HandlerParticipant> handlerParticipant() const { return m_handlerParticipant; }
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::shared_ptr<DdsHandler> m_ddsHandler;
|
||||
std::shared_ptr<DbHandler> m_dbHandler;
|
||||
std::shared_ptr<HandlerNasatAircraft> m_handlerNasatAircraft;
|
||||
|
||||
@@ -36,6 +36,8 @@ private Q_SLOTS:
|
||||
void onAirSupportImpact(AreaEffectSimulation::AirSupportImpactModifyRequest asi, int equipmentNumber);
|
||||
|
||||
private:
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
NgsHandler *m_ngsHandler;
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_dtcAes;
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Ftc> m_ftcAes;
|
||||
|
||||
+5
-6
@@ -9,11 +9,10 @@
|
||||
namespace HighLevelArchitecture
|
||||
{
|
||||
|
||||
DdsHandler::DdsHandler(int domainId, int exerciseId)
|
||||
: m_ddsConnector(new DDSConnector::DdsConnector(domainId, IDL::PartitionType::Exercise, exerciseId))
|
||||
, m_exerciseHasHlaConnection(false)
|
||||
{
|
||||
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_exerciseHasHlaConnection(false),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
DEBUG_LOG(m_logger) << "DdsHandler(" << domainId << ") for partition: " << m_ddsConnector->getDefaultPartition();
|
||||
}
|
||||
|
||||
DdsHandler::~DdsHandler()
|
||||
@@ -27,7 +26,7 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,8 +32,10 @@ public:
|
||||
Q_SIGNALS:
|
||||
void exerciseHlaStateChanged(bool bHlaEnabled);
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void onExerciseChanged(const ExerciseManagement::Exercise &ex, DataModification modType);
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
|
||||
std::shared_ptr<Core::Pacemaker> m_pacemaker;
|
||||
std::shared_ptr<ExerciseManagement::Interface::Dtc> m_dtcExm;
|
||||
|
||||
+4
-5
@@ -13,10 +13,9 @@
|
||||
namespace HighLevelArchitecture
|
||||
{
|
||||
|
||||
MainHandler::MainHandler(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_exerciseId(0)
|
||||
{}
|
||||
MainHandler::MainHandler(QObject *parent) : QObject(parent)
|
||||
, m_exerciseId(0),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {}
|
||||
|
||||
MainHandler::~MainHandler()
|
||||
{
|
||||
@@ -31,7 +30,7 @@ bool MainHandler::init(int domainId, int exerciseId)
|
||||
m_ddsHandler = std::make_shared<DdsHandler>(domainId, exerciseId);
|
||||
if (!m_ddsHandler->init())
|
||||
{
|
||||
ERROR_LOG() << "Could not init DDS handler";
|
||||
ERROR_LOG(m_logger) << "Could not init DDS handler";
|
||||
return false;
|
||||
}
|
||||
connect(m_ddsHandler.get(), &DdsHandler::exerciseHlaStateChanged,
|
||||
|
||||
@@ -26,6 +26,7 @@ public:
|
||||
private Q_SLOTS:
|
||||
void onExerciseHlaStateChanged(bool bHlaEnabled);
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::shared_ptr<DdsHandler> m_ddsHandler;
|
||||
std::shared_ptr<NgsHandler> m_ngsHandler;
|
||||
std::shared_ptr<WebSocketHandler> m_wsHandler;
|
||||
|
||||
+21
-22
@@ -127,8 +127,7 @@ static inline rpr2::SpatialStruct spatialStructFromWorldLocation(const rpr2::Wor
|
||||
|
||||
|
||||
|
||||
NgsConnector::NgsConnector(const QString &fedName, NgsHandler *ngsHandler)
|
||||
: m_ngsHandler(ngsHandler)
|
||||
NgsConnector::NgsConnector(const QString &fedName, NgsHandler *ngsHandler) : m_ngsHandler(ngsHandler)
|
||||
, m_fedName(fedName)
|
||||
, m_swadmin(&ngs::SimulatedWorldAPI::getSimulatedWorldAdmin())
|
||||
, m_master(nullptr)
|
||||
@@ -144,8 +143,8 @@ NgsConnector::NgsConnector(const QString &fedName, NgsHandler *ngsHandler)
|
||||
, m_iaWeaponFireCallback(new ObserverWeaponFireCBNotifier())
|
||||
, m_bInitialized(false)
|
||||
, m_bCanPublishData(false)
|
||||
, m_timer(new QTimer(this))
|
||||
{
|
||||
, m_timer(new QTimer(this)),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
connect(m_timer, &QTimer::timeout,
|
||||
this, &NgsConnector::go);
|
||||
connect(m_playerCallback, &PlayerCallback::firstTick,
|
||||
@@ -212,7 +211,7 @@ bool NgsConnector::initialize(ngs::IObserver::ProtocolType protocol, const QStri
|
||||
}
|
||||
catch (const ngs::NGSSimWorldException &e)
|
||||
{
|
||||
ERROR_LOG() << "caught exception during init (getIFederationMaster): " << e.print();
|
||||
ERROR_LOG(m_logger) << "caught exception during init (getIFederationMaster): " << e.print();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -227,7 +226,7 @@ bool NgsConnector::initialize(ngs::IObserver::ProtocolType protocol, const QStri
|
||||
}
|
||||
catch (const NGSException &e)
|
||||
{
|
||||
ERROR_LOG() << "caught exception during init (createFederation): " << e.print();
|
||||
ERROR_LOG(m_logger) << "caught exception during init (createFederation): " << e.print();
|
||||
return false;
|
||||
}
|
||||
player = &m_swadmin->getIPlayer(m_fedName.toStdString(), playerName.toStdString(), *m_playerCallback, Settings::swConfFileName().toLatin1().data(), Settings::fomIdentifier().toStdString(), Settings::rtiIdentifier().toStdString());
|
||||
@@ -277,22 +276,22 @@ void NgsConnector::subscribeAtNgs()
|
||||
m_enitityNumberCounter = 1;
|
||||
m_eventCount = 1;
|
||||
|
||||
INFO_LOG() << "Subscribe at NGS - Human Objects";
|
||||
INFO_LOG(m_logger) << "Subscribe at NGS - Human Objects";
|
||||
rpr2::IObserverHumanObjClass &humanObjClass = m_somPlayer->getObserverHumanObjClass(*m_humanCallback);
|
||||
humanObjClass.subscribeAllAttributes();
|
||||
humanObjClass.subscribe();
|
||||
|
||||
INFO_LOG() << "Subscribe at NGS - GroundVehicle Objects";
|
||||
INFO_LOG(m_logger) << "Subscribe at NGS - GroundVehicle Objects";
|
||||
rpr2::IObserverGroundVehicleObjClass &groundVehicleObjClass = m_somPlayer->getObserverGroundVehicleObjClass(*m_groundVehicleCallback);
|
||||
groundVehicleObjClass.subscribeAllAttributes();
|
||||
groundVehicleObjClass.subscribe();
|
||||
|
||||
INFO_LOG() << "Subscribe at NGS - LongBowApache Objects";
|
||||
INFO_LOG(m_logger) << "Subscribe at NGS - LongBowApache Objects";
|
||||
rpr2::IObserverLongBowApacheObjClass &longBowApacheObjClass = m_somPlayer->getObserverLongBowApacheObjClass(*m_longBowApacheCallback);
|
||||
longBowApacheObjClass.subscribeAllAttributes();
|
||||
longBowApacheObjClass.subscribe();
|
||||
|
||||
INFO_LOG() << "Subscribe at NGS - Designator Objects";
|
||||
INFO_LOG(m_logger) << "Subscribe at NGS - Designator Objects";
|
||||
rpr2::IObserverDesignatorObjClass &designatorObjClass = m_somPlayer->getObserverDesignatorObjClass(*m_designatorCallback);
|
||||
designatorObjClass.subscribeAllAttributes();
|
||||
designatorObjClass.subscribe();
|
||||
@@ -321,35 +320,35 @@ void NgsConnector::unsubscribeFromNgs()
|
||||
|
||||
if (m_somPlayer)
|
||||
{
|
||||
INFO_LOG() << "Unsubscribe at NGS - Human Objects";
|
||||
INFO_LOG(m_logger) << "Unsubscribe at NGS - Human Objects";
|
||||
rpr2::IObserverHumanObjClass &humanObjClass = m_somPlayer->getObserverHumanObjClass(*m_humanCallback);
|
||||
humanObjClass.unsubscribe();
|
||||
|
||||
INFO_LOG() << "Unsubscribe at NGS - GroundVehicle Objects";
|
||||
INFO_LOG(m_logger) << "Unsubscribe at NGS - GroundVehicle Objects";
|
||||
rpr2::IObserverGroundVehicleObjClass &groundVehicleObjClass = m_somPlayer->getObserverGroundVehicleObjClass(*m_groundVehicleCallback);
|
||||
groundVehicleObjClass.unsubscribe();
|
||||
|
||||
INFO_LOG() << "Unsubscribe at NGS - LongBowApache Objects";
|
||||
INFO_LOG(m_logger) << "Unsubscribe at NGS - LongBowApache Objects";
|
||||
rpr2::IObserverLongBowApacheObjClass &longBowApacheObjClass = m_somPlayer->getObserverLongBowApacheObjClass(*m_longBowApacheCallback);
|
||||
longBowApacheObjClass.unsubscribe();
|
||||
|
||||
INFO_LOG() << "Unsubscribe at NGS - Designator Objects";
|
||||
INFO_LOG(m_logger) << "Unsubscribe at NGS - Designator Objects";
|
||||
rpr2::IObserverDesignatorObjClass &designatorObjectClass = m_somPlayer->getObserverDesignatorObjClass(*m_designatorCallback);
|
||||
designatorObjectClass.unsubscribe();
|
||||
|
||||
INFO_LOG() << "Unsubscribe at NGS - Engagement Reply Interaction";
|
||||
INFO_LOG(m_logger) << "Unsubscribe at NGS - Engagement Reply Interaction";
|
||||
rpr2::IObserverEngagementReplyIntClass &enr = m_somPlayer->getObserverEngagementReplyIntClass(*m_iaEngagementReplyCallback);
|
||||
enr.unsubscribe();
|
||||
|
||||
INFO_LOG() << "Unsubscribe at NGS - Event Report Interaction";
|
||||
INFO_LOG(m_logger) << "Unsubscribe at NGS - Event Report Interaction";
|
||||
rpr2::IObserverEventReportIntClass &evr = m_somPlayer->getObserverEventReportIntClass(*m_iaEventReportCallback);
|
||||
evr.unsubscribe();
|
||||
|
||||
INFO_LOG() << "Unsubscribe at NGS - Munition Detonation Interaction";
|
||||
INFO_LOG(m_logger) << "Unsubscribe at NGS - Munition Detonation Interaction";
|
||||
rpr2::IObserverMunitionDetonationIntClass &md = m_somPlayer->getObserverMunitionDetonationIntClass(*m_iaMunitionDetonationCallback);
|
||||
md.unsubscribe();
|
||||
|
||||
INFO_LOG() << "Unsubscribe at NGS - Weapon Fire Interaction";
|
||||
INFO_LOG(m_logger) << "Unsubscribe at NGS - Weapon Fire Interaction";
|
||||
rpr2::IObserverWeaponFireIntClass &wf = m_somPlayer->getObserverWeaponFireIntClass(*m_iaWeaponFireCallback);
|
||||
wf.unsubscribe();
|
||||
}
|
||||
@@ -515,7 +514,7 @@ bool NgsConnector::sendData(int eqNo, const QByteArray& data, int requestIdentif
|
||||
vds.NumberOfLongLongs__A__Padding__A__DatumValue.resize(data.size() / 8 + 1);
|
||||
vds.DatumLengthInBits = 8 * data.size();
|
||||
|
||||
TRACE_LOG() << "--> Data. Receiver: " << eqNo << ", ReqID: " << requestIdentifier << ", Data: " << data;
|
||||
TRACE_LOG(m_logger) << "--> Data. Receiver: " << eqNo << ", ReqID: " << requestIdentifier << ", Data: " << data;
|
||||
|
||||
for (unsigned int i=0; i< vds.NumberOfLongLongs__A__Padding__A__DatumValue.size(); ++i)
|
||||
{
|
||||
@@ -682,11 +681,11 @@ void NgsConnector::go()
|
||||
}
|
||||
catch (const NGSException &ex)
|
||||
{
|
||||
ERROR_LOG() << "NGS Exception caught in Event Loop" << ex.print();
|
||||
ERROR_LOG(m_logger) << "NGS Exception caught in Event Loop" << ex.print();
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
ERROR_LOG() << "Standard Exception caught in Event Loop: " << e.what();
|
||||
ERROR_LOG(m_logger) << "Standard Exception caught in Event Loop: " << e.what();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@@ -1499,7 +1498,7 @@ void NgsConnector::onNewMunitionDetonation(const rpr2::IObserverMunitionDetonati
|
||||
|
||||
const auto &objectIdentifier = interaction.getEventIdentifier().IssuingObjectIdentifier;
|
||||
int eqId = getEquipmentNoByRTIObjectId(objectIdentifier.ID);
|
||||
DEBUG_LOG() << "Engagement Reply, Issuer: " << eqId;
|
||||
DEBUG_LOG(m_logger) << "Engagement Reply, Issuer: " << eqId;
|
||||
if (m_playerMap.contains(eqId) || objectIdentifier.ID == std::to_string(IdentifierStruct(0).toInt64()))
|
||||
return;
|
||||
|
||||
|
||||
Loaded 100 of 2102 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user