Adds immediate migration results in progress

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

No files matched your search

@@ -38,7 +38,7 @@ bool Api::init(const QString &chargesConfig,
const BuildingBsmConfig &bsmConfig,
const bool initBuilding)
{
DEBUG_LOG() << "chargesConfig=" << chargesConfig;
DEBUG_LOG(m_logger) << "chargesConfig=" << chargesConfig;
if (!XmlReader::readCharges(chargesConfig, m_chargeMap))
return false;
if (!XmlReader::readBuilding(vulBuildingConfig, m_building))
@@ -48,21 +48,21 @@ bool Api::init(const QString &chargesConfig,
QString fltXml = QString(QStringLiteral("/opt/BuildingModels/StaticMeshes/%1.flt.xml")).arg(m_building.name());
if (!XmlReader::readBuildingGeometry(fltXml, m_buildingRoomGeometry ))
{
ERROR_LOG() << "Error reading buildingRoomGeometry from file: " << fltXml << "'";
ERROR_LOG(m_logger) << "Error reading buildingRoomGeometry from file: " << fltXml << "'";
}
DEBUG_LOG() << "Building buildingRoomGeometry read successfully from file: " << fltXml << "'";
DEBUG_LOG(m_logger) << "Building buildingRoomGeometry read successfully from file: " << fltXml << "'";
int numberOfRemoved = m_building.cleanupPolygons();
int numberOfDuplicates = m_building.checkPolygons();
DEBUG_LOG() << "Building cleanupPolygons: " << m_building.name() << "' -> " << numberOfRemoved << " points removed";
DEBUG_LOG(m_logger) << "Building cleanupPolygons: " << m_building.name() << "' -> " << numberOfRemoved << " points removed";
if (numberOfDuplicates > 0)
ERROR_LOG() << "Building checkPolygons: " << m_building.name() << "' -> " << numberOfDuplicates << " duplicates";
ERROR_LOG(m_logger) << "Building checkPolygons: " << m_building.name() << "' -> " << numberOfDuplicates << " duplicates";
else
DEBUG_LOG() << "Building checkPolygons: " << m_building.name() << "' -> " << numberOfDuplicates << " duplicates";
DEBUG_LOG(m_logger) << "Building checkPolygons: " << m_building.name() << "' -> " << numberOfDuplicates << " duplicates";
m_bsmMap = bsmConfig.bsmMap;
@@ -85,7 +85,7 @@ void Api::onHitOptical(qint64 timeMSec, int sensorId, int originatorId, int char
if (!bsm.isValid())
{
WARNING_LOG() << "Given bsm id " << sensorId << " is not in our internal bsm list!";
WARNING_LOG(m_logger) << "Given bsm id " << sensorId << " is not in our internal bsm list!";
return;
}
@@ -105,7 +105,7 @@ void Api::onHitOptical(qint64 timeMSec, int sensorId, int originatorId, int char
void Api::onSetEffectStatesRequest(const QString &hostname, const QVector<BcuEffectState> &effectStates)
{
DEBUG_LOG() << "onSetEffectStatesRequest:"
DEBUG_LOG(m_logger) << "onSetEffectStatesRequest:"
<< " hostname= " << hostname
<< " effectStes.zize=" << effectStates.size();
@@ -120,7 +120,7 @@ void Api::onSetEffectStatesRequest(const QString &hostname, const QVector<BcuEff
if (es.effectOverride == BcuEffectOverride::BEO_Off)
{
overridesObj.insert(QStringLiteral("flash"), 0);
DEBUG_LOG() << "flash = 0";
DEBUG_LOG(m_logger) << "flash = 0";
}
}
}
@@ -137,14 +137,14 @@ void Api::onSetEffectStatesRequest(const QString &hostname, const QVector<BcuEff
{
QJsonObject relayStateObj;
relayStateObj[QString::number(es.id)]=es.effectOverride;
DEBUG_LOG() << "relay = " << QString::number(es.id)
DEBUG_LOG(m_logger) << "relay = " << QString::number(es.id)
<< " " << es.effectOverride;
relayStateArray.append(relayStateObj);
}
else if (es.type == BcuEffectType::BET_BackgroundSound)
{
overridesObj.insert(QStringLiteral("sound"), es.effectOverride);
DEBUG_LOG() << "sound=" << es.effectOverride;
DEBUG_LOG(m_logger) << "sound=" << es.effectOverride;
}
}
overridesObj.insert(QStringLiteral("relays"), relayStateArray);
@@ -154,7 +154,7 @@ void Api::onSetEffectStatesRequest(const QString &hostname, const QVector<BcuEff
propertiesObj[QStringLiteral("Overrides")] = overridesObj;
QString totalString = QString::fromLatin1(QJsonDocument(propertiesObj).toJson(QJsonDocument::Compact));
DEBUG_LOG() << "totalString=" << totalString;
DEBUG_LOG(m_logger) << "totalString=" << totalString;
m_building.setSegmentProperties(hostname,totalString);
StateStore::saveState(m_building, m_lastHitResult, m_contaminationStates);
}
@@ -264,15 +264,15 @@ void Api::onHitEcc(int originatorId, DamageState damageState, const QVector<int>
void Api::onSetContaminationState(const std::vector<ContaminationState> &contaminationStates)
{
DEBUG_LOG() << "contaminationStates.size=" << contaminationStates.size();
DEBUG_LOG(m_logger) << "contaminationStates.size=" << contaminationStates.size();
for (const auto &newcs : contaminationStates)
{
DEBUG_LOG() << "newcs.damagePercentNew=" << newcs.damagePercentNew
DEBUG_LOG(m_logger) << "newcs.damagePercentNew=" << newcs.damagePercentNew
<< " m_lastHitResult.damagePercentNew=" << m_lastHitResult.damagePercentNew;
if ( newcs.damagePercentNew > m_lastHitResult.damagePercentNew)
{
DEBUG_LOG() << "newcs.damagePercentNew=" << newcs.damagePercentNew;
DEBUG_LOG(m_logger) << "newcs.damagePercentNew=" << newcs.damagePercentNew;
m_lastHitResult.damagePercentNew = newcs.damagePercentNew;
}
if (m_contaminationStates.contains(newcs.aesId))
@@ -302,7 +302,7 @@ void Api::onSetContaminationState(const std::vector<ContaminationState> &contami
else
m_contaminationStates.insert(newcs.aesId, newcs);
}
DEBUG_LOG() << "onSetContaminationState emit hitResult "
DEBUG_LOG(m_logger) << "onSetContaminationState emit hitResult "
<< " m_lastHitResult.damagePercentNew=" << m_lastHitResult.damagePercentNew;
emit hitResult(m_lastHitResult, m_contaminationStates, false);
StateStore::saveState(m_building, m_lastHitResult, m_contaminationStates);
@@ -311,7 +311,7 @@ void Api::onSetContaminationState(const std::vector<ContaminationState> &contami
void Api::onResetContaminations()
{
m_contaminationStates.clear();
DEBUG_LOG() << "onResetContaminations emit hitResult";
DEBUG_LOG(m_logger) << "onResetContaminations emit hitResult";
m_lastHitResult.chargeTypeId = 0;
m_lastHitResult.originatorId = 0;
m_lastHitResult.originatorType = BuildingControlUnit::OriginatorType::ECC;
@@ -338,7 +338,7 @@ void Api::onHitCes(const qint64 effectTimeMSec, const int chargeTypeId,
hit.position.setZ(1);
INFO_LOG() << "XXXXX CES Hit = " << hit;
INFO_LOG(m_logger) << "XXXXX CES Hit = " << hit;
@@ -349,7 +349,7 @@ void Api::onHitCes(const qint64 effectTimeMSec, const int chargeTypeId,
posTmp.setZ(10000);
const LtsUtils::QPoint3D direction(0,0,1);
const auto hitPosTmp = BuildingControlUnit::VWM::Math::checkBsmPosition(posTmp, direction, m_building.rooms());
INFO_LOG() << "XXXXX hitPosTmp after checkBsmPosition = " << hitPosTmp;
INFO_LOG(m_logger) << "XXXXX hitPosTmp after checkBsmPosition = " << hitPosTmp;
if (hitPosTmp.state != BuildingControlUnit::VWM::HitPosition::State::NoHit)
{
auto room = m_building.rooms().value(hitPosTmp.roomId);
@@ -382,7 +382,7 @@ void Api::onHitCes(const qint64 effectTimeMSec, const int chargeTypeId,
NearestWall nearestWall;
if (hitPos.state == BuildingControlUnit::VWM::HitPosition::State::NoHit)
{
INFO_LOG() << "XXXXX CES Hit outside building - searching nearest wall ...";
INFO_LOG(m_logger) << "XXXXX CES Hit outside building - searching nearest wall ...";
double distanceOut = 0;
LtsUtils::QPoint3D directionWallElementPointToDetonationOut;
@@ -399,14 +399,14 @@ void Api::onHitCes(const qint64 effectTimeMSec, const int chargeTypeId,
if (hitPos.state == BuildingControlUnit::VWM::HitPosition::State::NoHit)
{
WARNING_LOG() << "Internal error - could not find impact position on building "
WARNING_LOG(m_logger) << "Internal error - could not find impact position on building "
<< m_building.name() << " with impact pos " << posImpactOnGround;
}
INFO_LOG() << "XXXXX Aes hit - hit pos: " << posImpactOnGround << " direction: " << hit.direction
INFO_LOG(m_logger) << "XXXXX Aes hit - hit pos: " << posImpactOnGround << " direction: " << hit.direction
<< " (p=" << hit.direction+posImpactOnGround << ")"
<< " ; nearestWall.roomId=" << nearestWall.roomId;
for (auto item : std::as_const(nearestWall.wallElement))
DEBUG_LOG() << "Aes hit - hit pos: " << posImpactOnGround << " direction: " << hit.direction
DEBUG_LOG(m_logger) << "Aes hit - hit pos: " << posImpactOnGround << " direction: " << hit.direction
<< " (p=" << hit.direction+posImpactOnGround
<< " - " << item;
@@ -417,7 +417,7 @@ void Api::onHitCes(const qint64 effectTimeMSec, const int chargeTypeId,
const LtsUtils::QPoint3D &center = centerOfWallElement3D(nearestWall.wallElement);
INFO_LOG() << "XXXXX Aes hit - hit pos: " << posImpactOnGround << " direction: " << hit.direction
INFO_LOG(m_logger) << "XXXXX Aes hit - hit pos: " << posImpactOnGround << " direction: " << hit.direction
<< ", m_building.name=" << m_building.name()
<< ", m_building.modelId=" << m_building.modelId()
<< ", nearestWall.roomId=" << nearestWall.roomId
@@ -436,7 +436,7 @@ NearestWall Api::findNearestWall(const LtsUtils::QPoint3D &detonationLocation, d
NearestWall nearestWall;
distanceOut = std::numeric_limits<double>::max();
INFO_LOG() << "XXXXX searching nearest wall ...";
INFO_LOG(m_logger) << "XXXXX searching nearest wall ...";
for (const Room &room : std::as_const(m_building.rooms()))
{
for (const OuterWall &wall : std::as_const(room.outerWalls()))
@@ -446,13 +446,13 @@ NearestWall Api::findNearestWall(const LtsUtils::QPoint3D &detonationLocation, d
for (const LtsUtils::QPoint3D &p : std::as_const(we))
{
const double dist = (detonationLocation - p).length();
DEBUG_LOG() << "Room[" << room.id() << "]: " << p << ", dist = " << dist;
DEBUG_LOG(m_logger) << "Room[" << room.id() << "]: " << p << ", dist = " << dist;
if (dist >= distanceOut)
continue;
distanceOut = dist;
INFO_LOG() << "New min distance " << dist << " Room[" << room.id() << "]: " << p;
INFO_LOG(m_logger) << "New min distance " << dist << " Room[" << room.id() << "]: " << p;
directionWallElementPointToDetonationOut = p - detonationLocation;
nearestWall.roomId = room.id();
@@ -486,7 +486,7 @@ void Api::onHitCes3D_Evaluation(const qint64 effectTimeMSec,
INFO_LOG() << "XXXXXXXXXX CES Hit 3D = " << hit
INFO_LOG(m_logger) << "XXXXXXXXXX CES Hit 3D = " << hit
<< ", detonationLocation = " << detonationLocation
<< ", detonationDistance = " << detonationDistance
<< ", chargeTypeId = " << chargeTypeId
@@ -514,16 +514,16 @@ void Api::onHitCes3D_Evaluation(const qint64 effectTimeMSec,
roomsWithDetonation = m_buildingRoomGeometry.pointIsInWhichRooms(detonationLocation);
if (roomsWithDetonation.isEmpty())
{
INFO_LOG() << "XXXX Building '" << m_building.name() << "'"
INFO_LOG(m_logger) << "XXXX Building '" << m_building.name() << "'"
<< ", detonationLocation = " << detonationLocation
<< " -> found no room";
} else {
if (roomsWithDetonation.size() == 1)
INFO_LOG() << "XXXX Building '" << m_building.name() << "'"
INFO_LOG(m_logger) << "XXXX Building '" << m_building.name() << "'"
<< ", detonationLocation = " << detonationLocation
<< " -> found just one room: " << roomsWithDetonation.first();
else
INFO_LOG() << "XXXX Building '" << m_building.name() << "'"
INFO_LOG(m_logger) << "XXXX Building '" << m_building.name() << "'"
<< ", detonationLocation = " << detonationLocation
<< " -> found several rooms, choose first: " << roomsWithDetonation.first();
@@ -541,7 +541,7 @@ void Api::onHitCes3D_Evaluation(const qint64 effectTimeMSec,
LtsUtils::QPoint3D directionWallElementPointToDetonationOut;
NearestWall nearestWall = findNearestWall(detonationLocation, distanceOut, directionWallElementPointToDetonationOut);
INFO_LOG() << "XXXXX CES Hit outside building - searching nearest wall ..."
INFO_LOG(m_logger) << "XXXXX CES Hit outside building - searching nearest wall ..."
<< ", detonationDistance = " << detonationDistance
<< ", nearestWall.roomId = " << nearestWall.roomId;
@@ -588,7 +588,7 @@ void Api::onHitCes3D_Evaluation(const qint64 effectTimeMSec,
bool hitSuccess = m_building.hit(LtsUtils::QPoint3D(), LtsUtils::QPoint3D(),
charge, &hitPosPreCalculated);
INFO_LOG() << "onHitCes3D_Evaluation hitSuccess=" << hitSuccess;
INFO_LOG(m_logger) << "onHitCes3D_Evaluation hitSuccess=" << hitSuccess;
result.rooms = m_building.roomStates();
result.damageState = m_building.damageState();
@@ -627,7 +627,7 @@ void Api::onFortifyFactorRequest(int originatorId, const QVector<FortifyInfo> &f
void Api::onRelayStatesRequest(const QString &hostname, const QVector<RelayStateInfo> &relayStateInfos)
{
DEBUG_LOG() << "onRelayStateRequest hostname=" << hostname
DEBUG_LOG(m_logger) << "onRelayStateRequest hostname=" << hostname
<< " only hanlde in svcBuildings"
<< " relayStateInfos.size()=" << relayStateInfos.size();
}
@@ -649,14 +649,14 @@ void Api::sendOverrides()
QJsonObject docObj = QJsonObject(doc.object());
DEBUG_LOG() << "sendOverrides hostname=" << hostname
DEBUG_LOG(m_logger) << "sendOverrides hostname=" << hostname
<< " properties=" << properties;
{
DEBUG_LOG() << "sendOverrides hostname=" << hostname
DEBUG_LOG(m_logger) << "sendOverrides hostname=" << hostname
<< " properties=" << properties << "BCU-Flash";
BcuEffectState bcuEffectState;
bcuEffectState.id = 1;
@@ -677,7 +677,7 @@ void Api::sendOverrides()
}
if (eo != BcuEffectOverride::BEO_Auto)
{
DEBUG_LOG() << "bcuEffectState.effectOverride = eo" << eo;
DEBUG_LOG(m_logger) << "bcuEffectState.effectOverride = eo" << eo;
bcuEffectState.effectOverride = eo;
emit newOverrides({}, {bcuEffectState});
}
@@ -726,7 +726,7 @@ void Api::sendHitToVwm(const Hit &hit)
{
m_hitsSinceLastInit += hit;
INFO_LOG() << " XXXXX sendHitToVwm, Incoming hit=" << hit
INFO_LOG(m_logger) << " XXXXX sendHitToVwm, Incoming hit=" << hit
<< " hit.chargeTypeId=" << hit.chargeTypeId
<< " originatorId=" << hit.originatorId
<< " typeOfHit=" << hit.typeOfHit;
@@ -753,7 +753,7 @@ void Api::sendHitToVwm(const Hit &hit)
charge.penetrationEffect = hit.penetrationFactor;
}
DEBUG_LOG() << "charge=" << charge.chargeTypeId
DEBUG_LOG(m_logger) << "charge=" << charge.chargeTypeId
<< " destructiveFactor" << charge.destructiveFactor
<< " penetrationEffect" << charge.penetrationEffect;
chargeOrg = charge;
@@ -770,23 +770,23 @@ void Api::sendHitToVwm(const Hit &hit)
LtsUtils::QPoint3D dummyDist = hit.position - hit.direction;
INFO_LOG() << " XXXX CES outside bulding, reduce charge: " << charge
INFO_LOG(m_logger) << " XXXX CES outside bulding, reduce charge: " << charge
<< ", hit.position " << hit.position
<< ", hit.direction " << hit.direction
<< ", dummyDist " << dummyDist.length();
charge.destructiveFactor *= 0.5;
charge.penetrationEffect *= 0.5;
INFO_LOG() << " XXXX CES outside bulding, reduce charge: " << charge;
INFO_LOG(m_logger) << " XXXX CES outside bulding, reduce charge: " << charge;
}
if (!charge.isValid())
{
if (hit.originatorType == OriginatorType::CesHit)
WARNING_LOG() << "Charge with id " << hit.chargeTypeId
WARNING_LOG(m_logger) << "Charge with id " << hit.chargeTypeId
<< " not configured - can not caluclate impact effect for this charge";
else
{
WARNING_LOG() << "Direct charge with id " << hit.chargeTypeId
WARNING_LOG(m_logger) << "Direct charge with id " << hit.chargeTypeId
<< " not configured - can not caluclate impact effect for this charge";
emit unknownDirectHit(hit.sensorId);
}
@@ -794,7 +794,7 @@ void Api::sendHitToVwm(const Hit &hit)
}
if (!m_building.hit(hit.position, hit.direction, charge))
{
WARNING_LOG() << "Detected hit was outside of the building - ignored";
WARNING_LOG(m_logger) << "Detected hit was outside of the building - ignored";
break;
}
result.rooms = m_building.roomStates();
@@ -832,7 +832,7 @@ void Api::sendHitToVwm(const Hit &hit)
{
case DamageState::NoDamage:
{
DEBUG_LOG() << "Hit OC/ECC with NoDamage";
DEBUG_LOG(m_logger) << "Hit OC/ECC with NoDamage";
m_building.init();
result.effectSoundId = Settings::effectSoundIdEccActivate();
@@ -855,7 +855,7 @@ void Api::sendHitToVwm(const Hit &hit)
}
case DamageState::Destroyed:
{
DEBUG_LOG() << "Hit OC/ECC with Destroyed";
DEBUG_LOG(m_logger) << "Hit OC/ECC with Destroyed";
const DamageState dsOld = m_building.damageState();
m_building.destroyAllRooms();
@@ -879,14 +879,14 @@ void Api::sendHitToVwm(const Hit &hit)
break;
}
default:
WARNING_LOG() << "Invalid damage state override given: " << hit.damageStateOverride;
WARNING_LOG(m_logger) << "Invalid damage state override given: " << hit.damageStateOverride;
result = HitResult();
break;
}
break;
}
case OriginatorType::Unknown:
WARNING_LOG() << "Unknown originator type given: " << hit.originatorType;
WARNING_LOG(m_logger) << "Unknown originator type given: " << hit.originatorType;
result = HitResult();
break;
}
@@ -905,7 +905,7 @@ const Charge Api::chargeFromChargeTypeId(int chargeTypeId) const
for (auto i = m_chargeMap.cbegin(), end = m_chargeMap.cend(); i != end; ++i)
{
TRACE_LOG() << "key=" << i.key() << " value=" << i.value();
TRACE_LOG(m_logger) << "key=" << i.key() << " value=" << i.value();
if ( chargeTypeId == i.value().id)
return m_chargeMap.value(i.key());
}