Migrates InfrastructureManagement to generated rtiddsgen API

Converts accessor calls to plain member access across ism service.
This commit is contained in:
berrux-dev committed 2026-09-21 02:45:09 +02:00
1 parent 472f537313
commit 82356f23e5
30 files changed
+1322 -1314

No files matched your search

@@ -4,9 +4,15 @@
# $Author$
#
# Make ${Qt6_WebSockets} optional
if(QT6_GUI_AVAILABLE AND TARGET Qt6::WebSockets)
set(Qt6_WebSockets ${Qt6_WebSockets})
# Link the real WebSockets module whenever the websocket code path is
# compiled: QT6_WEBSOCKETS_AVAILABLE (root CMakeLists) and the manual
# Qt6::WebSockets import are set when the real module was found. The old
# QT6_GUI_AVAILABLE condition never holds in this environment (Qt6
# discovery takes the minimal path) and the Qt6_WebSockets variable was
# never defined, so the websocket code compiled without the module on the
# link line and failed only at link time.
if(QT6_WEBSOCKETS_REAL_FOUND OR Qt6WebSockets_FOUND)
set(Qt6_WebSockets Qt6::WebSockets)
else()
set(Qt6_WebSockets "")
endif()
@@ -141,7 +141,7 @@ void IsmImportBuildings::remove(int buildingId)
auto predicate = [](const InfrastructureManagement::InstrumentationAsset & a)
{
return (!a.isDeleted() && (a.mountingPointTypeId() != InfrastructureManagement::MountingPointType::BuildingControlUnit));
return (!a.isDeleted && (a.mountingPointTypeId != InfrastructureManagement::MountingPointType::BuildingControlUnit));
};
QMap<int, QVector<InfrastructureManagement::InstrumentationAsset>> assetsMapBuilding;
@@ -190,7 +190,7 @@ void IsmImportBuildings::doImport()
INFO_LOG(m_logger) << "Sending request";
MainStructureElementModifyRequest req = buildingXml.parsedRequest();
QByteArray propertiesBa = QByteArray::fromStdString(req.properties());
QByteArray propertiesBa = QByteArray::fromStdString(req.properties);
QJsonParseError parserError;
const QJsonDocument doc(QJsonDocument::fromJson(propertiesBa, &parserError));
if (parserError.error != QJsonParseError::NoError)
@@ -202,17 +202,17 @@ void IsmImportBuildings::doImport()
QJsonArray array;
array.push_back(m_currentData.exerciseId);
obj.insert(QLatin1String("available_in_exercise"), array);
req.properties(QJsonDocument(obj).toJson(QJsonDocument::Compact).toStdString());
req.properties = QJsonDocument(obj).toJson(QJsonDocument::Compact).toStdString();
}
if (m_currentData.buildingId > 0)
req.id(m_currentData.buildingId);
req.externalWlsId(m_currentData.externalWlsId);
req.groupId(m_currentData.bauabschnitt);
req.structureElementTypeId(InfrastructureManagement::StructureElementType::Building);
req.id = m_currentData.buildingId;
req.externalWlsId = m_currentData.externalWlsId;
req.groupId = m_currentData.bauabschnitt;
req.structureElementTypeId = InfrastructureManagement::StructureElementType::Building;
// check if building exists
MainStructureElement oldMainStructureElement = mainStructureElementByName(req.name());
MainStructureElement oldMainStructureElement = mainStructureElementByName(req.name);
std::string msg;
QMap<qint32, QVector<std::string>> oldNamePaths;
QVector<MountingPointAsset> mountings;
@@ -220,7 +220,7 @@ void IsmImportBuildings::doImport()
if (oldMainStructureElement != MainStructureElement())
{
m_isInRestoringMode = true;
msg = "Building " + req.name() + " already exists. All related data is now saved.";
msg = "Building " + req.name + " already exists. All related data is now saved.";
INFO_LOG(m_logger) << msg;
std::cerr << msg << std::endl;
@@ -228,11 +228,11 @@ void IsmImportBuildings::doImport()
INFO_LOG(m_logger) << msg;
std::cerr << msg << std::endl;
QVector<qint32> mountingPointIds;
for (const StructureElement &structureElement : oldMainStructureElement.elements())
for (const StructureElement &structureElement : oldMainStructureElement.elements)
{
if (structureElement.structureElementTypeId() != StructureElementType::MountingPoint)
if (structureElement.structureElementTypeId != StructureElementType::MountingPoint)
continue;
mountingPointIds.append(structureElement.id());
mountingPointIds.append(structureElement.id);
}
msg = "Fetching MountingPointAssets.";
@@ -247,7 +247,7 @@ void IsmImportBuildings::doImport()
msg = "Removing MountingPointAssets.";
INFO_LOG(m_logger) << msg;
std::cerr << msg << std::endl;
unmountAssetsOfBuliding(oldMainStructureElement.id());
unmountAssetsOfBuliding(oldMainStructureElement.id);
// // remove mounting point assets
// for (const MountingPointAsset &mountingPointAsset : mountings)
// {
@@ -268,14 +268,14 @@ void IsmImportBuildings::doImport()
INFO_LOG(m_logger) << "Removing MountingPointPlans.";
auto copy = it.value();
for (auto &elem : copy)
elem.mountingPointState() = MountingPointState_def::Idle;
elem.mountingPointState = MountingPointState::Idle;
m_ftc->mountingPointPlanModifyRequest(MountingPointPlanModifyRequest(it.key(),copy), this);
}
msg = "Fetching paths of MountingPoints by name ... for later reconstruction.";
INFO_LOG(m_logger) << msg;
std::cerr << msg << std::endl;
for (const StructureElement &structureElement : oldMainStructureElement.elements())
oldNamePaths.insert(structureElement.id(), pathWithNames(structureElement, oldMainStructureElement));
for (const StructureElement &structureElement : oldMainStructureElement.elements)
oldNamePaths.insert(structureElement.id, pathWithNames(structureElement, oldMainStructureElement));
//msg = "Waiting for removing operations.";
connect(this, &IsmImportBuildings::removeDone, this, [this, oldMainStructureElement, oldNamePaths, mountings, mppsBySchedule, req]()
@@ -291,7 +291,7 @@ void IsmImportBuildings::doImport()
// std::cerr << "Unmount counter: " << unmountCounter << std::endl;
// QThread::sleep(1);
// }
remove(oldMainStructureElement.id());
remove(oldMainStructureElement.id);
}
else
createNewMainStructureElement(req);
@@ -321,7 +321,7 @@ MainStructureElement IsmImportBuildings::mainStructureElementByName(const std::s
for (auto it = mainStructureElements.constBegin(); it != mainStructureElements.constEnd(); ++it)
{
if (it.value().name() == name)
if (it.value().name == name)
return it.value();
}
@@ -337,10 +337,10 @@ QHash<int, std::vector<MountingPointPlan> > IsmImportBuildings::MountingPointPl
for (const MainSchedule &schedule : m_dtc->mainSchedules())
{
for (const MountingPointPlan &plan : schedule.elements())
for (const MountingPointPlan &plan : schedule.elements)
{
if (structureElementIds.contains(plan.structureElementId()))
result[schedule.id()].push_back(plan);
if (structureElementIds.contains(plan.structureElementId))
result[schedule.id].push_back(plan);
}
}
@@ -357,7 +357,7 @@ QVector<MountingPointAsset> IsmImportBuildings::mountingsOfStructureElements(con
for (auto it = mountings.constBegin(); it != mountings.constEnd(); ++it)
{
if (structureElementIds.contains(it.value().structureElementId()))
if (structureElementIds.contains(it.value().structureElementId))
result.append(it.value());
}
@@ -368,9 +368,9 @@ QVector<MountingPointAsset> IsmImportBuildings::mountingsOfStructureElements(con
QVector<std::string> IsmImportBuildings::pathWithNames(const StructureElement &structureElement, const MainStructureElement &mainStructureElement) const
{
QVector<std::string> result;
result.reserve(structureElement.path().size());
for (int32_t structureElementId : structureElement.path())
result.push_back(structureElementNameById(structureElementId, mainStructureElement.elements()));
result.reserve(structureElement.path.size());
for (int32_t structureElementId : structureElement.path)
result.push_back(structureElementNameById(structureElementId, mainStructureElement.elements));
return result;
}
@@ -380,8 +380,8 @@ std::string IsmImportBuildings::structureElementNameById(qint32 id, const std::v
{
for (const StructureElement &structureElement : structureElements)
{
if (structureElement.id() == id)
return structureElement.name();
if (structureElement.id == id)
return structureElement.name;
}
return std::string();
@@ -390,9 +390,9 @@ std::string IsmImportBuildings::structureElementNameById(qint32 id, const std::v
// ------------------------------------------------------------------------------
StructureElement IsmImportBuildings::structureElementById(qint32 id, const MainStructureElement &mainStructureElement) const
{
for (const StructureElement &structureElement : mainStructureElement.elements())
for (const StructureElement &structureElement : mainStructureElement.elements)
{
if (structureElement.id() == id)
if (structureElement.id == id)
return structureElement;
}
@@ -428,7 +428,7 @@ void IsmImportBuildings::restoreData(const MainStructureElement &oldMainStructur
if (oldMainStructureElement == MainStructureElement())
return;
MainStructureElement newMainStructureElement = mainStructureElementByName(oldMainStructureElement.name());
MainStructureElement newMainStructureElement = mainStructureElementByName(oldMainStructureElement.name);
if (newMainStructureElement == MainStructureElement())
{
FATAL_LOG(m_logger) << "There was no new MainStructureElement created. Please consider restoring the database by backup.";
@@ -436,16 +436,16 @@ void IsmImportBuildings::restoreData(const MainStructureElement &oldMainStructur
}
QVector<qint32> newMountingPointIds;
for (const StructureElement &structureElement : newMainStructureElement.elements())
for (const StructureElement &structureElement : newMainStructureElement.elements)
{
if (structureElement.structureElementTypeId() != StructureElementType::MountingPoint)
if (structureElement.structureElementTypeId != StructureElementType::MountingPoint)
continue;
newMountingPointIds.append(structureElement.id());
newMountingPointIds.append(structureElement.id);
}
QMap<qint32, QVector<std::string> > newNamePaths;
INFO_LOG(m_logger) << "Restoring mounting point data.";
for (const StructureElement &structureElement : newMainStructureElement.elements())
newNamePaths.insert(structureElement.id(), pathWithNames(structureElement, oldMainStructureElement));
for (const StructureElement &structureElement : newMainStructureElement.elements)
newNamePaths.insert(structureElement.id, pathWithNames(structureElement, oldMainStructureElement));
if (oldNamePaths.size() != newNamePaths.size())
INFO_LOG(m_logger) << "old name path size: " + QString::number(oldNamePaths.size()).toStdString() + " , new name path size: " + QString::number(newNamePaths.size()).toStdString();;
@@ -464,22 +464,22 @@ void IsmImportBuildings::restoreData(const MainStructureElement &oldMainStructur
}
StructureElementModifyRequest modifyRequest;
modifyRequest.mainStructureElementId(newMainStructureElement.id());
modifyRequest.mainStructureElementId = newMainStructureElement.id;
for (auto it = oldStructureElementIdToNewStructureElementId.constBegin(); it != oldStructureElementIdToNewStructureElementId.constEnd(); ++it)
{
StructureElement oldStructureElement = structureElementById(it.key(), oldMainStructureElement);
if (!oldStructureElement.barcode().size() && !oldStructureElement.properties().size())
if (!oldStructureElement.barcode.size() && !oldStructureElement.properties.size())
continue;
StructureElement newStructureElement = structureElementById(it.value(), newMainStructureElement);
newStructureElement.barcode(oldStructureElement.barcode());
newStructureElement.properties(oldMainStructureElement.properties());
newStructureElement.barcode = oldStructureElement.barcode;
newStructureElement.properties = oldMainStructureElement.properties;
modifyRequest.elements().push_back(newStructureElement);
modifyRequest.elements.push_back(newStructureElement);
}
if (modifyRequest.elements().size())
if (modifyRequest.elements.size())
m_ftc->structureElementModifyRequest(modifyRequest, this);
if (!mountings.isEmpty())
@@ -490,16 +490,16 @@ void IsmImportBuildings::restoreData(const MainStructureElement &oldMainStructur
// restore mountings
for (const MountingPointAsset &mountingPointAsset : mountings)
{
if (!oldStructureElementIdToNewStructureElementId.contains(mountingPointAsset.structureElementId()))
if (!oldStructureElementIdToNewStructureElementId.contains(mountingPointAsset.structureElementId))
{
msg = "There is no new StructureElement ID to old StructureElement ID " + QString::number(mountingPointAsset.structureElementId()).toStdString() + ". If somethind else looks suspicious, restore database data by backup.";
msg = "There is no new StructureElement ID to old StructureElement ID " + QString::number(mountingPointAsset.structureElementId).toStdString() + ". If somethind else looks suspicious, restore database data by backup.";
FATAL_LOG(m_logger) << msg;
std::cerr << msg << std::endl;
continue;
}
MountingPointAssetModifyRequest mountingRequest;
mountingRequest.assetId(mountingPointAsset.assetId());
mountingRequest.structureElementId(oldStructureElementIdToNewStructureElementId.value(mountingPointAsset.id()));
mountingRequest.assetId = mountingPointAsset.assetId;
mountingRequest.structureElementId = oldStructureElementIdToNewStructureElementId.value(mountingPointAsset.id);
m_ftc->mountingPointAssetModifyRequest(mountingRequest, this);
}
@@ -515,19 +515,19 @@ void IsmImportBuildings::restoreData(const MainStructureElement &oldMainStructur
MountingPointPlanModifyRequest createRequest;
for (auto it = mountingPointPlansBySchedule.cbegin(); it != mountingPointPlansBySchedule.cend(); ++it)
{
createRequest.mountingPointScheduleId() = it.key();
createRequest.mountingPointScheduleId = it.key();
// NO constRef! We change values...
for(MountingPointPlan mountingPointPlan : it.value())
{
if (!oldStructureElementIdToNewStructureElementId.contains(mountingPointPlan.structureElementId()))
if (!oldStructureElementIdToNewStructureElementId.contains(mountingPointPlan.structureElementId))
{
FATAL_LOG(m_logger) <<"There is no new StructureElement ID to old StructureElement ID " + QString::number(mountingPointPlan.structureElementId()).toStdString() + ". If somethind else looks suspicious, restore database data by backup.";
FATAL_LOG(m_logger) <<"There is no new StructureElement ID to old StructureElement ID " + QString::number(mountingPointPlan.structureElementId).toStdString() + ". If somethind else looks suspicious, restore database data by backup.";
continue;
// mountingPointPlan.structureElementId() = oldStructureElementIdToNewStructureElementId.value(mountingPointPlan.structureElementId());
// createRequest.mountingPointPlans().push_back(mountingPointPlan);
}
}
if (!createRequest.mountingPointPlans().empty())
if (!createRequest.mountingPointPlans.empty())
m_ftc->mountingPointPlanModifyRequest(createRequest, this);
}
}
@@ -763,13 +763,13 @@ static bool parsePositionString(const QStringRef &positionString,
if (parts.size() != 4)
return false;
bool bOk;
pos.lon(parts.at(0).toDouble(&bOk));
pos.lon = parts.at(0).toDouble(&bOk);
if (!bOk)
return false;
pos.lat(parts.at(1).toDouble(&bOk));
pos.lat = parts.at(1).toDouble(&bOk);
if (!bOk)
return false;
pos.z(parts.at(2).toDouble(&bOk));
pos.z = parts.at(2).toDouble(&bOk);
if (!bOk)
return false;
rotationDegree = parts.at(3).toDouble(&bOk);
@@ -942,7 +942,7 @@ int main(int argc, char **argv)
}
}
const QVector<QStringRef> parts = line.splitRef(QLatin1Char(';'));
const QStringList parts = line.split(QLatin1Char(';'));
if (parts.size() < 3 || parts.size() > 6)
{
WARNING_LOG(app.baseLogger()) << "Can not parse line: '" << line << "' - skipping";
@@ -979,7 +979,7 @@ int main(int argc, char **argv)
// bauabschnitt
// Normally '-1', but Steve and Iuliana use '0' as default.
data.bauabschnitt = InfrastructureManagement::BuildingGroup_def::type::UnknownGroup;
data.bauabschnitt = InfrastructureManagement::BuildingGroup::type::UnknownGroup;
if ((cfi.idxBauabschnitt>=0) && (parts.size() > cfi.idxBauabschnitt))
{
// postprocessing uses ba0 -> 0 , ba1 -> 1 ...
@@ -987,25 +987,25 @@ int main(int argc, char **argv)
const int ba = parts.at(cfi.idxBauabschnitt).toInt();
switch (ba) {
case 0:
data.bauabschnitt = InfrastructureManagement::BuildingGroup_def::type::Section0;
data.bauabschnitt = InfrastructureManagement::BuildingGroup::type::Section0;
break;
case 1:
data.bauabschnitt = InfrastructureManagement::BuildingGroup_def::type::Section1;
data.bauabschnitt = InfrastructureManagement::BuildingGroup::type::Section1;
break;
case 2:
data.bauabschnitt = InfrastructureManagement::BuildingGroup_def::type::Section2;
data.bauabschnitt = InfrastructureManagement::BuildingGroup::type::Section2;
break;
case 3:
data.bauabschnitt = InfrastructureManagement::BuildingGroup_def::type::Section3;
data.bauabschnitt = InfrastructureManagement::BuildingGroup::type::Section3;
break;
case 4:
data.bauabschnitt = InfrastructureManagement::BuildingGroup_def::type::Section4;
data.bauabschnitt = InfrastructureManagement::BuildingGroup::type::Section4;
break;
case 5:
data.bauabschnitt = InfrastructureManagement::BuildingGroup_def::type::Salchau;
data.bauabschnitt = InfrastructureManagement::BuildingGroup::type::Salchau;
break;
default:
data.bauabschnitt = InfrastructureManagement::BuildingGroup_def::type::UnknownGroup;
data.bauabschnitt = InfrastructureManagement::BuildingGroup::type::UnknownGroup;
break;
}
}