Adds immediate migration results in progress

This commit is contained in:
torsten committed 2026-08-19 11:18:24 +02:00
1 parent 8453e104c5
commit 3bb6e89496
2102 files changed
+17482 -15071

No files matched your search

@@ -42,7 +42,7 @@ IsmImportBuildings::IsmImportBuildings(QObject *parent)
// ------------------------------------------------------------------------------
bool IsmImportBuildings::init(int domainId, const QUrl &tcpDiscoveryUrl)
{
INFO_LOG() << "init begin";
INFO_LOG(m_logger) << "init begin";
// initialize DDS, always on exercise 0
m_ddsConnector.reset(new DDSConnector::DdsConnector(domainId, IDL::PartitionType::Global, 0, 0, tcpDiscoveryUrl));
@@ -50,13 +50,13 @@ bool IsmImportBuildings::init(int domainId, const QUrl &tcpDiscoveryUrl)
return false;
m_ddsConnector->initPublisherSubscriber();
DEBUG_LOG() << "create dtc";
DEBUG_LOG(m_logger) << "create dtc";
m_dtc = InfrastructureManagement::Interface::Dtc::create(m_ddsConnector);
DEBUG_LOG() << "create ftc";
DEBUG_LOG(m_logger) << "create ftc";
m_ftc = InfrastructureManagement::Interface::Ftc::create(m_ddsConnector);
DEBUG_LOG() << "init dtc & ftc";
DEBUG_LOG(m_logger) << "init dtc & ftc";
bool bRet = m_ftc->enableMainStructureElementModify() &&
m_ftc->enableMainStructureElementRemove() &&
m_ftc->enableMountingPointAssetRemove() &&
@@ -68,9 +68,9 @@ bool IsmImportBuildings::init(int domainId, const QUrl &tcpDiscoveryUrl)
m_dtc->enableMountingPointAsset() &&
m_dtc->enableMainSchedule();
DEBUG_LOG() << "init dtc, ftc end - bRet = " << bRet;
DEBUG_LOG(m_logger) << "init dtc, ftc end - bRet = " << bRet;
DEBUG_LOG() << "Domain Id = " << domainId;
DEBUG_LOG(m_logger) << "Domain Id = " << domainId;
return bRet;
}
@@ -91,7 +91,7 @@ void IsmImportBuildings::import(const QVector<ImportData> &importData)
QCoreApplication::quit();
return;
}
DEBUG_LOG() << "Trying to import " << m_importData.size() << " buildings";
DEBUG_LOG(m_logger) << "Trying to import " << m_importData.size() << " buildings";
m_curImportIdx = 0;
import(m_importData.at(m_curImportIdx));
}
@@ -146,11 +146,11 @@ void IsmImportBuildings::remove(int buildingId)
QMap<int, QVector<InfrastructureManagement::InstrumentationAsset>> assetsMapBuilding;
m_dtc->getAllAssetsPerBuilding(predicate, assetsMapBuilding);
DEBUG_LOG() << "assetsMapBuilding.size = " << assetsMapBuilding.size();
DEBUG_LOG(m_logger) << "assetsMapBuilding.size = " << assetsMapBuilding.size();
assetsMounted = (assetsMapBuilding[buildingId].size() > 0);
DEBUG_LOG() << "Building id = " << buildingId << " has assets mounted = " << assetsMounted;
DEBUG_LOG(m_logger) << "Building id = " << buildingId << " has assets mounted = " << assetsMounted;
// cfroebel 2018-11-30:
// Currently the ISM service fails to correctly remove a building when it has mounted assets (other than BCU).
@@ -159,7 +159,7 @@ void IsmImportBuildings::remove(int buildingId)
if (assetsMounted)
{
QString msg = QStringLiteral("Not possible to remove building with id %1 because there are assets mounted!").arg(buildingId);
ERROR_LOG() << msg;
ERROR_LOG(m_logger) << msg;
std::cerr << msg << std::endl;
m_idsToBeRemoved.pop_front();
IsmImportBuildings::removeNext();
@@ -171,7 +171,7 @@ void IsmImportBuildings::remove(int buildingId)
// ------------------------------------------------------------------------------
void IsmImportBuildings::doImport()
{
INFO_LOG() << "trying to Import / Modify";
INFO_LOG(m_logger) << "trying to Import / Modify";
ParseBuildingXml buildingXml(m_currentData.xmlFileName,
m_currentData.vulFileName,
m_currentData.egcuToRoomFileName,
@@ -180,21 +180,21 @@ void IsmImportBuildings::doImport()
m_currentData.angleDegree);
if (!buildingXml.parseXml())
{
ERROR_LOG() << "Can not parse building files: " << buildingXml.lastError();
ERROR_LOG(m_logger) << "Can not parse building files: " << buildingXml.lastError();
std::cerr << "Can not parse building files name: " << m_currentData.xmlFileName
<< " error: " << buildingXml.lastError() << std::endl;
QCoreApplication::exit(1);
return;
}
INFO_LOG() << "Sending request";
INFO_LOG(m_logger) << "Sending request";
MainStructureElementModifyRequest req = buildingXml.parsedRequest();
QByteArray propertiesBa = QByteArray::fromStdString(req.properties());
QJsonParseError parserError;
const QJsonDocument doc(QJsonDocument::fromJson(propertiesBa, &parserError));
if (parserError.error != QJsonParseError::NoError)
WARNING_LOG() << "Error parsing json document: " << parserError.errorString() << " '" << propertiesBa << "'";
DEBUG_LOG() << "json to parse: " << doc.toJson();
WARNING_LOG(m_logger) << "Error parsing json document: " << parserError.errorString() << " '" << propertiesBa << "'";
DEBUG_LOG(m_logger) << "json to parse: " << doc.toJson();
QJsonObject obj(doc.object());
if (m_currentData.exerciseId > 0)
{
@@ -220,11 +220,11 @@ void IsmImportBuildings::doImport()
{
m_isInRestoringMode = true;
msg = "Building " + req.name() + " already exists. All related data is now saved.";
INFO_LOG() << msg;
INFO_LOG(m_logger) << msg;
std::cerr << msg << std::endl;
msg = "Fetching IDs of MountingPints.";
INFO_LOG() << msg;
INFO_LOG(m_logger) << msg;
std::cerr << msg << std::endl;
QVector<qint32> mountingPointIds;
for (const StructureElement &structureElement : oldMainStructureElement.elements())
@@ -235,7 +235,7 @@ void IsmImportBuildings::doImport()
}
msg = "Fetching MountingPointAssets.";
INFO_LOG() << msg;
INFO_LOG(m_logger) << msg;
std::cerr << msg << std::endl;
// get mountings of mounting points of this building
mountings = mountingsOfStructureElements(mountingPointIds);
@@ -244,7 +244,7 @@ void IsmImportBuildings::doImport()
if (!mountings.isEmpty())
{
msg = "Removing MountingPointAssets.";
INFO_LOG() << msg;
INFO_LOG(m_logger) << msg;
std::cerr << msg << std::endl;
unmountAssetsOfBuliding(oldMainStructureElement.id());
// // remove mounting point assets
@@ -256,7 +256,7 @@ void IsmImportBuildings::doImport()
}
msg = "Fetching MountingPointPlans.";
INFO_LOG() << msg;
INFO_LOG(m_logger) << msg;
std::cerr << msg << std::endl;
// get mounting points in plans of this building
auto mppsBySchedule = MountingPointPlanByScheduleOfStructureElements(mountingPointIds);
@@ -264,14 +264,14 @@ void IsmImportBuildings::doImport()
// Don't know, why these are deleted anyways...
for (auto it = mppsBySchedule.cbegin(); it != mppsBySchedule.cend(); ++it)
{
INFO_LOG() << "Removing MountingPointPlans.";
INFO_LOG(m_logger) << "Removing MountingPointPlans.";
auto copy = it.value();
for (auto &elem : copy)
elem.mountingPointState() = MountingPointState_def::Idle;
m_ftc->mountingPointPlanModifyRequest(MountingPointPlanModifyRequest(it.key(),copy), this);
}
msg = "Fetching paths of MountingPoints by name ... for later reconstruction.";
INFO_LOG() << msg;
INFO_LOG(m_logger) << msg;
std::cerr << msg << std::endl;
for (const StructureElement &structureElement : oldMainStructureElement.elements())
oldNamePaths.insert(structureElement.id(), pathWithNames(structureElement, oldMainStructureElement));
@@ -300,11 +300,11 @@ void IsmImportBuildings::doImport()
void IsmImportBuildings::doRemove(int buildingId)
{
std::string msg = "Trying to Remove building with id " + QString::number(buildingId).toStdString();
INFO_LOG() << msg;
INFO_LOG(m_logger) << msg;
std::cerr << msg << std::endl;
if (!m_ftc->mainStructureElementRemoveRequest(MainStructureElementRemoveRequest(buildingId), this))
{
ERROR_LOG() << "Error requesting remove";
ERROR_LOG(m_logger) << "Error requesting remove";
std::cerr << "Error requesting remove" << std::endl;
QCoreApplication::exit(1);
return;
@@ -402,19 +402,19 @@ StructureElement IsmImportBuildings::structureElementById(qint32 id, const MainS
void IsmImportBuildings::createNewMainStructureElement(const MainStructureElementModifyRequest &request)
{
std::string msg = "Creating new MainStructureElement.";
INFO_LOG() << msg;
INFO_LOG(m_logger) << msg;
std::cerr << msg << std::endl;
if (!m_ftc->mainStructureElementModifyRequest(request, this))
{
if (m_currentData.buildingId > 0)
ERROR_LOG() << "Error requesting update";
ERROR_LOG(m_logger) << "Error requesting update";
else
ERROR_LOG() << "Error requesting create";
ERROR_LOG(m_logger) << "Error requesting create";
std::cerr << "Error requesting update/create" << std::endl;
QCoreApplication::exit(1);
return;
}
INFO_LOG() << "Waiting for answer";
INFO_LOG(m_logger) << "Waiting for answer";
}
// ------------------------------------------------------------------------------
@@ -442,12 +442,12 @@ void IsmImportBuildings::restoreData(const MainStructureElement &oldMainStructur
newMountingPointIds.append(structureElement.id());
}
QMap<qint32, QVector<std::string> > newNamePaths;
INFO_LOG() << "Restoring mounting point data.";
INFO_LOG(m_logger) << "Restoring mounting point data.";
for (const StructureElement &structureElement : newMainStructureElement.elements())
newNamePaths.insert(structureElement.id(), pathWithNames(structureElement, oldMainStructureElement));
if (oldNamePaths.size() != newNamePaths.size())
INFO_LOG() << "old name path size: " + QString::number(oldNamePaths.size()).toStdString() + " , new name path size: " + QString::number(newNamePaths.size()).toStdString();;
INFO_LOG(m_logger) << "old name path size: " + QString::number(oldNamePaths.size()).toStdString() + " , new name path size: " + QString::number(newNamePaths.size()).toStdString();;
QMap<qint32, qint32> oldStructureElementIdToNewStructureElementId;
for (auto it = oldNamePaths.constBegin(); it != oldNamePaths.constEnd(); ++it)
@@ -484,7 +484,7 @@ void IsmImportBuildings::restoreData(const MainStructureElement &oldMainStructur
if (!mountings.isEmpty())
{
msg = "Restoring MountingPointAssets.";
INFO_LOG() << msg;
INFO_LOG(m_logger) << msg;
std::cerr << msg << std::endl;
// restore mountings
for (const MountingPointAsset &mountingPointAsset : mountings)
@@ -508,7 +508,7 @@ void IsmImportBuildings::restoreData(const MainStructureElement &oldMainStructur
return;
msg = "Restoring MountingPointPlans.";
INFO_LOG() << msg;
INFO_LOG(m_logger) << msg;
std::cerr << msg << std::endl;
// restore mounting point plans
MountingPointPlanModifyRequest createRequest;
@@ -546,7 +546,7 @@ void IsmImportBuildings::unmountAssetsOfBuliding(qint32 buildingId)
{
msg = "Waiting for socket to open";
std::cerr << msg << std::endl;
INFO_LOG() << msg;
INFO_LOG(m_logger) << msg;
QThread::sleep(1);
}
@@ -563,7 +563,7 @@ void IsmImportBuildings::unmountAssetsOfBuliding(qint32 buildingId)
{
std::string msg = "Got reply: " + message.toStdString();
std::cerr << msg << std::endl;
INFO_LOG() << msg;
INFO_LOG(m_logger) << msg;
hasAnswer = true;
});
@@ -573,7 +573,7 @@ void IsmImportBuildings::unmountAssetsOfBuliding(qint32 buildingId)
{
msg = "Waiting for socket to answer";
std::cerr << msg << std::endl;
INFO_LOG() << msg;
INFO_LOG(m_logger) << msg;
QThread::sleep(1);
}
@@ -597,13 +597,13 @@ void IsmImportBuildings::onMainStructureElementRemoveReply(const Core::FunctionR
if (replyObject.error())
{
QString msg = QStringLiteral("Failed to remove building with id %1: %2").arg(buildingId).arg(QString::fromStdString(replyObject()));
ERROR_LOG() << msg;
ERROR_LOG(m_logger) << msg;
std::cerr << msg << std::endl;
}
else
{
QString msg = QStringLiteral("Removed building with id %1").arg(buildingId);
INFO_LOG() << msg;
INFO_LOG(m_logger) << msg;
std::cerr << msg << std::endl;
}
@@ -618,7 +618,7 @@ void IsmImportBuildings::onMountingPointPlanModifyReply(const Core::FunctionRepl
{
if (reply.error())
{
ERROR_LOG() << reply.error();
ERROR_LOG(m_logger) << reply.error();
std::cerr << reply.error() << std::endl;
}
}
@@ -626,10 +626,10 @@ void IsmImportBuildings::onMountingPointPlanModifyReply(const Core::FunctionRepl
// ------------------------------------------------------------------
void IsmImportBuildings::onMountingPointAssetRemoveReply(const Core::FunctionReplyObject &reply)
{
ERROR_LOG() << "REMOVE REPLY";
ERROR_LOG(m_logger) << "REMOVE REPLY";
if (reply.error())
{
ERROR_LOG() << reply.error();
ERROR_LOG(m_logger) << reply.error();
std::cerr << reply.error() << std::endl;
}
}
@@ -639,7 +639,7 @@ void IsmImportBuildings::onMountingPointAssetModifyReply(const Core::FunctionRep
{
if (reply.error())
{
ERROR_LOG() << reply.error();
ERROR_LOG(m_logger) << reply.error();
std::cerr << reply.error() << std::endl;
}
}
@@ -649,7 +649,7 @@ void IsmImportBuildings::onStructureElementModifyReply(const Core::FunctionReply
{
if (reply.error())
{
ERROR_LOG() << reply.error();
ERROR_LOG(m_logger) << reply.error();
std::cerr << reply.error() << std::endl;
}
}
@@ -659,7 +659,7 @@ bool IsmImportBuildings::handleReply(const Core::FunctionReplyObject &replyObjec
{
if (replyObject.error())
{
ERROR_LOG() << "Got Reply error: " << replyObject.translated();
ERROR_LOG(m_logger) << "Got Reply error: " << replyObject.translated();
std::cerr << "Error importing building" << std::endl;
QCoreApplication::exit(1);
return false;