Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,32 @@
|
||||
#
|
||||
# monitoring of the target areas
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
|
||||
SET(SRCS
|
||||
plugin.cpp
|
||||
plugin.h
|
||||
handler_aes_data.cpp
|
||||
handler_aes_data.h
|
||||
handler_participant_area.cpp
|
||||
handler_participant_area.h
|
||||
settings.cpp
|
||||
settings.h
|
||||
logger.cpp
|
||||
logger.h
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(AAR SV cesPluginCes2D MODULE ${SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(cesPluginCes2D
|
||||
PUBLIC
|
||||
Qt5::Network
|
||||
Qt5::Widgets
|
||||
cesPluginInterface
|
||||
ngldb
|
||||
svcCesDDSCommon
|
||||
# ProjectConfig
|
||||
)
|
||||
NGL_INSTALL_TARGET(cesPluginCes2D)
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Export definitions
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hanna E. Rathje, SLSE, 2015-08-04
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#ifndef CES_COMMON_EXPORT
|
||||
# ifdef BUILD_STATIC_LIBRARIES
|
||||
# define CES_COMMON_EXPORT
|
||||
# else
|
||||
# if defined(MAKE_SVCCESCOMMON_LIB)
|
||||
# define CES_COMMON_EXPORT Q_DECL_EXPORT
|
||||
# ifndef WIN32
|
||||
# ifdef NDDSUSERDllExport
|
||||
# undef NDDSUSERDllExport
|
||||
# endif
|
||||
# define NDDSUSERDllExport Q_DECL_EXPORT
|
||||
# endif
|
||||
# else
|
||||
# define CES_COMMON_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef CES_CLIENT_EXPORT
|
||||
# ifdef BUILD_STATIC_LIBRARIES
|
||||
# define CES_CLIENT_EXPORT
|
||||
# else
|
||||
# if defined(MAKE_SVCCESCLIENT_LIB)
|
||||
# define CES_CLIENT_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
# define CES_CLIENT_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef CES_SERVER_EXPORT
|
||||
# ifdef BUILD_STATIC_LIBRARIES
|
||||
# define CES_SERVER_EXPORT
|
||||
# else
|
||||
# if defined(MAKE_SVCCESSERVER_LIB)
|
||||
# define CES_SERVER_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
# define CES_SERVER_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
@@ -0,0 +1,454 @@
|
||||
/**
|
||||
* Handler for player data
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-02-20
|
||||
*/
|
||||
|
||||
#include "handler_aes_data.h"
|
||||
#include "settings.h"
|
||||
|
||||
#include <CentralEffectSimulation/handler_participant.h>
|
||||
#include <CentralEffectSimulation/handler_building_data.h>
|
||||
|
||||
#include <QPainterPath>
|
||||
#include <QPointF>
|
||||
#include <QPolygonF>
|
||||
#include <QTimer>
|
||||
#include <QTransform>
|
||||
|
||||
#include <LtsUtilsCore/dds_bitarray.h>
|
||||
#include <LtsUtilsCore/qpoint3d.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
|
||||
|
||||
namespace Ces2D
|
||||
{
|
||||
|
||||
HandlerAesData::HandlerAesData(const std::shared_ptr<CentralEffectSimulation::DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<CentralEffectSimulation::HandlerBuildingData> &buildingDataHandler,
|
||||
QObject *parent)
|
||||
|
||||
: QObject(parent)
|
||||
, m_ddsHandler(ddsHandler)
|
||||
, m_handlerBuildingData(buildingDataHandler)
|
||||
, m_logger(getLogger("HandlerAesData"))
|
||||
{
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
HandlerAesData::~HandlerAesData()
|
||||
{
|
||||
} // end of dtor()
|
||||
//-----------------------------------------------------------------------------
|
||||
bool HandlerAesData::init()
|
||||
{
|
||||
auto dtcAes = m_ddsHandler->dtcAes();
|
||||
auto dtcIsm = m_ddsHandler->dtcIsm();
|
||||
auto ftcTab = m_ddsHandler->ftcTab();
|
||||
dtcIsm->enableMainFootprint();
|
||||
dtcAes->enableAirSupportImpact();
|
||||
dtcAes->waitForHistoricalDataExplosionSingleCentral(20000);
|
||||
ftcTab->enableSendCesHitInformation();
|
||||
|
||||
connect(dtcAes.get(), &AreaEffectSimulation::Interface::Dtc::explosionSingleChanged,
|
||||
this, &HandlerAesData::onExplosionSingleChanged);
|
||||
connect(dtcAes.get(), &AreaEffectSimulation::Interface::Dtc::airSupportImpactChanged,
|
||||
this, &HandlerAesData::onAirSupportImpactChanged);
|
||||
connect(dtcAes.get(), &AreaEffectSimulation::Interface::Dtc::triggeredImpactsChanged,
|
||||
this, &HandlerAesData::onTriggeredImpactsChanged);
|
||||
connect(dtcAes.get(), &AreaEffectSimulation::Interface::Dtc::aesItemViewChanged,
|
||||
this, &HandlerAesData::onAesItemViewChanged);
|
||||
connect(dtcIsm.get(), &InfrastructureManagement::Interface::Dtc::mainFootprintChanged,
|
||||
this, &HandlerAesData::onMainFootprintChanged);
|
||||
|
||||
// Get 'static' data for all MainFootprints
|
||||
{
|
||||
auto cb = [this](const InfrastructureManagement::MainFootprint & mfp)
|
||||
{
|
||||
onMainFootprintChanged(mfp, DataModification::eAdded);
|
||||
};
|
||||
if (!dtcIsm->mainFootprints(cb))
|
||||
return false;
|
||||
}
|
||||
// Get 'static' data for all AesItemView
|
||||
{
|
||||
auto cb = [this](const AreaEffectSimulation::AesItemView & aiv)
|
||||
{
|
||||
onAesItemViewChanged(aiv, DataModification::eAdded);
|
||||
};
|
||||
if (!dtcAes->aesItemViews(cb))
|
||||
return false;
|
||||
}
|
||||
|
||||
//Get AesNames for all Danger Areas
|
||||
connect(dtcAes.get(), &AreaEffectSimulation::Interface::Dtc::dangerAreaChanged,
|
||||
this, cbGetNames);
|
||||
dtcAes->dangerAreas(cbGetNames);
|
||||
|
||||
//Get AesNames for all Nuclear Contaminations
|
||||
connect(dtcAes.get(), &AreaEffectSimulation::Interface::Dtc::nContaminationChanged,
|
||||
this, cbGetNames);
|
||||
dtcAes->nContaminations(cbGetNames);
|
||||
|
||||
//Get AesNames for all Mine Areas
|
||||
connect(dtcAes.get(), &AreaEffectSimulation::Interface::Dtc::mineAreaChanged,
|
||||
this, cbGetNames);
|
||||
dtcAes->mineAreas(cbGetNames);
|
||||
|
||||
//Get AesNames for all Functionsl Areas
|
||||
connect(dtcAes.get(), &AreaEffectSimulation::Interface::Dtc::functionalAreaChanged,
|
||||
this, cbGetNames);
|
||||
dtcAes->functionalAreas(cbGetNames);
|
||||
|
||||
return true;
|
||||
} // end of init()
|
||||
//-----------------------------------------------------------------------------
|
||||
// ///////////////////////////////////
|
||||
// A E S (AreaEffectSimulation)
|
||||
// ///////////////////////////////////
|
||||
|
||||
void HandlerAesData::onAesItemViewChanged(const AreaEffectSimulation::AesItemView &data, DataModification modType)
|
||||
{
|
||||
if (modType != DataModification::eAdded &&
|
||||
modType != DataModification::eModified)
|
||||
return;
|
||||
|
||||
DEBUG_LOG(m_logger) << "Got AesItemView: " << data.effectStateId();
|
||||
switch (data.effectStateId().underlying())
|
||||
{
|
||||
case AreaEffectSimulation::AesEffectState_def::EsUnknown:
|
||||
case AreaEffectSimulation::AesEffectState_def::EsError:
|
||||
case AreaEffectSimulation::AesEffectState_def::EsExpired:
|
||||
case AreaEffectSimulation::AesEffectState_def::EsRemoved:
|
||||
removeStates(data);
|
||||
m_aesItemViews.remove(data.aesItemId());
|
||||
break;
|
||||
case AreaEffectSimulation::AesEffectState_def::EsPrepared:
|
||||
case AreaEffectSimulation::AesEffectState_def::EsPaused:
|
||||
case AreaEffectSimulation::AesEffectState_def::EsActivated:
|
||||
case AreaEffectSimulation::AesEffectState_def::EsFired:
|
||||
m_aesItemViews.insert(data.aesItemId(), data);
|
||||
break;
|
||||
case AreaEffectSimulation::AesEffectState_def::EsCreated:
|
||||
case AreaEffectSimulation::AesEffectState_def::EsReceived:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void HandlerAesData::removeStates(const AreaEffectSimulation::AesItemView &data)
|
||||
{
|
||||
if (data.aesTypeId() != AreaEffectSimulation::AesType_def::AtExplosionArea)
|
||||
return;
|
||||
DEBUG_LOG(m_logger) << "Remove aesItemId=" << data.aesItemId();
|
||||
// remove State for each building
|
||||
for (BitfieldStates &bfs : m_bitfieldStatesBld)
|
||||
bfs.remove(data.aesItemId());
|
||||
} // end removeStates
|
||||
|
||||
void HandlerAesData::onExplosionSingleChanged(const AreaEffectSimulation::ExplosionSingle &data, DataModification modType)
|
||||
{
|
||||
bool handleExplosion = false;
|
||||
if (modType != DataModification::eAdded &&
|
||||
modType != DataModification::eModified)
|
||||
{
|
||||
m_explosionSingleState.remove(data.id());
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsRemoved)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Remove SingleExplosion";
|
||||
m_explosionSingleState.remove(data.id());
|
||||
return;
|
||||
}
|
||||
// Only handle transitions from prepared to activated
|
||||
if (m_explosionSingleState.value(data.id()) == AreaEffectSimulation::AesEffectState_def::EsPrepared
|
||||
&& data.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsActivated)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Handle SingleExplosion";
|
||||
handleExplosion = true;
|
||||
}
|
||||
m_explosionSingleState.insert(data.id(), data.effectStateId());
|
||||
|
||||
|
||||
DEBUG_LOG(m_logger) << "Got ExplosionSingle";
|
||||
if (handleExplosion)
|
||||
{
|
||||
const double impactRadius = m_ddsHandler->chargeTypeRadius(data.chargeTypeId());
|
||||
DEBUG_LOG(m_logger) << "Handle ExplosionSingle (EsActivated)";
|
||||
|
||||
// Bounding-Box-Check
|
||||
// QMap<int, Footprint> m_footprints;
|
||||
for (const Footprint &footprint : qAsConst(m_footprints))
|
||||
{
|
||||
const QPointF impactPos(CentralEffectSimulation::geographic2Utm(data.impactPosition(), footprint.zone));
|
||||
const QPolygonF polyBldgRadius({QPointF(footprint.boundingBoxPolyUtm.bottomLeft().rx() - impactRadius,
|
||||
footprint.boundingBoxPolyUtm.bottomLeft().ry() + impactRadius),
|
||||
QPointF(footprint.boundingBoxPolyUtm.topRight().rx() + impactRadius,
|
||||
footprint.boundingBoxPolyUtm.bottomLeft().ry() + impactRadius),
|
||||
QPointF(footprint.boundingBoxPolyUtm.topRight().rx() + impactRadius,
|
||||
footprint.boundingBoxPolyUtm.topRight().ry() - impactRadius),
|
||||
QPointF(footprint.boundingBoxPolyUtm.bottomLeft().rx() - impactRadius,
|
||||
footprint.boundingBoxPolyUtm.topRight().ry() - impactRadius)});
|
||||
if (polyBldgRadius.containsPoint(impactPos, Qt::OddEvenFill))
|
||||
{
|
||||
//calculateImpacts(data, footprint.mseId);
|
||||
// check, if impact-pos + munition-radius touch the building
|
||||
// get radius of munition
|
||||
const Core::GeoPosition2D impactPosition(data.impactPosition().lon(), data.impactPosition().lat());
|
||||
if (inFootprint(impactPosition, impactRadius, footprint))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "ftc sendCESHitOnBuilding mseId = " << footprint.mseId
|
||||
<< " chargeTypeId = " << data.chargeTypeId()
|
||||
<< " id = " << data.id()
|
||||
<< " currentPartitionTime = " << m_ddsHandler->currentPartitionTime()
|
||||
<< " impactPosition.lon = " << impactPosition.lon()
|
||||
<< " impactPosition.lat = " << impactPosition.lat();
|
||||
|
||||
Buildings::SendCesHitOnBuildingRequest requestBld(
|
||||
footprint.mseId,
|
||||
data.chargeTypeId(),
|
||||
data.id(),
|
||||
m_ddsHandler->currentPartitionTime(),
|
||||
Core::GeoPosition(impactPosition.lon(), impactPosition.lat(), 0.0));
|
||||
m_ddsHandler->ftcBld()->sendCesHitOnBuildingRequest(requestBld, this);
|
||||
}
|
||||
else
|
||||
DEBUG_LOG(m_logger) << "Not sendCESHitOnBuilding mseId = " << footprint.mseId;
|
||||
|
||||
DEBUG_LOG(m_logger) << "boundingBoxImpact.contains(footprint)";
|
||||
}
|
||||
} // for
|
||||
}
|
||||
} // onExplosionSingleChanged
|
||||
|
||||
void HandlerAesData::onAirSupportImpactChanged(const AreaEffectSimulation::AirSupportImpact &data, DataModification modType)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Got onAirSupportImpactChanged()";
|
||||
AreaEffectSimulation::ExplosionSingle esData;
|
||||
esData.id(data.id());
|
||||
esData.chargeTypeId(data.chargeTypeId());
|
||||
esData.impactPosition(data.impactPosition());
|
||||
esData.effectStateId(data.effectStateId());
|
||||
onExplosionSingleChanged(esData, modType);
|
||||
} // onExplosionSingleChanged
|
||||
|
||||
void HandlerAesData::onTriggeredImpactsChanged(const AreaEffectSimulation::TriggeredImpacts &data, DataModification modType)
|
||||
{
|
||||
if (modType != DataModification::eAdded &&
|
||||
modType != DataModification::eModified)
|
||||
return;
|
||||
|
||||
DEBUG_LOG(m_logger) << "Got TriggeredImpacts";
|
||||
preCalculateImpacts(data);
|
||||
}
|
||||
|
||||
// ///////////////////////////////////
|
||||
// I S M (InfrastructureManagement)
|
||||
// ///////////////////////////////////
|
||||
void HandlerAesData::onMainFootprintChanged(const InfrastructureManagement::MainFootprint &data, DataModification modType)
|
||||
{
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
case DataModification::eModified:
|
||||
DEBUG_LOG(m_logger) << "Got MainFootprint (Building)";
|
||||
calculateFootprint(data);
|
||||
break;
|
||||
case DataModification::eRemoved:
|
||||
m_footprints.remove(data.id());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// ///////////////////////////////////
|
||||
// Calculations:
|
||||
// ///////////////////////////////////
|
||||
|
||||
void HandlerAesData::calculateFootprint(const InfrastructureManagement::MainFootprint &mainFootprint)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Footprint: " << mainFootprint.id() << ": " << mainFootprint;
|
||||
DEBUG_LOG(m_logger) << "Footprint: " << " mainFootprint.elements().size()=" << mainFootprint.elements().size();
|
||||
|
||||
// If poly is Empty continue with next Footprint
|
||||
if (mainFootprint.elements().size() <= 0)
|
||||
return;
|
||||
|
||||
const InfrastructureManagement::MainStructureElement mse
|
||||
= m_handlerBuildingData->mainStructureElement(mainFootprint.id());
|
||||
if (mse.id() != mainFootprint.id())
|
||||
{
|
||||
// not (yet) there
|
||||
QTimer::singleShot(1000, this, [this, mainFootprint]() { calculateFootprint(mainFootprint); });
|
||||
return;
|
||||
}
|
||||
|
||||
// insert all Points to poly
|
||||
QPolygonF poly;
|
||||
poly.reserve(mainFootprint.elements().size());
|
||||
for (const InfrastructureManagement::FootprintElement &element : mainFootprint.elements())
|
||||
{
|
||||
const auto &relPos = element.relPosition();
|
||||
poly.push_back(QPointF(relPos.offsetX(), relPos.offsetY()));
|
||||
}
|
||||
|
||||
// rotate poly
|
||||
QTransform trans;
|
||||
trans.rotate(mse.angle());
|
||||
poly = trans.map(poly);
|
||||
|
||||
Footprint footprint;
|
||||
footprint.mseId = mainFootprint.id();
|
||||
footprint.geoPosition = mse.geoPosition();
|
||||
const QPointF utmFpPosition = CentralEffectSimulation::geographic2Utm(footprint.geoPosition, &footprint.zone);
|
||||
footprint.polyUtm.reserve(poly.size());
|
||||
for (const QPointF &point : qAsConst(poly))
|
||||
footprint.polyUtm.push_back(utmFpPosition + point);
|
||||
footprint.boundingBoxPolyUtm = footprint.polyUtm.boundingRect();
|
||||
|
||||
m_footprints.insert(footprint.mseId, footprint);
|
||||
}
|
||||
|
||||
bool HandlerAesData::inFootprint(const Core::GeoPosition2D &geoPosition, const double radius, const Footprint &footPrint) const
|
||||
{
|
||||
const QPointF impact(CentralEffectSimulation::geographic2Utm(geoPosition, footPrint.zone));
|
||||
|
||||
if (m_logger.isDebugEnabled())
|
||||
{
|
||||
const QPointF utmBuilding(CentralEffectSimulation::geographic2Utm(footPrint.geoPosition, footPrint.zone));
|
||||
DEBUG_LOG(m_logger) << "Impact (x/y)=" << CentralEffectSimulation::debug(impact - utmBuilding);
|
||||
for (int i = 0; i < footPrint.polyUtm.length(); i++)
|
||||
DEBUG_LOG(m_logger) << " poly (x/y)=" << CentralEffectSimulation::debug(footPrint.polyUtm[i] - utmBuilding);
|
||||
}
|
||||
|
||||
// Check, if hit direct on building
|
||||
if (footPrint.polyUtm.containsPoint(impact, Qt::OddEvenFill))
|
||||
return true;
|
||||
|
||||
// Check, if hit in munition-radius
|
||||
QPainterPath ppFp;
|
||||
ppFp.addPolygon(footPrint.polyUtm);
|
||||
QPainterPath ppCircle;
|
||||
ppCircle.addEllipse(impact, radius, radius);
|
||||
return ppFp.intersects(ppCircle);
|
||||
}
|
||||
|
||||
void HandlerAesData::preCalculateImpacts(const AreaEffectSimulation::TriggeredImpacts &data)
|
||||
{
|
||||
if (data.id() <= 0)
|
||||
return;
|
||||
DEBUG_LOG(m_logger) << "preCalculateImpacts";
|
||||
// Find AES ItemView and set Bounding-Box of Aes-Field
|
||||
|
||||
// Search corresponding itemView and get boundingBox data in UTM
|
||||
const bool bFound = m_aesItemViews.contains(data.aesItemId());
|
||||
if (!bFound)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Could not find item view for aes with id " << data.aesItemId();
|
||||
return;
|
||||
}
|
||||
// Bounding-Box-Check
|
||||
// QMap<int, Footprint> m_footprints;
|
||||
for (const Footprint &footprint : qAsConst(m_footprints))
|
||||
{
|
||||
//if (boundingBoxImpact.contains(footprint.boundingBoxPolyUtm))
|
||||
calculateImpacts(data, footprint);
|
||||
} // for
|
||||
|
||||
}
|
||||
|
||||
void HandlerAesData::onSendCesHitOnBuildingReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
if (replyObject.error())
|
||||
WARNING_LOG(m_logger) << "Can not send hit on building to building service: " << replyObject();
|
||||
else
|
||||
DEBUG_LOG(m_logger) << "onSendCesHitOnBuildingReply for id " << replyObject.id() << " success\n"
|
||||
<< " replyObject.str() = " << replyObject.str();
|
||||
}
|
||||
|
||||
void HandlerAesData::onSendCesHitInformationReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
if (reply.error())
|
||||
WARNING_LOG(m_logger) << "onSendCesHitInformationReply for id " << reply.id() << " failed: " << reply.str();
|
||||
else
|
||||
DEBUG_LOG(m_logger) << "onSendCesHitInformationReply for id " << reply.id() << " successful";
|
||||
}
|
||||
|
||||
// calculate impacts for one building
|
||||
void HandlerAesData::calculateImpacts(const AreaEffectSimulation::TriggeredImpacts &data, const Footprint &footprint)
|
||||
{
|
||||
// check for correct AES type artillery only
|
||||
switch (data.aesTypeId().underlying())
|
||||
{
|
||||
case AreaEffectSimulation::AesType_def::AtExplosionArea:
|
||||
case AreaEffectSimulation::AesType_def::AtExplosionSingle:
|
||||
case AreaEffectSimulation::AesType_def::AtExplosionAreaSingleExplosions:
|
||||
DEBUG_LOG(m_logger) << "Calculate";
|
||||
break;
|
||||
default:
|
||||
DEBUG_LOG(m_logger) << "No Calculation";
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "calculateImpacts mseId=" << footprint.mseId << " data.aesItemId() " << data.aesItemId();
|
||||
|
||||
|
||||
// get position(s) of impact(s):
|
||||
|
||||
// Search corresponding itemView. If not available no impact to participant.
|
||||
auto it = m_aesItemViews.constFind(data.aesItemId());
|
||||
if (it == m_aesItemViews.constEnd())
|
||||
{
|
||||
WARNING_LOG(m_logger) << "TriggeredExplosions.aesItemId=" << data.aesItemId() << " No aesItemView available";
|
||||
return;
|
||||
}
|
||||
|
||||
BitfieldStates &bitfieldStates = m_bitfieldStatesBld[footprint.mseId];
|
||||
QSet<int> &bitfieldState = bitfieldStates[data.aesItemId()];
|
||||
for (int i : qAsConst(bitfieldState))
|
||||
DEBUG_LOG(m_logger) << "bitfieldState for " << data.aesItemId() << ": " << i;
|
||||
|
||||
const AreaEffectSimulation::AesItemView &aesItemView = *it;
|
||||
for (int32_t bitFieldIdx = 0; bitFieldIdx < data.impactCount(); ++bitFieldIdx)
|
||||
{
|
||||
// no break, because every bit can be a hit
|
||||
if (LtsUtils::BitArray::testBit(data.bitfield(), bitFieldIdx))
|
||||
continue;
|
||||
|
||||
// get position of impact to corresponding bit
|
||||
if (aesItemView.form().size() <= size_t(bitFieldIdx))
|
||||
continue;
|
||||
|
||||
const Core::GeoPosition2D &impactPosition = aesItemView.form()[bitFieldIdx];
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION
|
||||
<< " impactPosition: lat/lon" << impactPosition.lat() << "/" << impactPosition.lon()
|
||||
<< " UTM=" << CentralEffectSimulation::debug(CentralEffectSimulation::geographic2Utm(impactPosition));
|
||||
|
||||
// check, if impact-pos + munition-radius touch the building
|
||||
// get radius of munition
|
||||
const double impactRadius = m_ddsHandler->chargeTypeRadius(aesItemView.chargeTypeId());
|
||||
if (inFootprint(impactPosition, impactRadius, footprint))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "In Footprint mseId = " << footprint.mseId;
|
||||
if (!bitfieldState.contains(bitFieldIdx))
|
||||
{
|
||||
bitfieldState.insert(bitFieldIdx);
|
||||
|
||||
DEBUG_LOG(m_logger) << "m_bitfieldStates.insert(data.aesItemId()=" << data.aesItemId() << ", bitfieldState)" << " bitFieldIdx=" << bitFieldIdx;
|
||||
|
||||
DEBUG_LOG(m_logger) << "ftc sendCESHitOnBuilding mseId = " << footprint.mseId << " bitFieldIdx= " << bitFieldIdx ;
|
||||
Buildings::SendCesHitOnBuildingRequest requestBld(
|
||||
footprint.mseId,
|
||||
aesItemView.chargeTypeId(),
|
||||
aesItemView.aesItemId(),
|
||||
m_ddsHandler->currentPartitionTime(),
|
||||
Core::GeoPosition(impactPosition.lon(), impactPosition.lat(), 0.0));
|
||||
m_ddsHandler->ftcBld()->sendCesHitOnBuildingRequest(requestBld, this);
|
||||
}
|
||||
}
|
||||
} // foreach Impact
|
||||
}
|
||||
|
||||
} // namespace Ces2D
|
||||
@@ -0,0 +1,120 @@
|
||||
/**
|
||||
* Handler for player data
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by gr, SLSE, 2017-02-20
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
#include <AreaEffectSimulation/aes_dtc.h>
|
||||
#include <Buildings/bld_dtc.h>
|
||||
#include <Buildings/bld_ftc.h>
|
||||
#include <ProjectDataManagement/pdm_dtc.h>
|
||||
#include <TrainingAreaBase/tab_ftc.h>
|
||||
#include <CentralEffectSimulation/dds_handler.h>
|
||||
#include <CentralEffectSimulation/handler_building_data.h>
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QVector>
|
||||
#include <QPolygonF>
|
||||
|
||||
|
||||
namespace LtsUtils
|
||||
{
|
||||
class QPoint3D;
|
||||
}
|
||||
|
||||
// AES-Handling for buildings
|
||||
|
||||
namespace Ces2D
|
||||
{
|
||||
|
||||
|
||||
class HandlerAesData : public QObject
|
||||
, protected Buildings::Interface::Ftc::SendCesHitOnBuildingReplyHandler
|
||||
, protected TrainingAreaBase::Interface::Ftc::SendCesHitInformationReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit HandlerAesData(const std::shared_ptr<CentralEffectSimulation::DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<CentralEffectSimulation::HandlerBuildingData> &buildingDataHandler,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
~HandlerAesData();
|
||||
|
||||
/**
|
||||
* Initialize the handler to manage information from player management
|
||||
*/
|
||||
bool init();
|
||||
AreaEffectSimulation::AesItemView itemView(const int &aesId) const { return m_aesItemViews.value(aesId); }
|
||||
|
||||
protected:
|
||||
void onSendCesHitOnBuildingReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
void onSendCesHitInformationReply(const Core::FunctionReplyObject &reply) override final;
|
||||
|
||||
private slots:
|
||||
/**
|
||||
* Handle the signals from 'AES'
|
||||
*/
|
||||
void onExplosionSingleChanged(const AreaEffectSimulation::ExplosionSingle &data, DataModification modType);
|
||||
void onAirSupportImpactChanged(const AreaEffectSimulation::AirSupportImpact &data, DataModification modType);
|
||||
void onAesItemViewChanged(const AreaEffectSimulation::AesItemView &data, DataModification modType);
|
||||
void onTriggeredImpactsChanged(const AreaEffectSimulation::TriggeredImpacts &data, DataModification modType);
|
||||
|
||||
/**
|
||||
* Handle MainFootprint from 'ISM'
|
||||
*/
|
||||
void onMainFootprintChanged(const InfrastructureManagement::MainFootprint &data, DataModification modType);
|
||||
|
||||
void removeStates(const AreaEffectSimulation::AesItemView &data);
|
||||
|
||||
private: // structs
|
||||
struct Footprint
|
||||
{
|
||||
int mseId = -1;
|
||||
int zone = -1;
|
||||
Core::GeoPosition geoPosition;
|
||||
QPolygonF polyUtm;
|
||||
QRectF boundingBoxPolyUtm;
|
||||
|
||||
bool isValid() const { return mseId > 0; }
|
||||
};
|
||||
|
||||
typedef QHash<int, QSet<int>> BitfieldStates;
|
||||
|
||||
private: // methoden
|
||||
void handleExplosionSingleCentral(const AreaEffectSimulation::AesItemView &itemView);
|
||||
|
||||
void calculateFootprint(const InfrastructureManagement::MainFootprint &mainFootprint);
|
||||
|
||||
bool inFootprint(const Core::GeoPosition2D &geoPosition, const double radius, const Footprint &footPrint) const;
|
||||
|
||||
void preCalculateImpacts(const AreaEffectSimulation::TriggeredImpacts &data);
|
||||
void calculateImpacts(const AreaEffectSimulation::TriggeredImpacts &data, const Footprint &footprint);
|
||||
double getRadiusOfMunition(const int32_t chargeTypeId) const;
|
||||
|
||||
|
||||
private: // attributes
|
||||
|
||||
std::shared_ptr<CentralEffectSimulation::DdsHandler> m_ddsHandler; ///< Pointer to VOM DDS handler
|
||||
std::shared_ptr<CentralEffectSimulation::HandlerBuildingData> m_handlerBuildingData;
|
||||
|
||||
QHash<int, Footprint> m_footprints; // key = footprint.mseId
|
||||
QHash<int, BitfieldStates> m_bitfieldStatesBld; // key = mseId, value = BitfieldState
|
||||
|
||||
// AES-Values
|
||||
QHash<int, AreaEffectSimulation::AesItemView> m_aesItemViews; // key = aesItemId
|
||||
QHash<int, AreaEffectSimulation::AesEffectState> m_explosionSingleState; // key = id value = state
|
||||
|
||||
NGL::INGLLogger &m_logger; ///< Interface to the Logging-Facility
|
||||
|
||||
};
|
||||
|
||||
} // namespace Ces2D
|
||||
|
||||
+1537
File diff suppressed because it is too large.
Load diff
+163
@@ -0,0 +1,163 @@
|
||||
/**
|
||||
* Handler for player data
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by gr, SLSE, 2017-02-20
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "logger.h"
|
||||
|
||||
#include <CentralEffectSimulation/dds_handler.h>
|
||||
#include <CentralEffectSimulation/aes_item_view_utm.h>
|
||||
#include <CentralEffectSimulation/handler_participant.h>
|
||||
#include <handler_aes_data.h>
|
||||
#include <handler_building_model.h>
|
||||
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QQueue>
|
||||
#include <QtCore/QPointF>
|
||||
#include <QtGui/QPolygonF>
|
||||
|
||||
// AES-Handling for participants
|
||||
namespace Ces2D
|
||||
{
|
||||
enum class EffectType
|
||||
{
|
||||
Unknown = 0,
|
||||
EffectiveMineRangeEnter = 0xf0000 | 1, // AtMineAreaSingleMines = 15 = 0xf
|
||||
EffectiveMineRangeLeave = 0xf0000 | 2, // AtMineAreaSingleMines = 15 = 0xf
|
||||
NContaminationLeave = 0x10000 | 0, // AtNContamination = 1
|
||||
NContaminationEnterArea1 = 0x10000 | 1,
|
||||
NContaminationEnterArea2 = 0x10000 | 2,
|
||||
NContaminationDetonation = 0x10000 | 255,
|
||||
FunctionalAreaLeave = 0xc0000 | 0, // AtReconArea = 12 = 0xc
|
||||
FunctionalAreaEnter = 0xc0000 | 1,
|
||||
ExplosionArea = 0x30000 | 2, // AtExplosionArea = 3
|
||||
ExplosionSingle = 0x40000 | 3, // AtExplosionSingle = 4
|
||||
BCContaminationLeave = 0x20000 | 0, // AtBCContamination = 2
|
||||
BCContaminationEnterFloating = 0x20000 | 1,
|
||||
BCContaminationEnterResident = 0x20000 | 2,
|
||||
BCContaminationEnterFloatingArea = 0x20000 | 3,
|
||||
BeStillWarning = 11,
|
||||
};
|
||||
QString toString(EffectType et);
|
||||
|
||||
struct ParticipantDistance
|
||||
{
|
||||
double squareDistance = 0;
|
||||
CentralEffectSimulation::HandlerParticipant::CesParticipantData participantPosition;
|
||||
};
|
||||
|
||||
class HandlerParticipantArea : public QObject
|
||||
, protected TrainingAreaBase::Interface::Ftc::SendCesHitReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit HandlerParticipantArea(const std::shared_ptr<CentralEffectSimulation::DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<CentralEffectSimulation::HandlerParticipant> &participantHandler,
|
||||
const std::shared_ptr<HandlerAesData> &aesDataHandler,
|
||||
const std::shared_ptr<HandlerBuildingModel> &buildingModelHandler,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
~HandlerParticipantArea();
|
||||
|
||||
/**
|
||||
* Initialize the handler to manage information from player management
|
||||
*/
|
||||
bool init();
|
||||
|
||||
protected:
|
||||
void onSendCesHitReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
|
||||
private Q_SLOTS:
|
||||
/**
|
||||
* Handle the signals from 'AES'
|
||||
*/
|
||||
void onAesItemViewChanged(const AreaEffectSimulation::AesItemView &data, DataModification modType);
|
||||
void onTriggeredImpactsChanged(const AreaEffectSimulation::TriggeredImpacts &data, DataModification modType);
|
||||
void onExplosionAreaChanged(const AreaEffectSimulation::ExplosionArea &data, DataModification modType);
|
||||
void onExplosionSingleChanged(const AreaEffectSimulation::ExplosionSingle &data, DataModification modType);
|
||||
void onExplosionSingleCentralChanged(const AreaEffectSimulation::ExplosionSingleCentral &data, DataModification modType);
|
||||
void onDusSingleMineChanged(const AreaEffectSimulation::DusSingleMine &data, DataModification modType);
|
||||
void onBCContaminationChanged(const AreaEffectSimulation::BCContamination &data, DataModification modType);
|
||||
void onNContaminationChanged(const AreaEffectSimulation::NContamination &data, DataModification modType);
|
||||
|
||||
private: // methoden
|
||||
void calculateImpacts(const AreaEffectSimulation::TriggeredImpacts &data);
|
||||
void calculateImpacts(const CentralEffectSimulation::AesItemViewUtm &itemView,
|
||||
const QVector<int> &impactsToCheck,
|
||||
const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantPosition);
|
||||
void calculateBcContamination(const CentralEffectSimulation::AesItemViewUtm &itemView);
|
||||
void calculateFunctionArea(const CentralEffectSimulation::AesItemViewUtm &itemView);
|
||||
void deleteFunctionalArea(const int aesItemId);
|
||||
void calculateAesParticipant(const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantPos);
|
||||
void calculateSmartExplosion(const AreaEffectSimulation::ExplosionSingle &data,
|
||||
const QHash<int, CentralEffectSimulation::HandlerParticipant::CesParticipantData> &participantPositions,
|
||||
qint64 impactTime);
|
||||
bool inMineRadiusCheck(const CentralEffectSimulation::AesItemViewUtm &itemView, const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantPosition);
|
||||
|
||||
bool inCircle(const QPointF ¢erUtm, const double radius, const QPointF &pointUtm);
|
||||
bool inBoundingBoxCheck(const CentralEffectSimulation::AesItemViewUtm &itemView, const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantPosition);
|
||||
bool inFormCheck(const CentralEffectSimulation::AesItemViewUtm &itemView, const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantPosition);
|
||||
void sendCesHitRequest(const CentralEffectSimulation::AesItemViewUtm &itemView,
|
||||
const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantPosition,
|
||||
qint64 effectTime,
|
||||
int remaining,
|
||||
int mineFieldBitIndex = 0);
|
||||
void sendCesHitRequest(const AreaEffectSimulation::AesItemView &itemView,
|
||||
const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantPosition,
|
||||
qint64 effectTime,
|
||||
int remaining,
|
||||
int mineFieldBitIndex = 0);
|
||||
void sendParticipantEvent(const CentralEffectSimulation::AesItemViewUtm &itemView,
|
||||
const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantPosition,
|
||||
const ProjectDataManagement::EventType eventType);
|
||||
void sendEffectTypeEvent(const CentralEffectSimulation::AesItemViewUtm &itemView,
|
||||
const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantPosition,
|
||||
EffectType effectType,
|
||||
int mineFieldBitIndex,
|
||||
qint64 effectTime);
|
||||
|
||||
bool eventMustBeSend(int aesItemId,
|
||||
int participantId,
|
||||
const ProjectDataManagement::EventType eventType);
|
||||
|
||||
bool effectTypeMustBeSend(int aesItemId,
|
||||
int participantId,
|
||||
EffectType effectType,
|
||||
int mineFieldBitIndex,
|
||||
bool insideBuilding);
|
||||
|
||||
ProjectDataManagement::EventType leaveEventTypeForAesType(AreaEffectSimulation::AesType aesTypeId);
|
||||
EffectType leaveEffectTypeForAesType(AreaEffectSimulation::AesType aesTypeId);
|
||||
EffectType effectTypeForNContaminationArea(const CentralEffectSimulation::AesItemViewUtm &itemView, const QPointF &participantPosUtmPoint, qint64 partPosSampleTime);
|
||||
EffectType effectTypeForBCContaminationArea(const CentralEffectSimulation::AesItemViewUtm &itemView, const QPointF &participantPosUtmPoint);
|
||||
|
||||
void aesItemViewRemoved(int aesItemId);
|
||||
private: // attributes
|
||||
|
||||
std::shared_ptr<CentralEffectSimulation::DdsHandler> m_ddsHandler; ///< Pointer to VOM DDS handler
|
||||
std::shared_ptr<CentralEffectSimulation::HandlerParticipant> m_handlerParticipant;
|
||||
std::shared_ptr<HandlerAesData> m_handlerAesData;
|
||||
std::shared_ptr<HandlerBuildingModel> m_handlerBuildingModel;
|
||||
|
||||
QHash<int32_t, int> m_aesItemId2partIdMap;
|
||||
QHash<int, AreaEffectSimulation::TriggeredImpacts> m_triggeredImpacts; // key = aesItemId
|
||||
|
||||
|
||||
// AES-Values
|
||||
QHash<int, CentralEffectSimulation::AesItemViewUtm> m_aesItemViews; // key = aesItemId
|
||||
QQueue<TrainingAreaBase::SendCesHitRequest> m_sendCesHitRequestQueue;
|
||||
QHash<int, AreaEffectSimulation::AesEffectState> m_explosionSingleStates; // key = id value = state
|
||||
QHash<int, AreaEffectSimulation::AesEffectState> m_explosionSingleCentralStates;
|
||||
QHash<int, QHash<int, QSet<ProjectDataManagement::EventType>>> m_eventStates; // QHash<aesItemId, QHash<participantId, QSet<EventType>>>
|
||||
QHash<int, QHash<int, QSet<EffectType>>> m_effectTypeStates; // QHash<aesItemId, QHash<participantId, QSet<effectStates>>>
|
||||
QHash<int, QHash<int, QSet<int>>> m_effectTypeBitFieldIndexes; // QHash<aesItemId, QHash<participantId, QSet<mineFieldBitIdx>>>
|
||||
|
||||
NGL::INGLLogger &m_logger; ///< Interface to the Logging-Facility
|
||||
};
|
||||
} // namespace Ces2D
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Building Config - logging facility
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
namespace Ces2D
|
||||
{
|
||||
|
||||
LOGGER_T getLogger(const char *name)
|
||||
{
|
||||
static const char ns[] = "CES.";
|
||||
std::string loggerName;
|
||||
const size_t len = strlen(name);
|
||||
loggerName.reserve(sizeof(ns) + len);
|
||||
loggerName.append(ns, sizeof(ns) - 1);
|
||||
loggerName.append(name, len);
|
||||
|
||||
try
|
||||
{
|
||||
return NGL::NGLLoggerBootstrap::getNGLRootLogger().
|
||||
getNGLLogger(loggerName);
|
||||
}
|
||||
catch (const std::exception &ex)
|
||||
{
|
||||
fprintf(stderr, "Error retrieving logger: %s", ex.what());
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Ces2D
|
||||
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Logging for CentralEffectSimulation
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
#include "ces_export.h"
|
||||
|
||||
namespace Ces2D
|
||||
{
|
||||
using LOGGER_T = NGL::INGLLogger &;
|
||||
|
||||
CES_COMMON_EXPORT LOGGER_T getLogger(const char *name);
|
||||
inline LOGGER_T getLogger(const QString &loggerName)
|
||||
{
|
||||
return getLogger(loggerName.toUtf8().constData());
|
||||
}
|
||||
} // namespace Ces2D
|
||||
@@ -0,0 +1,111 @@
|
||||
/**
|
||||
* Plugin Ces2D
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Gerlinde Rudolphus, SLTE, 2016-04-14
|
||||
*/
|
||||
|
||||
#include "plugin.h"
|
||||
#include "settings.h"
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
#include <ngldb/db_service_handler.h>
|
||||
|
||||
namespace Ces2D
|
||||
{
|
||||
|
||||
|
||||
std::shared_ptr<CentralEffectSimulation::Plugin::Interface> CentralEffectSimulation2DPlugin::createInterface(CentralEffectSimulation::Plugin::DataProvider *pdp,
|
||||
const std::shared_ptr<DDSConnector::DdsConnector> &dDSConnector,
|
||||
NGL::Settings *settings,
|
||||
const std::shared_ptr<CentralEffectSimulation::DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<CentralEffectSimulation::DatabaseInterface> &db,
|
||||
const std::shared_ptr<CentralEffectSimulation::HandlerParticipant> &handlerParticipant,
|
||||
const std::shared_ptr<CentralEffectSimulation::HandlerBuildingData> &handlerBuildingData)
|
||||
{
|
||||
return std::make_shared<Ces2DInterfaceImpl>(pdp, dDSConnector, settings, ddsHandler, db, handlerParticipant, handlerBuildingData);
|
||||
}
|
||||
|
||||
|
||||
Ces2DInterfaceImpl::Ces2DInterfaceImpl(CentralEffectSimulation::Plugin::DataProvider *pdp,
|
||||
const std::shared_ptr<DDSConnector::DdsConnector> &dDSConnector,
|
||||
NGL::Settings *settings,
|
||||
const std::shared_ptr<CentralEffectSimulation::DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<CentralEffectSimulation::DatabaseInterface> &db,
|
||||
const std::shared_ptr<CentralEffectSimulation::HandlerParticipant> &handlerParticipant,
|
||||
const std::shared_ptr<CentralEffectSimulation::HandlerBuildingData> &handlerBuildingData)
|
||||
: m_pdp(pdp)
|
||||
, m_ddsConnector(dDSConnector)
|
||||
, m_ddsHandler(ddsHandler)
|
||||
, m_db(db)
|
||||
, m_handlerBuildingData(handlerBuildingData)
|
||||
, m_handlerParticipant(handlerParticipant)
|
||||
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("CES.Plugin.CentralEffectSimulation2DInterfaceImpl"))
|
||||
{
|
||||
Q_UNUSED(settings)
|
||||
}
|
||||
|
||||
Ces2DInterfaceImpl::~Ces2DInterfaceImpl()
|
||||
{
|
||||
m_handlerAesData.reset();
|
||||
m_handlerBuildingModel.reset();
|
||||
m_handlerParticipantArea.reset();
|
||||
}
|
||||
|
||||
|
||||
bool Ces2DInterfaceImpl::init(int domainId, int exerciseId)
|
||||
{
|
||||
|
||||
m_domainId = domainId;
|
||||
m_exerciseId = exerciseId;
|
||||
INFO_LOG(m_logger) << "CentralEffectSimulation2DInterfaceImpl::init()"
|
||||
<< " m_domainId=" << m_domainId
|
||||
<< " m_exerciseId=" << m_exerciseId;
|
||||
|
||||
// initialize handlerAesData
|
||||
m_handlerAesData = std::make_shared<HandlerAesData>(m_ddsHandler,
|
||||
m_handlerBuildingData,
|
||||
this);
|
||||
|
||||
if (!m_handlerAesData->init())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Initialisation HandlerAesData failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
INFO_LOG(m_logger) << "initialize HandlerBuildingModel ----------------------------";
|
||||
m_handlerBuildingModel = std::make_shared<HandlerBuildingModel>(m_ddsHandler, m_handlerAesData, this);
|
||||
if (!m_handlerBuildingModel->init())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Initialisation HandlerBuildingModel failed.";
|
||||
return false;
|
||||
} // if
|
||||
|
||||
|
||||
// initialize handlerParticipantArea
|
||||
m_handlerParticipantArea = std::make_shared<HandlerParticipantArea>(m_ddsHandler,
|
||||
m_handlerParticipant,
|
||||
m_handlerAesData,
|
||||
m_handlerBuildingModel,
|
||||
this);
|
||||
|
||||
if (!m_handlerParticipantArea->init())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Initialisation HandlerParticipantArea failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
INFO_LOG(m_logger) << "CentralEffectSimulation2DInterfaceImpl::init() return true";
|
||||
return true;
|
||||
}
|
||||
|
||||
QString Ces2DInterfaceImpl::echo(const QString &message)
|
||||
{
|
||||
|
||||
QString ret(QStringLiteral("<<<< %1 >>>> CentralEffectSimulation2DInterfaceImpl::echo").arg(message));
|
||||
INFO_LOG(m_logger) << "CentralEffectSimulation2DInterfaceImpl::echo return:" << ret;
|
||||
DEBUG_LOG(m_logger) << "DEBUG: CentralEffectSimulation2DInterfaceImpl::echo return:" << ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
} //namespace Ces2D
|
||||
@@ -0,0 +1,86 @@
|
||||
/**
|
||||
* Plugin Ces2D
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Gerlinde Rudolphus, SLTE, 2016-04-14
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "handler_aes_data.h"
|
||||
#include "handler_building_model.h"
|
||||
#include "handler_participant_area.h"
|
||||
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
#include <CentralEffectSimulation/ces_plugin_interface.h>
|
||||
#include <CentralEffectSimulation/dds_handler.h>
|
||||
#include <CentralEffectSimulation/handler_building_data.h>
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
|
||||
#include <QObject>
|
||||
|
||||
|
||||
namespace Ces2D
|
||||
{
|
||||
//using DbHandler = NGLDB::DbServiceHandler<CentralEffectSimulation::DatabaseInterface>;
|
||||
|
||||
class CentralEffectSimulation2DPlugin : public QObject, public CentralEffectSimulation::Plugin::Plugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "special:3:ces.CentralEffectSimulation2DPlugin")
|
||||
Q_INTERFACES(CentralEffectSimulation::Plugin::Plugin)
|
||||
|
||||
public:
|
||||
CentralEffectSimulation2DPlugin() = default;
|
||||
~CentralEffectSimulation2DPlugin() = default;
|
||||
std::shared_ptr<CentralEffectSimulation::Plugin::Interface> createInterface(CentralEffectSimulation::Plugin::DataProvider *pdp,
|
||||
const std::shared_ptr<DDSConnector::DdsConnector> &dDSConnector,
|
||||
NGL::Settings *settings,
|
||||
const std::shared_ptr<CentralEffectSimulation::DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<CentralEffectSimulation::DatabaseInterface> &db,
|
||||
const std::shared_ptr<CentralEffectSimulation::HandlerParticipant> &handlerParticipant,
|
||||
const std::shared_ptr<CentralEffectSimulation::HandlerBuildingData> &handlerBuildingData) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
class Ces2DInterfaceImpl final : public CentralEffectSimulation::Plugin::Interface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Ces2DInterfaceImpl(CentralEffectSimulation::Plugin::DataProvider *pdp,
|
||||
const std::shared_ptr<DDSConnector::DdsConnector> &dDSConnector,
|
||||
NGL::Settings *settings,
|
||||
const std::shared_ptr<CentralEffectSimulation::DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<CentralEffectSimulation::DatabaseInterface> &db,
|
||||
const std::shared_ptr<CentralEffectSimulation::HandlerParticipant> &handlerParticipant,
|
||||
const std::shared_ptr<CentralEffectSimulation::HandlerBuildingData> &handlerBuildingData);
|
||||
~Ces2DInterfaceImpl();
|
||||
//bool init();
|
||||
const char *name() const override { return "CentralEffectSimulation2D"; }
|
||||
QString echo(const QString &message) override;
|
||||
|
||||
private Q_SLOTS:
|
||||
bool init(int domainId, int exerciseId) override;
|
||||
private:
|
||||
|
||||
private:
|
||||
CentralEffectSimulation::Plugin::DataProvider *m_pdp;
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
|
||||
|
||||
std::shared_ptr<CentralEffectSimulation::DdsHandler> m_ddsHandler;
|
||||
std::shared_ptr<CentralEffectSimulation::DatabaseInterface> m_db;
|
||||
std::shared_ptr<HandlerAesData> m_handlerAesData; ///< Pointer to AES Building handler
|
||||
std::shared_ptr<CentralEffectSimulation::HandlerBuildingData> m_handlerBuildingData; ///< Pointer to AES Building handler
|
||||
std::shared_ptr<HandlerBuildingModel> m_handlerBuildingModel; ///< Pointer to Building Model Handler
|
||||
std::shared_ptr<CentralEffectSimulation::HandlerParticipant> m_handlerParticipant; ///< Pointer to handler for all participants
|
||||
std::shared_ptr<HandlerParticipantArea> m_handlerParticipantArea; ///< Pointer to handler for participant outside from Buildings
|
||||
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
int m_domainId = 0;
|
||||
int m_exerciseId = 0;
|
||||
};
|
||||
|
||||
} // namespace Ces2D
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Settings for CentralEffectSimulation
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "settings.h"
|
||||
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtCore/QVariant>
|
||||
#include <nglsettings/nglsettings_settings.h>
|
||||
#include <ngltools/ngltools_filesystem.h>
|
||||
|
||||
namespace Ces2D
|
||||
{
|
||||
class NGLSettingsClass : public NGL::Settings
|
||||
{
|
||||
public:
|
||||
NGLSettingsClass()
|
||||
: NGL::Settings(s_iniFile.isEmpty() ? NGL::findProjectConfigFile() : s_iniFile)
|
||||
{}
|
||||
static void setIniFile(const QString &fn)
|
||||
{
|
||||
s_iniFile = fn;
|
||||
}
|
||||
static QString s_iniFile;
|
||||
};
|
||||
QString NGLSettingsClass::s_iniFile;
|
||||
Q_GLOBAL_STATIC(NGLSettingsClass, s)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
NGL::Settings *Settings::settings()
|
||||
{
|
||||
return s();
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void Settings::setIniFile(const QString &ini)
|
||||
{
|
||||
NGLSettingsClass::setIniFile(ini);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
Settings::CalculateCentralAes Settings::calculateCentralAes()
|
||||
{
|
||||
Settings::CalculateCentralAes value = static_cast<Settings::CalculateCentralAes>(s()->settings()->value(QStringLiteral("CES/calculateCentralAes"), 0).toInt());
|
||||
return value;
|
||||
}
|
||||
|
||||
} // namespace Ces2D
|
||||
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Settings for CentralEffectSimulation
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <QString>
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
class Settings;
|
||||
}
|
||||
|
||||
namespace Ces2D
|
||||
{
|
||||
namespace Settings
|
||||
{
|
||||
enum CalculateCentralAes
|
||||
{
|
||||
NO_AES_CALCUALTION,
|
||||
AES_CALCUALTION,
|
||||
AES_CALCUALTION_ONLY_IN_WLS_AREA
|
||||
};
|
||||
|
||||
NGL::Settings *settings();
|
||||
void setIniFile(const QString &ini);
|
||||
CalculateCentralAes calculateCentralAes();
|
||||
}
|
||||
|
||||
} // namespace Ces2D
|
||||
Reference in new issue
Block a user