/** * @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 #include #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 { public: /** * @brief The EinruestEssentials struct is just there to bundle essentials data * to a single return value */ struct EinruestEssentials { QVector trainingAreas; QVector areas; QVector objects; QVector levels; QVector rooms; QVector mountingPoints; QVector 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 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 &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 relativeToGeographic(const Messages::ReplyMessage::LonLatPoint &pos, const QVector &relPoints); QVector pathForStructureId(int32_t structureElementId) const; QVector 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 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 m_asmDtc; }; // class DataManager } // namespace WebSocketInterface } // namespace InfrastructureManagement