Migrates InfrastructureManagement to generated rtiddsgen API

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

No files matched your search

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