Initial commit

This commit is contained in:
torsten committed 2026-08-13 18:33:10 +02:00
commit b7d90b9afe
16245 files changed
+3396666

No files matched your search

@@ -0,0 +1,171 @@
/**
* @RDE_HEADER@
* The DataManager class is a convenience class for managing structure data
* $Id$
* $HeadURL$
* $Author$
* Created by Hannes Baeuerle, SLSE, 2016-09-12
*/
#pragma once
#include <LtsWebSocket/data_manager_base_dl.h>
#include <InfrastructureManagement/ism_db.h>
#include "WebSocketInterface/Messages/reply_message.h"
#include "Messages/reply_message.h"
#include "logger.h"
namespace AssetManagement
{
namespace Interface
{
class Dtc;
} // namespace Interface
} // namespace AssetManagement
namespace InfrastructureManagement
{
class MainHandler;
class ObjectInstrumentationAsset;
namespace WebSocketInterface
{
namespace Messages
{
class TrainingAreaMessage;
class AreaMessage;
class ObjectMessage;
class LevelMessage;
class RoomMessage;
class MountingPointMessage;
class AssetTypeMessage;
} // namespace Messages
/**
* @brief The DataManager class is a convenience class for managing structure data
*/
class DataManager final : LtsWebSocket::DataManagerBaseDl<DatabaseInterface>
{
public:
/**
* @brief The EinruestEssentials struct is just there to bundle essentials data
* to a single return value
*/
struct EinruestEssentials
{
QVector<Messages::TrainingAreaMessage> trainingAreas;
QVector<Messages::AreaMessage> areas;
QVector<Messages::ObjectMessage> objects;
QVector<Messages::LevelMessage> levels;
QVector<Messages::RoomMessage> rooms;
QVector<Messages::MountingPointMessage> mountingPoints;
QVector<Messages::AssetTypeMessage> assetTypes;
};
/**
* @brief DataManager Constructor
* @param mainHandler Source for needed handlers
*/
explicit DataManager(MainHandler *mainHandler);
/**
* @brief init Initialises a DataManager object
* @return True on sucess, otherwise false
*/
bool init();
/**
* @brief getEssentials Getter for initial data
* @param uuid Identifier of the message to be responded to
* @return Initial data of type EinruestEssentials
*/
EinruestEssentials getEssentials(const QString &uuid) const;
/**
* @brief getPlannedMounting Getter for data needed in response to a getPlannedMounting Message
* @param uuid Identifier of the message to be responded to
* @return All planned mounting messages
*/
QVector<Messages::PlannedMountingMessage> getPlannedMounting(const QString &uuid) const;
/**
* @brief getObjectMounting Getter for a Messages::ObjectMessage
* @param plannedMountingId Id of the schedule
* @param objectId Id of the object/building
* @param uuid Identifier of the message to be responded to
* @return Messages::ObjectMessage if combination of plannedMountingId and objectId exists,
* otherwise Messages::ErrorMessage
*/
LtsWebSocket::ReplyMessage *getObjectMounting(int plannedMountingId, int objectId, const QString &uuid) const;
LtsWebSocket::ReplyMessage *mountTag(const QString &mountingPointTag,
const QString &assetTag,
const QString &messageType,
const QString &uuid) const;
LtsWebSocket::ReplyMessage *mount(int32_t mountingPointId,
int32_t assetId,
const QString &messageType,
const QString &uuid) const;
LtsWebSocket::ReplyMessage *unmountAsset(int32_t assetId,
const QString &messageType,
const QString &uuid) const;
LtsWebSocket::ReplyMessage *unmountMountingPoint(int32_t mountingPointId,
const QString &messageType,
const QString &uuid) const;
LtsWebSocket::ReplyMessage *unmountObject(int32_t objectId,
const QString &messageType,
const QString &uuid) const;
LtsWebSocket::ReplyMessage *unmountArea(int32_t areaId,
const QString &messageType,
const QString &uuid) const;
LtsWebSocket::ReplyMessage *objectMountingReady(int32_t plannedMountingId,
int32_t objectId,
const QString &messageType,
const QString &uuid) const;
LtsWebSocket::ReplyMessage *getAssetState(int32_t assetId,
const QString &assetTag,
const QString &uuid) const;
LtsWebSocket::ReplyMessage *getAssets(const QSet<int> &assetTypeIds,
const QString &uuid) const;
LtsWebSocket::ReplyMessage *getBuildingState(int32_t buildingId,
const QString &uuid) const;
// base DL OC
LtsWebSocket::ReplyMessage *assetBaseData(const QString &uuid) const;
LtsWebSocket::ReplyMessage *mainStructureElementBaseData(const QString &uuid) const;
LtsWebSocket::ReplyMessage *structureElementBaseData(const QString &uuid) const;
LtsWebSocket::ReplyMessage *structureElementFootprintBaseData(const QString &uuid) const;
LtsWebSocket::ReplyMessage *mountingPointAssetBaseData(const QString &uuid) const;
LtsWebSocket::ReplyMessage *mountingPointScheduleBaseData(const QString &uuid) const;
LtsWebSocket::ReplyMessage *mountingPointPlanBaseData(const QString &uuid) const;
private: //methods
static QVector<Messages::ReplyMessage::LonLatPoint> relativeToGeographic(const Messages::ReplyMessage::LonLatPoint &pos,
const QVector<Messages::ReplyMessage::XYPoint> &relPoints);
QVector<Messages::ReplyMessage::XYPoint> pathForStructureId(int32_t structureElementId) const;
QVector<Messages::PlannedMountingMessage::MountingEntry> entriesForScheduleId(int32_t scheduleId) const;
int32_t areaIdForScheduleId(int32_t scheduleId) const;
int32_t stateForBuilding(int32_t buildingId) const;
bool isMounted(int32_t mountingPointId) const;
bool isPlannedObject(int32_t objectId) const;
QVector<Messages::ObjectMountingMessage::PlannedEntry> entriesForBuildingInSchedule(int32_t scheduleId, int32_t buildingId) const;
int32_t getMountedAssetId(int32_t mountingPointId) const;
int32_t mountingPointIdFromBarcode(const QString &barcode) const;
int32_t assetIdFromBarcode(const QString &barcode) const;
Messages::AssetData assetData(int32_t assetId) const;
Messages::AssetData assetData(const ObjectInstrumentationAsset *asset) const;
MountingPointState getMountingPointState(int32_t mountingPointId, int32_t scheduleId) const;
private: // attributes
MainHandler *m_mainHandler;
std::shared_ptr<AssetManagement::Interface::Dtc> m_asmDtc;
}; // class DataManager
} // namespace WebSocketInterface
} // namespace InfrastructureManagement