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$ # $Author$
# #
# Make ${Qt6_WebSockets} optional # Link the real WebSockets module whenever the websocket code path is
if(QT6_GUI_AVAILABLE AND TARGET Qt6::WebSockets) # compiled: QT6_WEBSOCKETS_AVAILABLE (root CMakeLists) and the manual
set(Qt6_WebSockets ${Qt6_WebSockets}) # 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() else()
set(Qt6_WebSockets "") set(Qt6_WebSockets "")
endif() endif()
@@ -141,7 +141,7 @@ void IsmImportBuildings::remove(int buildingId)
auto predicate = [](const InfrastructureManagement::InstrumentationAsset & a) 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; QMap<int, QVector<InfrastructureManagement::InstrumentationAsset>> assetsMapBuilding;
@@ -190,7 +190,7 @@ void IsmImportBuildings::doImport()
INFO_LOG(m_logger) << "Sending request"; INFO_LOG(m_logger) << "Sending request";
MainStructureElementModifyRequest req = buildingXml.parsedRequest(); MainStructureElementModifyRequest req = buildingXml.parsedRequest();
QByteArray propertiesBa = QByteArray::fromStdString(req.properties()); QByteArray propertiesBa = QByteArray::fromStdString(req.properties);
QJsonParseError parserError; QJsonParseError parserError;
const QJsonDocument doc(QJsonDocument::fromJson(propertiesBa, &parserError)); const QJsonDocument doc(QJsonDocument::fromJson(propertiesBa, &parserError));
if (parserError.error != QJsonParseError::NoError) if (parserError.error != QJsonParseError::NoError)
@@ -202,17 +202,17 @@ void IsmImportBuildings::doImport()
QJsonArray array; QJsonArray array;
array.push_back(m_currentData.exerciseId); array.push_back(m_currentData.exerciseId);
obj.insert(QLatin1String("available_in_exercise"), array); 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) if (m_currentData.buildingId > 0)
req.id(m_currentData.buildingId); req.id = m_currentData.buildingId;
req.externalWlsId(m_currentData.externalWlsId); req.externalWlsId = m_currentData.externalWlsId;
req.groupId(m_currentData.bauabschnitt); req.groupId = m_currentData.bauabschnitt;
req.structureElementTypeId(InfrastructureManagement::StructureElementType::Building); req.structureElementTypeId = InfrastructureManagement::StructureElementType::Building;
// check if building exists // check if building exists
MainStructureElement oldMainStructureElement = mainStructureElementByName(req.name()); MainStructureElement oldMainStructureElement = mainStructureElementByName(req.name);
std::string msg; std::string msg;
QMap<qint32, QVector<std::string>> oldNamePaths; QMap<qint32, QVector<std::string>> oldNamePaths;
QVector<MountingPointAsset> mountings; QVector<MountingPointAsset> mountings;
@@ -220,7 +220,7 @@ void IsmImportBuildings::doImport()
if (oldMainStructureElement != MainStructureElement()) if (oldMainStructureElement != MainStructureElement())
{ {
m_isInRestoringMode = true; 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; INFO_LOG(m_logger) << msg;
std::cerr << msg << std::endl; std::cerr << msg << std::endl;
@@ -228,11 +228,11 @@ void IsmImportBuildings::doImport()
INFO_LOG(m_logger) << msg; INFO_LOG(m_logger) << msg;
std::cerr << msg << std::endl; std::cerr << msg << std::endl;
QVector<qint32> mountingPointIds; 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; continue;
mountingPointIds.append(structureElement.id()); mountingPointIds.append(structureElement.id);
} }
msg = "Fetching MountingPointAssets."; msg = "Fetching MountingPointAssets.";
@@ -247,7 +247,7 @@ void IsmImportBuildings::doImport()
msg = "Removing MountingPointAssets."; msg = "Removing MountingPointAssets.";
INFO_LOG(m_logger) << msg; INFO_LOG(m_logger) << msg;
std::cerr << msg << std::endl; std::cerr << msg << std::endl;
unmountAssetsOfBuliding(oldMainStructureElement.id()); unmountAssetsOfBuliding(oldMainStructureElement.id);
// // remove mounting point assets // // remove mounting point assets
// for (const MountingPointAsset &mountingPointAsset : mountings) // for (const MountingPointAsset &mountingPointAsset : mountings)
// { // {
@@ -268,14 +268,14 @@ void IsmImportBuildings::doImport()
INFO_LOG(m_logger) << "Removing MountingPointPlans."; INFO_LOG(m_logger) << "Removing MountingPointPlans.";
auto copy = it.value(); auto copy = it.value();
for (auto &elem : copy) for (auto &elem : copy)
elem.mountingPointState() = MountingPointState_def::Idle; elem.mountingPointState = MountingPointState::Idle;
m_ftc->mountingPointPlanModifyRequest(MountingPointPlanModifyRequest(it.key(),copy), this); m_ftc->mountingPointPlanModifyRequest(MountingPointPlanModifyRequest(it.key(),copy), this);
} }
msg = "Fetching paths of MountingPoints by name ... for later reconstruction."; msg = "Fetching paths of MountingPoints by name ... for later reconstruction.";
INFO_LOG(m_logger) << msg; INFO_LOG(m_logger) << msg;
std::cerr << msg << std::endl; std::cerr << msg << std::endl;
for (const StructureElement &structureElement : oldMainStructureElement.elements()) for (const StructureElement &structureElement : oldMainStructureElement.elements)
oldNamePaths.insert(structureElement.id(), pathWithNames(structureElement, oldMainStructureElement)); oldNamePaths.insert(structureElement.id, pathWithNames(structureElement, oldMainStructureElement));
//msg = "Waiting for removing operations."; //msg = "Waiting for removing operations.";
connect(this, &IsmImportBuildings::removeDone, this, [this, oldMainStructureElement, oldNamePaths, mountings, mppsBySchedule, req]() 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; // std::cerr << "Unmount counter: " << unmountCounter << std::endl;
// QThread::sleep(1); // QThread::sleep(1);
// } // }
remove(oldMainStructureElement.id()); remove(oldMainStructureElement.id);
} }
else else
createNewMainStructureElement(req); createNewMainStructureElement(req);
@@ -321,7 +321,7 @@ MainStructureElement IsmImportBuildings::mainStructureElementByName(const std::s
for (auto it = mainStructureElements.constBegin(); it != mainStructureElements.constEnd(); ++it) for (auto it = mainStructureElements.constBegin(); it != mainStructureElements.constEnd(); ++it)
{ {
if (it.value().name() == name) if (it.value().name == name)
return it.value(); return it.value();
} }
@@ -337,10 +337,10 @@ QHash<int, std::vector<MountingPointPlan> > IsmImportBuildings::MountingPointPl
for (const MainSchedule &schedule : m_dtc->mainSchedules()) for (const MainSchedule &schedule : m_dtc->mainSchedules())
{ {
for (const MountingPointPlan &plan : schedule.elements()) for (const MountingPointPlan &plan : schedule.elements)
{ {
if (structureElementIds.contains(plan.structureElementId())) if (structureElementIds.contains(plan.structureElementId))
result[schedule.id()].push_back(plan); result[schedule.id].push_back(plan);
} }
} }
@@ -357,7 +357,7 @@ QVector<MountingPointAsset> IsmImportBuildings::mountingsOfStructureElements(con
for (auto it = mountings.constBegin(); it != mountings.constEnd(); ++it) 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()); 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> IsmImportBuildings::pathWithNames(const StructureElement &structureElement, const MainStructureElement &mainStructureElement) const
{ {
QVector<std::string> result; QVector<std::string> result;
result.reserve(structureElement.path().size()); result.reserve(structureElement.path.size());
for (int32_t structureElementId : structureElement.path()) for (int32_t structureElementId : structureElement.path)
result.push_back(structureElementNameById(structureElementId, mainStructureElement.elements())); result.push_back(structureElementNameById(structureElementId, mainStructureElement.elements));
return result; return result;
} }
@@ -380,8 +380,8 @@ std::string IsmImportBuildings::structureElementNameById(qint32 id, const std::v
{ {
for (const StructureElement &structureElement : structureElements) for (const StructureElement &structureElement : structureElements)
{ {
if (structureElement.id() == id) if (structureElement.id == id)
return structureElement.name(); return structureElement.name;
} }
return std::string(); 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 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; return structureElement;
} }
@@ -428,7 +428,7 @@ void IsmImportBuildings::restoreData(const MainStructureElement &oldMainStructur
if (oldMainStructureElement == MainStructureElement()) if (oldMainStructureElement == MainStructureElement())
return; return;
MainStructureElement newMainStructureElement = mainStructureElementByName(oldMainStructureElement.name()); MainStructureElement newMainStructureElement = mainStructureElementByName(oldMainStructureElement.name);
if (newMainStructureElement == MainStructureElement()) if (newMainStructureElement == MainStructureElement())
{ {
FATAL_LOG(m_logger) << "There was no new MainStructureElement created. Please consider restoring the database by backup."; 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; 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; continue;
newMountingPointIds.append(structureElement.id()); newMountingPointIds.append(structureElement.id);
} }
QMap<qint32, QVector<std::string> > newNamePaths; QMap<qint32, QVector<std::string> > newNamePaths;
INFO_LOG(m_logger) << "Restoring mounting point data."; INFO_LOG(m_logger) << "Restoring mounting point data.";
for (const StructureElement &structureElement : newMainStructureElement.elements()) for (const StructureElement &structureElement : newMainStructureElement.elements)
newNamePaths.insert(structureElement.id(), pathWithNames(structureElement, oldMainStructureElement)); newNamePaths.insert(structureElement.id, pathWithNames(structureElement, oldMainStructureElement));
if (oldNamePaths.size() != newNamePaths.size()) 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();; 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; StructureElementModifyRequest modifyRequest;
modifyRequest.mainStructureElementId(newMainStructureElement.id()); modifyRequest.mainStructureElementId = newMainStructureElement.id;
for (auto it = oldStructureElementIdToNewStructureElementId.constBegin(); it != oldStructureElementIdToNewStructureElementId.constEnd(); ++it) for (auto it = oldStructureElementIdToNewStructureElementId.constBegin(); it != oldStructureElementIdToNewStructureElementId.constEnd(); ++it)
{ {
StructureElement oldStructureElement = structureElementById(it.key(), oldMainStructureElement); StructureElement oldStructureElement = structureElementById(it.key(), oldMainStructureElement);
if (!oldStructureElement.barcode().size() && !oldStructureElement.properties().size()) if (!oldStructureElement.barcode.size() && !oldStructureElement.properties.size())
continue; continue;
StructureElement newStructureElement = structureElementById(it.value(), newMainStructureElement); StructureElement newStructureElement = structureElementById(it.value(), newMainStructureElement);
newStructureElement.barcode(oldStructureElement.barcode()); newStructureElement.barcode = oldStructureElement.barcode;
newStructureElement.properties(oldMainStructureElement.properties()); 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); m_ftc->structureElementModifyRequest(modifyRequest, this);
if (!mountings.isEmpty()) if (!mountings.isEmpty())
@@ -490,16 +490,16 @@ void IsmImportBuildings::restoreData(const MainStructureElement &oldMainStructur
// restore mountings // restore mountings
for (const MountingPointAsset &mountingPointAsset : 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; FATAL_LOG(m_logger) << msg;
std::cerr << msg << std::endl; std::cerr << msg << std::endl;
continue; continue;
} }
MountingPointAssetModifyRequest mountingRequest; MountingPointAssetModifyRequest mountingRequest;
mountingRequest.assetId(mountingPointAsset.assetId()); mountingRequest.assetId = mountingPointAsset.assetId;
mountingRequest.structureElementId(oldStructureElementIdToNewStructureElementId.value(mountingPointAsset.id())); mountingRequest.structureElementId = oldStructureElementIdToNewStructureElementId.value(mountingPointAsset.id);
m_ftc->mountingPointAssetModifyRequest(mountingRequest, this); m_ftc->mountingPointAssetModifyRequest(mountingRequest, this);
} }
@@ -515,19 +515,19 @@ void IsmImportBuildings::restoreData(const MainStructureElement &oldMainStructur
MountingPointPlanModifyRequest createRequest; MountingPointPlanModifyRequest createRequest;
for (auto it = mountingPointPlansBySchedule.cbegin(); it != mountingPointPlansBySchedule.cend(); ++it) for (auto it = mountingPointPlansBySchedule.cbegin(); it != mountingPointPlansBySchedule.cend(); ++it)
{ {
createRequest.mountingPointScheduleId() = it.key(); createRequest.mountingPointScheduleId = it.key();
// NO constRef! We change values... // NO constRef! We change values...
for(MountingPointPlan mountingPointPlan : it.value()) 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; continue;
// mountingPointPlan.structureElementId() = oldStructureElementIdToNewStructureElementId.value(mountingPointPlan.structureElementId()); // mountingPointPlan.structureElementId() = oldStructureElementIdToNewStructureElementId.value(mountingPointPlan.structureElementId());
// createRequest.mountingPointPlans().push_back(mountingPointPlan); // createRequest.mountingPointPlans().push_back(mountingPointPlan);
} }
} }
if (!createRequest.mountingPointPlans().empty()) if (!createRequest.mountingPointPlans.empty())
m_ftc->mountingPointPlanModifyRequest(createRequest, this); m_ftc->mountingPointPlanModifyRequest(createRequest, this);
} }
} }
@@ -763,13 +763,13 @@ static bool parsePositionString(const QStringRef &positionString,
if (parts.size() != 4) if (parts.size() != 4)
return false; return false;
bool bOk; bool bOk;
pos.lon(parts.at(0).toDouble(&bOk)); pos.lon = parts.at(0).toDouble(&bOk);
if (!bOk) if (!bOk)
return false; return false;
pos.lat(parts.at(1).toDouble(&bOk)); pos.lat = parts.at(1).toDouble(&bOk);
if (!bOk) if (!bOk)
return false; return false;
pos.z(parts.at(2).toDouble(&bOk)); pos.z = parts.at(2).toDouble(&bOk);
if (!bOk) if (!bOk)
return false; return false;
rotationDegree = parts.at(3).toDouble(&bOk); 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) if (parts.size() < 3 || parts.size() > 6)
{ {
WARNING_LOG(app.baseLogger()) << "Can not parse line: '" << line << "' - skipping"; WARNING_LOG(app.baseLogger()) << "Can not parse line: '" << line << "' - skipping";
@@ -979,7 +979,7 @@ int main(int argc, char **argv)
// bauabschnitt // bauabschnitt
// Normally '-1', but Steve and Iuliana use '0' as default. // 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)) if ((cfi.idxBauabschnitt>=0) && (parts.size() > cfi.idxBauabschnitt))
{ {
// postprocessing uses ba0 -> 0 , ba1 -> 1 ... // postprocessing uses ba0 -> 0 , ba1 -> 1 ...
@@ -987,25 +987,25 @@ int main(int argc, char **argv)
const int ba = parts.at(cfi.idxBauabschnitt).toInt(); const int ba = parts.at(cfi.idxBauabschnitt).toInt();
switch (ba) { switch (ba) {
case 0: case 0:
data.bauabschnitt = InfrastructureManagement::BuildingGroup_def::type::Section0; data.bauabschnitt = InfrastructureManagement::BuildingGroup::type::Section0;
break; break;
case 1: case 1:
data.bauabschnitt = InfrastructureManagement::BuildingGroup_def::type::Section1; data.bauabschnitt = InfrastructureManagement::BuildingGroup::type::Section1;
break; break;
case 2: case 2:
data.bauabschnitt = InfrastructureManagement::BuildingGroup_def::type::Section2; data.bauabschnitt = InfrastructureManagement::BuildingGroup::type::Section2;
break; break;
case 3: case 3:
data.bauabschnitt = InfrastructureManagement::BuildingGroup_def::type::Section3; data.bauabschnitt = InfrastructureManagement::BuildingGroup::type::Section3;
break; break;
case 4: case 4:
data.bauabschnitt = InfrastructureManagement::BuildingGroup_def::type::Section4; data.bauabschnitt = InfrastructureManagement::BuildingGroup::type::Section4;
break; break;
case 5: case 5:
data.bauabschnitt = InfrastructureManagement::BuildingGroup_def::type::Salchau; data.bauabschnitt = InfrastructureManagement::BuildingGroup::type::Salchau;
break; break;
default: default:
data.bauabschnitt = InfrastructureManagement::BuildingGroup_def::type::UnknownGroup; data.bauabschnitt = InfrastructureManagement::BuildingGroup::type::UnknownGroup;
break; break;
} }
} }
@@ -188,9 +188,9 @@ static void addElementToRequest(MainStructureElementModifyRequest &request,
const StructureElement &se, const StructureElement &se,
int parentIdx) int parentIdx)
{ {
const size_t size = request.elements().size(); const size_t size = request.elements.size();
request.elements().resize(size + 1, se); request.elements.resize(size + 1, se);
request.childParentRelations().resize(size + 1, parentIdx); request.childParentRelations.resize(size + 1, parentIdx);
} }
// ************* MAIN STRUCTURE ELEMENT ********************************************** // ************* MAIN STRUCTURE ELEMENT **********************************************
@@ -202,199 +202,199 @@ void IsmTests::tryCreateMainStructureElement()
MainStructureElementModifyRequest data; MainStructureElementModifyRequest data;
// Building 56 // Building 56
data.name("Test Building"); data.name = "Test Building";
QJsonObject jsonObj; QJsonObject jsonObj;
jsonObj[QStringLiteral("street")] = QStringLiteral("Brueggeweg"); jsonObj[QStringLiteral("street")] = QStringLiteral("Brueggeweg");
jsonObj[QStringLiteral("number")] = QStringLiteral("56"); jsonObj[QStringLiteral("number")] = QStringLiteral("56");
// '{"street":"Brueggeweg", "number":"56"}' // '{"street":"Brueggeweg", "number":"56"}'
QJsonDocument doc(jsonObj); QJsonDocument doc(jsonObj);
data.description(doc.toJson().toStdString()); data.description = doc.toJson().toStdString();
data.angle(30.5); data.angle = 30.5;
data.modelId(1001); data.modelId = 1001;
data.externalWlsId(1001); data.externalWlsId = 1001;
data.geoPosition().lon(0.1552736550); data.geoPosition.lon = 0.1552736550;
data.geoPosition().lat(0.9259746511); data.geoPosition.lat = 0.9259746511;
data.geoPosition().z(0.00); data.geoPosition.z = 0.00;
data.properties("{}"); data.properties = "{}";
data.structureElementTypeId(InfrastructureManagement::StructureElementType::Building); data.structureElementTypeId = InfrastructureManagement::StructureElementType::Building;
StructureElement seData; StructureElement seData;
// element 1 & 2 -> see ParseBuildingXml::parseXmlInternal() // element 1 & 2 -> see ParseBuildingXml::parseXmlInternal()
// building, idx = 0 // building, idx = 0
seData.name("Test Building"); seData.name = "Test Building";
seData.displayName("Building 56"); seData.displayName = "Building 56";
seData.structureElementTypeId(InfrastructureManagement::StructureElementType::Building); seData.structureElementTypeId = InfrastructureManagement::StructureElementType::Building;
seData.relPosition().offsetX(0); seData.relPosition.offsetX = 0;
seData.relPosition().offsetY(0); seData.relPosition.offsetY = 0;
seData.relPosition().offsetZ(0); seData.relPosition.offsetZ = 0;
seData.mountingPointTypeId(InfrastructureManagement::MountingPointType::Unknown); seData.mountingPointTypeId = InfrastructureManagement::MountingPointType::Unknown;
seData.properties("{\"description\":\"Info Test Building\"}"); seData.properties = "{\"description\":\"Info Test Building\"}";
addElementToRequest(data, seData, -1); // root element has no parent addElementToRequest(data, seData, -1); // root element has no parent
// building mounting point, idx = 1 // building mounting point, idx = 1
seData.name("Test Building - Mounting Point"); seData.name = "Test Building - Mounting Point";
seData.displayName("Building 56 - MP"); seData.displayName = "Building 56 - MP";
seData.structureElementTypeId(InfrastructureManagement::StructureElementType::MountingPoint); seData.structureElementTypeId = InfrastructureManagement::StructureElementType::MountingPoint;
seData.barcode("4711"); seData.barcode = "4711";
seData.relPosition().offsetX(0); seData.relPosition.offsetX = 0;
seData.relPosition().offsetY(0); seData.relPosition.offsetY = 0;
seData.relPosition().offsetZ(0); seData.relPosition.offsetZ = 0;
seData.mountingPointTypeId(InfrastructureManagement::MountingPointType::BuildingControlUnit); seData.mountingPointTypeId = InfrastructureManagement::MountingPointType::BuildingControlUnit;
seData.properties("{\"description\":\"Info Test Mounting Point\"}"); seData.properties = "{\"description\":\"Info Test Mounting Point\"}";
addElementToRequest(data, seData, 0); addElementToRequest(data, seData, 0);
// Floor 1, idx = 1 // Floor 1, idx = 1
seData.name("Floor 01"); seData.name = "Floor 01";
seData.displayName("Floor 1"); seData.displayName = "Floor 1";
seData.structureElementTypeId(InfrastructureManagement::StructureElementType::Floor); // type floor seData.structureElementTypeId = InfrastructureManagement::StructureElementType::Floor; // type floor
seData.barcode("123xxxx"); seData.barcode = "123xxxx";
seData.relPosition().offsetX(70000); seData.relPosition.offsetX = 70000;
seData.relPosition().offsetY(90000); seData.relPosition.offsetY = 90000;
seData.relPosition().offsetZ(10); seData.relPosition.offsetZ = 10;
seData.mountingPointTypeId(InfrastructureManagement::MountingPointType::Unknown); seData.mountingPointTypeId = InfrastructureManagement::MountingPointType::Unknown;
seData.orientation(Core::Orientation(0, 0, 0)); seData.orientation = Core::Orientation(0, 0, 0);
seData.properties("{\"description\":\"Info-Building-56-Floor-01\"}"); seData.properties = "{\"description\":\"Info-Building-56-Floor-01\"}";
addElementToRequest(data, seData, 0); addElementToRequest(data, seData, 0);
// Floor 2, idx = 2 // Floor 2, idx = 2
seData.name("Floor 02"); seData.name = "Floor 02";
seData.displayName("Floor 2"); seData.displayName = "Floor 2";
seData.structureElementTypeId(InfrastructureManagement::StructureElementType::Floor); // type floor seData.structureElementTypeId = InfrastructureManagement::StructureElementType::Floor; // type floor
seData.barcode("123xxxx"); seData.barcode = "123xxxx";
seData.relPosition().offsetX(70000); seData.relPosition.offsetX = 70000;
seData.relPosition().offsetY(90000); seData.relPosition.offsetY = 90000;
seData.relPosition().offsetZ(10); seData.relPosition.offsetZ = 10;
seData.mountingPointTypeId(InfrastructureManagement::MountingPointType::Unknown); seData.mountingPointTypeId = InfrastructureManagement::MountingPointType::Unknown;
seData.orientation(Core::Orientation(0, 0, 0)); seData.orientation = Core::Orientation(0, 0, 0);
seData.properties("{\"description\":\"Info-Building-56-Floor-02\"}"); seData.properties = "{\"description\":\"Info-Building-56-Floor-02\"}";
addElementToRequest(data, seData, 0); addElementToRequest(data, seData, 0);
// Room 01-01, idx = 3 // Room 01-01, idx = 3
seData.name("Room 01"); seData.name = "Room 01";
seData.displayName("Room 01"); seData.displayName = "Room 01";
seData.structureElementTypeId(InfrastructureManagement::StructureElementType::Room); // type room seData.structureElementTypeId = InfrastructureManagement::StructureElementType::Room; // type room
seData.barcode("123xxxx"); seData.barcode = "123xxxx";
seData.relPosition().offsetX(70000); seData.relPosition.offsetX = 70000;
seData.relPosition().offsetY(90000); seData.relPosition.offsetY = 90000;
seData.relPosition().offsetZ(10); seData.relPosition.offsetZ = 10;
seData.mountingPointTypeId(InfrastructureManagement::MountingPointType::Unknown); seData.mountingPointTypeId = InfrastructureManagement::MountingPointType::Unknown;
seData.orientation(Core::Orientation(0, 0, 0)); seData.orientation = Core::Orientation(0, 0, 0);
seData.properties("{\"description\":\"Info-Building-56-Floor-01-Room-01\"}"); seData.properties = "{\"description\":\"Info-Building-56-Floor-01-Room-01\"}";
addElementToRequest(data, seData, 1); addElementToRequest(data, seData, 1);
// Room 01-02, idx = 4 // Room 01-02, idx = 4
seData.name("Room 02"); seData.name = "Room 02";
seData.displayName("Room 02"); seData.displayName = "Room 02";
seData.structureElementTypeId(InfrastructureManagement::StructureElementType::Room); // type room seData.structureElementTypeId = InfrastructureManagement::StructureElementType::Room; // type room
seData.barcode("123xxxx"); seData.barcode = "123xxxx";
seData.relPosition().offsetX(70000); seData.relPosition.offsetX = 70000;
seData.relPosition().offsetY(90000); seData.relPosition.offsetY = 90000;
seData.relPosition().offsetZ(10); seData.relPosition.offsetZ = 10;
seData.mountingPointTypeId(InfrastructureManagement::MountingPointType::Unknown); seData.mountingPointTypeId = InfrastructureManagement::MountingPointType::Unknown;
seData.orientation(Core::Orientation(0, 0, 0)); seData.orientation = Core::Orientation(0, 0, 0);
seData.properties("{\"description\":\"Info-Building-56-Floor-01-Room-02\"}"); seData.properties = "{\"description\":\"Info-Building-56-Floor-01-Room-02\"}";
addElementToRequest(data, seData, 1); addElementToRequest(data, seData, 1);
// Room 02-01, idx = 5 // Room 02-01, idx = 5
seData.name("Room 01"); seData.name = "Room 01";
seData.displayName("Room 01"); seData.displayName = "Room 01";
seData.structureElementTypeId(InfrastructureManagement::StructureElementType::Room); // type room seData.structureElementTypeId = InfrastructureManagement::StructureElementType::Room; // type room
seData.barcode("123xxxx"); seData.barcode = "123xxxx";
seData.relPosition().offsetX(70000); seData.relPosition.offsetX = 70000;
seData.relPosition().offsetY(90000); seData.relPosition.offsetY = 90000;
seData.relPosition().offsetZ(10); seData.relPosition.offsetZ = 10;
seData.mountingPointTypeId(InfrastructureManagement::MountingPointType::Unknown); seData.mountingPointTypeId = InfrastructureManagement::MountingPointType::Unknown;
seData.orientation(Core::Orientation(0, 0, 0)); seData.orientation = Core::Orientation(0, 0, 0);
seData.properties("{\"description\":\"Info-Building-56-Floor-02-Room-01\"}"); seData.properties = "{\"description\":\"Info-Building-56-Floor-02-Room-01\"}";
addElementToRequest(data, seData, 2); addElementToRequest(data, seData, 2);
// Room 02-02, idx = 6 // Room 02-02, idx = 6
seData.name("Room 02"); seData.name = "Room 02";
seData.displayName("Room 02"); seData.displayName = "Room 02";
seData.structureElementTypeId(InfrastructureManagement::StructureElementType::Room); // type room seData.structureElementTypeId = InfrastructureManagement::StructureElementType::Room; // type room
seData.barcode("123xxxx"); seData.barcode = "123xxxx";
seData.relPosition().offsetX(70000); seData.relPosition.offsetX = 70000;
seData.relPosition().offsetY(90000); seData.relPosition.offsetY = 90000;
seData.relPosition().offsetZ(10); seData.relPosition.offsetZ = 10;
seData.mountingPointTypeId(InfrastructureManagement::MountingPointType::Unknown); seData.mountingPointTypeId = InfrastructureManagement::MountingPointType::Unknown;
seData.orientation(Core::Orientation(0, 0, 0)); seData.orientation = Core::Orientation(0, 0, 0);
seData.properties("{\"description\":\"Info-Building-56-Floor-02-Room-02\"}"); seData.properties = "{\"description\":\"Info-Building-56-Floor-02-Room-02\"}";
addElementToRequest(data, seData, 2); addElementToRequest(data, seData, 2);
// Mounting Point 01-01-01 // Mounting Point 01-01-01
seData.name("Mounting Point 56-01-01-01"); seData.name = "Mounting Point 56-01-01-01";
seData.displayName("MP 1"); seData.displayName = "MP 1";
seData.structureElementTypeId(InfrastructureManagement::StructureElementType::MountingPoint); // type mounting point seData.structureElementTypeId = InfrastructureManagement::StructureElementType::MountingPoint; // type mounting point
seData.barcode("123xxxx"); seData.barcode = "123xxxx";
seData.relPosition().offsetX(70000); seData.relPosition.offsetX = 70000;
seData.relPosition().offsetY(90000); seData.relPosition.offsetY = 90000;
seData.relPosition().offsetZ(10); seData.relPosition.offsetZ = 10;
seData.mountingPointTypeId(InfrastructureManagement::MountingPointType::IndoorCamera); seData.mountingPointTypeId = InfrastructureManagement::MountingPointType::IndoorCamera;
seData.orientation(Core::Orientation(0, 0, 0)); seData.orientation = Core::Orientation(0, 0, 0);
seData.properties("{\"description\":\"Info-Building-56-Floor-01-Room-01-MP-01\"}"); seData.properties = "{\"description\":\"Info-Building-56-Floor-01-Room-01-MP-01\"}";
addElementToRequest(data, seData, 3); addElementToRequest(data, seData, 3);
// Mounting Point 01-01-02 // Mounting Point 01-01-02
seData.name("Mounting Point 56-01-01-02"); seData.name = "Mounting Point 56-01-01-02";
seData.displayName("MP 2"); seData.displayName = "MP 2";
seData.structureElementTypeId(InfrastructureManagement::StructureElementType::MountingPoint); // type mounting point seData.structureElementTypeId = InfrastructureManagement::StructureElementType::MountingPoint; // type mounting point
seData.barcode("123xxxx"); seData.barcode = "123xxxx";
seData.relPosition().offsetX(70000); seData.relPosition.offsetX = 70000;
seData.relPosition().offsetY(90000); seData.relPosition.offsetY = 90000;
seData.relPosition().offsetZ(10); seData.relPosition.offsetZ = 10;
seData.mountingPointTypeId(InfrastructureManagement::MountingPointType::IndoorCamera); seData.mountingPointTypeId = InfrastructureManagement::MountingPointType::IndoorCamera;
seData.orientation(Core::Orientation(0, 0, 0)); seData.orientation = Core::Orientation(0, 0, 0);
seData.properties("{\"description\":\"Info-Building-56-Floor-01-Room-01-MP-02\"}"); seData.properties = "{\"description\":\"Info-Building-56-Floor-01-Room-01-MP-02\"}";
addElementToRequest(data, seData, 3); addElementToRequest(data, seData, 3);
// Mounting Point 01-02-01 // Mounting Point 01-02-01
seData.name("Mounting Point 56-01-02-01"); seData.name = "Mounting Point 56-01-02-01";
seData.displayName("MP 3"); seData.displayName = "MP 3";
seData.structureElementTypeId(InfrastructureManagement::StructureElementType::MountingPoint); // type mounting point seData.structureElementTypeId = InfrastructureManagement::StructureElementType::MountingPoint; // type mounting point
seData.barcode("123xxxx"); seData.barcode = "123xxxx";
seData.relPosition().offsetX(70000); seData.relPosition.offsetX = 70000;
seData.relPosition().offsetY(90000); seData.relPosition.offsetY = 90000;
seData.relPosition().offsetZ(10); seData.relPosition.offsetZ = 10;
seData.mountingPointTypeId(InfrastructureManagement::MountingPointType::IndoorCamera); seData.mountingPointTypeId = InfrastructureManagement::MountingPointType::IndoorCamera;
seData.orientation(Core::Orientation(0, 0, 0)); seData.orientation = Core::Orientation(0, 0, 0);
seData.properties("{\"description\":\"Info-Building-56-Floor-01-Room-02-MP-01\"}"); seData.properties = "{\"description\":\"Info-Building-56-Floor-01-Room-02-MP-01\"}";
addElementToRequest(data, seData, 4); addElementToRequest(data, seData, 4);
// Mounting Point 01-02-02 // Mounting Point 01-02-02
seData.name("Mounting Point 56-01-02-02"); seData.name = "Mounting Point 56-01-02-02";
seData.displayName("MP 4"); seData.displayName = "MP 4";
seData.structureElementTypeId(InfrastructureManagement::StructureElementType::MountingPoint); // type mounting point seData.structureElementTypeId = InfrastructureManagement::StructureElementType::MountingPoint; // type mounting point
seData.barcode("123xxxx"); seData.barcode = "123xxxx";
seData.relPosition().offsetX(70000); seData.relPosition.offsetX = 70000;
seData.relPosition().offsetY(90000); seData.relPosition.offsetY = 90000;
seData.relPosition().offsetZ(10); seData.relPosition.offsetZ = 10;
seData.mountingPointTypeId(InfrastructureManagement::MountingPointType::IndoorCamera); seData.mountingPointTypeId = InfrastructureManagement::MountingPointType::IndoorCamera;
seData.orientation(Core::Orientation(0, 0, 0)); seData.orientation = Core::Orientation(0, 0, 0);
seData.properties("{\"description\":\"Info-Building-56-Floor-01-Room-02-MP-02\"}"); seData.properties = "{\"description\":\"Info-Building-56-Floor-01-Room-02-MP-02\"}";
addElementToRequest(data, seData, 4); addElementToRequest(data, seData, 4);
// mounting point building central unit // mounting point building central unit
seData.name("Test MP Building"); seData.name = "Test MP Building";
seData.displayName("MP 5"); seData.displayName = "MP 5";
seData.structureElementTypeId(InfrastructureManagement::StructureElementType::MountingPoint); seData.structureElementTypeId = InfrastructureManagement::StructureElementType::MountingPoint;
seData.barcode("4711"); seData.barcode = "4711";
seData.relPosition().offsetX(0); seData.relPosition.offsetX = 0;
seData.relPosition().offsetY(0); seData.relPosition.offsetY = 0;
seData.relPosition().offsetZ(0); seData.relPosition.offsetZ = 0;
seData.mountingPointTypeId(InfrastructureManagement::MountingPointType::BuildingControlUnit); seData.mountingPointTypeId = InfrastructureManagement::MountingPointType::BuildingControlUnit;
seData.properties("{\"description\":\"Info MP Test Building\"}"); seData.properties = "{\"description\":\"Info MP Test Building\"}";
addElementToRequest(data, seData, 0); addElementToRequest(data, seData, 0);
@@ -404,38 +404,38 @@ void IsmTests::tryCreateMainStructureElement()
elements.resize(4); elements.resize(4);
// index 1 // index 1
feData.id(1); feData.id = 1;
feData.relPosition().offsetX(0); feData.relPosition.offsetX = 0;
feData.relPosition().offsetY(0); feData.relPosition.offsetY = 0;
feData.relPosition().offsetZ(0); feData.relPosition.offsetZ = 0;
elements[0] = feData; elements[0] = feData;
// index 2 // index 2
feData.id(2); feData.id = 2;
feData.relPosition().offsetX(9.11999988555908); feData.relPosition.offsetX = 9.11999988555908;
feData.relPosition().offsetY(0); feData.relPosition.offsetY = 0;
feData.relPosition().offsetZ(0); feData.relPosition.offsetZ = 0;
elements[1] = feData; elements[1] = feData;
// index 3 // index 3
feData.id(3); feData.id = 3;
feData.relPosition().offsetX(9.11999988555908); feData.relPosition.offsetX = 9.11999988555908;
feData.relPosition().offsetY(9.02999973297119); feData.relPosition.offsetY = 9.02999973297119;
feData.relPosition().offsetZ(0); feData.relPosition.offsetZ = 0;
elements[2] = feData; elements[2] = feData;
// index 4 // index 4
feData.id(4); feData.id = 4;
feData.relPosition().offsetX(0); feData.relPosition.offsetX = 0;
feData.relPosition().offsetY(9.02999973297119); feData.relPosition.offsetY = 9.02999973297119;
feData.relPosition().offsetZ(0); feData.relPosition.offsetZ = 0;
elements[3] = feData; elements[3] = feData;
data.footprint(elements); data.footprint = elements;
QByteArray vmTest; QByteArray vmTest;
vmTest += "bla-bla-bla"; vmTest += "bla-bla-bla";
@@ -458,28 +458,28 @@ void IsmTests::tryModifyMainStructureElement()
InfrastructureManagement::MainStructureElement mse = m_dtc->mainStructureElement(m_mainStructureElementId); InfrastructureManagement::MainStructureElement mse = m_dtc->mainStructureElement(m_mainStructureElementId);
InfrastructureManagement::MainStructureElementModifyRequest data; InfrastructureManagement::MainStructureElementModifyRequest data;
if (mse.id() == 0) if (mse.id == 0)
{ {
ERROR_LOG(m_logger) << "Error requesting modify data"; ERROR_LOG(m_logger) << "Error requesting modify data";
failExit(); failExit();
} }
DEBUG_LOG(m_logger) << "Modify MainStructureElement with id = " << mse.id(); DEBUG_LOG(m_logger) << "Modify MainStructureElement with id = " << mse.id;
// creating ModifyRequest // creating ModifyRequest
data.id(mse.id()); data.id = mse.id;
data.name(mse.name()); data.name = mse.name;
data.description(mse.description()); data.description = mse.description;
data.angle(mse.angle()); data.angle = mse.angle;
data.modelId(mse.modelId()); data.modelId = mse.modelId;
data.externalWlsId(mse.externalWlsId()); data.externalWlsId = mse.externalWlsId;
data.geoPosition(mse.geoPosition()); data.geoPosition = mse.geoPosition;
data.elements(mse.elements()); data.elements = mse.elements;
data.properties(mse.properties()); data.properties = mse.properties;
data.structureElementTypeId(mse.structureElementTypeId()); data.structureElementTypeId = mse.structureElementTypeId;
// changing MSE name // changing MSE name
data.name("TestBuilding-Updated"); data.name = "TestBuilding-Updated";
m_replyFinished = false; m_replyFinished = false;
if (!m_ftc->mainStructureElementModifyRequest(data, this)) if (!m_ftc->mainStructureElementModifyRequest(data, this))
@@ -494,16 +494,16 @@ void IsmTests::tryModifyMainStructureElement()
InfrastructureManagement::StructureElement se; InfrastructureManagement::StructureElement se;
InfrastructureManagement::StructureElementModifyRequest seData; InfrastructureManagement::StructureElementModifyRequest seData;
seData.mainStructureElementId(mse.id()); seData.mainStructureElementId = mse.id;
seData.elements().reserve(mse.elements().size()); seData.elements.reserve(mse.elements.size());
for (size_t i = 0; i < mse.elements().size(); ++i) for (size_t i = 0; i < mse.elements.size(); ++i)
{ {
se = mse.elements().at(i); se = mse.elements.at(i);
DEBUG_LOG(m_logger) << "Updating barcode for element (" << i << ") with old barcode = " << se.barcode(); DEBUG_LOG(m_logger) << "Updating barcode for element (" << i << ") with old barcode = " << se.barcode;
se.barcode("BARCODE"); se.barcode = "BARCODE";
seData.elements().push_back(se); seData.elements.push_back(se);
} }
if (!m_ftc->structureElementModifyRequest(seData, this)) if (!m_ftc->structureElementModifyRequest(seData, this))
@@ -523,7 +523,7 @@ void IsmTests::tryRemoveMainStructureElement()
m_dtc->waitForHistoricalDataMainStructureElement(); m_dtc->waitForHistoricalDataMainStructureElement();
InfrastructureManagement::MainStructureElement mse = m_dtc->mainStructureElement(m_mainStructureElementId); InfrastructureManagement::MainStructureElement mse = m_dtc->mainStructureElement(m_mainStructureElementId);
if (mse.id() == 0) if (mse.id == 0)
{ {
ERROR_LOG(m_logger) << "Cannot find main structure element with id = " << m_mainStructureElementId; ERROR_LOG(m_logger) << "Cannot find main structure element with id = " << m_mainStructureElementId;
failExit(); failExit();
@@ -545,30 +545,30 @@ void IsmTests::tryCreateBridge()
MainStructureElementModifyRequest data; MainStructureElementModifyRequest data;
data.name("Test Bridge"); data.name = "Test Bridge";
QJsonObject jsonObj; QJsonObject jsonObj;
jsonObj[QStringLiteral("bridgeStatus")] = 0; jsonObj[QStringLiteral("bridgeStatus")] = 0;
// '{"bridgeStatus":0}' // '{"bridgeStatus":0}'
QJsonDocument doc(jsonObj); QJsonDocument doc(jsonObj);
data.properties(doc.toJson().toStdString()); data.properties = doc.toJson().toStdString();
data.angle(30.5); data.angle = 30.5;
data.modelId(0); data.modelId = 0;
data.externalWlsId(0); data.externalWlsId = 0;
data.geoPosition().lon(0.1552736550); data.geoPosition.lon = 0.1552736550;
data.geoPosition().lat(0.9259746511); data.geoPosition.lat = 0.9259746511;
data.geoPosition().z(0.00); data.geoPosition.z = 0.00;
data.description("{}"); data.description = "{}";
data.structureElementTypeId(InfrastructureManagement::StructureElementType::Bridge); data.structureElementTypeId = InfrastructureManagement::StructureElementType::Bridge;
StructureElement seData; StructureElement seData;
seData.name("Test Bridge"); seData.name = "Test Bridge";
seData.displayName("Bridge 001"); seData.displayName = "Bridge 001";
seData.structureElementTypeId(InfrastructureManagement::StructureElementType::Bridge); seData.structureElementTypeId = InfrastructureManagement::StructureElementType::Bridge;
seData.relPosition().offsetX(0); seData.relPosition.offsetX = 0;
seData.relPosition().offsetY(0); seData.relPosition.offsetY = 0;
seData.relPosition().offsetZ(0); seData.relPosition.offsetZ = 0;
seData.mountingPointTypeId(InfrastructureManagement::MountingPointType::Unknown); seData.mountingPointTypeId = InfrastructureManagement::MountingPointType::Unknown;
seData.properties("{\"description\":\"Info Test Bridge\"}"); seData.properties = "{\"description\":\"Info Test Bridge\"}";
addElementToRequest(data, seData, -1); // root element has no parent addElementToRequest(data, seData, -1); // root element has no parent
@@ -590,20 +590,20 @@ void IsmTests::tryChangeBridgeStatus()
InfrastructureManagement::MainStructureElement mse = m_dtc->mainStructureElement(m_mainStructureElementId); InfrastructureManagement::MainStructureElement mse = m_dtc->mainStructureElement(m_mainStructureElementId);
InfrastructureManagement::MainStructureElementModifyBridgeStatusRequest data; InfrastructureManagement::MainStructureElementModifyBridgeStatusRequest data;
if (mse.id() == 0) if (mse.id == 0)
{ {
ERROR_LOG(m_logger) << "Error requesting modify data"; ERROR_LOG(m_logger) << "Error requesting modify data";
failExit(); failExit();
} }
DEBUG_LOG(m_logger) << "Modify MainStructureElement with id = " << mse.id(); DEBUG_LOG(m_logger) << "Modify MainStructureElement with id = " << mse.id;
// creating ModifyRequest // creating ModifyRequest
data.id(mse.id()); data.id = mse.id;
if (m_dtc->getBridgeStatus(m_mainStructureElementId) == BridgeStatus::Intact) if (m_dtc->getBridgeStatus(m_mainStructureElementId) == BridgeStatus::Intact)
data.status(BridgeStatus::Broken); data.status = BridgeStatus::Broken;
else else
data.status(BridgeStatus::Intact); data.status = BridgeStatus::Intact;
m_replyFinished = false; m_replyFinished = false;
if (!m_ftc->mainStructureElementModifyBridgeStatusRequest(data, this)) if (!m_ftc->mainStructureElementModifyBridgeStatusRequest(data, this))
@@ -626,10 +626,10 @@ void IsmTests::tryCreateAsset()
InstrumentationAssetModifyRequest data; InstrumentationAssetModifyRequest data;
data.name("Camera-01"); data.name = "Camera-01";
data.mountingPointTypeId(InfrastructureManagement::MountingPointType::IndoorCamera); data.mountingPointTypeId = InfrastructureManagement::MountingPointType::IndoorCamera;
data.barcode("1"); data.barcode = "1";
data.properties("{\"description\":\"Info-Camera-01\"}"); data.properties = "{\"description\":\"Info-Camera-01\"}";
if (!m_ftc->instrumentationAssetModifyRequest(data, this)) if (!m_ftc->instrumentationAssetModifyRequest(data, this))
{ {
@@ -639,10 +639,10 @@ void IsmTests::tryCreateAsset()
QTest::qWait(1000); QTest::qWait(1000);
data.name("Camera-02"); data.name = "Camera-02";
data.barcode("2"); data.barcode = "2";
data.mountingPointTypeId(InfrastructureManagement::MountingPointType::IndoorCamera); data.mountingPointTypeId = InfrastructureManagement::MountingPointType::IndoorCamera;
data.properties("{\"description\":\"Info-Camera-02\"}"); data.properties = "{\"description\":\"Info-Camera-02\"}";
if (!m_ftc->instrumentationAssetModifyRequest(data, this)) if (!m_ftc->instrumentationAssetModifyRequest(data, this))
{ {
@@ -652,10 +652,10 @@ void IsmTests::tryCreateAsset()
QTest::qWait(1000); QTest::qWait(1000);
data.name("Camera-03"); data.name = "Camera-03";
data.barcode("3"); data.barcode = "3";
data.mountingPointTypeId(InfrastructureManagement::MountingPointType::MeteoDataUnit); data.mountingPointTypeId = InfrastructureManagement::MountingPointType::MeteoDataUnit;
data.properties("{\"description\":\"Info-Camera-03\"}"); data.properties = "{\"description\":\"Info-Camera-03\"}";
if (!m_ftc->instrumentationAssetModifyRequest(data, this)) if (!m_ftc->instrumentationAssetModifyRequest(data, this))
{ {
@@ -665,10 +665,10 @@ void IsmTests::tryCreateAsset()
QTest::qWait(1000); QTest::qWait(1000);
data.name("Camera-04"); data.name = "Camera-04";
data.barcode("4"); data.barcode = "4";
data.mountingPointTypeId(InfrastructureManagement::MountingPointType::MeteoDataUnit); data.mountingPointTypeId = InfrastructureManagement::MountingPointType::MeteoDataUnit;
data.properties("{\"description\":\"Info-Camera-03\"}"); data.properties = "{\"description\":\"Info-Camera-03\"}";
if (!m_ftc->instrumentationAssetModifyRequest(data, this)) if (!m_ftc->instrumentationAssetModifyRequest(data, this))
{ {
@@ -692,25 +692,25 @@ void IsmTests::tryModifyAsset()
// const InfrastructureManagement::InstrumentationAsset &ast1 = m_dtc->instrumentationAssets()[m_assetId]; // const InfrastructureManagement::InstrumentationAsset &ast1 = m_dtc->instrumentationAssets()[m_assetId];
InfrastructureManagement::InstrumentationAssetModifyRequest data; InfrastructureManagement::InstrumentationAssetModifyRequest data;
DEBUG_LOG(m_logger) << "ast.id() = " << ast.id(); DEBUG_LOG(m_logger) << "ast.id() = " << ast.id;
// DEBUG_LOG(m_logger) << "ast1.id() = " << ast1.id(); // DEBUG_LOG(m_logger) << "ast1.id() = " << ast1.id();
if (ast.id() == 0) if (ast.id == 0)
{ {
ERROR_LOG(m_logger) << "Cannot find Asset Id = " << m_assetId; ERROR_LOG(m_logger) << "Cannot find Asset Id = " << m_assetId;
failExit(); failExit();
} }
else else
{ {
data.id(ast.id()); data.id = ast.id;
data.name(ast.name()); data.name = ast.name;
data.barcode(ast.barcode()); data.barcode = ast.barcode;
data.mountingPointTypeId(ast.mountingPointTypeId()); data.mountingPointTypeId = ast.mountingPointTypeId;
data.instrumentationAssetStateId(ast.assetStateId()); data.instrumentationAssetStateId = ast.assetStateId;
data.properties(ast.properties()); data.properties = ast.properties;
// changing only name // changing only name
data.name("Asset-Updated"); data.name = "Asset-Updated";
if (!m_ftc->instrumentationAssetModifyRequest(InstrumentationAssetModifyRequest(data), this)) if (!m_ftc->instrumentationAssetModifyRequest(InstrumentationAssetModifyRequest(data), this))
{ {
@@ -730,7 +730,7 @@ void IsmTests::tryRemoveAsset()
m_dtc->waitForHistoricalDataInstrumentationAsset(); m_dtc->waitForHistoricalDataInstrumentationAsset();
const InfrastructureManagement::InstrumentationAsset &ast = m_dtc->instrumentationAsset(m_assetId); const InfrastructureManagement::InstrumentationAsset &ast = m_dtc->instrumentationAsset(m_assetId);
if (ast.id() == 0) if (ast.id == 0)
{ {
ERROR_LOG(m_logger) << "Cannot find Asset Id = " << m_assetId; ERROR_LOG(m_logger) << "Cannot find Asset Id = " << m_assetId;
failExit(); failExit();
@@ -756,18 +756,18 @@ void IsmTests::tryUnmountAsset()
// const InfrastructureManagement::InstrumentationAsset &ast1 = m_dtc->instrumentationAssets()[m_assetId]; // const InfrastructureManagement::InstrumentationAsset &ast1 = m_dtc->instrumentationAssets()[m_assetId];
InfrastructureManagement::InstrumentationAssetSetStateRequest data; InfrastructureManagement::InstrumentationAssetSetStateRequest data;
DEBUG_LOG(m_logger) << "ast.id() = " << ast.id(); DEBUG_LOG(m_logger) << "ast.id() = " << ast.id;
// DEBUG_LOG(m_logger) << "ast1.id() = " << ast1.id(); // DEBUG_LOG(m_logger) << "ast1.id() = " << ast1.id();
if (ast.id() == 0) if (ast.id == 0)
{ {
ERROR_LOG(m_logger) << "Cannot find Asset Id = " << m_assetId; ERROR_LOG(m_logger) << "Cannot find Asset Id = " << m_assetId;
failExit(); failExit();
} }
else else
{ {
data.id(ast.id()); data.id = ast.id;
data.instrumentationAssetStateId(InstrumentationAssetState::Unmounted); data.instrumentationAssetStateId = InstrumentationAssetState::Unmounted;
if (!m_ftc->instrumentationAssetSetStateRequest(InstrumentationAssetSetStateRequest(data), this)) if (!m_ftc->instrumentationAssetSetStateRequest(InstrumentationAssetSetStateRequest(data), this))
{ {
@@ -787,9 +787,9 @@ void IsmTests::tryCreateMountingPointAsset()
MountingPointAssetModifyRequest data; MountingPointAssetModifyRequest data;
data.assetId(m_assetId); data.assetId = m_assetId;
data.structureElementId(m_structureElementId); data.structureElementId = m_structureElementId;
data.lastUpdated(QDateTime::currentMSecsSinceEpoch()); data.lastUpdated = QDateTime::currentMSecsSinceEpoch();
if (!m_ftc->mountingPointAssetModifyRequest(data, this)) if (!m_ftc->mountingPointAssetModifyRequest(data, this))
{ {
@@ -831,14 +831,14 @@ void IsmTests::tryCreateMainSchedule()
MainScheduleModifyRequest data0, data1, data2; MainScheduleModifyRequest data0, data1, data2;
data1.id(0); // to be inserted data1.id = 0; // to be inserted
data1.name("Instrumentation Plan 1 (ex 42)"); data1.name = "Instrumentation Plan 1 (ex 42)";
data1.exerciseId(42); data1.exerciseId = 42;
data1.statusId(InfrastructureManagement::ScheduleStatus::Inactive); data1.statusId = InfrastructureManagement::ScheduleStatus::Inactive;
data1.timeCreated(10000000); data1.timeCreated = 10000000;
data1.timeStart(12000000); data1.timeStart = 12000000;
data1.timeEnd( 13000000); data1.timeEnd = 13000000;
data1.description("Info-Main-Schedule-01"); data1.description = "Info-Main-Schedule-01";
if (!m_ftc->mainScheduleModifyRequest(data1, this)) if (!m_ftc->mainScheduleModifyRequest(data1, this))
{ {
@@ -848,14 +848,14 @@ void IsmTests::tryCreateMainSchedule()
QTest::qWait(1000); QTest::qWait(1000);
data2.id(0); // to be inserted data2.id = 0; // to be inserted
data2.name("Instrumentation Plan 2 (ex 42)"); data2.name = "Instrumentation Plan 2 (ex 42)";
data2.exerciseId(42); data2.exerciseId = 42;
data2.statusId(InfrastructureManagement::ScheduleStatus::Inactive); data2.statusId = InfrastructureManagement::ScheduleStatus::Inactive;
data2.timeCreated(14000000); data2.timeCreated = 14000000;
data2.timeStart(16000000); data2.timeStart = 16000000;
data2.timeEnd( 17000000); data2.timeEnd = 17000000;
data2.description("Info-Main-Schedule-02"); data2.description = "Info-Main-Schedule-02";
if (!m_ftc->mainScheduleModifyRequest(data2, this)) if (!m_ftc->mainScheduleModifyRequest(data2, this))
{ {
@@ -865,13 +865,13 @@ void IsmTests::tryCreateMainSchedule()
QTest::qWait(1000); QTest::qWait(1000);
data0.id(0); // to be inserted data0.id = 0; // to be inserted
data0.name("No exercise"); data0.name = "No exercise";
data0.statusId(InfrastructureManagement::ScheduleStatus::Active); data0.statusId = InfrastructureManagement::ScheduleStatus::Active;
data0.timeCreated(14000000); data0.timeCreated = 14000000;
data0.timeStart(15000000); data0.timeStart = 15000000;
data0.timeEnd( 19000000); data0.timeEnd = 19000000;
data0.description("Info-Main-Schedule-03"); data0.description = "Info-Main-Schedule-03";
if (!m_ftc->mainScheduleModifyRequest(data0, this)) if (!m_ftc->mainScheduleModifyRequest(data0, this))
{ {
@@ -894,22 +894,22 @@ void IsmTests::tryModifyMainSchedule()
DEBUG_LOG(m_logger) << "m_assetId = " << m_assetId; DEBUG_LOG(m_logger) << "m_assetId = " << m_assetId;
DEBUG_LOG(m_logger) << "ast.id() = " << ast.id(); DEBUG_LOG(m_logger) << "ast.id() = " << ast.id;
// creating ModifyRequest // creating ModifyRequest
if (ast.id() > 0) if (ast.id > 0)
{ {
data.id(ast.id()); data.id = ast.id;
data.name(ast.name()); data.name = ast.name;
data.statusId(ast.statusId()); data.statusId = ast.statusId;
data.exerciseId(ast.exerciseId()); data.exerciseId = ast.exerciseId;
data.timeCreated(ast.timeCreated()); data.timeCreated = ast.timeCreated;
data.timeStart(ast.timeStart()); data.timeStart = ast.timeStart;
data.timeEnd(ast.timeEnd()); data.timeEnd = ast.timeEnd;
data.description(ast.description()); data.description = ast.description;
// changing name // changing name
data.name("MPS-Updated"); data.name = "MPS-Updated";
if (!m_ftc->mainScheduleModifyRequest(MainScheduleModifyRequest(data), this)) if (!m_ftc->mainScheduleModifyRequest(MainScheduleModifyRequest(data), this))
{ {
@@ -937,35 +937,35 @@ void IsmTests::tryChangeStatusSchedule()
DEBUG_LOG(m_logger) << "m_assetId = " << m_assetId; DEBUG_LOG(m_logger) << "m_assetId = " << m_assetId;
DEBUG_LOG(m_logger) << "ast.id() = " << ast.id(); DEBUG_LOG(m_logger) << "ast.id() = " << ast.id;
// creating ModifyRequest // creating ModifyRequest
if (ast.id() > 0) if (ast.id > 0)
{ {
data.id(ast.id()); data.id = ast.id;
data.name(ast.name()); data.name = ast.name;
data.statusId(ast.statusId()); data.statusId = ast.statusId;
data.exerciseId(ast.exerciseId()); data.exerciseId = ast.exerciseId;
data.timeCreated(ast.timeCreated()); data.timeCreated = ast.timeCreated;
data.timeStart(ast.timeStart()); data.timeStart = ast.timeStart;
data.timeEnd(ast.timeEnd()); data.timeEnd = ast.timeEnd;
data.description(ast.description()); data.description = ast.description;
// changing name and status // changing name and status
switch (data.statusId().underlying()) switch (data.statusId)
{ {
case InfrastructureManagement::ScheduleStatus::Inactive: case InfrastructureManagement::ScheduleStatus::Inactive:
{ {
data.name("MPS-UpdatedStatus-Activated"); data.name = "MPS-UpdatedStatus-Activated";
data.statusId(InfrastructureManagement::ScheduleStatus::Active); data.statusId = InfrastructureManagement::ScheduleStatus::Active;
data.timeStart(QDateTime::currentMSecsSinceEpoch()); data.timeStart = QDateTime::currentMSecsSinceEpoch();
break; break;
} }
case InfrastructureManagement::ScheduleStatus::Active: case InfrastructureManagement::ScheduleStatus::Active:
{ {
data.name("MPS-UpdatedStatus-Inactivated"); data.name = "MPS-UpdatedStatus-Inactivated";
data.statusId(InfrastructureManagement::ScheduleStatus::Inactive); data.statusId = InfrastructureManagement::ScheduleStatus::Inactive;
data.timeEnd(QDateTime::currentMSecsSinceEpoch()); data.timeEnd = QDateTime::currentMSecsSinceEpoch();
break; break;
} }
default: default:
@@ -994,7 +994,7 @@ void IsmTests::tryRemoveMainSchedule()
m_dtc->waitForHistoricalDataMainSchedule(); m_dtc->waitForHistoricalDataMainSchedule();
InfrastructureManagement::MainSchedule ast = m_dtc->mainSchedule(m_assetId); InfrastructureManagement::MainSchedule ast = m_dtc->mainSchedule(m_assetId);
if (ast.id() == 0) if (ast.id == 0)
{ {
ERROR_LOG(m_logger) << "Cannot find main schedule id = " << m_assetId; ERROR_LOG(m_logger) << "Cannot find main schedule id = " << m_assetId;
failExit(); failExit();
@@ -1018,9 +1018,9 @@ void IsmTests::tryCopySchedule()
InfrastructureManagement::MainSchedule ms = m_dtc->mainSchedule(m_assetId); InfrastructureManagement::MainSchedule ms = m_dtc->mainSchedule(m_assetId);
DEBUG_LOG(m_logger) << "scheduleId = " << m_assetId; DEBUG_LOG(m_logger) << "scheduleId = " << m_assetId;
DEBUG_LOG(m_logger) << "ms.id() = " << ms.id(); DEBUG_LOG(m_logger) << "ms.id() = " << ms.id;
int newId = m_db->copySchedule(ms.id()); int newId = m_db->copySchedule(ms.id);
if (newId <= 0) if (newId <= 0)
{ {
@@ -1042,7 +1042,7 @@ void IsmTests::checkSchedule()
InfrastructureManagement::MainSchedule ms = m_dtc->mainSchedule(m_assetId); InfrastructureManagement::MainSchedule ms = m_dtc->mainSchedule(m_assetId);
DEBUG_LOG(m_logger) << "scheduleId = " << m_assetId; DEBUG_LOG(m_logger) << "scheduleId = " << m_assetId;
DEBUG_LOG(m_logger) << "ms.id() = " << ms.id(); DEBUG_LOG(m_logger) << "ms.id() = " << ms.id;
QList<MountingPointPlan> diff; QList<MountingPointPlan> diff;
bool ok = m_dtc->getScheduleDifferences(m_assetId, diff); bool ok = m_dtc->getScheduleDifferences(m_assetId, diff);
@@ -1053,7 +1053,7 @@ void IsmTests::checkSchedule()
{ {
ERROR_LOG(m_logger) << "Instrumentation plan not complete !!!"; ERROR_LOG(m_logger) << "Instrumentation plan not complete !!!";
for (const MountingPointPlan &mpp : qAsConst(diff)) for (const MountingPointPlan &mpp : qAsConst(diff))
ERROR_LOG(m_logger) << "Diff - # mpp.structureElementId() = " << mpp.structureElementId(); ERROR_LOG(m_logger) << "Diff - # mpp.structureElementId() = " << mpp.structureElementId;
} }
QTest::qWait(1000); QTest::qWait(1000);
@@ -1068,7 +1068,7 @@ void IsmTests::tryCreateMountingPointPlan()
MountingPointPlanModifyRequest data; MountingPointPlanModifyRequest data;
data.mountingPointScheduleId(m_assetId); data.mountingPointScheduleId = m_assetId;
// data.structureElementId(m_structureElementId); // data.structureElementId(m_structureElementId);
// data.mountingPointState(InfrastructureManagement::MountingPointState::Equipped); // data.mountingPointState(InfrastructureManagement::MountingPointState::Equipped);
@@ -1080,7 +1080,7 @@ void IsmTests::tryCreateMountingPointPlan()
QTest::qWait(1000); QTest::qWait(1000);
data.mountingPointScheduleId(m_assetId); data.mountingPointScheduleId = m_assetId;
// data.structureElementId(m_mainStructureElementId); // data.structureElementId(m_mainStructureElementId);
// data.mountingPointState(InfrastructureManagement::MountingPointState::Idle); // data.mountingPointState(InfrastructureManagement::MountingPointState::Idle);
@@ -47,7 +47,7 @@ int determineFloorNumber(ObjectStructureElement *floor)
Q_ASSERT(floor); Q_ASSERT(floor);
Q_ASSERT(floor->getStructureElementTypeId() == StructureElementType::Floor); Q_ASSERT(floor->getStructureElementTypeId() == StructureElementType::Floor);
QString name = QString::fromStdString(floor->getData().name()).toLower(); QString name = QString::fromStdString(floor->getData().name).toLower();
if (!name.startsWith(FLOOR_PATTERN)) if (!name.startsWith(FLOOR_PATTERN))
return 0; return 0;
@@ -102,36 +102,36 @@ DataManager::EinruestEssentials DataManager::getEssentials(const QString &uuid)
path.clear(); path.clear();
// bottom left // bottom left
UtmCoordinate bl(UtmCoordinate::fromGeographic({currentArea.bottomLeft().lon(), currentArea.bottomLeft().lat()})); UtmCoordinate bl(UtmCoordinate::fromGeographic({currentArea.bottomLeft.lon, currentArea.bottomLeft.lat}));
point.lon = currentArea.bottomLeft().lon(); point.lon = currentArea.bottomLeft.lon;
point.lat = currentArea.bottomLeft().lat(); point.lat = currentArea.bottomLeft.lat;
trainingAreaData.path.append(point); trainingAreaData.path.append(point);
areaData.path.append(point); areaData.path.append(point);
// upper left // upper left
UtmCoordinate ul(UtmCoordinate::fromGeographic(bl.geographic(0, currentArea.height()))); UtmCoordinate ul(UtmCoordinate::fromGeographic(bl.geographic(0, currentArea.height)));
point.lon = ul.geographic().x(); point.lon = ul.geographic().x();
point.lat = ul.geographic().y(); point.lat = ul.geographic().y();
trainingAreaData.path.append(point); trainingAreaData.path.append(point);
areaData.path.append(point); areaData.path.append(point);
// upper right // upper right
UtmCoordinate ur(UtmCoordinate::fromGeographic(bl.geographic(currentArea.width(), currentArea.height()))); UtmCoordinate ur(UtmCoordinate::fromGeographic(bl.geographic(currentArea.width, currentArea.height)));
point.lon = ur.geographic().x(); point.lon = ur.geographic().x();
point.lat = ur.geographic().y(); point.lat = ur.geographic().y();
trainingAreaData.path.append(point); trainingAreaData.path.append(point);
areaData.path.append(point); areaData.path.append(point);
// lower right // lower right
UtmCoordinate lr(UtmCoordinate::fromGeographic(bl.geographic(currentArea.width(), 0))); UtmCoordinate lr(UtmCoordinate::fromGeographic(bl.geographic(currentArea.width, 0)));
point.lon = lr.geographic().x(); point.lon = lr.geographic().x();
point.lat = lr.geographic().y(); point.lat = lr.geographic().y();
trainingAreaData.path.append(point); trainingAreaData.path.append(point);
areaData.path.append(point); areaData.path.append(point);
trainingAreaData.designation = QString::fromStdString(currentArea.name()); trainingAreaData.designation = QString::fromStdString(currentArea.name);
trainingAreaData.id = currentArea.id(); trainingAreaData.id = currentArea.id;
areaData.id = currentArea.id(); areaData.id = currentArea.id;
areaData.trainingAreaId = currentArea.id(); areaData.trainingAreaId = currentArea.id;
areaData.designation = QString::fromStdString(currentArea.name()); areaData.designation = QString::fromStdString(currentArea.name);
result.trainingAreas.append(TrainingAreaMessage(trainingAreaData, uuid)); result.trainingAreas.append(TrainingAreaMessage(trainingAreaData, uuid));
result.areas.append(AreaMessage(areaData, uuid)); result.areas.append(AreaMessage(areaData, uuid));
@@ -144,7 +144,7 @@ DataManager::EinruestEssentials DataManager::getEssentials(const QString &uuid)
{ {
ObjectStructureElement *currentElement = it.value(); ObjectStructureElement *currentElement = it.value();
switch (currentElement->getStructureElementTypeId().underlying()) switch (currentElement->getStructureElementTypeId())
{ {
case StructureElementType::TrainingArea: case StructureElementType::TrainingArea:
case StructureElementType::City: case StructureElementType::City:
@@ -160,16 +160,16 @@ DataManager::EinruestEssentials DataManager::getEssentials(const QString &uuid)
ObjectMessage::ObjectMessageData objectData; ObjectMessage::ObjectMessageData objectData;
ReplyMessage::LonLatPoint refPoint; ReplyMessage::LonLatPoint refPoint;
refPoint.lat = currentElement->getGeoPosition().lat(); refPoint.lat = currentElement->getGeoPosition().lat;
refPoint.lon = currentElement->getGeoPosition().lon(); refPoint.lon = currentElement->getGeoPosition().lon;
objectData.z = currentElement->getGeoPosition().z(); objectData.z = currentElement->getGeoPosition().z;
objectData.refPoint = refPoint; objectData.refPoint = refPoint;
objectData.pathRelative = pathForStructureId(currentElement->getId()); objectData.pathRelative = pathForStructureId(currentElement->getId());
objectData.path = relativeToGeographic(objectData.refPoint, objectData.pathRelative); objectData.path = relativeToGeographic(objectData.refPoint, objectData.pathRelative);
objectData.designation = (currentElement->getData().displayName().size() > 0) ? objectData.designation = (currentElement->getData().displayName.size() > 0) ?
QString::fromStdString(currentElement->getData().displayName()) : QString::fromStdString(currentElement->getData().displayName) :
QString::fromStdString(currentElement->getData().name()); QString::fromStdString(currentElement->getData().name);
objectData.id = currentElement->getId(); objectData.id = currentElement->getId();
objectData.areaId = 6; // TODO: HACK - calculate from position objectData.areaId = 6; // TODO: HACK - calculate from position
objectData.mseId = currentElement->getMainStructureElementId(); objectData.mseId = currentElement->getMainStructureElementId();
@@ -182,7 +182,7 @@ DataManager::EinruestEssentials DataManager::getEssentials(const QString &uuid)
objectData.street = description.value(QStringLiteral("street")).toString(); objectData.street = description.value(QStringLiteral("street")).toString();
objectData.number = description.value(QStringLiteral("number")).toString(); objectData.number = description.value(QStringLiteral("number")).toString();
objectData.rotationDegree = mse->getData().angle(); objectData.rotationDegree = mse->getData().angle;
} }
result.objects.append(ObjectMessage(objectData, uuid)); result.objects.append(ObjectMessage(objectData, uuid));
@@ -194,12 +194,12 @@ DataManager::EinruestEssentials DataManager::getEssentials(const QString &uuid)
levelData.id = currentElement->getId(); levelData.id = currentElement->getId();
levelData.objectid = currentElement->getPath().at(0); levelData.objectid = currentElement->getPath().at(0);
levelData.designation = (currentElement->getData().displayName().size() > 0) ? levelData.designation = (currentElement->getData().displayName.size() > 0) ?
QString::fromStdString(currentElement->getData().displayName()) : QString::fromStdString(currentElement->getData().displayName) :
QString::fromStdString(currentElement->getData().name()); QString::fromStdString(currentElement->getData().name);
levelData.number = determineFloorNumber(currentElement); levelData.number = determineFloorNumber(currentElement);
levelData.path = pathForStructureId(currentElement->getId()); levelData.path = pathForStructureId(currentElement->getId());
levelData.zPos = currentElement->getRelativePosition().offsetZ(); levelData.zPos = currentElement->getRelativePosition().offsetZ;
result.levels.append(LevelMessage(levelData, uuid)); result.levels.append(LevelMessage(levelData, uuid));
break; break;
@@ -209,9 +209,9 @@ DataManager::EinruestEssentials DataManager::getEssentials(const QString &uuid)
RoomMessage::RoomData roomData; RoomMessage::RoomData roomData;
roomData.id = currentElement->getId(); roomData.id = currentElement->getId();
roomData.designation = (currentElement->getData().displayName().size() > 0) ? roomData.designation = (currentElement->getData().displayName.size() > 0) ?
QString::fromStdString(currentElement->getData().displayName()) : QString::fromStdString(currentElement->getData().displayName) :
QString::fromStdString(currentElement->getData().name()); QString::fromStdString(currentElement->getData().name);
roomData.path = pathForStructureId(currentElement->getId()); roomData.path = pathForStructureId(currentElement->getId());
roomData.levelId = currentElement->getPath().at(1); roomData.levelId = currentElement->getPath().at(1);
@@ -223,17 +223,17 @@ DataManager::EinruestEssentials DataManager::getEssentials(const QString &uuid)
MountingPointMessage::MountingPointData mountingPointData; MountingPointMessage::MountingPointData mountingPointData;
mountingPointData.id = currentElement->getId(); mountingPointData.id = currentElement->getId();
mountingPointData.designation = (currentElement->getData().displayName().size() > 0) ? mountingPointData.designation = (currentElement->getData().displayName.size() > 0) ?
QString::fromStdString(currentElement->getData().displayName()) : QString::fromStdString(currentElement->getData().displayName) :
QString::fromStdString(currentElement->getData().name()); QString::fromStdString(currentElement->getData().name);
mountingPointData.tag = QString::fromStdString(currentElement->getData().barcode()); mountingPointData.tag = QString::fromStdString(currentElement->getData().barcode);
mountingPointData.objectId = currentElement->getPath().at(0); mountingPointData.objectId = currentElement->getPath().at(0);
mountingPointData.levelId = currentElement->getPath().size() > 2 ? currentElement->getPath().at(1) : -1; mountingPointData.levelId = currentElement->getPath().size() > 2 ? currentElement->getPath().at(1) : -1;
mountingPointData.roomId = currentElement->getPath().size() > 2 ? currentElement->getPath().at(2) : -1; mountingPointData.roomId = currentElement->getPath().size() > 2 ? currentElement->getPath().at(2) : -1;
mountingPointData.position3d.x = currentElement->getRelativePosition().offsetX(); mountingPointData.position3d.x = currentElement->getRelativePosition().offsetX;
mountingPointData.position3d.y = currentElement->getRelativePosition().offsetY(); mountingPointData.position3d.y = currentElement->getRelativePosition().offsetY;
mountingPointData.position3d.z = currentElement->getRelativePosition().offsetZ(); mountingPointData.position3d.z = currentElement->getRelativePosition().offsetZ;
mountingPointData.supportedAssetTypIds.append(currentElement->getData().mountingPointTypeId().underlying()); mountingPointData.supportedAssetTypIds.append(currentElement->getData().mountingPointTypeId);
mountingPointData.assetId = getMountedAssetId(currentElement->getId()); mountingPointData.assetId = getMountedAssetId(currentElement->getId());
result.mountingPoints.append(MountingPointMessage(mountingPointData, uuid)); result.mountingPoints.append(MountingPointMessage(mountingPointData, uuid));
@@ -244,13 +244,13 @@ DataManager::EinruestEssentials DataManager::getEssentials(const QString &uuid)
// No BuildingNetworkSwitch and no AnnouncementUnit (see GUEZE-1548/1459) // No BuildingNetworkSwitch and no AnnouncementUnit (see GUEZE-1548/1459)
AssetTypeMessage::AssetTypeData assetTypeData; AssetTypeMessage::AssetTypeData assetTypeData;
for (int i = MountingPointType::Unknown; i <= MountingPointType::EffectGenerationControlUnit; ++i) for (int i = MountingPointType::Unknown; i <= static_cast<int>(MountingPointType::EffectGenerationControlUnit); ++i)
{ {
if (i == MountingPointType_def::AnnouncementUnit) if (i == static_cast<int>(MountingPointType::AnnouncementUnit))
continue; continue;
assetTypeData.id = i; assetTypeData.id = i;
assetTypeData.designation = toString(static_cast<MountingPointType::type>(i)); assetTypeData.designation = toString(static_cast<MountingPointType>(i));
if (assetTypeData.designation.endsWith(QLatin1Char(')'))) if (assetTypeData.designation.endsWith(QLatin1Char(')')))
continue; continue;
assetTypeData.deviceClass = 1; // device class is just a dumy value here ... assetTypeData.deviceClass = 1; // device class is just a dumy value here ...
@@ -274,13 +274,13 @@ QVector<Messages::PlannedMountingMessage> DataManager::getPlannedMounting(const
{ {
const MainSchedule &data = sched->getData(); const MainSchedule &data = sched->getData();
if (data.statusId() == ScheduleStatus::Inactive) if (data.statusId == ScheduleStatus::Inactive)
continue; continue;
mountingData.areaId = areaIdForScheduleId(data.id()); mountingData.areaId = areaIdForScheduleId(data.id);
mountingData.plannedMountingId = data.id(); mountingData.plannedMountingId = data.id;
mountingData.designation = QString::fromStdString(data.name()); mountingData.designation = QString::fromStdString(data.name);
mountingData.mounting = entriesForScheduleId(data.id()); mountingData.mounting = entriesForScheduleId(data.id);
result.append(PlannedMountingMessage(mountingData, uuid)); result.append(PlannedMountingMessage(mountingData, uuid));
} }
@@ -320,7 +320,7 @@ LtsWebSocket::ReplyMessage *DataManager::getObjectMounting(int plannedMountingId
errorData.errorMessage = QObject::tr("Building id is invalid", "DataManager"); errorData.errorMessage = QObject::tr("Building id is invalid", "DataManager");
errorData.uuid = uuid; errorData.uuid = uuid;
WARNING_LOG(m_logger) << errorData.errorMessage << " - " << (buildingEle ? buildingEle->getStructureElementTypeId().underlying() : -1) WARNING_LOG(m_logger) << errorData.errorMessage << " - " << (buildingEle ? buildingEle->getStructureElementTypeId() : -1)
<< ", " << plannedMountingId << ", " << objectId; << ", " << plannedMountingId << ", " << objectId;
LtsWebSocket::ReplyMessage *reply = new LtsWebSocket::ErrorMessage(errorData); LtsWebSocket::ReplyMessage *reply = new LtsWebSocket::ErrorMessage(errorData);
return reply; return reply;
@@ -404,7 +404,7 @@ LtsWebSocket::ReplyMessage *DataManager::mountTag(const QString &mountingPointTa
if(assetId > 0) if(assetId > 0)
{ {
ObjectInstrumentationAsset *asset = m_mainHandler->getHandlerInstrumentationAsset()->getAssetFromId(assetId); ObjectInstrumentationAsset *asset = m_mainHandler->getHandlerInstrumentationAsset()->getAssetFromId(assetId);
if(asset->getData().assetStateId() == InstrumentationAssetState::Defect) if(asset->getData().assetStateId == InstrumentationAssetState::Defect)
{ {
LtsWebSocket::ErrorMessage::ErrorData data; LtsWebSocket::ErrorMessage::ErrorData data;
data.errorClass = 1; data.errorClass = 1;
@@ -667,10 +667,10 @@ LtsWebSocket::ReplyMessage *DataManager::unmountArea(int32_t areaId, const QStri
{ {
if (seElem->getStructureElementTypeId() == StructureElementType::MountingPoint) if (seElem->getStructureElementTypeId() == StructureElementType::MountingPoint)
{ {
if (!seElem->getData().path().size()) if (!seElem->getData().path.size())
continue; continue;
int32_t buildingId = seElem->getData().path()[0]; int32_t buildingId = seElem->getData().path[0];
if (structEleMap.value(buildingId)->getParentId() == areaId) if (structEleMap.value(buildingId)->getParentId() == areaId)
{ {
@@ -732,11 +732,11 @@ LtsWebSocket::ReplyMessage *DataManager::objectMountingReady(int32_t plannedMoun
for (const auto &mpp : mountingPointPlans) for (const auto &mpp : mountingPointPlans)
{ {
int32_t structEleId = mpp.structureElementId(); int32_t structEleId = mpp.structureElementId;
int32_t buildingId = -1; int32_t buildingId = -1;
if (structEleMap.value(structEleId)->getData().path().size()) if (structEleMap.value(structEleId)->getData().path.size())
buildingId = structEleMap.value(structEleId)->getData().path()[0]; buildingId = structEleMap.value(structEleId)->getData().path[0];
if (buildingId == objectId) if (buildingId == objectId)
{ {
@@ -831,7 +831,7 @@ LtsWebSocket::ReplyMessage *DataManager::getAssets(const QSet<int> &assetTypeIds
QVector<AssetData> assets; QVector<AssetData> assets;
for (const ObjectInstrumentationAsset *asset : m) for (const ObjectInstrumentationAsset *asset : m)
{ {
if (assetTypeIds.contains(asset->getData().mountingPointTypeId().underlying())) if (assetTypeIds.contains(asset->getData().mountingPointTypeId))
assets += assetData(asset); assets += assetData(asset);
} }
@@ -873,9 +873,9 @@ LtsWebSocket::ReplyMessage *DataManager::getBuildingState(int32_t buildingId, co
for (const StructureElement &currentElement : mse->getElements()) for (const StructureElement &currentElement : mse->getElements())
{ {
if (currentElement.structureElementTypeId() == InfrastructureManagement::StructureElementType::MountingPoint) if (currentElement.structureElementTypeId == InfrastructureManagement::StructureElementType::MountingPoint)
{ {
int32_t assetId = mountingPointAssetHandler->getMountedAssetId(currentElement.id()); int32_t assetId = mountingPointAssetHandler->getMountedAssetId(currentElement.id);
if (assetId) if (assetId)
{ {
const AssetData assetDat = assetData(assetId); const AssetData assetDat = assetData(assetId);
@@ -976,11 +976,11 @@ QVector<Messages::ReplyMessage::XYPoint> DataManager::pathForStructureId(int32_t
const MainFootprint &footprint = mse->getFootprint(); const MainFootprint &footprint = mse->getFootprint();
ReplyMessage::XYPoint newPoint; ReplyMessage::XYPoint newPoint;
result.reserve(footprint.elements().size()); result.reserve(footprint.elements.size());
const double angleDegree = mse->getData().angle(); const double angleDegree = mse->getData().angle;
for (const FootprintElement &fpElem : footprint.elements()) for (const FootprintElement &fpElem : footprint.elements)
{ {
const QPointF offset = rotatePoint(fpElem.relPosition().offsetX(), fpElem.relPosition().offsetY(), angleDegree); const QPointF offset = rotatePoint(fpElem.relPosition.offsetX, fpElem.relPosition.offsetY, angleDegree);
newPoint.x = offset.x(); newPoint.x = offset.x();
newPoint.y = offset.y(); newPoint.y = offset.y();
@@ -1003,7 +1003,7 @@ QVector<Messages::PlannedMountingMessage::MountingEntry> DataManager::entriesFor
for (const MountingPointPlan &currentPlan : m_mainHandler->getHandlerMainSchedule()->getMountingPointPlans(scheduleId)) for (const MountingPointPlan &currentPlan : m_mainHandler->getHandlerMainSchedule()->getMountingPointPlans(scheduleId))
{ {
const auto path = structEleHandler->getStructureElement(currentPlan.structureElementId())->getPath(); const auto path = structEleHandler->getStructureElement(currentPlan.structureElementId)->getPath();
int32_t buildingId = -1; int32_t buildingId = -1;
@@ -1030,7 +1030,7 @@ int32_t DataManager::areaIdForScheduleId(int32_t scheduleId) const
for (const auto &data : mountingPointPlans) for (const auto &data : mountingPointPlans)
{ {
int32_t buildingId = structureElementHandler->getStructureElement(data.structureElementId())->getPath()[0]; int32_t buildingId = structureElementHandler->getStructureElement(data.structureElementId)->getPath()[0];
return structureElementHandler->getStructureElement(buildingId)->getParentId(); return structureElementHandler->getStructureElement(buildingId)->getParentId();
} }
return -1; return -1;
@@ -1049,7 +1049,7 @@ int32_t DataManager::stateForBuilding(int32_t buildingId) const
const auto seElements = objMse->getStructureElements(); const auto seElements = objMse->getStructureElements();
for (ObjectStructureElement *currentElement : seElements) for (ObjectStructureElement *currentElement : seElements)
{ {
if (currentElement->getStructureElementTypeId().underlying() == StructureElementType::MountingPoint) if (currentElement->getStructureElementTypeId() == StructureElementType::MountingPoint)
{ {
bool isMountingPointMounted = isMounted(currentElement->getId()); bool isMountingPointMounted = isMounted(currentElement->getId());
isFullyMounted &= isMountingPointMounted; isFullyMounted &= isMountingPointMounted;
@@ -1079,7 +1079,7 @@ bool DataManager::isPlannedObject(int32_t objectId) const
{ {
for (const auto &mpp : m_mainHandler->getHandlerMainSchedule()->getMountingPointPlans(mainScheduleId)) for (const auto &mpp : m_mainHandler->getHandlerMainSchedule()->getMountingPointPlans(mainScheduleId))
{ {
const auto path = structEleHandler->getStructureElement(mpp.structureElementId())->getPath(); const auto path = structEleHandler->getStructureElement(mpp.structureElementId)->getPath();
if (!path.size()) if (!path.size())
continue; continue;
@@ -1107,7 +1107,7 @@ QVector<Messages::ObjectMountingMessage::PlannedEntry> DataManager::entriesForBu
const auto seElements = objMse->getStructureElements(); const auto seElements = objMse->getStructureElements();
for (ObjectStructureElement *currentElement : seElements) for (ObjectStructureElement *currentElement : seElements)
{ {
if (currentElement->getStructureElementTypeId().underlying() == StructureElementType::MountingPoint) if (currentElement->getStructureElementTypeId() == StructureElementType::MountingPoint)
{ {
MountingPointState mountingPointState = getMountingPointState(currentElement->getId(), scheduleId); MountingPointState mountingPointState = getMountingPointState(currentElement->getId(), scheduleId);
@@ -1147,8 +1147,8 @@ int32_t DataManager::mountingPointIdFromBarcode(const QString &barcode) const
const auto barcodeStd(barcode.toStdString()); const auto barcodeStd(barcode.toStdString());
for (const auto &p : structEleMap) for (const auto &p : structEleMap)
{ {
if (p->getStructureElementTypeId().underlying() == StructureElementType::MountingPoint && if (p->getStructureElementTypeId() == StructureElementType::MountingPoint &&
p->getData().barcode() == barcodeStd) p->getData().barcode == barcodeStd)
return p->getId(); return p->getId();
} }
@@ -1163,7 +1163,7 @@ int32_t DataManager::assetIdFromBarcode(const QString &barcode) const
const auto barcodeStd(barcode.toStdString()); const auto barcodeStd(barcode.toStdString());
for (const auto &p : assetMap) for (const auto &p : assetMap)
{ {
if (p->getData().barcode() == barcodeStd) if (p->getData().barcode == barcodeStd)
return p->getId(); return p->getId();
} }
@@ -1196,14 +1196,14 @@ Messages::AssetData DataManager::assetData(const ObjectInstrumentationAsset *ass
} }
result.id = asset->getId(); result.id = asset->getId();
result.assetTypeId = asset->getData().mountingPointTypeId().underlying(); result.assetTypeId = asset->getData().mountingPointTypeId;
result.assetTag = QString::fromStdString(asset->getData().barcode()); result.assetTag = QString::fromStdString(asset->getData().barcode);
result.designation = QString::fromStdString(asset->getData().name()); result.designation = QString::fromStdString(asset->getData().name);
result.hostname = QString::fromStdString(asset->getData().hostname()); result.hostname = QString::fromStdString(asset->getData().hostname);
result.state = toString(asset->getData().assetStateId()); result.state = toString(asset->getData().assetStateId);
result.time = QDateTime::fromMSecsSinceEpoch(asset->getData().lastUpdated()).toString(QStringLiteral("dd:MM:yy hh:mm")); result.time = QDateTime::fromMSecsSinceEpoch(asset->getData().lastUpdated).toString(QStringLiteral("dd:MM:yy hh:mm"));
if (asset->getData().assetStateId() == InstrumentationAssetState::Defect) if (asset->getData().assetStateId == InstrumentationAssetState::Defect)
result.errorDescription = QObject::tr("Instrumentation asset not working properly"); result.errorDescription = QObject::tr("Instrumentation asset not working properly");
return result; return result;
@@ -1214,8 +1214,8 @@ MountingPointState DataManager::getMountingPointState(int32_t mountingPointId, i
{ {
for (const auto &data : m_mainHandler->getHandlerMainSchedule()->getMountingPointPlans(scheduleId)) for (const auto &data : m_mainHandler->getHandlerMainSchedule()->getMountingPointPlans(scheduleId))
{ {
if (data.structureElementId() == mountingPointId) if (data.structureElementId == mountingPointId)
return data.mountingPointState(); return data.mountingPointState;
} }
return MountingPointState::Idle; return MountingPointState::Idle;
@@ -18,23 +18,23 @@ inline MainStructureElement convert(const Database::IsmMainStructureElement &dbD
{ {
MainStructureElement ddsData; MainStructureElement ddsData;
ddsData.id(dbData.id); ddsData.id = dbData.id;
ddsData.name(dbData.name.toStdString()); ddsData.name = dbData.name.toStdString();
ddsData.description(dbData.description.toStdString()); ddsData.description = dbData.description.toStdString();
ddsData.geoPosition(Core::GeoPosition(dbData.geoPosition.x(), dbData.geoPosition.y(), dbData.geoPosition.z())); ddsData.geoPosition = Core::GeoPosition(dbData.geoPosition.x(), dbData.geoPosition.y(), dbData.geoPosition.z());
ddsData.angle(dbData.angle); ddsData.angle = dbData.angle;
ddsData.externalWlsId(dbData.externalWlsId); ddsData.externalWlsId = dbData.externalWlsId;
ddsData.groupId(dbData.groupId); ddsData.groupId = dbData.groupId;
ddsData.modelId(dbData.modelId); ddsData.modelId = dbData.modelId;
ddsData.properties(dbData.properties.toStdString()); ddsData.properties = dbData.properties.toStdString();
// init data not in db // init data not in db
ddsData.isDeleted(false); ddsData.isDeleted = false;
ddsData.isUsed(false); ddsData.isUsed = false;
// TODO: fill additional data? // TODO: fill additional data?
//ddsData.structureElementId(); //ddsData.structureElementId;
//ddsData.elements(); //ddsData.elements;
return ddsData; return ddsData;
} }
@@ -43,25 +43,25 @@ inline StructureElement convert(const Database::IsmStructureElement &dbData)
{ {
StructureElement ddsData; StructureElement ddsData;
ddsData.id(dbData.id); ddsData.id = dbData.id;
ddsData.name(dbData.name.toStdString()); ddsData.name = dbData.name.toStdString();
ddsData.displayName(dbData.displayName.toStdString()); ddsData.displayName = dbData.displayName.toStdString();
ddsData.mainStructureElementId(dbData.mainStructureElementId); ddsData.mainStructureElementId = dbData.mainStructureElementId;
ddsData.structureElementTypeId(dbData.structureElementTypeId); ddsData.structureElementTypeId = dbData.structureElementTypeId;
ddsData.path(dbData.path()); ddsData.path = dbData.path();
ddsData.mountingPointId(dbData.mountingPointId); ddsData.mountingPointId = dbData.mountingPointId;
ddsData.barcode(dbData.barcode.toStdString()); ddsData.barcode = dbData.barcode.toStdString();
ddsData.relPosition(Core::RelativePosition(dbData.relPosition.x(), ddsData.relPosition = Core::RelativePosition(dbData.relPosition.x(),
dbData.relPosition.y(), dbData.relPosition.y(),
dbData.relPosition.z())); dbData.relPosition.z());
ddsData.mountingPointTypeId(dbData.mountingPointTypeId); ddsData.mountingPointTypeId = dbData.mountingPointTypeId;
ddsData.orientation(Core::Orientation(dbData.orientation.x(), ddsData.orientation = Core::Orientation(dbData.orientation.x(),
dbData.orientation.y(), dbData.orientation.y(),
dbData.orientation.z())); dbData.orientation.z());
ddsData.properties(dbData.properties.toStdString()); ddsData.properties = dbData.properties.toStdString();
// init data not in db // init data not in db
ddsData.isDeleted(false); ddsData.isDeleted = false;
ddsData.isUsed(false); ddsData.isUsed = false;
return ddsData; return ddsData;
} }
@@ -70,16 +70,16 @@ inline StructureElement convert(const Database::IsmStructureElement &dbData)
inline MainSchedule convert(const Database::IsmMountingPointSchedule &dbData) inline MainSchedule convert(const Database::IsmMountingPointSchedule &dbData)
{ {
MainSchedule ddsData; MainSchedule ddsData;
ddsData.id(dbData.id); ddsData.id = dbData.id;
ddsData.name(dbData.name.toStdString()); ddsData.name = dbData.name.toStdString();
ddsData.statusId(dbData.statusId); ddsData.statusId = dbData.statusId;
ddsData.timeCreated(dbData.timeCreated.toMSecsSinceEpoch()); ddsData.timeCreated = dbData.timeCreated.toMSecsSinceEpoch();
if (!dbData.timeStart.isNull() && dbData.timeStart.isValid()) if (!dbData.timeStart.isNull() && dbData.timeStart.isValid())
ddsData.timeStart(dbData.timeStart.toMSecsSinceEpoch()); ddsData.timeStart = dbData.timeStart.toMSecsSinceEpoch();
if (!dbData.timeEnd.isNull() && dbData.timeEnd.isValid()) if (!dbData.timeEnd.isNull() && dbData.timeEnd.isValid())
ddsData.timeEnd(dbData.timeEnd.toMSecsSinceEpoch()); ddsData.timeEnd = dbData.timeEnd.toMSecsSinceEpoch();
if (!dbData.exerciseId.isNull() && dbData.exerciseId.canConvert<unsigned int>()) if (!dbData.exerciseId.isNull() && dbData.exerciseId.canConvert<unsigned int>())
ddsData.exerciseId(dbData.exerciseId.toUInt()); ddsData.exerciseId = dbData.exerciseId.toUInt();
return ddsData; return ddsData;
} }
@@ -61,15 +61,15 @@ bool HandlerEffectArea::init()
int HandlerEffectArea::getSeId(const int mountPointId, const InfrastructureManagement::MainStructureElement &mse) const int HandlerEffectArea::getSeId(const int mountPointId, const InfrastructureManagement::MainStructureElement &mse) const
{ {
for ( unsigned int i = 0; i < mse.elements().size(); i++) for ( unsigned int i = 0; i < mse.elements.size(); i++)
{ {
ERROR_LOG(m_logger) << "mountPointId=" << mountPointId ERROR_LOG(m_logger) << "mountPointId=" << mountPointId
<< " id=" << mse.elements().at(i).id() << " id=" << mse.elements.at(i).id
<< " mpId="<< mse.elements().at(i).mountingPointId(); << " mpId="<< mse.elements.at(i).mountingPointId;
if ( mountPointId ==mse.elements().at(i).mountingPointId() ) if ( mountPointId ==mse.elements.at(i).mountingPointId )
{ {
ERROR_LOG(m_logger) << "return id=" << mse.elements().at(i).id(); ERROR_LOG(m_logger) << "return id=" << mse.elements.at(i).id;
return mse.elements().at(i).id(); return mse.elements.at(i).id;
} }
} }
return 0; return 0;
@@ -77,12 +77,12 @@ int HandlerEffectArea::getSeId(const int mountPointId, const InfrastructureManag
ObjectEffectArea *HandlerEffectArea::createEffectAreaForMse(const InfrastructureManagement::MainStructureElement &mse) ObjectEffectArea *HandlerEffectArea::createEffectAreaForMse(const InfrastructureManagement::MainStructureElement &mse)
{ {
std::string properties = mse.properties(); std::string properties = mse.properties;
if (properties.find("soundArea") == std::string::npos) // building has no associated sound area if (properties.find("soundArea") == std::string::npos) // building has no associated sound area
return nullptr; return nullptr;
DEBUG_LOG(m_logger) << "createEffectAreaForMse id=" << mse.id() DEBUG_LOG(m_logger) << "createEffectAreaForMse id=" << mse.id
<< " propoerties=" << properties; << " propoerties=" << properties;
QJsonObject jsonObj = QJsonDocument::fromJson(QByteArray::fromStdString(properties)).object().value(QStringLiteral("soundArea")).toObject(); QJsonObject jsonObj = QJsonDocument::fromJson(QByteArray::fromStdString(properties)).object().value(QStringLiteral("soundArea")).toObject();
@@ -99,18 +99,18 @@ ObjectEffectArea *HandlerEffectArea::createEffectAreaForMse(const Infrastructure
} }
EffectArea effectArea; EffectArea effectArea;
effectArea.id(id); effectArea.id = id;
int seId = getSeId(mainEgcuMountpoint, mse); int seId = getSeId(mainEgcuMountpoint, mse);
effectArea.areaEgcuId(seId); effectArea.areaEgcuId = seId;
effectArea.egcuIds(egcuIdsFromJsonObject(jsonObj, mse)); effectArea.egcuIds = egcuIdsFromJsonObject(jsonObj, mse);
effectArea.geometry(geometryFromJsonObject(jsonObj)); effectArea.geometry = geometryFromJsonObject(jsonObj);
DEBUG_LOG(m_logger) << "mainEgcuMountpoint=" << mainEgcuMountpoint DEBUG_LOG(m_logger) << "mainEgcuMountpoint=" << mainEgcuMountpoint
<< " effectArea.areaEgcuId()=" << effectArea.areaEgcuId() << " effectArea.areaEgcuId=" << effectArea.areaEgcuId
<< " effectArea.egcuIds().size()=" << effectArea.egcuIds().size() << " effectArea.egcuIds.size()=" << effectArea.egcuIds.size()
<< " effectArea.name()=" << effectArea.name(); << " effectArea.name=" << effectArea.name;
ObjectEffectArea *effectAreaObj = new ObjectEffectArea(m_mainHandler); ObjectEffectArea *effectAreaObj = new ObjectEffectArea(m_mainHandler);
effectAreaObj->createObject(effectArea); effectAreaObj->createObject(effectArea);
@@ -161,8 +161,8 @@ std::vector<Core::GeoPosition2D> HandlerEffectArea::geometryFromJsonObject(const
{ {
QJsonObject pnt = point.toObject(); // 2D vertex of the polygon that defines the sound area geometry QJsonObject pnt = point.toObject(); // 2D vertex of the polygon that defines the sound area geometry
geoPos2D.lat(pnt.value(QStringLiteral("lat")).toDouble()); geoPos2D.lat = pnt.value(QStringLiteral("lat")).toDouble();
geoPos2D.lon(pnt.value(QStringLiteral("lon")).toDouble()); geoPos2D.lon = pnt.value(QStringLiteral("lon")).toDouble();
geometry.push_back(geoPos2D); geometry.push_back(geoPos2D);
} // for } // for
@@ -170,7 +170,7 @@ std::vector<Core::GeoPosition2D> HandlerEffectArea::geometryFromJsonObject(const
{ {
DEBUG_LOG(m_logger) << "number of vertices found: " << geometry.size(); DEBUG_LOG(m_logger) << "number of vertices found: " << geometry.size();
for (const auto &geoPos : geometry) for (const auto &geoPos : geometry)
DEBUG_LOG(m_logger) << "lat = " << geoPos.lat() << " | lon = " << geoPos.lon(); DEBUG_LOG(m_logger) << "lat = " << geoPos.lat << " | lon = " << geoPos.lon;
} // if } // if
return geometry; return geometry;
@@ -49,9 +49,9 @@ bool HandlerInstrumentationAsset::init()
} }
m_ObjectInstrumentationAssetMap.insert(ifs->getId(), ifs); m_ObjectInstrumentationAssetMap.insert(ifs->getId(), ifs);
DEBUG_LOG(m_logger) << "asset id=" << ifs->getId() DEBUG_LOG(m_logger) << "asset id=" << ifs->getId()
<< " id=" << ifs->getData().id() << " id=" << ifs->getData().id
<< " mountingPointTypeId=" << ifs->getData().mountingPointTypeId() << " mountingPointTypeId=" << ifs->getData().mountingPointTypeId
<< " name=" << ifs->getData().name(); << " name=" << ifs->getData().name;
}; };
// create Asset objects // create Asset objects
@@ -71,8 +71,8 @@ ObjectInstrumentationAsset *HandlerInstrumentationAsset::createInstrumentationAs
{ {
int assetId = 0; int assetId = 0;
InstrumentationAssetModifyRequest request; InstrumentationAssetModifyRequest request;
request.name(QStringLiteral("Building_%1_SE_%2").arg(buildingId).arg(structureElementId).toStdString()); request.name = QStringLiteral("Building_%1_SE_%2").arg(buildingId).arg(structureElementId).toStdString();
request.mountingPointTypeId(InfrastructureManagement::MountingPointType::BuildingControlUnit); request.mountingPointTypeId = InfrastructureManagement::MountingPointType::BuildingControlUnit;
instrumentationAssetCreate(request, &assetId); instrumentationAssetCreate(request, &assetId);
return m_ObjectInstrumentationAssetMap.value(assetId); return m_ObjectInstrumentationAssetMap.value(assetId);
} }
@@ -81,7 +81,7 @@ ObjectInstrumentationAsset *HandlerInstrumentationAsset::createInstrumentationAs
bool HandlerInstrumentationAsset::removeInstrumentationAssetForMse(int assetId) bool HandlerInstrumentationAsset::removeInstrumentationAssetForMse(int assetId)
{ {
Core::RemoveElementRequest request; Core::RemoveElementRequest request;
request.id(assetId); request.id = assetId;
const Core::FunctionReplyObject ret = onInstrumentationAssetRemove(request); const Core::FunctionReplyObject ret = onInstrumentationAssetRemove(request);
if (ret.error()) if (ret.error())
WARNING_LOG(m_logger) << ret(); WARNING_LOG(m_logger) << ret();
@@ -96,7 +96,7 @@ bool HandlerInstrumentationAsset::setAssetState(int assetId, InstrumentationAsse
return false; return false;
InstrumentationAsset data = obj->getData(); InstrumentationAsset data = obj->getData();
data.assetStateId(state); data.assetStateId = state;
return !obj->updateObject(data).error(); return !obj->updateObject(data).error();
} }
@@ -108,7 +108,7 @@ bool HandlerInstrumentationAsset::setAssetAvailableInExercise(int32_t assetId, c
return false; return false;
InstrumentationAsset data = obj->getData(); InstrumentationAsset data = obj->getData();
data.availableInExercise(exercises); data.availableInExercise = exercises;
return !obj->updateObject(data).error(); return !obj->updateObject(data).error();
} }
@@ -118,7 +118,7 @@ ObjectInstrumentationAsset *HandlerInstrumentationAsset::getAssetFromBarcode(con
const std::string barcodeStd = barcode.toStdString(); const std::string barcodeStd = barcode.toStdString();
for (auto it = m_ObjectInstrumentationAssetMap.begin(); it != m_ObjectInstrumentationAssetMap.end(); ++it) for (auto it = m_ObjectInstrumentationAssetMap.begin(); it != m_ObjectInstrumentationAssetMap.end(); ++it)
{ {
if (it.value()->getData().barcode() == barcodeStd) if (it.value()->getData().barcode == barcodeStd)
return it.value(); return it.value();
} }
@@ -138,7 +138,7 @@ ObjectInstrumentationAsset *HandlerInstrumentationAsset::getAssetFromBarcodeAndI
if (result == nullptr) if (result == nullptr)
return nullptr; return nullptr;
if (QString::fromStdString(result->getData().barcode()) != barcode) if (QString::fromStdString(result->getData().barcode) != barcode)
return nullptr; return nullptr;
return result; return result;
} }
@@ -148,7 +148,7 @@ void HandlerInstrumentationAsset::onInstrumentationAssetModifyRequest(const rti:
const InstrumentationAssetModifyRequest &request) const InstrumentationAssetModifyRequest &request)
{ {
DEBUG_LOG(m_logger) << "onInstrumentationAssetModifyRequest: " << request; DEBUG_LOG(m_logger) << "onInstrumentationAssetModifyRequest: " << request;
const Core::FunctionReplyObject ret = request.id() > 0 ? instrumentationAssetModify(request) : instrumentationAssetCreate(request); const Core::FunctionReplyObject ret = request.id > 0 ? instrumentationAssetModify(request) : instrumentationAssetCreate(request);
if (ret.error()) if (ret.error())
WARNING_LOG(m_logger) << ret(); WARNING_LOG(m_logger) << ret();
m_mainHandler->dds()->fts()->instrumentationAssetModifyReply(cookie, ret); m_mainHandler->dds()->fts()->instrumentationAssetModifyReply(cookie, ret);
@@ -159,15 +159,15 @@ static InstrumentationAsset convert(const InstrumentationAssetModifyRequest &req
const InstrumentationAssetState &state = InstrumentationAssetState::Unmounted) const InstrumentationAssetState &state = InstrumentationAssetState::Unmounted)
{ {
InstrumentationAsset newData; InstrumentationAsset newData;
newData.id(request.id()); newData.id = request.id;
newData.name(request.name()); newData.name = request.name;
newData.mountingPointTypeId(request.mountingPointTypeId()); newData.mountingPointTypeId = request.mountingPointTypeId;
newData.barcode(request.barcode()); newData.barcode = request.barcode;
newData.hostname(request.hostname()); newData.hostname = request.hostname;
newData.properties(request.properties()); newData.properties = request.properties;
newData.assetStateId(state); newData.assetStateId = state;
newData.lastUpdated(QDateTime::currentMSecsSinceEpoch()); newData.lastUpdated = QDateTime::currentMSecsSinceEpoch();
newData.availableInExercise(request.availableInExercise()); newData.availableInExercise = request.availableInExercise;
return newData; return newData;
} }
@@ -195,11 +195,11 @@ Core::FunctionReplyObject HandlerInstrumentationAsset::instrumentationAssetCreat
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
Core::FunctionReplyObject HandlerInstrumentationAsset::instrumentationAssetModify(const InstrumentationAssetModifyRequest &request) Core::FunctionReplyObject HandlerInstrumentationAsset::instrumentationAssetModify(const InstrumentationAssetModifyRequest &request)
{ {
ObjectInstrumentationAsset *ifs = m_ObjectInstrumentationAssetMap.value(request.id()); ObjectInstrumentationAsset *ifs = m_ObjectInstrumentationAssetMap.value(request.id);
if (ifs == nullptr) if (ifs == nullptr)
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "Asset with id %1 not found")).arg(request.id()); return Core::FunctionReplyObject(request.id, tr_lts("dds", "Asset with id %1 not found")).arg(request.id);
return ifs->updateObject(convert(request, ifs->getData().assetStateId())); return ifs->updateObject(convert(request, ifs->getData().assetStateId));
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -215,23 +215,23 @@ void HandlerInstrumentationAsset::onInstrumentationAssetRemoveRequest(const rti:
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
Core::FunctionReplyObject HandlerInstrumentationAsset::onInstrumentationAssetRemove(const Core::RemoveElementRequest &request) Core::FunctionReplyObject HandlerInstrumentationAsset::onInstrumentationAssetRemove(const Core::RemoveElementRequest &request)
{ {
ObjectInstrumentationAsset *ifs = m_ObjectInstrumentationAssetMap.value(request.id()); ObjectInstrumentationAsset *ifs = m_ObjectInstrumentationAssetMap.value(request.id);
if (ifs == nullptr) if (ifs == nullptr)
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "Asset with id %1 not found")).arg(request.id()); return Core::FunctionReplyObject(request.id, tr_lts("dds", "Asset with id %1 not found")).arg(request.id);
if (m_mainHandler->dds()->topicLockMaster()->isLocked(ifs->getData(), m_mainHandler->exerciseId())) if (m_mainHandler->dds()->topicLockMaster()->isLocked(ifs->getData(), m_mainHandler->exerciseId()))
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "Asset '%1' is used by another user!")).arg(ifs->getName()); return Core::FunctionReplyObject(request.id, tr_lts("dds", "Asset '%1' is used by another user!")).arg(ifs->getName());
Core::FunctionReplyObject ret = ifs->removeObject(); Core::FunctionReplyObject ret = ifs->removeObject();
DEBUG_LOG(m_logger) << "Deleted Asset id = " << request.id(); DEBUG_LOG(m_logger) << "Deleted Asset id = " << request.id;
if (ret.error()) if (ret.error())
return ret; return ret;
// delete ObjectInstrumentationAsset (including Map) // delete ObjectInstrumentationAsset (including Map)
delete ifs; delete ifs;
m_ObjectInstrumentationAssetMap.remove(request.id()); m_ObjectInstrumentationAssetMap.remove(request.id);
m_mainHandler->getHandlerMountingPointAsset()->unmountAsset(request.id()); m_mainHandler->getHandlerMountingPointAsset()->unmountAsset(request.id);
return ret; return ret;
} }
@@ -251,35 +251,35 @@ Core::FunctionReplyObject HandlerInstrumentationAsset::instrumentationAssetSetSt
{ {
Core::FunctionReplyObject ret; Core::FunctionReplyObject ret;
if (request.id() > 0) if (request.id > 0)
{ {
ObjectInstrumentationAsset *ifs = m_ObjectInstrumentationAssetMap.value(request.id()); ObjectInstrumentationAsset *ifs = m_ObjectInstrumentationAssetMap.value(request.id);
if (ifs == nullptr) if (ifs == nullptr)
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "Asset with id %1 not found")).arg(request.id()); return Core::FunctionReplyObject(request.id, tr_lts("dds", "Asset with id %1 not found")).arg(request.id);
if (m_mainHandler->dds()->topicLockMaster()->isLocked(ifs->getData(), m_mainHandler->exerciseId())) if (m_mainHandler->dds()->topicLockMaster()->isLocked(ifs->getData(), m_mainHandler->exerciseId()))
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "Asset '%1' is used by another user!")).arg(ifs->getName()); return Core::FunctionReplyObject(request.id, tr_lts("dds", "Asset '%1' is used by another user!")).arg(ifs->getName());
// we cannot mount here // we cannot mount here
if (request.instrumentationAssetStateId() == InstrumentationAssetState::Mounted) if (request.instrumentationAssetStateId == InstrumentationAssetState::Mounted)
{ {
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "Asset '%1' cannot be mounted by this request")).arg(ifs->getName()); return Core::FunctionReplyObject(request.id, tr_lts("dds", "Asset '%1' cannot be mounted by this request")).arg(ifs->getName());
} }
if(request.instrumentationAssetStateId() == InstrumentationAssetState::Defect) if(request.instrumentationAssetStateId == InstrumentationAssetState::Defect)
{ {
bool retUnmount = m_mainHandler->getHandlerMountingPointAsset()->unmountAsset(request.id()); bool retUnmount = m_mainHandler->getHandlerMountingPointAsset()->unmountAsset(request.id);
WARNING_LOG(m_logger)<<"unmount Asset id ( "<< request.id()<<" )"<<" return ? "<<retUnmount; WARNING_LOG(m_logger)<<"unmount Asset id ( "<< request.id<<" )"<<" return ? "<<retUnmount;
} }
// set new state (unmounted or defect) // set new state (unmounted or defect)
if (!setAssetState(request.id(), request.instrumentationAssetStateId())) if (!setAssetState(request.id, request.instrumentationAssetStateId))
{ {
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "Could not update state for asset with id %1")).arg(request.id()); return Core::FunctionReplyObject(request.id, tr_lts("dds", "Could not update state for asset with id %1")).arg(request.id);
} }
InstrumentationAsset data = ifs->getData(); InstrumentationAsset data = ifs->getData();
data.assetStateId(request.instrumentationAssetStateId()); data.assetStateId = request.instrumentationAssetStateId;
data.lastUpdated(QDateTime::currentMSecsSinceEpoch()); data.lastUpdated = QDateTime::currentMSecsSinceEpoch();
ret = ifs->updateObject(data); ret = ifs->updateObject(data);
} }
@@ -300,22 +300,22 @@ void HandlerInstrumentationAsset::onInstrumentationAssetUnmountRequest(const rti
Core::FunctionReplyObject HandlerInstrumentationAsset::instrumentationAssetUnmount(const InstrumentationAssetUnmountRequest &request) Core::FunctionReplyObject HandlerInstrumentationAsset::instrumentationAssetUnmount(const InstrumentationAssetUnmountRequest &request)
{ {
Core::FunctionReplyObject ret; Core::FunctionReplyObject ret;
if(request.id() > 0) if(request.id > 0)
{ {
ObjectInstrumentationAsset *ifs = m_ObjectInstrumentationAssetMap.value(request.id()); ObjectInstrumentationAsset *ifs = m_ObjectInstrumentationAssetMap.value(request.id);
if (ifs == nullptr) if (ifs == nullptr)
{ {
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "Asset with id %1 not found")).arg(request.id()); return Core::FunctionReplyObject(request.id, tr_lts("dds", "Asset with id %1 not found")).arg(request.id);
} }
if (m_mainHandler->dds()->topicLockMaster()->isLocked(ifs->getData(), m_mainHandler->exerciseId())) if (m_mainHandler->dds()->topicLockMaster()->isLocked(ifs->getData(), m_mainHandler->exerciseId()))
{ {
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "Asset '%1' is used by another user!")).arg(ifs->getName()); return Core::FunctionReplyObject(request.id, tr_lts("dds", "Asset '%1' is used by another user!")).arg(ifs->getName());
} }
if (!m_mainHandler->getHandlerMountingPointAsset()->unmountAsset(request.id())) if (!m_mainHandler->getHandlerMountingPointAsset()->unmountAsset(request.id))
{ {
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "Error unmounting instrumentation asset with id %1")).arg(request.id()); return Core::FunctionReplyObject(request.id, tr_lts("dds", "Error unmounting instrumentation asset with id %1")).arg(request.id);
} }
} }
return ret; return ret;
@@ -77,7 +77,7 @@ void HandlerMainSchedule::onMainScheduleModifyRequest(const rti::core::SampleIde
const MainScheduleModifyRequest &request) const MainScheduleModifyRequest &request)
{ {
DEBUG_LOG(m_logger) << "onMainScheduleModifyRequest: " << request; DEBUG_LOG(m_logger) << "onMainScheduleModifyRequest: " << request;
const Core::FunctionReplyObject ret = request.id() > 0 ? mainScheduleModify(request) : mainScheduleCreate(request); const Core::FunctionReplyObject ret = request.id > 0 ? mainScheduleModify(request) : mainScheduleCreate(request);
if (ret.error()) if (ret.error())
WARNING_LOG(m_logger) << ret(); WARNING_LOG(m_logger) << ret();
m_mainHandler->dds()->fts()->mainScheduleModifyReply(cookie, ret); m_mainHandler->dds()->fts()->mainScheduleModifyReply(cookie, ret);
@@ -89,10 +89,10 @@ void HandlerMainSchedule::onMainScheduleCopyRequest(const rti::core::SampleIdent
{ {
DEBUG_LOG(m_logger) << "onMainScheduleCopyRequest: " << request; DEBUG_LOG(m_logger) << "onMainScheduleCopyRequest: " << request;
Core::FunctionReplyObject ret; Core::FunctionReplyObject ret;
if (request.id() > 0) if (request.id > 0)
{ {
ObjectMainSchedule ifs(m_mainHandler); ObjectMainSchedule ifs(m_mainHandler);
ret = ifs.copyObject(request.id()); ret = ifs.copyObject(request.id);
onDbInsertedSchedule(ifs.getId()); // because notification is not emitted in this case onDbInsertedSchedule(ifs.getId()); // because notification is not emitted in this case
} }
if (ret.error()) if (ret.error())
@@ -105,14 +105,14 @@ void HandlerMainSchedule::onMainScheduleCopyRequest(const rti::core::SampleIdent
static MainSchedule convert(const MainScheduleModifyRequest &request) static MainSchedule convert(const MainScheduleModifyRequest &request)
{ {
MainSchedule ddsData; MainSchedule ddsData;
ddsData.id(request.id()); ddsData.id = request.id;
ddsData.name(request.name()); ddsData.name = request.name;
ddsData.statusId(request.statusId()); ddsData.statusId = request.statusId;
ddsData.timeCreated(request.timeCreated()); ddsData.timeCreated = request.timeCreated;
ddsData.timeStart(request.timeStart()); ddsData.timeStart = request.timeStart;
ddsData.timeEnd(request.timeEnd()); ddsData.timeEnd = request.timeEnd;
ddsData.exerciseId(request.exerciseId()); ddsData.exerciseId = request.exerciseId;
ddsData.description(request.description()); ddsData.description = request.description;
return ddsData; return ddsData;
} }
@@ -137,9 +137,9 @@ Core::FunctionReplyObject HandlerMainSchedule::mainScheduleCreate(const Infrastr
// ---- .elements() are explicitely NOT changed with this method ---- // ---- .elements() are explicitely NOT changed with this method ----
Core::FunctionReplyObject HandlerMainSchedule::mainScheduleModify(const InfrastructureManagement::MainScheduleModifyRequest &request) Core::FunctionReplyObject HandlerMainSchedule::mainScheduleModify(const InfrastructureManagement::MainScheduleModifyRequest &request)
{ {
ObjectMainSchedule *ifs = m_objectMainScheduleMap.value(request.id()); ObjectMainSchedule *ifs = m_objectMainScheduleMap.value(request.id);
if (ifs == nullptr) if (ifs == nullptr)
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "MainSchedule with id %1 not found")).arg(request.id()); return Core::FunctionReplyObject(request.id, tr_lts("dds", "MainSchedule with id %1 not found")).arg(request.id);
return ifs->updateObject(convert(request));; return ifs->updateObject(convert(request));;
} }
@@ -149,17 +149,17 @@ void HandlerMainSchedule::onMainScheduleRemoveRequest(const rti::core::SampleIde
const Core::RemoveElementRequest &request) const Core::RemoveElementRequest &request)
{ {
Core::FunctionReplyObject ret; Core::FunctionReplyObject ret;
ObjectMainSchedule *ifs = m_objectMainScheduleMap.value(request.id()); ObjectMainSchedule *ifs = m_objectMainScheduleMap.value(request.id);
if (ifs == nullptr) if (ifs == nullptr)
{ {
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "MainSchedule with id %1 not found")).arg(request.id()); ret = Core::FunctionReplyObject(request.id, tr_lts("dds", "MainSchedule with id %1 not found")).arg(request.id);
m_mainHandler->dds()->fts()->mainScheduleRemoveReply(cookie, ret); m_mainHandler->dds()->fts()->mainScheduleRemoveReply(cookie, ret);
return; return;
} }
if (m_mainHandler->dds()->topicLockMaster()->isLocked(ifs->getData(), m_mainHandler->exerciseId())) if (m_mainHandler->dds()->topicLockMaster()->isLocked(ifs->getData(), m_mainHandler->exerciseId()))
{ {
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "MainSchedule '%1' is used by another user!")).arg(ifs->getName()); ret = Core::FunctionReplyObject(request.id, tr_lts("dds", "MainSchedule '%1' is used by another user!")).arg(ifs->getName());
m_mainHandler->dds()->fts()->mainScheduleRemoveReply(cookie, ret); m_mainHandler->dds()->fts()->mainScheduleRemoveReply(cookie, ret);
return; return;
} }
@@ -171,7 +171,7 @@ void HandlerMainSchedule::onMainScheduleRemoveRequest(const rti::core::SampleIde
else else
{ {
delete ifs; delete ifs;
m_objectMainScheduleMap.remove(request.id()); m_objectMainScheduleMap.remove(request.id);
} }
m_mainHandler->dds()->fts()->mainScheduleRemoveReply(cookie, ret); m_mainHandler->dds()->fts()->mainScheduleRemoveReply(cookie, ret);
@@ -190,11 +190,11 @@ void HandlerMainSchedule::onMountingPointPlanModifyRequest(const rti::core::Samp
Core::FunctionReplyObject HandlerMainSchedule::mountingPointPlanModify(const InfrastructureManagement::MountingPointPlanModifyRequest &request) Core::FunctionReplyObject HandlerMainSchedule::mountingPointPlanModify(const InfrastructureManagement::MountingPointPlanModifyRequest &request)
{ {
ObjectMainSchedule *ifs = m_objectMainScheduleMap.value(request.mountingPointScheduleId()); ObjectMainSchedule *ifs = m_objectMainScheduleMap.value(request.mountingPointScheduleId);
if (ifs == nullptr) if (ifs == nullptr)
return Core::FunctionReplyObject(request.mountingPointScheduleId(), tr_lts("dds", "MainSchedule with id %1 not found")).arg(request.mountingPointScheduleId()); return Core::FunctionReplyObject(request.mountingPointScheduleId, tr_lts("dds", "MainSchedule with id %1 not found")).arg(request.mountingPointScheduleId);
return ifs->updateElements(request.mountingPointPlans()); return ifs->updateElements(request.mountingPointPlans);
} }
//---------------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------------
@@ -238,5 +238,5 @@ std::vector<MountingPointPlan> HandlerMainSchedule::getMountingPointPlans(int sc
{ {
if (!getMainSchedule(scheduleId)) if (!getMainSchedule(scheduleId))
return {}; return {};
return getMainSchedule(scheduleId)->getData().elements(); return getMainSchedule(scheduleId)->getData().elements;
} }
@@ -129,11 +129,11 @@ bool HandlerMainStructureElement::init()
FootprintElement elem; FootprintElement elem;
for (const auto &pos : cont) for (const auto &pos : cont)
{ {
elem.id(pos.id); elem.id = pos.id;
elem.relPosition(Core::RelativePosition(pos.relPosition.x(), elem.relPosition = Core::RelativePosition(pos.relPosition.x(),
pos.relPosition.y(), pos.relPosition.y(),
pos.relPosition.z())); pos.relPosition.z());
elem.isGroundLevel(pos.isGroundLevel); elem.isGroundLevel = pos.isGroundLevel;
elements.push_back(elem); elements.push_back(elem);
} }
objMse->setFootprintData(elements); objMse->setFootprintData(elements);
@@ -157,37 +157,37 @@ void HandlerMainStructureElement::onMainStructureElementModifyRequest(const rti:
const MainStructureElementModifyRequest &request) const MainStructureElementModifyRequest &request)
{ {
DEBUG_LOG(m_logger) << "onMainStructureElementModifyRequest: " << request; DEBUG_LOG(m_logger) << "onMainStructureElementModifyRequest: " << request;
const Core::FunctionReplyObject ret = request.id() == 0 ? onMainStructureElementCreate(request) : onMainStructureElementModify(request); const Core::FunctionReplyObject ret = request.id == 0 ? onMainStructureElementCreate(request) : onMainStructureElementModify(request);
if (ret.error()) if (ret.error())
ERROR_LOG(m_logger) << ret() ERROR_LOG(m_logger) << ret()
<< " request.id()=" << request.id(); << " request.id()=" << request.id;
m_mainHandler->dds()->fts()->mainStructureElementModifyReply(cookie, ret); m_mainHandler->dds()->fts()->mainStructureElementModifyReply(cookie, ret);
} }
//--------------------------------------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------------------------------------
Core::FunctionReplyObject HandlerMainStructureElement::onMainStructureElementCreate(const MainStructureElementModifyRequest &request) Core::FunctionReplyObject HandlerMainStructureElement::onMainStructureElementCreate(const MainStructureElementModifyRequest &request)
{ {
if (request.elements().size() < 1) if (request.elements.size() < 1)
return Core::FunctionReplyObject(0, tr_lts("dds", "No structure elements given")); return Core::FunctionReplyObject(0, tr_lts("dds", "No structure elements given"));
if (request.elements().size() != request.childParentRelations().size()) if (request.elements.size() != request.childParentRelations.size())
return Core::FunctionReplyObject(0, tr_lts("dds", "Structure elements do not match child - parent relations")); return Core::FunctionReplyObject(0, tr_lts("dds", "Structure elements do not match child - parent relations"));
const StructureElement &seBuilding = request.elements().at(0); const StructureElement &seBuilding = request.elements.at(0);
const InfrastructureManagement::StructureElementType &seType = seBuilding.structureElementTypeId(); const InfrastructureManagement::StructureElementType &seType = seBuilding.structureElementTypeId;
if ((seType != InfrastructureManagement::StructureElementType::Building && if ((seType != InfrastructureManagement::StructureElementType::Building &&
seType != InfrastructureManagement::StructureElementType::Announcement && seType != InfrastructureManagement::StructureElementType::Announcement &&
seType != InfrastructureManagement::StructureElementType::ApproachingPoint && seType != InfrastructureManagement::StructureElementType::ApproachingPoint &&
seType != InfrastructureManagement::StructureElementType::MeteoDataUnit && seType != InfrastructureManagement::StructureElementType::MeteoDataUnit &&
seType != InfrastructureManagement::StructureElementType::RadioStation && seType != InfrastructureManagement::StructureElementType::RadioStation &&
seType != InfrastructureManagement::StructureElementType::Bridge) || seType != InfrastructureManagement::StructureElementType::Bridge) ||
seBuilding.mountingPointTypeId() != InfrastructureManagement::MountingPointType::Unknown) seBuilding.mountingPointTypeId != InfrastructureManagement::MountingPointType::Unknown)
return Core::FunctionReplyObject(0, tr_lts("dds", "First structure element is not from a top level type")); return Core::FunctionReplyObject(0, tr_lts("dds", "First structure element is not from a top level type"));
if (request.elements().size() > 1) // Buildings must have min 2 elements if (request.elements.size() > 1) // Buildings must have min 2 elements
{ {
const StructureElement &seBuildingBCU = request.elements().at(1); const StructureElement &seBuildingBCU = request.elements.at(1);
if (seBuildingBCU.structureElementTypeId() != InfrastructureManagement::StructureElementType::MountingPoint || if (seBuildingBCU.structureElementTypeId != InfrastructureManagement::StructureElementType::MountingPoint ||
seBuildingBCU.mountingPointTypeId() != InfrastructureManagement::MountingPointType::BuildingControlUnit) seBuildingBCU.mountingPointTypeId != InfrastructureManagement::MountingPointType::BuildingControlUnit)
return Core::FunctionReplyObject(0, tr_lts("dds", "Second structure element is not from type 'MountingPoint' for 'BuildingControlUnit'")); return Core::FunctionReplyObject(0, tr_lts("dds", "Second structure element is not from type 'MountingPoint' for 'BuildingControlUnit'"));
} }
@@ -228,9 +228,9 @@ Core::FunctionReplyObject HandlerMainStructureElement::onMainStructureElementCre
//--------------------------------------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------------------------------------
Core::FunctionReplyObject HandlerMainStructureElement::onMainStructureElementModify(const MainStructureElementModifyRequest &request) Core::FunctionReplyObject HandlerMainStructureElement::onMainStructureElementModify(const MainStructureElementModifyRequest &request)
{ {
InfrastructureManagement::ObjectMainStructureElement *ifs = m_objectMainStructureElementMap.value(request.id()); InfrastructureManagement::ObjectMainStructureElement *ifs = m_objectMainStructureElementMap.value(request.id);
if (ifs == nullptr) if (ifs == nullptr)
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "MainStructureElement with id %1 not found")).arg(request.id()); return Core::FunctionReplyObject(request.id, tr_lts("dds", "MainStructureElement with id %1 not found")).arg(request.id);
Core::FunctionReplyObject ret = ifs->updateObject(request); Core::FunctionReplyObject ret = ifs->updateObject(request);
if (ret.error()) if (ret.error())
@@ -243,21 +243,21 @@ Core::FunctionReplyObject HandlerMainStructureElement::onMainStructureElementMod
InfrastructureManagement::ObjectStructureElement *ifse = m_objectStructureElementMap.value(ifs->getStructureElementId()); InfrastructureManagement::ObjectStructureElement *ifse = m_objectStructureElementMap.value(ifs->getStructureElementId());
if (!ifse) if (!ifse)
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "StructureElement with id %1 not found for MainStructureElement %2")) return Core::FunctionReplyObject(request.id, tr_lts("dds", "StructureElement with id %1 not found for MainStructureElement %2"))
.arg(ifs->getStructureElementId()).arg(request.id()); .arg(ifs->getStructureElementId()).arg(request.id);
InfrastructureManagement::StructureElement seData = ifse->getData(); InfrastructureManagement::StructureElement seData = ifse->getData();
seData.name(request.name()); seData.name = request.name;
seData.displayName(ifse->getData().displayName()); seData.displayName = ifse->getData().displayName;
DEBUG_LOG(m_logger) << "Updating corresponding Structure Element id = " << ifs->getStructureElementId() DEBUG_LOG(m_logger) << "Updating corresponding Structure Element id = " << ifs->getStructureElementId()
<< " seData.displayName=" << seData.displayName(); << " seData.displayName=" << seData.displayName;
Core::FunctionReplyObject retSe = ifse->updateObject(seData); Core::FunctionReplyObject retSe = ifse->updateObject(seData);
if (retSe.error()) if (retSe.error())
return retSe; return retSe;
} }
publishMainStructureElement(request.id()); publishMainStructureElement(request.id);
return ret; return ret;
} }
@@ -267,7 +267,7 @@ void HandlerMainStructureElement::onMainStructureElementRemoveRequest(const rti:
const InfrastructureManagement::MainStructureElementRemoveRequest &request) const InfrastructureManagement::MainStructureElementRemoveRequest &request)
{ {
Core::FunctionReplyObject ret; Core::FunctionReplyObject ret;
int buildingId = request.id(); int buildingId = request.id;
// gest MSE object // gest MSE object
InfrastructureManagement::ObjectMainStructureElement *ifs = m_objectMainStructureElementMap.value(buildingId); InfrastructureManagement::ObjectMainStructureElement *ifs = m_objectMainStructureElementMap.value(buildingId);
@@ -280,7 +280,7 @@ void HandlerMainStructureElement::onMainStructureElementRemoveRequest(const rti:
if (m_mainHandler->dds()->topicLockMaster()->isLocked(ifs->getData(), m_mainHandler->exerciseId())) if (m_mainHandler->dds()->topicLockMaster()->isLocked(ifs->getData(), m_mainHandler->exerciseId()))
{ {
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "MainStructureElement '%1' is used by another user!")).arg(ifs->getName()); ret = Core::FunctionReplyObject(request.id, tr_lts("dds", "MainStructureElement '%1' is used by another user!")).arg(ifs->getName());
m_mainHandler->dds()->fts()->mainStructureElementRemoveReply(cookie, ret); m_mainHandler->dds()->fts()->mainStructureElementRemoveReply(cookie, ret);
return; return;
} }
@@ -332,16 +332,16 @@ void HandlerMainStructureElement::onMainStructureElementRemoveRequest(const rti:
void HandlerMainStructureElement::onMainStructureElementModifyPositionRequest(const rti::core::SampleIdentity &cookie, void HandlerMainStructureElement::onMainStructureElementModifyPositionRequest(const rti::core::SampleIdentity &cookie,
const MainStructureElementModifyPositionRequest &request) const MainStructureElementModifyPositionRequest &request)
{ {
const int mseId = request.id(); const int mseId = request.id;
Core::FunctionReplyObject ret; Core::FunctionReplyObject ret;
InfrastructureManagement::ObjectMainStructureElement *ifs = m_objectMainStructureElementMap.value(mseId); InfrastructureManagement::ObjectMainStructureElement *ifs = m_objectMainStructureElementMap.value(mseId);
if (ifs == nullptr) if (ifs == nullptr)
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "MainStructureElement with id %1 not found")).arg(mseId); ret = Core::FunctionReplyObject(request.id, tr_lts("dds", "MainStructureElement with id %1 not found")).arg(mseId);
else else
{ {
ret = ifs->updatePosition(request.geoPosition()); ret = ifs->updatePosition(request.geoPosition);
if (!ret.error()) if (!ret.error())
publishMainStructureElement(request.id()); publishMainStructureElement(request.id);
} }
m_mainHandler->dds()->fts()->mainStructureElementModifyPositionReply(cookie, ret); m_mainHandler->dds()->fts()->mainStructureElementModifyPositionReply(cookie, ret);
} }
@@ -352,23 +352,23 @@ void HandlerMainStructureElement::onMainStructureElementModifyBridgeStatusReques
const MainStructureElementModifyBridgeStatusRequest &request) const MainStructureElementModifyBridgeStatusRequest &request)
{ {
static int s_id = 1; static int s_id = 1;
const int mseId = request.id(); const int mseId = request.id;
Core::FunctionReplyObject ret; Core::FunctionReplyObject ret;
InfrastructureManagement::ObjectMainStructureElement *ifs = m_objectMainStructureElementMap.value(mseId); InfrastructureManagement::ObjectMainStructureElement *ifs = m_objectMainStructureElementMap.value(mseId);
if (ifs == nullptr) if (ifs == nullptr)
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "MainStructureElement with id %1 not found")).arg(mseId); ret = Core::FunctionReplyObject(request.id, tr_lts("dds", "MainStructureElement with id %1 not found")).arg(mseId);
else else
{ {
ret = ifs->setBridgeStatus(request.status()); ret = ifs->setBridgeStatus(request.status);
if (!ret.error()) if (!ret.error())
{ {
publishMainStructureElement(request.id()); publishMainStructureElement(request.id);
// publish BridgeStatus // publish BridgeStatus
BridgeChangeStatus bcs; BridgeChangeStatus bcs;
bcs.id(s_id++); bcs.id = s_id++;
bcs.buildingId(mseId); bcs.buildingId = mseId;
bcs.sampleTime(QDateTime::currentMSecsSinceEpoch()); bcs.sampleTime = QDateTime::currentMSecsSinceEpoch();
bcs.status(request.status()); bcs.status = request.status;
m_mainHandler->dds()->dts()->publish(bcs); m_mainHandler->dds()->dts()->publish(bcs);
} }
} }
@@ -390,26 +390,26 @@ void HandlerMainStructureElement::onStructureElementUpdateEffectOverrideRequest(
const StructureElementUpdateEffectOverrideRequest &request) const StructureElementUpdateEffectOverrideRequest &request)
{ {
INFO_LOG(m_logger) << "onStructureElementUpdateEffectOverrideRequest " INFO_LOG(m_logger) << "onStructureElementUpdateEffectOverrideRequest "
<< " structureElementId=" << request.structureElementId() << " structureElementId=" << request.structureElementId
<< " effectId=" << request.effectId() << " effectId=" << request.effectId
<< " effectOverride=" << request.effectOverride(); << " effectOverride=" << request.effectOverride;
if (!m_objectStructureElementMap.contains(request.structureElementId())) if (!m_objectStructureElementMap.contains(request.structureElementId))
{ {
ERROR_LOG(m_logger) << "structureElementId=" << request.structureElementId() << " not valid"; ERROR_LOG(m_logger) << "structureElementId=" << request.structureElementId << " not valid";
const Core::FunctionReplyObject ret = Core::FunctionReplyObject(-1, tr_lts("dds", "structureElementId %1 not valid")).arg(request.structureElementId()); const Core::FunctionReplyObject ret = Core::FunctionReplyObject(-1, tr_lts("dds", "structureElementId %1 not valid")).arg(request.structureElementId);
m_mainHandler->dds()->fts()->structureElementUpdateEffectOverrideReply(cookie, ret); m_mainHandler->dds()->fts()->structureElementUpdateEffectOverrideReply(cookie, ret);
return; return;
} }
InfrastructureManagement::StructureElement structureElement = getStructureElement(request.structureElementId())->getData(); InfrastructureManagement::StructureElement structureElement = getStructureElement(request.structureElementId)->getData();
udpatePropertiesForRelayOverride(request.effectId(), request.effectOverride(), structureElement); udpatePropertiesForRelayOverride(request.effectId, request.effectOverride, structureElement);
InfrastructureManagement::ObjectStructureElement *ifse = m_objectStructureElementMap.value(structureElement.id()); InfrastructureManagement::ObjectStructureElement *ifse = m_objectStructureElementMap.value(structureElement.id);
StructureElementModifyRequest requestSe; StructureElementModifyRequest requestSe;
int mseId = ifse->getMainStructureElementId(); int mseId = ifse->getMainStructureElementId();
//m_mainHandler->dds()->dts()->getBuildingId (structureElement.id(), mseId); //m_mainHandler->dds()->dts()->getBuildingId (structureElement.id(), mseId);
requestSe.mainStructureElementId(mseId); requestSe.mainStructureElementId = mseId;
requestSe.elements().resize(1); requestSe.elements.resize(1);
requestSe.elements()[0] = structureElement; requestSe.elements[0] = structureElement;
const Core::FunctionReplyObject ret = onStructureElementModify(requestSe); const Core::FunctionReplyObject ret = onStructureElementModify(requestSe);
if (ret.error()) if (ret.error())
@@ -427,22 +427,22 @@ void HandlerMainStructureElement::changeBuildingNameinMountingPoints(const Struc
for (auto it = m_objectStructureElementMap.begin(); it != m_objectStructureElementMap.end(); ++it) for (auto it = m_objectStructureElementMap.begin(); it != m_objectStructureElementMap.end(); ++it)
{ {
const int structureElementId = it.key(); const int structureElementId = it.key();
const int buildingId = se.mainStructureElementId(); const int buildingId = se.mainStructureElementId;
ObjectStructureElement *ose = it.value(); ObjectStructureElement *ose = it.value();
DEBUG_LOG(m_logger) << "buildingId=" << buildingId DEBUG_LOG(m_logger) << "buildingId=" << buildingId
<< " structureElementId=" << structureElementId << " structureElementId=" << structureElementId
<< " se.id=" << se.id() << " se.id=" << se.id
<< " id=" << ose->getId() << " id=" << ose->getId()
<< " type=" << ose->getStructureElementTypeId() << " type=" << ose->getStructureElementTypeId()
<< " displayName=" << ose->getData().displayName() << " displayName=" << ose->getData().displayName
<< " MainStructureElementId=" << ose->getMainStructureElementId(); << " MainStructureElementId=" << ose->getMainStructureElementId();
if ((buildingId == ose->getMainStructureElementId()) if ((buildingId == ose->getMainStructureElementId())
//&& (ose->getStructureElementTypeId() == StructureElementType::Building)) //&& (ose->getStructureElementTypeId() == StructureElementType::Building))
&& (ose->getData().mountingPointTypeId() == MountingPointType::BuildingControlUnit)) && (ose->getData().mountingPointTypeId == MountingPointType::BuildingControlUnit))
{ {
oldBuildingName = QString::fromStdString(ose->getData().displayName()); oldBuildingName = QString::fromStdString(ose->getData().displayName);
newBuildingName = QString::fromStdString(se.displayName()); newBuildingName = QString::fromStdString(se.displayName);
DEBUG_LOG(m_logger) << "old BuildingName= " << oldBuildingName DEBUG_LOG(m_logger) << "old BuildingName= " << oldBuildingName
<< " newBuildingName= " << newBuildingName; << " newBuildingName= " << newBuildingName;
break; break;
@@ -452,21 +452,21 @@ void HandlerMainStructureElement::changeBuildingNameinMountingPoints(const Struc
for (auto it = m_objectStructureElementMap.begin(); it != m_objectStructureElementMap.end(); ++it) for (auto it = m_objectStructureElementMap.begin(); it != m_objectStructureElementMap.end(); ++it)
{ {
const int structureElementId = it.key(); const int structureElementId = it.key();
const int buildingId = se.mainStructureElementId(); const int buildingId = se.mainStructureElementId;
ObjectStructureElement *ose = it.value(); ObjectStructureElement *ose = it.value();
DEBUG_LOG(m_logger) << "buildingId=" << buildingId DEBUG_LOG(m_logger) << "buildingId=" << buildingId
<< " structureElementId=" << structureElementId << " structureElementId=" << structureElementId
<< " se.id=" << se.id() << " se.id=" << se.id
<< " id=" << ose->getId() << " id=" << ose->getId()
<< " type=" << ose->getStructureElementTypeId() << " type=" << ose->getStructureElementTypeId()
<< " displayName=" << ose->getData().displayName() << " displayName=" << ose->getData().displayName
<< " MainStructureElementId=" << ose->getMainStructureElementId(); << " MainStructureElementId=" << ose->getMainStructureElementId();
if ((buildingId == ose->getMainStructureElementId()) if ((buildingId == ose->getMainStructureElementId())
&& ((ose->getStructureElementTypeId() == StructureElementType::MountingPoint) && ((ose->getStructureElementTypeId() == StructureElementType::MountingPoint)
|| (ose->getStructureElementTypeId() == StructureElementType::Building))) || (ose->getStructureElementTypeId() == StructureElementType::Building)))
{ {
QString displayName = QString::fromStdString(ose->getData().displayName()); QString displayName = QString::fromStdString(ose->getData().displayName);
if (displayName.contains(oldBuildingName)) if (displayName.contains(oldBuildingName))
{ {
DEBUG_LOG(m_logger) << "update = displayName=" << displayName DEBUG_LOG(m_logger) << "update = displayName=" << displayName
@@ -475,18 +475,18 @@ void HandlerMainStructureElement::changeBuildingNameinMountingPoints(const Struc
displayName.replace(oldBuildingName, newBuildingName); displayName.replace(oldBuildingName, newBuildingName);
InfrastructureManagement::StructureElement seData = ose->getData(); InfrastructureManagement::StructureElement seData = ose->getData();
seData.displayName(displayName.toStdString()); seData.displayName = displayName.toStdString();
// update mseData before publishing // update mseData before publishing
for (size_t j = 0; j < mseData.elements().size(); ++j) for (size_t j = 0; j < mseData.elements.size(); ++j)
{ {
const StructureElement &curSe = mseData.elements().at(j); const StructureElement &curSe = mseData.elements.at(j);
if (curSe.id() == structureElementId) if (curSe.id == structureElementId)
{ {
DEBUG_LOG(m_logger) << "i=" << j DEBUG_LOG(m_logger) << "i=" << j
<< " id=" << curSe.id() << " id=" << curSe.id
<< " displayName=" << curSe.displayName(); << " displayName=" << curSe.displayName;
mseData.elements().at(j) = seData; mseData.elements.at(j) = seData;
break; break;
} }
} }
@@ -501,30 +501,30 @@ void HandlerMainStructureElement::changeBuildingNameinMountingPoints(const Struc
//----------------------------------------------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------------------------------------------
Core::FunctionReplyObject HandlerMainStructureElement::onStructureElementModify(const StructureElementModifyRequest &request) Core::FunctionReplyObject HandlerMainStructureElement::onStructureElementModify(const StructureElementModifyRequest &request)
{ {
const int mseId = request.mainStructureElementId(); const int mseId = request.mainStructureElementId;
InfrastructureManagement::ObjectMainStructureElement *ifs = m_objectMainStructureElementMap.value(mseId); InfrastructureManagement::ObjectMainStructureElement *ifs = m_objectMainStructureElementMap.value(mseId);
if (ifs == nullptr) if (ifs == nullptr)
return Core::FunctionReplyObject(request.mainStructureElementId(), tr_lts("dds", "MainStructureElement with id %1 not found")).arg(mseId); return Core::FunctionReplyObject(request.mainStructureElementId, tr_lts("dds", "MainStructureElement with id %1 not found")).arg(mseId);
MainStructureElementModifyRequest mseData; MainStructureElementModifyRequest mseData;
// copy for lazy people ... // copy for lazy people ...
MainStructureElement &mse = mseData; MainStructureElement &mse = mseData;
mse = ifs->getData(); mse = ifs->getData();
DEBUG_LOG(m_logger) << "request.mseId: " << mseId << " #elements: " << mseData.elements().size() << "request count: " << request.elements().size(); DEBUG_LOG(m_logger) << "request.mseId: " << mseId << " #elements: " << mseData.elements.size() << "request count: " << request.elements.size();
for (const StructureElement &se : request.elements()) for (const StructureElement &se : request.elements)
{ {
bool bFound = false; bool bFound = false;
for (size_t i = 0; i < mseData.elements().size(); ++i) for (size_t i = 0; i < mseData.elements.size(); ++i)
{ {
const StructureElement &curSe = mseData.elements().at(i); const StructureElement &curSe = mseData.elements.at(i);
if (se.id() == curSe.id()) if (se.id == curSe.id)
{ {
bFound = true; bFound = true;
mseData.elements()[i] = se; mseData.elements[i] = se;
DEBUG_LOG(m_logger) << "StructureElement Modify = " << mseData.elements()[i]; DEBUG_LOG(m_logger) << "StructureElement Modify = " << mseData.elements[i];
if (se.structureElementTypeId() == StructureElementType::Building if (se.structureElementTypeId == StructureElementType::Building
&& se.displayName() != curSe.displayName()) && se.displayName != curSe.displayName)
changeBuildingNameinMountingPoints(se, mseData); changeBuildingNameinMountingPoints(se, mseData);
break; break;
@@ -532,7 +532,7 @@ Core::FunctionReplyObject HandlerMainStructureElement::onStructureElementModify(
} }
if (!bFound) if (!bFound)
return Core::FunctionReplyObject(mseId, return Core::FunctionReplyObject(mseId,
tr_lts("dds", "StructureElement with id %1 not found in MainStructure with id %2")).arg(se.id()).arg(mseId); tr_lts("dds", "StructureElement with id %1 not found in MainStructure with id %2")).arg(se.id).arg(mseId);
} }
return onMainStructureElementModify(mseData); return onMainStructureElementModify(mseData);
} }
@@ -578,41 +578,41 @@ void HandlerMainStructureElement::addedStructureElements(const QMap<int, ObjectS
void HandlerMainStructureElement::onExerciseStateChanged(const ExerciseManagement::Exercise &data, DataModification mod) void HandlerMainStructureElement::onExerciseStateChanged(const ExerciseManagement::Exercise &data, DataModification mod)
{ {
Q_UNUSED(mod) Q_UNUSED(mod)
if (data.state().underlying() != ExerciseManagement::ExerciseState::Terminated) if (data.state != ExerciseManagement::ExerciseState::Terminated)
return; return;
for (auto mseObj : qAsConst(m_objectMainStructureElementMap)) for (auto mseObj : qAsConst(m_objectMainStructureElementMap))
{ {
const MainStructureElement &mse = mseObj->getData(); const MainStructureElement &mse = mseObj->getData();
QJsonObject obj = QJsonDocument::fromJson(QByteArray::fromStdString(mse.properties())).object(); QJsonObject obj = QJsonDocument::fromJson(QByteArray::fromStdString(mse.properties)).object();
if (obj.value(QStringLiteral("available_in_exercise")).toArray().at(0).toInt() == data.id()) if (obj.value(QStringLiteral("available_in_exercise")).toArray().at(0).toInt() == data.id)
{ {
MainStructureElementModifyRequest modReq; MainStructureElementModifyRequest modReq;
modReq.angle(mse.angle()); modReq.angle = mse.angle;
modReq.description(mse.description()); modReq.description = mse.description;
modReq.externalWlsId(mse.externalWlsId()); modReq.externalWlsId = mse.externalWlsId;
modReq.elements(mse.elements()); modReq.elements = mse.elements;
// modReq.footprint(mseObj->getFootprint()); // modReq.footprint(mseObj->getFootprint());
modReq.geoPosition(mse.geoPosition()); modReq.geoPosition = mse.geoPosition;
modReq.groupId(mse.groupId()); modReq.groupId = mse.groupId;
modReq.id(mse.id()); modReq.id = mse.id;
modReq.isDeleted(mse.isDeleted()); modReq.isDeleted = mse.isDeleted;
modReq.isUsed(mse.isUsed()); modReq.isUsed = mse.isUsed;
modReq.modelId(mse.modelId()); modReq.modelId = mse.modelId;
modReq.name(mse.name()); modReq.name = mse.name;
std::vector<InfrastructureManagement::StructureElement> resElements; std::vector<InfrastructureManagement::StructureElement> resElements;
for (auto element : qAsConst(mse.elements())) for (auto element : qAsConst(mse.elements))
{ {
QJsonDocument doc = QJsonDocument::fromJson(QByteArray::fromStdString(element.properties())); QJsonDocument doc = QJsonDocument::fromJson(QByteArray::fromStdString(element.properties));
QJsonObject objEle = doc.object(); QJsonObject objEle = doc.object();
if (objEle.contains(QStringLiteral("record"))) if (objEle.contains(QStringLiteral("record")))
{ {
objEle[QStringLiteral("record")] = false; objEle[QStringLiteral("record")] = false;
element.properties(QJsonDocument(objEle).toJson().toStdString()); element.properties = QJsonDocument(objEle).toJson().toStdString();
} }
resElements.push_back(element); resElements.push_back(element);
} }
modReq.elements(resElements); modReq.elements = resElements;
QJsonObject root; QJsonObject root;
try try
{ {
@@ -623,9 +623,9 @@ void HandlerMainStructureElement::onExerciseStateChanged(const ExerciseManagemen
ERROR_LOG(m_logger) << "can't parse json"; ERROR_LOG(m_logger) << "can't parse json";
Q_ASSERT(false); Q_ASSERT(false);
} }
modReq.properties(QString::fromUtf8(QJsonDocument(obj).toJson()).toStdString()); modReq.properties = QString::fromUtf8(QJsonDocument(obj).toJson()).toStdString();
modReq.structureElementId(mse.structureElementId()); modReq.structureElementId = mse.structureElementId;
modReq.structureElementTypeId(mse.structureElementTypeId()); modReq.structureElementTypeId = mse.structureElementTypeId;
onMainStructureElementModify(modReq); onMainStructureElementModify(modReq);
} }
@@ -636,7 +636,7 @@ void HandlerMainStructureElement::udpatePropertiesForRelayOverride(const int rel
const InfrastructureManagement::EffectOverride state, const InfrastructureManagement::EffectOverride state,
InfrastructureManagement::StructureElement &se) InfrastructureManagement::StructureElement &se)
{ {
QByteArray content = QByteArray::fromStdString(se.properties()); QByteArray content = QByteArray::fromStdString(se.properties);
const QJsonDocument doc(QJsonDocument::fromJson(content)); const QJsonDocument doc(QJsonDocument::fromJson(content));
QJsonObject docObj = QJsonObject(doc.object()); QJsonObject docObj = QJsonObject(doc.object());
@@ -654,15 +654,15 @@ void HandlerMainStructureElement::udpatePropertiesForRelayOverride(const int rel
if (key != relay) if (key != relay)
continue; continue;
if (state.underlying() != InfrastructureManagement::EffectOverride_def::Automatic) if (state != InfrastructureManagement::EffectOverride::Automatic)
arrRelays[i] = QJsonObject({qMakePair<QString, QJsonValue>(keyStr, state.underlying())}); arrRelays[i] = QJsonObject({qMakePair<QString, QJsonValue>(keyStr, static_cast<int>(state))});
else else
arrRelays.removeAt(i); arrRelays.removeAt(i);
containsRelay = true; containsRelay = true;
break; break;
} }
if (!containsRelay && state.underlying() != InfrastructureManagement::EffectOverride_def::Automatic) if (!containsRelay && state != InfrastructureManagement::EffectOverride::Automatic)
arrRelays.append(QJsonObject({qMakePair<QString, QJsonValue>(QString::number(relay), state.underlying())})); arrRelays.append(QJsonObject({qMakePair<QString, QJsonValue>(QString::number(relay), static_cast<int>(state))}));
if (arrRelays.isEmpty()) if (arrRelays.isEmpty())
overridesObj.remove(QStringLiteral("relays")); overridesObj.remove(QStringLiteral("relays"));
@@ -676,7 +676,7 @@ void HandlerMainStructureElement::udpatePropertiesForRelayOverride(const int rel
QByteArray content_neu = QJsonDocument(docObj).toJson(QJsonDocument::Compact); QByteArray content_neu = QJsonDocument(docObj).toJson(QJsonDocument::Compact);
se.properties(content_neu.toStdString()); se.properties = content_neu.toStdString();
} }
//--------------------------------------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------------------------------------
@@ -69,7 +69,7 @@ void HandlerMountingPointAsset::onMountingPointAssetModifyRequest(const rti::cor
const MountingPointAssetModifyRequest &request) const MountingPointAssetModifyRequest &request)
{ {
DEBUG_LOG(m_logger) << "onMountingPointAssetModifyRequest: " << request; DEBUG_LOG(m_logger) << "onMountingPointAssetModifyRequest: " << request;
const Core::FunctionReplyObject ret = request.id() > 0 ? mountingPointAssetModify(request) : mountingPointAssetCreate(request); const Core::FunctionReplyObject ret = request.id > 0 ? mountingPointAssetModify(request) : mountingPointAssetCreate(request);
if (ret.error()) if (ret.error())
WARNING_LOG(m_logger) << ret(); WARNING_LOG(m_logger) << ret();
m_mainHandler->dds()->fts()->mountingPointAssetModifyReply(cookie, ret); m_mainHandler->dds()->fts()->mountingPointAssetModifyReply(cookie, ret);
@@ -80,10 +80,10 @@ Core::FunctionReplyObject HandlerMountingPointAsset::mountingPointAssetCreate(co
{ {
MountingPointAsset newData; MountingPointAsset newData;
newData.structureElementId(request.structureElementId()); newData.structureElementId = request.structureElementId;
newData.assetId(request.assetId()); newData.assetId = request.assetId;
newData.name(request.name()); newData.name = request.name;
newData.lastUpdated(QDateTime::currentMSecsSinceEpoch()); newData.lastUpdated = QDateTime::currentMSecsSinceEpoch();
ObjectMountingPointAsset *ifs(new ObjectMountingPointAsset(m_mainHandler)); ObjectMountingPointAsset *ifs(new ObjectMountingPointAsset(m_mainHandler));
Core::FunctionReplyObject ret = ifs->createObject(newData); Core::FunctionReplyObject ret = ifs->createObject(newData);
@@ -93,7 +93,7 @@ Core::FunctionReplyObject HandlerMountingPointAsset::mountingPointAssetCreate(co
ifs = nullptr; ifs = nullptr;
return ret; return ret;
} }
syncAvailableInExercise(request.structureElementId(), request.assetId()); syncAvailableInExercise(request.structureElementId, request.assetId);
m_objectMountingPointAssetMap.insert(ifs->getId(), ifs); m_objectMountingPointAssetMap.insert(ifs->getId(), ifs);
@@ -103,17 +103,17 @@ Core::FunctionReplyObject HandlerMountingPointAsset::mountingPointAssetCreate(co
//------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------
Core::FunctionReplyObject HandlerMountingPointAsset::mountingPointAssetModify(const InfrastructureManagement::MountingPointAssetModifyRequest &request) Core::FunctionReplyObject HandlerMountingPointAsset::mountingPointAssetModify(const InfrastructureManagement::MountingPointAssetModifyRequest &request)
{ {
ObjectMountingPointAsset *ifs = m_objectMountingPointAssetMap.value(request.id()); ObjectMountingPointAsset *ifs = m_objectMountingPointAssetMap.value(request.id);
if (ifs == nullptr) if (ifs == nullptr)
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "MountingPointAsset with id %1 not found")).arg(request.id()); return Core::FunctionReplyObject(request.id, tr_lts("dds", "MountingPointAsset with id %1 not found")).arg(request.id);
MountingPointAsset ddsData; MountingPointAsset ddsData;
ddsData.id(request.id()); ddsData.id = request.id;
ddsData.structureElementId(request.structureElementId()); ddsData.structureElementId = request.structureElementId;
ddsData.assetId(request.assetId()); ddsData.assetId = request.assetId;
ddsData.name(request.name()); ddsData.name = request.name;
ddsData.lastUpdated(QDateTime::currentMSecsSinceEpoch()); ddsData.lastUpdated = QDateTime::currentMSecsSinceEpoch();
int32_t oldAssetId = ifs->getAssetId(); int32_t oldAssetId = ifs->getAssetId();
@@ -134,16 +134,16 @@ void HandlerMountingPointAsset::onMountingPointAssetRemoveRequest(const rti::cor
const Core::RemoveElementRequest &request) const Core::RemoveElementRequest &request)
{ {
Core::FunctionReplyObject ret; Core::FunctionReplyObject ret;
ObjectMountingPointAsset *ifs = m_objectMountingPointAssetMap.value(request.id()); ObjectMountingPointAsset *ifs = m_objectMountingPointAssetMap.value(request.id);
if (ifs == nullptr) if (ifs == nullptr)
{ {
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "MountingPointAsset with id %1 not found")).arg(request.id()); ret = Core::FunctionReplyObject(request.id, tr_lts("dds", "MountingPointAsset with id %1 not found")).arg(request.id);
m_mainHandler->dds()->fts()->mountingPointAssetRemoveReply(cookie, ret); m_mainHandler->dds()->fts()->mountingPointAssetRemoveReply(cookie, ret);
return; return;
} }
if (m_mainHandler->dds()->topicLockMaster()->isLocked(ifs->getData(), m_mainHandler->exerciseId())) if (m_mainHandler->dds()->topicLockMaster()->isLocked(ifs->getData(), m_mainHandler->exerciseId()))
{ {
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "MountingPointAsset id %1 is used by another user!")).arg(ifs->getId()); ret = Core::FunctionReplyObject(request.id, tr_lts("dds", "MountingPointAsset id %1 is used by another user!")).arg(ifs->getId());
m_mainHandler->dds()->fts()->mountingPointAssetRemoveReply(cookie, ret); m_mainHandler->dds()->fts()->mountingPointAssetRemoveReply(cookie, ret);
return; return;
} }
@@ -158,7 +158,7 @@ void HandlerMountingPointAsset::onMountingPointAssetRemoveRequest(const rti::cor
{ {
// delete ObjectMountingPointAsset (including MapStateMachine) // delete ObjectMountingPointAsset (including MapStateMachine)
delete ifs; delete ifs;
m_objectMountingPointAssetMap.remove(request.id()); m_objectMountingPointAssetMap.remove(request.id);
} }
m_mainHandler->dds()->fts()->mountingPointAssetRemoveReply(cookie, ret); m_mainHandler->dds()->fts()->mountingPointAssetRemoveReply(cookie, ret);
@@ -198,9 +198,9 @@ bool InfrastructureManagement::HandlerMountingPointAsset::mount(int32_t assetId,
return false; return false;
} }
if (asset->getData().assetStateId() == InstrumentationAssetState::Defect ) if (asset->getData().assetStateId == InstrumentationAssetState::Defect )
{ {
WARNING_LOG(m_logger) << "Can not mount asset with DEFECT state. asset_id: " << assetId <<" name: "<<asset->getData().name(); WARNING_LOG(m_logger) << "Can not mount asset with DEFECT state. asset_id: " << assetId <<" name: "<<asset->getData().name;
return false; return false;
} }
@@ -210,8 +210,8 @@ bool InfrastructureManagement::HandlerMountingPointAsset::mount(int32_t assetId,
<< mountingPoint->getStructureElementTypeId(); << mountingPoint->getStructureElementTypeId();
return false; return false;
} }
auto assetMpType = asset->getData().mountingPointTypeId(); auto assetMpType = asset->getData().mountingPointTypeId;
auto mpType = mountingPoint->getData().mountingPointTypeId(); auto mpType = mountingPoint->getData().mountingPointTypeId;
if (!Settings::distinguishBetweenIndoorAndOutdoorIPS()) if (!Settings::distinguishBetweenIndoorAndOutdoorIPS())
{ {
if (assetMpType == MountingPointType::OutdoorIPS) if (assetMpType == MountingPointType::OutdoorIPS)
@@ -223,8 +223,8 @@ bool InfrastructureManagement::HandlerMountingPointAsset::mount(int32_t assetId,
{ {
WARNING_LOG(m_logger) << "Structure Element " << mountingPointId << " and asset " << assetId WARNING_LOG(m_logger) << "Structure Element " << mountingPointId << " and asset " << assetId
<< " - mouting point type id do not match: " << " - mouting point type id do not match: "
<< mountingPoint->getData().mountingPointTypeId() << " != " << mountingPoint->getData().mountingPointTypeId << " != "
<< asset->getData().mountingPointTypeId(); << asset->getData().mountingPointTypeId;
return false; return false;
} }
@@ -233,10 +233,10 @@ bool InfrastructureManagement::HandlerMountingPointAsset::mount(int32_t assetId,
MountingPointAsset data; MountingPointAsset data;
data.structureElementId(mountingPointId); data.structureElementId = mountingPointId;
data.assetId(assetId); data.assetId = assetId;
data.name(name.empty() ? asset->getName().toStdString() : name); data.name = (name.empty() ? asset->getName().toStdString() : name);
data.lastUpdated(QDateTime::currentMSecsSinceEpoch()); data.lastUpdated = QDateTime::currentMSecsSinceEpoch();
ObjectMountingPointAsset *newMountingPointAsset = new ObjectMountingPointAsset(m_mainHandler); ObjectMountingPointAsset *newMountingPointAsset = new ObjectMountingPointAsset(m_mainHandler);
@@ -252,7 +252,7 @@ bool InfrastructureManagement::HandlerMountingPointAsset::mount(int32_t assetId,
m_mainHandler->getHandlerInstrumentationAsset()->setAssetState(assetId, InstrumentationAssetState::Mounted); m_mainHandler->getHandlerInstrumentationAsset()->setAssetState(assetId, InstrumentationAssetState::Mounted);
m_objectMountingPointAssetMap.insert(newMountingPointAsset->getId(), newMountingPointAsset); m_objectMountingPointAssetMap.insert(newMountingPointAsset->getId(), newMountingPointAsset);
syncAvailableInExercise(data.structureElementId(), data.assetId()); syncAvailableInExercise(data.structureElementId, data.assetId);
return true; return true;
} }
@@ -42,8 +42,8 @@ bool HandlerSpecialArea::init()
return; return;
} }
m_objectSpecialAreaMap.insert(ifs->getId(), ifs); m_objectSpecialAreaMap.insert(ifs->getId(), ifs);
DEBUG_LOG(m_logger) << " id=" << ifs->getData().id() DEBUG_LOG(m_logger) << " id=" << ifs->getData().id
<< " name=" << ifs->getData().name(); << " name=" << ifs->getData().name;
}; };
// create Asset objects // create Asset objects
@@ -131,7 +131,7 @@ bool DatabaseInterfaceImplCustom::updateMountingPointPlan(int scheduleId, int mo
const QString tableName(getTableName(QStringLiteral("ism_mounting_point_plan"))); const QString tableName(getTableName(QStringLiteral("ism_mounting_point_plan")));
const QString stmt(QStringLiteral("UPDATE ") + tableName + const QString stmt(QStringLiteral("UPDATE ") + tableName +
QStringLiteral(" SET mounting_point_state = ") + QStringLiteral(" SET mounting_point_state = ") +
QString::number(mountingPointState.underlying()) + QString::number(static_cast<int>(mountingPointState)) +
QStringLiteral(" WHERE mounting_point_schedule_id = ") + QStringLiteral(" WHERE mounting_point_schedule_id = ") +
QString::number(scheduleId) + QString::number(scheduleId) +
QStringLiteral(" AND structure_element_id = ") + QStringLiteral(" AND structure_element_id = ") +
@@ -188,7 +188,7 @@ bool DatabaseInterfaceImplCustom::insertMountingPointPlans(const std::vector<Dat
{ {
m_query->bindValue(QStringLiteral(":mounting_point_schedule_id"), data.mountingPointScheduleId); m_query->bindValue(QStringLiteral(":mounting_point_schedule_id"), data.mountingPointScheduleId);
m_query->bindValue(QStringLiteral(":structure_element_id"), data.structureElementId); m_query->bindValue(QStringLiteral(":structure_element_id"), data.structureElementId);
m_query->bindValue(QStringLiteral(":mounting_point_state"), static_cast<int>(data.mountingPointState.underlying())); m_query->bindValue(QStringLiteral(":mounting_point_state"), static_cast<int>(data.mountingPointState));
if (!m_query->exec(m_bEmitMessageOnError)) if (!m_query->exec(m_bEmitMessageOnError))
{ {
m_lastError = m_query->lastError(); m_lastError = m_query->lastError();
@@ -160,13 +160,13 @@ void DtcImplCustom::updateStructureElementCache(const MainStructureElement &mse,
bIsVeryFirstCall = false; bIsVeryFirstCall = false;
} }
const std::vector<InfrastructureManagement::StructureElement>& ses = mse.elements(); const std::vector<InfrastructureManagement::StructureElement>& ses = mse.elements;
for (const auto &se : ses) for (const auto &se : ses)
{ {
if (modType==DataModification::eRemoved) if (modType==DataModification::eRemoved)
d->structureElementCache.remove(se.id()); d->structureElementCache.remove(se.id);
else else
d->structureElementCache[se.id()] = se; d->structureElementCache[se.id] = se;
} // for } // for
DEBUG_LOG(m_logger) << "ISM::StructureElementCache updateStructureElementCache, new size = " << d->structureElementCache.size(); DEBUG_LOG(m_logger) << "ISM::StructureElementCache updateStructureElementCache, new size = " << d->structureElementCache.size();
@@ -180,11 +180,11 @@ long DtcImplCustom::structureElementCacheSize() const
//--------------------------------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------------------------------
bool DtcImplCustom::isElementAssignedToExercise(const MainStructureElement &mse, int exerciseId) const bool DtcImplCustom::isElementAssignedToExercise(const MainStructureElement &mse, int exerciseId) const
{ {
const QJsonObject obj(LtsUtils::JsonObject::fromJson(mse.properties())); const QJsonObject obj(LtsUtils::JsonObject::fromJson(mse.properties));
auto it = obj.find(QStringLiteral("available_in_exercise")); auto it = obj.find(QStringLiteral("available_in_exercise"));
if (it == obj.end()) if (it == obj.end())
{ {
INFO_LOG(m_logger) << "Main structure element id " << mse.id() << ": Attribute \"available_in_exercise\" not found. Ignoring..."; INFO_LOG(m_logger) << "Main structure element id " << mse.id << ": Attribute \"available_in_exercise\" not found. Ignoring...";
return false; return false;
} }
@@ -192,7 +192,7 @@ bool DtcImplCustom::isElementAssignedToExercise(const MainStructureElement &mse,
if (std::any_of(arr.begin(), arr.end(), [exerciseId](const QJsonValue & val) { return val.isDouble() && exerciseId == val.toInt(); })) if (std::any_of(arr.begin(), arr.end(), [exerciseId](const QJsonValue & val) { return val.isDouble() && exerciseId == val.toInt(); }))
return true; return true;
INFO_LOG(m_logger) << "Main structure element id " << mse.id() << ": Not assigned (\"available_in_exercise\") to current exercise which has id " << exerciseId << ". Ignoring..."; INFO_LOG(m_logger) << "Main structure element id " << mse.id << ": Not assigned (\"available_in_exercise\") to current exercise which has id " << exerciseId << ". Ignoring...";
return false; return false;
} }
@@ -204,14 +204,14 @@ bool DtcImplCustom::getMountingPointAssetId(int structureElementId, int assetId,
for (const auto &sample : m_dtcMountingPointAsset->readAlive()) for (const auto &sample : m_dtcMountingPointAsset->readAlive())
{ {
DEBUG_LOG(m_logger) << "getMountingPointAssetId: " DEBUG_LOG(m_logger) << "getMountingPointAssetId: "
<< " sample.data().structureElementId()=" << sample.data().structureElementId() << " sample.data().structureElementId()=" << sample.data().structureElementId
<< " structureElementId=" << structureElementId << " structureElementId=" << structureElementId
<< " sample.data().assetId()=" << sample.data().assetId() << " sample.data().assetId()=" << sample.data().assetId
<< " assetId" << assetId; << " assetId" << assetId;
if ((sample.data().structureElementId() == structureElementId || structureElementId <= 0) && if ((sample.data().structureElementId == structureElementId || structureElementId <= 0) &&
(sample.data().assetId() == assetId || assetId <= 0)) (sample.data().assetId == assetId || assetId <= 0))
{ {
mountingPointAssetId = sample.data().id(); mountingPointAssetId = sample.data().id;
return true; return true;
} }
} }
@@ -228,12 +228,12 @@ bool DtcImplCustom::getAssetIdFromMountingPoint(int structureElementId, int moun
TRACE_LOG(m_logger) << "getAssetIdFromMountingPoint:" TRACE_LOG(m_logger) << "getAssetIdFromMountingPoint:"
<< " structureElementId=" << structureElementId << " structureElementId=" << structureElementId
<< " mountingPointAssetId=" << mountingPointAssetId << " mountingPointAssetId=" << mountingPointAssetId
<< " sample.data().id()=" << sample.data().id() << " sample.data().id()=" << sample.data().id
<< " sample.data().structureElementId()=" << sample.data().structureElementId() << " sample.data().structureElementId()=" << sample.data().structureElementId
<< " sample.data().assetId()=" << sample.data().assetId(); << " sample.data().assetId()=" << sample.data().assetId;
if (sample.data().structureElementId() == structureElementId) if (sample.data().structureElementId == structureElementId)
{ {
assetId = sample.data().assetId(); assetId = sample.data().assetId;
return true; return true;
} }
} }
@@ -267,15 +267,15 @@ int DtcImplCustom::getOpticalCodeFromAssetId(int assetId) const
for (const InfrastructureManagement::InstrumentationAsset &instrumentationAsset : m_dtcInstrumentationAsset->readAlive()) for (const InfrastructureManagement::InstrumentationAsset &instrumentationAsset : m_dtcInstrumentationAsset->readAlive())
{ {
DEBUG_LOG(m_logger) << "getAssetIdFromOpticalCode:" DEBUG_LOG(m_logger) << "getAssetIdFromOpticalCode:"
<< instrumentationAsset.properties(); << instrumentationAsset.properties;
if ((instrumentationAsset.mountingPointTypeId() == InfrastructureManagement::MountingPointType_def::IndoorIPS) if ((instrumentationAsset.mountingPointTypeId == InfrastructureManagement::MountingPointType::IndoorIPS)
|| (instrumentationAsset.mountingPointTypeId() == InfrastructureManagement::MountingPointType_def::OutdoorIPS)) || (instrumentationAsset.mountingPointTypeId == InfrastructureManagement::MountingPointType::OutdoorIPS))
{ {
DEBUG_LOG(m_logger) << "getOpticalCodeFromAsset:" DEBUG_LOG(m_logger) << "getOpticalCodeFromAsset:"
<< " assetId=" << instrumentationAsset.id() << " assetId=" << instrumentationAsset.id
<< " opticalCode=" << getOpsCodeFromJSon(instrumentationAsset.properties()); << " opticalCode=" << getOpsCodeFromJSon(instrumentationAsset.properties);
if (assetId == instrumentationAsset.id()) if (assetId == instrumentationAsset.id)
return getOpsCodeFromJSon(instrumentationAsset.properties()); return getOpsCodeFromJSon(instrumentationAsset.properties);
} }
} }
return assetId; return assetId;
@@ -292,15 +292,15 @@ int DtcImplCustom::getAssetIdFromOpticalCode(int opticalCode) const
for (const InfrastructureManagement::InstrumentationAsset &instrumentationAsset : m_dtcInstrumentationAsset->readAlive()) for (const InfrastructureManagement::InstrumentationAsset &instrumentationAsset : m_dtcInstrumentationAsset->readAlive())
{ {
DEBUG_LOG(m_logger) << "getAssetIdFromOpticalCode:" DEBUG_LOG(m_logger) << "getAssetIdFromOpticalCode:"
<< instrumentationAsset.properties(); << instrumentationAsset.properties;
if ((instrumentationAsset.mountingPointTypeId() == InfrastructureManagement::MountingPointType_def::IndoorIPS) if ((instrumentationAsset.mountingPointTypeId == InfrastructureManagement::MountingPointType::IndoorIPS)
|| (instrumentationAsset.mountingPointTypeId() == InfrastructureManagement::MountingPointType_def::OutdoorIPS)) || (instrumentationAsset.mountingPointTypeId == InfrastructureManagement::MountingPointType::OutdoorIPS))
{ {
DEBUG_LOG(m_logger) << "getAssetIdFromOpticalCode:" DEBUG_LOG(m_logger) << "getAssetIdFromOpticalCode:"
<< instrumentationAsset.properties(); << instrumentationAsset.properties;
int opticalCodeAsset = getOpsCodeFromJSon(instrumentationAsset.properties()); int opticalCodeAsset = getOpsCodeFromJSon(instrumentationAsset.properties);
if (opticalCodeAsset == opticalCode) if (opticalCodeAsset == opticalCode)
return instrumentationAsset.id(); return instrumentationAsset.id;
} }
} }
return assetId; return assetId;
@@ -313,16 +313,16 @@ int DtcImplCustom::getAssetIdFromMountingPointId(int mainStructureElementId, in
for (const auto &sample : m_dtcMainStructureElement->readAlive()) for (const auto &sample : m_dtcMainStructureElement->readAlive())
{ {
if (sample.data().id() != mainStructureElementId) if (sample.data().id != mainStructureElementId)
continue; continue;
for (const StructureElement &elem : sample.data().elements()) for (const StructureElement &elem : sample.data().elements)
{ {
DEBUG_LOG(m_logger) << "elem.id=" << elem.id() DEBUG_LOG(m_logger) << "elem.id=" << elem.id
<< " elem.mountingPointId=" << elem.mountingPointId(); << " elem.mountingPointId=" << elem.mountingPointId;
if (elem.mountingPointId() == mountingPointId) if (elem.mountingPointId == mountingPointId)
{ {
return (getMountedAssetId(elem.id())); return (getMountedAssetId(elem.id));
} }
} }
} }
@@ -339,19 +339,19 @@ bool DtcImplCustom::getOpsDataFromMseIdAndSeId(int mainStructureElementId, int s
<< " structureElementId=" << structureElementId; << " structureElementId=" << structureElementId;
for (const auto &sample : m_dtcMainStructureElement->readAlive()) for (const auto &sample : m_dtcMainStructureElement->readAlive())
{ {
if (sample.data().id() != mainStructureElementId) if (sample.data().id != mainStructureElementId)
continue; continue;
for (const StructureElement &elem : sample.data().elements()) for (const StructureElement &elem : sample.data().elements)
{ {
DEBUG_LOG(m_logger) << "elem.id=" << elem.id() DEBUG_LOG(m_logger) << "elem.id=" << elem.id
<< " elem.mountingPointId=" << elem.mountingPointId() << " elem.mountingPointId=" << elem.mountingPointId
<< " elem.path().size=" << elem.path().size(); << " elem.path().size=" << elem.path.size();
if (elem.id() == structureElementId) if (elem.id == structureElementId)
{ {
if (elem.path().size() > 1) if (elem.path.size() > 1)
roomId = elem.path().at(elem.path().size() - 2); roomId = elem.path.at(elem.path.size() - 2);
geoPosition = elem.geoPosition(); geoPosition = elem.geoPosition;
return true; return true;
} }
} }
@@ -409,9 +409,9 @@ bool DtcImplCustom::getStructureElementById(int structureElementId, StructureEle
// fallback: old approach // fallback: old approach
for (const auto &sample : m_dtcMainStructureElement->readAlive()) for (const auto &sample : m_dtcMainStructureElement->readAlive())
{ {
for (const StructureElement &elem : sample.data().elements()) for (const StructureElement &elem : sample.data().elements)
{ {
if (elem.id() == structureElementId) if (elem.id == structureElementId)
{ {
structureElement = elem; structureElement = elem;
return true; return true;
@@ -428,9 +428,9 @@ bool DtcImplCustom::getStructureElementInMntPointAssetByAssetId(int assetId, Str
int structureElementId = 0; int structureElementId = 0;
for (const auto &sample : m_dtcMountingPointAsset->readAlive()) for (const auto &sample : m_dtcMountingPointAsset->readAlive())
{ {
if (sample.data().assetId() == assetId) if (sample.data().assetId == assetId)
{ {
structureElementId = sample.data().structureElementId(); structureElementId = sample.data().structureElementId;
break; break;
} }
} }
@@ -440,9 +440,9 @@ bool DtcImplCustom::getStructureElementInMntPointAssetByAssetId(int assetId, Str
for (const auto &sample : m_dtcMainStructureElement->readAlive()) for (const auto &sample : m_dtcMainStructureElement->readAlive())
{ {
for (const StructureElement &elem : sample.data().elements()) for (const StructureElement &elem : sample.data().elements)
{ {
if (elem.id() == structureElementId) if (elem.id == structureElementId)
{ {
structureElement = elem; structureElement = elem;
return true; return true;
@@ -457,12 +457,12 @@ bool DtcImplCustom::getStructureElementByBuildingIdAndMountingPointId(int mainSt
{ {
for (const auto &sample : m_dtcMainStructureElement->readAlive()) for (const auto &sample : m_dtcMainStructureElement->readAlive())
{ {
if (sample.data().id() != mainStructureElementId) if (sample.data().id != mainStructureElementId)
continue; continue;
for (const StructureElement &elem : sample.data().elements()) for (const StructureElement &elem : sample.data().elements)
{ {
if (elem.mountingPointId() == mountingPointId) if (elem.mountingPointId == mountingPointId)
{ {
structureElement = elem; structureElement = elem;
return true; return true;
@@ -488,35 +488,35 @@ bool DtcImplCustom::getAllAssetsPerRoom(const std::function<bool(const Instrumen
dds::sub::LoanedSamples<DATA_A> samples_a = m_dtcInstrumentationAsset->readAlive(); dds::sub::LoanedSamples<DATA_A> samples_a = m_dtcInstrumentationAsset->readAlive();
std::unordered_map<int, LOANED_DATA_A> assetMap; std::unordered_map<int, LOANED_DATA_A> assetMap;
for (const LOANED_DATA_A &asset : samples_a) for (const LOANED_DATA_A &asset : samples_a)
assetMap.insert(std::make_pair(asset.data().id(), asset)); assetMap.insert(std::make_pair(asset.data().id, asset));
dds::sub::LoanedSamples<DATA_MSE> samples_mse = m_dtcMainStructureElement->readAlive(); dds::sub::LoanedSamples<DATA_MSE> samples_mse = m_dtcMainStructureElement->readAlive();
std::unordered_map<int, InfrastructureManagement::StructureElement> structElementMap; std::unordered_map<int, InfrastructureManagement::StructureElement> structElementMap;
for (const LOANED_DATA_MSE &mse : samples_mse) for (const LOANED_DATA_MSE &mse : samples_mse)
for (const auto &se : mse.data().elements()) for (const auto &se : mse.data().elements)
structElementMap.insert(std::make_pair(se.id(), se)); structElementMap.insert(std::make_pair(se.id, se));
dds::sub::LoanedSamples<DATA_MPA> samples_mpa = m_dtcMountingPointAsset->readAlive(); dds::sub::LoanedSamples<DATA_MPA> samples_mpa = m_dtcMountingPointAsset->readAlive();
for (const LOANED_DATA_MPA &mpa : samples_mpa) for (const LOANED_DATA_MPA &mpa : samples_mpa)
{ {
const int assetId = mpa.data().assetId(); const int assetId = mpa.data().assetId;
const auto assetIt = assetMap.find(assetId); const auto assetIt = assetMap.find(assetId);
if (assetIt == assetMap.end()) if (assetIt == assetMap.end())
continue; continue;
if (!predicate(assetIt->second)) if (!predicate(assetIt->second))
continue; continue;
const int structureElementId = mpa.data().structureElementId(); const int structureElementId = mpa.data().structureElementId;
const auto structureElementIt = structElementMap.find(structureElementId); const auto structureElementIt = structElementMap.find(structureElementId);
if (structureElementIt == structElementMap.end()) if (structureElementIt == structElementMap.end())
continue; continue;
const InfrastructureManagement::StructureElement &se = structureElementIt->second; const InfrastructureManagement::StructureElement &se = structureElementIt->second;
if (se.structureElementTypeId() != InfrastructureManagement::StructureElementType::MountingPoint) if (se.structureElementTypeId != InfrastructureManagement::StructureElementType::MountingPoint)
continue; continue;
int roomId = 0; int roomId = 0;
if (se.path().size() > 1) if (se.path.size() > 1)
roomId = se.path().at(se.path().size() - 2); roomId = se.path.at(se.path.size() - 2);
allAssets[roomId].push_back(assetIt->second); allAssets[roomId].push_back(assetIt->second);
} }
return true; return true;
@@ -535,12 +535,12 @@ bool DtcImplCustom::getAllAssetsPerBuilding(const std::function<bool(const Instr
dds::sub::LoanedSamples<DATA_A> samples_a = m_dtcInstrumentationAsset->readAlive(); dds::sub::LoanedSamples<DATA_A> samples_a = m_dtcInstrumentationAsset->readAlive();
std::unordered_map<int, LOANED_DATA_A> assetMap; std::unordered_map<int, LOANED_DATA_A> assetMap;
for (const LOANED_DATA_A &asset : samples_a) for (const LOANED_DATA_A &asset : samples_a)
assetMap.insert(std::make_pair(asset.data().id(), asset)); assetMap.insert(std::make_pair(asset.data().id, asset));
dds::sub::LoanedSamples<DATA_MPA> samples_mpa = m_dtcMountingPointAsset->readAlive(); dds::sub::LoanedSamples<DATA_MPA> samples_mpa = m_dtcMountingPointAsset->readAlive();
for (const LOANED_DATA_MPA &mpa : samples_mpa) for (const LOANED_DATA_MPA &mpa : samples_mpa)
{ {
const int assetId = mpa.data().assetId(); const int assetId = mpa.data().assetId;
DEBUG_LOG(m_logger) << "Found assetId = " << assetId; DEBUG_LOG(m_logger) << "Found assetId = " << assetId;
const auto assetIt = assetMap.find(assetId); const auto assetIt = assetMap.find(assetId);
if (assetIt == assetMap.end()) if (assetIt == assetMap.end())
@@ -548,7 +548,7 @@ bool DtcImplCustom::getAllAssetsPerBuilding(const std::function<bool(const Instr
if (!predicate(assetIt->second)) if (!predicate(assetIt->second))
continue; continue;
const int structureElementId = mpa.data().structureElementId(); const int structureElementId = mpa.data().structureElementId;
int buildingId = 0; int buildingId = 0;
if (getBuildingId(structureElementId, buildingId)) if (getBuildingId(structureElementId, buildingId))
{ {
@@ -566,11 +566,11 @@ bool DtcImplCustom::getBuildingId(int structureElementId, int &buildingId) const
{ {
for (const auto &sample : m_dtcMainStructureElement->readAlive()) for (const auto &sample : m_dtcMainStructureElement->readAlive())
{ {
for (const auto &se : sample.data().elements()) for (const auto &se : sample.data().elements)
{ {
if (se.id() == structureElementId) if (se.id == structureElementId)
{ {
buildingId = sample.data().id(); buildingId = sample.data().id;
return true; return true;
} }
} }
@@ -585,8 +585,8 @@ QList<int> DtcImplCustom::getSections()
QList<int> sections; QList<int> sections;
for (const auto &sample : m_dtcMainStructureElement->readAlive()) for (const auto &sample : m_dtcMainStructureElement->readAlive())
{ {
if (!sections.contains(sample.data().groupId())) if (!sections.contains(sample.data().groupId))
sections.append(sample.data().groupId()); sections.append(sample.data().groupId);
} }
return sections; return sections;
} }
@@ -600,16 +600,16 @@ QString DtcImplCustom::getBuildingDisplayName(int buildingId)
//--------------------------------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------------------------------
QString DtcImplCustom::getBuildingDisplayName(const MainStructureElement &mse) const QString DtcImplCustom::getBuildingDisplayName(const MainStructureElement &mse) const
{ {
for (const StructureElement &elem : mse.elements()) for (const StructureElement &elem : mse.elements)
{ {
if ((elem.structureElementTypeId() == InfrastructureManagement::StructureElementType::Building) || if ((elem.structureElementTypeId == InfrastructureManagement::StructureElementType::Building) ||
(elem.structureElementTypeId() == InfrastructureManagement::StructureElementType::Bridge)) (elem.structureElementTypeId == InfrastructureManagement::StructureElementType::Bridge))
{ {
if (elem.displayName().size() > 0) if (elem.displayName.size() > 0)
return QString::fromStdString(elem.displayName()); return QString::fromStdString(elem.displayName);
} }
} }
return QString::fromStdString(mse.name()); return QString::fromStdString(mse.name);
} }
@@ -617,11 +617,11 @@ MountingPointPlan DtcImplCustom::getMountingPointPlan(int scheduleId, int struct
{ {
for (const auto &sample : m_dtcMainSchedule->readAlive()) for (const auto &sample : m_dtcMainSchedule->readAlive())
{ {
if (sample.data().id() == scheduleId) if (sample.data().id == scheduleId)
{ {
for (auto &mpp : sample.data().elements()) for (auto &mpp : sample.data().elements)
{ {
if (mpp.structureElementId() == structureElementId) if (mpp.structureElementId == structureElementId)
return mpp; return mpp;
} }
} }
@@ -634,11 +634,11 @@ int DtcImplCustom::getBuildingRoomsCount(int buildingId)
{ {
int roomCount = 0; int roomCount = 0;
const MainStructureElement mse = mainStructureElement(buildingId); const MainStructureElement mse = mainStructureElement(buildingId);
if (mse.id() > 0) if (mse.id > 0)
{ {
for (const StructureElement &elem : mse.elements()) for (const StructureElement &elem : mse.elements)
{ {
if (elem.structureElementTypeId() == InfrastructureManagement::StructureElementType::Room) if (elem.structureElementTypeId == InfrastructureManagement::StructureElementType::Room)
roomCount++; roomCount++;
} }
} }
@@ -650,9 +650,9 @@ BridgeStatus DtcImplCustom::getBridgeStatus(int buildingId)
{ {
BridgeStatus ret = BridgeStatus::Intact; BridgeStatus ret = BridgeStatus::Intact;
const MainStructureElement mse = mainStructureElement(buildingId); const MainStructureElement mse = mainStructureElement(buildingId);
if (mse.id() > 0 && mse.structureElementTypeId() == StructureElementType::Bridge) if (mse.id > 0 && mse.structureElementTypeId == StructureElementType::Bridge)
{ {
const QJsonObject obj(LtsUtils::JsonObject::fromJson(mse.properties())); const QJsonObject obj(LtsUtils::JsonObject::fromJson(mse.properties));
auto it = obj.find(QStringLiteral("bridgeStatus")); auto it = obj.find(QStringLiteral("bridgeStatus"));
if (it == obj.end()) if (it == obj.end())
return ret; return ret;
@@ -668,14 +668,14 @@ BridgeStatus DtcImplCustom::getBridgeStatus(int buildingId)
bool DtcImplCustom::checkSchedule(int scheduleId) bool DtcImplCustom::checkSchedule(int scheduleId)
{ {
const MainSchedule schedule = mainSchedule(scheduleId); const MainSchedule schedule = mainSchedule(scheduleId);
for (const MountingPointPlan &mpp : schedule.elements()) // for (const MountingPointPlan &mpp : schedule.elements) //
{ {
if (mpp.mountingPointState() == MountingPointState::Idle) // whatever mounted or unmounted should be ok ? if (mpp.mountingPointState == MountingPointState::Idle) // whatever mounted or unmounted should be ok ?
continue; continue;
int assetId = getMountedAssetId(mpp.structureElementId()); int assetId = getMountedAssetId(mpp.structureElementId);
if (mpp.mountingPointState() == MountingPointState::Empty && assetId != -1) //mounted, but it should be empty if (mpp.mountingPointState == MountingPointState::Empty && assetId != -1) //mounted, but it should be empty
return false; return false;
else if (mpp.mountingPointState() == MountingPointState::Equipped && assetId == -1) // not mounted, but it should be else if (mpp.mountingPointState == MountingPointState::Equipped && assetId == -1) // not mounted, but it should be
return false; return false;
} }
return true; return true;
@@ -686,14 +686,14 @@ bool DtcImplCustom::checkSchedule(int scheduleId)
bool DtcImplCustom::getScheduleDifferences(int scheduleId, QList<MountingPointPlan> &diffList) bool DtcImplCustom::getScheduleDifferences(int scheduleId, QList<MountingPointPlan> &diffList)
{ {
const MainSchedule schedule = mainSchedule(scheduleId); const MainSchedule schedule = mainSchedule(scheduleId);
for (const MountingPointPlan &mpp : schedule.elements()) // for (const MountingPointPlan &mpp : schedule.elements) //
{ {
if (mpp.mountingPointState() == MountingPointState::Idle) // whatever mounted or unmounted should be ok ? if (mpp.mountingPointState == MountingPointState::Idle) // whatever mounted or unmounted should be ok ?
continue; continue;
int assetId = getMountedAssetId(mpp.structureElementId()); int assetId = getMountedAssetId(mpp.structureElementId);
if (mpp.mountingPointState() == MountingPointState::Empty && assetId != -1) //mounted, but it should be empty if (mpp.mountingPointState == MountingPointState::Empty && assetId != -1) //mounted, but it should be empty
diffList.append(mpp); diffList.append(mpp);
else if (mpp.mountingPointState() == MountingPointState::Equipped && assetId == -1) // not mounted, but it should be else if (mpp.mountingPointState == MountingPointState::Equipped && assetId == -1) // not mounted, but it should be
diffList.append(mpp); diffList.append(mpp);
} }
return diffList.isEmpty(); return diffList.isEmpty();
@@ -714,8 +714,8 @@ int DtcImplCustom::getMountedAssetId(int structureElementId) const
dds::sub::LoanedSamples<DATA_MPA> samples_mpa = m_dtcMountingPointAsset->readAlive(); dds::sub::LoanedSamples<DATA_MPA> samples_mpa = m_dtcMountingPointAsset->readAlive();
for (const LOANED_DATA_MPA &mpa : samples_mpa) for (const LOANED_DATA_MPA &mpa : samples_mpa)
{ {
if (mpa.data().structureElementId() == structureElementId) if (mpa.data().structureElementId == structureElementId)
return mpa.data().assetId(); return mpa.data().assetId;
} }
return -1; return -1;
} }
@@ -730,11 +730,11 @@ int DtcImplCustom::getStructueElementIdFromAssetId(int assetId) const
dds::sub::LoanedSamples<DATA_MPA> samples_mpa = m_dtcMountingPointAsset->readAlive(); dds::sub::LoanedSamples<DATA_MPA> samples_mpa = m_dtcMountingPointAsset->readAlive();
for (const LOANED_DATA_MPA &mpa : samples_mpa) for (const LOANED_DATA_MPA &mpa : samples_mpa)
{ {
DEBUG_LOG(m_logger) << "mpa.data().assetId()=" << mpa.data().assetId() DEBUG_LOG(m_logger) << "mpa.data().assetId()=" << mpa.data().assetId
<< " assetId=" << assetId << " assetId=" << assetId
<< " mpa.data().structureElementId()=" << mpa.data().structureElementId(); << " mpa.data().structureElementId()=" << mpa.data().structureElementId;
if (mpa.data().assetId() == assetId) if (mpa.data().assetId == assetId)
return mpa.data().structureElementId(); return mpa.data().structureElementId;
} }
return -1; return -1;
} }
@@ -747,7 +747,7 @@ QMap<int, MainFootprint> DtcImplCustom::getFootprintsByExerciseId(int exerciseId
const auto &buildings = mainStructureElements(); const auto &buildings = mainStructureElements();
for (const auto &building : buildings) for (const auto &building : buildings)
{ {
int mseId = building.id(); int mseId = building.id;
if (isElementAssignedToExercise(building, exerciseId)) if (isElementAssignedToExercise(building, exerciseId))
footprints.insert(mseId, mainFootprint(mseId)); footprints.insert(mseId, mainFootprint(mseId));
} }
@@ -763,16 +763,16 @@ QMap<int, QPolygonF> DtcImplCustom::getUtmFootprintsByExerciseId(int exerciseId,
const auto &buildings = mainStructureElements(); const auto &buildings = mainStructureElements();
for (const auto &building : buildings) for (const auto &building : buildings)
{ {
const int mseId = building.id(); const int mseId = building.id;
const MainStructureElement &mse = mainStructureElement(mseId); const MainStructureElement &mse = mainStructureElement(mseId);
DEBUG_LOG(m_logger) << "mseId: " << mseId; DEBUG_LOG(m_logger) << "mseId: " << mseId;
if (isElementAssignedToExercise(building, exerciseId)) if (isElementAssignedToExercise(building, exerciseId))
{ {
// skip Bridges: // skip Bridges:
const std::vector<InfrastructureManagement::StructureElement> &elementsRef = mse.elements(); const std::vector<InfrastructureManagement::StructureElement> &elementsRef = mse.elements;
// per definition, frontElement contains StructureElementType: // per definition, frontElement contains StructureElementType:
if (elementsRef.empty() || if (elementsRef.empty() ||
(elementsRef.front().structureElementTypeId() != InfrastructureManagement::StructureElementType_def::Building) (elementsRef.front().structureElementTypeId != InfrastructureManagement::StructureElementType::Building)
) )
{ {
DEBUG_LOG(m_logger) << "Footprint: " << mseId << ", skip due to StructureElementType != Building"; DEBUG_LOG(m_logger) << "Footprint: " << mseId << ", skip due to StructureElementType != Building";
@@ -1031,13 +1031,13 @@ QVector <int> DtcImplCustom::getFloorIdsFromBuilding(int buildingId)
QList <StructureElement> floors = getFloorsFromBuilding(buildingId); QList <StructureElement> floors = getFloorsFromBuilding(buildingId);
floorIds.reserve(floors.size()); floorIds.reserve(floors.size());
for (int i = 0; i < floors.size(); i++) for (int i = 0; i < floors.size(); i++)
floorIds.append(floors.at(i).id()); floorIds.append(floors.at(i).id);
return floorIds; return floorIds;
} }
bool structureElementHeightComparator(const StructureElement &a, const StructureElement &b) bool structureElementHeightComparator(const StructureElement &a, const StructureElement &b)
{ {
return a.relPosition().offsetZ() < b.relPosition().offsetZ(); return a.relPosition.offsetZ < b.relPosition.offsetZ;
} }
QList <StructureElement> DtcImplCustom::getFloorsFromBuilding(int buildingId) QList <StructureElement> DtcImplCustom::getFloorsFromBuilding(int buildingId)
@@ -1045,15 +1045,15 @@ QList <StructureElement> DtcImplCustom::getFloorsFromBuilding(int buildingId)
QList <StructureElement> floors; QList <StructureElement> floors;
const MainStructureElement mse = mainStructureElement(buildingId); const MainStructureElement mse = mainStructureElement(buildingId);
// Determine all floor heights // Determine all floor heights
if (mse.id() > 0) if (mse.id > 0)
{ {
for (const StructureElement &elem : mse.elements()) for (const StructureElement &elem : mse.elements)
{ {
if (elem.structureElementTypeId() == InfrastructureManagement::StructureElementType::Floor) if (elem.structureElementTypeId == InfrastructureManagement::StructureElementType::Floor)
{ {
DEBUG_LOG(m_logger) << "getFloorsFromBuilding append " DEBUG_LOG(m_logger) << "getFloorsFromBuilding append "
<< " id=" << elem.id() << " id=" << elem.id
<< " Z=" << elem.relPosition().offsetZ(); << " Z=" << elem.relPosition.offsetZ;
floors.append(elem); floors.append(elem);
} }
} }
@@ -1076,14 +1076,14 @@ double DtcImplCustom::getHalfFloorHeight(int buildingId, int floorId)
for (int i = 0; i < floorHeights.size(); i++) for (int i = 0; i < floorHeights.size(); i++)
{ {
DEBUG_LOG(m_logger) << "i=" << i DEBUG_LOG(m_logger) << "i=" << i
<< " id= " << floorHeights[i].id() << " id= " << floorHeights[i].id
<< " offsetZ()=" << floorHeights[i].relPosition().offsetZ(); << " offsetZ()=" << floorHeights[i].relPosition.offsetZ;
if (floorHeights[i].id() == floorId) if (floorHeights[i].id == floorId)
{ {
if (floorHeights.size() > i + 1) if (floorHeights.size() > i + 1)
return (floorHeights[i].relPosition().offsetZ() + floorHeights[i + 1].relPosition().offsetZ()) / 2.0; return (floorHeights[i].relPosition.offsetZ + floorHeights[i + 1].relPosition.offsetZ) / 2.0;
else else
return floorHeights[i].relPosition().offsetZ() + 2.0; return floorHeights[i].relPosition.offsetZ + 2.0;
} }
} }
@@ -1098,19 +1098,19 @@ QVector <int> DtcImplCustom::getRoomIdsFromFloorId(int buildingId, int floorId)
QVector <int> rooms; QVector <int> rooms;
const MainStructureElement mse = mainStructureElement(buildingId); const MainStructureElement mse = mainStructureElement(buildingId);
rooms.reserve(mse.elements().size()); rooms.reserve(mse.elements.size());
// Determine all floor heights // Determine all floor heights
if (mse.id() > 0) if (mse.id > 0)
{ {
for (const StructureElement &elem : mse.elements()) for (const StructureElement &elem : mse.elements)
{ {
std::vector< int32_t > path = elem.path(); std::vector< int32_t > path = elem.path;
if (std::find(path.begin(), path.end(), floorId) != path.end()) if (std::find(path.begin(), path.end(), floorId) != path.end())
if (elem.structureElementTypeId() == InfrastructureManagement::StructureElementType::Room) if (elem.structureElementTypeId == InfrastructureManagement::StructureElementType::Room)
{ {
DEBUG_LOG(m_logger) << " rooms.append=" << elem.id(); DEBUG_LOG(m_logger) << " rooms.append=" << elem.id;
rooms.append(elem.id()); rooms.append(elem.id);
} }
} }
} }
@@ -1126,7 +1126,7 @@ QVector <int> DtcImplCustom::getBuildingIdsByExercise ( int exerciseId)
for (const auto &building : buildings) for (const auto &building : buildings)
{ {
if (isElementAssignedToExercise(building, exerciseId)) if (isElementAssignedToExercise(building, exerciseId))
result.append(building.id()); result.append(building.id);
} }
return result; return result;
@@ -1135,14 +1135,14 @@ QVector <int> DtcImplCustom::getBuildingIdsByExercise ( int exerciseId)
QByteArray DtcImplCustom::getVulnerabilityModelData( int buildingId) QByteArray DtcImplCustom::getVulnerabilityModelData( int buildingId)
{ {
const MainStructureElement &mse = mainStructureElement(buildingId); const MainStructureElement &mse = mainStructureElement(buildingId);
if (mse.id() != buildingId) if (mse.id != buildingId)
{ {
WARNING_LOG(m_logger) << "mainStructureElement not found, id/buildingId = " << buildingId; WARNING_LOG(m_logger) << "mainStructureElement not found, id/buildingId = " << buildingId;
return {}; return {};
} }
static const QString optPath = QStringLiteral("/opt/BuildingModels/StaticMeshes/"); static const QString optPath = QStringLiteral("/opt/BuildingModels/StaticMeshes/");
const QString &vulnerabilityModelFilename = optPath + QStringLiteral("%1.flt.VWM_Building.xml").arg(QString::fromStdString(mse.name())); const QString &vulnerabilityModelFilename = optPath + QStringLiteral("%1.flt.VWM_Building.xml").arg(QString::fromStdString(mse.name));
QFile f(vulnerabilityModelFilename); QFile f(vulnerabilityModelFilename);
if (!f.open(QIODevice::ReadOnly)) if (!f.open(QIODevice::ReadOnly))
@@ -48,31 +48,31 @@ public:
return true; return true;
const MainStructureElement &mse = m_dtcCustom->mainStructureElement(mseId); const MainStructureElement &mse = m_dtcCustom->mainStructureElement(mseId);
if (mse.id() != mseId) if (mse.id != mseId)
return false; return false;
const MainFootprint &mf = m_dtcCustom->mainFootprint(mseId); const MainFootprint &mf = m_dtcCustom->mainFootprint(mseId);
if (mf.id() != mseId) if (mf.id != mseId)
return {}; return {};
// determine the zone (using the mse.geoPosition()) // determine the zone (using the mse.geoPosition())
const auto &utm = LtsCoordTrans::UtmCoordinate::fromGeographic(QPointF(mse.geoPosition().lon(), mse.geoPosition().lat())); const auto &utm = LtsCoordTrans::UtmCoordinate::fromGeographic(QPointF(mse.geoPosition.lon, mse.geoPosition.lat));
zoneOut = utm.zone; zoneOut = utm.zone;
// //
// get all elements according m_isGroundLevel // get all elements according m_isGroundLevel
// //
// relative: // relative:
const std::vector<InfrastructureManagement::FootprintElement> &mfElements = mf.elements(); const std::vector<InfrastructureManagement::FootprintElement> &mfElements = mf.elements;
QPolygonF poly; QPolygonF poly;
poly.reserve(mfElements.size()); poly.reserve(mfElements.size());
for (const InfrastructureManagement::FootprintElement &element : qAsConst(mfElements)) for (const InfrastructureManagement::FootprintElement &element : qAsConst(mfElements))
{ {
// if different, continue // if different, continue
if (isGroundLevel != element.isGroundLevel()) if (isGroundLevel != element.isGroundLevel)
continue; continue;
const auto &relPos = element.relPosition(); const auto &relPos = element.relPosition;
poly.push_back(QPointF(relPos.offsetX(), relPos.offsetY())); poly.push_back(QPointF(relPos.offsetX, relPos.offsetY));
} }
// Get other footprint if groundLevel footprint is not available // Get other footprint if groundLevel footprint is not available
@@ -80,8 +80,8 @@ public:
{ {
for (const InfrastructureManagement::FootprintElement &element : qAsConst(mfElements)) for (const InfrastructureManagement::FootprintElement &element : qAsConst(mfElements))
{ {
const auto &relPos = element.relPosition(); const auto &relPos = element.relPosition;
poly.push_back(QPointF(relPos.offsetX(), relPos.offsetY())); poly.push_back(QPointF(relPos.offsetX, relPos.offsetY));
} }
} }
@@ -111,7 +111,7 @@ public:
// rotate,and translate poly // rotate,and translate poly
QTransform trans; QTransform trans;
trans.translate(utm.x, utm.y); trans.translate(utm.x, utm.y);
trans.rotate(mse.angle()); trans.rotate(mse.angle);
poly = trans.map(poly); poly = trans.map(poly);
// finally: store in cache // finally: store in cache
@@ -148,7 +148,7 @@ bool MainHandler::init(int domainId)
INFO_LOG(m_logger) << "ISM MainHandler initialized."; INFO_LOG(m_logger) << "ISM MainHandler initialized.";
pm->setNewState(Core::RunningState::Running); pm->setNewState(Core::RunningState::Running);
pm->addPort(m_handlerWebSocketInterface->webSocketPort(), Core::PortType::WebSocketServer); pm->addPort(m_handlerWebSocketInterface->webSocketPort(), Core::CorePortType::WebSocketServer);
return true; return true;
} // end of init() } // end of init()
@@ -27,36 +27,36 @@ ObjectEffectArea::~ObjectEffectArea()
Core::FunctionReplyObject ObjectEffectArea::createObject(const EffectArea &data) Core::FunctionReplyObject ObjectEffectArea::createObject(const EffectArea &data)
{ {
m_data = data; m_data = data;
m_data.name("Sound Area " + std::to_string(m_data.id())); m_data.name = "Sound Area " + std::to_string(m_data.id);
onPublishData(); // publish data via DDS onPublishData(); // publish data via DDS
return Core::FunctionReplyObject(m_data.id()); return Core::FunctionReplyObject(m_data.id);
} }
Core::FunctionReplyObject ObjectEffectArea::updateObject(const EffectArea &data) Core::FunctionReplyObject ObjectEffectArea::updateObject(const EffectArea &data)
{ {
m_data = data; m_data = data;
DEBUG_LOG(m_logger) << "Data changed for Id: " << m_data.id(); DEBUG_LOG(m_logger) << "Data changed for Id: " << m_data.id;
onPublishData(); // publish data via DTS onPublishData(); // publish data via DTS
return Core::FunctionReplyObject(m_data.id()); return Core::FunctionReplyObject(m_data.id);
} }
Core::FunctionReplyObject ObjectEffectArea::removeObject() Core::FunctionReplyObject ObjectEffectArea::removeObject()
{ {
if (!dts()->removeEffectAreaByKey(m_data.id())) if (!dts()->removeEffectAreaByKey(m_data.id))
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "EffectArea with id %1 can not be removed from DDS")).arg(m_data.id()); return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "EffectArea with id %1 can not be removed from DDS")).arg(m_data.id);
return Core::FunctionReplyObject(m_data.id()); return Core::FunctionReplyObject(m_data.id);
} }
//----------------------------------------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------------------------------------
void ObjectEffectArea::onPublishData() void ObjectEffectArea::onPublishData()
{ {
INFO_LOG(m_logger) << "Publish IsmEffectArea-data to dds (" << m_data.id() << ") ..."; INFO_LOG(m_logger) << "Publish IsmEffectArea-data to dds (" << m_data.id << ") ...";
if (!dts()->publish(m_data)) if (!dts()->publish(m_data))
ERROR_LOG(m_logger) << "Error publishing IsmEffectArea-data to dds"; ERROR_LOG(m_logger) << "Error publishing IsmEffectArea-data to dds";
@@ -29,10 +29,10 @@ public:
Core::FunctionReplyObject updateObject(const EffectArea &data); Core::FunctionReplyObject updateObject(const EffectArea &data);
Core::FunctionReplyObject removeObject(); Core::FunctionReplyObject removeObject();
int32_t getId() const { return m_data.id(); } int32_t getId() const { return m_data.id; }
int32_t getAreaEgcuId() const { return m_data.areaEgcuId(); } int32_t getAreaEgcuId() const { return m_data.areaEgcuId; }
std::vector<int32_t> getEgcuIds() const { return m_data.egcuIds(); } std::vector<int32_t> getEgcuIds() const { return m_data.egcuIds; }
std::vector<Core::GeoPosition2D> getGeometry() const { return m_data.geometry(); } std::vector<Core::GeoPosition2D> getGeometry() const { return m_data.geometry; }
EffectArea getData() const { return m_data; } EffectArea getData() const { return m_data; }
protected: protected:
@@ -25,13 +25,13 @@ ObjectInstrumentationAsset::~ObjectInstrumentationAsset()
//------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------
bool ObjectInstrumentationAsset::isValid() const bool ObjectInstrumentationAsset::isValid() const
{ {
return m_data.id() > 0; return m_data.id > 0;
} }
//------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------
bool ObjectInstrumentationAsset::isUsed() const bool ObjectInstrumentationAsset::isUsed() const
{ {
return m_data.isUsed(); return m_data.isUsed;
} }
//------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------
@@ -39,9 +39,9 @@ Core::FunctionReplyObject ObjectInstrumentationAsset::createObject(const Instrum
{ {
m_data = data; m_data = data;
if (m_data.id() <= 0) if (m_data.id <= 0)
{ {
m_data.isUsed(false); m_data.isUsed = false;
Database::IsmAsset dbData; Database::IsmAsset dbData;
dbData = toDbData(data); dbData = toDbData(data);
@@ -50,64 +50,64 @@ Core::FunctionReplyObject ObjectInstrumentationAsset::createObject(const Instrum
if (!db()->insert(dbData)) if (!db()->insert(dbData))
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting IsmAsset-data into database")); return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting IsmAsset-data into database"));
m_data.id(dbData.id); m_data.id = dbData.id;
DEBUG_LOG(m_logger) << "New Id: " << m_data.id(); DEBUG_LOG(m_logger) << "New Id: " << m_data.id;
} }
// Publish Data via DTS // Publish Data via DTS
onPublishData(); onPublishData();
return Core::FunctionReplyObject(m_data.id()); return Core::FunctionReplyObject(m_data.id);
} }
//------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------
Core::FunctionReplyObject ObjectInstrumentationAsset::updateObject(const InstrumentationAsset &data) Core::FunctionReplyObject ObjectInstrumentationAsset::updateObject(const InstrumentationAsset &data)
{ {
if (!isValid()) if (!isValid())
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Object not valid/blocked")); return Core::FunctionReplyObject(data.id, tr_lts("dds", "Object not valid/blocked"));
Database::IsmAsset dbData; Database::IsmAsset dbData;
dbData = toDbData(data); dbData = toDbData(data);
if (!db()->update(dbData)) if (!db()->update(dbData))
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Error updating IsmAsset-data into database")); return Core::FunctionReplyObject(data.id, tr_lts("dds", "Error updating IsmAsset-data into database"));
m_data = data; m_data = data;
DEBUG_LOG(m_logger) << "Data changed for Id: " << m_data.id(); DEBUG_LOG(m_logger) << "Data changed for Id: " << m_data.id;
// Publish Data via DTS // Publish Data via DTS
onPublishData(); onPublishData();
return Core::FunctionReplyObject(m_data.id()); return Core::FunctionReplyObject(m_data.id);
} }
//------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------
Core::FunctionReplyObject ObjectInstrumentationAsset::setUsed(bool isUsed) Core::FunctionReplyObject ObjectInstrumentationAsset::setUsed(bool isUsed)
{ {
if (!isValid()) if (!isValid())
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "Trying to update an already removed IsmAsset object")); return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "Trying to update an already removed IsmAsset object"));
m_data.isUsed(isUsed); m_data.isUsed = isUsed;
// Publish Data via DTS // Publish Data via DTS
onPublishData(); onPublishData();
return Core::FunctionReplyObject(m_data.id()); return Core::FunctionReplyObject(m_data.id);
} }
//------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------
Core::FunctionReplyObject ObjectInstrumentationAsset::removeObject() Core::FunctionReplyObject ObjectInstrumentationAsset::removeObject()
{ {
if (isUsed()) if (isUsed())
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "Asset still in use")); return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "Asset still in use"));
if (!db()->removeIsmAsset(m_data.id())) if (!db()->removeIsmAsset(m_data.id))
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "Asset with id %1 can not be removed from DB")).arg(m_data.id()); return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "Asset with id %1 can not be removed from DB")).arg(m_data.id);
if (!dts()->removeInstrumentationAssetByKey(m_data.id())) if (!dts()->removeInstrumentationAssetByKey(m_data.id))
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "Asset with id %1 can not be removed from DDS")).arg(m_data.id()); return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "Asset with id %1 can not be removed from DDS")).arg(m_data.id);
return Core::FunctionReplyObject(m_data.id()); return Core::FunctionReplyObject(m_data.id);
} }
//------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------
@@ -119,7 +119,7 @@ InfrastructureManagement::InstrumentationAsset InfrastructureManagement::ObjectI
//------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------
void ObjectInstrumentationAsset::onPublishData() void ObjectInstrumentationAsset::onPublishData()
{ {
INFO_LOG(m_logger) << "Publish IsmAsset-data to dds (" << m_data.id() << ") ..."; INFO_LOG(m_logger) << "Publish IsmAsset-data to dds (" << m_data.id << ") ...";
if (!dts()->publish(m_data)) if (!dts()->publish(m_data))
ERROR_LOG(m_logger) << "Error publishing IsmAsset-data to dds"; ERROR_LOG(m_logger) << "Error publishing IsmAsset-data to dds";
@@ -134,15 +134,15 @@ Database::IsmAsset ObjectInstrumentationAsset::toDbData(const InstrumentationAss
{ {
Database::IsmAsset dbData; Database::IsmAsset dbData;
dbData.id = ddsData.id(); dbData.id = ddsData.id;
dbData.name = QString::fromStdString(ddsData.name()); dbData.name = QString::fromStdString(ddsData.name);
dbData.mountingPointTypeId = ddsData.mountingPointTypeId(); dbData.mountingPointTypeId = ddsData.mountingPointTypeId;
dbData.barcode = QString::fromStdString(ddsData.barcode()); dbData.barcode = QString::fromStdString(ddsData.barcode);
dbData.hostname = QString::fromStdString(ddsData.hostname()); dbData.hostname = QString::fromStdString(ddsData.hostname);
dbData.properties = QString::fromStdString(ddsData.properties()); dbData.properties = QString::fromStdString(ddsData.properties);
dbData.assetStateId = ddsData.assetStateId(); dbData.assetStateId = ddsData.assetStateId;
dbData.availableInExercise = LtsUtils::IntArray(ddsData.availableInExercise()); dbData.availableInExercise = LtsUtils::IntArray(ddsData.availableInExercise);
dbData.lastUpdated = QDateTime::fromMSecsSinceEpoch(ddsData.lastUpdated()); dbData.lastUpdated = QDateTime::fromMSecsSinceEpoch(ddsData.lastUpdated);
return dbData; return dbData;
} }
@@ -153,19 +153,19 @@ InstrumentationAsset ObjectInstrumentationAsset::toDdsData(const Database::IsmAs
{ {
InstrumentationAsset ddsData; InstrumentationAsset ddsData;
ddsData.id(dbData.id); ddsData.id = dbData.id;
ddsData.name(dbData.name.toStdString()); ddsData.name = dbData.name.toStdString();
ddsData.mountingPointTypeId(dbData.mountingPointTypeId); ddsData.mountingPointTypeId = dbData.mountingPointTypeId;
ddsData.barcode(dbData.barcode.toStdString()); ddsData.barcode = dbData.barcode.toStdString();
ddsData.hostname(dbData.hostname.toStdString()); ddsData.hostname = dbData.hostname.toStdString();
ddsData.properties(dbData.properties.toStdString()); ddsData.properties = dbData.properties.toStdString();
ddsData.assetStateId(dbData.assetStateId); ddsData.assetStateId = dbData.assetStateId;
ddsData.availableInExercise(dbData.availableInExercise()); ddsData.availableInExercise = dbData.availableInExercise();
ddsData.lastUpdated(dbData.lastUpdated.toMSecsSinceEpoch()); ddsData.lastUpdated = dbData.lastUpdated.toMSecsSinceEpoch();
// init data not in db // init data not in db
ddsData.isDeleted(false); ddsData.isDeleted = false;
ddsData.isUsed(false); ddsData.isUsed = false;
return ddsData; return ddsData;
} }
@@ -29,9 +29,9 @@ public:
qint32 getId() const qint32 getId() const
{ {
return m_data.id(); return m_data.id;
} }
QString getName() const { return QString::fromStdString(m_data.name()); } QString getName() const { return QString::fromStdString(m_data.name); }
InfrastructureManagement::InstrumentationAsset getData() const; InfrastructureManagement::InstrumentationAsset getData() const;
bool isValid() const; bool isValid() const;
@@ -26,13 +26,13 @@ ObjectMainSchedule::~ObjectMainSchedule()
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
bool ObjectMainSchedule::isValid() const bool ObjectMainSchedule::isValid() const
{ {
return m_data.id() > 0; return m_data.id > 0;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
bool ObjectMainSchedule::isUsed() const bool ObjectMainSchedule::isUsed() const
{ {
return m_data.isUsed(); return m_data.isUsed;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@@ -40,10 +40,10 @@ Core::FunctionReplyObject ObjectMainSchedule::createObject(const MainSchedule &d
{ {
m_data = data; m_data = data;
if (m_data.id() <= 0) if (m_data.id <= 0)
{ {
// This is a brand new Item to push into the Database // This is a brand new Item to push into the Database
m_data.isUsed(false); m_data.isUsed = false;
Database::IsmMountingPointSchedule dbData; Database::IsmMountingPointSchedule dbData;
dbData = toDbData(data); dbData = toDbData(data);
@@ -51,8 +51,8 @@ Core::FunctionReplyObject ObjectMainSchedule::createObject(const MainSchedule &d
if (!db()->insert(dbData)) if (!db()->insert(dbData))
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting IsmMainSchedule-data into database")); return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting IsmMainSchedule-data into database"));
m_data.id(dbData.id); m_data.id = dbData.id;
DEBUG_LOG(m_logger) << "New Id: " << m_data.id(); DEBUG_LOG(m_logger) << "New Id: " << m_data.id;
// Publish Data via DTS // Publish Data via DTS
dts()->publish(m_data); dts()->publish(m_data);
} }
@@ -61,23 +61,23 @@ Core::FunctionReplyObject ObjectMainSchedule::createObject(const MainSchedule &d
// Cannot be done within createObject as the SQL Janitor prevents this! // Cannot be done within createObject as the SQL Janitor prevents this!
// Therefore, this item is not published in this case, but within loadMountingPointPlans()! // Therefore, this item is not published in this case, but within loadMountingPointPlans()!
return Core::FunctionReplyObject(m_data.id()); return Core::FunctionReplyObject(m_data.id);
} }
// Cannot be done within createObject as the SQL Janitor prevents this! // Cannot be done within createObject as the SQL Janitor prevents this!
bool ObjectMainSchedule::loadMountingPointPlans() bool ObjectMainSchedule::loadMountingPointPlans()
{ {
m_data.elements().clear(); m_data.elements.clear();
// Data from DB is pushed in here, we just need to update MPPs // Data from DB is pushed in here, we just need to update MPPs
auto cbMps = [this] (const Database::IsmMountingPointPlan &data) auto cbMps = [this] (const Database::IsmMountingPointPlan &data)
{ {
MountingPointPlan ddsData = ObjectMainSchedule::toDdsData(data); MountingPointPlan ddsData = ObjectMainSchedule::toDdsData(data);
m_data.elements().push_back(ddsData); m_data.elements.push_back(ddsData);
m_mppMap.insert(ddsData.structureElementId(), ddsData); m_mppMap.insert(ddsData.structureElementId, ddsData);
}; };
// create Mounting Point Schedule objects // create Mounting Point Schedule objects
if (!db()->selectByMountingPointScheduleId(cbMps,m_data.id())) if (!db()->selectByMountingPointScheduleId(cbMps,m_data.id))
return false; return false;
return dts()->publish(m_data); return dts()->publish(m_data);
@@ -88,29 +88,29 @@ bool ObjectMainSchedule::loadMountingPointPlans()
Core::FunctionReplyObject ObjectMainSchedule::updateObject(const MainSchedule &data) Core::FunctionReplyObject ObjectMainSchedule::updateObject(const MainSchedule &data)
{ {
if (!isValid()) if (!isValid())
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Object not valid/blocked")); return Core::FunctionReplyObject(data.id, tr_lts("dds", "Object not valid/blocked"));
Database::IsmMountingPointSchedule dbData; Database::IsmMountingPointSchedule dbData;
dbData = toDbData(data); dbData = toDbData(data);
if (!db()->update(dbData)) if (!db()->update(dbData))
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Error updating IsmMainSchedule-data into database")); return Core::FunctionReplyObject(data.id, tr_lts("dds", "Error updating IsmMainSchedule-data into database"));
// Change state if different // Change state if different
if (m_data.statusId() != data.statusId()) if (m_data.statusId != data.statusId)
setScheduleStatus(data.statusId()); setScheduleStatus(data.statusId);
// If elements are not saved, a MainSchedule with 0 elements will be published. // If elements are not saved, a MainSchedule with 0 elements will be published.
std::vector< InfrastructureManagement::MountingPointPlan > tempElements = m_data.elements(); std::vector< InfrastructureManagement::MountingPointPlan > tempElements = m_data.elements;
m_data = data; m_data = data;
m_data.elements(tempElements); m_data.elements = tempElements;
DEBUG_LOG(m_logger) << "Data changed for Id: " << m_data.id(); DEBUG_LOG(m_logger) << "Data changed for Id: " << m_data.id;
// Publish Data via DTS // Publish Data via DTS
dts()->publish(m_data); dts()->publish(m_data);
return Core::FunctionReplyObject(m_data.id()); return Core::FunctionReplyObject(m_data.id);
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@@ -135,11 +135,11 @@ Core::FunctionReplyObject ObjectMainSchedule::copyObject(qint32 scheduleId)
// auto cbMps = [this] (const Database::IsmMountingPointPlan &data) // auto cbMps = [this] (const Database::IsmMountingPointPlan &data)
// { // {
// InfrastructureManagement::MountingPointPlan ddsData = ObjectMainSchedule::toDdsData(data); // InfrastructureManagement::MountingPointPlan ddsData = ObjectMainSchedule::toDdsData(data);
// m_data.elements().push_back(ddsData); // m_data.elements.push_back(ddsData);
// }; // };
// // create Mounting Point Schedule objects // // create Mounting Point Schedule objects
// if (!db()->selectByMountingPointScheduleId(cbMps,m_data.id())) // if (!db()->selectByMountingPointScheduleId(cbMps,m_data.id))
// { // {
// return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting IsmMountingPointPlan-data into DDS Structure")); // return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting IsmMountingPointPlan-data into DDS Structure"));
// } // }
@@ -155,23 +155,23 @@ Core::FunctionReplyObject ObjectMainSchedule::updateElements(const std::vector<M
bool retVal = true; bool retVal = true;
for (const MountingPointPlan &mpp : newElements) for (const MountingPointPlan &mpp : newElements)
{ {
int seId = mpp.structureElementId(); int seId = mpp.structureElementId;
if (m_mppMap.contains(seId)) if (m_mppMap.contains(seId))
{ {
if (mpp.mountingPointState() == MountingPointState_def::Idle) if (mpp.mountingPointState == MountingPointState::Idle)
{ {
retVal &= db()->deleteMountingPointPlan(m_data.id(), seId); retVal &= db()->deleteMountingPointPlan(m_data.id, seId);
m_mppMap.remove(seId); m_mppMap.remove(seId);
} }
else else
{ {
retVal &= db()->updateMountingPointPlan(m_data.id(), seId, mpp.mountingPointState()); retVal &= db()->updateMountingPointPlan(m_data.id, seId, mpp.mountingPointState);
m_mppMap[seId] = mpp; m_mppMap[seId] = mpp;
} }
} }
else else
{ {
auto copy = toDbData(m_data.id(), mpp); auto copy = toDbData(m_data.id, mpp);
m_mppMap[seId] = mpp; m_mppMap[seId] = mpp;
// Do this as a bulk.... // Do this as a bulk....
insert.push_back(copy); insert.push_back(copy);
@@ -180,50 +180,50 @@ Core::FunctionReplyObject ObjectMainSchedule::updateElements(const std::vector<M
retVal &= db()->insertMountingPointPlans(insert); retVal &= db()->insertMountingPointPlans(insert);
trans.commit(); trans.commit();
m_data.elements().clear(); m_data.elements.clear();
m_data.elements().reserve(m_mppMap.size()); m_data.elements.reserve(m_mppMap.size());
std::copy(m_mppMap.begin(), m_mppMap.end(),std::back_inserter(m_data.elements())); std::copy(m_mppMap.begin(), m_mppMap.end(),std::back_inserter(m_data.elements));
QTimer::singleShot(50, [this](){dts()->publish(m_data);}); QTimer::singleShot(50, [this](){dts()->publish(m_data);});
if (!retVal) if (!retVal)
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "Error on updating MountingPoint Plans.")); return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "Error on updating MountingPoint Plans."));
return Core::FunctionReplyObject(m_data.id()); return Core::FunctionReplyObject(m_data.id);
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
Core::FunctionReplyObject ObjectMainSchedule::setUsed(bool isUsed) Core::FunctionReplyObject ObjectMainSchedule::setUsed(bool isUsed)
{ {
if (!isValid()) if (!isValid())
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "Trying to update an already removed IsmMainSchedule object")); return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "Trying to update an already removed IsmMainSchedule object"));
m_data.isUsed(isUsed); m_data.isUsed = isUsed;
// Publish Data via DTS // Publish Data via DTS
//onPublishData(); //onPublishData();
return Core::FunctionReplyObject(m_data.id()); return Core::FunctionReplyObject(m_data.id);
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
Core::FunctionReplyObject ObjectMainSchedule::removeObject() Core::FunctionReplyObject ObjectMainSchedule::removeObject()
{ {
if (isUsed()) if (isUsed())
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "MainSchedule still in use")); return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "MainSchedule still in use"));
if (!db()->removeIsmMountingPointSchedule(m_data.id())) if (!db()->removeIsmMountingPointSchedule(m_data.id))
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "MainSchedule with id %1 can not be removed from DB")).arg(m_data.id()); return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "MainSchedule with id %1 can not be removed from DB")).arg(m_data.id);
if (!dts()->removeMainScheduleByKey(m_data.id())) if (!dts()->removeMainScheduleByKey(m_data.id))
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "MainSchedule with id %1 can not be removed from DDS")).arg(m_data.id()); return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "MainSchedule with id %1 can not be removed from DDS")).arg(m_data.id);
return Core::FunctionReplyObject(m_data.id()); return Core::FunctionReplyObject(m_data.id);
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
bool ObjectMainSchedule::setScheduleStatus(const ScheduleStatus &status) bool ObjectMainSchedule::setScheduleStatus(const ScheduleStatus &status)
{ {
if (m_data.statusId() == status) if (m_data.statusId == status)
return true; return true;
if (!isValid()) if (!isValid())
@@ -232,22 +232,22 @@ bool ObjectMainSchedule::setScheduleStatus(const ScheduleStatus &status)
return false; return false;
} }
DEBUG_LOG(m_logger) << "## old status = " << m_data.statusId(); DEBUG_LOG(m_logger) << "## old status = " << m_data.statusId;
DEBUG_LOG(m_logger) << "## new status = " << status; DEBUG_LOG(m_logger) << "## new status = " << status;
m_data.statusId() = status; m_data.statusId = status;
QDateTime changed = QDateTime::currentDateTimeUtc(); QDateTime changed = QDateTime::currentDateTimeUtc();
if (m_data.timeCreated() <= 0) if (m_data.timeCreated <= 0)
m_data.timeCreated() = changed.toMSecsSinceEpoch(); m_data.timeCreated = changed.toMSecsSinceEpoch();
switch (m_data.statusId().underlying()) switch (m_data.statusId)
{ {
case ScheduleStatus::Active: case ScheduleStatus::Active:
m_data.timeStart() = changed.toMSecsSinceEpoch(); m_data.timeStart = changed.toMSecsSinceEpoch();
break; break;
case ScheduleStatus::Inactive: case ScheduleStatus::Inactive:
m_data.timeEnd() = changed.toMSecsSinceEpoch(); m_data.timeEnd = changed.toMSecsSinceEpoch();
break; break;
default: default:
break; break;
@@ -258,13 +258,13 @@ bool ObjectMainSchedule::setScheduleStatus(const ScheduleStatus &status)
if (!db()->update(dbData)) if (!db()->update(dbData))
{ {
ERROR_LOG(m_logger) << "Error updating MainSchedule-data in database (ScheduleStatus) for id = " << m_data.id() << " : " << db()->getLastError().text();; ERROR_LOG(m_logger) << "Error updating MainSchedule-data in database (ScheduleStatus) for id = " << m_data.id << " : " << db()->getLastError().text();;
return false; return false;
} }
Database::IsmScheduleStatusChange stateChange; Database::IsmScheduleStatusChange stateChange;
stateChange.id = 0; stateChange.id = 0;
stateChange.scheduleId = m_data.id(); stateChange.scheduleId = m_data.id;
stateChange.changedAt = changed.currentMSecsSinceEpoch(); stateChange.changedAt = changed.currentMSecsSinceEpoch();
// record stateChange // record stateChange
@@ -286,20 +286,20 @@ Database::IsmMountingPointSchedule ObjectMainSchedule::toDbData(const MainSchedu
{ {
Database::IsmMountingPointSchedule dbData; Database::IsmMountingPointSchedule dbData;
dbData.id = ddsData.id(); dbData.id = ddsData.id;
dbData.name = QString::fromStdString(ddsData.name()); dbData.name = QString::fromStdString(ddsData.name);
dbData.timeCreated = QDateTime::fromMSecsSinceEpoch(ddsData.timeCreated()); dbData.timeCreated = QDateTime::fromMSecsSinceEpoch(ddsData.timeCreated);
dbData.statusId = ddsData.statusId(); dbData.statusId = ddsData.statusId;
if (ddsData.timeStart().is_set() && ddsData.timeStart().get() > 0) if (ddsData.timeStart.is_set() && ddsData.timeStart.get() > 0)
dbData.timeStart = QDateTime::fromMSecsSinceEpoch(ddsData.timeStart().get()); dbData.timeStart = QDateTime::fromMSecsSinceEpoch(ddsData.timeStart.get());
else else
dbData.timeStart = QDateTime(); dbData.timeStart = QDateTime();
if (ddsData.timeEnd().is_set() && ddsData.timeEnd().get() > 0) if (ddsData.timeEnd.is_set() && ddsData.timeEnd.get() > 0)
dbData.timeEnd = QDateTime::fromMSecsSinceEpoch(ddsData.timeEnd().get()); dbData.timeEnd = QDateTime::fromMSecsSinceEpoch(ddsData.timeEnd.get());
else else
dbData.timeEnd = QDateTime(); dbData.timeEnd = QDateTime();
if (ddsData.exerciseId().is_set() && ddsData.exerciseId().get() > 0) if (ddsData.exerciseId.is_set() && ddsData.exerciseId.get() > 0)
dbData.exerciseId = ddsData.exerciseId().get(); dbData.exerciseId = ddsData.exerciseId.get();
return dbData; return dbData;
} }
@@ -309,9 +309,9 @@ Database::IsmMountingPointPlan ObjectMainSchedule::toDbData(int scheduleId, cons
{ {
Database::IsmMountingPointPlan dbData; Database::IsmMountingPointPlan dbData;
dbData.structureElementId = ddsData.structureElementId(); dbData.structureElementId = ddsData.structureElementId;
dbData.mountingPointScheduleId = scheduleId; dbData.mountingPointScheduleId = scheduleId;
dbData.mountingPointState= ddsData.mountingPointState(); dbData.mountingPointState= ddsData.mountingPointState;
return dbData; return dbData;
} }
@@ -323,19 +323,19 @@ MainSchedule ObjectMainSchedule::toDdsData(const Database::IsmMountingPointSched
{ {
MainSchedule ddsData; MainSchedule ddsData;
ddsData.id(dbData.id); ddsData.id = dbData.id;
ddsData.name(dbData.name.toStdString()); ddsData.name = dbData.name.toStdString();
ddsData.statusId(dbData.statusId); ddsData.statusId = dbData.statusId;
if (!dbData.timeStart.isNull() && dbData.timeStart.isValid() && dbData.timeStart.toMSecsSinceEpoch() > 0) if (!dbData.timeStart.isNull() && dbData.timeStart.isValid() && dbData.timeStart.toMSecsSinceEpoch() > 0)
ddsData.timeStart(dbData.timeStart.toMSecsSinceEpoch()); ddsData.timeStart = dbData.timeStart.toMSecsSinceEpoch();
if (!dbData.timeEnd.isNull() && dbData.timeEnd.isValid() && dbData.timeEnd.toMSecsSinceEpoch() > 0) if (!dbData.timeEnd.isNull() && dbData.timeEnd.isValid() && dbData.timeEnd.toMSecsSinceEpoch() > 0)
ddsData.timeEnd(dbData.timeEnd.toMSecsSinceEpoch()); ddsData.timeEnd = dbData.timeEnd.toMSecsSinceEpoch();
ddsData.timeCreated(dbData.timeCreated.toMSecsSinceEpoch()); ddsData.timeCreated = dbData.timeCreated.toMSecsSinceEpoch();
if (!dbData.exerciseId.isNull() && dbData.exerciseId.canConvert<int>()) if (!dbData.exerciseId.isNull() && dbData.exerciseId.canConvert<int>())
ddsData.exerciseId(dbData.exerciseId.toInt()); ddsData.exerciseId = dbData.exerciseId.toInt();
// init data not in db // init data not in db
ddsData.isDeleted(false); ddsData.isDeleted = false;
ddsData.isUsed(false); ddsData.isUsed = false;
return ddsData; return ddsData;
} }
@@ -343,8 +343,8 @@ MainSchedule ObjectMainSchedule::toDdsData(const Database::IsmMountingPointSched
MountingPointPlan ObjectMainSchedule::toDdsData(const Database::IsmMountingPointPlan &dbData) MountingPointPlan ObjectMainSchedule::toDdsData(const Database::IsmMountingPointPlan &dbData)
{ {
MountingPointPlan ddsData; MountingPointPlan ddsData;
ddsData.mountingPointState(dbData.mountingPointState); ddsData.mountingPointState = dbData.mountingPointState;
ddsData.structureElementId(dbData.structureElementId); ddsData.structureElementId = dbData.structureElementId;
return ddsData; return ddsData;
} }
@@ -28,10 +28,10 @@ public:
Core::FunctionReplyObject removeObject(); Core::FunctionReplyObject removeObject();
Core::FunctionReplyObject copyObject(qint32 scheduleId); Core::FunctionReplyObject copyObject(qint32 scheduleId);
qint32 getId() const { return m_data.id(); } qint32 getId() const { return m_data.id; }
MainSchedule getData() const { return m_data; } MainSchedule getData() const { return m_data; }
QString getName() const { return QString::fromStdString(m_data.name()); } QString getName() const { return QString::fromStdString(m_data.name); }
ScheduleStatus scheduleStatus() const { return m_data.statusId(); } ScheduleStatus scheduleStatus() const { return m_data.statusId; }
Core::FunctionReplyObject updateElements(const std::vector<MountingPointPlan> &newElements); Core::FunctionReplyObject updateElements(const std::vector<MountingPointPlan> &newElements);
@@ -52,8 +52,8 @@ ObjectMainStructureElement::ObjectMainStructureElement(const Database::IsmMainSt
: Base(mainHandler, getLogger("ObjectMainStructureElement")) : Base(mainHandler, getLogger("ObjectMainStructureElement"))
, m_data(Database::convert(dbData)) , m_data(Database::convert(dbData))
{ {
m_data.elements().reserve(100); // sadly dds::vector has neither squeeze() nor is using over-provisioning... :( m_data.elements.reserve(100); // sadly dds::vector has neither squeeze() nor is using over-provisioning... :(
m_footprint.id(m_data.id()); m_footprint.id = m_data.id;
} }
//------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------
@@ -65,23 +65,23 @@ ObjectMainStructureElement::~ObjectMainStructureElement()
//------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------
bool ObjectMainStructureElement::isValid() const bool ObjectMainStructureElement::isValid() const
{ {
return m_data.id() > 0; return m_data.id > 0;
} }
//------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------
Core::FunctionReplyObject ObjectMainStructureElement::updatePosition(const Core::GeoPosition &position) Core::FunctionReplyObject ObjectMainStructureElement::updatePosition(const Core::GeoPosition &position)
{ {
MainStructureElement data(m_data); MainStructureElement data(m_data);
data.geoPosition(position); data.geoPosition = position;
if (!db()->update(toDbData(data))) if (!db()->update(toDbData(data)))
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Error updating IsmMainStructureElement-data into database")); return Core::FunctionReplyObject(data.id, tr_lts("dds", "Error updating IsmMainStructureElement-data into database"));
m_data = data; m_data = data;
DEBUG_LOG(m_logger) << "Data changed for Id: " << m_data.id(); DEBUG_LOG(m_logger) << "Data changed for Id: " << m_data.id;
return Core::FunctionReplyObject(m_data.id()); return Core::FunctionReplyObject(m_data.id);
} }
//------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------
@@ -90,18 +90,18 @@ Core::FunctionReplyObject ObjectMainStructureElement::setBridgeStatus(const Brid
MainStructureElement data(m_data); MainStructureElement data(m_data);
QJsonObject jsonObj; QJsonObject jsonObj;
jsonObj[QStringLiteral("bridgeStatus")] = st.underlying(); jsonObj[QStringLiteral("bridgeStatus")] = static_cast<int>(st);
QJsonDocument doc(jsonObj); QJsonDocument doc(jsonObj);
data.properties(doc.toJson().toStdString()); data.properties = doc.toJson().toStdString();
if (!db()->update(toDbData(data))) if (!db()->update(toDbData(data)))
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Error updating IsmMainStructureElement-properties into database")); return Core::FunctionReplyObject(data.id, tr_lts("dds", "Error updating IsmMainStructureElement-properties into database"));
m_data = data; m_data = data;
DEBUG_LOG(m_logger) << "Properties changed for Id: " << m_data.id(); DEBUG_LOG(m_logger) << "Properties changed for Id: " << m_data.id;
return Core::FunctionReplyObject(m_data.id()); return Core::FunctionReplyObject(m_data.id);
} }
/*! /*!
* \brief ObjectMainStructureElement::deleteEGCUOverrides * \brief ObjectMainStructureElement::deleteEGCUOverrides
@@ -118,15 +118,15 @@ std::vector<StructureElement> ObjectMainStructureElement::deleteEGCUOverrides(co
{ {
if(oldExerciseId == newExerciseId) if(oldExerciseId == newExerciseId)
return data.elements(); return data.elements;
std::vector<InfrastructureManagement::StructureElement> resElements; std::vector<InfrastructureManagement::StructureElement> resElements;
for(auto element : data.elements()) for(auto element : data.elements)
{ {
if (element.mountingPointTypeId() == MountingPointType::EffectGenerationControlUnit) if (element.mountingPointTypeId == MountingPointType::EffectGenerationControlUnit)
{ {
QJsonObject structureEleProps = QJsonDocument::fromJson(QByteArray::fromStdString(element.properties())).object(); QJsonObject structureEleProps = QJsonDocument::fromJson(QByteArray::fromStdString(element.properties)).object();
if(structureEleProps.contains(QStringLiteral("Overrides"))) if(structureEleProps.contains(QStringLiteral("Overrides")))
{ {
@@ -149,8 +149,8 @@ std::vector<StructureElement> ObjectMainStructureElement::deleteEGCUOverrides(co
//relaysResult[QStringLiteral("relays")] = resultList; //relaysResult[QStringLiteral("relays")] = resultList;
structureEleProps[QStringLiteral("Overrides")] = relaysResult; structureEleProps[QStringLiteral("Overrides")] = relaysResult;
element.properties(QString::fromUtf8(QJsonDocument(structureEleProps).toJson()).toStdString()); element.properties = QString::fromUtf8(QJsonDocument(structureEleProps).toJson()).toStdString();
modifiedStructureElements.insert(element.id()); modifiedStructureElements.insert(element.id);
} }
} }
} }
@@ -180,192 +180,192 @@ void ObjectMainStructureElement::noticeNewProperties(bool remove)
if (!remove) if (!remove)
exercises = getAvailableInExercise(); exercises = getAvailableInExercise();
for (const auto &ele : m_data.elements()) for (const auto &ele : m_data.elements)
{ {
if (ele.structureElementTypeId() == StructureElementType::MountingPoint) if (ele.structureElementTypeId == StructureElementType::MountingPoint)
m_mainHandler->getHandlerMountingPointAsset()->setAvailableInExerciseForAssetOnMountingPoint(ele.id(), exercises); m_mainHandler->getHandlerMountingPointAsset()->setAvailableInExerciseForAssetOnMountingPoint(ele.id, exercises);
} }
} }
//------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------
Core::FunctionReplyObject ObjectMainStructureElement::createObject(const MainStructureElementModifyRequest &request) Core::FunctionReplyObject ObjectMainStructureElement::createObject(const MainStructureElementModifyRequest &request)
{ {
if (!isValidJsonObject(request.properties())) if (!isValidJsonObject(request.properties))
return Core::FunctionReplyObject(0, tr_lts("dds", "MainStructureElement with invalid JSON properties")); return Core::FunctionReplyObject(0, tr_lts("dds", "MainStructureElement with invalid JSON properties"));
m_data = MainStructureElement(); m_data = MainStructureElement();
m_footprint = MainFootprint(); m_footprint = MainFootprint();
m_data.name(request.name()); m_data.name = request.name;
m_data.description(request.description()); m_data.description = request.description;
m_data.geoPosition(request.geoPosition()); m_data.geoPosition = request.geoPosition;
m_data.angle(request.angle()); m_data.angle = request.angle;
m_data.modelId(request.modelId()); m_data.modelId = request.modelId;
m_data.externalWlsId(request.externalWlsId()); m_data.externalWlsId = request.externalWlsId;
m_data.groupId(request.groupId()); m_data.groupId = request.groupId;
m_data.elements(request.elements()); m_data.elements = request.elements;
m_data.properties(request.properties()); m_data.properties = request.properties;
m_data.structureElementTypeId(request.structureElementTypeId()); m_data.structureElementTypeId = request.structureElementTypeId;
DBTransaction trans(db()->database()); DBTransaction trans(db()->database());
m_data.isUsed(false); m_data.isUsed = false;
// Insert MainStructure Element // Insert MainStructure Element
Database::IsmMainStructureElement dbData(toDbData(m_data)); Database::IsmMainStructureElement dbData(toDbData(m_data));
if (!db()->insert(dbData)) if (!db()->insert(dbData))
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting IsmMainStructureElement-data into database")); return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting IsmMainStructureElement-data into database"));
m_data.id(dbData.id); m_data.id = dbData.id;
// Insert Structure Elements // Insert Structure Elements
QVector<ObjectStructureElement *> objSeVec; QVector<ObjectStructureElement *> objSeVec;
objSeVec.reserve(m_data.elements().size()); objSeVec.reserve(m_data.elements.size());
auto fro = createStructureElements(m_data, objSeVec); auto fro = createStructureElements(m_data, objSeVec);
if (fro.error()) if (fro.error())
return fro; return fro;
ObjectStructureElement *objStructureElementBuilding = objSeVec.first(); ObjectStructureElement *objStructureElementBuilding = objSeVec.first();
// Insert Footprint Elements // Insert Footprint Elements
m_footprint.id(m_data.id()); // = buildingId, important for remove etc. m_footprint.id = m_data.id; // = buildingId, important for remove etc.
m_footprint.structureElementId(objStructureElementBuilding->getId()); m_footprint.structureElementId = objStructureElementBuilding->getId();
m_footprint.name(m_data.name()); // footprint name = building name m_footprint.name = m_data.name; // footprint name = building name
if (request.footprint().is_set()) if (request.footprint.is_set())
{ {
const auto &fp = request.footprint().get(); const auto &fp = request.footprint.get();
for (size_t i = 0; i < fp.size(); ++i) for (size_t i = 0; i < fp.size(); ++i)
{ {
FootprintElement fpElem = fp.at(i); FootprintElement fpElem = fp.at(i);
const Core::RelativePosition &relPos = fpElem.relPosition(); const Core::RelativePosition &relPos = fpElem.relPosition;
Database::IsmStructureElementFootprint footprint; Database::IsmStructureElementFootprint footprint;
footprint.indexNo = i; footprint.indexNo = i;
footprint.relPosition = LtsUtils::QPoint3D(relPos.offsetX(), relPos.offsetY(), relPos.offsetZ()); footprint.relPosition = LtsUtils::QPoint3D(relPos.offsetX, relPos.offsetY, relPos.offsetZ);
footprint.structureElementId = objStructureElementBuilding->getId(); footprint.structureElementId = objStructureElementBuilding->getId();
if (!db()->insert(footprint)) if (!db()->insert(footprint))
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting IsmStructureElementFootprint-data into database")); return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting IsmStructureElementFootprint-data into database"));
fpElem.id(footprint.id); fpElem.id = footprint.id;
m_footprint.elements().resize(m_footprint.elements().size()+1, fpElem); m_footprint.elements.resize(m_footprint.elements.size()+1, fpElem);
} }
} }
DEBUG_LOG(m_logger) << "m_footprint.elements().size() = " << m_footprint.elements().size(); DEBUG_LOG(m_logger) << "m_footprint.elements.size() = " << m_footprint.elements.size();
if (!db()->update(toDbData(m_data))) if (!db()->update(toDbData(m_data)))
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "Error updating IsmMainStructureElement-data into database")); return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "Error updating IsmMainStructureElement-data into database"));
fro = updatePaths(m_data, objSeVec, request.childParentRelations()); fro = updatePaths(m_data, objSeVec, request.childParentRelations);
if (fro.error()) if (fro.error())
return fro; return fro;
DEBUG_LOG(m_logger) << "New Id: " << m_data.id(); DEBUG_LOG(m_logger) << "New Id: " << m_data.id;
trans.commit(); trans.commit();
if (m_data.properties().size()) if (m_data.properties.size())
noticeNewProperties(); noticeNewProperties();
m_mainHandler->getHandlerMainStructureElement()->addedStructureElements(m_objectStructureElements); m_mainHandler->getHandlerMainStructureElement()->addedStructureElements(m_objectStructureElements);
return Core::FunctionReplyObject(m_data.id()); return Core::FunctionReplyObject(m_data.id);
} }
//------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------
Core::FunctionReplyObject ObjectMainStructureElement::updateObject(const MainStructureElementModifyRequest &request) Core::FunctionReplyObject ObjectMainStructureElement::updateObject(const MainStructureElementModifyRequest &request)
{ {
if (!isValidJsonObject(request.properties())) if (!isValidJsonObject(request.properties))
return Core::FunctionReplyObject(0, tr_lts("dds", "MainStructureElement with invalid JSON properties")); return Core::FunctionReplyObject(0, tr_lts("dds", "MainStructureElement with invalid JSON properties"));
if (!isValid()) if (!isValid())
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "Object not valid/blocked")); return Core::FunctionReplyObject(request.id, tr_lts("dds", "Object not valid/blocked"));
bool hasNewProps = m_data.properties() != request.properties(); bool hasNewProps = m_data.properties != request.properties;
MainStructureElement data(m_data); MainStructureElement data(m_data);
QJsonObject objRequest = QJsonDocument::fromJson(QByteArray::fromStdString(request.properties())).object(); QJsonObject objRequest = QJsonDocument::fromJson(QByteArray::fromStdString(request.properties)).object();
QJsonObject objCurrent = QJsonDocument::fromJson(QByteArray::fromStdString(data.properties())).object(); QJsonObject objCurrent = QJsonDocument::fromJson(QByteArray::fromStdString(data.properties)).object();
int newExerciseId = objRequest.value(QStringLiteral("available_in_exercise")).toArray().at(0).toInt(); int newExerciseId = objRequest.value(QStringLiteral("available_in_exercise")).toArray().at(0).toInt();
int currentExerciseId = objCurrent.value(QStringLiteral("available_in_exercise")).toArray().at(0).toInt(); int currentExerciseId = objCurrent.value(QStringLiteral("available_in_exercise")).toArray().at(0).toInt();
data.name(request.name()); data.name = request.name;
data.description(request.description()); data.description = request.description;
data.geoPosition(request.geoPosition()); data.geoPosition = request.geoPosition;
data.angle(request.angle()); data.angle = request.angle;
data.modelId(request.modelId()); data.modelId = request.modelId;
data.externalWlsId(request.externalWlsId()); data.externalWlsId = request.externalWlsId;
data.groupId(request.groupId()); data.groupId = request.groupId;
data.properties(request.properties()); data.properties = request.properties;
data.structureElementId(request.structureElementId()); data.structureElementId = request.structureElementId;
data.structureElementTypeId(request.structureElementTypeId()); data.structureElementTypeId = request.structureElementTypeId;
// when we want to allow insert / update / remove for SE: // when we want to allow insert / update / remove for SE:
// data.elements(request.elements()); // data.elements(request.elements);
QSet<int> modifiedStructureElements; QSet<int> modifiedStructureElements;
bool bStructureElementCountChanged = false; bool bStructureElementCountChanged = false;
std::vector<int> childParentMapping; std::vector<int> childParentMapping;
const auto oldStructureElements = m_objectStructureElements; const auto oldStructureElements = m_objectStructureElements;
if (request.elements().size() != 0) if (request.elements.size() != 0)
{ {
if (request.elements().size() != data.elements().size()) if (request.elements.size() != data.elements.size())
{ {
bStructureElementCountChanged = true; bStructureElementCountChanged = true;
QHash<int, size_t> parentId2Index; QHash<int, size_t> parentId2Index;
childParentMapping.resize(request.elements().size()); childParentMapping.resize(request.elements.size());
data.elements(request.elements()); data.elements = request.elements;
for (size_t i = 0; i < request.elements().size(); ++i) for (size_t i = 0; i < request.elements.size(); ++i)
{ {
StructureElement &newElem = data.elements().at(i); StructureElement &newElem = data.elements.at(i);
if (!isValidJsonObject(newElem.properties())) if (!isValidJsonObject(newElem.properties))
return Core::FunctionReplyObject(0, tr_lts("dds", "StructureElement with invalid JSON properties")); return Core::FunctionReplyObject(0, tr_lts("dds", "StructureElement with invalid JSON properties"));
parentId2Index[newElem.id()] = i; parentId2Index[newElem.id] = i;
childParentMapping[i] = parentId2Index.value(parentFromPath(newElem.path())); childParentMapping[i] = parentId2Index.value(parentFromPath(newElem.path));
// Do *not* modify the those // Do *not* modify the those
if (!isStructureElementDeletable(newElem)) if (!isStructureElementDeletable(newElem))
continue; continue;
newElem.id(0); newElem.id = 0;
} }
} }
else else
{ {
for (size_t i = 0; i < request.elements().size(); ++i) for (size_t i = 0; i < request.elements.size(); ++i)
{ {
const StructureElement &newElem = request.elements().at(i); const StructureElement &newElem = request.elements.at(i);
if (!isValidJsonObject(newElem.properties())) if (!isValidJsonObject(newElem.properties))
return Core::FunctionReplyObject(0, tr_lts("dds", "StructureElement with invalid JSON properties")); return Core::FunctionReplyObject(0, tr_lts("dds", "StructureElement with invalid JSON properties"));
StructureElement &oldElem = data.elements()[i]; StructureElement &oldElem = data.elements[i];
if (oldElem.id() != newElem.id() && newElem.id() != 0) if (oldElem.id != newElem.id && newElem.id != 0)
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Adding / Removing Structure elements not (yet) supported")); return Core::FunctionReplyObject(data.id, tr_lts("dds", "Adding / Removing Structure elements not (yet) supported"));
if (oldElem == newElem) if (oldElem == newElem)
continue; continue;
modifiedStructureElements += oldElem.id(); modifiedStructureElements += oldElem.id;
// currently we only support modifing these values: // currently we only support modifing these values:
oldElem.displayName(newElem.displayName()); oldElem.displayName = newElem.displayName;
oldElem.barcode(newElem.barcode()); oldElem.barcode = newElem.barcode;
oldElem.mountingPointId(newElem.mountingPointId()); oldElem.mountingPointId = newElem.mountingPointId;
oldElem.mountingPointTypeId(newElem.mountingPointTypeId()); oldElem.mountingPointTypeId = newElem.mountingPointTypeId;
oldElem.relPosition(newElem.relPosition()); oldElem.relPosition = newElem.relPosition;
oldElem.structureElementTypeId(newElem.structureElementTypeId()); oldElem.structureElementTypeId = newElem.structureElementTypeId;
oldElem.properties(newElem.properties()); oldElem.properties = newElem.properties;
DEBUG_LOG(m_logger) << "add " << oldElem.id() << " to modifiedStructureElements" << oldElem; DEBUG_LOG(m_logger) << "add " << oldElem.id << " to modifiedStructureElements" << oldElem;
} }
} }
} }
MainFootprint mfData(m_footprint); MainFootprint mfData(m_footprint);
bool bUpdateFootprintNeeded = false; bool bUpdateFootprintNeeded = false;
if (request.footprint().is_set()) if (request.footprint.is_set())
{ {
const auto &fpReq = request.footprint().get(); const auto &fpReq = request.footprint.get();
bUpdateFootprintNeeded = fpReq.size() != mfData.elements().size(); bUpdateFootprintNeeded = fpReq.size() != mfData.elements.size();
if (!bUpdateFootprintNeeded) if (!bUpdateFootprintNeeded)
{ {
for (size_t i = 0; i < fpReq.size(); ++i) for (size_t i = 0; i < fpReq.size(); ++i)
{ {
if (fpReq.at(i) != mfData.elements().at(i)) if (fpReq.at(i) != mfData.elements.at(i))
{ {
bUpdateFootprintNeeded = true; bUpdateFootprintNeeded = true;
break; break;
@@ -375,15 +375,15 @@ Core::FunctionReplyObject ObjectMainStructureElement::updateObject(const MainStr
} }
//The modifiedStructureElements need to be filled //The modifiedStructureElements need to be filled
data.elements(deleteEGCUOverrides(data, currentExerciseId, newExerciseId, modifiedStructureElements)); data.elements = deleteEGCUOverrides(data, currentExerciseId, newExerciseId, modifiedStructureElements);
DBTransaction trans(db()->database()); DBTransaction trans(db()->database());
if (bStructureElementCountChanged) if (bStructureElementCountChanged)
{ {
DEBUG_LOG(m_logger) << "Re-creating structure elements for " << data.id(); DEBUG_LOG(m_logger) << "Re-creating structure elements for " << data.id;
QVector<ObjectStructureElement *> objSeVec; QVector<ObjectStructureElement *> objSeVec;
objSeVec.reserve(data.elements().size()); objSeVec.reserve(data.elements.size());
auto fro = createStructureElements(data, objSeVec); auto fro = createStructureElements(data, objSeVec);
if (fro.error()) if (fro.error())
return fro; return fro;
@@ -393,44 +393,44 @@ Core::FunctionReplyObject ObjectMainStructureElement::updateObject(const MainStr
} }
else else
{ {
for (const auto &dataSe : data.elements()) for (const auto &dataSe : data.elements)
{ {
if (!modifiedStructureElements.contains(dataSe.id())) if (!modifiedStructureElements.contains(dataSe.id))
continue; continue;
InfrastructureManagement::ObjectStructureElement *objSe = m_objectStructureElements.value(dataSe.id()); InfrastructureManagement::ObjectStructureElement *objSe = m_objectStructureElements.value(dataSe.id);
if (!objSe) if (!objSe)
WARNING_LOG(m_logger) << "Internal Error: can not find structure element with id " << dataSe.id(); WARNING_LOG(m_logger) << "Internal Error: can not find structure element with id " << dataSe.id;
else else
objSe->updateObject(dataSe); objSe->updateObject(dataSe);
} }
} }
if (!db()->update(toDbData(data))) if (!db()->update(toDbData(data)))
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Error updating IsmMainStructureElement-data into database")); return Core::FunctionReplyObject(data.id, tr_lts("dds", "Error updating IsmMainStructureElement-data into database"));
DEBUG_LOG(m_logger) << "bUpdateFootprintNeeded = " << bUpdateFootprintNeeded; DEBUG_LOG(m_logger) << "bUpdateFootprintNeeded = " << bUpdateFootprintNeeded;
if (bUpdateFootprintNeeded) if (bUpdateFootprintNeeded)
{ {
// remove old footprint data // remove old footprint data
for (const FootprintElement &elem : m_footprint.elements()) for (const FootprintElement &elem : m_footprint.elements)
db()->removeIsmStructureElementFootprint(elem.id()); db()->removeIsmStructureElementFootprint(elem.id);
// add new footprint data // add new footprint data
Database::IsmStructureElementFootprint sef; Database::IsmStructureElementFootprint sef;
sef.structureElementId = getStructureElementId(); sef.structureElementId = getStructureElementId();
for (size_t i = 0; i < mfData.elements().size(); ++i) for (size_t i = 0; i < mfData.elements.size(); ++i)
{ {
FootprintElement &elem = mfData.elements()[i]; FootprintElement &elem = mfData.elements[i];
const Core::RelativePosition &relPos = elem.relPosition(); const Core::RelativePosition &relPos = elem.relPosition;
sef.indexNo = i; sef.indexNo = i;
sef.relPosition = LtsUtils::QPoint3D(relPos.offsetX(), sef.relPosition = LtsUtils::QPoint3D(relPos.offsetX,
relPos.offsetY(), relPos.offsetY,
relPos.offsetZ()); relPos.offsetZ);
if (!db()->insert(sef)) if (!db()->insert(sef))
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Error updating IsmStructureElementFootprint-data into database")); return Core::FunctionReplyObject(data.id, tr_lts("dds", "Error updating IsmStructureElementFootprint-data into database"));
elem.id(sef.id); elem.id = sef.id;
m_footprint.elements().resize(m_footprint.elements().size()+1, elem); m_footprint.elements.resize(m_footprint.elements.size()+1, elem);
} }
} }
DEBUG_LOG(m_logger) << "mfData.elements().size() = " << mfData.elements().size(); DEBUG_LOG(m_logger) << "mfData.elements.size() = " << mfData.elements.size();
trans.commit(); trans.commit();
@@ -461,7 +461,7 @@ Core::FunctionReplyObject ObjectMainStructureElement::updateObject(const MainStr
m_footprintNeedsUpdate = (m_footprint != mfData); m_footprintNeedsUpdate = (m_footprint != mfData);
m_footprint = mfData; m_footprint = mfData;
DEBUG_LOG(m_logger) << "Data changed for Id: " << m_data.id(); DEBUG_LOG(m_logger) << "Data changed for Id: " << m_data.id;
if (hasNewProps) if (hasNewProps)
noticeNewProperties(); noticeNewProperties();
@@ -469,24 +469,24 @@ Core::FunctionReplyObject ObjectMainStructureElement::updateObject(const MainStr
return Core::FunctionReplyObject(m_data.id()); return Core::FunctionReplyObject(m_data.id);
} }
//------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------
Core::FunctionReplyObject ObjectMainStructureElement::removeObject() Core::FunctionReplyObject ObjectMainStructureElement::removeObject()
{ {
/* done in Handler MSE /* done in Handler MSE
for (auto dataSe : m_data.elements()) for (auto dataSe : m_data.elements)
{ {
if (!db()->removeIsmStructureElement(dataSe.id())) if (!db()->removeIsmStructureElement(dataSe.id))
return Core::FunctionReplyObject(dataSe.id(), tr_lts("dds", "StructureElement %1 can not be removed from DB")).arg(dataSe.id()); return Core::FunctionReplyObject(dataSe.id, tr_lts("dds", "StructureElement %1 can not be removed from DB")).arg(dataSe.id);
} }
*/ */
if (!db()->removeIsmMainStructureElement(m_data.id())) if (!db()->removeIsmMainStructureElement(m_data.id))
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "MainStructureElement with id %1 can not be removed from DB")).arg(m_data.id()); return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "MainStructureElement with id %1 can not be removed from DB")).arg(m_data.id);
dts()->removeMainStructureElementByKey(m_data.id()); dts()->removeMainStructureElementByKey(m_data.id);
dts()->removeMainFootprintByKey(m_footprint.id()); dts()->removeMainFootprintByKey(m_footprint.id);
for (ObjectStructureElement *ose : qAsConst(m_objectStructureElements)) for (ObjectStructureElement *ose : qAsConst(m_objectStructureElements))
{ {
@@ -498,22 +498,22 @@ Core::FunctionReplyObject ObjectMainStructureElement::removeObject()
m_data = MainStructureElement(); m_data = MainStructureElement();
m_footprint = MainFootprint(); m_footprint = MainFootprint();
return Core::FunctionReplyObject(m_data.id()); return Core::FunctionReplyObject(m_data.id);
} }
//------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------
void ObjectMainStructureElement::onPublishData() void ObjectMainStructureElement::onPublishData()
{ {
INFO_LOG(m_logger) << "Publish IsmMainStructureElement-data to dds (" << m_data.id() << ") ..."; INFO_LOG(m_logger) << "Publish IsmMainStructureElement-data to dds (" << m_data.id << ") ...";
dts()->publish(m_data); dts()->publish(m_data);
DEBUG_LOG(m_logger) << "m_footprint.elements().size() = " << m_footprint.elements().size(); DEBUG_LOG(m_logger) << "m_footprint.elements.size() = " << m_footprint.elements.size();
if (m_footprint.elements().size() == 0) if (m_footprint.elements.size() == 0)
{ {
if (m_footprint.id() != 0) if (m_footprint.id != 0)
dts()->removeMainFootprintByKey(m_footprint.id()); dts()->removeMainFootprintByKey(m_footprint.id);
} }
else if (m_footprintNeedsUpdate) else if (m_footprintNeedsUpdate)
dts()->publish(m_footprint); dts()->publish(m_footprint);
@@ -537,23 +537,23 @@ ObjectStructureElement *ObjectMainStructureElement::createStructureElementObject
// top level types: Building, ApproachingPoint, Announcement, MeteoDataUnit, RadioStation, Bridge // top level types: Building, ApproachingPoint, Announcement, MeteoDataUnit, RadioStation, Bridge
if (isTopLevel(dbData.structureElementTypeId)) if (isTopLevel(dbData.structureElementTypeId))
{ {
m_data.structureElementId(ifs->getId()); m_data.structureElementId = ifs->getId();
m_data.structureElementTypeId(dbData.structureElementTypeId); m_data.structureElementTypeId = dbData.structureElementTypeId;
if (dbData.structureElementTypeId == StructureElementType::Building) if (dbData.structureElementTypeId == StructureElementType::Building)
{ {
m_footprintNeedsUpdate |= (m_footprint.structureElementId() != ifs->getId()); m_footprintNeedsUpdate |= (m_footprint.structureElementId != ifs->getId());
m_footprint.structureElementId(ifs->getId()); m_footprint.structureElementId = ifs->getId();
auto name = dbData.name.toStdString(); auto name = dbData.name.toStdString();
m_footprintNeedsUpdate |= (m_footprint.name() != name); m_footprintNeedsUpdate |= (m_footprint.name != name);
m_footprint.name(name); m_footprint.name = name;
} }
} }
ifs->updateGeoPosition(); ifs->updateGeoPosition();
int last = m_data.elements().size(); int last = m_data.elements.size();
// ifs->getData() to retrieve the correct geo position // ifs->getData() to retrieve the correct geo position
m_data.elements().resize(last + 1, ifs->getData()); m_data.elements.resize(last + 1, ifs->getData());
m_objectStructureElements.insert(ifs->getId(), ifs); m_objectStructureElements.insert(ifs->getId(), ifs);
@@ -567,8 +567,8 @@ const ObjectStructureElement *ObjectMainStructureElement::getMainStructureElemen
for (const ObjectStructureElement *ose : m_objectStructureElements) for (const ObjectStructureElement *ose : m_objectStructureElements)
{ {
const auto &data = ose->getData(); const auto &data = ose->getData();
if (data.structureElementTypeId() == InfrastructureManagement::StructureElementType::MountingPoint && if (data.structureElementTypeId == InfrastructureManagement::StructureElementType::MountingPoint &&
data.mountingPointTypeId() == InfrastructureManagement::MountingPointType::BuildingControlUnit) data.mountingPointTypeId == InfrastructureManagement::MountingPointType::BuildingControlUnit)
return ose; return ose;
} }
return nullptr; return nullptr;
@@ -577,20 +577,20 @@ const ObjectStructureElement *ObjectMainStructureElement::getMainStructureElemen
//------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------
void ObjectMainStructureElement::setFootprintData(const std::vector<FootprintElement> &elements) void ObjectMainStructureElement::setFootprintData(const std::vector<FootprintElement> &elements)
{ {
m_footprintNeedsUpdate |= (m_footprint.elements() != elements); m_footprintNeedsUpdate |= (m_footprint.elements != elements);
m_footprint.elements() = elements; m_footprint.elements = elements;
} }
//------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------
QJsonArray ObjectMainStructureElement::getAvailableInExerciseJsonArray() const QJsonArray ObjectMainStructureElement::getAvailableInExerciseJsonArray() const
{ {
return LtsUtils::JsonObject::fromJson(m_data.properties()).object().value(QLatin1String("available_in_exercise")).toArray(); return LtsUtils::JsonObject::fromJson(m_data.properties).object().value(QLatin1String("available_in_exercise")).toArray();
} }
//------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------
int ObjectMainStructureElement::getBridgeStatus() const int ObjectMainStructureElement::getBridgeStatus() const
{ {
return LtsUtils::JsonObject::fromJson(m_data.properties()).object().value(QLatin1String("bridgeStatus")).toInt(); return LtsUtils::JsonObject::fromJson(m_data.properties).object().value(QLatin1String("bridgeStatus")).toInt();
} }
//------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------
@@ -611,32 +611,32 @@ std::vector<int32_t> ObjectMainStructureElement::getAvailableInExercise() const
Core::FunctionReplyObject ObjectMainStructureElement::createStructureElements(MainStructureElement &mse, Core::FunctionReplyObject ObjectMainStructureElement::createStructureElements(MainStructureElement &mse,
QVector<ObjectStructureElement *> &objSeVec) QVector<ObjectStructureElement *> &objSeVec)
{ {
if (mse.elements().size() == 0) if (mse.elements.size() == 0)
return Core::FunctionReplyObject(0, tr_lts("dds", "MainStructureElement without StructureElements")); return Core::FunctionReplyObject(0, tr_lts("dds", "MainStructureElement without StructureElements"));
ObjectStructureElement *objStructureElementBuilding = nullptr; ObjectStructureElement *objStructureElementBuilding = nullptr;
int rootStructureElementId = -1; int rootStructureElementId = -1;
const Core::GeoPosition &geoPositionBase = m_data.geoPosition(); const Core::GeoPosition &geoPositionBase = m_data.geoPosition;
const auto mseBaseCoord(LtsCoordTrans::UtmCoordinate::fromGeographic(geoPositionBase.lon(), geoPositionBase.lat())); const auto mseBaseCoord(LtsCoordTrans::UtmCoordinate::fromGeographic(geoPositionBase.lon, geoPositionBase.lat));
for (size_t i = 0; i < mse.elements().size(); ++i) for (size_t i = 0; i < mse.elements.size(); ++i)
{ {
StructureElement &dataSe = mse.elements()[i]; StructureElement &dataSe = mse.elements[i];
if (!isValidJsonObject(dataSe.properties())) if (!isValidJsonObject(dataSe.properties))
return Core::FunctionReplyObject(0, tr_lts("dds", "StructureElement with invalid JSON properties")); return Core::FunctionReplyObject(0, tr_lts("dds", "StructureElement with invalid JSON properties"));
DEBUG_LOG(m_logger) << "#CreateStructureElement: " << dataSe.displayName(); DEBUG_LOG(m_logger) << "#CreateStructureElement: " << dataSe.displayName;
Database::IsmStructureElement dbDataSe(InfrastructureManagement::ObjectStructureElement::toDbData(dataSe)); Database::IsmStructureElement dbDataSe(InfrastructureManagement::ObjectStructureElement::toDbData(dataSe));
dbDataSe.mainStructureElementId = mse.id(); dbDataSe.mainStructureElementId = mse.id;
// id + 1 to make sure the path does not exist when we update the paths with the correct values // id + 1 to make sure the path does not exist when we update the paths with the correct values
const int seDummyParentId = rootStructureElementId < 0 ? mse.id() : rootStructureElementId + 1; const int seDummyParentId = rootStructureElementId < 0 ? mse.id : rootStructureElementId + 1;
dbDataSe.path = LtsUtils::IntArray(std::vector<int>({seDummyParentId, static_cast<int>(i)})); // dummy path for unique constraint dbDataSe.path = LtsUtils::IntArray(std::vector<int>({seDummyParentId, static_cast<int>(i)})); // dummy path for unique constraint
// DEBUG_LOG(m_logger) << "dbDataSe.path: " << mse.id() << ", " << i; // DEBUG_LOG(m_logger) << "dbDataSe.path: " << mse.id << ", " << i;
if (dataSe.id() == 0) if (dataSe.id == 0)
{ {
if (!db()->insert(dbDataSe)) if (!db()->insert(dbDataSe))
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting IsmStructureElement-data into database")); return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting IsmStructureElement-data into database"));
@@ -652,8 +652,8 @@ Core::FunctionReplyObject ObjectMainStructureElement::createStructureElements(Ma
rootStructureElementId = dbDataSe.id; rootStructureElementId = dbDataSe.id;
ObjectStructureElement *objSe = nullptr; ObjectStructureElement *objSe = nullptr;
if (dataSe.id() == 0) if (dataSe.id == 0)
objSe = m_objectStructureElements.value(dataSe.id()); objSe = m_objectStructureElements.value(dataSe.id);
if (!objSe) if (!objSe)
objSe = new ObjectStructureElement(Database::convert(dbDataSe), m_mainHandler, this); objSe = new ObjectStructureElement(Database::convert(dbDataSe), m_mainHandler, this);
@@ -662,22 +662,22 @@ Core::FunctionReplyObject ObjectMainStructureElement::createStructureElements(Ma
{ {
objStructureElementBuilding = objSe; objStructureElementBuilding = objSe;
// make sure to be consistent (will be updated later when se.path is updated) // make sure to be consistent (will be updated later when se.path is updated)
objStructureElementBuilding->getData().mountingPointTypeId(InfrastructureManagement::MountingPointType::Unknown); objStructureElementBuilding->getData().mountingPointTypeId = InfrastructureManagement::MountingPointType::Unknown;
} }
// in two containers - need a sorted one for path updates // in two containers - need a sorted one for path updates
objSeVec += objSe; objSeVec += objSe;
m_objectStructureElements.insert(objSe->getId(), objSe); m_objectStructureElements.insert(objSe->getId(), objSe);
// update GeoPos // update GeoPos
objSe->updateGeoPosition(mseBaseCoord, geoPositionBase.z(), m_data.angle()); objSe->updateGeoPosition(mseBaseCoord, geoPositionBase.z, m_data.angle);
dataSe.geoPosition() = objSe->getGeoPosition(); dataSe.geoPosition = objSe->getGeoPosition();
} }
if (!objStructureElementBuilding) if (!objStructureElementBuilding)
return Core::FunctionReplyObject(0, tr_lts("dds", "MainStructureElement without valid StructureElements")); return Core::FunctionReplyObject(0, tr_lts("dds", "MainStructureElement without valid StructureElements"));
mse.structureElementId(objStructureElementBuilding->getId()); mse.structureElementId = objStructureElementBuilding->getId();
mse.structureElementTypeId(objStructureElementBuilding->getStructureElementTypeId()); mse.structureElementTypeId = objStructureElementBuilding->getStructureElementTypeId();
DEBUG_LOG(m_logger) << "(Re)Created " << mse.elements().size() << " structure elements"; DEBUG_LOG(m_logger) << "(Re)Created " << mse.elements.size() << " structure elements";
return Core::FunctionReplyObject(); return Core::FunctionReplyObject();
} }
@@ -689,21 +689,21 @@ Core::FunctionReplyObject ObjectMainStructureElement::updatePaths(MainStructureE
const std::vector<int> &childParentMapping) const std::vector<int> &childParentMapping)
{ {
// now update parent - child relations // now update parent - child relations
const int buildingId = mse.id(); const int buildingId = mse.id;
// update first element (building SE) // update first element (building SE)
{ {
ObjectStructureElement *objSe = objSeVec.at(0); ObjectStructureElement *objSe = objSeVec.at(0);
StructureElement seData = objSe->getData(); StructureElement seData = objSe->getData();
seData.path().clear(); seData.path.clear();
seData.path().resize(1, seData.id()); seData.path.resize(1, seData.id);
seData.mainStructureElementId(buildingId); seData.mainStructureElementId = buildingId;
objSe->updateObject(seData); objSe->updateObject(seData);
DEBUG_LOG(m_logger) << "UpdatePaths Building = " << seData.displayName(); DEBUG_LOG(m_logger) << "UpdatePaths Building = " << seData.displayName;
// update mse.elements // update mse.elements
mse.elements()[0] = objSe->getData(); mse.elements[0] = objSe->getData();
} }
for (int i = 1; i < objSeVec.size(); ++i) for (int i = 1; i < objSeVec.size(); ++i)
@@ -730,15 +730,15 @@ Core::FunctionReplyObject ObjectMainStructureElement::updatePaths(MainStructureE
// update db // update db
StructureElement seData = objSe->getData(); StructureElement seData = objSe->getData();
DEBUG_LOG(m_logger) << "Updated path for element: " << seData.displayName() << ", path = " << p; DEBUG_LOG(m_logger) << "Updated path for element: " << seData.displayName << ", path = " << p;
seData.path(path); seData.path = path;
seData.mainStructureElementId(buildingId); seData.mainStructureElementId = buildingId;
const Core::FunctionReplyObject fro = objSe->updateObject(seData); const Core::FunctionReplyObject fro = objSe->updateObject(seData);
if (fro.error()) if (fro.error())
return fro; return fro;
// update mse.elements // update mse.elements
mse.elements()[i] = objSe->getData(); mse.elements[i] = objSe->getData();
} }
DEBUG_LOG(m_logger) << "Updated paths for " << objSeVec.size() << " structure elements"; DEBUG_LOG(m_logger) << "Updated paths for " << objSeVec.size() << " structure elements";
return Core::FunctionReplyObject(); return Core::FunctionReplyObject();
@@ -748,10 +748,10 @@ Core::FunctionReplyObject ObjectMainStructureElement::updatePaths(MainStructureE
//------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------
bool ObjectMainStructureElement::isStructureElementDeletable(const StructureElement &se) bool ObjectMainStructureElement::isStructureElementDeletable(const StructureElement &se)
{ {
if (se.structureElementTypeId() == InfrastructureManagement::StructureElementType::Building) if (se.structureElementTypeId == InfrastructureManagement::StructureElementType::Building)
return false; return false;
if (se.structureElementTypeId() == InfrastructureManagement::StructureElementType::MountingPoint && if (se.structureElementTypeId == InfrastructureManagement::StructureElementType::MountingPoint &&
se.mountingPointTypeId() == InfrastructureManagement::MountingPointType::BuildingControlUnit) se.mountingPointTypeId == InfrastructureManagement::MountingPointType::BuildingControlUnit)
return false; return false;
return true; return true;
} }
@@ -766,15 +766,15 @@ Database::IsmMainStructureElement ObjectMainStructureElement::toDbData(const Mai
{ {
Database::IsmMainStructureElement dbData; Database::IsmMainStructureElement dbData;
dbData.id = ddsData.id(); dbData.id = ddsData.id;
dbData.name = QString::fromStdString(ddsData.name()); dbData.name = QString::fromStdString(ddsData.name);
dbData.description = QString::fromStdString(ddsData.description()); dbData.description = QString::fromStdString(ddsData.description);
dbData.geoPosition = LtsUtils::QPoint3D(ddsData.geoPosition().lon(), ddsData.geoPosition().lat(), ddsData.geoPosition().z()); dbData.geoPosition = LtsUtils::QPoint3D(ddsData.geoPosition.lon, ddsData.geoPosition.lat, ddsData.geoPosition.z);
dbData.angle = ddsData.angle(); dbData.angle = ddsData.angle;
dbData.modelId = ddsData.modelId(); dbData.modelId = ddsData.modelId;
dbData.externalWlsId = ddsData.externalWlsId(); dbData.externalWlsId = ddsData.externalWlsId;
dbData.groupId = ddsData.groupId(); dbData.groupId = ddsData.groupId;
dbData.properties = QString::fromStdString(ddsData.properties()); dbData.properties = QString::fromStdString(ddsData.properties);
return dbData; return dbData;
} }
@@ -36,12 +36,12 @@ public:
ObjectStructureElement *createStructureElementObject(const Database::IsmStructureElement &dbData); ObjectStructureElement *createStructureElementObject(const Database::IsmStructureElement &dbData);
qint32 getId() const { return m_data.id(); } qint32 getId() const { return m_data.id; }
qint32 getStructureElementId() const { return m_data.structureElementId(); } qint32 getStructureElementId() const { return m_data.structureElementId; }
const ObjectStructureElement *getMainStructureElementMountingPoint() const; const ObjectStructureElement *getMainStructureElementMountingPoint() const;
QString getDescription() const { return QString::fromStdString(m_data.description()); } QString getDescription() const { return QString::fromStdString(m_data.description); }
QString getName() const { return QString::fromStdString(m_data.name()); } QString getName() const { return QString::fromStdString(m_data.name); }
std::vector<InfrastructureManagement::StructureElement> getElements() const { return m_data.elements(); } std::vector<InfrastructureManagement::StructureElement> getElements() const { return m_data.elements; }
QMap<int, ObjectStructureElement *> getStructureElements() const { return m_objectStructureElements; } QMap<int, ObjectStructureElement *> getStructureElements() const { return m_objectStructureElements; }
const MainStructureElement &getData() const { return m_data; } const MainStructureElement &getData() const { return m_data; }
const MainFootprint &getFootprint() const { return m_footprint; } const MainFootprint &getFootprint() const { return m_footprint; }
@@ -26,7 +26,7 @@ Core::FunctionReplyObject ObjectMountingPointAsset::createObject(const MountingP
{ {
m_data = data; m_data = data;
if (m_data.id() <= 0) if (m_data.id <= 0)
{ {
Database::IsmMountingPointAsset dbData; Database::IsmMountingPointAsset dbData;
dbData = toDbData(data); dbData = toDbData(data);
@@ -34,14 +34,14 @@ Core::FunctionReplyObject ObjectMountingPointAsset::createObject(const MountingP
if (!db()->insert(dbData)) if (!db()->insert(dbData))
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting IsmMountingPointAsset-data into database")); return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting IsmMountingPointAsset-data into database"));
m_data.id(dbData.id); m_data.id = dbData.id;
DEBUG_LOG(m_logger) << "New Id: " << m_data.id(); DEBUG_LOG(m_logger) << "New Id: " << m_data.id;
} }
// Publish Data via DDS // Publish Data via DDS
onPublishData(); onPublishData();
return Core::FunctionReplyObject(m_data.id()); return Core::FunctionReplyObject(m_data.id);
} }
//------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------
@@ -50,33 +50,33 @@ Core::FunctionReplyObject ObjectMountingPointAsset::updateObject(const MountingP
Database::IsmMountingPointAsset dbData = toDbData(data); Database::IsmMountingPointAsset dbData = toDbData(data);
if (!db()->update(dbData)) if (!db()->update(dbData))
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Error updating IsmMountingPointAsset-data into database")); return Core::FunctionReplyObject(data.id, tr_lts("dds", "Error updating IsmMountingPointAsset-data into database"));
m_data = data; m_data = data;
DEBUG_LOG(m_logger) << "Data changed for Id: " << m_data.id(); DEBUG_LOG(m_logger) << "Data changed for Id: " << m_data.id;
// Publish Data via DTS // Publish Data via DTS
onPublishData(); onPublishData();
return Core::FunctionReplyObject(m_data.id()); return Core::FunctionReplyObject(m_data.id);
} }
//------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------
Core::FunctionReplyObject ObjectMountingPointAsset::removeObject() Core::FunctionReplyObject ObjectMountingPointAsset::removeObject()
{ {
if (!db()->removeIsmMountingPointAsset(m_data.id())) if (!db()->removeIsmMountingPointAsset(m_data.id))
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "MountingPointAsset with id %1 can not be removed from DB")).arg(m_data.id()); return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "MountingPointAsset with id %1 can not be removed from DB")).arg(m_data.id);
if (!dts()->removeMountingPointAssetByKey(m_data.id())) if (!dts()->removeMountingPointAssetByKey(m_data.id))
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "MountingPointAsset with id %1 can not be removed from DDS")).arg(m_data.id()); return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "MountingPointAsset with id %1 can not be removed from DDS")).arg(m_data.id);
return Core::FunctionReplyObject(m_data.id()); return Core::FunctionReplyObject(m_data.id);
} }
//------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------
void ObjectMountingPointAsset::onPublishData() void ObjectMountingPointAsset::onPublishData()
{ {
INFO_LOG(m_logger) << "Publish IsmMountingPointAsset-data to dds (" << m_data.id() << ") ..."; INFO_LOG(m_logger) << "Publish IsmMountingPointAsset-data to dds (" << m_data.id << ") ...";
if (!dts()->publish(m_data)) if (!dts()->publish(m_data))
ERROR_LOG(m_logger) << "Error publishing IsmMountingPointAsset-data to dds"; ERROR_LOG(m_logger) << "Error publishing IsmMountingPointAsset-data to dds";
@@ -91,11 +91,11 @@ Database::IsmMountingPointAsset ObjectMountingPointAsset::toDbData(const Mountin
{ {
Database::IsmMountingPointAsset dbData; Database::IsmMountingPointAsset dbData;
dbData.id = ddsData.id(); dbData.id = ddsData.id;
dbData.assetId = ddsData.assetId(); dbData.assetId = ddsData.assetId;
dbData.structureElementId = ddsData.structureElementId(); dbData.structureElementId = ddsData.structureElementId;
dbData.name = QString::fromStdString(ddsData.name()); dbData.name = QString::fromStdString(ddsData.name);
dbData.lastUpdated = QDateTime::fromMSecsSinceEpoch(ddsData.lastUpdated()); dbData.lastUpdated = QDateTime::fromMSecsSinceEpoch(ddsData.lastUpdated);
return dbData; return dbData;
} }
@@ -106,11 +106,11 @@ MountingPointAsset ObjectMountingPointAsset::toDdsData(const Database::IsmMounti
{ {
MountingPointAsset ddsData; MountingPointAsset ddsData;
ddsData.id(dbData.id); ddsData.id = dbData.id;
ddsData.assetId(dbData.assetId); ddsData.assetId = dbData.assetId;
ddsData.structureElementId(dbData.structureElementId); ddsData.structureElementId = dbData.structureElementId;
ddsData.name(dbData.name.toStdString()); ddsData.name = dbData.name.toStdString();
ddsData.lastUpdated(dbData.lastUpdated.toMSecsSinceEpoch()); ddsData.lastUpdated = dbData.lastUpdated.toMSecsSinceEpoch();
return ddsData; return ddsData;
} }
@@ -29,15 +29,15 @@ public:
qint32 getId() const qint32 getId() const
{ {
return m_data.id(); return m_data.id;
} }
qint32 getStructureElementId() const qint32 getStructureElementId() const
{ {
return m_data.structureElementId(); return m_data.structureElementId;
} }
qint32 getAssetId() const qint32 getAssetId() const
{ {
return m_data.assetId(); return m_data.assetId;
} }
MountingPointAsset getData() const MountingPointAsset getData() const
{ {
@@ -32,32 +32,32 @@ Core::FunctionReplyObject ObjectSpecialArea::createObject(const SpecialArea &dat
onPublishData(); // publish data via DDS onPublishData(); // publish data via DDS
return Core::FunctionReplyObject(m_data.id()); return Core::FunctionReplyObject(m_data.id);
} }
Core::FunctionReplyObject ObjectSpecialArea::updateObject(const SpecialArea &data) Core::FunctionReplyObject ObjectSpecialArea::updateObject(const SpecialArea &data)
{ {
m_data = data; m_data = data;
DEBUG_LOG(m_logger) << "Data changed for Id: " << m_data.id(); DEBUG_LOG(m_logger) << "Data changed for Id: " << m_data.id;
onPublishData(); // publish data via DTS onPublishData(); // publish data via DTS
return Core::FunctionReplyObject(m_data.id()); return Core::FunctionReplyObject(m_data.id);
} }
Core::FunctionReplyObject ObjectSpecialArea::removeObject() Core::FunctionReplyObject ObjectSpecialArea::removeObject()
{ {
if (!dts()->removeSpecialAreaByKey(m_data.id())) if (!dts()->removeSpecialAreaByKey(m_data.id))
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "SpecialArea with id %1 can not be removed from DDS")).arg(m_data.id()); return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "SpecialArea with id %1 can not be removed from DDS")).arg(m_data.id);
return Core::FunctionReplyObject(m_data.id()); return Core::FunctionReplyObject(m_data.id);
} }
//----------------------------------------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------------------------------------
void ObjectSpecialArea::onPublishData() void ObjectSpecialArea::onPublishData()
{ {
INFO_LOG(m_logger) << "Publish IsmSpecialArea-data to dds (" << m_data.id() << ") ..."; INFO_LOG(m_logger) << "Publish IsmSpecialArea-data to dds (" << m_data.id << ") ...";
if (!dts()->publish(m_data)) if (!dts()->publish(m_data))
ERROR_LOG(m_logger) << "Error publishing IsmSpecialArea-data to dds"; ERROR_LOG(m_logger) << "Error publishing IsmSpecialArea-data to dds";
@@ -69,36 +69,36 @@ SpecialArea ObjectSpecialArea::toDdsData(const Database::IsmSpecialArea &dbData)
{ {
SpecialArea ddsData; SpecialArea ddsData;
ddsData.id(dbData.id); ddsData.id = dbData.id;
ddsData.name(dbData.name.toStdString()); ddsData.name = dbData.name.toStdString();
ddsData.specialType(dbData.specialType.underlying()); ddsData.specialType = dbData.specialType;
const QJsonDocument doc(QJsonDocument::fromJson(dbData.polygon.toUtf8())); const QJsonDocument doc(QJsonDocument::fromJson(dbData.polygon.toUtf8()));
const QJsonObject obj(doc.object()); const QJsonObject obj(doc.object());
const QJsonArray arrPoly = obj.value(QStringLiteral("polygon")).toArray(); const QJsonArray arrPoly = obj.value(QStringLiteral("polygon")).toArray();
ddsData.polygon().reserve(arrPoly.size()); ddsData.polygon.reserve(arrPoly.size());
for (const auto &ele : arrPoly) for (const auto &ele : arrPoly)
{ {
const QJsonObject objSeg(ele.toObject()); const QJsonObject objSeg(ele.toObject());
Core::GeoPosition2D element; Core::GeoPosition2D element;
element.lat(objSeg[QStringLiteral("lat")].toDouble()); element.lat = objSeg[QStringLiteral("lat")].toDouble();
element.lon(objSeg[QStringLiteral("lon")].toDouble()); element.lon = objSeg[QStringLiteral("lon")].toDouble();
ddsData.polygon().push_back(std::move(element)); ddsData.polygon.push_back(std::move(element));
} }
//End elements //End elements
QPolygonF tmp; QPolygonF tmp;
tmp.reserve(ddsData.polygon().size()); tmp.reserve(ddsData.polygon.size());
for (const Core::GeoPosition2D &pos : qAsConst(ddsData.polygon())) for (const Core::GeoPosition2D &pos : qAsConst(ddsData.polygon))
tmp.push_back(QPointF(pos.lon(),pos.lat())); tmp.push_back(QPointF(pos.lon, pos.lat));
QRectF boundingBox = tmp.boundingRect(); QRectF boundingBox = tmp.boundingRect();
ddsData.boundingBoxBottomLeft() = Core::GeoPosition2D(boundingBox.bottomLeft().x(), boundingBox.bottomLeft().y()); ddsData.boundingBoxBottomLeft = Core::GeoPosition2D(boundingBox.bottomLeft().x(), boundingBox.bottomLeft().y());
ddsData.boundingBoxTopRight() = Core::GeoPosition2D(boundingBox.topRight().x(), boundingBox.topRight().y()); ddsData.boundingBoxTopRight = Core::GeoPosition2D(boundingBox.topRight().x(), boundingBox.topRight().y());
// init data not in db // init data not in db
ddsData.isDeleted(false); ddsData.isDeleted = false;
ddsData.isUsed(false); ddsData.isUsed = false;
return ddsData; return ddsData;
} }
@@ -33,7 +33,7 @@ public:
Core::FunctionReplyObject removeObject(); Core::FunctionReplyObject removeObject();
static SpecialArea toDdsData(const Database::IsmSpecialArea &dbData); static SpecialArea toDdsData(const Database::IsmSpecialArea &dbData);
int32_t getId() const { return m_data.id(); } int32_t getId() const { return m_data.id; }
SpecialArea getData() const { return m_data; } SpecialArea getData() const { return m_data; }
protected: protected:
@@ -22,7 +22,7 @@ ObjectStructureElement::ObjectStructureElement(MainHandler *mainHandler, ObjectM
: Base(mainHandler, getLogger("ObjectStructureElement")) : Base(mainHandler, getLogger("ObjectStructureElement"))
, m_objMse(objMse) , m_objMse(objMse)
{ {
m_data.mainStructureElementId(objMse->getId()); m_data.mainStructureElementId = objMse->getId();
} }
// ------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------
@@ -31,19 +31,19 @@ ObjectStructureElement::ObjectStructureElement(const StructureElement &data, Mai
, m_data(data) , m_data(data)
, m_objMse(objMse) , m_objMse(objMse)
{ {
m_data.mainStructureElementId(objMse->getId()); m_data.mainStructureElementId = objMse->getId();
} }
// ------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------
bool ObjectStructureElement::isValid() const bool ObjectStructureElement::isValid() const
{ {
return m_data.id() > 0; return m_data.id > 0;
} }
// ------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------
bool ObjectStructureElement::isUsed() const bool ObjectStructureElement::isUsed() const
{ {
return m_data.isUsed(); return m_data.isUsed;
} }
// ------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------
@@ -51,16 +51,16 @@ Core::FunctionReplyObject ObjectStructureElement::createObject(const Database::I
{ {
m_data = Database::convert(dbData); m_data = Database::convert(dbData);
if (m_data.id() <= 0) if (m_data.id <= 0)
{ {
m_data.isUsed(false); m_data.isUsed = false;
Database::IsmStructureElement dbData2(dbData); Database::IsmStructureElement dbData2(dbData);
if (!db()->insert(dbData2)) if (!db()->insert(dbData2))
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting IsmStructureElement-data into database")); return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting IsmStructureElement-data into database"));
m_data.id(dbData2.id); m_data.id = dbData2.id;
DEBUG_LOG(m_logger) << "New Id: " << m_data.id(); DEBUG_LOG(m_logger) << "New Id: " << m_data.id;
} }
updateGeoPosition(); updateGeoPosition();
@@ -68,71 +68,71 @@ Core::FunctionReplyObject ObjectStructureElement::createObject(const Database::I
// Publish Data via DTS // Publish Data via DTS
//onPublishData(); //onPublishData();
return Core::FunctionReplyObject(m_data.id()); return Core::FunctionReplyObject(m_data.id);
} }
// ------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------
Core::FunctionReplyObject ObjectStructureElement::updateObject(const StructureElement &data) Core::FunctionReplyObject ObjectStructureElement::updateObject(const StructureElement &data)
{ {
if (!isValid()) if (!isValid())
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Object not valid/blocked")); return Core::FunctionReplyObject(data.id, tr_lts("dds", "Object not valid/blocked"));
if (!db()->update(toDbData(data))) if (!db()->update(toDbData(data)))
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Error updating StructureElement with id %1 in database")).arg(data.id()); return Core::FunctionReplyObject(data.id, tr_lts("dds", "Error updating StructureElement with id %1 in database")).arg(data.id);
m_data = data; m_data = data;
TRACE_LOG(m_logger) << "Data changed for Id: " << m_data.id(); TRACE_LOG(m_logger) << "Data changed for Id: " << m_data.id;
updateGeoPosition(); updateGeoPosition();
// Publish Data via DTS // Publish Data via DTS
//onPublishData(); //onPublishData();
return Core::FunctionReplyObject(m_data.id()); return Core::FunctionReplyObject(m_data.id);
} }
// ------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------
Core::FunctionReplyObject ObjectStructureElement::setUsed(bool isUsed) Core::FunctionReplyObject ObjectStructureElement::setUsed(bool isUsed)
{ {
if (!isValid()) if (!isValid())
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "Trying to update an already removed IsmStructureElement object")); return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "Trying to update an already removed IsmStructureElement object"));
m_data.isUsed(isUsed); m_data.isUsed = isUsed;
// Publish Data via DTS // Publish Data via DTS
//onPublishData(); //onPublishData();
return Core::FunctionReplyObject(m_data.id()); return Core::FunctionReplyObject(m_data.id);
} }
// ------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------
Core::FunctionReplyObject ObjectStructureElement::removeObject() Core::FunctionReplyObject ObjectStructureElement::removeObject()
{ {
if (isUsed()) if (isUsed())
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "StructureElement still in use")); return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "StructureElement still in use"));
if (!db()->removeIsmStructureElement(m_data.id())) if (!db()->removeIsmStructureElement(m_data.id))
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "StructureElement with id %1 can not be removed from DB")).arg(m_data.id()); return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "StructureElement with id %1 can not be removed from DB")).arg(m_data.id);
return Core::FunctionReplyObject(m_data.id()); return Core::FunctionReplyObject(m_data.id);
} }
// ------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------
void ObjectStructureElement::updateGeoPosition() void ObjectStructureElement::updateGeoPosition()
{ {
if (m_data.mainStructureElementId() <= 0) if (m_data.mainStructureElementId <= 0)
return; return;
const Core::GeoPosition &geoPositionBase = m_objMse->getData().geoPosition(); const Core::GeoPosition &geoPositionBase = m_objMse->getData().geoPosition;
const double angleDegree = m_objMse->getData().angle(); const double angleDegree = m_objMse->getData().angle;
updateGeoPosition(LtsCoordTrans::UtmCoordinate::fromGeographic(geoPositionBase.lon(), geoPositionBase.lat()), geoPositionBase.z(), angleDegree); updateGeoPosition(LtsCoordTrans::UtmCoordinate::fromGeographic(geoPositionBase.lon, geoPositionBase.lat), geoPositionBase.z, angleDegree);
} }
// ------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------
void ObjectStructureElement::updateGeoPosition(const LtsCoordTrans::UtmCoordinate &basePoint, double zBase, double angleDeg) void ObjectStructureElement::updateGeoPosition(const LtsCoordTrans::UtmCoordinate &basePoint, double zBase, double angleDeg)
{ {
const QPointF offset = rotatePoint(m_data.relPosition().offsetX(), m_data.relPosition().offsetY(), angleDeg); const QPointF offset = rotatePoint(m_data.relPosition.offsetX, m_data.relPosition.offsetY, angleDeg);
const QPointF geoPos = basePoint.geographic(offset); const QPointF geoPos = basePoint.geographic(offset);
m_data.geoPosition() = Core::GeoPosition(geoPos.x(), geoPos.y(), m_data.relPosition().offsetZ() + zBase); m_data.geoPosition = Core::GeoPosition(geoPos.x(), geoPos.y(), m_data.relPosition.offsetZ + zBase);
} }
// ------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------
@@ -144,20 +144,22 @@ Database::IsmStructureElement ObjectStructureElement::toDbData(const StructureEl
{ {
Database::IsmStructureElement dbData; Database::IsmStructureElement dbData;
dbData.id = ddsData.id(); dbData.id = ddsData.id;
dbData.name = QString::fromStdString(ddsData.name()); dbData.name = QString::fromStdString(ddsData.name);
dbData.displayName = QString::fromStdString(ddsData.displayName()); dbData.displayName = QString::fromStdString(ddsData.displayName);
dbData.mainStructureElementId = ddsData.mainStructureElementId(); dbData.mainStructureElementId = ddsData.mainStructureElementId;
dbData.structureElementTypeId = ddsData.structureElementTypeId(); dbData.structureElementTypeId = ddsData.structureElementTypeId;
dbData.path = LtsUtils::IntArray(ddsData.path()); dbData.path = LtsUtils::IntArray(ddsData.path);
dbData.mountingPointId = ddsData.mountingPointId(); dbData.mountingPointId = ddsData.mountingPointId;
dbData.barcode = QString::fromStdString(ddsData.barcode()); dbData.barcode = QString::fromStdString(ddsData.barcode);
dbData.relPosition = LtsUtils::QPoint3D(ddsData.relPosition()); dbData.relPosition = LtsUtils::QPoint3D(ddsData.relPosition.offsetX,
dbData.mountingPointTypeId = ddsData.mountingPointTypeId(); ddsData.relPosition.offsetY,
dbData.orientation = LtsUtils::QPoint3D(ddsData.orientation().heave(), ddsData.relPosition.offsetZ);
ddsData.orientation().pitch(), dbData.mountingPointTypeId = ddsData.mountingPointTypeId;
ddsData.orientation().roll()); dbData.orientation = LtsUtils::QPoint3D(ddsData.orientation.heave,
dbData.properties = QString::fromStdString(ddsData.properties()); ddsData.orientation.pitch,
ddsData.orientation.roll);
dbData.properties = QString::fromStdString(ddsData.properties);
return dbData; return dbData;
} }
@@ -37,31 +37,31 @@ public:
qint32 getId() const qint32 getId() const
{ {
return m_data.id(); return m_data.id;
} }
const std::string &getName() const const std::string &getName() const
{ {
return m_data.displayName(); return m_data.displayName;
} }
std::vector<int32_t> getPath() const std::vector<int32_t> getPath() const
{ {
return m_data.path(); return m_data.path;
} }
qint32 getParentId() const qint32 getParentId() const
{ {
return m_data.path().size() > 0 ? m_data.path().at(m_data.path().size() - 1) : 0; return !m_data.path.empty() ? m_data.path.at(m_data.path.size() - 1) : 0;
} }
qint32 getMainStructureElementId() const qint32 getMainStructureElementId() const
{ {
return m_data.mainStructureElementId(); return m_data.mainStructureElementId;
} }
InfrastructureManagement::StructureElementType getStructureElementTypeId() const InfrastructureManagement::StructureElementType getStructureElementTypeId() const
{ {
return m_data.structureElementTypeId(); return m_data.structureElementTypeId;
} }
InfrastructureManagement::MountingPointType getMountingPointType() const InfrastructureManagement::MountingPointType getMountingPointType() const
{ {
return m_data.mountingPointTypeId(); return m_data.mountingPointTypeId;
} }
InfrastructureManagement::StructureElement &getData() InfrastructureManagement::StructureElement &getData()
{ {
@@ -73,11 +73,11 @@ public:
} }
const Core::RelativePosition &getRelativePosition() const const Core::RelativePosition &getRelativePosition() const
{ {
return m_data.relPosition(); return m_data.relPosition;
} }
const Core::GeoPosition &getGeoPosition() const const Core::GeoPosition &getGeoPosition() const
{ {
return m_data.geoPosition(); return m_data.geoPosition;
} }
ObjectMainStructureElement *getMainStructureElement() const ObjectMainStructureElement *getMainStructureElement() const
{ {
@@ -98,8 +98,8 @@ QJsonObject ParseBuildingXml::soundAreaToJson() const
QJsonArray arrayGeometry; QJsonArray arrayGeometry;
for (const auto &point : m_soundArea.geometry) for (const auto &point : m_soundArea.geometry)
{ {
json[QStringLiteral("lat")] = point.lat(); json[QStringLiteral("lat")] = point.lat;
json[QStringLiteral("lon")] = point.lon(); json[QStringLiteral("lon")] = point.lon;
arrayGeometry.append(json); arrayGeometry.append(json);
} }
QJsonArray arrayEgcus; QJsonArray arrayEgcus;
@@ -120,7 +120,7 @@ bool ParseBuildingXml::parseXml()
{ {
DEBUG_LOG(m_logger) << "parseXml"; DEBUG_LOG(m_logger) << "parseXml";
m_request = MainStructureElementModifyRequest(); m_request = MainStructureElementModifyRequest();
m_request.properties("{}"); m_request.properties = "{}";
m_lastError.clear(); m_lastError.clear();
bool bRet = true; bool bRet = true;
@@ -160,7 +160,7 @@ bool ParseBuildingXml::parseXml()
properties[QStringLiteral("soundArea")] = soundAreaToJson(); properties[QStringLiteral("soundArea")] = soundAreaToJson();
} }
m_request.properties(QJsonDocument(properties).toJson(QJsonDocument::Compact).toStdString()); m_request.properties = QJsonDocument(properties).toJson(QJsonDocument::Compact).toStdString();
DEBUG_LOG(m_logger) << "Finished import for file " << m_xmlFilename; DEBUG_LOG(m_logger) << "Finished import for file " << m_xmlFilename;
return bRet; return bRet;
@@ -284,8 +284,8 @@ bool ParseBuildingXml::parseXmlSoundArea()
INFO_LOG(m_logger) << "Point=" << point.tagName() INFO_LOG(m_logger) << "Point=" << point.tagName()
<< " lat = " << point.firstChildElement(QStringLiteral("lat")).text().toDouble() << " lat = " << point.firstChildElement(QStringLiteral("lat")).text().toDouble()
<< " lon = " << point.firstChildElement(QStringLiteral("lon")).text().toDouble(); << " lon = " << point.firstChildElement(QStringLiteral("lon")).text().toDouble();
geoPosition.lat(point.firstChildElement(QStringLiteral("lat")).text().toDouble()); geoPosition.lat = point.firstChildElement(QStringLiteral("lat")).text().toDouble();
geoPosition.lon(point.firstChildElement(QStringLiteral("lon")).text().toDouble()); geoPosition.lon = point.firstChildElement(QStringLiteral("lon")).text().toDouble();
m_soundArea.geometry.push_back(geoPosition); m_soundArea.geometry.push_back(geoPosition);
} }
@@ -377,9 +377,9 @@ QVector<ParseBuildingXml::BuildingMetaInfo> ParseBuildingXml::parseMetaXml(const
info.geoPosition = positionFromElement<Core::GeoPosition>(posElem); info.geoPosition = positionFromElement<Core::GeoPosition>(posElem);
INFO_LOG(m_logger) << "Found Building position: (" << info.geoPosition.lon() << ", (" INFO_LOG(m_logger) << "Found Building position: (" << info.geoPosition.lon << ", ("
<< info.geoPosition.lat() << ", (" << info.geoPosition.lat << ", ("
<< info.geoPosition.z() << ")"; << info.geoPosition.z << ")";
ret += info; ret += info;
} }
@@ -400,38 +400,38 @@ void ParseBuildingXml::parseXmlInternal()
DEBUG_LOG(m_logger) << "Start import for file " << m_xmlFilename; DEBUG_LOG(m_logger) << "Start import for file " << m_xmlFilename;
m_request.angle(m_rotationAngleDegree); m_request.angle = m_rotationAngleDegree;
m_request.geoPosition(m_geoPosition); m_request.geoPosition = m_geoPosition;
m_request.modelId(getInteger(getChildElement(baseGroupElem, QStringLiteral("ModelId")), QStringLiteral("Id"))); m_request.modelId = getInteger(getChildElement(baseGroupElem, QStringLiteral("ModelId")), QStringLiteral("Id"));
m_request.name(getChildElement(baseGroupElem, QStringLiteral("Name")).text().toStdString()); m_request.name = getChildElement(baseGroupElem, QStringLiteral("Name")).text().toStdString();
m_request.description(m_request.name()); m_request.description = m_request.name;
INFO_LOG(m_logger) << "Importing building with name: " << m_request.name(); INFO_LOG(m_logger) << "Importing building with name: " << m_request.name;
InfrastructureManagement::StructureElement seBuilding; InfrastructureManagement::StructureElement seBuilding;
seBuilding.name(m_request.name()); seBuilding.name = m_request.name;
seBuilding.displayName(m_request.name()); seBuilding.displayName = m_request.name;
seBuilding.structureElementTypeId(InfrastructureManagement::StructureElementType::Building); seBuilding.structureElementTypeId = InfrastructureManagement::StructureElementType::Building;
seBuilding.mountingPointTypeId(InfrastructureManagement::MountingPointType::Unknown); seBuilding.mountingPointTypeId = InfrastructureManagement::MountingPointType::Unknown;
seBuilding.properties("{}"); seBuilding.properties = "{}";
addElementToRequest(seBuilding, -1); addElementToRequest(seBuilding, -1);
InfrastructureManagement::StructureElement seMPBuilding; InfrastructureManagement::StructureElement seMPBuilding;
seMPBuilding.name(m_request.name()); seMPBuilding.name = m_request.name;
seMPBuilding.displayName(m_request.name()); seMPBuilding.displayName = m_request.name;
m_buildingName = QString::fromStdString(seBuilding.displayName()); m_buildingName = QString::fromStdString(seBuilding.displayName);
seMPBuilding.structureElementTypeId(InfrastructureManagement::StructureElementType::MountingPoint); seMPBuilding.structureElementTypeId = InfrastructureManagement::StructureElementType::MountingPoint;
seMPBuilding.mountingPointTypeId(InfrastructureManagement::MountingPointType::BuildingControlUnit); seMPBuilding.mountingPointTypeId = InfrastructureManagement::MountingPointType::BuildingControlUnit;
seMPBuilding.properties("{}"); seMPBuilding.properties = "{}";
addElementToRequest(seMPBuilding, 0); addElementToRequest(seMPBuilding, 0);
//SWPA 2/22 - GUEZE-1459 - IO 2022.11.10 - do not import GV for new Guez Buildings //SWPA 2/22 - GUEZE-1459 - IO 2022.11.10 - do not import GV for new Guez Buildings
#ifndef GUEZ_MODE #ifndef GUEZ_MODE
InfrastructureManagement::StructureElement seGVBuilding; InfrastructureManagement::StructureElement seGVBuilding;
seGVBuilding.name(m_request.name()+std::string("_gv")); seGVBuilding.name = m_request.name + std::string("_gv");
seGVBuilding.displayName(m_request.name()+std::string("_gv")); seGVBuilding.displayName = m_request.name + std::string("_gv");
seGVBuilding.structureElementTypeId(InfrastructureManagement::StructureElementType::MountingPoint); seGVBuilding.structureElementTypeId = InfrastructureManagement::StructureElementType::MountingPoint;
seGVBuilding.mountingPointTypeId(InfrastructureManagement::MountingPointType::BuildingNetworkSwitch); seGVBuilding.mountingPointTypeId = InfrastructureManagement::MountingPointType::BuildingNetworkSwitch;
seGVBuilding.properties("{}"); seGVBuilding.properties = "{}";
addElementToRequest(seGVBuilding, 0); addElementToRequest(seGVBuilding, 0);
#endif #endif
@@ -464,13 +464,13 @@ void ParseBuildingXml::importFootprint(const QDomElement &parent)
if (coordElem.isNull()) if (coordElem.isNull())
continue; continue;
FootprintElement fpElem; FootprintElement fpElem;
fpElem.relPosition() = positionFromElement<Core::RelativePosition>(coordElem); fpElem.relPosition = positionFromElement<Core::RelativePosition>(coordElem);
fp.resize(fp.size() + 1, fpElem); fp.resize(fp.size() + 1, fpElem);
} }
break; break;
} }
if (fp.size() > 0) if (fp.size() > 0)
m_request.footprint(std::move(fp)); m_request.footprint = std::move(fp);
} }
//------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------
@@ -482,17 +482,17 @@ void ParseBuildingXml::importExternalReferences(const QDomElement &parent,
{ {
const StructureElement se = getStructureElement(extRefElem); const StructureElement se = getStructureElement(extRefElem);
// we don't care about BCU Mounting positions inside xml file - we create our own // we don't care about BCU Mounting positions inside xml file - we create our own
if (se.mountingPointTypeId() == MountingPointType::BuildingControlUnit) if (se.mountingPointTypeId == MountingPointType::BuildingControlUnit)
{ {
INFO_LOG(m_logger) << "Ignoring xml-internal BuildingControl mounting point - not needed"; INFO_LOG(m_logger) << "Ignoring xml-internal BuildingControl mounting point - not needed";
continue; continue;
} }
if (se.mountingPointTypeId() == MountingPointType::Unknown) if (se.mountingPointTypeId == MountingPointType::Unknown)
{ {
INFO_LOG(m_logger) << "Ignoring unknown mounting point type with subId " << se.mountingPointId(); INFO_LOG(m_logger) << "Ignoring unknown mounting point type with subId " << se.mountingPointId;
continue; continue;
} }
INFO_LOG(m_logger) << "importExternalReferences: " << se.displayName() << ", parentIdx = " << parentIdx; INFO_LOG(m_logger) << "importExternalReferences: " << se.displayName << ", parentIdx = " << parentIdx;
addElementToRequest(se, parentIdx); addElementToRequest(se, parentIdx);
} }
} }
@@ -511,11 +511,11 @@ void ParseBuildingXml::importFloors(const QDomElement &parent,
INFO_LOG(m_logger) << "importFloors: " << nameElement.text() << ", parentIdx = " << parentIdx; INFO_LOG(m_logger) << "importFloors: " << nameElement.text() << ", parentIdx = " << parentIdx;
StructureElement se; StructureElement se;
se.name(nameElement.text().simplified().toStdString()); se.name = nameElement.text().simplified().toStdString();
se.displayName(se.name()); se.displayName = se.name;
se.structureElementTypeId(InfrastructureManagement::StructureElementType::Floor); se.structureElementTypeId = InfrastructureManagement::StructureElementType::Floor;
se.mountingPointTypeId(InfrastructureManagement::MountingPointType::Unknown); se.mountingPointTypeId = InfrastructureManagement::MountingPointType::Unknown;
se.properties("{}"); se.properties = "{}";
// read base height from xml comment // read base height from xml comment
const QDomElement commentElement = getChildElement(floorElem, QStringLiteral("Comment"), false); const QDomElement commentElement = getChildElement(floorElem, QStringLiteral("Comment"), false);
@@ -525,11 +525,11 @@ void ParseBuildingXml::importFloors(const QDomElement &parent,
if (comm.at(0) == QStringLiteral("base_height")) if (comm.at(0) == QStringLiteral("base_height"))
baseHeight = comm.at(1).toDouble(); baseHeight = comm.at(1).toDouble();
DEBUG_LOG(m_logger) << "base_height = " << baseHeight; DEBUG_LOG(m_logger) << "base_height = " << baseHeight;
se.relPosition().offsetZ(baseHeight); se.relPosition.offsetZ = baseHeight;
addElementToRequest(se, parentIdx); addElementToRequest(se, parentIdx);
const int curIdx = m_request.elements().size() - 1; const int curIdx = static_cast<int>(m_request.elements.size()) - 1;
importRooms(floorElem, curIdx); importRooms(floorElem, curIdx);
} }
} }
@@ -547,30 +547,30 @@ void ParseBuildingXml::importRooms(const QDomElement &parent,
const int subId = getInteger(getChildElement(roomElem, QStringLiteral("SubId")), QStringLiteral("ID")); const int subId = getInteger(getChildElement(roomElem, QStringLiteral("SubId")), QStringLiteral("ID"));
StructureElement se; StructureElement se;
se.name(nameElement.text().simplified().toStdString()); se.name = nameElement.text().simplified().toStdString();
QString roomName = QString::fromStdString(se.name()); QString roomName = QString::fromStdString(se.name);
// displayed room names are too long // displayed room names are too long
roomName.replace(QStringLiteral("SW_room"), QStringLiteral("R")); roomName.replace(QStringLiteral("SW_room"), QStringLiteral("R"));
INFO_LOG(m_logger) << "importRooms: " << roomName << ", parentIdx = " << parentIdx; INFO_LOG(m_logger) << "importRooms: " << roomName << ", parentIdx = " << parentIdx;
se.displayName(roomName.toStdString()); se.displayName = roomName.toStdString();
se.mountingPointId(subId); se.mountingPointId = subId;
se.structureElementTypeId(InfrastructureManagement::StructureElementType::Room); se.structureElementTypeId = InfrastructureManagement::StructureElementType::Room;
se.mountingPointTypeId(InfrastructureManagement::MountingPointType::Unknown); se.mountingPointTypeId = InfrastructureManagement::MountingPointType::Unknown;
se.properties("{}"); se.properties = "{}";
QDomElement subRoomElem = roomElem.firstChildElement(QStringLiteral("Group")); QDomElement subRoomElem = roomElem.firstChildElement(QStringLiteral("Group"));
if (!subRoomElem.isNull()) if (!subRoomElem.isNull())
{ {
tryGetRoomBoundingBox(subRoomElem, se); tryGetRoomBoundingBox(subRoomElem, se);
addElementToRequest(se, parentIdx); addElementToRequest(se, parentIdx);
const int curIdx = m_request.elements().size() - 1; const int curIdx = static_cast<int>(m_request.elements.size()) - 1;
importExternalReferences(subRoomElem, curIdx); importExternalReferences(subRoomElem, curIdx);
DEBUG_LOG(m_logger) << "Room=" << se.name() DEBUG_LOG(m_logger) << "Room=" << se.name
<< " Id=" << se.id() << " Id=" << se.id
<< " mountingPointId=" << se.mountingPointId(); << " mountingPointId=" << se.mountingPointId;
} }
else else
{ {
@@ -589,18 +589,18 @@ void ParseBuildingXml::tryGetRoomBoundingBox(const QDomElement &subRoomElem, Str
return; return;
const auto minPos(positionFromElement<Core::RelativePosition>(min)); const auto minPos(positionFromElement<Core::RelativePosition>(min));
const auto maxPos(positionFromElement<Core::RelativePosition>(min)); const auto maxPos(positionFromElement<Core::RelativePosition>(min));
se.relPosition(Core::RelativePosition((minPos.offsetX() + maxPos.offsetX()) / 2, se.relPosition = Core::RelativePosition((minPos.offsetX + maxPos.offsetX) / 2,
(minPos.offsetY() + maxPos.offsetY()) / 2, (minPos.offsetY + maxPos.offsetY) / 2,
(minPos.offsetZ() + maxPos.offsetZ()) / 2)); (minPos.offsetZ + maxPos.offsetZ) / 2);
} }
//------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------
void ParseBuildingXml::addElementToRequest(const StructureElement &se, void ParseBuildingXml::addElementToRequest(const StructureElement &se,
int parentIdx) int parentIdx)
{ {
const size_t size = m_request.elements().size(); const size_t size = m_request.elements.size();
m_request.elements().resize(size + 1, se); m_request.elements.resize(size + 1, se);
m_request.childParentRelations().resize(size + 1, parentIdx); m_request.childParentRelations.resize(size + 1, parentIdx);
} }
//------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------
@@ -660,18 +660,18 @@ StructureElement ParseBuildingXml::getStructureElement(const QDomElement &elemen
const int subId = getInteger(getChildElement(element, QStringLiteral("SubId")), QStringLiteral("ID")); const int subId = getInteger(getChildElement(element, QStringLiteral("SubId")), QStringLiteral("ID"));
StructureElement se; StructureElement se;
se.relPosition(positionFromElement<Core::RelativePosition>(getChildElement(element, QStringLiteral("Coord")))); se.relPosition = positionFromElement<Core::RelativePosition>(getChildElement(element, QStringLiteral("Coord")));
se.orientation(positionFromElement<Core::Orientation>(getChildElement(element, QStringLiteral("Dir")))); // xyz=hpr? se.orientation = positionFromElement<Core::Orientation>(getChildElement(element, QStringLiteral("Dir"))); // xyz=hpr?
se.mountingPointTypeId(mptFromSubId(subId)); se.mountingPointTypeId = mptFromSubId(subId);
se.structureElementTypeId(InfrastructureManagement::StructureElementType::MountingPoint); se.structureElementTypeId = InfrastructureManagement::StructureElementType::MountingPoint;
se.name(element.firstChildElement(QStringLiteral("Name")).text().simplified().toStdString()); se.name = element.firstChildElement(QStringLiteral("Name")).text().simplified().toStdString();
QString displayName = m_buildingName; QString displayName = m_buildingName;
displayName.append(QLatin1String(" - ")); displayName.append(QLatin1String(" - "));
displayName.append(QString::fromStdString(se.name())); displayName.append(QString::fromStdString(se.name));
se.displayName(displayName.toStdString()); se.displayName = displayName.toStdString();
se.mountingPointId(subId); se.mountingPointId = subId;
se.properties("{}"); se.properties = "{}";
return se; return se;
} }