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);
|
||||
|
||||
Reference in new issue
Block a user