Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
Executable
+204
@@ -0,0 +1,204 @@
|
||||
/**
|
||||
* Retrieve data from InfrastructeManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-04-14
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <QObject>
|
||||
#include <QMap>
|
||||
#include <QSet>
|
||||
#include <QHash>
|
||||
#include <QVector>
|
||||
|
||||
#include <InfrastructureManagement/ism.hpp>
|
||||
#include <InfrastructureManagement/ism_dtc.h>
|
||||
#include <InfrastructureManagement/ism_ftc.h>
|
||||
|
||||
#include <LtsUtilsCore/data_modification_enum.h>
|
||||
#include <LtsUtilsCore/qpoint3d.h>
|
||||
#include "logger.h"
|
||||
|
||||
class QTimer;
|
||||
namespace Buildings
|
||||
{
|
||||
class MainHandler;
|
||||
|
||||
struct BsmInfo
|
||||
{
|
||||
int assetId = 0; // unique id from asset (database)
|
||||
int bsmId = 0; // unique (per building) id from xml
|
||||
Core::RelativePosition relPosition;
|
||||
Core::Orientation orientation;
|
||||
QString hostname;
|
||||
unsigned short port = 0;
|
||||
|
||||
bool operator ==(const BsmInfo &o) const
|
||||
{
|
||||
return assetId == o.assetId &&
|
||||
bsmId == o.bsmId &&
|
||||
port == o.port &&
|
||||
hostname == o.hostname &&
|
||||
relPosition == o.relPosition &&
|
||||
orientation == o.orientation;
|
||||
}
|
||||
};
|
||||
|
||||
enum EffectType
|
||||
{
|
||||
FOG = 0,
|
||||
FIRE_LAMP = 1,
|
||||
SIGNAL_LAMP = 2
|
||||
};
|
||||
|
||||
//struct Effect
|
||||
//{
|
||||
// QString effectType;
|
||||
// int id = 0; // No of relay
|
||||
// int damage = 0; // damage in percent
|
||||
// int repeat = 0; // number of repetitions
|
||||
// int pulse = 0; // pulse duration [ms]
|
||||
// int delay = 0; // delay duration [ms]
|
||||
|
||||
// bool operator==(const Effect &o) const
|
||||
// {
|
||||
// return effectType == o.effectType &&
|
||||
// id == o.id &&
|
||||
// damage == o.damage &&
|
||||
// repeat == o.repeat &&
|
||||
// pulse == o.pulse &&
|
||||
// delay == o.delay;
|
||||
// }
|
||||
//};
|
||||
|
||||
struct EgcuInfo
|
||||
{
|
||||
QString buildingName;
|
||||
QString mountPointName;
|
||||
int mountPointId = 0;
|
||||
QString assetName;
|
||||
int assetId = 0;
|
||||
QString hostname;
|
||||
QSet<int> roomIds;
|
||||
|
||||
bool operator ==(const EgcuInfo &o) const
|
||||
{
|
||||
return (buildingName == o.buildingName &&
|
||||
mountPointName == o.mountPointName &&
|
||||
mountPointId == o.mountPointId &&
|
||||
hostname == o.hostname &&
|
||||
roomIds == o.roomIds);
|
||||
}
|
||||
};
|
||||
|
||||
struct RoomInfo
|
||||
{
|
||||
QString roomStr;
|
||||
int roomId = 0;
|
||||
};
|
||||
|
||||
struct Egcu
|
||||
{
|
||||
QString mountpointEgcu;
|
||||
int mountpointId = 0;
|
||||
int assetId = 0;
|
||||
QVector<RoomInfo> rooms;
|
||||
};
|
||||
|
||||
struct BuildingInfo
|
||||
{
|
||||
int mseId = 0;
|
||||
int modelId = 0;
|
||||
int externalWlsId = 0;
|
||||
int currentExerciseId = -1;
|
||||
int structureElementId = 0;
|
||||
int assetId = 0;
|
||||
QString name;
|
||||
Core::GeoPosition absPosition; // lonLatZ
|
||||
double angle = 0;
|
||||
|
||||
// QMap<assetId, BsmInfo>
|
||||
QMap<int, BsmInfo> bsms;
|
||||
QVector<EgcuInfo> egcus;
|
||||
QMap<int, int> subId2RoomId;
|
||||
QMap<int, int> roomId2SubId;
|
||||
QMap<QString, int> roomName2RoomId;
|
||||
|
||||
bool operator ==(const BuildingInfo &o) const
|
||||
{
|
||||
return mseId == o.mseId &&
|
||||
modelId == o.modelId &&
|
||||
externalWlsId == o.externalWlsId &&
|
||||
currentExerciseId == o.currentExerciseId &&
|
||||
structureElementId == o.structureElementId &&
|
||||
assetId == o.assetId &&
|
||||
name == o.name &&
|
||||
absPosition == o.absPosition &&
|
||||
qFuzzyCompare(angle, o.angle) &&
|
||||
bsms == o.bsms &&
|
||||
egcus == o.egcus &&
|
||||
subId2RoomId == o.subId2RoomId &&
|
||||
roomId2SubId == o.roomId2SubId &&
|
||||
roomName2RoomId == o.roomName2RoomId;
|
||||
}
|
||||
bool operator !=(const BuildingInfo &o) const
|
||||
{
|
||||
return !operator==(o);
|
||||
}
|
||||
};
|
||||
|
||||
class IsmHandler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit IsmHandler(MainHandler *mainHandler);
|
||||
~IsmHandler();
|
||||
|
||||
bool init();
|
||||
InfrastructureManagement::MainStructureElement mainStructureElement(int id) const;
|
||||
bool isElementAssignedToExercise(const int mseId, int exerciseId);
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Ftc> ftcIsm() const { return m_ftcIsm;}
|
||||
|
||||
Q_SIGNALS:
|
||||
void buildingRemoved(int buildingId);
|
||||
void buildingChanged(const BuildingInfo &buildingInfo, bool percentDamageInit = false);
|
||||
void setEffectStates(const int buildingId, const int assetId, QByteArray &properties);
|
||||
private Q_SLOTS:
|
||||
void onInstrumentationAssetChanged(const InfrastructureManagement::InstrumentationAsset &data, DataModification modType = DataModification::eAdded);
|
||||
void onMountingPointAssetChanged(const InfrastructureManagement::MountingPointAsset &data, DataModification modType = DataModification::eAdded);
|
||||
void onMainStructureElementChanged(const InfrastructureManagement::MainStructureElement &data, DataModification modType = DataModification::eAdded);
|
||||
void onBridgeStatusChanged(const InfrastructureManagement::BridgeChangeStatus &data, DataModification modType = DataModification::eAdded);
|
||||
|
||||
void onBuildingsChanged();
|
||||
void onBuildingsChangedInit();
|
||||
|
||||
private:
|
||||
void handleBuildingSensorModule(const InfrastructureManagement::StructureElement &se, BuildingInfo &bi) const;
|
||||
void handleBuildingControlUnit(const InfrastructureManagement::StructureElement &se, BuildingInfo &bi) const;
|
||||
void handleEffectGenerationControlUnit(const InfrastructureManagement::StructureElement &se, BuildingInfo &bi) const;
|
||||
static unsigned short getBsmPortFromJSon(const std::string &s);
|
||||
void getEgcuToRoom(const InfrastructureManagement::MainStructureElement &mse, QVector<EgcuInfo> &eis);
|
||||
void buildingsChanged(bool init);
|
||||
void checkOverride(const InfrastructureManagement::MainStructureElement &mseOld,
|
||||
const InfrastructureManagement::MainStructureElement &mseNew);
|
||||
|
||||
MainHandler *m_mainHandler;
|
||||
QMap<int, InfrastructureManagement::MainStructureElement> m_mainStructureElements;
|
||||
QMap<int, InfrastructureManagement::InstrumentationAsset> m_instAssets;
|
||||
QMap<int, int> m_assetMainStructureElementInExercise;
|
||||
QMap<int, int> m_structureElementId2AssetId;
|
||||
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_dtcIsm;
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Ftc> m_ftcIsm;
|
||||
|
||||
QMap<int, BuildingInfo> m_currentBuildingConfiguration;
|
||||
QMap<int, QString> m_roomId2RoomName;
|
||||
|
||||
QTimer *m_changeTimeoutTimer;
|
||||
QTimer *m_changeTimeoutTimerInit;
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
|
||||
} // namespace Buildings
|
||||
Reference in new issue
Block a user