Adds immediate migration results in progress
This commit is contained in:
2102 files changed
+17482
-15071
No files matched your search
+3
-3
@@ -33,7 +33,7 @@ bool Api::init(const BuildingBsmConfig &bsmConfig)
|
||||
|
||||
bool Api::triggerFlashlight(int bsmId, const QString &hostname, int numberOfFlashes, int pauseBetweenFlashesSec)
|
||||
{
|
||||
DEBUG_LOG() << "triggerFlashlight bsmId=" << bsmId
|
||||
DEBUG_LOG(m_logger) << "triggerFlashlight bsmId=" << bsmId
|
||||
<< " hostname=" << hostname
|
||||
<< " numberOfFlashes=" << numberOfFlashes
|
||||
<< " pauseBetweenFlashesSec=" << pauseBetweenFlashesSec;
|
||||
@@ -46,7 +46,7 @@ bool Api::triggerFlashlightPulse(int bsmId, const QString &hostname,
|
||||
int choppedConfiguration,
|
||||
int flashDuration)
|
||||
{
|
||||
DEBUG_LOG() << "triggerFlashlightPulse bsmId=" << bsmId
|
||||
DEBUG_LOG(m_logger) << "triggerFlashlightPulse bsmId=" << bsmId
|
||||
<< " hostname=" << hostname
|
||||
<< " numberOfFlashes=" << numberOfFlashes
|
||||
<< " pauseDuration=" << pauseDuration
|
||||
@@ -60,7 +60,7 @@ bool Api::triggerFlashlights( int numberOfFlashes,
|
||||
int choppedConfiguration,
|
||||
int flashDuration)
|
||||
{
|
||||
DEBUG_LOG() << "triggerFlashlights numberOfFlashes=" << numberOfFlashes
|
||||
DEBUG_LOG(m_logger) << "triggerFlashlights numberOfFlashes=" << numberOfFlashes
|
||||
<< " pauseDuration=" << pauseDuration
|
||||
<< " choppedConfiguration" << choppedConfiguration
|
||||
<< " flashDuration=" << flashDuration;
|
||||
|
||||
@@ -50,6 +50,7 @@ Q_SIGNALS:
|
||||
DamageState damageState);
|
||||
void bsmStateChanged(const QVector<BsmState> &bsmStates);
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
SocketHandler *m_socketHandler;
|
||||
};
|
||||
}
|
||||
|
||||
+8
-8
@@ -45,10 +45,10 @@ bool Socket::sendData(const QByteArray &data)
|
||||
{
|
||||
if (!isConnected())
|
||||
{
|
||||
WARNING_LOG() << "BSM " << m_config.id << ": Trying to send data but not connected!";
|
||||
WARNING_LOG(m_logger) << "BSM " << m_config.id << ": Trying to send data but not connected!";
|
||||
return false;
|
||||
}
|
||||
DEBUG_LOG() << "BSM " << m_config.id << ": sending data: 0x" << data.toHex();
|
||||
DEBUG_LOG(m_logger) << "BSM " << m_config.id << ": sending data: 0x" << data.toHex();
|
||||
m_tcpSocket->write(data);
|
||||
m_tcpSocket->flush();
|
||||
return true;
|
||||
@@ -57,7 +57,7 @@ bool Socket::sendData(const QByteArray &data)
|
||||
void Socket::setVersionInformation(int verMajor, int verMinor, int verRev, const QString &manufacturer)
|
||||
{
|
||||
m_versionInfo = QStringLiteral("%1.%2-%3 (%4)").arg(verMajor).arg(verMinor).arg(verRev).arg(manufacturer);
|
||||
INFO_LOG() << "BSM " << m_config.id
|
||||
INFO_LOG(m_logger) << "BSM " << m_config.id
|
||||
<< ": version = " << m_versionInfo;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ void Socket::gotAlive()
|
||||
|
||||
void Socket::onConnected()
|
||||
{
|
||||
INFO_LOG() << "BSM " << m_config.id << " is connected to "
|
||||
INFO_LOG(m_logger) << "BSM " << m_config.id << " is connected to "
|
||||
<< m_tcpSocket->peerAddress().toString() << ":" << m_tcpSocket->peerPort();
|
||||
Telegrams::PanConfigurationSetup tele;
|
||||
tele.m_aliveMessage = s_aliveTimeout;
|
||||
@@ -83,7 +83,7 @@ void Socket::onConnected()
|
||||
|
||||
void Socket::onDisconnected()
|
||||
{
|
||||
INFO_LOG() << "BSM " << m_config.id << " is disconnected";
|
||||
INFO_LOG(m_logger) << "BSM " << m_config.id << " is disconnected";
|
||||
m_versionInfo.clear();
|
||||
startReconnectTimer();
|
||||
emit disconnected(m_config.id);
|
||||
@@ -91,7 +91,7 @@ void Socket::onDisconnected()
|
||||
|
||||
void Socket::onError(QAbstractSocket::SocketError error)
|
||||
{
|
||||
DEBUG_LOG() << "BSM " << m_config.id
|
||||
DEBUG_LOG(m_logger) << "BSM " << m_config.id
|
||||
<< " can not connect to " << m_config.hostname << ":" << m_config.port
|
||||
<< ": " << m_tcpSocket->errorString()
|
||||
<< " (" << error << ");";
|
||||
@@ -100,7 +100,7 @@ void Socket::onError(QAbstractSocket::SocketError error)
|
||||
|
||||
void Socket::onConnect()
|
||||
{
|
||||
DEBUG_LOG() << "BSM " << m_config.id
|
||||
DEBUG_LOG(m_logger) << "BSM " << m_config.id
|
||||
<< " trying to connect to " << m_config.hostname << ":" << m_config.port;
|
||||
m_tcpSocket->connectToHost(m_config.hostname, m_config.port);
|
||||
}
|
||||
@@ -112,7 +112,7 @@ void Socket::onReadyRead()
|
||||
|
||||
void Socket::onAliveTimeout()
|
||||
{
|
||||
WARNING_LOG() << "BSM " << m_config.id
|
||||
WARNING_LOG(m_logger) << "BSM " << m_config.id
|
||||
<< " alive timeout! Reconnecting";
|
||||
|
||||
}
|
||||
|
||||
+1
@@ -39,6 +39,7 @@ private Q_SLOTS:
|
||||
void onReadyRead();
|
||||
void onAliveTimeout();
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void startReconnectTimer();
|
||||
private:
|
||||
BuildingControlUnit::Bsm m_config;
|
||||
|
||||
+15
-15
@@ -66,7 +66,7 @@ bool SocketHandler::triggerFlashlight(int bsmId, const QString &hostname, int nu
|
||||
Socket *s = hostname.isEmpty() ? getSocketForBsm(bsmId) : getSocketForBsm(hostname);
|
||||
if (!s)
|
||||
return false;
|
||||
DEBUG_LOG() << "triggerFlashlight BSM Socket with socketId " << bsmId;
|
||||
DEBUG_LOG(m_logger) << "triggerFlashlight BSM Socket with socketId " << bsmId;
|
||||
Telegrams::PanChoppedSignalFlashlight flash;
|
||||
flash.m_noOfFlashes = qBound(0, numberOfFlashes, 255);
|
||||
flash.m_pauseDuration = qBound(1, pauseBetweenFlashesSec, 10);
|
||||
@@ -83,7 +83,7 @@ bool SocketHandler::triggerFlashlightPulse(int bsmId, const QString &hostname,
|
||||
Socket *s = hostname.isEmpty() ? getSocketForBsm(bsmId) : getSocketForBsm(hostname);
|
||||
if (!s)
|
||||
return false;
|
||||
DEBUG_LOG() << "triggerFlashlightPulse BSM Socket with socketId " << bsmId
|
||||
DEBUG_LOG(m_logger) << "triggerFlashlightPulse BSM Socket with socketId " << bsmId
|
||||
<< " hostname=" << hostname
|
||||
<< " numberOfFlashes=" << numberOfFlashes
|
||||
<< " pauseDuration=" << pauseDuration
|
||||
@@ -118,12 +118,12 @@ bool SocketHandler::triggerFlashlights(int numberOfFlashes,
|
||||
++cntSocketsActive;
|
||||
}
|
||||
else
|
||||
WARNING_LOG() << "BSM " << s->bsmConfig().id
|
||||
WARNING_LOG(m_logger) << "BSM " << s->bsmConfig().id
|
||||
<< " is not connected - can not activate flash light";
|
||||
}
|
||||
if (cntSocketsActive == 0)
|
||||
{
|
||||
WARNING_LOG() << "No active bsm - can not trigger flash light for all bsm";
|
||||
WARNING_LOG(m_logger) << "No active bsm - can not trigger flash light for all bsm";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -184,13 +184,13 @@ void SocketHandler::onDataAvailable(int id, const QByteArray &data)
|
||||
void SocketHandler::onSocketConnected(int id)
|
||||
{
|
||||
requestVersion(id);
|
||||
DEBUG_LOG() << "BSM Socket with id " << id << " connected";
|
||||
DEBUG_LOG(m_logger) << "BSM Socket with id " << id << " connected";
|
||||
m_bsmStateTimer.start();
|
||||
}
|
||||
|
||||
void SocketHandler::onSocketDisconnected(int id)
|
||||
{
|
||||
DEBUG_LOG() << "BSM Socket with id " << id << " disconnected";
|
||||
DEBUG_LOG(m_logger) << "BSM Socket with id " << id << " disconnected";
|
||||
m_socketData[id].clear();
|
||||
m_bsmStateTimer.start();
|
||||
}
|
||||
@@ -216,12 +216,12 @@ Socket *SocketHandler::getSocketForBsm(int bsmId)
|
||||
Socket *s = m_sockets.value(bsmId);
|
||||
if (!s)
|
||||
{
|
||||
WARNING_LOG() << "Got invalid bsm id (" << bsmId << ") to trigger flashlight";
|
||||
WARNING_LOG(m_logger) << "Got invalid bsm id (" << bsmId << ") to trigger flashlight";
|
||||
return nullptr;
|
||||
}
|
||||
if (!s->isConnected())
|
||||
{
|
||||
WARNING_LOG() << "Bsm with id " << bsmId
|
||||
WARNING_LOG(m_logger) << "Bsm with id " << bsmId
|
||||
<< " is not connected - can not activate flash light";
|
||||
return nullptr;
|
||||
}
|
||||
@@ -269,7 +269,7 @@ void SocketHandler::parseBsmTelegram(int id, const QByteArray &baTele)
|
||||
if (!tele)
|
||||
return;
|
||||
if (tele->telId() != Telegrams::PanTelegramId::ALIVE)
|
||||
DEBUG_LOG() << "Got tele from bsm with id " << id << ": " << tele->print();
|
||||
DEBUG_LOG(m_logger) << "Got tele from bsm with id " << id << ": " << tele->print();
|
||||
switch (tele->telId())
|
||||
{
|
||||
case Telegrams::PanTelegramId::ALIVE:
|
||||
@@ -317,7 +317,7 @@ void SocketHandler::parseBsmTelegram(int id, const QByteArray &baTele)
|
||||
|
||||
bool SocketHandler::requestVersion(int id)
|
||||
{
|
||||
DEBUG_LOG() << "Requesting version for BSM " << id;
|
||||
DEBUG_LOG(m_logger) << "Requesting version for BSM " << id;
|
||||
Socket *s = m_sockets.value(id);
|
||||
if (!s || !s->isConnected())
|
||||
return false;
|
||||
@@ -333,7 +333,7 @@ void SocketHandler::handleDirectFire(int id, const Telegrams::PanDirectFire *tel
|
||||
|
||||
if (tele->m_ammunitionId == 0)
|
||||
{
|
||||
WARNING_LOG() << "Got direct fire without valid ammunition - ignoring: " << tele->print();
|
||||
WARNING_LOG(m_logger) << "Got direct fire without valid ammunition - ignoring: " << tele->print();
|
||||
return;
|
||||
}
|
||||
OpticalShot osNew;
|
||||
@@ -351,21 +351,21 @@ void SocketHandler::handleDirectFire(int id, const Telegrams::PanDirectFire *tel
|
||||
|
||||
void SocketHandler::handleDirectFireSummray()
|
||||
{
|
||||
DEBUG_LOG() << "handleDirectFireSummray m_lastShots.size=" << m_lastShots.size();
|
||||
DEBUG_LOG(m_logger) << "handleDirectFireSummray m_lastShots.size=" << m_lastShots.size();
|
||||
OpticalShot osNew;
|
||||
if ( m_lastShots.size() == 0)
|
||||
return;
|
||||
int distance = 3000;
|
||||
DEBUG_LOG() << "distance=" << distance;
|
||||
DEBUG_LOG(m_logger) << "distance=" << distance;
|
||||
for (const OpticalShot &os : std::as_const(m_lastShots))
|
||||
{
|
||||
int act_distance = os.deposition1 * os.deposition1 + os.deposition2 * os.deposition2;
|
||||
DEBUG_LOG() << "act_distance=" << act_distance << " BSM-ID=" << os.id
|
||||
DEBUG_LOG(m_logger) << "act_distance=" << act_distance << " BSM-ID=" << os.id
|
||||
<< " ammunitionId=" << os.ammunitionId;
|
||||
if ( act_distance < distance)
|
||||
{
|
||||
distance = act_distance;
|
||||
DEBUG_LOG() << "distance=" << distance << " BSM-ID=" << os.id;
|
||||
DEBUG_LOG(m_logger) << "distance=" << distance << " BSM-ID=" << os.id;
|
||||
osNew = os;
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -69,6 +69,8 @@ private Q_SLOTS:
|
||||
void handleDirectFireSummray();
|
||||
|
||||
private:
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
Socket *getSocketForBsm(int bsmId);
|
||||
Socket *getSocketForBsm(const QString &hostname);
|
||||
QByteArray parseBuffer(int id, const QByteArray &buffer);
|
||||
|
||||
+8
-8
@@ -61,22 +61,22 @@ void HandelEffect::handleEffect()
|
||||
switch (m_currentAction->aclass)
|
||||
{
|
||||
case AC_Unset:
|
||||
DEBUG_LOG() << "---- This is unset ----";
|
||||
DEBUG_LOG(m_logger) << "---- This is unset ----";
|
||||
break;
|
||||
case AC_Standard:
|
||||
{
|
||||
DEBUG_LOG() << "---- This is a standard Action ----";
|
||||
DEBUG_LOG(m_logger) << "---- This is a standard Action ----";
|
||||
if (!m_currentAction->url.isEmpty())
|
||||
{
|
||||
|
||||
DEBUG_LOG() << "---- emit newHttpRequest(a->url):" << m_currentAction->url.toString();
|
||||
DEBUG_LOG(m_logger) << "---- emit newHttpRequest(a->url):" << m_currentAction->url.toString();
|
||||
emit newHttpRequest(m_currentAction->url);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case AC_Repeat:
|
||||
{
|
||||
DEBUG_LOG() << "---- This is a Repeat Action";
|
||||
DEBUG_LOG(m_logger) << "---- This is a Repeat Action";
|
||||
const RepeatAction *ra = static_cast<const RepeatAction *>(m_currentAction);
|
||||
|
||||
HandelEffect *he = new HandelEffect(this);
|
||||
@@ -92,7 +92,7 @@ void HandelEffect::handleEffect()
|
||||
case AC_Pause:
|
||||
{
|
||||
const PauseAction *pa = static_cast<const PauseAction *>(m_currentAction);
|
||||
DEBUG_LOG() << "---- This is a Pause Action Pause=" << pa->pause
|
||||
DEBUG_LOG(m_logger) << "---- This is a Pause Action Pause=" << pa->pause
|
||||
<< " comment=" << pa->comment;
|
||||
|
||||
QTimer::singleShot(pa->pause, this, &HandelEffect::handleEffect);
|
||||
@@ -102,11 +102,11 @@ void HandelEffect::handleEffect()
|
||||
}
|
||||
case AC_Bsm:
|
||||
{
|
||||
DEBUG_LOG() << "---- This is a Bsm Action ";
|
||||
DEBUG_LOG(m_logger) << "---- This is a Bsm Action ";
|
||||
const BsmAction *ba = static_cast<const BsmAction*>(m_currentAction);
|
||||
if (!ba->isNull())
|
||||
{
|
||||
DEBUG_LOG() << "emit triggerAllFlashlights ------ atype=" << m_currentAction->atype
|
||||
DEBUG_LOG(m_logger) << "emit triggerAllFlashlights ------ atype=" << m_currentAction->atype
|
||||
<< " pause=" << ba->pause
|
||||
<< " choplength=" << ba->choplength
|
||||
<< " pulses=" << ba->pulses
|
||||
@@ -120,7 +120,7 @@ void HandelEffect::handleEffect()
|
||||
default:
|
||||
break;
|
||||
}
|
||||
DEBUG_LOG() << "--- End Action ";
|
||||
DEBUG_LOG(m_logger) << "--- End Action ";
|
||||
|
||||
|
||||
QTimer::singleShot(0, this, &HandelEffect::handleEffect);
|
||||
|
||||
+33
-33
@@ -22,7 +22,7 @@ HandelEffects::HandelEffects(QObject *parent, const QString &loggerchannel)
|
||||
, m_getRelayStateTimer(new QTimer(this))
|
||||
, m_logger(getLogger(QStringLiteral("HandelEffects.") + loggerchannel))
|
||||
{
|
||||
DEBUG_LOG() << "HandelEffects::init loggerchannel=" << loggerchannel;
|
||||
DEBUG_LOG(m_logger) << "HandelEffects::init loggerchannel=" << loggerchannel;
|
||||
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ void HandelEffects::init(const QString &controlEffectsCfg, const QString &hostna
|
||||
{
|
||||
m_xmlReader.init(controlEffectsCfg);
|
||||
|
||||
DEBUG_LOG() << "HandelEffects::init";
|
||||
DEBUG_LOG(m_logger) << "HandelEffects::init";
|
||||
m_hostname = hostname;
|
||||
m_lastDamage = -1;
|
||||
m_effectType = et;
|
||||
@@ -53,7 +53,7 @@ void HandelEffects::startEffects(int damagePercent)
|
||||
{
|
||||
if (m_lastDamage == damagePercent)
|
||||
{
|
||||
DEBUG_LOG() << "damagePercent=" << damagePercent
|
||||
DEBUG_LOG(m_logger) << "damagePercent=" << damagePercent
|
||||
<< " m_lastDamage=" << m_lastDamage
|
||||
<< " return";
|
||||
return;
|
||||
@@ -73,7 +73,7 @@ void HandelEffects::startEffects(int damagePercent)
|
||||
if (e->effectType == ET_Relay && m_effectType == ET_BsmFlash)
|
||||
continue;
|
||||
|
||||
DEBUG_LOG() << "- HandelEffects::Starting Effect " << e << " of Type " << e->effectType << ". ----"
|
||||
DEBUG_LOG(m_logger) << "- HandelEffects::Starting Effect " << e << " of Type " << e->effectType << ". ----"
|
||||
<< " name=" << e->name;
|
||||
for (const Range *range : e->constRanges())
|
||||
{
|
||||
@@ -87,7 +87,7 @@ void HandelEffects::startEffects(int damagePercent)
|
||||
|
||||
createEffectHandler(e, range);
|
||||
}
|
||||
DEBUG_LOG() << "- End Effect ";
|
||||
DEBUG_LOG(m_logger) << "- End Effect ";
|
||||
}
|
||||
m_lastDamage = damagePercent;
|
||||
}
|
||||
@@ -103,7 +103,7 @@ void HandelEffects::createEffectHandler(Effect *e, const Range *range)
|
||||
{
|
||||
if (m_effectType == ET_BsmFlash)
|
||||
{
|
||||
INFO_LOG() << "setOverrides connect Flashes" ;
|
||||
INFO_LOG(m_logger) << "setOverrides connect Flashes" ;
|
||||
connect(handelEffect, &HandelEffect::triggerAllFlashlights, this, &HandelEffects::triggerAllFlashlights, Qt::UniqueConnection);
|
||||
}
|
||||
else
|
||||
@@ -112,15 +112,15 @@ void HandelEffects::createEffectHandler(Effect *e, const Range *range)
|
||||
|
||||
connect(handelEffect, &HandelEffect::effectReady, this, &HandelEffects::onEffectReady);
|
||||
|
||||
DEBUG_LOG() << "-- HandelEffects::Starting Range " << range->min << " - " << range->max
|
||||
DEBUG_LOG(m_logger) << "-- HandelEffects::Starting Range " << range->min << " - " << range->max
|
||||
<< ". ----";
|
||||
|
||||
DEBUG_LOG() << "-- Range has " << range->actions.count() << " actions";
|
||||
DEBUG_LOG(m_logger) << "-- Range has " << range->actions.count() << " actions";
|
||||
|
||||
handelEffect->init(range->actions, 1);
|
||||
|
||||
QTimer::singleShot(0, handelEffect, &HandelEffect::handleEffect);
|
||||
DEBUG_LOG() << "-- End Range ";
|
||||
DEBUG_LOG(m_logger) << "-- End Range ";
|
||||
}
|
||||
|
||||
void HandelEffects::playHitSound(const int hitSoundId)
|
||||
@@ -162,18 +162,18 @@ void HandelEffects::switchRelay(const SwitchRelayValues &switchRelayValues)
|
||||
void HandelEffects::setOverrides(const QVector<BcuEffectState> &effectStates)
|
||||
{
|
||||
m_effectStates = effectStates;
|
||||
DEBUG_LOG() << "In set overrides for " << m_hostname << ", effectStates.size: " << effectStates.size();
|
||||
DEBUG_LOG(m_logger) << "In set overrides for " << m_hostname << ", effectStates.size: " << effectStates.size();
|
||||
for(const auto &es : std::as_const(m_effectStates))
|
||||
{
|
||||
DEBUG_LOG() << "m_effectStates: es.id=" << es.id
|
||||
DEBUG_LOG(m_logger) << "m_effectStates: es.id=" << es.id
|
||||
<< ", es.type=" << es.type
|
||||
<< ", es.override=" << es.effectOverride;
|
||||
}
|
||||
m_sounds = EffectOverride::EO_Auto;
|
||||
DEBUG_LOG() << "Nun die Schleife:";
|
||||
DEBUG_LOG(m_logger) << "Nun die Schleife:";
|
||||
for(const auto &es : std::as_const(effectStates))
|
||||
{
|
||||
DEBUG_LOG() << "es.id=" << es.id
|
||||
DEBUG_LOG(m_logger) << "es.id=" << es.id
|
||||
<< ", es.type=" << es.type
|
||||
<< ", es.override=" << es.effectOverride;
|
||||
switch (es.type) {
|
||||
@@ -194,14 +194,14 @@ void HandelEffects::setOverrides(const QVector<BcuEffectState> &effectStates)
|
||||
if (e->effectHandler)
|
||||
{
|
||||
disconnect(e->effectHandler, &HandelEffect::newHttpRequest, this, &HandelEffects::sendHttpRequest);
|
||||
INFO_LOG() << "setOverrides emit triggerAllFlashlights(0,0,0,0)" ;
|
||||
INFO_LOG(m_logger) << "setOverrides emit triggerAllFlashlights(0,0,0,0)" ;
|
||||
emit triggerAllFlashlights(0,0,0,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (es.effectOverride == BEO_Off )
|
||||
{
|
||||
DEBUG_LOG() << "BEO_Off";
|
||||
DEBUG_LOG(m_logger) << "BEO_Off";
|
||||
|
||||
QUrl url = XmlReader::createPreparedUrl(contents(), m_hostname);
|
||||
QUrlQuery query;
|
||||
@@ -260,7 +260,7 @@ void HandelEffects::setOverrides(const QVector<BcuEffectState> &effectStates)
|
||||
{
|
||||
if (e->effectHandler)
|
||||
{
|
||||
INFO_LOG() << "setOverrides disconnect Flashes" ;
|
||||
INFO_LOG(m_logger) << "setOverrides disconnect Flashes" ;
|
||||
disconnect (e->effectHandler, &HandelEffect::triggerAllFlashlights, this, &HandelEffects::triggerAllFlashlights);
|
||||
}
|
||||
}
|
||||
@@ -309,7 +309,7 @@ QVector<BcuEffectState> HandelEffects::getOverrides()
|
||||
break;
|
||||
|
||||
}
|
||||
DEBUG_LOG() << "getOverrides "
|
||||
DEBUG_LOG(m_logger) << "getOverrides "
|
||||
<< " id=" << override.id
|
||||
<< " type=" << override.type
|
||||
<< " override" << override.effectOverride;
|
||||
@@ -335,7 +335,7 @@ void HandelEffects::sendHttpRequest(const QUrl &url)
|
||||
{
|
||||
QUrl copy = url;
|
||||
copy.setHost(m_hostname);
|
||||
DEBUG_LOG() << "sendHttpRequest" << copy.toString();
|
||||
DEBUG_LOG(m_logger) << "sendHttpRequest" << copy.toString();
|
||||
emit newHttpRequest(copy, HandleHttpQueueMessageStatus::MS_Single);
|
||||
}
|
||||
|
||||
@@ -349,7 +349,7 @@ void HandelEffects::onRelayStateTimerTimeout()
|
||||
emit sendRelayState(m_relayState);
|
||||
m_overridesSend = false;
|
||||
}
|
||||
DEBUG_LOG() << "send get relay-State contents()=" << contents().toString()
|
||||
DEBUG_LOG(m_logger) << "send get relay-State contents()=" << contents().toString()
|
||||
<< " m_offlineCounter=" << m_offlineCounter;
|
||||
QUrl url = XmlReader::createPreparedUrl(contents(), m_hostname);
|
||||
url.setPath(QStringLiteral("/relay.php"));
|
||||
@@ -364,12 +364,12 @@ void HandelEffects::onRelayStateTimerTimeout()
|
||||
void HandelEffects::handleEgcuReplyObject(const QString &host, const QByteArray &data)
|
||||
{
|
||||
bool relayStateChanged = false;
|
||||
TRACE_LOG() << "handleEgcuReply Object:" << data
|
||||
TRACE_LOG(m_logger) << "handleEgcuReply Object:" << data
|
||||
<< " m_offlineState=" << m_offlineState;
|
||||
|
||||
if (m_offlineState)
|
||||
{
|
||||
DEBUG_LOG() << "State wiederherstellen !!!!!!!!!!! m_offlineState=" << m_offlineState;
|
||||
DEBUG_LOG(m_logger) << "State wiederherstellen !!!!!!!!!!! m_offlineState=" << m_offlineState;
|
||||
m_offlineState = false;
|
||||
setOverrides(m_effectStates);
|
||||
}
|
||||
@@ -384,7 +384,7 @@ void HandelEffects::handleEgcuReplyObject(const QString &host, const QByteArray
|
||||
rsi.id = it.key().toInt();
|
||||
rsi.state = it.value().isString() ? (it.value().toString().compare(QLatin1String("on"), Qt::CaseInsensitive) == 0) : it.value().toBool(false);
|
||||
m_relayState.relayStates.append(rsi);
|
||||
TRACE_LOG() << "id=" << rsi.id
|
||||
TRACE_LOG(m_logger) << "id=" << rsi.id
|
||||
<< " state=" << rsi.state;
|
||||
}
|
||||
if ( m_relayState.relayStates.size() == lastRelayState.relayStates.size())
|
||||
@@ -393,19 +393,19 @@ void HandelEffects::handleEgcuReplyObject(const QString &host, const QByteArray
|
||||
{
|
||||
if (m_relayState.relayStates[i].state != lastRelayState.relayStates[i].state)
|
||||
{
|
||||
TRACE_LOG() << "Values relayStateChanged = true";
|
||||
TRACE_LOG(m_logger) << "Values relayStateChanged = true";
|
||||
relayStateChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TRACE_LOG() << "Size relayStateChanged = true";
|
||||
TRACE_LOG(m_logger) << "Size relayStateChanged = true";
|
||||
relayStateChanged = true;
|
||||
}
|
||||
if ( m_offlineCounter > 1)
|
||||
{
|
||||
TRACE_LOG() << "m_offlineCounter=" << m_offlineCounter;
|
||||
TRACE_LOG(m_logger) << "m_offlineCounter=" << m_offlineCounter;
|
||||
relayStateChanged = true;
|
||||
}
|
||||
|
||||
@@ -413,7 +413,7 @@ void HandelEffects::handleEgcuReplyObject(const QString &host, const QByteArray
|
||||
m_relayState.stateTime = QDateTime::currentMSecsSinceEpoch();
|
||||
m_relayState.offlineTime = 0;
|
||||
m_offlineCounter=0;
|
||||
DEBUG_LOG() << "host=" << host.toLower()
|
||||
DEBUG_LOG(m_logger) << "host=" << host.toLower()
|
||||
<< " relayStateChanged=" << relayStateChanged
|
||||
<< " m_overridesSend=" << m_overridesSend
|
||||
<< " m_offlineState=" << m_offlineState;
|
||||
@@ -427,7 +427,7 @@ void HandelEffects::handleEgcuReplyObject(const QString &host, const QByteArray
|
||||
|
||||
if ( m_relayState.hostname.toLower() == host.toLower() && relayStateChanged)
|
||||
{
|
||||
DEBUG_LOG() << "emit sendRelayState(m_relayState) relayStateChanged";
|
||||
DEBUG_LOG(m_logger) << "emit sendRelayState(m_relayState) relayStateChanged";
|
||||
emit sendRelayState(m_relayState);
|
||||
}
|
||||
}
|
||||
@@ -435,7 +435,7 @@ void HandelEffects::handleEgcuReplyObject(const QString &host, const QByteArray
|
||||
void HandelEffects::handleEgcuReplyArray(const QString &host, const QByteArray &data)
|
||||
{
|
||||
Q_UNUSED (host);
|
||||
TRACE_LOG() << "handleEgcuReply Array:" << data;
|
||||
TRACE_LOG(m_logger) << "handleEgcuReply Array:" << data;
|
||||
m_relayState.relayStates.clear();
|
||||
|
||||
const QJsonObject jsonObject = QJsonDocument::fromJson(data).object();
|
||||
@@ -449,7 +449,7 @@ void HandelEffects::handleEgcuReplyArray(const QString &host, const QByteArray &
|
||||
rsi.id = i;
|
||||
rsi.state = stateArray[i].isString() ? (stateArray[i].toString().compare(QLatin1String("on"), Qt::CaseInsensitive)== 0 ): stateArray[i].toBool(false);
|
||||
m_relayState.relayStates.append(rsi);
|
||||
TRACE_LOG() << "id=" << rsi.id
|
||||
TRACE_LOG(m_logger) << "id=" << rsi.id
|
||||
<< " state=" << rsi.state;
|
||||
}
|
||||
|
||||
@@ -466,7 +466,7 @@ void HandelEffects::handleEgcuReplyArray(const QString &host, const QByteArray &
|
||||
void HandelEffects::handleEgcuReply(const QString &host, const QByteArray &data)
|
||||
{
|
||||
|
||||
DEBUG_LOG() << "HandelEffects::handleEgcuReply host=" << host
|
||||
DEBUG_LOG(m_logger) << "HandelEffects::handleEgcuReply host=" << host
|
||||
<< " m_hostname=" << m_hostname
|
||||
<< " m_overridesSend=" << m_overridesSend;
|
||||
|
||||
@@ -477,18 +477,18 @@ void HandelEffects::handleEgcuReply(const QString &host, const QByteArray &data)
|
||||
if (!jsonObject.contains(QStringLiteral("State")) )
|
||||
{
|
||||
m_overridesSend = true;
|
||||
TRACE_LOG() << "No State return";
|
||||
TRACE_LOG(m_logger) << "No State return";
|
||||
return;
|
||||
}
|
||||
const QJsonValue jsonValue = jsonObject[QStringLiteral("State")];
|
||||
if (jsonValue.isArray())
|
||||
{
|
||||
TRACE_LOG() << "data isArray\n";
|
||||
TRACE_LOG(m_logger) << "data isArray\n";
|
||||
handleEgcuReplyArray(host, data);
|
||||
}
|
||||
else
|
||||
{
|
||||
TRACE_LOG() << "data isObject\n";
|
||||
TRACE_LOG(m_logger) << "data isObject\n";
|
||||
handleEgcuReplyObject(host, data);
|
||||
}
|
||||
|
||||
|
||||
+25
-25
@@ -21,11 +21,11 @@ bool XmlReader::init(const QString &effectConfigFile)
|
||||
m_contents.effects.clear();
|
||||
|
||||
QFile file(effectConfigFile);
|
||||
DEBUG_LOG() << "open effectConfigFile: " << effectConfigFile;
|
||||
DEBUG_LOG(m_logger) << "open effectConfigFile: " << effectConfigFile;
|
||||
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
{
|
||||
WARNING_LOG() << "Couldn't open EffectConfigFile: " << effectConfigFile;
|
||||
WARNING_LOG(m_logger) << "Couldn't open EffectConfigFile: " << effectConfigFile;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -63,18 +63,18 @@ bool XmlReader::init(const QString &effectConfigFile)
|
||||
|
||||
if (xml.hasError())
|
||||
{
|
||||
ERROR_LOG() << "Effect Config File had XML Errors:\n" << xml.errorString();
|
||||
ERROR_LOG(m_logger) << "Effect Config File had XML Errors:\n" << xml.errorString();
|
||||
return false;
|
||||
}
|
||||
|
||||
DEBUG_LOG() << "Effect Config File Contents: " << m_contents.toString();
|
||||
DEBUG_LOG(m_logger) << "Effect Config File Contents: " << m_contents.toString();
|
||||
createHttpRequests();
|
||||
return true;
|
||||
}
|
||||
|
||||
Effect *XmlReader::parseEffect(QXmlStreamReader &xml)
|
||||
{
|
||||
DEBUG_LOG() << "- parseEffect Start";
|
||||
DEBUG_LOG(m_logger) << "- parseEffect Start";
|
||||
|
||||
if (xml.tokenType() != QXmlStreamReader::StartElement ||
|
||||
xml.name() != QStringLiteral("effect"))
|
||||
@@ -125,12 +125,12 @@ Effect *XmlReader::parseEffect(QXmlStreamReader &xml)
|
||||
}
|
||||
xml.readNext();
|
||||
}
|
||||
DEBUG_LOG() << "- parseEffect: Name: " << e->id
|
||||
DEBUG_LOG(m_logger) << "- parseEffect: Name: " << e->id
|
||||
<< ", Type: " << e->effectType
|
||||
<< ", Category: " << e->category
|
||||
<< ", Name: " << e->name
|
||||
<< ", override: " << e->override;
|
||||
DEBUG_LOG() << "- parseEffect End. It has " << e->ranges.size() << " ranges";
|
||||
DEBUG_LOG(m_logger) << "- parseEffect End. It has " << e->ranges.size() << " ranges";
|
||||
return e;
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ Range *XmlReader::parseRange(QXmlStreamReader &xml)
|
||||
xml.name() != QStringLiteral("range"))
|
||||
return {};
|
||||
|
||||
DEBUG_LOG() << "-- parseRange Start";
|
||||
DEBUG_LOG(m_logger) << "-- parseRange Start";
|
||||
Range *r = new Range();
|
||||
|
||||
QXmlStreamAttributes attributes = xml.attributes();
|
||||
@@ -164,10 +164,10 @@ Range *XmlReader::parseRange(QXmlStreamReader &xml)
|
||||
|
||||
xml.readNext();
|
||||
}
|
||||
DEBUG_LOG() << "-- parseRange: [" << r->min << "-" << r->max << "]"
|
||||
DEBUG_LOG(m_logger) << "-- parseRange: [" << r->min << "-" << r->max << "]"
|
||||
<< ", restartOnChange: " <<r->restartOnChange
|
||||
<< ", ActionCount: " << r->actions.count();
|
||||
DEBUG_LOG() << "-- parseRange End";
|
||||
DEBUG_LOG(m_logger) << "-- parseRange End";
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ Action *XmlReader::parseAction(QXmlStreamReader &xml)
|
||||
if (xml.name() == QStringLiteral("bsm"))
|
||||
return parseBsmAction(xml);
|
||||
|
||||
WARNING_LOG() << "--- parseUnknownAction with name '" << xml.name().string() << "'cannot be handled.";
|
||||
WARNING_LOG(m_logger) << "--- parseUnknownAction with name '" << xml.name().string() << "'cannot be handled.";
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -198,18 +198,18 @@ PauseAction *XmlReader::parsePauseAction(QXmlStreamReader &xml)
|
||||
xml.name() != QLatin1String("pause"))
|
||||
return {};
|
||||
|
||||
DEBUG_LOG() << "--- parsePauseAction Start";
|
||||
DEBUG_LOG(m_logger) << "--- parsePauseAction Start";
|
||||
QXmlStreamAttributes attributes = xml.attributes();
|
||||
PauseAction *p = new PauseAction();
|
||||
p->atype = static_cast<ActionType>(attributes.value(QStringLiteral("type")).toInt());
|
||||
if (attributes.hasAttribute(QStringLiteral("comment")))
|
||||
p->comment = attributes.value(QStringLiteral("comment")).toString();
|
||||
p->pause = xml.readElementText().toInt();
|
||||
DEBUG_LOG() << "--- parsePauseAction: "
|
||||
DEBUG_LOG(m_logger) << "--- parsePauseAction: "
|
||||
<< " Pause: " << p->pause
|
||||
<< ", Comment: " << p->comment;
|
||||
|
||||
DEBUG_LOG() << "--- parsePauseAction End";
|
||||
DEBUG_LOG(m_logger) << "--- parsePauseAction End";
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ RepeatAction *XmlReader::parseRepeatAction(QXmlStreamReader &xml)
|
||||
if (xml.tokenType() != QXmlStreamReader::StartElement ||
|
||||
xml.name() != QStringLiteral("repeat"))
|
||||
return {};
|
||||
DEBUG_LOG() << "--- parseRepeatAction Start";
|
||||
DEBUG_LOG(m_logger) << "--- parseRepeatAction Start";
|
||||
RepeatAction *ra = new RepeatAction();
|
||||
QXmlStreamAttributes attributes = xml.attributes();
|
||||
|
||||
@@ -244,8 +244,8 @@ RepeatAction *XmlReader::parseRepeatAction(QXmlStreamReader &xml)
|
||||
QString repetitions = QString::number(ra->count);
|
||||
if (ra->count < 0)
|
||||
repetitions = QLatin1String("Infinite");
|
||||
DEBUG_LOG() << "--- parseRepeatAction: Repetitions: " << repetitions << ", Comment: " << ra->comment;
|
||||
DEBUG_LOG() << "--- parseRepeatAction End";
|
||||
DEBUG_LOG(m_logger) << "--- parseRepeatAction: Repetitions: " << repetitions << ", Comment: " << ra->comment;
|
||||
DEBUG_LOG(m_logger) << "--- parseRepeatAction End";
|
||||
return ra;
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ Action *XmlReader::parseStandardAction(QXmlStreamReader &xml)
|
||||
xml.name() != QStringLiteral("action"))
|
||||
return {};
|
||||
|
||||
DEBUG_LOG() << "--- parseStandardAction Start";
|
||||
DEBUG_LOG(m_logger) << "--- parseStandardAction Start";
|
||||
|
||||
QXmlStreamAttributes attributes = xml.attributes();
|
||||
|
||||
@@ -269,9 +269,9 @@ Action *XmlReader::parseStandardAction(QXmlStreamReader &xml)
|
||||
a->atype = static_cast<ActionType>(attributes.value(QStringLiteral("type")).toInt());
|
||||
if (attributes.hasAttribute(QStringLiteral("comment")))
|
||||
a->comment = attributes.value(QStringLiteral("comment")).toString();
|
||||
DEBUG_LOG() << "--- parseStandardAction: Type: " << a->atype
|
||||
DEBUG_LOG(m_logger) << "--- parseStandardAction: Type: " << a->atype
|
||||
<< ", Comment: " << a->comment;
|
||||
DEBUG_LOG() << "--- parseStandardAction End";
|
||||
DEBUG_LOG(m_logger) << "--- parseStandardAction End";
|
||||
return a;
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ BsmAction *XmlReader::parseBsmAction(QXmlStreamReader &xml)
|
||||
QXmlStreamAttributes attributes = xml.attributes();
|
||||
|
||||
|
||||
DEBUG_LOG() << "--- parseBsmAction Start";
|
||||
DEBUG_LOG(m_logger) << "--- parseBsmAction Start";
|
||||
BsmAction *a = new BsmAction();
|
||||
a->atype = static_cast<ActionType>(attributes.value(QStringLiteral("type")).toInt());
|
||||
if (attributes.hasAttribute(QStringLiteral("comment")))
|
||||
@@ -302,14 +302,14 @@ BsmAction *XmlReader::parseBsmAction(QXmlStreamReader &xml)
|
||||
xml.readNext();
|
||||
}
|
||||
|
||||
DEBUG_LOG() << "--- parseBsmAction: Type: " << a->atype
|
||||
DEBUG_LOG(m_logger) << "--- parseBsmAction: Type: " << a->atype
|
||||
<< ", Pause: " << a->pause
|
||||
<< ", Choplength: " << a->choplength
|
||||
<< ", Count: " << a->count
|
||||
<< ", Pulses: " << a->pulses
|
||||
<< ", Pulseduration: " << a->pulseduration
|
||||
<< ", Comment: " << a->comment;
|
||||
DEBUG_LOG() << "--- parseBsmAction End";
|
||||
DEBUG_LOG(m_logger) << "--- parseBsmAction End";
|
||||
return a;
|
||||
}
|
||||
|
||||
@@ -384,7 +384,7 @@ void XmlReader::generateUrl(const Effect *e, Action *a)
|
||||
}
|
||||
url.setQuery(query);
|
||||
a->url = url;
|
||||
DEBUG_LOG() << "Effect " << e->name << ", Action '" << a->comment << "' now has URL: " << url.toString();
|
||||
DEBUG_LOG(m_logger) << "Effect " << e->name << ", Action '" << a->comment << "' now has URL: " << url.toString();
|
||||
break;
|
||||
}
|
||||
case AC_Repeat:
|
||||
@@ -397,7 +397,7 @@ void XmlReader::generateUrl(const Effect *e, Action *a)
|
||||
case AC_Pause:
|
||||
case AC_Bsm:
|
||||
default:
|
||||
DEBUG_LOG() << "Effect " << e->name << ", Action '" << a->comment << "' of Type " << a->aclass << " needs no URL";
|
||||
DEBUG_LOG(m_logger) << "Effect " << e->name << ", Action '" << a->comment << "' of Type " << a->aclass << " needs no URL";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -178,6 +178,7 @@ public:
|
||||
XmlContents contents() const { return m_contents; }
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void createHttpRequests();
|
||||
static QString categoryName(Category c);
|
||||
|
||||
|
||||
+3
-3
@@ -65,7 +65,7 @@ void Api::sendHitResult(const HitResult &hitResult, const QMap <int, Contaminati
|
||||
tele.hitResult.contaminations += csi;
|
||||
}
|
||||
|
||||
DEBUG_LOG() << Q_FUNC_INFO << ", tele = " << tele.toJson();
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << ", tele = " << tele.toJson();
|
||||
|
||||
m_webSocketHandler->sendTelegram(&tele, ws);
|
||||
}
|
||||
@@ -141,7 +141,7 @@ void Api::sendEffectOverrides(const QString &segment,
|
||||
|
||||
void Api::onTelegramReceived(const std::shared_ptr<Telegrams::BaseTelegram> &tele)
|
||||
{
|
||||
DEBUG_LOG() << "tele->telegramId(): " << tele->telegramId();
|
||||
DEBUG_LOG(m_logger) << "tele->telegramId(): " << tele->telegramId();
|
||||
|
||||
if (tele->telegramId() == Telegrams::SetDamageState::telegramId())
|
||||
{
|
||||
@@ -271,7 +271,7 @@ void Api::onTelegramReceived(const std::shared_ptr<Telegrams::BaseTelegram> &tel
|
||||
emit getBsmTechnicalStatus(tel->sensorId);
|
||||
return;
|
||||
}
|
||||
WARNING_LOG() << "Received unhandled telegram " << tele->telegramId();
|
||||
WARNING_LOG(m_logger) << "Received unhandled telegram " << tele->telegramId();
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
@@ -76,6 +76,7 @@ Q_SIGNALS:
|
||||
private Q_SLOTS:
|
||||
void onTelegramReceived(const std::shared_ptr<Telegrams::BaseTelegram> &tele);
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
WebSocketHandler *m_webSocketHandler;
|
||||
};
|
||||
}
|
||||
|
||||
+8
-9
@@ -11,10 +11,9 @@ namespace BuildingControlUnit
|
||||
{
|
||||
namespace Json
|
||||
{
|
||||
WebSocketHandler::WebSocketHandler(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_webSocketServer(new QWebSocketServer(QStringLiteral("BCU"), QWebSocketServer::NonSecureMode, this))
|
||||
{}
|
||||
WebSocketHandler::WebSocketHandler(QObject *parent) : QObject(parent)
|
||||
, m_webSocketServer(new QWebSocketServer(QStringLiteral("BCU"), QWebSocketServer::NonSecureMode, this)),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {}
|
||||
|
||||
WebSocketHandler::~WebSocketHandler()
|
||||
{
|
||||
@@ -30,7 +29,7 @@ bool WebSocketHandler::init(quint16 listenPort)
|
||||
{
|
||||
if (!m_webSocketServer->listen(QHostAddress::Any, listenPort))
|
||||
{
|
||||
WARNING_LOG() << "Can not listen on port " << listenPort << " - aborting";
|
||||
WARNING_LOG(m_logger) << "Can not listen on port " << listenPort << " - aborting";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -48,7 +47,7 @@ bool WebSocketHandler::sendTelegram(const Telegrams::BaseTelegram *tele, QWebSoc
|
||||
return false;
|
||||
|
||||
const QString jsonStr = QString::fromUtf8(tele->toJson());
|
||||
DEBUG_LOG() << "jsonStr" << jsonStr;
|
||||
DEBUG_LOG(m_logger) << "jsonStr" << jsonStr;
|
||||
|
||||
bool bOk = false;
|
||||
for (QWebSocket *ws : std::as_const(m_webSockets))
|
||||
@@ -68,7 +67,7 @@ void WebSocketHandler::onNewConnection()
|
||||
QWebSocket *ws = m_webSocketServer->nextPendingConnection();
|
||||
if (!ws)
|
||||
return;
|
||||
DEBUG_LOG() << "New websocket connection from " << ws->peerAddress().toString() << ":" << ws->peerPort();
|
||||
DEBUG_LOG(m_logger) << "New websocket connection from " << ws->peerAddress().toString() << ":" << ws->peerPort();
|
||||
|
||||
connect(ws, &QWebSocket::textMessageReceived,
|
||||
this, &WebSocketHandler::onTextMessageReceived);
|
||||
@@ -82,11 +81,11 @@ void WebSocketHandler::onNewConnection()
|
||||
|
||||
void WebSocketHandler::onTextMessageReceived(const QString &msg)
|
||||
{
|
||||
DEBUG_LOG() << "new text message: " << msg;
|
||||
DEBUG_LOG(m_logger) << "new text message: " << msg;
|
||||
auto tele = std::shared_ptr<Telegrams::BaseTelegram>(Telegrams::BaseTelegram::telegramFromJson(msg.toUtf8()));
|
||||
if (!tele)
|
||||
{
|
||||
WARNING_LOG() << "Error parsing incoming json data: '" << msg << "'";
|
||||
WARNING_LOG(m_logger) << "Error parsing incoming json data: '" << msg << "'";
|
||||
return;
|
||||
}
|
||||
emit telegramReceived(tele);
|
||||
|
||||
+1
@@ -41,6 +41,7 @@ private Q_SLOTS:
|
||||
void onWebSocketDisconnected();
|
||||
void onTextMessageReceived(const QString &msg);
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
QWebSocketServer *m_webSocketServer;
|
||||
QSet<QWebSocket *> m_webSockets;
|
||||
};
|
||||
|
||||
+7
-8
@@ -13,10 +13,9 @@
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
|
||||
Test::Test()
|
||||
: m_api(new BuildingControlUnit::VWM::Api(this))
|
||||
.getNGLLogger("BCU.VWM.Test"))
|
||||
{
|
||||
Test::Test() : m_api(new BuildingControlUnit::VWM::Api(this))
|
||||
.getNGLLogger("BCU.VWM.Test")),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
connect(m_api, &BuildingControlUnit::VWM::Api::hitResult,
|
||||
this, &Test::hitResult);
|
||||
QTimer::singleShot(0, this, &Test::test1);
|
||||
@@ -29,7 +28,7 @@ Test::~Test()
|
||||
|
||||
void Test::hitResult(const BuildingControlUnit::HitResult &result)
|
||||
{
|
||||
INFO_LOG() << "Hit Result: sensorId = " << result.sensorId
|
||||
INFO_LOG(m_logger) << "Hit Result: sensorId = " << result.sensorId
|
||||
<< ", originatorId = " << result.originatorId
|
||||
<< ", chargeTypeId = " << result.chargeTypeId
|
||||
<< ", dmgPercentOld = " << result.damagePercentOld
|
||||
@@ -54,18 +53,18 @@ void Test::test1()
|
||||
const auto hitPos = BuildingControlUnit::VWM::Math::checkBsmPosition(bsm.position, bsm.direction, rooms);
|
||||
if (hitPos.state != BuildingControlUnit::VWM::HitPosition::State::OuterWall)
|
||||
{
|
||||
WARNING_LOG() << "Effect on bsm " << bsm.id << " does not hit building ! - position: "
|
||||
WARNING_LOG(m_logger) << "Effect on bsm " << bsm.id << " does not hit building ! - position: "
|
||||
<< bsm.position << ", direction: " << bsm.direction;
|
||||
}
|
||||
else if (hitPos.distance < 0)
|
||||
{
|
||||
WARNING_LOG() << "Effect on bsm " << bsm.id << " results in hit pos behind a wall ("
|
||||
WARNING_LOG(m_logger) << "Effect on bsm " << bsm.id << " results in hit pos behind a wall ("
|
||||
<< hitPos.distance << "m) instead in front - BSM is not modelled in the correct place: "
|
||||
<< bsm.position << ", direction: " << bsm.direction << ", roomId which was hit: " << hitPos.roomId;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_LOG() << "BSM with id " << bsm.id << " looks fine - room which will be hit: " << hitPos.roomId;
|
||||
DEBUG_LOG(m_logger) << "BSM with id " << bsm.id << " looks fine - room which will be hit: " << hitPos.roomId;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -24,4 +24,5 @@ private Q_SLOTS:
|
||||
void test5();
|
||||
void test6();
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
+49
-49
@@ -38,7 +38,7 @@ bool Api::init(const QString &chargesConfig,
|
||||
const BuildingBsmConfig &bsmConfig,
|
||||
const bool initBuilding)
|
||||
{
|
||||
DEBUG_LOG() << "chargesConfig=" << chargesConfig;
|
||||
DEBUG_LOG(m_logger) << "chargesConfig=" << chargesConfig;
|
||||
if (!XmlReader::readCharges(chargesConfig, m_chargeMap))
|
||||
return false;
|
||||
if (!XmlReader::readBuilding(vulBuildingConfig, m_building))
|
||||
@@ -48,21 +48,21 @@ bool Api::init(const QString &chargesConfig,
|
||||
QString fltXml = QString(QStringLiteral("/opt/BuildingModels/StaticMeshes/%1.flt.xml")).arg(m_building.name());
|
||||
if (!XmlReader::readBuildingGeometry(fltXml, m_buildingRoomGeometry ))
|
||||
{
|
||||
ERROR_LOG() << "Error reading buildingRoomGeometry from file: " << fltXml << "'";
|
||||
ERROR_LOG(m_logger) << "Error reading buildingRoomGeometry from file: " << fltXml << "'";
|
||||
|
||||
}
|
||||
|
||||
DEBUG_LOG() << "Building buildingRoomGeometry read successfully from file: " << fltXml << "'";
|
||||
DEBUG_LOG(m_logger) << "Building buildingRoomGeometry read successfully from file: " << fltXml << "'";
|
||||
|
||||
|
||||
|
||||
int numberOfRemoved = m_building.cleanupPolygons();
|
||||
int numberOfDuplicates = m_building.checkPolygons();
|
||||
DEBUG_LOG() << "Building cleanupPolygons: " << m_building.name() << "' -> " << numberOfRemoved << " points removed";
|
||||
DEBUG_LOG(m_logger) << "Building cleanupPolygons: " << m_building.name() << "' -> " << numberOfRemoved << " points removed";
|
||||
if (numberOfDuplicates > 0)
|
||||
ERROR_LOG() << "Building checkPolygons: " << m_building.name() << "' -> " << numberOfDuplicates << " duplicates";
|
||||
ERROR_LOG(m_logger) << "Building checkPolygons: " << m_building.name() << "' -> " << numberOfDuplicates << " duplicates";
|
||||
else
|
||||
DEBUG_LOG() << "Building checkPolygons: " << m_building.name() << "' -> " << numberOfDuplicates << " duplicates";
|
||||
DEBUG_LOG(m_logger) << "Building checkPolygons: " << m_building.name() << "' -> " << numberOfDuplicates << " duplicates";
|
||||
|
||||
|
||||
m_bsmMap = bsmConfig.bsmMap;
|
||||
@@ -85,7 +85,7 @@ void Api::onHitOptical(qint64 timeMSec, int sensorId, int originatorId, int char
|
||||
|
||||
if (!bsm.isValid())
|
||||
{
|
||||
WARNING_LOG() << "Given bsm id " << sensorId << " is not in our internal bsm list!";
|
||||
WARNING_LOG(m_logger) << "Given bsm id " << sensorId << " is not in our internal bsm list!";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ void Api::onHitOptical(qint64 timeMSec, int sensorId, int originatorId, int char
|
||||
|
||||
void Api::onSetEffectStatesRequest(const QString &hostname, const QVector<BcuEffectState> &effectStates)
|
||||
{
|
||||
DEBUG_LOG() << "onSetEffectStatesRequest:"
|
||||
DEBUG_LOG(m_logger) << "onSetEffectStatesRequest:"
|
||||
<< " hostname= " << hostname
|
||||
<< " effectStes.zize=" << effectStates.size();
|
||||
|
||||
@@ -120,7 +120,7 @@ void Api::onSetEffectStatesRequest(const QString &hostname, const QVector<BcuEff
|
||||
if (es.effectOverride == BcuEffectOverride::BEO_Off)
|
||||
{
|
||||
overridesObj.insert(QStringLiteral("flash"), 0);
|
||||
DEBUG_LOG() << "flash = 0";
|
||||
DEBUG_LOG(m_logger) << "flash = 0";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -137,14 +137,14 @@ void Api::onSetEffectStatesRequest(const QString &hostname, const QVector<BcuEff
|
||||
{
|
||||
QJsonObject relayStateObj;
|
||||
relayStateObj[QString::number(es.id)]=es.effectOverride;
|
||||
DEBUG_LOG() << "relay = " << QString::number(es.id)
|
||||
DEBUG_LOG(m_logger) << "relay = " << QString::number(es.id)
|
||||
<< " " << es.effectOverride;
|
||||
relayStateArray.append(relayStateObj);
|
||||
}
|
||||
else if (es.type == BcuEffectType::BET_BackgroundSound)
|
||||
{
|
||||
overridesObj.insert(QStringLiteral("sound"), es.effectOverride);
|
||||
DEBUG_LOG() << "sound=" << es.effectOverride;
|
||||
DEBUG_LOG(m_logger) << "sound=" << es.effectOverride;
|
||||
}
|
||||
}
|
||||
overridesObj.insert(QStringLiteral("relays"), relayStateArray);
|
||||
@@ -154,7 +154,7 @@ void Api::onSetEffectStatesRequest(const QString &hostname, const QVector<BcuEff
|
||||
propertiesObj[QStringLiteral("Overrides")] = overridesObj;
|
||||
|
||||
QString totalString = QString::fromLatin1(QJsonDocument(propertiesObj).toJson(QJsonDocument::Compact));
|
||||
DEBUG_LOG() << "totalString=" << totalString;
|
||||
DEBUG_LOG(m_logger) << "totalString=" << totalString;
|
||||
m_building.setSegmentProperties(hostname,totalString);
|
||||
StateStore::saveState(m_building, m_lastHitResult, m_contaminationStates);
|
||||
}
|
||||
@@ -264,15 +264,15 @@ void Api::onHitEcc(int originatorId, DamageState damageState, const QVector<int>
|
||||
|
||||
void Api::onSetContaminationState(const std::vector<ContaminationState> &contaminationStates)
|
||||
{
|
||||
DEBUG_LOG() << "contaminationStates.size=" << contaminationStates.size();
|
||||
DEBUG_LOG(m_logger) << "contaminationStates.size=" << contaminationStates.size();
|
||||
|
||||
for (const auto &newcs : contaminationStates)
|
||||
{
|
||||
DEBUG_LOG() << "newcs.damagePercentNew=" << newcs.damagePercentNew
|
||||
DEBUG_LOG(m_logger) << "newcs.damagePercentNew=" << newcs.damagePercentNew
|
||||
<< " m_lastHitResult.damagePercentNew=" << m_lastHitResult.damagePercentNew;
|
||||
if ( newcs.damagePercentNew > m_lastHitResult.damagePercentNew)
|
||||
{
|
||||
DEBUG_LOG() << "newcs.damagePercentNew=" << newcs.damagePercentNew;
|
||||
DEBUG_LOG(m_logger) << "newcs.damagePercentNew=" << newcs.damagePercentNew;
|
||||
m_lastHitResult.damagePercentNew = newcs.damagePercentNew;
|
||||
}
|
||||
if (m_contaminationStates.contains(newcs.aesId))
|
||||
@@ -302,7 +302,7 @@ void Api::onSetContaminationState(const std::vector<ContaminationState> &contami
|
||||
else
|
||||
m_contaminationStates.insert(newcs.aesId, newcs);
|
||||
}
|
||||
DEBUG_LOG() << "onSetContaminationState emit hitResult "
|
||||
DEBUG_LOG(m_logger) << "onSetContaminationState emit hitResult "
|
||||
<< " m_lastHitResult.damagePercentNew=" << m_lastHitResult.damagePercentNew;
|
||||
emit hitResult(m_lastHitResult, m_contaminationStates, false);
|
||||
StateStore::saveState(m_building, m_lastHitResult, m_contaminationStates);
|
||||
@@ -311,7 +311,7 @@ void Api::onSetContaminationState(const std::vector<ContaminationState> &contami
|
||||
void Api::onResetContaminations()
|
||||
{
|
||||
m_contaminationStates.clear();
|
||||
DEBUG_LOG() << "onResetContaminations emit hitResult";
|
||||
DEBUG_LOG(m_logger) << "onResetContaminations emit hitResult";
|
||||
m_lastHitResult.chargeTypeId = 0;
|
||||
m_lastHitResult.originatorId = 0;
|
||||
m_lastHitResult.originatorType = BuildingControlUnit::OriginatorType::ECC;
|
||||
@@ -338,7 +338,7 @@ void Api::onHitCes(const qint64 effectTimeMSec, const int chargeTypeId,
|
||||
|
||||
hit.position.setZ(1);
|
||||
|
||||
INFO_LOG() << "XXXXX CES Hit = " << hit;
|
||||
INFO_LOG(m_logger) << "XXXXX CES Hit = " << hit;
|
||||
|
||||
|
||||
|
||||
@@ -349,7 +349,7 @@ void Api::onHitCes(const qint64 effectTimeMSec, const int chargeTypeId,
|
||||
posTmp.setZ(10000);
|
||||
const LtsUtils::QPoint3D direction(0,0,1);
|
||||
const auto hitPosTmp = BuildingControlUnit::VWM::Math::checkBsmPosition(posTmp, direction, m_building.rooms());
|
||||
INFO_LOG() << "XXXXX hitPosTmp after checkBsmPosition = " << hitPosTmp;
|
||||
INFO_LOG(m_logger) << "XXXXX hitPosTmp after checkBsmPosition = " << hitPosTmp;
|
||||
if (hitPosTmp.state != BuildingControlUnit::VWM::HitPosition::State::NoHit)
|
||||
{
|
||||
auto room = m_building.rooms().value(hitPosTmp.roomId);
|
||||
@@ -382,7 +382,7 @@ void Api::onHitCes(const qint64 effectTimeMSec, const int chargeTypeId,
|
||||
NearestWall nearestWall;
|
||||
if (hitPos.state == BuildingControlUnit::VWM::HitPosition::State::NoHit)
|
||||
{
|
||||
INFO_LOG() << "XXXXX CES Hit outside building - searching nearest wall ...";
|
||||
INFO_LOG(m_logger) << "XXXXX CES Hit outside building - searching nearest wall ...";
|
||||
|
||||
double distanceOut = 0;
|
||||
LtsUtils::QPoint3D directionWallElementPointToDetonationOut;
|
||||
@@ -399,14 +399,14 @@ void Api::onHitCes(const qint64 effectTimeMSec, const int chargeTypeId,
|
||||
|
||||
if (hitPos.state == BuildingControlUnit::VWM::HitPosition::State::NoHit)
|
||||
{
|
||||
WARNING_LOG() << "Internal error - could not find impact position on building "
|
||||
WARNING_LOG(m_logger) << "Internal error - could not find impact position on building "
|
||||
<< m_building.name() << " with impact pos " << posImpactOnGround;
|
||||
}
|
||||
INFO_LOG() << "XXXXX Aes hit - hit pos: " << posImpactOnGround << " direction: " << hit.direction
|
||||
INFO_LOG(m_logger) << "XXXXX Aes hit - hit pos: " << posImpactOnGround << " direction: " << hit.direction
|
||||
<< " (p=" << hit.direction+posImpactOnGround << ")"
|
||||
<< " ; nearestWall.roomId=" << nearestWall.roomId;
|
||||
for (auto item : std::as_const(nearestWall.wallElement))
|
||||
DEBUG_LOG() << "Aes hit - hit pos: " << posImpactOnGround << " direction: " << hit.direction
|
||||
DEBUG_LOG(m_logger) << "Aes hit - hit pos: " << posImpactOnGround << " direction: " << hit.direction
|
||||
<< " (p=" << hit.direction+posImpactOnGround
|
||||
<< " - " << item;
|
||||
|
||||
@@ -417,7 +417,7 @@ void Api::onHitCes(const qint64 effectTimeMSec, const int chargeTypeId,
|
||||
|
||||
const LtsUtils::QPoint3D ¢er = centerOfWallElement3D(nearestWall.wallElement);
|
||||
|
||||
INFO_LOG() << "XXXXX Aes hit - hit pos: " << posImpactOnGround << " direction: " << hit.direction
|
||||
INFO_LOG(m_logger) << "XXXXX Aes hit - hit pos: " << posImpactOnGround << " direction: " << hit.direction
|
||||
<< ", m_building.name=" << m_building.name()
|
||||
<< ", m_building.modelId=" << m_building.modelId()
|
||||
<< ", nearestWall.roomId=" << nearestWall.roomId
|
||||
@@ -436,7 +436,7 @@ NearestWall Api::findNearestWall(const LtsUtils::QPoint3D &detonationLocation, d
|
||||
NearestWall nearestWall;
|
||||
distanceOut = std::numeric_limits<double>::max();
|
||||
|
||||
INFO_LOG() << "XXXXX searching nearest wall ...";
|
||||
INFO_LOG(m_logger) << "XXXXX searching nearest wall ...";
|
||||
for (const Room &room : std::as_const(m_building.rooms()))
|
||||
{
|
||||
for (const OuterWall &wall : std::as_const(room.outerWalls()))
|
||||
@@ -446,13 +446,13 @@ NearestWall Api::findNearestWall(const LtsUtils::QPoint3D &detonationLocation, d
|
||||
for (const LtsUtils::QPoint3D &p : std::as_const(we))
|
||||
{
|
||||
const double dist = (detonationLocation - p).length();
|
||||
DEBUG_LOG() << "Room[" << room.id() << "]: " << p << ", dist = " << dist;
|
||||
DEBUG_LOG(m_logger) << "Room[" << room.id() << "]: " << p << ", dist = " << dist;
|
||||
if (dist >= distanceOut)
|
||||
continue;
|
||||
|
||||
|
||||
distanceOut = dist;
|
||||
INFO_LOG() << "New min distance " << dist << " Room[" << room.id() << "]: " << p;
|
||||
INFO_LOG(m_logger) << "New min distance " << dist << " Room[" << room.id() << "]: " << p;
|
||||
directionWallElementPointToDetonationOut = p - detonationLocation;
|
||||
|
||||
nearestWall.roomId = room.id();
|
||||
@@ -486,7 +486,7 @@ void Api::onHitCes3D_Evaluation(const qint64 effectTimeMSec,
|
||||
|
||||
|
||||
|
||||
INFO_LOG() << "XXXXXXXXXX CES Hit 3D = " << hit
|
||||
INFO_LOG(m_logger) << "XXXXXXXXXX CES Hit 3D = " << hit
|
||||
<< ", detonationLocation = " << detonationLocation
|
||||
<< ", detonationDistance = " << detonationDistance
|
||||
<< ", chargeTypeId = " << chargeTypeId
|
||||
@@ -514,16 +514,16 @@ void Api::onHitCes3D_Evaluation(const qint64 effectTimeMSec,
|
||||
roomsWithDetonation = m_buildingRoomGeometry.pointIsInWhichRooms(detonationLocation);
|
||||
if (roomsWithDetonation.isEmpty())
|
||||
{
|
||||
INFO_LOG() << "XXXX Building '" << m_building.name() << "'"
|
||||
INFO_LOG(m_logger) << "XXXX Building '" << m_building.name() << "'"
|
||||
<< ", detonationLocation = " << detonationLocation
|
||||
<< " -> found no room";
|
||||
} else {
|
||||
if (roomsWithDetonation.size() == 1)
|
||||
INFO_LOG() << "XXXX Building '" << m_building.name() << "'"
|
||||
INFO_LOG(m_logger) << "XXXX Building '" << m_building.name() << "'"
|
||||
<< ", detonationLocation = " << detonationLocation
|
||||
<< " -> found just one room: " << roomsWithDetonation.first();
|
||||
else
|
||||
INFO_LOG() << "XXXX Building '" << m_building.name() << "'"
|
||||
INFO_LOG(m_logger) << "XXXX Building '" << m_building.name() << "'"
|
||||
<< ", detonationLocation = " << detonationLocation
|
||||
<< " -> found several rooms, choose first: " << roomsWithDetonation.first();
|
||||
|
||||
@@ -541,7 +541,7 @@ void Api::onHitCes3D_Evaluation(const qint64 effectTimeMSec,
|
||||
LtsUtils::QPoint3D directionWallElementPointToDetonationOut;
|
||||
NearestWall nearestWall = findNearestWall(detonationLocation, distanceOut, directionWallElementPointToDetonationOut);
|
||||
|
||||
INFO_LOG() << "XXXXX CES Hit outside building - searching nearest wall ..."
|
||||
INFO_LOG(m_logger) << "XXXXX CES Hit outside building - searching nearest wall ..."
|
||||
<< ", detonationDistance = " << detonationDistance
|
||||
<< ", nearestWall.roomId = " << nearestWall.roomId;
|
||||
|
||||
@@ -588,7 +588,7 @@ void Api::onHitCes3D_Evaluation(const qint64 effectTimeMSec,
|
||||
bool hitSuccess = m_building.hit(LtsUtils::QPoint3D(), LtsUtils::QPoint3D(),
|
||||
charge, &hitPosPreCalculated);
|
||||
|
||||
INFO_LOG() << "onHitCes3D_Evaluation hitSuccess=" << hitSuccess;
|
||||
INFO_LOG(m_logger) << "onHitCes3D_Evaluation hitSuccess=" << hitSuccess;
|
||||
|
||||
result.rooms = m_building.roomStates();
|
||||
result.damageState = m_building.damageState();
|
||||
@@ -627,7 +627,7 @@ void Api::onFortifyFactorRequest(int originatorId, const QVector<FortifyInfo> &f
|
||||
|
||||
void Api::onRelayStatesRequest(const QString &hostname, const QVector<RelayStateInfo> &relayStateInfos)
|
||||
{
|
||||
DEBUG_LOG() << "onRelayStateRequest hostname=" << hostname
|
||||
DEBUG_LOG(m_logger) << "onRelayStateRequest hostname=" << hostname
|
||||
<< " only hanlde in svcBuildings"
|
||||
<< " relayStateInfos.size()=" << relayStateInfos.size();
|
||||
}
|
||||
@@ -649,14 +649,14 @@ void Api::sendOverrides()
|
||||
|
||||
QJsonObject docObj = QJsonObject(doc.object());
|
||||
|
||||
DEBUG_LOG() << "sendOverrides hostname=" << hostname
|
||||
DEBUG_LOG(m_logger) << "sendOverrides hostname=" << hostname
|
||||
<< " properties=" << properties;
|
||||
|
||||
|
||||
|
||||
|
||||
{
|
||||
DEBUG_LOG() << "sendOverrides hostname=" << hostname
|
||||
DEBUG_LOG(m_logger) << "sendOverrides hostname=" << hostname
|
||||
<< " properties=" << properties << "BCU-Flash";
|
||||
BcuEffectState bcuEffectState;
|
||||
bcuEffectState.id = 1;
|
||||
@@ -677,7 +677,7 @@ void Api::sendOverrides()
|
||||
}
|
||||
if (eo != BcuEffectOverride::BEO_Auto)
|
||||
{
|
||||
DEBUG_LOG() << "bcuEffectState.effectOverride = eo" << eo;
|
||||
DEBUG_LOG(m_logger) << "bcuEffectState.effectOverride = eo" << eo;
|
||||
bcuEffectState.effectOverride = eo;
|
||||
emit newOverrides({}, {bcuEffectState});
|
||||
}
|
||||
@@ -726,7 +726,7 @@ void Api::sendHitToVwm(const Hit &hit)
|
||||
{
|
||||
m_hitsSinceLastInit += hit;
|
||||
|
||||
INFO_LOG() << " XXXXX sendHitToVwm, Incoming hit=" << hit
|
||||
INFO_LOG(m_logger) << " XXXXX sendHitToVwm, Incoming hit=" << hit
|
||||
<< " hit.chargeTypeId=" << hit.chargeTypeId
|
||||
<< " originatorId=" << hit.originatorId
|
||||
<< " typeOfHit=" << hit.typeOfHit;
|
||||
@@ -753,7 +753,7 @@ void Api::sendHitToVwm(const Hit &hit)
|
||||
charge.penetrationEffect = hit.penetrationFactor;
|
||||
}
|
||||
|
||||
DEBUG_LOG() << "charge=" << charge.chargeTypeId
|
||||
DEBUG_LOG(m_logger) << "charge=" << charge.chargeTypeId
|
||||
<< " destructiveFactor" << charge.destructiveFactor
|
||||
<< " penetrationEffect" << charge.penetrationEffect;
|
||||
chargeOrg = charge;
|
||||
@@ -770,23 +770,23 @@ void Api::sendHitToVwm(const Hit &hit)
|
||||
|
||||
LtsUtils::QPoint3D dummyDist = hit.position - hit.direction;
|
||||
|
||||
INFO_LOG() << " XXXX CES outside bulding, reduce charge: " << charge
|
||||
INFO_LOG(m_logger) << " XXXX CES outside bulding, reduce charge: " << charge
|
||||
<< ", hit.position " << hit.position
|
||||
<< ", hit.direction " << hit.direction
|
||||
<< ", dummyDist " << dummyDist.length();
|
||||
charge.destructiveFactor *= 0.5;
|
||||
charge.penetrationEffect *= 0.5;
|
||||
INFO_LOG() << " XXXX CES outside bulding, reduce charge: " << charge;
|
||||
INFO_LOG(m_logger) << " XXXX CES outside bulding, reduce charge: " << charge;
|
||||
}
|
||||
|
||||
if (!charge.isValid())
|
||||
{
|
||||
if (hit.originatorType == OriginatorType::CesHit)
|
||||
WARNING_LOG() << "Charge with id " << hit.chargeTypeId
|
||||
WARNING_LOG(m_logger) << "Charge with id " << hit.chargeTypeId
|
||||
<< " not configured - can not caluclate impact effect for this charge";
|
||||
else
|
||||
{
|
||||
WARNING_LOG() << "Direct charge with id " << hit.chargeTypeId
|
||||
WARNING_LOG(m_logger) << "Direct charge with id " << hit.chargeTypeId
|
||||
<< " not configured - can not caluclate impact effect for this charge";
|
||||
emit unknownDirectHit(hit.sensorId);
|
||||
}
|
||||
@@ -794,7 +794,7 @@ void Api::sendHitToVwm(const Hit &hit)
|
||||
}
|
||||
if (!m_building.hit(hit.position, hit.direction, charge))
|
||||
{
|
||||
WARNING_LOG() << "Detected hit was outside of the building - ignored";
|
||||
WARNING_LOG(m_logger) << "Detected hit was outside of the building - ignored";
|
||||
break;
|
||||
}
|
||||
result.rooms = m_building.roomStates();
|
||||
@@ -832,7 +832,7 @@ void Api::sendHitToVwm(const Hit &hit)
|
||||
{
|
||||
case DamageState::NoDamage:
|
||||
{
|
||||
DEBUG_LOG() << "Hit OC/ECC with NoDamage";
|
||||
DEBUG_LOG(m_logger) << "Hit OC/ECC with NoDamage";
|
||||
m_building.init();
|
||||
|
||||
result.effectSoundId = Settings::effectSoundIdEccActivate();
|
||||
@@ -855,7 +855,7 @@ void Api::sendHitToVwm(const Hit &hit)
|
||||
}
|
||||
case DamageState::Destroyed:
|
||||
{
|
||||
DEBUG_LOG() << "Hit OC/ECC with Destroyed";
|
||||
DEBUG_LOG(m_logger) << "Hit OC/ECC with Destroyed";
|
||||
const DamageState dsOld = m_building.damageState();
|
||||
|
||||
m_building.destroyAllRooms();
|
||||
@@ -879,14 +879,14 @@ void Api::sendHitToVwm(const Hit &hit)
|
||||
break;
|
||||
}
|
||||
default:
|
||||
WARNING_LOG() << "Invalid damage state override given: " << hit.damageStateOverride;
|
||||
WARNING_LOG(m_logger) << "Invalid damage state override given: " << hit.damageStateOverride;
|
||||
result = HitResult();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case OriginatorType::Unknown:
|
||||
WARNING_LOG() << "Unknown originator type given: " << hit.originatorType;
|
||||
WARNING_LOG(m_logger) << "Unknown originator type given: " << hit.originatorType;
|
||||
result = HitResult();
|
||||
break;
|
||||
}
|
||||
@@ -905,7 +905,7 @@ const Charge Api::chargeFromChargeTypeId(int chargeTypeId) const
|
||||
|
||||
for (auto i = m_chargeMap.cbegin(), end = m_chargeMap.cend(); i != end; ++i)
|
||||
{
|
||||
TRACE_LOG() << "key=" << i.key() << " value=" << i.value();
|
||||
TRACE_LOG(m_logger) << "key=" << i.key() << " value=" << i.value();
|
||||
if ( chargeTypeId == i.value().id)
|
||||
return m_chargeMap.value(i.key());
|
||||
}
|
||||
|
||||
@@ -77,6 +77,7 @@ Q_SIGNALS:
|
||||
void newOverrides( const QString &hostname, const QVector<BcuEffectState> &effectStates);
|
||||
void unknownDirectHit(int sensorId);
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void sendHitToVwm(const Hit &hit);
|
||||
private:
|
||||
QMap<int, Bsm> m_bsmMap;
|
||||
|
||||
+12
-12
@@ -354,7 +354,7 @@ int Building::cleanupDublicatePointsInPolygon(int roomId, int idx, int subIdx, c
|
||||
auto p2 = points.at(j);
|
||||
if (qFuzzyCompare(p1, p2))
|
||||
{
|
||||
DEBUG_LOG() << "Building '" << m_name << "' -> "
|
||||
DEBUG_LOG(m_logger) << "Building '" << m_name << "' -> "
|
||||
<< "Polygon point " << i << " (" << p1 << ") and " << j << " (" << p2
|
||||
<< ") in room " << roomId << ", " << type << "[" << idx
|
||||
<< "], element[" << subIdx << "] are the same! -> REMOVE";
|
||||
@@ -410,7 +410,7 @@ QVector<HitRoom> Building::roomStates() const
|
||||
hr.fortifyFactor = room.fortifyFactor();
|
||||
hr.directHit = room.isDirectHit();
|
||||
ret += hr;
|
||||
DEBUG_LOG() << "HitRoom " << hr.roomId
|
||||
DEBUG_LOG(m_logger) << "HitRoom " << hr.roomId
|
||||
<< " damage: " << hr.damagePercent
|
||||
<< "%, remainEffect: " << hr.remainingEffectPercent << "%"
|
||||
<< ", remainingEffectChargeTypeId: " << hr.remainingEffectChargeTypeId << "%"
|
||||
@@ -448,7 +448,7 @@ void Building::setRoomState(DamageState damageState, const QVector<int> &afffect
|
||||
auto it = m_rooms.find(roomId);
|
||||
if (it == m_rooms.end())
|
||||
{
|
||||
WARNING_LOG() << "Could not find room with id " << roomId;
|
||||
WARNING_LOG(m_logger) << "Could not find room with id " << roomId;
|
||||
continue;
|
||||
}
|
||||
if (damageState == DamageState::Destroyed)
|
||||
@@ -465,7 +465,7 @@ void Building::setFortifyInfo(const QVector<FortifyInfo> &foritfyInfos)
|
||||
auto it = m_rooms.find(info.roomId);
|
||||
if (it == m_rooms.end())
|
||||
{
|
||||
WARNING_LOG() << "Could not find room with id " << info.roomId;
|
||||
WARNING_LOG(m_logger) << "Could not find room with id " << info.roomId;
|
||||
continue;
|
||||
}
|
||||
Room &room = it.value();
|
||||
@@ -538,14 +538,14 @@ bool Building::hit(const LtsUtils::QPoint3D &pos, const LtsUtils::QPoint3D &dir,
|
||||
const bool bBelowGround = isLastHitPositionBelowGroundHack();
|
||||
if (bBelowGround)
|
||||
{
|
||||
INFO_LOG() << " XXXX CES belowGround, reduce charge: " << charge;
|
||||
INFO_LOG(m_logger) << " XXXX CES belowGround, reduce charge: " << charge;
|
||||
charge.destructiveFactor *= 0.25;
|
||||
charge.penetrationEffect *= 0.25;
|
||||
INFO_LOG() << " XXXX CES belowGround, reduce charge: " << charge;
|
||||
INFO_LOG(m_logger) << " XXXX CES belowGround, reduce charge: " << charge;
|
||||
}
|
||||
|
||||
|
||||
INFO_LOG() << "XXXXX HitPosition: state=" << m_lastHitPosition.state
|
||||
INFO_LOG(m_logger) << "XXXXX HitPosition: state=" << m_lastHitPosition.state
|
||||
<< ", m_name=" << m_name
|
||||
<< ", m_modelId=" << m_modelId
|
||||
<< ", roomId=" << m_lastHitPosition.roomId
|
||||
@@ -560,7 +560,7 @@ bool Building::hit(const LtsUtils::QPoint3D &pos, const LtsUtils::QPoint3D &dir,
|
||||
Room &hitRoom = m_rooms[m_lastHitPosition.roomId];
|
||||
if (!hitRoom.isValid())
|
||||
{
|
||||
ERROR_LOG() << "Internal error in hit calculation - could not find room with id " << m_lastHitPosition.roomId;
|
||||
ERROR_LOG(m_logger) << "Internal error in hit calculation - could not find room with id " << m_lastHitPosition.roomId;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -651,7 +651,7 @@ QMap<int, Building::NeighboursToCheck> Building::checkHitNeighbours(const QMap<i
|
||||
auto itRoom = m_rooms.find(neighbourRoomId);
|
||||
if (itRoom == m_rooms.end())
|
||||
{
|
||||
WARNING_LOG() << "Could not find room with id " << neighbourRoomId;
|
||||
WARNING_LOG(m_logger) << "Could not find room with id " << neighbourRoomId;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -670,7 +670,7 @@ QMap<int, Building::NeighboursToCheck> Building::checkHitNeighbours(const QMap<i
|
||||
|
||||
const double oldRe = neighbour.remainingEffect();
|
||||
neighbour.setRemainingEffect(neighbourRoom.remainEffect * TF);
|
||||
DEBUG_LOG() << "room " << neighbourRoomId << " remaining effect old: "
|
||||
DEBUG_LOG(m_logger) << "room " << neighbourRoomId << " remaining effect old: "
|
||||
<< oldRe << " -> new: " << neighbour.remainingEffect();
|
||||
|
||||
|
||||
@@ -740,7 +740,7 @@ int Building::checkDublicatePointsInPolygon(int roomId, int idx, int subIdx, con
|
||||
if (qFuzzyCompare(p1, p2))
|
||||
{
|
||||
++numberOfDuplicates;
|
||||
WARNING_LOG() << "Building '" << m_name << "' -> "
|
||||
WARNING_LOG(m_logger) << "Building '" << m_name << "' -> "
|
||||
<< "Polygon point " << i << " (" << p1 << ") and " << j << " (" << p2
|
||||
<< ") in room " << roomId << ", " << type << "[" << idx
|
||||
<< "], element[" << subIdx << "] are the same! (size=" << points.size() << ")";
|
||||
@@ -750,7 +750,7 @@ int Building::checkDublicatePointsInPolygon(int roomId, int idx, int subIdx, con
|
||||
|
||||
if (numberOfDuplicates > 0)
|
||||
for (auto point : points)
|
||||
WARNING_LOG() << "Building '" << m_name << "' -> " << "point =" << point << " (same points)";
|
||||
WARNING_LOG(m_logger) << "Building '" << m_name << "' -> " << "point =" << point << " (same points)";
|
||||
return numberOfDuplicates;
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -29,6 +29,8 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
int m_id = 0;
|
||||
double m_transitionFactor = 0;
|
||||
};
|
||||
|
||||
+11
-11
@@ -17,30 +17,30 @@ namespace VWM
|
||||
BuildingRoomGeometry::BuildingRoomGeometry()
|
||||
: m_logger(BuildingControlUnit::getLogger("VWM.BuildingRoomGeometry"))
|
||||
{
|
||||
TRACE_LOG() << Q_FUNC_INFO << " START";
|
||||
TRACE_LOG() << Q_FUNC_INFO << " END";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
}
|
||||
|
||||
BuildingRoomGeometry::~BuildingRoomGeometry()
|
||||
{
|
||||
TRACE_LOG() << Q_FUNC_INFO << " START";
|
||||
TRACE_LOG() << Q_FUNC_INFO << " END";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
}
|
||||
|
||||
bool BuildingRoomGeometry::init(const QDomElement &domRoot)
|
||||
{
|
||||
TRACE_LOG() << Q_FUNC_INFO << " START";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
|
||||
parse(domRoot);
|
||||
|
||||
TRACE_LOG() << Q_FUNC_INFO << " END";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QVector<int> BuildingRoomGeometry::pointIsInWhichRooms(const LtsUtils::QPoint3D &pointToFind)
|
||||
{
|
||||
TRACE_LOG() << Q_FUNC_INFO << " START, pointToFind" << pointToFind
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START, pointToFind" << pointToFind
|
||||
<< ", m_roomOutlines.size() " << m_roomOutlines.size();
|
||||
|
||||
QVector<int> roomtIds;
|
||||
@@ -52,26 +52,26 @@ QVector<int> BuildingRoomGeometry::pointIsInWhichRooms(const LtsUtils::QPoint3D
|
||||
const int roomId = it.key();
|
||||
const RoomOutlineData &rod = it.value();
|
||||
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " check room " << roomId << " (check maxZ " << rod.maxZ << " ; minZ " << rod.minZ;
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " check room " << roomId << " (check maxZ " << rod.maxZ << " ; minZ " << rod.minZ;
|
||||
if (m_logger.isDebugEnabled())
|
||||
qCritical() << " check room " << roomId << ", outline: " << rod.outline;
|
||||
|
||||
|
||||
if (rod.outline.containsPoint( {pointToFind.x(), pointToFind.y()}, Qt::OddEvenFill))
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " within room " << roomId;
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " within room " << roomId;
|
||||
|
||||
if ((rod.maxZ > pointToFind.z()) &&
|
||||
(pointToFind.z() > rod.minZ))
|
||||
{
|
||||
DEBUG_LOG() << Q_FUNC_INFO << " found roomId: " << roomId
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " found roomId: " << roomId
|
||||
<< " pointToFind: " << pointToFind.x() << " , " << pointToFind.y();
|
||||
roomtIds.append(roomId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TRACE_LOG() << Q_FUNC_INFO << " END, roomtIds.size() " << roomtIds.size();
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END, roomtIds.size() " << roomtIds.size();
|
||||
return roomtIds;
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -36,6 +36,8 @@ public:
|
||||
QVector<int> pointIsInWhichRooms(const LtsUtils::QPoint3D &pointToFind);
|
||||
|
||||
private:
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
bool parse(const QDomElement &domGroup);
|
||||
|
||||
|
||||
|
||||
+20
-21
@@ -9,12 +9,11 @@
|
||||
|
||||
namespace BuildingControlUnit
|
||||
{
|
||||
HandleHttpRequest::HandleHttpRequest(bool useQueue, QObject *parent)
|
||||
: QObject(parent)
|
||||
HandleHttpRequest::HandleHttpRequest(bool useQueue, QObject *parent) : QObject(parent)
|
||||
, m_nam(new QNetworkAccessManager(this))
|
||||
, m_bUseQueue(useQueue)
|
||||
{
|
||||
INFO_LOG() << "Using Queue: " << m_bUseQueue;
|
||||
, m_bUseQueue(useQueue),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
INFO_LOG(m_logger) << "Using Queue: " << m_bUseQueue;
|
||||
connect(m_nam, &QNetworkAccessManager::finished,
|
||||
this, &HandleHttpRequest::onReplyFinished);
|
||||
connect(m_nam, &QNetworkAccessManager::authenticationRequired,
|
||||
@@ -41,7 +40,7 @@ void HandleHttpRequest::enqueue(const QUrl &url, HandleHttpQueueMessageStatus st
|
||||
if ((HandleHttpQueueMessageStatus::MS_Cyclic == status) &&
|
||||
m_queueMap[host].uniquenessChecker.contains(url.toString()))
|
||||
{
|
||||
WARNING_LOG() << "Discarding duplicate url \"" << url.toString() << "\" due to slow message handling.";
|
||||
WARNING_LOG(m_logger) << "Discarding duplicate url \"" << url.toString() << "\" due to slow message handling.";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -49,7 +48,7 @@ void HandleHttpRequest::enqueue(const QUrl &url, HandleHttpQueueMessageStatus st
|
||||
networkRequest.request = QNetworkRequest(url);
|
||||
m_queueMap[host].uniquenessChecker.insert(url.toString());
|
||||
m_queueMap[host].requests.enqueue(networkRequest);
|
||||
DEBUG_LOG() << "Added '" << url.toString() << " to queue for host: " << host
|
||||
DEBUG_LOG(m_logger) << "Added '" << url.toString() << " to queue for host: " << host
|
||||
<< " Queue has " << m_queueMap[host].requests.count() << " elements";
|
||||
trySendNextRequest();
|
||||
}
|
||||
@@ -59,21 +58,21 @@ void HandleHttpRequest::onAuthenticationRequired(QNetworkReply *reply, QAuthenti
|
||||
{
|
||||
if (!reply || !authenticator)
|
||||
{
|
||||
ERROR_LOG() << "Internal error - Nullptr exception!";
|
||||
ERROR_LOG(m_logger) << "Internal error - Nullptr exception!";
|
||||
}
|
||||
else if (!m_queueMap.contains(reply->url().host()))
|
||||
{
|
||||
WARNING_LOG() << "Internal error - got auth reply from unknown host!";
|
||||
WARNING_LOG(m_logger) << "Internal error - got auth reply from unknown host!";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_bUseQueue && reply != m_queueMap[reply->url().host()].activeReply)
|
||||
WARNING_LOG() << "Internal error - got auth reply from unknown request!";
|
||||
WARNING_LOG(m_logger) << "Internal error - got auth reply from unknown request!";
|
||||
|
||||
|
||||
if (m_queueMap[reply->url().host()].bAuthAlreadyRequested)
|
||||
return;
|
||||
DEBUG_LOG() << "Authentication request";
|
||||
DEBUG_LOG(m_logger) << "Authentication request";
|
||||
authenticator->setUser(m_username);
|
||||
authenticator->setPassword(m_passwd);
|
||||
m_queueMap[reply->url().host()].bAuthAlreadyRequested = true;
|
||||
@@ -89,17 +88,17 @@ void HandleHttpRequest::onReplyFinished(QNetworkReply *reply)
|
||||
}
|
||||
if (!reply)
|
||||
{
|
||||
ERROR_LOG() << "Internal error - Nullptr exception!";
|
||||
ERROR_LOG(m_logger) << "Internal error - Nullptr exception!";
|
||||
}
|
||||
else if (!m_queueMap.contains(reply->url().host()))
|
||||
{
|
||||
reply->deleteLater();
|
||||
WARNING_LOG() << "Internal error - got reply from unknown host!";
|
||||
WARNING_LOG(m_logger) << "Internal error - got reply from unknown host!";
|
||||
}
|
||||
else if (m_bUseQueue && reply != m_queueMap[reply->url().host()].activeReply)
|
||||
{
|
||||
reply->deleteLater();
|
||||
WARNING_LOG() << "Internal error - got reply from unknown request!";
|
||||
WARNING_LOG(m_logger) << "Internal error - got reply from unknown request!";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -109,16 +108,16 @@ void HandleHttpRequest::onReplyFinished(QNetworkReply *reply)
|
||||
if ( m_newConnection)
|
||||
{
|
||||
m_newConnection = false;
|
||||
DEBUG_LOG() << "emit newEgcuConnection host=" << reply->url().host();
|
||||
DEBUG_LOG(m_logger) << "emit newEgcuConnection host=" << reply->url().host();
|
||||
emit newEgcuConnection(reply->url().host());
|
||||
}
|
||||
DEBUG_LOG() << "Request successfull";
|
||||
DEBUG_LOG(m_logger) << "Request successfull";
|
||||
}
|
||||
else
|
||||
WARNING_LOG() << "Invalid request for host " << reply->url().host() << ", response code: " << responseCode << ", query: " << reply->url().toString();
|
||||
WARNING_LOG(m_logger) << "Invalid request for host " << reply->url().host() << ", response code: " << responseCode << ", query: " << reply->url().toString();
|
||||
|
||||
QByteArray replyData = reply->readAll();
|
||||
DEBUG_LOG() << "Got reply (" << reply->url().toString() << "): " << replyData
|
||||
DEBUG_LOG(m_logger) << "Got reply (" << reply->url().toString() << "): " << replyData
|
||||
<< " host=" << reply->url().host();
|
||||
emit egcuReply(reply->url().host(), replyData);
|
||||
|
||||
@@ -133,7 +132,7 @@ void HandleHttpRequest::sendNextRequest(HandleHttpQueue& queue)
|
||||
{
|
||||
if (m_bUseQueue && queue.activeReply != nullptr)
|
||||
{
|
||||
WARNING_LOG() << "Internal error - active reply not yet finished!";
|
||||
WARNING_LOG(m_logger) << "Internal error - active reply not yet finished!";
|
||||
}
|
||||
else if (!queue.requests.isEmpty())
|
||||
{
|
||||
@@ -144,11 +143,11 @@ void HandleHttpRequest::sendNextRequest(HandleHttpQueue& queue)
|
||||
if ( networkRequest.time.secsTo(QTime::currentTime()) < 5)
|
||||
{
|
||||
queue.activeReply = m_nam->get(request);
|
||||
DEBUG_LOG() << "Send request " << request.url().toString() << " and waiting for reply (" << queue.activeReply << ")";
|
||||
DEBUG_LOG(m_logger) << "Send request " << request.url().toString() << " and waiting for reply (" << queue.activeReply << ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_LOG() << "remove request " << request.url().toString()
|
||||
DEBUG_LOG(m_logger) << "remove request " << request.url().toString()
|
||||
<< " because it's too old" << networkRequest.time.secsTo(QTime::currentTime());
|
||||
sendNextRequest(queue);
|
||||
m_newConnection = true;
|
||||
|
||||
+1
@@ -68,6 +68,7 @@ private Q_SLOTS:
|
||||
void trySendNextRequest();
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
QNetworkAccessManager *m_nam;
|
||||
bool m_bUseQueue;
|
||||
QString m_username;
|
||||
|
||||
+24
-25
@@ -11,15 +11,14 @@
|
||||
|
||||
namespace BuildingControlUnit
|
||||
{
|
||||
MainHandler::MainHandler()
|
||||
: QObject()
|
||||
MainHandler::MainHandler() : QObject()
|
||||
, m_bsmApi(nullptr)
|
||||
, m_jsonApi(nullptr)
|
||||
, m_vwmApi(nullptr)
|
||||
, m_handelEffectsBsm(nullptr)
|
||||
, m_handleHttpRequest(nullptr)
|
||||
, m_bsmFlash(BEO_Auto)
|
||||
{}
|
||||
, m_bsmFlash(BEO_Auto),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {}
|
||||
|
||||
MainHandler::~MainHandler()
|
||||
{
|
||||
@@ -59,17 +58,17 @@ bool MainHandler::init(const QString &ammuXml,
|
||||
}
|
||||
if (!m_vwmApi->init(ammuXml, vwmXml, bsmConfig, initBuilding))
|
||||
{
|
||||
ERROR_LOG() << "Can not initialize VWM API - aborting";
|
||||
ERROR_LOG(m_logger) << "Can not initialize VWM API - aborting";
|
||||
return false;
|
||||
}
|
||||
if (!m_jsonApi->init(listenPort))
|
||||
{
|
||||
ERROR_LOG() << "Can not initialize Json API - aborting";
|
||||
ERROR_LOG(m_logger) << "Can not initialize Json API - aborting";
|
||||
return false;
|
||||
}
|
||||
if (!m_bsmApi->init(bsmConfig))
|
||||
{
|
||||
ERROR_LOG() << "Can not initialize BSM API - aborting";
|
||||
ERROR_LOG(m_logger) << "Can not initialize BSM API - aborting";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -135,16 +134,16 @@ bool MainHandler::init(const QString &ammuXml,
|
||||
|
||||
void MainHandler::setInitialOverrides(const QString &hostname)
|
||||
{
|
||||
DEBUG_LOG() << "setInitialOverrides m_handelEffectsVec.size()=" << m_handelEffectsVec.size();
|
||||
DEBUG_LOG(m_logger) << "setInitialOverrides m_handelEffectsVec.size()=" << m_handelEffectsVec.size();
|
||||
|
||||
for ( int i = 0; i < m_handelEffectsVec.size(); i++)
|
||||
{
|
||||
QString hostnameLocal = m_handelEffectsVec.at(i)->hostname();
|
||||
const QVector<BcuEffectState> effectStates = m_handelEffectsVec.at(i)->getOverrides();
|
||||
DEBUG_LOG() << "setInitialOverrides host=" << hostnameLocal
|
||||
DEBUG_LOG(m_logger) << "setInitialOverrides host=" << hostnameLocal
|
||||
<< " effectStates.size=" << effectStates.size();
|
||||
for (int j = 0; j < effectStates.size(); j++)
|
||||
DEBUG_LOG() << "setInitialOverrides j=" << j
|
||||
DEBUG_LOG(m_logger) << "setInitialOverrides j=" << j
|
||||
<< " id=" << effectStates[j].id
|
||||
<< " type=" << effectStates[j].type
|
||||
<< " override=" << effectStates[j].effectOverride;
|
||||
@@ -171,7 +170,7 @@ void MainHandler::onHitResult(const HitResult &result, const QMap<int, Contamina
|
||||
{
|
||||
Q_UNUSED(contaminationStates)
|
||||
const VWM::Charge charge = m_vwmApi->chargeFromChargeTypeId(result.chargeTypeId);
|
||||
DEBUG_LOG() << "onHitResult chargeTypeId=" << result.chargeTypeId
|
||||
DEBUG_LOG(m_logger) << "onHitResult chargeTypeId=" << result.chargeTypeId
|
||||
<< " result.effectSoundId=" << result.effectSoundId
|
||||
<< " damagePercentNew=" << result.damagePercentNew
|
||||
<< " destructiveFactor=" << charge.destructiveFactor;
|
||||
@@ -182,15 +181,15 @@ void MainHandler::onHitResult(const HitResult &result, const QMap<int, Contamina
|
||||
{
|
||||
for (HandelEffects *he : std::as_const(m_handelEffectsVec))
|
||||
{
|
||||
DEBUG_LOG() << "playHitSound @EGCU " << he->hostname() << ", SoundId: " << result.effectSoundId;
|
||||
DEBUG_LOG(m_logger) << "playHitSound @EGCU " << he->hostname() << ", SoundId: " << result.effectSoundId;
|
||||
he->playHitSound(result.effectSoundId);
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_LOG() << "HitResult: " << result;
|
||||
DEBUG_LOG(m_logger) << "HitResult: " << result;
|
||||
if (result.sensorId != 0 && result.originatorId != 0 && m_bsmFlash != BEO_Off && charge.destructiveFactor > 1 )
|
||||
{
|
||||
DEBUG_LOG() << "BSM Flash";
|
||||
DEBUG_LOG(m_logger) << "BSM Flash";
|
||||
m_bsmApi->triggerFlashlight(result.sensorId);
|
||||
m_bsmApi->triggerFlashlightPulse(result.sensorId,
|
||||
QString(),
|
||||
@@ -200,7 +199,7 @@ void MainHandler::onHitResult(const HitResult &result, const QMap<int, Contamina
|
||||
Settings::flashDuration());
|
||||
}
|
||||
else
|
||||
DEBUG_LOG() << "Kein BSM Flash";
|
||||
DEBUG_LOG(m_logger) << "Kein BSM Flash";
|
||||
|
||||
|
||||
|
||||
@@ -210,14 +209,14 @@ void MainHandler::onHitResult(const HitResult &result, const QMap<int, Contamina
|
||||
|
||||
for (int i = 0; i < m_egcuConfig.egcus.size(); i++)
|
||||
{
|
||||
DEBUG_LOG() << "segmentDamage.size=" << segmentDamage.size();
|
||||
DEBUG_LOG(m_logger) << "segmentDamage.size=" << segmentDamage.size();
|
||||
if ( i < segmentDamage.size() )
|
||||
{
|
||||
DEBUG_LOG() << "segmentDamage[" << i <<"]=" << segmentDamage[i];
|
||||
DEBUG_LOG(m_logger) << "segmentDamage[" << i <<"]=" << segmentDamage[i];
|
||||
m_handelEffectsVec[i]->startEffects(segmentDamage[i]);
|
||||
}
|
||||
else
|
||||
DEBUG_LOG() << "No segment Damage for egcu:" << m_egcuConfig.egcus[i].hostname;
|
||||
DEBUG_LOG(m_logger) << "No segment Damage for egcu:" << m_egcuConfig.egcus[i].hostname;
|
||||
}
|
||||
m_handelEffectsBsm->startEffects(result.damagePercentNew);
|
||||
}
|
||||
@@ -231,22 +230,22 @@ void MainHandler::onUnknownDirectHit(int sensorId)
|
||||
|
||||
void MainHandler::onSetEffectStatesRequest(const QString &hostname, const QVector<BcuEffectState> &effectStates)
|
||||
{
|
||||
DEBUG_LOG() << "1 BSM flash hostname='" << hostname
|
||||
DEBUG_LOG(m_logger) << "1 BSM flash hostname='" << hostname
|
||||
<< "' isEmpty:"<< hostname.isEmpty()
|
||||
<<" isNull:" << hostname.isNull();
|
||||
m_effectStates.insert(hostname, effectStates);
|
||||
if (hostname.isEmpty())
|
||||
{
|
||||
m_bsmFlash = BEO_Auto;
|
||||
DEBUG_LOG() << "2 BSM flash =" << m_bsmFlash;
|
||||
DEBUG_LOG(m_logger) << "2 BSM flash =" << m_bsmFlash;
|
||||
m_handelEffectsBsm->setOverrides(effectStates);
|
||||
for ( int i = 0; i < effectStates.size(); i++)
|
||||
{
|
||||
DEBUG_LOG() << "3 BSM flash =" << m_bsmFlash;
|
||||
DEBUG_LOG(m_logger) << "3 BSM flash =" << m_bsmFlash;
|
||||
if ( effectStates.at(i).type == BET_BsmFlash)
|
||||
{
|
||||
m_bsmFlash = effectStates.at(i).effectOverride;
|
||||
DEBUG_LOG() << "4 BSM flash =" << m_bsmFlash;
|
||||
DEBUG_LOG(m_logger) << "4 BSM flash =" << m_bsmFlash;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -266,7 +265,7 @@ void MainHandler::onSwitchRelayRequest(const QString &hostname, const SwitchRela
|
||||
{
|
||||
if (m_handelEffectsVec[i]->hostname() == hostname )
|
||||
{
|
||||
DEBUG_LOG() << "switchRelay "
|
||||
DEBUG_LOG(m_logger) << "switchRelay "
|
||||
<< " id=" << switchRelayValues.id
|
||||
<< " bcuRelayState=" << switchRelayValues.bcuRelayState;
|
||||
m_handelEffectsVec[i]->switchRelay(switchRelayValues);
|
||||
@@ -328,7 +327,7 @@ QVector<int> MainHandler::getSegmentDamage(const QVector<HitRoom> &allHitRooms,
|
||||
if (egcu.roomIds.size() > 0 )
|
||||
averageDamage = damagePercentSegment / egcu.roomIds.size();
|
||||
result.append(averageDamage);
|
||||
INFO_LOG() << "getSegmentDamage[" << egcu.hostname << "]=" << averageDamage;
|
||||
INFO_LOG(m_logger) << "getSegmentDamage[" << egcu.hostname << "]=" << averageDamage;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -337,7 +336,7 @@ QVector<int> MainHandler::getSegmentDamage(const QVector<HitRoom> &allHitRooms,
|
||||
void MainHandler::flashBuildingDestructionIndicator(int egcu)
|
||||
{
|
||||
|
||||
ERROR_LOG() << "TODO flashBuildingDestructionIndicator egcu=" << egcu;
|
||||
ERROR_LOG(m_logger) << "TODO flashBuildingDestructionIndicator egcu=" << egcu;
|
||||
|
||||
|
||||
|
||||
|
||||
+2
@@ -37,12 +37,14 @@ private Q_SLOTS:
|
||||
void onSwitchRelayRequest(const QString &hostname, const SwitchRelayValues &switchRelayValues);
|
||||
void webSocketSendInitialData(QWebSocket *ws);
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
QVector<int> getAffectedRoomIds(const QVector<HitRoom> &allHitRooms) const;
|
||||
QVector<int> getSegmentDamage(const QVector<HitRoom> &allHitRooms, const int damagePercentNew) const;
|
||||
int getHitRoomId(const QVector<HitRoom> &allHitRooms) const;
|
||||
void flashBuildingDestructionIndicator(int egcu);
|
||||
void cleanup();
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
BSM::Api *m_bsmApi;
|
||||
|
||||
Json::Api *m_jsonApi;
|
||||
|
||||
Reference in new issue
Block a user