Migrates residual Lts sources to generated rtiddsgen API
Adds NmeaManagement tests, fixes codegen includes and Qt6 SerialPort CMake target.
This commit is contained in:
1 parent
5485a90385
commit
881d44f4dd
512 files changed
+6887
-6426
No files matched your search
@@ -53,6 +53,7 @@ BuildingProcess::BuildingProcess(MainHandler *mainHandler,
|
||||
, m_hitLineInfoTimer(new QTimer(this))
|
||||
, m_hitLineId(info.mseId << 16)
|
||||
, m_initBuilding(initBuilding)
|
||||
, m_logger(getLogger("BuildingProcess"))
|
||||
{
|
||||
m_proc.setProgram(procName);
|
||||
m_proc.setReadChannel(QProcess::StandardOutput);
|
||||
@@ -86,7 +87,7 @@ void BuildingProcess::onStructureElementUpdateEffectOverrideReply(const Core::Fu
|
||||
bool BuildingProcess::start()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "BuildingProcess::start mseId = " << m_buildingInfo.mseId
|
||||
<< " m_historyState.size() = " << m_historyState.stateHistory().size()
|
||||
<< " m_historyState.size() = " << m_historyState.stateHistory.size()
|
||||
<< " m_initBuilding=" << m_initBuilding;
|
||||
if (m_buildingInfo.mseId <= 0)
|
||||
{
|
||||
@@ -201,11 +202,11 @@ void BuildingProcess::shutdown()
|
||||
|
||||
void BuildingProcess::setHistoryState(const Buildings::HistoryState &historyState)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "BuildingProcess::setHistoryState size =" << historyState.stateHistory().size();
|
||||
DEBUG_LOG(m_logger) << "BuildingProcess::setHistoryState size =" << historyState.stateHistory.size();
|
||||
|
||||
ERROR_LOG(m_logger) << "[BuildingProcess::setHistoryState]>>> history =" << historyState;
|
||||
m_historyState = historyState;
|
||||
m_historyState.sampleTime(QDateTime::currentMSecsSinceEpoch());
|
||||
m_historyState.sampleTime = QDateTime::currentMSecsSinceEpoch();
|
||||
m_mainHandler->ddsHandler()->dts()->publish(m_historyState);
|
||||
}
|
||||
|
||||
@@ -215,7 +216,7 @@ bool BuildingProcess::setVulnerabilityState(ProjectDataManagement::Vulnerability
|
||||
if (!m_wsSocket || !m_wsSocket->isValid())
|
||||
return false;
|
||||
BuildingControlUnit::Json::Telegrams::SetDamageState tele;
|
||||
tele.damageState = (state == ProjectDataManagement::VulnerabilityState::CatastrophicKill ?
|
||||
tele.damageState = (state == ProjectDataManagement::VulnerabilityState::VulnerabilityState_CatastrophicKill ?
|
||||
BuildingControlUnit::DamageState::Destroyed :
|
||||
BuildingControlUnit::DamageState::NoDamage);
|
||||
tele.roomIds.reserve(roomIds.size());
|
||||
@@ -236,12 +237,12 @@ bool BuildingProcess::setContaminationState(const int &bldId, const Contaminatio
|
||||
return false;
|
||||
BuildingControlUnit::Json::Telegrams::SetContaminationState tele;
|
||||
BuildingControlUnit::ContaminationState contState;
|
||||
contState.aesId = contaminationState.aesId();
|
||||
if ( contaminationState.vulnerabilityState() == ProjectDataManagement::VulnerabilityState::CatastrophicKill )
|
||||
contState.aesId = contaminationState.aesId;
|
||||
if ( contaminationState.vulnerabilityState == ProjectDataManagement::VulnerabilityState::VulnerabilityState_CatastrophicKill )
|
||||
contState.damagePercentNew = 100;
|
||||
else
|
||||
contState.damagePercentNew = 0;
|
||||
contState.rooms = contaminationState.rooms();
|
||||
contState.rooms = contaminationState.rooms;
|
||||
tele.contaminationStates.push_back(contState);
|
||||
|
||||
DEBUG_LOG(m_logger) << "SetContaminationState websocket send: " << QString::fromUtf8(tele.toJson());
|
||||
@@ -271,8 +272,8 @@ bool BuildingProcess::setFortifyFactors(const std::vector<Buildings::FortifyFact
|
||||
for (const auto &ff : fortifyFactors)
|
||||
{
|
||||
BuildingControlUnit::Json::Telegrams::SetFortifyFactor::FortifyInfo info;
|
||||
info.roomId = m_buildingInfo.roomId2SubId.value(ff.roomId());
|
||||
info.fortifyFactor = ff.fortifyFactor();
|
||||
info.roomId = m_buildingInfo.roomId2SubId.value(ff.roomId);
|
||||
info.fortifyFactor = ff.fortifyFactor;
|
||||
|
||||
tele.fortifyFactors.push_back(info);
|
||||
}
|
||||
@@ -402,8 +403,8 @@ bool BuildingProcess::relayState(const std::vector<Buildings::RelayStateItem> &r
|
||||
for (const auto &ff : relayStates)
|
||||
{
|
||||
BuildingControlUnit::Json::Telegrams::RelayState::RelayStateInfo info;
|
||||
info.id = ff.id();
|
||||
info.state = ff.state();
|
||||
info.id = ff.id;
|
||||
info.state = ff.state;
|
||||
|
||||
tele.relayStates.push_back(info);
|
||||
}
|
||||
@@ -427,21 +428,21 @@ bool BuildingProcess::sendCesHitOnBuilding(const qint64 effectTimeMSec,
|
||||
return false;
|
||||
|
||||
|
||||
const LtsCoordTrans::UtmCoordinate coord(LtsCoordTrans::UtmCoordinate::fromGeographic(m_buildingInfo.absPosition.lon(),
|
||||
m_buildingInfo.absPosition.lat()));
|
||||
const LtsCoordTrans::UtmCoordinate impact(LtsCoordTrans::UtmCoordinate::fromGeographic(impactPosition.lon(),
|
||||
impactPosition.lat(),
|
||||
const LtsCoordTrans::UtmCoordinate coord(LtsCoordTrans::UtmCoordinate::fromGeographic(m_buildingInfo.absPosition.lon,
|
||||
m_buildingInfo.absPosition.lat));
|
||||
const LtsCoordTrans::UtmCoordinate impact(LtsCoordTrans::UtmCoordinate::fromGeographic(impactPosition.lon,
|
||||
impactPosition.lat,
|
||||
coord.zone));
|
||||
Core::RelativePosition relPos(impact.x - coord.x,
|
||||
impact.y - coord.y,
|
||||
impactPosition.z() - m_buildingInfo.absPosition.z());
|
||||
impactPosition.z - m_buildingInfo.absPosition.z);
|
||||
double xRot, yRot;
|
||||
QTransform m;
|
||||
|
||||
m.rotate(-m_buildingInfo.angle);
|
||||
m.map(relPos.offsetX(), relPos.offsetY(), &xRot, &yRot);
|
||||
relPos.offsetX(xRot);
|
||||
relPos.offsetY(yRot);
|
||||
m.map(relPos.offsetX, relPos.offsetY, &xRot, &yRot);
|
||||
relPos.offsetX = xRot;
|
||||
relPos.offsetY = yRot;
|
||||
|
||||
|
||||
BuildingControlUnit::Json::Telegrams::CentralEffectSimulationHit tele;
|
||||
@@ -450,9 +451,9 @@ bool BuildingProcess::sendCesHitOnBuilding(const qint64 effectTimeMSec,
|
||||
tele.destructiveFactor = destructiveFactor;
|
||||
tele.penetrationFactor = penetrationFactor;
|
||||
tele.aesId = aesId;
|
||||
tele.relPosition.x = relPos.offsetX();
|
||||
tele.relPosition.y = relPos.offsetY();
|
||||
tele.relPosition.z = relPos.offsetZ();
|
||||
tele.relPosition.x = relPos.offsetX;
|
||||
tele.relPosition.y = relPos.offsetY;
|
||||
tele.relPosition.z = relPos.offsetZ;
|
||||
tele.properties = properties;
|
||||
|
||||
DEBUG_LOG(m_logger) << "sendCesHitOnBuilding websocket send: " << QString::fromUtf8(tele.toJson());
|
||||
@@ -469,27 +470,27 @@ bool BuildingProcess::sendCesHit3DonBuilding(const qint64 effectTimeMSec, const
|
||||
return false;
|
||||
|
||||
|
||||
const LtsCoordTrans::UtmCoordinate &coord(LtsCoordTrans::UtmCoordinate::fromGeographic(m_buildingInfo.absPosition.lon(),
|
||||
m_buildingInfo.absPosition.lat()));
|
||||
const LtsCoordTrans::UtmCoordinate &coord(LtsCoordTrans::UtmCoordinate::fromGeographic(m_buildingInfo.absPosition.lon,
|
||||
m_buildingInfo.absPosition.lat));
|
||||
|
||||
Core::RelativePosition relImpactPos;
|
||||
{
|
||||
const LtsCoordTrans::UtmCoordinate &impactUtm(LtsCoordTrans::UtmCoordinate::fromGeographic(impactPosition.lon(),
|
||||
impactPosition.lat(),
|
||||
const LtsCoordTrans::UtmCoordinate &impactUtm(LtsCoordTrans::UtmCoordinate::fromGeographic(impactPosition.lon,
|
||||
impactPosition.lat,
|
||||
coord.zone));
|
||||
relImpactPos = Core::RelativePosition(impactUtm.x - coord.x,
|
||||
impactUtm.y - coord.y,
|
||||
impactPosition.z() - m_buildingInfo.absPosition.z());
|
||||
impactPosition.z - m_buildingInfo.absPosition.z);
|
||||
}
|
||||
|
||||
Core::RelativePosition relDetoLoc;
|
||||
{
|
||||
const LtsCoordTrans::UtmCoordinate &detonationLocationUtm(LtsCoordTrans::UtmCoordinate::fromGeographic(detonationLocation.lon(),
|
||||
detonationLocation.lat(),
|
||||
const LtsCoordTrans::UtmCoordinate &detonationLocationUtm(LtsCoordTrans::UtmCoordinate::fromGeographic(detonationLocation.lon,
|
||||
detonationLocation.lat,
|
||||
coord.zone));
|
||||
relDetoLoc = Core::RelativePosition(detonationLocationUtm.x - coord.x,
|
||||
detonationLocationUtm.y - coord.y,
|
||||
detonationLocation.z() - m_buildingInfo.absPosition.z());
|
||||
detonationLocation.z - m_buildingInfo.absPosition.z);
|
||||
}
|
||||
|
||||
|
||||
@@ -498,13 +499,13 @@ bool BuildingProcess::sendCesHit3DonBuilding(const qint64 effectTimeMSec, const
|
||||
|
||||
m.rotate(-m_buildingInfo.angle);
|
||||
|
||||
m.map(relImpactPos.offsetX(), relImpactPos.offsetY(), &xRot, &yRot);
|
||||
relImpactPos.offsetX(xRot);
|
||||
relImpactPos.offsetY(yRot);
|
||||
m.map(relImpactPos.offsetX, relImpactPos.offsetY, &xRot, &yRot);
|
||||
relImpactPos.offsetX = xRot;
|
||||
relImpactPos.offsetY = yRot;
|
||||
|
||||
m.map(relDetoLoc.offsetX(), relDetoLoc.offsetY(), &xRot, &yRot);
|
||||
relDetoLoc.offsetX(xRot);
|
||||
relDetoLoc.offsetY(yRot);
|
||||
m.map(relDetoLoc.offsetX, relDetoLoc.offsetY, &xRot, &yRot);
|
||||
relDetoLoc.offsetX = xRot;
|
||||
relDetoLoc.offsetY = yRot;
|
||||
|
||||
|
||||
BuildingControlUnit::Json::Telegrams::CentralEffectSimulationHit3D tele;
|
||||
@@ -514,13 +515,13 @@ bool BuildingProcess::sendCesHit3DonBuilding(const qint64 effectTimeMSec, const
|
||||
tele.penetrationFactor = penetrationFactor;
|
||||
tele.aesId = aesId;
|
||||
|
||||
tele.impactPosition.x = relImpactPos.offsetX();
|
||||
tele.impactPosition.y = relImpactPos.offsetY();
|
||||
tele.impactPosition.z = relImpactPos.offsetZ();
|
||||
tele.impactPosition.x = relImpactPos.offsetX;
|
||||
tele.impactPosition.y = relImpactPos.offsetY;
|
||||
tele.impactPosition.z = relImpactPos.offsetZ;
|
||||
|
||||
tele.detonationLocation.x = relDetoLoc.offsetX();
|
||||
tele.detonationLocation.y = relDetoLoc.offsetY();
|
||||
tele.detonationLocation.z = relDetoLoc.offsetZ();
|
||||
tele.detonationLocation.x = relDetoLoc.offsetX;
|
||||
tele.detonationLocation.y = relDetoLoc.offsetY;
|
||||
tele.detonationLocation.z = relDetoLoc.offsetZ;
|
||||
|
||||
tele.detonationDistance = detonationDistance;
|
||||
tele.properties = properties;
|
||||
@@ -537,9 +538,9 @@ bool BuildingProcess::switchRelay(const SwitchRelayRequest &data)
|
||||
if (!m_wsSocket || !m_wsSocket->isValid())
|
||||
return false;
|
||||
DEBUG_LOG(m_logger) << "switchRelay"
|
||||
<< " buildingId=" << data.buildingId()
|
||||
<< " assetId=" << data.assetId()
|
||||
<< data.state();
|
||||
<< " buildingId=" << data.buildingId
|
||||
<< " assetId=" << data.assetId
|
||||
<< data.state;
|
||||
|
||||
|
||||
for (const EgcuInfo &egcu : std::as_const(m_buildingInfo.egcus))
|
||||
@@ -547,19 +548,19 @@ bool BuildingProcess::switchRelay(const SwitchRelayRequest &data)
|
||||
DEBUG_LOG(m_logger) << "EGCU: " << egcu.assetName
|
||||
<< " assetId=" << egcu.assetId
|
||||
<< " hostname=" << egcu.hostname;
|
||||
DEBUG_LOG(m_logger) << "data.assetId()=" << data.assetId()
|
||||
DEBUG_LOG(m_logger) << "data.assetId()=" << data.assetId
|
||||
<< "egcu.assetId=" << egcu.assetId;
|
||||
if ( data.assetId() != egcu.assetId)
|
||||
if ( data.assetId != egcu.assetId)
|
||||
continue;
|
||||
|
||||
tele.segment = egcu.hostname;
|
||||
tele.switchRelayValues.id = data.number();
|
||||
tele.switchRelayValues.bcuRelayState = static_cast <BuildingControlUnit::BcuRelayState>(data.state().underlying());
|
||||
if ( data.state() == StateSetRelay_def::Pulse)
|
||||
tele.switchRelayValues.id = data.number;
|
||||
tele.switchRelayValues.bcuRelayState = static_cast <BuildingControlUnit::BcuRelayState>(static_cast<int>(data.state));
|
||||
if ( data.state == StateSetRelay::Pulse)
|
||||
{
|
||||
tele.switchRelayValues.count = data.pulseAttributes().get().count();
|
||||
tele.switchRelayValues.delay = data.pulseAttributes().get().delay();
|
||||
tele.switchRelayValues.pulse = data.pulseAttributes().get().pulse();
|
||||
tele.switchRelayValues.count = data.pulseAttributes.get().count;
|
||||
tele.switchRelayValues.delay = data.pulseAttributes.get().delay;
|
||||
tele.switchRelayValues.pulse = data.pulseAttributes.get().pulse;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "switchRelay websocket send: " << QString::fromUtf8(tele.toJson());
|
||||
m_wsSocket->sendTextMessage(QString::fromUtf8(tele.toJson()));
|
||||
@@ -575,8 +576,8 @@ bool BuildingProcess::triggerFlashlight(const TriggerBsmFlashRequest data)
|
||||
if (!m_wsSocket || !m_wsSocket->isValid())
|
||||
return false;
|
||||
DEBUG_LOG(m_logger) << "triggerFlashlight"
|
||||
<< " BuildingId=" << data.buildingId()
|
||||
<< " assetId=" << data.assetId()
|
||||
<< " BuildingId=" << data.buildingId
|
||||
<< " assetId=" << data.assetId
|
||||
<< " m_buildingInfo.bsms.size()" << m_buildingInfo.bsms.size();
|
||||
|
||||
QMapIterator<int, BsmInfo> i(m_buildingInfo.bsms);
|
||||
@@ -589,10 +590,10 @@ bool BuildingProcess::triggerFlashlight(const TriggerBsmFlashRequest data)
|
||||
<< " port=" << i.value().port;
|
||||
|
||||
}
|
||||
if ( m_buildingInfo.bsms.contains(data.assetId()))
|
||||
if ( m_buildingInfo.bsms.contains(data.assetId))
|
||||
{
|
||||
BsmInfo bsmInfo = m_buildingInfo.bsms.value(data.assetId());
|
||||
DEBUG_LOG(m_logger) << " BuildingId=" << data.buildingId()
|
||||
BsmInfo bsmInfo = m_buildingInfo.bsms.value(data.assetId);
|
||||
DEBUG_LOG(m_logger) << " BuildingId=" << data.buildingId
|
||||
<< " assetId=" << bsmInfo.assetId
|
||||
<< " hostname=" << bsmInfo.hostname;
|
||||
|
||||
@@ -664,21 +665,21 @@ void BuildingProcess::onTextMessageReceived(const QString &message)
|
||||
void BuildingProcess::handleBsmState(BuildingControlUnit::Json::Telegrams::BsmState *tel)
|
||||
{
|
||||
BuildingStateTechnical state;
|
||||
state.id(m_buildingInfo.mseId);
|
||||
state.assetId(m_buildingInfo.assetId);
|
||||
state.structureElementId(m_buildingInfo.structureElementId);
|
||||
state.sampleTime(QDateTime::currentMSecsSinceEpoch());
|
||||
state.bsmStates().resize(tel->bsmStates.size());
|
||||
state.id = m_buildingInfo.mseId;
|
||||
state.assetId = m_buildingInfo.assetId;
|
||||
state.structureElementId = m_buildingInfo.structureElementId;
|
||||
state.sampleTime = QDateTime::currentMSecsSinceEpoch();
|
||||
state.bsmStates.resize(tel->bsmStates.size());
|
||||
BsmState s;
|
||||
for (int i = 0; i < tel->bsmStates.size(); ++i)
|
||||
{
|
||||
const BuildingControlUnit::Json::Telegrams::BsmState::BsmStateInfo &info = tel->bsmStates.at(i);
|
||||
s.id(info.id);
|
||||
s.connected(info.connected);
|
||||
s.hostport(info.port);
|
||||
s.hostname(info.hostname.toStdString());
|
||||
s.versionInfo(info.versionInfo.toStdString());
|
||||
state.bsmStates()[i] = s;
|
||||
s.id = info.id;
|
||||
s.connected = info.connected;
|
||||
s.hostport = info.port;
|
||||
s.hostname = info.hostname.toStdString();
|
||||
s.versionInfo = info.versionInfo.toStdString();
|
||||
state.bsmStates[i] = s;
|
||||
m_bsmStates.insert(info.id, s);
|
||||
}
|
||||
|
||||
@@ -687,32 +688,32 @@ void BuildingProcess::handleBsmState(BuildingControlUnit::Json::Telegrams::BsmSt
|
||||
|
||||
void BuildingProcess::historyState(const BuildingState &state)
|
||||
{
|
||||
if (state.vulnerabilityState() == ProjectDataManagement::VulnerabilityState::CombatReady
|
||||
&& state.damagePercent() == 0
|
||||
&& state.originatorParticipantId() == 0
|
||||
&& state.contaminationStates().size() == 0)
|
||||
if (state.vulnerabilityState == ProjectDataManagement::VulnerabilityState::VulnerabilityState_CombatReady
|
||||
&& state.damagePercent == 0
|
||||
&& state.originatorParticipantId == 0
|
||||
&& state.contaminationStates.size() == 0)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "setVulnerabilityState->removeHistoryStateByKey:" << state.id();
|
||||
m_historyState.stateHistory().resize(0);
|
||||
DEBUG_LOG(m_logger) << "setVulnerabilityState->removeHistoryStateByKey:" << state.id;
|
||||
m_historyState.stateHistory.resize(0);
|
||||
}
|
||||
|
||||
HistoryStateItem historyStateItem;
|
||||
historyStateItem.aesId(state.aesId());
|
||||
historyStateItem.chargeTypeId(state.chargeTypeId());
|
||||
historyStateItem.damagePercent(state.damagePercent());
|
||||
historyStateItem.damagePercentOld(state.damagePercentOld());
|
||||
historyStateItem.originatorParticipantId(state.originatorParticipantId());
|
||||
historyStateItem.originatorType() = state.originatorType();
|
||||
historyStateItem.time(state.sampleTime());
|
||||
historyStateItem.vulnerabilityState() = state.vulnerabilityState();
|
||||
historyStateItem.contaminationStates() = state.contaminationStates();
|
||||
historyStateItem.aesId = state.aesId;
|
||||
historyStateItem.chargeTypeId = state.chargeTypeId;
|
||||
historyStateItem.damagePercent = state.damagePercent;
|
||||
historyStateItem.damagePercentOld = state.damagePercentOld;
|
||||
historyStateItem.originatorParticipantId = state.originatorParticipantId;
|
||||
historyStateItem.originatorType = state.originatorType;
|
||||
historyStateItem.time = state.sampleTime;
|
||||
historyStateItem.vulnerabilityState = state.vulnerabilityState;
|
||||
historyStateItem.contaminationStates = state.contaminationStates;
|
||||
|
||||
m_historyState.stateHistory().push_back(std::move(historyStateItem));
|
||||
m_historyState.stateHistory.push_back(std::move(historyStateItem));
|
||||
DEBUG_LOG(m_logger) << "BuildingProcess::historyState contaminationStates:" << state;
|
||||
|
||||
m_historyState.mseId(state.id());
|
||||
DEBUG_LOG(m_logger) << "setVulnerabilityState->removeHistoryStateByKey:" << m_historyState.mseId();
|
||||
m_historyState.sampleTime(QDateTime::currentMSecsSinceEpoch());
|
||||
m_historyState.mseId = state.id;
|
||||
DEBUG_LOG(m_logger) << "setVulnerabilityState->removeHistoryStateByKey:" << m_historyState.mseId;
|
||||
m_historyState.sampleTime = QDateTime::currentMSecsSinceEpoch();
|
||||
m_mainHandler->ddsHandler()->dts()->publish(m_historyState);
|
||||
}
|
||||
|
||||
@@ -722,78 +723,78 @@ void BuildingProcess::handleHitResult(BuildingControlUnit::Json::Telegrams::HitR
|
||||
BuildingState state;
|
||||
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " data.hitOnRoomId=" << data.hitOnRoomId;
|
||||
state.id(m_buildingInfo.mseId);
|
||||
state.id = m_buildingInfo.mseId;
|
||||
|
||||
int assetId = m_mainHandler->ddsHandler()->dtcIsm()->getAssetIdFromMountingPointId(m_buildingInfo.mseId, data.sensorId);
|
||||
DEBUG_LOG(m_logger) << "handleHitResult assetId=" << assetId;
|
||||
state.assetId(assetId);
|
||||
state.assetId = assetId;
|
||||
|
||||
InfrastructureManagement::StructureElement se;
|
||||
m_mainHandler->ddsHandler()->dtcIsm()->getStructureElementInMntPointAssetByAssetId(assetId, se);
|
||||
DEBUG_LOG(m_logger) << "handleHitResult structureElementId=" << se.id();
|
||||
state.structureElementId(se.id());
|
||||
state.sampleTime(QDateTime::currentMSecsSinceEpoch());
|
||||
DEBUG_LOG(m_logger) << "handleHitResult structureElementId=" << se.id;
|
||||
state.structureElementId = se.id;
|
||||
state.sampleTime = QDateTime::currentMSecsSinceEpoch();
|
||||
if (data.originatorType == BuildingControlUnit::OriginatorType::DirectHit)
|
||||
{
|
||||
|
||||
state.originatorParticipantId(m_mainHandler->ppmHandler()->equipmentNumberToParticipantId(data.originatorId));
|
||||
state.chargeTypeId(data.chargeTypeId);
|
||||
state.originatorType(ProjectDataManagement::StateChangeOriginator_def::Participant);
|
||||
state.originatorParticipantId = m_mainHandler->ppmHandler()->equipmentNumberToParticipantId(data.originatorId);
|
||||
state.chargeTypeId = data.chargeTypeId;
|
||||
state.originatorType = ProjectDataManagement::StateChangeOriginator::StateChangeOriginator_Participant;
|
||||
}
|
||||
else if (data.originatorType == BuildingControlUnit::OriginatorType::CesHit)
|
||||
{
|
||||
|
||||
state.aesId(data.originatorId);
|
||||
state.aesId = data.originatorId;
|
||||
|
||||
state.chargeTypeId(data.chargeTypeId);
|
||||
state.originatorType(ProjectDataManagement::StateChangeOriginator_def::AreaEffectSimulation);
|
||||
state.chargeTypeId = data.chargeTypeId;
|
||||
state.originatorType = ProjectDataManagement::StateChangeOriginator::StateChangeOriginator_AreaEffectSimulation;
|
||||
}
|
||||
else if (data.originatorType == BuildingControlUnit::OriginatorType::OC)
|
||||
{
|
||||
state.originatorParticipantId(0);
|
||||
state.chargeTypeId(data.chargeTypeId);
|
||||
state.originatorType(ProjectDataManagement::StateChangeOriginator_def::ObserverController);
|
||||
state.originatorParticipantId = 0;
|
||||
state.chargeTypeId = data.chargeTypeId;
|
||||
state.originatorType = ProjectDataManagement::StateChangeOriginator::StateChangeOriginator_ObserverController;
|
||||
}
|
||||
else
|
||||
{
|
||||
state.originatorParticipantId(0);
|
||||
state.chargeTypeId(data.chargeTypeId);
|
||||
state.originatorType(ProjectDataManagement::StateChangeOriginator_def::ExerciseControl);
|
||||
state.originatorParticipantId = 0;
|
||||
state.chargeTypeId = data.chargeTypeId;
|
||||
state.originatorType = ProjectDataManagement::StateChangeOriginator::StateChangeOriginator_ExerciseControl;
|
||||
}
|
||||
state.damagePercent(data.damagePercentNew);
|
||||
state.damagePercentOld(data.damagePercentOld);
|
||||
state.vulnerabilityState(data.damageState == BuildingControlUnit::DamageState::Destroyed ?
|
||||
ProjectDataManagement::VulnerabilityState::CatastrophicKill :
|
||||
ProjectDataManagement::VulnerabilityState::CombatReady);
|
||||
state.hitOnRoomId(data.hitOnRoomId);
|
||||
state.roomStates().reserve(data.rooms.size());
|
||||
state.damagePercent = data.damagePercentNew;
|
||||
state.damagePercentOld = data.damagePercentOld;
|
||||
state.vulnerabilityState = data.damageState == BuildingControlUnit::DamageState::Destroyed ?
|
||||
ProjectDataManagement::VulnerabilityState::VulnerabilityState_CatastrophicKill :
|
||||
ProjectDataManagement::VulnerabilityState::VulnerabilityState_CombatReady;
|
||||
state.hitOnRoomId = data.hitOnRoomId;
|
||||
state.roomStates.reserve(data.rooms.size());
|
||||
RoomState s;
|
||||
for (const auto &info : data.rooms)
|
||||
{
|
||||
s.id(m_buildingInfo.subId2RoomId.value(info.roomId));
|
||||
s.mountingPointId(info.roomId);
|
||||
s.damagePercent(info.damagePercent);
|
||||
s.remainingEffectPercent(info.remainingEffectPercent);
|
||||
s.fortifyFactor(info.fortifyFactor);
|
||||
state.roomStates().push_back(s);
|
||||
s.id = m_buildingInfo.subId2RoomId.value(info.roomId);
|
||||
s.mountingPointId = info.roomId;
|
||||
s.damagePercent = info.damagePercent;
|
||||
s.remainingEffectPercent = info.remainingEffectPercent;
|
||||
s.fortifyFactor = info.fortifyFactor;
|
||||
state.roomStates.push_back(s);
|
||||
}
|
||||
|
||||
ContaminationState cs;
|
||||
state.contaminationStates().reserve(data.contaminations.count());
|
||||
state.contaminationStates.reserve(data.contaminations.count());
|
||||
for (const auto &csi : data.contaminations)
|
||||
{
|
||||
cs.aesId(csi.aesId);
|
||||
cs.rooms().assign(csi.rooms.begin(), csi.rooms.end());
|
||||
state.contaminationStates().push_back(cs);
|
||||
cs.aesId = csi.aesId;
|
||||
cs.rooms.assign(csi.rooms.begin(), csi.rooms.end());
|
||||
state.contaminationStates.push_back(cs);
|
||||
}
|
||||
|
||||
|
||||
if (m_historyState.mseId() != 0)
|
||||
if (m_historyState.mseId != 0)
|
||||
historyState(state);
|
||||
else
|
||||
{
|
||||
|
||||
m_historyState.mseId(m_buildingInfo.mseId);
|
||||
m_historyState.mseId = m_buildingInfo.mseId;
|
||||
}
|
||||
|
||||
m_mainHandler->ddsHandler()->dts()->publish(state);
|
||||
@@ -823,7 +824,7 @@ void BuildingProcess::handleReconnectEgcu(const QString &segment)
|
||||
if (m_effectOverridesReconnect.value(relayId) >= 0)
|
||||
{
|
||||
|
||||
InfrastructureManagement::EffectOverride override = InfrastructureManagement::EffectOverride_def::PermanentOff;
|
||||
InfrastructureManagement::EffectOverride override = InfrastructureManagement::EffectOverride::PermanentOff;
|
||||
|
||||
int structureElementIdMp = m_mainHandler->ddsHandler()->dtcIsm()->getStructueElementIdFromAssetId(egcu.assetId);
|
||||
|
||||
@@ -837,9 +838,9 @@ void BuildingProcess::handleReconnectEgcu(const QString &segment)
|
||||
|
||||
|
||||
InfrastructureManagement::StructureElementUpdateEffectOverrideRequest request;
|
||||
request.structureElementId(structureElementIdMp);
|
||||
request.effectId(relayId);
|
||||
request.effectOverride(override);
|
||||
request.structureElementId = structureElementIdMp;
|
||||
request.effectId = relayId;
|
||||
request.effectOverride = override;
|
||||
DEBUG_LOG(m_logger) << "Vor structureElementUpdateEffectOverrideRequest";
|
||||
int result = m_mainHandler->ismHandler()->ftcIsm()->structureElementUpdateEffectOverrideRequest(request, this);
|
||||
DEBUG_LOG(m_logger) << "Nach structureElementUpdateEffectOverrideRequest result=" << result;
|
||||
@@ -875,9 +876,9 @@ void BuildingProcess::handleRelayState(BuildingControlUnit::Json::Telegrams::Rel
|
||||
<< " assetId=" << egcu.assetId
|
||||
<< " hostname='" << egcu.hostname
|
||||
<< "' buildingName=" << egcu.buildingName;
|
||||
state.id(egcu.assetId);
|
||||
state.stateTime(tel->stateTime);
|
||||
state.offlineTime(tel->offlineTime);
|
||||
state.id = egcu.assetId;
|
||||
state.stateTime = tel->stateTime;
|
||||
state.offlineTime = tel->offlineTime;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -885,10 +886,10 @@ void BuildingProcess::handleRelayState(BuildingControlUnit::Json::Telegrams::Rel
|
||||
RelayStateItem item;
|
||||
for (const auto &info : std::as_const(tel->relayStates))
|
||||
{
|
||||
item.id(info.id);
|
||||
item.state(info.state);
|
||||
item.id = info.id;
|
||||
item.state = info.state;
|
||||
|
||||
state.relayStates().push_back(item);
|
||||
state.relayStates.push_back(item);
|
||||
}
|
||||
|
||||
|
||||
@@ -914,85 +915,85 @@ void BuildingProcess::handleEffectOverride(BuildingControlUnit::Json::Telegrams:
|
||||
<< " structureElementId=" << m_buildingInfo.structureElementId
|
||||
<< " structureElementIdMp=" << structureElementIdMp;
|
||||
|
||||
request.structureElementId(structureElementIdMp);
|
||||
request.structureElementId = structureElementIdMp;
|
||||
}
|
||||
for ( int j = 0; j < tel->overrides.size(); j++ )
|
||||
{
|
||||
|
||||
request.effectId(tel->overrides.at(j).id);
|
||||
request.effectId = tel->overrides.at(j).id;
|
||||
switch (tel->overrides.at(j).effectOverride)
|
||||
{
|
||||
case -1:
|
||||
{
|
||||
request.effectOverride(InfrastructureManagement::EffectOverride_def::Automatic);
|
||||
request.effectOverride = InfrastructureManagement::EffectOverride::Automatic;
|
||||
break;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
request.effectOverride(InfrastructureManagement::EffectOverride_def::PermanentOff);
|
||||
request.effectOverride = InfrastructureManagement::EffectOverride::PermanentOff;
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
request.effectOverride(InfrastructureManagement::EffectOverride_def::PermanentOn);
|
||||
request.effectOverride = InfrastructureManagement::EffectOverride::PermanentOn;
|
||||
break;
|
||||
}
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "Send Override Request"
|
||||
<< " structureElementId=" << request.structureElementId()
|
||||
<< " effectId=" << request.effectId()
|
||||
<< " effectOverride=" << request.effectOverride();
|
||||
if ( request.structureElementId() > 0)
|
||||
<< " structureElementId=" << request.structureElementId
|
||||
<< " effectId=" << request.effectId
|
||||
<< " effectOverride=" << request.effectOverride;
|
||||
if ( request.structureElementId > 0)
|
||||
m_mainHandler->ddsHandler()->ftcIsm()->structureElementUpdateEffectOverrideRequest(request, this);
|
||||
else
|
||||
ERROR_LOG(m_logger) << "request.structureElementId() =" << request.structureElementId() << " NOT VALID!!!";
|
||||
ERROR_LOG(m_logger) << "request.structureElementId() =" << request.structureElementId << " NOT VALID!!!";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool BuildingProcess::isValidPos(const Core::GeoPosition &pos)
|
||||
{
|
||||
if (qFuzzyIsNull(pos.lat()) && qFuzzyIsNull(pos.lon()))
|
||||
if (qFuzzyIsNull(pos.lat) && qFuzzyIsNull(pos.lon))
|
||||
return false;
|
||||
return !std::isnan(pos.lat()) && !std::isnan(pos.lon());
|
||||
return !std::isnan(pos.lat) && !std::isnan(pos.lon);
|
||||
}
|
||||
|
||||
void BuildingProcess::sendHitLine(const BuildingState &state)
|
||||
{
|
||||
if (state.originatorParticipantId() <= 0)
|
||||
if (state.originatorParticipantId <= 0)
|
||||
return;
|
||||
const ParticipantManagement::ParticipantPosition participantPosition = m_mainHandler->ppmHandler()->participantPosition(state.originatorParticipantId());
|
||||
if (!isValidPos(participantPosition.pos()))
|
||||
const ParticipantManagement::ParticipantPosition participantPosition = m_mainHandler->ppmHandler()->participantPosition(state.originatorParticipantId);
|
||||
if (!isValidPos(participantPosition.pos))
|
||||
return;
|
||||
BuildingHitLineInfo buildingHitLineInfo;
|
||||
InfrastructureManagement::MainStructureElement mainStructureElement = m_mainHandler->ismHandler()->mainStructureElement(state.id());
|
||||
InfrastructureManagement::MainStructureElement mainStructureElement = m_mainHandler->ismHandler()->mainStructureElement(state.id);
|
||||
|
||||
buildingHitLineInfo.id(m_hitLineId);
|
||||
buildingHitLineInfo.buildingId(m_buildingInfo.mseId);
|
||||
buildingHitLineInfo.buildingPos(mainStructureElement.geoPosition());
|
||||
if (state.hitOnRoomId() > 0)
|
||||
buildingHitLineInfo.id = m_hitLineId;
|
||||
buildingHitLineInfo.buildingId = m_buildingInfo.mseId;
|
||||
buildingHitLineInfo.buildingPos = mainStructureElement.geoPosition;
|
||||
if (state.hitOnRoomId > 0)
|
||||
{
|
||||
for (const auto &se : mainStructureElement.elements())
|
||||
for (const auto &se : mainStructureElement.elements)
|
||||
{
|
||||
if (se.structureElementTypeId() == InfrastructureManagement::StructureElementType::Room &&
|
||||
se.mountingPointId() == state.hitOnRoomId())
|
||||
if (se.structureElementTypeId == InfrastructureManagement::StructureElementType::Room &&
|
||||
se.mountingPointId == state.hitOnRoomId)
|
||||
{
|
||||
buildingHitLineInfo.buildingPos(se.geoPosition());
|
||||
buildingHitLineInfo.buildingPos = se.geoPosition;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
buildingHitLineInfo.chargeTypeId(state.chargeTypeId());
|
||||
buildingHitLineInfo.originatorParticipantId(state.originatorParticipantId());
|
||||
buildingHitLineInfo.originatorPos(participantPosition.pos());
|
||||
buildingHitLineInfo.originatorPartyId(participantPosition.partyId());
|
||||
buildingHitLineInfo.sampleTime(state.sampleTime());
|
||||
buildingHitLineInfo.hitOnRoomId(state.hitOnRoomId());
|
||||
buildingHitLineInfo.contaminationStates(state.contaminationStates());
|
||||
buildingHitLineInfo.chargeTypeId = state.chargeTypeId;
|
||||
buildingHitLineInfo.originatorParticipantId = state.originatorParticipantId;
|
||||
buildingHitLineInfo.originatorPos = participantPosition.pos;
|
||||
buildingHitLineInfo.originatorPartyId = participantPosition.partyId;
|
||||
buildingHitLineInfo.sampleTime = state.sampleTime;
|
||||
buildingHitLineInfo.hitOnRoomId = state.hitOnRoomId;
|
||||
buildingHitLineInfo.contaminationStates = state.contaminationStates;
|
||||
|
||||
m_mainHandler->ddsHandler()->dts()->publish(buildingHitLineInfo);
|
||||
|
||||
m_hitLineInfoMap.insert(buildingHitLineInfo.id(), buildingHitLineInfo);
|
||||
m_hitLineInfoMap.insert(buildingHitLineInfo.id, buildingHitLineInfo);
|
||||
++m_hitLineId;
|
||||
}
|
||||
|
||||
@@ -1003,9 +1004,9 @@ void BuildingProcess::onHitLineInfoTimeout()
|
||||
auto it = m_hitLineInfoMap.begin();
|
||||
while (it != m_hitLineInfoMap.end())
|
||||
{
|
||||
if (!LtsUtils::isPositionTimeOutdated(tNow, it.value().sampleTime()))
|
||||
if (!LtsUtils::isPositionTimeOutdated(tNow, it.value().sampleTime))
|
||||
break;
|
||||
m_mainHandler->ddsHandler()->dts()->removeBuildingHitLineInfoByKey(it.value().id());
|
||||
m_mainHandler->ddsHandler()->dts()->removeBuildingHitLineInfoByKey(it.value().id);
|
||||
|
||||
it = m_hitLineInfoMap.erase(it);
|
||||
}
|
||||
@@ -1037,16 +1038,16 @@ static void outputBsmData(QXmlStreamWriter &sw, const BsmInfo &bsm)
|
||||
|
||||
sw.writeStartElement(QStringLiteral("Position"));
|
||||
{
|
||||
sw.writeAttribute(QStringLiteral("x"), QString::number(bsm.relPosition.offsetX(), 'f', 10));
|
||||
sw.writeAttribute(QStringLiteral("y"), QString::number(bsm.relPosition.offsetY(), 'f', 10));
|
||||
sw.writeAttribute(QStringLiteral("z"), QString::number(bsm.relPosition.offsetZ(), 'f', 10));
|
||||
sw.writeAttribute(QStringLiteral("x"), QString::number(bsm.relPosition.offsetX, 'f', 10));
|
||||
sw.writeAttribute(QStringLiteral("y"), QString::number(bsm.relPosition.offsetY, 'f', 10));
|
||||
sw.writeAttribute(QStringLiteral("z"), QString::number(bsm.relPosition.offsetZ, 'f', 10));
|
||||
}
|
||||
sw.writeEndElement();
|
||||
sw.writeStartElement(QStringLiteral("Direction"));
|
||||
{
|
||||
sw.writeAttribute(QStringLiteral("x"), QString::number(bsm.orientation.heave(), 'f', 10));
|
||||
sw.writeAttribute(QStringLiteral("y"), QString::number(bsm.orientation.pitch(), 'f', 10));
|
||||
sw.writeAttribute(QStringLiteral("z"), QString::number(bsm.orientation.roll(), 'f', 10));
|
||||
sw.writeAttribute(QStringLiteral("x"), QString::number(bsm.orientation.heave, 'f', 10));
|
||||
sw.writeAttribute(QStringLiteral("y"), QString::number(bsm.orientation.pitch, 'f', 10));
|
||||
sw.writeAttribute(QStringLiteral("z"), QString::number(bsm.orientation.roll, 'f', 10));
|
||||
}
|
||||
sw.writeEndElement();
|
||||
}
|
||||
@@ -1077,7 +1078,6 @@ QByteArray BuildingProcess::generateBuildingConfigData() const
|
||||
QXmlStreamWriter sw(&ret);
|
||||
sw.setAutoFormatting(true);
|
||||
sw.setAutoFormattingIndent(2);
|
||||
sw.setCodec("UTF-8");
|
||||
sw.writeStartDocument(QStringLiteral("1.0"), true);
|
||||
sw.writeStartElement(QStringLiteral("BuildingConfiguration"));
|
||||
{
|
||||
@@ -1103,31 +1103,30 @@ QByteArray BuildingProcess::generateChargesData() const
|
||||
QXmlStreamWriter sw(&ret);
|
||||
sw.setAutoFormatting(true);
|
||||
sw.setAutoFormattingIndent(2);
|
||||
sw.setCodec("UTF-8");
|
||||
sw.writeStartDocument(QStringLiteral("1.0"), true);
|
||||
sw.writeStartElement(QStringLiteral("Charges"));
|
||||
{
|
||||
for (const ProjectDataManagement::BuildingChargeEffect &charge : buildingCharges)
|
||||
{
|
||||
auto it = chargeTypes.find(charge.chargeTypeId());
|
||||
auto it = chargeTypes.find(charge.chargeTypeId);
|
||||
if (it == chargeTypes.end())
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Could not find charge type with id " << charge.chargeTypeId() << " - skipping";
|
||||
WARNING_LOG(m_logger) << "Could not find charge type with id " << charge.chargeTypeId << " - skipping";
|
||||
continue;
|
||||
}
|
||||
|
||||
ProjectDataManagement::ChargeTypeProperty chargeTypeProperty = m_mainHandler->ddsHandler()->dtcPdm()->getChargeTypeSpecialProperty(charge.chargeTypeId(),0,0);
|
||||
ProjectDataManagement::ChargeTypeProperty chargeTypeProperty = m_mainHandler->ddsHandler()->dtcPdm()->getChargeTypeSpecialProperty(charge.chargeTypeId,0,0);
|
||||
sw.writeStartElement(QStringLiteral("Charge"));
|
||||
sw.writeTextElement(QStringLiteral("Id"), QString::number(charge.id()));
|
||||
sw.writeTextElement(QStringLiteral("ChargeTypeId"), QString::number(charge.chargeTypeId()));
|
||||
sw.writeTextElement(QStringLiteral("DestructiveFactor"), QString::number(charge.destructiveFactor()));
|
||||
sw.writeTextElement(QStringLiteral("PenetrationEffect"), QString::number(charge.penetrationFactor()));
|
||||
sw.writeTextElement(QStringLiteral("Id"), QString::number(charge.id));
|
||||
sw.writeTextElement(QStringLiteral("ChargeTypeId"), QString::number(charge.chargeTypeId));
|
||||
sw.writeTextElement(QStringLiteral("DestructiveFactor"), QString::number(charge.destructiveFactor));
|
||||
sw.writeTextElement(QStringLiteral("PenetrationEffect"), QString::number(charge.penetrationFactor));
|
||||
sw.writeTextElement(QStringLiteral("properties"), properties);
|
||||
sw.writeTextElement(QStringLiteral("EffectSound"), QString::number(charge.hitSound()));
|
||||
sw.writeTextElement(QStringLiteral("DifcueLight"), QString::number(charge.difcueLight()));
|
||||
sw.writeTextElement(QStringLiteral("DifcuePyro"), QString::number(charge.difcuePyro()));
|
||||
if (chargeTypeProperty == ProjectDataManagement::ChargeTypeProperty_def::None)
|
||||
if (charge.destructiveFactor() > 0)
|
||||
sw.writeTextElement(QStringLiteral("EffectSound"), QString::number(charge.hitSound));
|
||||
sw.writeTextElement(QStringLiteral("DifcueLight"), QString::number(charge.difcueLight));
|
||||
sw.writeTextElement(QStringLiteral("DifcuePyro"), QString::number(charge.difcuePyro));
|
||||
if (chargeTypeProperty == ProjectDataManagement::ChargeTypeProperty::None)
|
||||
if (charge.destructiveFactor > 0)
|
||||
sw.writeTextElement(QStringLiteral("showHitLine"), QString::number(1));
|
||||
else
|
||||
sw.writeTextElement(QStringLiteral("showHitLine"), QString::number(0));
|
||||
|
||||
Reference in new issue
Block a user