Migrates OcSituation and ServiceManagement to generated rtiddsgen API
Converts accessor calls to plain member access in osc, oss and obd services.
This commit is contained in:
30 files changed
+1000
-1007
No files matched your search
+64
-64
@@ -95,7 +95,7 @@ void HandlerOcSituationData::process(const QByteArray &data, bool bIsInitial)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Processing initial situation data.";
|
||||
|
||||
int ownEquipmentNumber = m_tabocDtc->specificsEquipment(1).equipmentNumber();
|
||||
int ownEquipmentNumber = m_tabocDtc->specificsEquipment(1).equipmentNumber;
|
||||
int ownParticipantId = -1;
|
||||
for (const int &participantId : qAsConst(m_participantId2EqId))
|
||||
{
|
||||
@@ -133,14 +133,14 @@ void HandlerOcSituationData::process(const QByteArray &data, bool bIsInitial)
|
||||
void HandlerOcSituationData::removeAllPositions()
|
||||
{
|
||||
TrainingAreaBase::EquipmentPosition invalidPos;
|
||||
invalidPos.position().position().lon(nan(""));
|
||||
invalidPos.position().position().lat(nan(""));
|
||||
invalidPos.position().reportingSource(Core::PositionReportingSource::SetByOperator); // SetByOperator -> nan is allowed
|
||||
invalidPos.sampleTime(m_dds->currentPartitionTime());
|
||||
invalidPos.position.position.lon = nan("");
|
||||
invalidPos.position.position.lat = nan("");
|
||||
invalidPos.position.reportingSource = Core::PositionReportingSource::SetByOperator; // SetByOperator -> nan is allowed
|
||||
invalidPos.sampleTime = m_dds->currentPartitionTime();
|
||||
|
||||
for (const auto eqNumber : qAsConst(m_participantId2EqId))
|
||||
{
|
||||
invalidPos.equipmentNumber(eqNumber);
|
||||
invalidPos.equipmentNumber = eqNumber;
|
||||
m_tabDts->publish(invalidPos);
|
||||
}
|
||||
}
|
||||
@@ -148,11 +148,11 @@ void HandlerOcSituationData::removeAllPositions()
|
||||
void HandlerOcSituationData::setInvalidPositionForParticipant(int participantId)
|
||||
{
|
||||
TrainingAreaBase::EquipmentPosition invalidPos;
|
||||
invalidPos.position().position().lon(nan(""));
|
||||
invalidPos.position().position().lat(nan(""));
|
||||
invalidPos.position().reportingSource(Core::PositionReportingSource::SetByOperator); // SetByOperator -> nan is allowed
|
||||
invalidPos.sampleTime(m_dds->currentPartitionTime());
|
||||
invalidPos.equipmentNumber(-participantId); // negative -> treat equipNo as participantId
|
||||
invalidPos.position.position.lon = nan("");
|
||||
invalidPos.position.position.lat = nan("");
|
||||
invalidPos.position.reportingSource = Core::PositionReportingSource::SetByOperator; // SetByOperator -> nan is allowed
|
||||
invalidPos.sampleTime = m_dds->currentPartitionTime();
|
||||
invalidPos.equipmentNumber = -participantId; // negative -> treat equipNo as participantId
|
||||
m_tabDts->publish(invalidPos);
|
||||
}
|
||||
|
||||
@@ -187,8 +187,8 @@ bool HandlerOcSituationData::decodeSituationData(const QByteArray &data)
|
||||
LtsUtils::get1Byte(data, participantOverloaded);
|
||||
//send overload topic
|
||||
TrainingAreaBaseOC::ParticipantsOverload participantsOverload;
|
||||
participantsOverload.id(1);
|
||||
participantsOverload.hasOverload(participantOverloaded);
|
||||
participantsOverload.id = 1;
|
||||
participantsOverload.hasOverload = participantOverloaded;
|
||||
m_tabocDts->publish(participantsOverload);
|
||||
DEBUG_LOG(m_logger) << "publish overload: " << participantOverloaded;
|
||||
|
||||
@@ -233,7 +233,7 @@ bool HandlerOcSituationData::decodeSituationData(const QByteArray &data)
|
||||
// position
|
||||
bool bRet = false;
|
||||
TrainingAreaBase::EquipmentPosition position;
|
||||
position.position().reportingSource(Core::PositionReportingSource::Gps); // we don't know better
|
||||
position.position.reportingSource = Core::PositionReportingSource::Gps; // we don't know better
|
||||
bRet |= getPosition2D(uncompressed, pos, position, (modifiedFlag & OcSituation::ModificationFlag::ePosition2D) == OcSituation::ModificationFlag::ePosition2D);
|
||||
bRet |= getPosition3D(uncompressed, pos, position, (modifiedFlag & OcSituation::ModificationFlag::ePosition3D) == OcSituation::ModificationFlag::ePosition3D);
|
||||
if (bRet)
|
||||
@@ -274,22 +274,22 @@ bool HandlerOcSituationData::decodeSituationData(const QByteArray &data)
|
||||
bRet |= getSymbolSidc(uncompressed, pos, participantData, (modifiedFlag & OcSituation::ModificationFlag::eSymbol) == OcSituation::ModificationFlag::eSymbol);
|
||||
//sanity
|
||||
bool bInsane = false;
|
||||
if (bRet && (participantData.partyId() <= 0 || participantData.id() <= 0 || participantData.typeId() <= 0))
|
||||
if (bRet && (participantData.partyId <= 0 || participantData.id <= 0 || participantData.typeId <= 0))
|
||||
bInsane = true;
|
||||
|
||||
if (bRet && !bInsane)
|
||||
{
|
||||
int unitId = Settings::unitOffset() + participantData.partyId();
|
||||
if (participantData.id() == 0) // if new participant
|
||||
int unitId = Settings::unitOffset() + participantData.partyId;
|
||||
if (participantData.id == 0) // if new participant
|
||||
{
|
||||
participantData.id(participantId);
|
||||
participantData.modId(modId++);
|
||||
participantData.hierarchyNumber(participantId); // it just needs to be unqiue here
|
||||
participantData.id = participantId;
|
||||
participantData.modId = modId++;
|
||||
participantData.hierarchyNumber = participantId; // it just needs to be unqiue here
|
||||
}
|
||||
//always set superiorModId! changeing party Id only won't work
|
||||
participantData.superiorModId(unitId);
|
||||
participantData.superiorModId = unitId;
|
||||
|
||||
participantData.assignState(ParticipantManagement::ParticipantAssignState::HandoutExcon); // set always as we can deduce it anyway //TODO cant reasign EQ nr
|
||||
participantData.assignState = ParticipantManagement::ParticipantAssignState::HandoutExcon; // set always as we can deduce it anyway //TODO cant reasign EQ nr
|
||||
|
||||
if (!m_participantData.contains(unitId)) // Adding Unit to participantData, if not already added
|
||||
{
|
||||
@@ -300,14 +300,14 @@ bool HandlerOcSituationData::decodeSituationData(const QByteArray &data)
|
||||
m_participantData.insert(participantId, participantData);
|
||||
DEBUG_LOG(m_logger) << "Adding ParticipantData to internal map: " << participantData;
|
||||
|
||||
if (participantData.equipmentNumber().is_set())
|
||||
m_participantId2EqId[participantId] = participantData.equipmentNumber().get();
|
||||
if (participantData.equipmentNumber.is_set())
|
||||
m_participantId2EqId[participantId] = participantData.equipmentNumber.get();
|
||||
else
|
||||
m_participantId2EqId[participantId] = 0; // so the positions can be removed, see e.g. removeAllPositions()
|
||||
}
|
||||
|
||||
// no position update for ourself. Easier to filter here than in server but a bit overhead in TETRA
|
||||
if (m_tabocDtc->specificsEquipment(1).equipmentNumber() == m_participantId2EqId.value(participantId))
|
||||
if (m_tabocDtc->specificsEquipment(1).equipmentNumber == m_participantId2EqId.value(participantId))
|
||||
m_equipmentPositions.remove(participantId);
|
||||
}
|
||||
|
||||
@@ -344,10 +344,10 @@ void HandlerOcSituationData::publishMap(QMap<int, T> &map)
|
||||
{
|
||||
for (auto it = map.begin(); it != map.end();)
|
||||
{
|
||||
if (m_participants.value(it.key()).id() > 0) // publishing only for existing participants
|
||||
if (m_participants.value(it.key()).id > 0) // publishing only for existing participants
|
||||
{
|
||||
auto topic = it.value();
|
||||
topic.equipmentNumber(m_participantId2EqId.value(it.key()));
|
||||
topic.equipmentNumber = m_participantId2EqId.value(it.key());
|
||||
m_tabDts->publish(topic);
|
||||
it = map.erase(it);
|
||||
}
|
||||
@@ -382,10 +382,10 @@ bool HandlerOcSituationData::getPosition2D(const QByteArray &buf, size_t &pos, T
|
||||
// lon, lat, sampleTime
|
||||
double tmp;
|
||||
bRet &= LtsUtils::get8Byte(buf, pos, tmp);
|
||||
position.position().position().lon(tmp);
|
||||
position.position.position.lon = tmp;
|
||||
bRet &= LtsUtils::get8Byte(buf, pos, tmp);
|
||||
position.position().position().lat(tmp);
|
||||
position.sampleTime(m_dds->currentPartitionTime());
|
||||
position.position.position.lat = tmp;
|
||||
position.sampleTime = m_dds->currentPartitionTime();
|
||||
|
||||
return bRet;
|
||||
}
|
||||
@@ -404,15 +404,15 @@ bool HandlerOcSituationData::getPosition3D(const QByteArray &buf, size_t &pos, T
|
||||
int buildingId = -1;
|
||||
|
||||
bRet &= LtsUtils::get8Byte(buf, pos, tmp);
|
||||
position.position().position().z(tmp);
|
||||
position.position.position.z = tmp;
|
||||
bRet &= LtsUtils::get2Byte(buf, pos, buildingId);
|
||||
bRet &= LtsUtils::get4Byte(buf, pos, roomId);
|
||||
|
||||
if (buildingId > 0 && roomId > 0)
|
||||
{
|
||||
position.position().moutRoomId().set(roomId);
|
||||
position.position().moutObjectId().set(buildingId);
|
||||
position.position().reportingSource() = (tmp >= 0.0) ? Core::PositionReportingSource::Ops : Core::PositionReportingSource::OpsTunnel;
|
||||
position.position.moutRoomId.set(roomId);
|
||||
position.position.moutObjectId.set(buildingId);
|
||||
position.position.reportingSource = (tmp >= 0.0) ? Core::PositionReportingSource::Ops : Core::PositionReportingSource::OpsTunnel;
|
||||
}
|
||||
|
||||
|
||||
@@ -429,11 +429,11 @@ bool HandlerOcSituationData::getVBG(const QByteArray &buf, size_t &pos, Training
|
||||
// vulnerabilityState, vulnerabilityBits, originatorParty, sampleTime
|
||||
uint64_t tmp;
|
||||
bRet &= LtsUtils::get1Byte(buf, pos, tmp);
|
||||
equipmentState.vulnerabilityState(ProjectDataManagement::VulnerabilityState::inner_enum(tmp));
|
||||
equipmentState.vulnerabilityState = ProjectDataManagement::VulnerabilityState::inner_enum(tmp);
|
||||
bRet &= LtsUtils::get4Byte(buf, pos, tmp);
|
||||
equipmentState.vulnerabilityKindId(tmp);
|
||||
equipmentState.vulnerabilityKindId = tmp;
|
||||
bRet &= LtsUtils::get2Byte(buf, pos, tmp);
|
||||
equipmentState.vulnerabilityBits(tmp);
|
||||
equipmentState.vulnerabilityBits = tmp;
|
||||
bRet &= LtsUtils::get1Byte(buf, pos, tmp);
|
||||
if (!m_knownParties.contains(tmp))
|
||||
{
|
||||
@@ -443,32 +443,32 @@ bool HandlerOcSituationData::getVBG(const QByteArray &buf, size_t &pos, Training
|
||||
//Sollte nicht passieren, doch falls ja gibt es goldene Kreuze beim Ausfall
|
||||
tmp = 1;
|
||||
}
|
||||
equipmentState.originatorId(Settings::unitOffset() + tmp);
|
||||
equipmentState.originatorId = Settings::unitOffset() + tmp;
|
||||
|
||||
if (m_bWithVBGTime)
|
||||
{
|
||||
bRet &= LtsUtils::get4Byte(buf, pos, tmp);
|
||||
equipmentState.sampleTime(tmp * 1000UL);
|
||||
equipmentState.sampleTime = tmp * 1000UL;
|
||||
}
|
||||
else
|
||||
equipmentState.sampleTime(QDateTime::currentMSecsSinceEpoch());
|
||||
equipmentState.sampleTime = QDateTime::currentMSecsSinceEpoch();
|
||||
|
||||
quint8 vitRest;
|
||||
bRet &= LtsUtils::get1Byte(buf, pos, vitRest);
|
||||
if (bRet)
|
||||
{
|
||||
int vit = (vitRest & 0x0F) * 10;
|
||||
equipmentState.vitality(vit);
|
||||
equipmentState.vitality = vit;
|
||||
TrainingAreaBase::SanitationResult result = static_cast<TrainingAreaBase::SanitationResult_def::type>(vitRest >> 4);
|
||||
sanitation.sanitationResult(result);
|
||||
sanitation.proceduresTaken(1);
|
||||
sanitation.qualification(TrainingAreaBase::Qualification::SANPers);
|
||||
sanitation.sanitationResult = result;
|
||||
sanitation.proceduresTaken = 1;
|
||||
sanitation.qualification = TrainingAreaBase::Qualification::SANPers;
|
||||
|
||||
}
|
||||
qint8 originator = 0;
|
||||
bRet &= LtsUtils::get1Byte(buf, pos, originator);
|
||||
if (bRet)
|
||||
equipmentState.originatorType(ProjectDataManagement::StateChangeOriginator::inner_enum(originator));
|
||||
equipmentState.originatorType = ProjectDataManagement::StateChangeOriginator::inner_enum(originator);
|
||||
|
||||
return bRet;
|
||||
}
|
||||
@@ -483,12 +483,12 @@ bool HandlerOcSituationData::getState(const QByteArray &buf, size_t &pos, Traini
|
||||
int tmp;
|
||||
bRet &= LtsUtils::get1Byte(buf, pos, tmp);
|
||||
|
||||
specialSensorData.sampleTime(m_dds->currentPartitionTime());
|
||||
specialSensorData.sampleTime = m_dds->currentPartitionTime();
|
||||
|
||||
equipmentOperationalState.nbcProtectionActive((tmp & 0x02) || (tmp & 0x04));
|
||||
equipmentOperationalState.isManipulation(tmp & 0x02);
|
||||
equipmentOperationalState.nbcProtectionActive = (tmp & 0x02) || (tmp & 0x04);
|
||||
equipmentOperationalState.isManipulation = tmp & 0x02;
|
||||
|
||||
equipmentOperationalState.sampleTime(m_dds->currentPartitionTime());
|
||||
equipmentOperationalState.sampleTime = m_dds->currentPartitionTime();
|
||||
|
||||
return bRet;
|
||||
}
|
||||
@@ -502,15 +502,15 @@ bool HandlerOcSituationData::getStructure(const QByteArray &buf, size_t &pos, Pa
|
||||
// equipmentNumber, typeId, partyId
|
||||
int tmp;
|
||||
bRet &= LtsUtils::get2Byte(buf, pos, tmp);
|
||||
participant.equipmentNumber(dds::core::optional<int32_t>(tmp));
|
||||
participant.equipmentNumber = dds::core::optional<int32_t>(tmp);
|
||||
bRet &= LtsUtils::get2Byte(buf, pos, tmp);
|
||||
participant.typeId(tmp);
|
||||
participant.typeId = tmp;
|
||||
bRet &= LtsUtils::get2Byte(buf, pos, tmp);
|
||||
if (m_knownParties.contains(tmp))
|
||||
participant.partyId(tmp);
|
||||
participant.partyId = tmp;
|
||||
else
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Not setting new party: " << tmp << " for participant: " << participant.id() << " as the party is unknown -> do a base download.";
|
||||
WARNING_LOG(m_logger) << "Not setting new party: " << tmp << " for participant: " << participant.id << " as the party is unknown -> do a base download.";
|
||||
bRet = false;
|
||||
}
|
||||
|
||||
@@ -540,12 +540,12 @@ bool HandlerOcSituationData::getDesignator(const QByteArray &buf, size_t &pos, P
|
||||
if ((size_t)buf.size() < pos + len1)
|
||||
bRet = false;
|
||||
if (bRet)
|
||||
participant.designator(buf.mid(pos, len1).toStdString());
|
||||
participant.designator = buf.mid(pos, len1).toStdString();
|
||||
pos += len1;
|
||||
if ((size_t)buf.size() < pos + len2)
|
||||
bRet = false;
|
||||
if (bRet)
|
||||
participant.tacticalIdentifier(buf.mid(pos, len2).toStdString());
|
||||
participant.tacticalIdentifier = buf.mid(pos, len2).toStdString();
|
||||
pos += len2;
|
||||
|
||||
return bRet;
|
||||
@@ -562,14 +562,14 @@ bool HandlerOcSituationData::getSymbolSidc(const QByteArray &buf, size_t &pos, P
|
||||
if (len == 0)
|
||||
{
|
||||
// get symbol from type id
|
||||
const auto type = m_ppmDtc->type(participant.typeId());
|
||||
participant.symbol(type.symbol());
|
||||
const auto type = m_ppmDtc->type(participant.typeId);
|
||||
participant.symbol = type.symbol;
|
||||
return bRet;
|
||||
}
|
||||
if ((size_t)buf.size() < pos + len)
|
||||
bRet = false;
|
||||
if (bRet)
|
||||
participant.symbol(buf.mid(pos, len).toStdString());
|
||||
participant.symbol = buf.mid(pos, len).toStdString();
|
||||
pos += len;
|
||||
|
||||
return bRet;
|
||||
@@ -581,10 +581,10 @@ void HandlerOcSituationData::onPartyChanged(const ParticipantManagement::Party &
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
case DataModification::eModified:
|
||||
m_knownParties.insert(party.id());
|
||||
m_knownParties.insert(party.id);
|
||||
break;
|
||||
case DataModification::eRemoved:
|
||||
m_knownParties.remove(party.id());
|
||||
m_knownParties.remove(party.id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -595,13 +595,13 @@ void HandlerOcSituationData::onParticipantChanged(const ParticipantManagement::P
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
case DataModification::eModified:
|
||||
m_participants[participant.id()] = participant;
|
||||
m_participants[participant.id] = participant;
|
||||
// if there is a participant but it has (currently) no equipno, remove it from sitmap by setting invalid position
|
||||
if (!m_participantId2EqId.contains(participant.id()))
|
||||
setInvalidPositionForParticipant(participant.id());
|
||||
if (!m_participantId2EqId.contains(participant.id))
|
||||
setInvalidPositionForParticipant(participant.id);
|
||||
break;
|
||||
case DataModification::eRemoved:
|
||||
m_participants.remove(participant.id());
|
||||
m_participants.remove(participant.id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user