Adds immediate migration results in progress

This commit is contained in:
torsten committed 2026-08-19 11:18:24 +02:00
1 parent 8453e104c5
commit 3bb6e89496
2102 files changed
+17482 -15071

No files matched your search

@@ -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;
};
}
@@ -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";
}
@@ -39,6 +39,7 @@ private Q_SLOTS:
void onReadyRead();
void onAliveTimeout();
private:
NGL::INGLLogger &m_logger;
void startReconnectTimer();
private:
BuildingControlUnit::Bsm m_config;
@@ -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;
}
}
@@ -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);
@@ -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);
@@ -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);
}
@@ -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;
}
}
@@ -178,6 +178,7 @@ public:
XmlContents contents() const { return m_contents; }
private:
NGL::INGLLogger &m_logger;
void createHttpRequests();
static QString categoryName(Category c);
@@ -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();
}
@@ -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;
};
}
@@ -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);
@@ -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;
};
@@ -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;
}
}
@@ -24,4 +24,5 @@ private Q_SLOTS:
void test5();
void test6();
private:
NGL::INGLLogger &m_logger;
};
@@ -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 &center = 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;
@@ -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;
}
@@ -29,6 +29,8 @@ public:
private:
NGL::INGLLogger &m_logger;
int m_id = 0;
double m_transitionFactor = 0;
};
@@ -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;
}
@@ -36,6 +36,8 @@ public:
QVector<int> pointIsInWhichRooms(const LtsUtils::QPoint3D &pointToFind);
private:
NGL::INGLLogger &m_logger;
bool parse(const QDomElement &domGroup);
@@ -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;
@@ -68,6 +68,7 @@ private Q_SLOTS:
void trySendNextRequest();
private:
NGL::INGLLogger &m_logger;
QNetworkAccessManager *m_nam;
bool m_bUseQueue;
QString m_username;
@@ -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;
@@ -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;