Adds latest migration results

This commit is contained in:
torsten committed 2026-09-01 12:27:57 +02:00
1 parent ad07345480
commit 0c1503d85c
829 files changed
+35074 -70886

No files matched your search

@@ -9,6 +9,7 @@
#include "pdm_dtc_impl_custom.h"
#include "NGLLogger/INGLLogger.h"
#include "NGLLogger/NGLLoggerBootstrap.h"
#include "pdm_translation.h"
#include <QJsonArray>
#include <QJsonDocument>
@@ -25,7 +26,7 @@ namespace ProjectDataManagement
namespace Interface
{
DtcImplCustom::DtcImplCustom(const std::shared_ptr<DDSConnector::DdsConnector> &ddsConnector)
: DtcImpl(ddsConnector)
: DtcImpl(ddsConnector), m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("ProjectDataManagement.DtcImplCustom"))
{
waitForHistoricalDataChargeType(2000);
waitForHistoricalDataIgniterFunction(2000);
@@ -59,20 +60,20 @@ void DtcImplCustom::fillChargeTypeIgniterTypeIgniterFunctionProps()
for (auto it = ctItIfMap.constBegin(); it != ctItIfMap.constEnd(); ++it)
{
ChargeTypeIgniterTypeIgniterFunctionProps props;
ChargeTypeIgniterTypeIgniterFunction ctitif = it.value();
ChargeTypeIgniterTypeIgniterFunction ctitif = *it;
props.chargeTypeId = ctitif.chargeTypeId();
props.igniterTypeId = ctitif.igniterTypeId();
props.igniterFunctionId = ctitif.igniterFunctionId();
props.igniterFunctionBase = ctitif.igniterFunctionBaseId();
props.impactRadius = ctitif.impactRadius();
props.hazardDistance = ctitif.hazardDistance();
props.chargeLegacyId = ctitif.chargeLegacyId();
props.chargeTypeId = ctitif.chargeTypeId;
props.igniterTypeId = ctitif.igniterTypeId;
props.igniterFunctionId = ctitif.igniterFunctionId;
props.igniterFunctionBase = ctitif.igniterFunctionBase;
props.impactRadius = ctitif.impactRadius;
props.hazardDistance = ctitif.hazardDistance;
props.chargeLegacyId = ctitif.chargeLegacyId;
QJsonObject ctProps = propertiesToJson(chargeType(props.chargeTypeId).properties());
QJsonObject itProps = propertiesToJson(igniterType(props.igniterTypeId).properties());
QJsonObject ifProps = propertiesToJson(igniterFunction(props.igniterFunctionId).properties());
QJsonObject ctitifProps = propertiesToJson(ctitif.properties());
QJsonObject ctProps = propertiesToJson(chargeType(props.chargeTypeId).properties);
QJsonObject itProps = propertiesToJson(igniterType(props.igniterTypeId).properties);
QJsonObject ifProps = propertiesToJson(igniterFunction(props.igniterFunctionId).properties);
QJsonObject ctitifProps = propertiesToJson(ctitif.properties);
// Combine JsonObjects to Map -> one big JsonObject
QVariantMap map = ctProps.toVariantMap();
@@ -89,28 +90,28 @@ void DtcImplCustom::fillChargeTypeIgniterTypeIgniterFunctionProps()
QJsonObject obj = QJsonObject::fromVariantMap(map);
setProps(props, obj);
m_ctItIfProps.insert(it.key(), props);
m_ctItIfProps.insert(ctitif.id, props);
}
for (auto it = m_ctItIfProps.constBegin(); it != m_ctItIfProps.constEnd(); ++it)
{
if (it.value().chargeTypeId > 2000 || it.value().chargeTypeId < 100)
if (it->chargeTypeId > 2000 || it->chargeTypeId < 100)
continue;
INFO_LOG(m_logger) << "chargeTypeId: " << it.value().chargeTypeId;
INFO_LOG(m_logger) << "ChargeTypeName:" << it.value().adlerChargeTypeName;
INFO_LOG(m_logger) << "igniterTypeId: " << it.value().igniterTypeId;
INFO_LOG(m_logger) << "igniterTypeName: " << it.value().adlerIgniterTypeName;
INFO_LOG(m_logger) << "igniterFunctionId: " << it.value().igniterFunctionId;
INFO_LOG(m_logger) << "igniterFunctionName: " << it.value().adlerIgniterFunctionName;
INFO_LOG(m_logger) << "igniterFunctionBase: " << it.value().igniterFunctionBase;
INFO_LOG(m_logger) << "impactRadius: " << it.value().impactRadius;
INFO_LOG(m_logger) << "chargeLegacyId: " << it.value().chargeLegacyId;
INFO_LOG(m_logger) << "isSmart: " << it.value().isSmart;
INFO_LOG(m_logger) << "isSmoke: " << it.value().isSmoke;
INFO_LOG(m_logger) << "isDus: " << it.value().isDus;
INFO_LOG(m_logger) << "isConcrete: " << it.value().isConcrete;
INFO_LOG(m_logger) << "volatilityTypeId: " << it.value().volatilityTypeId;
INFO_LOG(m_logger) << "chargeTypeId: " << it->chargeTypeId;
INFO_LOG(m_logger) << "ChargeTypeName:" << it->adlerChargeTypeName;
INFO_LOG(m_logger) << "igniterTypeId: " << it->igniterTypeId;
INFO_LOG(m_logger) << "igniterTypeName: " << it->adlerIgniterTypeName;
INFO_LOG(m_logger) << "igniterFunctionId: " << it->igniterFunctionId;
INFO_LOG(m_logger) << "igniterFunctionName: " << it->adlerIgniterFunctionName;
INFO_LOG(m_logger) << "igniterFunctionBase: " << it->igniterFunctionBase;
INFO_LOG(m_logger) << "impactRadius: " << it->impactRadius;
INFO_LOG(m_logger) << "chargeLegacyId: " << it->chargeLegacyId;
INFO_LOG(m_logger) << "isSmart: " << it->isSmart;
INFO_LOG(m_logger) << "isSmoke: " << it->isSmoke;
INFO_LOG(m_logger) << "isDus: " << it->isDus;
INFO_LOG(m_logger) << "isConcrete: " << it->isConcrete;
INFO_LOG(m_logger) << "volatilityTypeId: " << it->volatilityTypeId;
}
}
@@ -122,11 +123,11 @@ void DtcImplCustom::fillChargeTypeLoadTypeProps()
for (const auto &ctlt : chargeTypeLoadTypes())
{
ChargeTypeLoadTypeProps props;
props.chargeTypeId = ctlt.chargeTypeId();
props.loadTypeId = ctlt.loadTypeId();
props.chargeTypeId = ctlt.chargeTypeId;
props.loadTypeId = ctlt.loadTypeId;
QJsonObject ltProps = propertiesToJson(loadType(props.loadTypeId).properties());
QJsonObject ctltProps = propertiesToJson(ctlt.properties());
QJsonObject ltProps = propertiesToJson(loadType(props.loadTypeId).properties);
QJsonObject ctltProps = propertiesToJson(ctlt.properties);
// Combine JsonObjects to Map -> one big JsonObject
QVariantMap map = ltProps.toVariantMap();
@@ -139,24 +140,24 @@ void DtcImplCustom::fillChargeTypeLoadTypeProps()
QJsonObject obj = QJsonObject::fromVariantMap(map);
setProps(props, obj);
m_ctLtProps.insert(ctlt.id(), props);
m_ctLtProps.insert(ctlt.id, props);
}
}
void DtcImplCustom::onIgniterTypeChanged(const IgniterType &ignType)
{
if (ignType.id() <= 0)
if (ignType.id <= 0)
return;
for (auto it = m_ctItIfProps.begin(); it != m_ctItIfProps.end(); ++it)
{
if (it.value().igniterTypeId != ignType.id())
if (it->igniterTypeId != ignType.id)
continue;
QJsonObject ctProps = propertiesToJson(chargeType(it.value().chargeTypeId).properties());
QJsonObject itProps = propertiesToJson(ignType.properties());
QJsonObject ifProps = propertiesToJson(igniterFunction(it.value().igniterFunctionId).properties());
QJsonObject ctitifProps = propertiesToJson(chargeTypeIgniterTypeIgniterFunction(it.key()).properties());
QJsonObject ctProps = propertiesToJson(chargeType(it->chargeTypeId).properties);
QJsonObject itProps = propertiesToJson(ignType.properties);
QJsonObject ifProps = propertiesToJson(igniterFunction(it->igniterFunctionId).properties);
QJsonObject ctitifProps = propertiesToJson(chargeTypeIgniterTypeIgniterFunction(it.key()).properties);
// Combine JsonObjects to Map -> one big JsonObject
mergeProperties(it, ifProps, ctProps, ctitifProps, itProps);
@@ -165,18 +166,18 @@ void DtcImplCustom::onIgniterTypeChanged(const IgniterType &ignType)
void DtcImplCustom::onIgniterFunctionChanged(const IgniterFunction &ignFunc)
{
if (ignFunc.id() <= 0)
if (ignFunc.id <= 0)
return;
for (auto it = m_ctItIfProps.begin(); it != m_ctItIfProps.end(); ++it)
{
if (it.value().igniterFunctionId != ignFunc.id())
if (it->igniterFunctionId != ignFunc.id)
continue;
QJsonObject ctProps = propertiesToJson(chargeType(it.value().chargeTypeId).properties());
QJsonObject itProps = propertiesToJson(igniterType(it.value().igniterFunctionId).properties());
QJsonObject ifProps = propertiesToJson(ignFunc.properties());
QJsonObject ctitifProps = propertiesToJson(chargeTypeIgniterTypeIgniterFunction(it.key()).properties());
QJsonObject ctProps = propertiesToJson(chargeType(it->chargeTypeId).properties);
QJsonObject itProps = propertiesToJson(igniterType(it->igniterTypeId).properties);
QJsonObject ifProps = propertiesToJson(ignFunc.properties);
QJsonObject ctitifProps = propertiesToJson(chargeTypeIgniterTypeIgniterFunction(it.key()).properties);
// Combine JsonObjects to Map -> one big JsonObject
mergeProperties(it, ifProps, ctProps, ctitifProps, itProps);
@@ -202,9 +203,9 @@ void DtcImplCustom::mergeProperties(QHash<int, ChargeTypeIgniterTypeIgniterFunct
#endif
QJsonObject obj = QJsonObject::fromVariantMap(map);
setProps(it.value(), obj);
setProps(*it, obj);
m_ctItIfProps.insert(it.key(), it.value());
m_ctItIfProps.insert(it.key(), *it);
}
void DtcImplCustom::onChargeTypeChanged(const ChargeType &ct)
@@ -215,13 +216,13 @@ void DtcImplCustom::onChargeTypeChanged(const ChargeType &ct)
QHash<int, ChargeTypeIgniterTypeIgniterFunctionProps>::iterator it;
for (it = m_ctItIfProps.begin(); it != m_ctItIfProps.end(); ++it)
{
if (it.value().chargeTypeId != ct.id())
if (it->chargeTypeId != ct.id())
continue;
QJsonObject ctProps = propertiesToJson(ct.properties());
QJsonObject itProps = propertiesToJson(igniterType(it.value().igniterFunctionId).properties());
QJsonObject ifProps = propertiesToJson(igniterFunction(it.value().igniterFunctionId).properties());
QJsonObject ctitifProps = propertiesToJson(chargeTypeIgniterTypeIgniterFunction(it.key()).properties());
QJsonObject itProps = propertiesToJson(igniterType(it->igniterTypeId).properties);
QJsonObject ifProps = propertiesToJson(igniterFunction(it->igniterFunctionId).properties);
QJsonObject ctitifProps = propertiesToJson(chargeTypeIgniterTypeIgniterFunction(it.key()).properties);
// Combine JsonObjects to Map -> one big JsonObject
mergeProperties(it, ifProps, ctProps, ctitifProps, itProps);
@@ -230,58 +231,59 @@ void DtcImplCustom::onChargeTypeChanged(const ChargeType &ct)
void DtcImplCustom::onChargeTypeIgniterTypeIgniterFunctionChanged(const ChargeTypeIgniterTypeIgniterFunction &ctitif)
{
if (ctitif.id() <= 0)
if (ctitif.id <= 0)
return;
for (auto it = m_ctItIfProps.begin(); it != m_ctItIfProps.end(); ++it)
{
if (it.key() != ctitif.id())
if (it.key() != ctitif.id)
continue;
it.value().chargeTypeId = ctitif.chargeTypeId();
it.value().igniterTypeId = ctitif.igniterTypeId();
it.value().igniterFunctionId = ctitif.igniterFunctionId();
it.value().igniterFunctionBase = ctitif.igniterFunctionBaseId();
it.value().impactRadius = ctitif.impactRadius();
it.value().hazardDistance = ctitif.hazardDistance();
it.value().chargeLegacyId = ctitif.chargeLegacyId();
it->chargeTypeId = ctitif.chargeTypeId;
it->igniterTypeId = ctitif.igniterTypeId;
it->igniterFunctionId = ctitif.igniterFunctionId;
it->igniterFunctionBase = ctitif.igniterFunctionBase;
it->impactRadius = ctitif.impactRadius;
it->hazardDistance = ctitif.hazardDistance;
it->chargeLegacyId = ctitif.chargeLegacyId;
QJsonObject ctProps = propertiesToJson(chargeType(it.value().chargeTypeId).properties());
QJsonObject itProps = propertiesToJson(igniterType(it.value().igniterFunctionId).properties());
QJsonObject ifProps = propertiesToJson(igniterFunction(it.value().igniterFunctionId).properties());
QJsonObject ctitifProps = propertiesToJson(ctitif.properties());
QJsonObject ctProps = propertiesToJson(chargeType(it->chargeTypeId).properties);
QJsonObject itProps = propertiesToJson(igniterType(it->igniterFunctionId).properties);
QJsonObject ifProps = propertiesToJson(igniterFunction(it->igniterFunctionId).properties);
QJsonObject ctitifProps = propertiesToJson(ctitif.properties);
// Combine JsonObjects to Map -> one big JsonObject
mergeProperties(it, ifProps, ctProps, ctitifProps, itProps);
}
}
QVector<ProjectDataManagement::ChargeType> DtcImplCustom::chargesForGearClass(GearClass gearClass)
QVector<ProjectDataManagement::ChargeTypeData> DtcImplCustom::chargesForGearClass(GearClass gearClass)
{
QVector<ProjectDataManagement::ChargeType> ret;
QVector<ProjectDataManagement::ChargeTypeData> ret;
if (!isGearTypeEnabled())
{
enableGearType();
enableGearType(true);
waitForHistoricalDataGearType(2000);
}
if (!isGearTypeChargeTypeEnabled())
{
enableGearTypeChargeType();
enableGearTypeChargeType(true);
waitForHistoricalDataGearTypeChargeType(2000);
}
const auto gear2ChargeMap = gearTypeChargeTypes();
const auto chargeMap = chargeTypes();
for (const rti::sub::LoanedSample<ProjectDataManagement::GearType> &sample : m_dtcGearType->readAlive())
const auto gearTypesList = gearTypes();
for (const auto &gearType : gearTypesList)
{
if (sample.data().gearClassId() != gearClass)
if (gearType.gearClassId() != gearClass.id())
continue;
const int gearTypeId = sample.data().id();
const int gearTypeId = gearType.id();
for (auto gIt = gear2ChargeMap.begin(); gIt != gear2ChargeMap.end(); ++gIt)
{
if (gIt.value().gearTypeId() == gearTypeId)
ret += chargeMap.value(gIt.value().chargeTypeId());
if (gIt->gearTypeId == gearTypeId)
ret += chargeMap.value(gIt->chargeTypeId);
}
}
return ret;
@@ -293,13 +295,13 @@ QVector<ProjectDataManagement::IgniterType> DtcImplCustom::ignitersForChargeType
if (!isIgniterTypeEnabled())
{
enableIgniterType();
enableIgniterType(true);
waitForHistoricalDataIgniterType(2000);
}
if (!isChargeTypeIgniterTypeIgniterFunctionEnabled())
{
enableChargeTypeIgniterTypeIgniterFunction();
enableChargeTypeIgniterTypeIgniterFunction(true);
waitForHistoricalDataChargeTypeIgniterTypeIgniterFunction(2000);
}
@@ -308,9 +310,9 @@ QVector<ProjectDataManagement::IgniterType> DtcImplCustom::ignitersForChargeType
for (auto it = chargeType2IgniterMap.begin(); it != chargeType2IgniterMap.end(); ++it)
{
if (it.value().chargeTypeId() == chargeTypeId)
if ((*it).chargeTypeId == chargeTypeId)
{
ProjectDataManagement::IgniterType igType = igniterTypeMap.value(it.value().igniterTypeId());
ProjectDataManagement::IgniterType igType = igniterTypeMap.value((*it).igniterTypeId);
if (!ret.contains(igType))
ret += igType;
}
@@ -325,13 +327,13 @@ QVector<ProjectDataManagement::ChargeTypeIgniterTypeIgniterFunction> DtcImplCust
if (!isIgniterFunctionEnabled())
{
enableIgniterFunction();
enableIgniterFunction(true);
waitForHistoricalDataIgniterFunction(2000);
}
if (!isChargeTypeIgniterTypeIgniterFunctionEnabled())
{
enableChargeTypeIgniterTypeIgniterFunction();
enableChargeTypeIgniterTypeIgniterFunction(true);
waitForHistoricalDataChargeTypeIgniterTypeIgniterFunction(2000);
}
@@ -339,8 +341,8 @@ QVector<ProjectDataManagement::ChargeTypeIgniterTypeIgniterFunction> DtcImplCust
for (auto it = chargeType2IgniterMap.constBegin(); it != chargeType2IgniterMap.constEnd(); ++it)
{
if (it.value().chargeTypeId() == chargeTypeId && it.value().igniterTypeId() == igniterTypeId)
ret += it.value();
if ((*it).chargeTypeId == chargeTypeId && (*it).igniterTypeId == igniterTypeId)
ret += (*it);
}
return ret;
@@ -352,13 +354,13 @@ QVector<ProjectDataManagement::LoadType> DtcImplCustom::loadsForChargeType(int c
if (!isLoadTypeEnabled())
{
enableLoadType();
enableLoadType(true);
waitForHistoricalDataLoadType(2000);
}
if (!isChargeTypeLoadTypeEnabled())
{
enableChargeTypeLoadType();
enableChargeTypeLoadType(true);
waitForHistoricalDataChargeTypeLoadType(2000);
}
@@ -367,9 +369,9 @@ QVector<ProjectDataManagement::LoadType> DtcImplCustom::loadsForChargeType(int c
for (auto it = chargeType2IgniterMap.begin(); it != chargeType2IgniterMap.end(); ++it)
{
if (it.value().chargeTypeId() == chargeTypeId)
if ((*it).chargeTypeId == chargeTypeId)
{
ProjectDataManagement::LoadType igType = loadTypeMap.value(it.value().loadTypeId());
ProjectDataManagement::LoadType igType = loadTypeMap.value((*it).loadTypeId);
if (!ret.contains(igType))
ret += igType;
}
@@ -385,7 +387,7 @@ int DtcImplCustom::getTargetTypeIdFromAdlerTargetType(const QString &typ)
if (!isTargetTypeEnabled())
{
enableTargetType();
enableTargetType(true);
waitForHistoricalDataTargetType(2000);
}
@@ -393,10 +395,10 @@ int DtcImplCustom::getTargetTypeIdFromAdlerTargetType(const QString &typ)
for (const auto &targetType : targetTypeMap)
{
if (adlerTargetTypeName(targetType.id()) != typ)
if (adlerTargetTypeName(targetType) != typ)
continue;
DEBUG_LOG(m_logger) << LOGFUNCTION << " - adlerTargetTypeName: " << typ << ", targetTypeId:" << targetType.id();
return targetType.id();
DEBUG_LOG(m_logger) << LOGFUNCTION << " - adlerTargetTypeName: " << typ << ", targetTypeId:" << targetType;
return targetType;
}
return 0;
@@ -409,7 +411,7 @@ int DtcImplCustom::getTargetSubTypeIdFromAdlerTargetSubType(const QString &subTy
if (!isTargetSubTypeEnabled())
{
enableTargetSubType();
enableTargetSubType(true);
waitForHistoricalDataTargetSubType(2000);
}
@@ -417,10 +419,10 @@ int DtcImplCustom::getTargetSubTypeIdFromAdlerTargetSubType(const QString &subTy
for (const auto &targetSubType : targetSubTypeMap)
{
if (adlerTargetSubTypeName(targetSubType.id()) != subTyp)
if (adlerTargetSubTypeName(targetSubType.targetSubTypeId) != subTyp)
continue;
DEBUG_LOG(m_logger) << LOGFUNCTION << " - adlerTargetSubTypName: " << subTyp << ", targetSubTypeId:" << targetSubType.id();
return targetSubType.id();
DEBUG_LOG(m_logger) << LOGFUNCTION << " - adlerTargetSubTypName: " << subTyp << ", targetSubTypeId:" << targetSubType.targetSubTypeId;
return targetSubType.targetSubTypeId;
}
return 0;
@@ -434,7 +436,7 @@ int DtcImplCustom::getChargeTypeIdFromAdlerCharges(const QString &geschosssorte)
if (!isChargeTypeEnabled())
{
enableChargeType();
enableChargeType(true);
waitForHistoricalDataChargeType(2000);
}
@@ -442,10 +444,10 @@ int DtcImplCustom::getChargeTypeIdFromAdlerCharges(const QString &geschosssorte)
for (const auto &charge : chargeMap)
{
if (adlerChargeTypeName(charge.id()) != geschosssorte)
if (adlerChargeTypeName(charge.chargeTypeId) != geschosssorte)
continue;
INFO_LOG(m_logger) << "---- geschosssorte: " << geschosssorte << ", chargeId:" << charge.id();
return charge.id();
INFO_LOG(m_logger) << "---- geschosssorte: " << geschosssorte << ", chargeTypeId:" << charge.chargeTypeId;
return charge.chargeTypeId;
}
return 0;
@@ -457,7 +459,7 @@ int DtcImplCustom::getIgniterTypeIdFromAdlerIgniter(const QString &zuender)
if (!isIgniterTypeEnabled())
{
enableIgniterType();
enableIgniterType(true);
waitForHistoricalDataIgniterType(2000);
}
@@ -465,11 +467,11 @@ int DtcImplCustom::getIgniterTypeIdFromAdlerIgniter(const QString &zuender)
for (const auto &ignType : ignTypeMap)
{
if (adlerIgniterTypeName(ignType.id()) != zuender)
if (adlerIgniterTypeName(ignType.id) != zuender)
continue;
INFO_LOG(m_logger) << "---- zuender: " << zuender << ", igniterTypeId:" << ignType.id();
igniterTypeId = ignType.id();
INFO_LOG(m_logger) << "---- zuender: " << zuender << ", igniterTypeId:" << ignType.id;
igniterTypeId = ignType.id;
break;
}
@@ -482,7 +484,7 @@ int DtcImplCustom::getIgniterFunctionIdFromAdlerIgniterFunction(const QString &z
if (!isIgniterFunctionEnabled())
{
enableIgniterFunction();
enableIgniterFunction(true);
waitForHistoricalDataIgniterFunction(2000);
}
@@ -490,11 +492,11 @@ int DtcImplCustom::getIgniterFunctionIdFromAdlerIgniterFunction(const QString &z
for (const auto &ignFunc : ignFunctionMap)
{
if (adlerIgniterFunctionName(ignFunc.id()) != zuenderFunktion)
if (adlerIgniterFunctionName(ignFunc.id) != zuenderFunktion)
continue;
INFO_LOG(m_logger) << "---- zuender: " << zuenderFunktion << ", igniterFunctionId:" << ignFunc.id();
igniterFunctionId = ignFunc.id();
INFO_LOG(m_logger) << "---- zuender: " << zuenderFunktion << ", igniterFunctionId:" << ignFunc.id;
igniterFunctionId = ignFunc.id;
break;
}
@@ -507,17 +509,17 @@ int DtcImplCustom::getLoadTypeIdFromAdlerLoad(const QString &ladung)
if (!isLoadTypeEnabled())
{
enableLoadType();
enableLoadType(true);
waitForHistoricalDataLoadType(2000);
}
for (const auto &lt : loadTypes())
{
if (adlerLoadTypeName(lt.id()) != ladung)
if (adlerLoadTypeName(lt.id) != ladung)
continue;
INFO_LOG(m_logger) << "---- zuender: " << ladung << ", loadTypeId:" << lt.id();
loadTypeId = lt.id();
INFO_LOG(m_logger) << "---- zuender: " << ladung << ", loadTypeId:" << lt.id;
loadTypeId = lt.id;
break;
}
@@ -703,8 +705,8 @@ int DtcImplCustom::maxCharge(int gearTypeId, int chargeTypeId)
const auto gear2ChargeMap = gearTypeChargeTypes();
for (auto gIt = gear2ChargeMap.begin(); gIt != gear2ChargeMap.end(); ++gIt)
{
if (gIt.value().gearTypeId() == gearTypeId && gIt.value().chargeTypeId() == chargeTypeId)
return gearTypeChargeTypeProps(gIt.value().id()).maxCharge;
if (gIt->gearTypeId == gearTypeId && gIt->chargeTypeId == chargeTypeId)
return gearTypeChargeTypeProps(gIt->id).maxCharge;
}
return 0;
}
@@ -714,8 +716,8 @@ int DtcImplCustom::factoryDefault(int gearTypeId, int chargeTypeId)
const auto gear2ChargeMap = gearTypeChargeTypes();
for (auto gIt = gear2ChargeMap.begin(); gIt != gear2ChargeMap.end(); ++gIt)
{
if (gIt.value().gearTypeId() == gearTypeId && gIt.value().chargeTypeId() == chargeTypeId)
return gearTypeChargeTypeProps(gIt.value().id()).factoryDefault;
if (gIt->gearTypeId == gearTypeId && gIt->chargeTypeId == chargeTypeId)
return gearTypeChargeTypeProps(gIt->id).factoryDefault;
}
return 0;
}
@@ -727,11 +729,11 @@ QVector<TargetSubType> DtcImplCustom::targetSubTypesForTargetType(int targetType
const auto &targetTypeTargetSubtypeMap = targetTypeTargetSubTypes();
const auto &targetSubtypesMap = targetSubTypes();
for (const auto &targeTypeTargetSubtype : targetTypeTargetSubtypeMap)
for (const auto &targetTypeTargetSubtype : targetTypeTargetSubtypeMap)
{
if (targeTypeTargetSubtype.targetTypeId() == targetTypeId)
if (targetTypeTargetSubtype.targetTypeId == targetTypeId)
{
ProjectDataManagement::TargetSubType targetSubType = targetSubtypesMap.value(targeTypeTargetSubtype.targetSubTypeId());
ProjectDataManagement::TargetSubType targetSubType = targetSubtypesMap.value(targetTypeTargetSubtype.targetSubTypeId);
if (!ret.contains(targetSubType))
ret += targetSubType;
}
@@ -753,8 +755,8 @@ QVector<int> DtcImplCustom::gearTypeIdFromChargeTypeId(int chargeTypeId)
QVector<int> ret;
for (const auto &gtct : gearTypeChargeTypes())
{
if (gtct.chargeTypeId() == chargeTypeId)
ret << gtct.gearTypeId();
if (gtct.chargeTypeId == chargeTypeId)
ret << gtct.gearTypeId;
}
s_gearTypeChargeTypeCache[chargeTypeId] = ret;
@@ -788,9 +790,9 @@ GearClass DtcImplCustom::gearClassFromChargeTypeId(int chargeTypeId)
for (const auto &gearType2ChargeType : gear2ChargeMap) // gear2ChargeMap is already const :-)
{
if (gearType2ChargeType.chargeTypeId() == chargeTypeId)
if (gearType2ChargeType.chargeTypeId == chargeTypeId)
{
const auto &gearType = gearTypesMap.value(gearType2ChargeType.gearTypeId());
const auto &gearType = gearTypesMap.value(gearType2ChargeType.gearTypeId);
// update cache:
s_gearClassChargeTypeCache[requestedCTID] = gearType.gearClassId();
@@ -819,7 +821,7 @@ QVector<SanitationProcedure> DtcImplCustom::getSanitationProcedures(qint64 proce
for (const auto &proc : procs)
{
if (procedures & proc.dataCode())
if (procedures & proc.dataCode)
ret.append(proc);
}
/*
@@ -946,11 +948,11 @@ QStringList DtcImplCustom::sanitationProceduresList(qint64 procedures)
if (!proc.isEmpty())
{
// No Procedure Taken so it's a connect/disconnect telegram missused.... later check for qualification for DISconnect
if (proc.size() == 1 && proc.at(0).id() == 0)
if (proc.size() == 1 && proc.at(0).id == 0)
return ret << tr("DCU Connected");
ret.reserve(proc.size());
for (const auto &s : proc)
ret << trSanitationProcedureName(s.name());
ret << trSanitationProcedureName(s.name);
}
return ret;
}
@@ -967,9 +969,9 @@ int DtcImplCustom::chargeTypeIdFromLegacyId(GearClass gearClass, int legacyId)
for (const auto &charge : chargeMap)
{
// igniterType/igniterFunction default 0
auto chargeIgniterFunction = getChargeTypeIgniterTypeIgniterFunction(charge.id(), 0, 0);
if (chargeIgniterFunction.chargeLegacyId() == legacyId)
return charge.id();
auto chargeIgniterFunction = getChargeTypeIgniterTypeIgniterFunction(charge.chargeTypeId, 0, 0);
if (chargeIgniterFunction.chargeLegacyId == legacyId)
return charge.chargeTypeId;
}
return 0;
@@ -1001,7 +1003,7 @@ ChargeTypeIgniterTypeIgniterFunction DtcImplCustom::getChargeTypeIgniterTypeIgni
for (const ChargeTypeIgniterTypeIgniterFunction &ctigtf : chargeTIgnTFunctVec)
{
if (ctigtf.igniterFunctionId() == igniterFunctionId)
if (ctigtf.igniterFunctionId == igniterFunctionId)
return ctigtf;
}
@@ -1018,7 +1020,7 @@ ChargeTypeLoadType DtcImplCustom::getChargeTypeLoadType(int chargeTypeId, int lo
for (const ChargeTypeLoadType &ctlt : chargeTypeLoadTypes())
{
if (ctlt.chargeTypeId() == chargeTypeId && ctlt.loadTypeId() == loadTypeId)
if (ctlt.chargeTypeId == chargeTypeId && ctlt.loadTypeId == loadTypeId)
return ctlt;
}
@@ -1157,14 +1159,14 @@ QStringList DtcImplCustom::chargeNames(std::vector<int> &chargeIds)
QString chargeName = translate(&DtcImpl::chargeType, &ProjectDataManagement::trChargeTypeName, it.key());
QStringList sl;
auto uleisClassOffsets = it.value();
auto uleisClassOffsets = (*it);
sl.reserve(uleisClassOffsets.size());
for (UleisClassOffset o : qAsConst(uleisClassOffsets))
sl << offsetName(o);
if (sl.size() == 6)
chargeName += tr(" (all)");
else if (sl.size() == 1 && (it.value().contains(UleisClassOffset::DirectImpactGrandparent) || it.value().contains(UleisClassOffset::None)))
else if (sl.size() == 1 && ((*it).contains(UleisClassOffset::DirectImpactGrandparent) || (*it).contains(UleisClassOffset::None)))
{
// Noop
}
@@ -1181,41 +1183,41 @@ QString DtcImplCustom::translate(const std::function<PdmBaseName(DtcImplCustom &
qint32 id)
{
const auto item = getItem(*this, id);
if (item.id() != id)
if (item.id != id)
return tr("[invalid:%1]").arg(id);
return pdmTranslate(item.name());
return pdmTranslate(item.name);
}
QString DtcImplCustom::translateShortChargeType(const std::function<QString(const std::string &)> &pdmTranslate, qint32 id)
{
const auto item = chargeType(id);
if (item.id() != id)
if (item.id != id)
return tr("[invalid:%1]").arg(id);
return pdmTranslate(item.shortName());
return pdmTranslate(item.shortName);
}
QString DtcImplCustom::translateShortIgniterType(const std::function<QString(const std::string &)> &pdmTranslate, qint32 id)
{
const auto item = igniterType(id);
if (item.id() != id)
if (item.id != id)
return tr("[invalid:%1]").arg(id);
return pdmTranslate(item.shortName());
return pdmTranslate(item.shortName);
}
QString DtcImplCustom::translateShortIgniterFunction(const std::function<QString(const std::string &)> &pdmTranslate, qint32 id)
{
const auto item = igniterFunction(id);
if (item.id() != id)
if (item.id != id)
return tr("[invalid:%1]").arg(id);
return pdmTranslate(item.shortName());
return pdmTranslate(item.shortName);
}
QString DtcImplCustom::translateShortLoadType(const std::function<QString(const std::string &)> &pdmTranslate, qint32 id)
{
const auto item = loadType(id);
if (item.id() != id)
if (item.id != id)
return tr("[invalid:%1]").arg(id);
return pdmTranslate(item.shortName());
return pdmTranslate(item.shortName);
}
QString DtcImplCustom::trBiteComponentTextName(int biteComponentId)
@@ -1295,18 +1297,29 @@ QString DtcImplCustom::trSanitationMaterialName(int sanitationMaterialId)
return translate(&DtcImpl::sanitationMaterial, &ProjectDataManagement::trSanitationMaterialName, sanitationMaterialId);
}
QJsonObject DtcImplCustom::propertiesToJson(const std::string &properties)
QString DtcImplCustom::trSanitationProcedureName(int sanitationProcedureId)
{
QJsonParseError parserError;
const QByteArray props(QByteArray::fromRawData(properties.c_str(), properties.size()));
const QJsonDocument doc(QJsonDocument::fromJson(props, &parserError));
if (parserError.error != QJsonParseError::NoError)
{
ERROR_LOG(m_logger) << "Cannot parse properties: no valid json:" << properties;
return {};
}
return translate(&DtcImpl::sanitationProcedure, &ProjectDataManagement::trSanitationProcedureName, sanitationProcedureId);
}
return doc.object();
QString DtcImplCustom::trSanitationInjuryKindName(int sanitationInjuryKindId)
{
return translate(&DtcImpl::sanitationInjuryKind, &ProjectDataManagement::trSanitationInjuryKindName, sanitationInjuryKindId);
}
QString DtcImplCustom::trSanitationInjuryPlace1Name(int sanitationInjuryPlace1Id)
{
return translate(&DtcImpl::sanitationInjuryPlace1, &ProjectDataManagement::trSanitationInjuryPlace1Name, sanitationInjuryPlace1Id);
}
QString DtcImplCustom::trSanitationInjuryPlace2Name(int sanitationInjuryPlace2Id)
{
return translate(&DtcImpl::sanitationInjuryPlace2, &ProjectDataManagement::trSanitationInjuryPlace2Name, sanitationInjuryPlace2Id);
}
QJsonObject DtcImplCustom::propertiesToJson(const QJsonObject &properties)
{
return properties;
}
void DtcImplCustom::setProps(ChargeTypeIgniterTypeIgniterFunctionProps &props, QJsonObject obj)
@@ -1370,7 +1383,7 @@ void DtcImplCustom::setProps(ChargeTypeIgniterTypeIgniterFunctionProps &props, Q
ce.impactRadius(objFt.value(QStringLiteral("impactRadius")).toInt());
props.casEffects.append(ce);
}
std::sort(props.casEffects.begin(), props.casEffects.end(), [](const CasEffect &a, const CasEffect &b) { return a.severityType() < b.severityType(); });
std::sort(props.casEffects.begin(), props.casEffects.end(), [](const CasEffect &a, const CasEffect &b) { return a.severityType < b.severityType; });
// Caution: Negate as suppressVisibility is negation of isVisible!
props.isVisible = !obj.value(QStringLiteral("suppressVisibility")).toBool(false);
@@ -1384,7 +1397,7 @@ void DtcImplCustom::setProps(ChargeTypeIgniterTypeIgniterFunctionProps &props, Q
// Malte: primary: most severe CasEffect
const QVector<CasEffect> &casEffectsCopy = props.casEffects;
if (!casEffectsCopy.empty())
props.impactRadius = casEffectsCopy.first().impactRadius();
props.impactRadius = casEffectsCopy.first().impactRadius;
props.impactEdgeLength = props.impactRadius * 2.0;
// : impactRadius by most severe CasEffect)
@@ -1400,22 +1413,22 @@ DtcImplCustom::ChargeTypeIgniterTypeIgniterFunctionProps DtcImplCustom::chargeTy
for (auto it = m_ctItIfProps.constBegin(); it != m_ctItIfProps.constEnd(); ++it)
{
if (it.value().chargeTypeId == chargeTypeId && it.value().igniterTypeId == igniterTypeId && it.value().igniterFunctionId == igniterFunctionId)
return it.value();
if ((*it).chargeTypeId == chargeTypeId && (*it).igniterTypeId == igniterTypeId && (*it).igniterFunctionId == igniterFunctionId)
return (*it);
}
// if no entry, find first entry for chargeTypeId & igniterTypeId
for (auto it = m_ctItIfProps.constBegin(); it != m_ctItIfProps.constEnd(); ++it)
{
if (it.value().chargeTypeId == chargeTypeId && it.value().igniterTypeId == igniterTypeId)
return it.value();
if ((*it).chargeTypeId == chargeTypeId && (*it).igniterTypeId == igniterTypeId)
return (*it);
}
// if no entry, find first entry for chargeTypeId
for (auto it = m_ctItIfProps.constBegin(); it != m_ctItIfProps.constEnd(); ++it)
{
if (it.value().chargeTypeId == chargeTypeId)
return it.value();
if ((*it).chargeTypeId == chargeTypeId)
return (*it);
}
return {};
@@ -1427,8 +1440,8 @@ DtcImplCustom::ChargeTypeLoadTypeProps DtcImplCustom::chargeTypeLoadTypeProps(in
for (auto it = m_ctLtProps.constBegin(); it != m_ctLtProps.constEnd(); ++it)
{
if (it.value().chargeTypeId == chargeTypeId && it.value().loadTypeId == loadTypeId)
return it.value();
if ((*it).chargeTypeId == chargeTypeId && (*it).loadTypeId == loadTypeId)
return (*it);
}
return {};
@@ -1436,14 +1449,14 @@ DtcImplCustom::ChargeTypeLoadTypeProps DtcImplCustom::chargeTypeLoadTypeProps(in
void DtcImplCustom::onGearTypeChanged(const GearType &gt)
{
if (gt.id() <= 0)
if (gt.id <= 0)
return;
QJsonParseError parserError;
const QByteArray props(QByteArray::fromRawData(gt.properties().c_str(), gt.properties().size()));
const QByteArray props(QByteArray::fromRawData(gt.properties.c_str(), gt.properties.size()));
const QJsonDocument doc(QJsonDocument::fromJson(props, &parserError));
if (parserError.error != QJsonParseError::NoError)
{
m_gtProps.remove(gt.id());
m_gtProps.remove(gt.id);
return;
}
@@ -1455,7 +1468,7 @@ void DtcImplCustom::onGearTypeChanged(const GearType &gt)
gtp.maxCharges = obj.value(QStringLiteral("maxCharges")).toInt(12);
gtp.adlerWeaponSystemId = obj.value(QStringLiteral("AdlerWeaponSystemId")).toInt();
gtp.cadence = obj.value(QStringLiteral("cadence")).toInt(-1);
m_gtProps.insert(gt.id(), gtp);
m_gtProps.insert(gt.id, gtp);
}
DtcImplCustom::GearTypeProps DtcImplCustom::gearTypeProps(int gearTypeId)
@@ -1467,7 +1480,7 @@ DtcImplCustom::GearTypeProps DtcImplCustom::gearTypeProps(int gearTypeId)
it = m_gtProps.constFind(gearTypeId);
}
if (it != m_gtProps.constEnd())
return it.value();
return (*it);
return GearTypeProps();
}
@@ -1502,7 +1515,7 @@ DtcImplCustom::GearTypeChargeTypeProps DtcImplCustom::gearTypeChargeTypeProps(in
it = m_gtctProps.constFind(gearTypeChargeTypeId);
}
if (it != m_gtctProps.constEnd())
return it.value();
return (*it);
return GearTypeChargeTypeProps();
}
@@ -1579,8 +1592,8 @@ double DtcImplCustom::getLethalRadius(int chargeTypeId, int igniterTypeId, int i
const auto &vec = casEffects(chargeTypeId, igniterTypeId, igniterFunctionId);
for (const ProjectDataManagement::CasEffect &casEffect : vec)
{
if (casEffect.severityType() == SeverityType_def::lethal)
return casEffect.impactRadius();
if (casEffect.severityType == SeverityType_def::lethal)
return casEffect.impactRadius;
}
return 0.0;
}
@@ -1590,8 +1603,8 @@ double DtcImplCustom::getNonLethalRadius(int chargeTypeId, int igniterTypeId, in
const auto &vec = casEffects(chargeTypeId, igniterTypeId, igniterFunctionId);
for (const ProjectDataManagement::CasEffect &casEffect : vec)
{
if (casEffect.severityType() == SeverityType_def::medium)
return casEffect.impactRadius();
if (casEffect.severityType == SeverityType_def::medium)
return casEffect.impactRadius;
}
return 0.0;
}
@@ -1601,8 +1614,8 @@ double DtcImplCustom::getMaxRange(int chargeTypeId, int gearTypeId)
const auto gear2ChargeMap = gearTypeChargeTypes();
for (auto gIt = gear2ChargeMap.begin(); gIt != gear2ChargeMap.end(); ++gIt)
{
if (gIt.value().gearTypeId() == gearTypeId && gIt.value().chargeTypeId() == chargeTypeId)
return gIt.value().maxRange();
if (gIt->gearTypeId == gearTypeId && gIt->chargeTypeId == chargeTypeId)
return gIt->maxRange;
}
return 0;
}
@@ -1617,7 +1630,7 @@ ProjectDataManagement::BuildingChargeEffect DtcImplCustom::getBuildingChargeEffe
for (const ProjectDataManagement::BuildingChargeEffect &bcEffect : qAsConst(m_buildingChargeEffectCont))
{
if (bcEffect.chargeTypeId() == chargeTypeId)
if (bcEffect.chargeTypeId == chargeTypeId)
{
DEBUG_LOG(m_logger) << "getBuildingChargeEffectByChargeTypeId: chargeTypeId '" << chargeTypeId << "' found"
<< ", bcEffect=" << bcEffect;
@@ -1636,8 +1649,8 @@ QString DtcImplCustom::adlerChargeTypeName(int chargeTypeId)
// if no entry, find first entry for chargeTypeId
for (auto it = m_ctItIfProps.constBegin(); it != m_ctItIfProps.constEnd(); ++it)
{
if (it.value().chargeTypeId == chargeTypeId)
return it.value().adlerChargeTypeName;
if ((*it).chargeTypeId == chargeTypeId)
return (*it).adlerChargeTypeName;
}
return {};
@@ -1647,8 +1660,8 @@ QString DtcImplCustom::adlerIgniterTypeName(int igniterTypeId)
{
for (auto it = m_ctItIfProps.constBegin(); it != m_ctItIfProps.constEnd(); ++it)
{
if (it.value().igniterTypeId == igniterTypeId)
return it.value().adlerIgniterTypeName;
if ((*it).igniterTypeId == igniterTypeId)
return (*it).adlerIgniterTypeName;
}
return {};
}
@@ -1657,8 +1670,8 @@ QString DtcImplCustom::adlerIgniterFunctionName(int igniterFunctionId)
{
for (auto it = m_ctItIfProps.constBegin(); it != m_ctItIfProps.constEnd(); ++it)
{
if (it.value().igniterFunctionId == igniterFunctionId)
return it.value().adlerIgniterFunctionName;
if ((*it).igniterFunctionId == igniterFunctionId)
return (*it).adlerIgniterFunctionName;
}
return {};
}
@@ -1667,8 +1680,8 @@ QString DtcImplCustom::adlerLoadTypeName(int loadTypeId)
{
for (auto it = m_ctLtProps.constBegin(); it != m_ctLtProps.constEnd(); ++it)
{
if (it.value().loadTypeId == loadTypeId)
return it.value().adlerLoadTypeName;
if ((*it).loadTypeId == loadTypeId)
return (*it).adlerLoadTypeName;
}
return {};
}
@@ -1677,9 +1690,9 @@ QString DtcImplCustom::adlerTargetTypeName(int targetTypeId)
{
for (const ProjectDataManagement::TargetType &targetTyp : qAsConst(m_targetTypeCont))
{
const QJsonObject obj = QJsonDocument::fromJson(QByteArray::fromRawData(targetTyp.properties().c_str(),
targetTyp.properties().size())).object();
if (targetTyp.id() == targetTypeId)
const QJsonObject obj = QJsonDocument::fromJson(QByteArray::fromRawData(targetTyp.properties.c_str(),
targetTyp.properties.size())).object();
if (targetTyp.id == targetTypeId)
return obj[QStringLiteral("AdlerL20String")].toString();
}
return {};
@@ -1689,9 +1702,9 @@ QString DtcImplCustom::adlerTargetSubTypeName(int targetSubTypeId)
{
for (const ProjectDataManagement::TargetSubType &targetSubTyp : qAsConst(m_targetSubTypeCont))
{
const QJsonObject obj = QJsonDocument::fromJson(QByteArray::fromRawData(targetSubTyp.properties().c_str(),
targetSubTyp.properties().size())).object();
if (targetSubTyp.id() == targetSubTypeId)
const QJsonObject obj = QJsonDocument::fromJson(QByteArray::fromRawData(targetSubTyp.properties.c_str(),
targetSubTyp.properties.size())).object();
if (targetSubTyp.id == targetSubTypeId)
return obj[QStringLiteral("AdlerL21String")].toString();
}
return {};
@@ -1700,14 +1713,14 @@ QString DtcImplCustom::adlerTargetSubTypeName(int targetSubTypeId)
int DtcImplCustom::getAmountFireMarkers(int firePurposeId)
{
const ProjectDataManagement::FirePurpose &fp = firePurpose(firePurposeId);
QJsonObject obj = propertiesToJson(fp.properties());
QJsonObject obj = propertiesToJson(fp.properties);
return obj.value(QStringLiteral("FireMarkers")).toInt();
}
bool DtcImplCustom::getWithDurationFirePurpose(int firePurposeId)
{
const ProjectDataManagement::FirePurpose &fp = firePurpose(firePurposeId);
QJsonObject obj = propertiesToJson(fp.properties());
QJsonObject obj = propertiesToJson(fp.properties);
return obj.value(QStringLiteral("withDuration")).toBool();
}