Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
Executable
+182
@@ -0,0 +1,182 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
|
||||
INCLUDE(MacroRTIDDSGen)
|
||||
INCLUDE(MacroCodeGenIdl)
|
||||
|
||||
SET(xml_FILE asm_service.xml)
|
||||
|
||||
#
|
||||
# --- Library svcAsmCommon --------------------------------------------------------------------------------
|
||||
#
|
||||
SET(SRCS_common
|
||||
asm_export.h
|
||||
logger.cpp
|
||||
logger.h
|
||||
)
|
||||
|
||||
# Generate asm_enums.idl / asm.idl
|
||||
CODEGEN_IDL_SVC(SRCS_common ${xml_FILE})
|
||||
# Generate asm_db_impl.cpp/.h, asm_db.h
|
||||
CODEGEN_DATABASE(SRCS_common ${xml_FILE})
|
||||
|
||||
# Generate *.cpp/*.hpp from idl
|
||||
RTIDDSGEN(SRCS_common asm_enums.idl)
|
||||
RTIDDSGEN(SRCS_common asm.idl)
|
||||
|
||||
# Generate asm_dt[s,c]_types.h, asm_ft[s,c]_types.h
|
||||
CODEGEN_TOPIC_TYPEDEFS(SRCS_common ${xml_FILE})
|
||||
# generate asm_[d|f]tc.h
|
||||
CODEGEN_CLIENT_TOPICS_IFC(SRCS_common ${xml_FILE})
|
||||
|
||||
NGL_ADD_LIBRARY(AAR SV WS HLA svcAsmCommon SHARED ${SRCS_common})
|
||||
NGL_TARGET_INCLUDE_DIRECTORIES(svcAsmCommon
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||
)
|
||||
NGL_TARGET_LINK_LIBRARIES(svcAsmCommon
|
||||
PRIVATE
|
||||
RTI::nddscpp2
|
||||
PUBLIC
|
||||
Qt5::Core
|
||||
ngldb
|
||||
ddscore
|
||||
NGLLogger
|
||||
)
|
||||
NGL_INSTALL_TARGET(svcAsmCommon)
|
||||
|
||||
#
|
||||
# --- Library svcAsmClient --------------------------------------------------------------------------------
|
||||
#
|
||||
SET(SRCS_client
|
||||
asm_dtc_impl_custom.cpp
|
||||
asm_dtc_impl_custom.h
|
||||
asm_export.h
|
||||
)
|
||||
# generate asm_ftc_impl.[cpp|h]
|
||||
CODEGEN_CLIENT_TOPICS_IMPL(SRCS_client ${xml_FILE})
|
||||
|
||||
NGL_ADD_LIBRARY(WS AAR SV svcAsmClient SHARED ${SRCS_client})
|
||||
NGL_TARGET_INCLUDE_DIRECTORIES(svcAsmClient
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||
)
|
||||
|
||||
NGL_TARGET_LINK_LIBRARIES(svcAsmClient
|
||||
PRIVATE
|
||||
RTI::nddscpp2
|
||||
ddsconnector
|
||||
PUBLIC
|
||||
svcAsmCommon
|
||||
ddsftc
|
||||
)
|
||||
NGL_INSTALL_TARGET(svcAsmClient)
|
||||
|
||||
#
|
||||
# --- Library svcAsmServer --------------------------------------------------------------------------------
|
||||
#
|
||||
SET(SRCS_server
|
||||
asm_export.h
|
||||
convert_db_to_dds.h
|
||||
)
|
||||
# generate asm_[d|f]ts.h, asm_[d|f]ts_impl.[cpp|h]
|
||||
CODEGEN_SERVER_TOPICS(SRCS_server ${xml_FILE})
|
||||
|
||||
NGL_ADD_LIBRARY(WS AAR SV svcAsmServer SHARED ${SRCS_server})
|
||||
NGL_TARGET_INCLUDE_DIRECTORIES(svcAsmServer
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||
)
|
||||
|
||||
NGL_TARGET_LINK_LIBRARIES(svcAsmServer
|
||||
PRIVATE
|
||||
RTI::nddscpp2
|
||||
ddsconnector
|
||||
ddsfts
|
||||
PUBLIC
|
||||
svcAsmCommon
|
||||
ngldb
|
||||
)
|
||||
NGL_INSTALL_TARGET(svcAsmServer)
|
||||
|
||||
#
|
||||
# --- Topic Type Plugin --------------------------------------------------------------
|
||||
#
|
||||
CREATE_TOPIC_TYPE_PLUGIN(${xml_FILE})
|
||||
|
||||
#
|
||||
# --- Executable svcAssetManagement (sASM) -------------------------------------------------
|
||||
#
|
||||
SET(SRCS_exe
|
||||
dds_handler.cpp
|
||||
dds_handler.h
|
||||
handler_asset.cpp
|
||||
handler_asset.h
|
||||
handler_location.cpp
|
||||
handler_location.h
|
||||
handler_training_area.cpp
|
||||
handler_training_area.h
|
||||
handler_workstation_logout.cpp
|
||||
handler_workstation_logout.h
|
||||
handler_relay_info.cpp
|
||||
handler_relay_info.h
|
||||
main.cpp
|
||||
main_handler.cpp
|
||||
main_handler.h
|
||||
object_asset.cpp
|
||||
object_asset.h
|
||||
object_map_description.cpp
|
||||
object_map_description.h
|
||||
object_training_area.cpp
|
||||
object_training_area.h
|
||||
object_relay_info.cpp
|
||||
object_relay_info.h
|
||||
settings.cpp
|
||||
settings.h
|
||||
|
||||
WebSocketInterface/data_manager.cpp
|
||||
WebSocketInterface/data_manager.h
|
||||
WebSocketInterface/json_keys.h
|
||||
WebSocketInterface/websocket_interface_handler.cpp
|
||||
WebSocketInterface/websocket_interface_handler.h
|
||||
WebSocketInterface/Messages/client_message.cpp
|
||||
WebSocketInterface/Messages/client_message.h
|
||||
WebSocketInterface/Messages/reply_message.cpp
|
||||
WebSocketInterface/Messages/reply_message.h
|
||||
|
||||
${xml_FILE}
|
||||
)
|
||||
|
||||
# Generate asm.sql, asm.xml
|
||||
CODEGEN_SQL(SRCS_exe ${xml_FILE})
|
||||
|
||||
NGL_ADD_SVC_ICON(SRCS_exe)
|
||||
NGL_ADD_EXECUTABLE(SV AAR svcAssetManagement ${SRCS_exe})
|
||||
NGL_TARGET_LINK_LIBRARIES(svcAssetManagement
|
||||
Qt5::Core
|
||||
svcAsmCommon
|
||||
svcAsmServer
|
||||
svcCoreClient
|
||||
ddsconnector
|
||||
nglsettings
|
||||
ProjectConfig
|
||||
LtsCommandLineParser
|
||||
LtsWebSocketServer
|
||||
NGLLogger
|
||||
nglcoreapplication
|
||||
ngltools
|
||||
LtsUtilsCore
|
||||
)
|
||||
NGL_INSTALL_TARGET(svcAssetManagement)
|
||||
NGL_INSTALL(AAR SV FILES log4cxx_asm.props DESTINATION bin)
|
||||
NGL_ADD_TARGET_LINK(svcAssetManagement sASM)
|
||||
|
||||
# Uncomment if necessary
|
||||
#ADD_SUBDIRECTORY(UnitTests)
|
||||
ADD_SUBDIRECTORY(ModuleTests)
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
|
||||
SET(SRCS_TEST
|
||||
asm_tests.cpp
|
||||
)
|
||||
SET(HDRS_TEST
|
||||
asm_tests.h
|
||||
)
|
||||
|
||||
IF(BUILD_TESTING)
|
||||
IF(TARGET svcAsmClient)
|
||||
|
||||
# Testing FunctionTopic Functionality (FTC)
|
||||
ADD_EXECUTABLE(asmTests ${SRCS_TEST} ${HDRS_TEST})
|
||||
TARGET_LINK_LIBRARIES(asmTests
|
||||
Qt5::Core
|
||||
Qt5::Test
|
||||
RTI::nddscpp2
|
||||
svcAsmClient
|
||||
LtsCommandLineParser
|
||||
ddsconnector
|
||||
nglcoreapplication
|
||||
)
|
||||
IF(NOT BUILD_RPM)
|
||||
NGL_INSTALL(AAR SV TARGETS asmTests DESTINATION bin/test)
|
||||
NGL_INSTALL(AAR SV FILES ../log4cxx_asm.props DESTINATION bin/test)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
+323
@@ -0,0 +1,323 @@
|
||||
/**
|
||||
* Asm Function Topic Module Test
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "asm_tests.h"
|
||||
|
||||
#include <nglapplication/nglcoreapplication.h>
|
||||
#include <LtsCommandLineParser/LtsCommandLineParser.h>
|
||||
#include <QTimer>
|
||||
#include <QTest>
|
||||
|
||||
#include <AssetManagement/asm_ftc.h>
|
||||
|
||||
/* ----------------------------------------------------------------------------------
|
||||
* HOW TO RUN THE TESTS (example)
|
||||
* ----------------------------------------------------------------------------------
|
||||
* 0. Preconditions:
|
||||
*
|
||||
* ./asmTests -t 1 // Create
|
||||
* ./asmTests -t 2 -a 7 // Modify TraingAreaId = 7
|
||||
* ./asmTests -t 3 -a 7 // Delete TraingAreaId = 7
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
namespace AssetManagement
|
||||
{
|
||||
AsmTests::AsmTests(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_trainingAreaId(0)
|
||||
, m_testId(0)
|
||||
, m_bTestsSuccessful(true)
|
||||
, m_logger(getLogger("Test"))
|
||||
{
|
||||
qRegisterMetaType<Core::FunctionReply>("Core::FunctionReply");
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
AsmTests::~AsmTests()
|
||||
{}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
bool AsmTests::init(int domainId, int trainingAreaId, int testId)
|
||||
{
|
||||
INFO_LOG(m_logger) << "init begin";
|
||||
|
||||
m_testId = testId;
|
||||
m_trainingAreaId = trainingAreaId; // overwritten when new exercise created
|
||||
|
||||
m_ddsConnector.reset(new DDSConnector::DdsConnector(domainId, IDL::PartitionType::Any));
|
||||
if (!m_ddsConnector->init())
|
||||
{
|
||||
failExit();
|
||||
return false;
|
||||
}
|
||||
m_ddsConnector->initPublisherSubscriber();
|
||||
|
||||
DEBUG_LOG(m_logger) << "create ftc";
|
||||
m_ftc = AssetManagement::Interface::Ftc::create(m_ddsConnector);
|
||||
DEBUG_LOG(m_logger) << "init ftc";
|
||||
bool bRet = m_ftc->enableAll();
|
||||
DEBUG_LOG(m_logger) << "init end - bRet = " << bRet;
|
||||
|
||||
DEBUG_LOG(m_logger) << "Domain Id = " << domainId;
|
||||
DEBUG_LOG(m_logger) << "Training Area Id = " << trainingAreaId;
|
||||
DEBUG_LOG(m_logger) << "Test Id = " << testId;
|
||||
|
||||
if (!bRet)
|
||||
failExit();
|
||||
return bRet;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
void AsmTests::startTest()
|
||||
{
|
||||
INFO_LOG(m_logger) << "startTest";
|
||||
if (m_testId == 1)
|
||||
QTimer::singleShot(0, this, &AsmTests::tryCreate);
|
||||
else if (m_testId == 2)
|
||||
QTimer::singleShot(0, this, &AsmTests::tryModify);
|
||||
else if (m_testId == 3)
|
||||
QTimer::singleShot(0, this, &AsmTests::tryDelete);
|
||||
else
|
||||
failExit();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
void AsmTests::setRequestData(AssetManagement::TrainingAreaModifyRequest &request , int modId)
|
||||
{
|
||||
AssetManagement::MapDescription mapDescription;
|
||||
std::vector<uint8_t> imageVector(0);
|
||||
std::vector<AssetManagement::MapDescription> map2D_param;
|
||||
std::vector<AssetManagement::MapDescription> scene3D_param;
|
||||
std::vector<AssetManagement::MapDescription> elevation_param;
|
||||
std::vector<AssetManagement::MapDescription> sceneObjects_param;
|
||||
|
||||
mapDescription.name("Topographic 01");
|
||||
mapDescription.description("Description_01");
|
||||
mapDescription.isDeleted(false);
|
||||
mapDescription.mapTypeId(AssetManagement::MapType_def::Topographic);
|
||||
mapDescription.mapDescriptionTypeId(AssetManagement::MapDescriptionType::Map2D);
|
||||
mapDescription.maxScale(20.0);
|
||||
mapDescription.minScale(0.5);
|
||||
if (modId > 0)
|
||||
{
|
||||
mapDescription.trainingAreaId(modId);
|
||||
mapDescription.url("URL1 modified");
|
||||
}
|
||||
else
|
||||
mapDescription.url("URL1 initial");
|
||||
|
||||
map2D_param.resize(2);
|
||||
map2D_param[0] = mapDescription;
|
||||
|
||||
mapDescription.name("Topographic 02");
|
||||
mapDescription.description("Description_02");
|
||||
if (modId > 0)
|
||||
{
|
||||
mapDescription.trainingAreaId(modId);
|
||||
mapDescription.url("URL2 modified");
|
||||
}
|
||||
else
|
||||
mapDescription.url("URL2 initial");
|
||||
|
||||
map2D_param[1] = mapDescription;
|
||||
request.map2D(map2D_param);
|
||||
|
||||
scene3D_param.resize(1);
|
||||
mapDescription.mapTypeId(AssetManagement::MapType_def::Topographic);
|
||||
mapDescription.mapDescriptionTypeId(AssetManagement::MapDescriptionType::Scene3D);
|
||||
mapDescription.description("Description_03");
|
||||
mapDescription.name("Scene3D");
|
||||
if (modId > 0)
|
||||
{
|
||||
mapDescription.trainingAreaId(modId);
|
||||
mapDescription.url("URL3 modified");
|
||||
}
|
||||
else
|
||||
mapDescription.url("URL3 initial");
|
||||
scene3D_param[0] = mapDescription;
|
||||
request.scene3D(scene3D_param);
|
||||
|
||||
if (modId == 0)
|
||||
{
|
||||
elevation_param.resize(1);
|
||||
mapDescription.mapTypeId(AssetManagement::MapType_def::Elevation);
|
||||
mapDescription.mapDescriptionTypeId(AssetManagement::MapDescriptionType::Elevation);
|
||||
mapDescription.url("URL4 initial");
|
||||
mapDescription.description("Description_04");
|
||||
mapDescription.name("Elevation");
|
||||
elevation_param[0] = mapDescription;
|
||||
request.elevation(elevation_param);
|
||||
|
||||
sceneObjects_param.resize(1);
|
||||
mapDescription.mapTypeId(AssetManagement::MapType_def::SceneObjects);
|
||||
mapDescription.mapDescriptionTypeId(AssetManagement::MapDescriptionType::SceneObj);
|
||||
mapDescription.url("URL5 initial");
|
||||
mapDescription.description("Description_05");
|
||||
mapDescription.name("SceneObjects");
|
||||
sceneObjects_param[0] = mapDescription;
|
||||
request.sceneObjects(sceneObjects_param);
|
||||
|
||||
request.id(0);
|
||||
request.name("TestTrainingAreaCreate");
|
||||
request.bottomLeft(Core::GeoPosition2D(11.61/180*M_PI, 53.07/180*M_PI));
|
||||
request.height(100000);
|
||||
request.width(100000);
|
||||
request.image(imageVector);
|
||||
}
|
||||
else
|
||||
{
|
||||
request.id(m_trainingAreaId);
|
||||
request.name("TestTrainingAreaModified");
|
||||
request.bottomLeft(Core::GeoPosition2D(11.61/180*M_PI, 53.07/180*M_PI));
|
||||
request.height(140000);
|
||||
request.width(120000);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
void AsmTests::tryCreate()
|
||||
{
|
||||
INFO_LOG(m_logger) << "trying to send ModifyRequest TrainingArea (create)";
|
||||
|
||||
AssetManagement::TrainingAreaModifyRequest request;
|
||||
|
||||
setRequestData(request, 0);
|
||||
|
||||
if (!m_ftc->trainingAreaModifyRequest(request, this))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting create data";
|
||||
failExit();
|
||||
}
|
||||
|
||||
QTest::qWait(1000);
|
||||
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
void AsmTests::tryModify()
|
||||
{
|
||||
AssetManagement::TrainingAreaModifyRequest request;
|
||||
INFO_LOG(m_logger) << "trying to send modify request for training Area Id = " << m_trainingAreaId;
|
||||
|
||||
setRequestData(request, m_trainingAreaId);
|
||||
|
||||
if (!m_ftc->trainingAreaModifyRequest(request, this))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting modify data";
|
||||
failExit();
|
||||
}
|
||||
|
||||
QTest::qWait(1000);
|
||||
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
void AsmTests::tryDelete()
|
||||
{
|
||||
INFO_LOG(m_logger) << "trying to send delete request for exercise Id = " << m_trainingAreaId;
|
||||
if (!m_ftc->trainingAreaRemoveRequest(TrainingAreaRemoveRequest(m_trainingAreaId), this))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting delete data";
|
||||
failExit();
|
||||
}
|
||||
|
||||
QTest::qWait(1000);
|
||||
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
void AsmTests::onTrainingAreaModifyReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
INFO_LOG(m_logger) << "Got modifyReply with id " << replyObject.id()
|
||||
<< " and errorString " << replyObject.translated();
|
||||
|
||||
if (replyObject.error())
|
||||
failExit();
|
||||
|
||||
m_trainingAreaId = replyObject.id();
|
||||
|
||||
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
void AsmTests::onTrainingAreaRemoveReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
INFO_LOG(m_logger) << "Got removeReply with id " << replyObject.id()
|
||||
<< " and errorString " << replyObject.translated();
|
||||
|
||||
if (replyObject.error())
|
||||
failExit();
|
||||
|
||||
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
void AsmTests::failExit()
|
||||
{
|
||||
m_bTestsSuccessful = false;
|
||||
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
||||
}
|
||||
|
||||
} //end namespace
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
class CmdLineParser : public LtsCommandLineParser::LtsCommandLineParser
|
||||
{
|
||||
public:
|
||||
CmdLineParser()
|
||||
: LtsCommandLineParser()
|
||||
{
|
||||
addOption( { QStringList() << QLatin1String("t") << QLatin1String("testId")
|
||||
, QLatin1String("TestId.")
|
||||
, QLatin1String("Default: 0 (all tests)")
|
||||
, QLatin1String("0")
|
||||
} );
|
||||
|
||||
addOption( { QStringList() << QLatin1String("a") << QLatin1String("trainingAreaId")
|
||||
, QLatin1String("TrainingAreaId.")
|
||||
, QLatin1String("Default: 0 (Unknown)")
|
||||
, QLatin1String("0")
|
||||
} );
|
||||
}
|
||||
|
||||
int testId() const { return isSet(QLatin1String("t")) ? value(QLatin1String("t")).toInt() : 0; }
|
||||
int trainingAreaId() const { return isSet(QLatin1String("a")) ? value(QLatin1String("a")).toInt() : 0; }
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
NGLCoreApplication app(argc, argv);
|
||||
app.createLogger("ASM", 0 );
|
||||
|
||||
int iRet = -1;
|
||||
CmdLineParser options;
|
||||
if (!options.init())
|
||||
return iRet;
|
||||
|
||||
std::unique_ptr<AssetManagement::AsmTests> AsmTests(new AssetManagement::AsmTests);
|
||||
|
||||
if(!AsmTests->init(options.domainId(), options.trainingAreaId(), options.testId()))
|
||||
return iRet;
|
||||
|
||||
QTimer::singleShot(0, AsmTests.get(), &AssetManagement::AsmTests::startTest);
|
||||
|
||||
STARTUP_LOG(app.baseLogger());
|
||||
|
||||
app.exec();
|
||||
|
||||
iRet = AsmTests->testsSuccessful() ? 0 : 1;
|
||||
fprintf(stderr, "%d\n", iRet);
|
||||
|
||||
DEBUG_LOG(app.baseLogger()) << "** TEST result = " << iRet;
|
||||
|
||||
SHUTDOWN_LOG(app.baseLogger());
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
Parameters, Comment
|
||||
-t 1, 1. Create Training Area (id=2)
|
||||
-t 2 -a 2, 2. Modify Training Area (id=2)
|
||||
-t 3 -a 2, 3. Delete Training Area (id=2)
|
||||
|
+52
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* ModuleTests for ASM
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AssetManagement/asm_ftc.h>
|
||||
#include <AssetManagement/asm_ftc_types.h>
|
||||
#include <AssetManagement/logger.h>
|
||||
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
#include <QObject>
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
class AsmTests : public QObject
|
||||
, protected AssetManagement::Interface::Ftc::TrainingAreaModifyReplyHandler
|
||||
, protected AssetManagement::Interface::Ftc::TrainingAreaRemoveReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AsmTests(QObject *parent = nullptr);
|
||||
~AsmTests();
|
||||
|
||||
bool init(int domainId, int trainingAreaId, int testId);
|
||||
bool testsSuccessful() const { return m_bTestsSuccessful; }
|
||||
|
||||
public Q_SLOTS:
|
||||
void startTest();
|
||||
protected Q_SLOTS:
|
||||
void setRequestData(AssetManagement::TrainingAreaModifyRequest &request, int modId);
|
||||
void tryCreate();
|
||||
void tryModify();
|
||||
void tryDelete();
|
||||
protected:
|
||||
void onTrainingAreaModifyReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
void onTrainingAreaRemoveReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
void failExit();
|
||||
private:
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
|
||||
std::shared_ptr<AssetManagement::Interface::Ftc> m_ftc;
|
||||
qint32 m_trainingAreaId;
|
||||
int m_testId;
|
||||
bool m_bTestsSuccessful;
|
||||
LOGGER_T m_logger;
|
||||
|
||||
};
|
||||
|
||||
} // namespace AssetManagement
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The ClientMessage class is an abstract base class for concrete ClientMessage objects
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLST, 2017-12-05
|
||||
*/
|
||||
#include "client_message.h"
|
||||
|
||||
#include "WebSocketInterface/Messages/reply_message.h"
|
||||
#include "WebSocketInterface/json_keys.h"
|
||||
#include "WebSocketInterface/data_manager.h"
|
||||
|
||||
#include <QtCore/QJsonDocument>
|
||||
#include <QtCore/QUuid>
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
namespace WebSocketInterface
|
||||
{
|
||||
namespace ClientMessages
|
||||
{
|
||||
using namespace JsonKeys;
|
||||
|
||||
// ####### ClientMessageFactory begin #######
|
||||
ClientMessageFactory::ClientMessageFactory(DataManager *dataManager)
|
||||
: LtsWebSocket::AbstractClientMessageFactory(getLogger("ClientMessageFactory"))
|
||||
, m_dataManager(dataManager)
|
||||
{}
|
||||
|
||||
LtsWebSocket::AbstractClientMessage *ClientMessageFactory::createMessage(LtsWebSocket::ReplyHandler *client,
|
||||
const QString &message)
|
||||
{
|
||||
LtsWebSocket::AbstractClientMessage *result = checkAttributes(client, message);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
if (m_type == OcBaseDownload::WebSocketInterface::JsonKeys::BASE_DL_REQUEST())
|
||||
result = new BaseDlRequest(m_dataManager, client, m_type, m_typeId, m_uuid);
|
||||
|
||||
return checkResult(client, message, result);
|
||||
}
|
||||
// ####### ClientMessageFactory end #######
|
||||
|
||||
// ####### ClientMessage begin #######
|
||||
ClientMessage::ClientMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data)
|
||||
: LtsWebSocket::AbstractClientMessage(client, type, typeId, uuid, data)
|
||||
, m_dataManager(dataManager)
|
||||
, m_logger(getLogger("ClientMessage"))
|
||||
{}
|
||||
// ####### ClientMessage end #######
|
||||
|
||||
// ####### BaseDlRequest begin #######
|
||||
BaseDlRequest::BaseDlRequest(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid)
|
||||
: ClientMessage(dataManager, client, type, typeId, uuid)
|
||||
{}
|
||||
|
||||
void BaseDlRequest::process()
|
||||
{
|
||||
m_client->addReply(m_dataManager->trainingAreaBaseData(m_uuid));
|
||||
m_client->addReply(m_dataManager->technicalAreaBaseData(m_uuid));
|
||||
//m_client->addReply(m_dataManager->mapDescriptionBaseData(m_uuid));
|
||||
m_client->addReply(m_dataManager->locationBaseData(m_uuid));
|
||||
m_client->addReply(m_dataManager->assetBaseData(m_uuid));
|
||||
}
|
||||
|
||||
bool BaseDlRequest::hasValidData() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// ####### BaseDlRequest end #######
|
||||
|
||||
} // namespace ClientMessages
|
||||
} // namespace WebSocketInterface
|
||||
} // namespace AssetManagement
|
||||
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The ClientMessage class is an abstract base class for concrete ClientMessage objects
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLST, 2017-12-05
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/QJsonObject>
|
||||
|
||||
#include <LtsWebSocket/client_message_factory.h>
|
||||
#include <LtsWebSocket/client_message.h>
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
namespace WebSocketInterface
|
||||
{
|
||||
class DataManager;
|
||||
|
||||
namespace ClientMessages
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief The ClientMessageFactory class creates ClientMessages which will then be processed
|
||||
*/
|
||||
class ClientMessageFactory final : public LtsWebSocket::AbstractClientMessageFactory
|
||||
{
|
||||
public:
|
||||
explicit ClientMessageFactory(DataManager *dataManager);
|
||||
|
||||
/**
|
||||
* @brief create Only way to create a ClientMessage object
|
||||
* @param message Text message which will be converted to a ClientMessage object
|
||||
* @return A ClientMessage object, which represents a concrete ClientMessage
|
||||
*/
|
||||
LtsWebSocket::AbstractClientMessage *createMessage(LtsWebSocket::ReplyHandler *client,
|
||||
const QString &message);
|
||||
|
||||
private:
|
||||
DataManager *m_dataManager;
|
||||
|
||||
}; // class ClientMessageFactory
|
||||
|
||||
/**
|
||||
* @brief The ClientMessage class is an abstract base class for concrete ClientMessage objects
|
||||
*/
|
||||
class ClientMessage : public LtsWebSocket::AbstractClientMessage
|
||||
{
|
||||
protected: // method
|
||||
explicit ClientMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data = QJsonValue());
|
||||
|
||||
protected: // attributes
|
||||
DataManager *m_dataManager;
|
||||
LOGGER_T m_logger;
|
||||
}; // class ClientMessage
|
||||
|
||||
/**
|
||||
* @brief The BaseDlRequest class handles the base DL request and sends multiple replys depending on the data requested
|
||||
*/
|
||||
class BaseDlRequest : public ClientMessage
|
||||
{
|
||||
public:
|
||||
explicit BaseDlRequest(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid);
|
||||
|
||||
void process();
|
||||
bool hasValidData() const;
|
||||
}; // class BaseDlRequest
|
||||
|
||||
} // namespace ClientMessages
|
||||
} // namespace WebSocketInterface
|
||||
} // namespace AssetManagement
|
||||
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The ReplyMessage class is an abstract base class for all possible messages which are sent to the client
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLST, 2017-12-05
|
||||
*/
|
||||
#include "reply_message.h"
|
||||
|
||||
#include <LtsWebSocket/json_keys.h>
|
||||
#include "WebSocketInterface/json_keys.h"
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
namespace WebSocketInterface
|
||||
{
|
||||
namespace ReplyMessages
|
||||
{
|
||||
using namespace JsonKeys;
|
||||
using namespace LtsWebSocket::JsonKeys;
|
||||
|
||||
|
||||
// ####### TrainingAreaBaseData begin #######
|
||||
TrainingAreaBaseData::TrainingAreaBaseData(const QJsonArray &data, const QString &uuid)
|
||||
: LtsWebSocket::ReplyMessage (TRAINING_AREA_BASE_DATA(), 1, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation.insert(DATA(), data);
|
||||
}
|
||||
// ####### TrainingAreaBaseData end #######
|
||||
|
||||
// ####### TechnicalAreaBaseData begin #######
|
||||
TechnicalAreaBaseData::TechnicalAreaBaseData(const QJsonArray &data, const QString &uuid)
|
||||
: LtsWebSocket::ReplyMessage (TECHNICAL_AREA_BASE_DATA(), 2, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation.insert(DATA(), data);
|
||||
}
|
||||
// ####### TechnicalAreaBaseData end #######
|
||||
|
||||
// ####### MapDescriptionBaseData begin #######
|
||||
MapDescriptionBaseData::MapDescriptionBaseData(const QJsonArray &data, const QString &uuid)
|
||||
: LtsWebSocket::ReplyMessage (MAP_DESCRIPTION_BASE_DATA(), 3, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation.insert(DATA(), data);
|
||||
}
|
||||
// ####### MapDescriptionBaseData end #######
|
||||
|
||||
// ####### LocationBaseData begin #######
|
||||
LocationBaseData::LocationBaseData(const QJsonArray &data, const QString &uuid)
|
||||
: LtsWebSocket::ReplyMessage (LOCATION_BASE_DATA(), 4, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation.insert(DATA(), data);
|
||||
}
|
||||
// ####### LocationBaseData end #######
|
||||
|
||||
// ####### AssetBaseData begin #######
|
||||
AssetBaseData::AssetBaseData(const QJsonArray &data, const QString &uuid)
|
||||
: LtsWebSocket::ReplyMessage (ASM_ASSET_BASE_DATA(), 5, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation.insert(DATA(), data);
|
||||
}
|
||||
// ####### AssetBaseData end #######
|
||||
|
||||
} // namespace ReplyMessages
|
||||
} // namespace WebSocketInterface
|
||||
} // namespace AssetManagement
|
||||
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The ReplyMessage class is an abstract base class for all possible messages which are sent to the client
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLST, 2017-12-05
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <LtsWebSocket/reply_message.h>
|
||||
|
||||
#include <QJsonArray>
|
||||
#include <QString>
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
namespace WebSocketInterface
|
||||
{
|
||||
namespace ReplyMessages
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief The TrainingAreaBaseData class training area data for base DL
|
||||
*/
|
||||
class TrainingAreaBaseData : public LtsWebSocket::ReplyMessage
|
||||
{
|
||||
public:
|
||||
explicit TrainingAreaBaseData(const QJsonArray &data, const QString &uuid);
|
||||
}; // class TrainingAreaBaseData
|
||||
|
||||
/**
|
||||
* @brief The TechnicalAreaBaseData class technical area data for base DL
|
||||
*/
|
||||
class TechnicalAreaBaseData : public LtsWebSocket::ReplyMessage
|
||||
{
|
||||
public:
|
||||
explicit TechnicalAreaBaseData(const QJsonArray &data, const QString &uuid);
|
||||
}; // class TechnicalAreaBaseData
|
||||
|
||||
/**
|
||||
* @brief The MapDescriptionBaseData class map description data for base DL
|
||||
*/
|
||||
class MapDescriptionBaseData : public LtsWebSocket::ReplyMessage
|
||||
{
|
||||
public:
|
||||
explicit MapDescriptionBaseData(const QJsonArray &data, const QString &uuid);
|
||||
}; // class MapDescriptionBaseData
|
||||
|
||||
/**
|
||||
* @brief The LocationBaseData class location data for base DL
|
||||
*/
|
||||
class LocationBaseData : public LtsWebSocket::ReplyMessage
|
||||
{
|
||||
public:
|
||||
explicit LocationBaseData(const QJsonArray &data, const QString &uuid);
|
||||
}; // class LocationBaseData
|
||||
|
||||
/**
|
||||
* @brief The AssetBaseData class asset data for base DL
|
||||
*/
|
||||
class AssetBaseData : public LtsWebSocket::ReplyMessage
|
||||
{
|
||||
public:
|
||||
explicit AssetBaseData(const QJsonArray &data, const QString &uuid);
|
||||
}; // class AssetBaseData
|
||||
|
||||
} // namespace ReplyMessages
|
||||
} // namespace WebSocketInterface
|
||||
} // namespace AssetManagement
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The DataManager class handles data to be send to the websocket
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLST, 2017-12-05
|
||||
*/
|
||||
#include "data_manager.h"
|
||||
#include "Messages/reply_message.h"
|
||||
#include "main_handler.h"
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
namespace WebSocketInterface
|
||||
{
|
||||
//---------------------------------------------------------------------------------------------------------
|
||||
DataManager::DataManager(MainHandler *mainHandler)
|
||||
: LtsWebSocket::DataManagerBaseDl<DatabaseInterface>(mainHandler->db(), getLogger("DataManager"))
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------
|
||||
LtsWebSocket::ReplyMessage *DataManager::trainingAreaBaseData(const QString &uuid) const
|
||||
{
|
||||
return toBaseDataMessageFromDb<Database::AsmTrainingArea, ReplyMessages::TrainingAreaBaseData>(uuid);
|
||||
}
|
||||
|
||||
LtsWebSocket::ReplyMessage *DataManager::technicalAreaBaseData(const QString &uuid) const
|
||||
{
|
||||
return toBaseDataMessageFromDb<Database::AsmTechnicalArea, ReplyMessages::TechnicalAreaBaseData>(uuid);
|
||||
}
|
||||
|
||||
LtsWebSocket::ReplyMessage *DataManager::mapDescriptionBaseData(const QString &uuid) const
|
||||
{
|
||||
return toBaseDataMessageFromDb<Database::AsmMapDescription, ReplyMessages::MapDescriptionBaseData>(uuid);
|
||||
}
|
||||
|
||||
LtsWebSocket::ReplyMessage *DataManager::locationBaseData(const QString &uuid) const
|
||||
{
|
||||
return toBaseDataMessageFromDb<Database::AsmLocation, ReplyMessages::LocationBaseData>(uuid);
|
||||
}
|
||||
|
||||
LtsWebSocket::ReplyMessage *DataManager::assetBaseData(const QString &uuid) const
|
||||
{
|
||||
return toBaseDataMessageFromDb<Database::AsmAsset, ReplyMessages::AssetBaseData>(uuid);
|
||||
}
|
||||
|
||||
} // namespace WebSocketInterface
|
||||
} // namespace AssetManagement
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The DataManager class handles data to be send to the websocket
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLST, 2017-12-05
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <LtsWebSocket/data_manager_base_dl.h>
|
||||
#include <AssetManagement/asm_db.h>
|
||||
#include "logger.h"
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
class MainHandler;
|
||||
|
||||
namespace WebSocketInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief The DataManager class is a convenience class for managing base DL data
|
||||
*/
|
||||
class DataManager final : public LtsWebSocket::DataManagerBaseDl<DatabaseInterface>
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief DataManager Constructor
|
||||
* @param mainHandler Source for needed handlers
|
||||
*/
|
||||
explicit DataManager(MainHandler *mainHandler);
|
||||
|
||||
LtsWebSocket::ReplyMessage *trainingAreaBaseData(const QString &uuid) const;
|
||||
LtsWebSocket::ReplyMessage *technicalAreaBaseData(const QString &uuid) const;
|
||||
LtsWebSocket::ReplyMessage *mapDescriptionBaseData(const QString &uuid) const;
|
||||
LtsWebSocket::ReplyMessage *locationBaseData(const QString &uuid) const;
|
||||
LtsWebSocket::ReplyMessage *assetBaseData(const QString &uuid) const;
|
||||
}; // class DataManager
|
||||
|
||||
} // namespace WebSocketInterface
|
||||
} // namespace AssetManagement
|
||||
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Header file which holds all occuring JSON keys
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLST, 2017-12-05
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include <OcBaseDownload/WebSocketInterface/json_keys.h>
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
namespace WebSocketInterface
|
||||
{
|
||||
/**
|
||||
* @brief Namespace which holds all occuring JSON keys as const QString objects
|
||||
*/
|
||||
namespace JsonKeys
|
||||
{
|
||||
// types for client --> server messages
|
||||
|
||||
// types for server --> client messages
|
||||
inline QString TRAINING_AREA_BASE_DATA() { return QStringLiteral("trainingAreaBaseData"); }
|
||||
inline QString TECHNICAL_AREA_BASE_DATA() { return QStringLiteral("technicalAreaBaseData"); }
|
||||
inline QString MAP_DESCRIPTION_BASE_DATA() { return QStringLiteral("mapDescriptionBaseData"); }
|
||||
inline QString LOCATION_BASE_DATA() { return QStringLiteral("locationBaseData"); }
|
||||
inline QString ASM_ASSET_BASE_DATA() { return QStringLiteral("asmAssetBaseData"); }
|
||||
|
||||
// data keys
|
||||
|
||||
} // namespace JsonKeys
|
||||
} // namespace WebSocketInterface
|
||||
} // namespace AssetManagement
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Handler for the WebSocket Interface
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLST, 2017-12-05
|
||||
*/
|
||||
#include "websocket_interface_handler.h"
|
||||
|
||||
#include "main_handler.h"
|
||||
#include "data_manager.h"
|
||||
#include "WebSocketInterface/Messages/client_message.h"
|
||||
#include "settings.h"
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
namespace WebSocketInterface
|
||||
{
|
||||
|
||||
WebSocketInterfaceHandler::WebSocketInterfaceHandler(MainHandler *mainHandler, QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_webSocketServer(nullptr)
|
||||
, m_messageFactory(nullptr)
|
||||
, m_dataManager(nullptr)
|
||||
, m_mainHandler(mainHandler)
|
||||
, m_logger(getLogger("WebSocketInterfaceHandler"))
|
||||
{
|
||||
}
|
||||
|
||||
WebSocketInterfaceHandler::~WebSocketInterfaceHandler()
|
||||
{
|
||||
cleanup();
|
||||
}
|
||||
|
||||
bool WebSocketInterfaceHandler::init()
|
||||
{
|
||||
cleanup();
|
||||
|
||||
DEBUG_LOG(m_logger) << "... ok";
|
||||
|
||||
m_dataManager = new DataManager(m_mainHandler);
|
||||
|
||||
m_messageFactory = new ClientMessages::ClientMessageFactory(m_dataManager);
|
||||
|
||||
m_webSocketServer = new LtsWebSocket::LtsWebSocketServer(m_messageFactory, this);
|
||||
|
||||
DEBUG_LOG(m_logger) << "Initialising LtsWebSocketServer";
|
||||
if (!m_webSocketServer->init(QStringLiteral("ASM"), Settings::getWebSocketServerPortRange(1)))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Failed to initialise LtsWebSocketServer";
|
||||
return false;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "... ok";
|
||||
|
||||
DEBUG_LOG(m_logger) << "Connection signals and slots";
|
||||
DEBUG_LOG(m_logger) << "... ok";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void WebSocketInterfaceHandler::cleanup()
|
||||
{
|
||||
delete m_webSocketServer;
|
||||
delete m_messageFactory;
|
||||
delete m_dataManager;
|
||||
}
|
||||
|
||||
} // namespace WebSocketInterface
|
||||
} // namespace AssetManagement
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Handler for the WebSocket Interface
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLST, 2017-12-05
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
#include <LtsWebSocket/lts_web_socket_server.h>
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
class MainHandler;
|
||||
namespace WebSocketInterface
|
||||
{
|
||||
namespace ClientMessages
|
||||
{
|
||||
class ClientMessageFactory;
|
||||
}
|
||||
class DataManager;
|
||||
|
||||
/**
|
||||
* @brief The WebSocketInterfaceHandler class is the main class for the WebSocketInterface
|
||||
*/
|
||||
class WebSocketInterfaceHandler final : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* @brief WebSocketInterfaceHandler Constructor
|
||||
* @param mainHandler MainHandler to get the HandlerStructureElement from
|
||||
*/
|
||||
explicit WebSocketInterfaceHandler(MainHandler *mainHandler, QObject *parent = nullptr);
|
||||
|
||||
/**
|
||||
* @brief ~WebSocketInterfaceHandler Destructor
|
||||
*/
|
||||
~WebSocketInterfaceHandler();
|
||||
|
||||
/**
|
||||
* @brief init Initialises all needed classes for the WebSocketInterface
|
||||
* @return True on success, otherwise false
|
||||
*/
|
||||
bool init();
|
||||
|
||||
/**
|
||||
* @brief webSocketPort returns the listen port
|
||||
* @return listen port
|
||||
*/
|
||||
unsigned short serverWebSocketPort() { return m_webSocketServer->webSocketPort(); }
|
||||
|
||||
private:
|
||||
void cleanup();
|
||||
|
||||
private:
|
||||
LtsWebSocket::LtsWebSocketServer *m_webSocketServer;
|
||||
ClientMessages::ClientMessageFactory *m_messageFactory;
|
||||
DataManager *m_dataManager;
|
||||
MainHandler *m_mainHandler;
|
||||
LOGGER_T m_logger;
|
||||
}; // class WebSocketInterfaceHandle
|
||||
|
||||
} // namespace WebSocketInterface
|
||||
} // namespace AssetManagement
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Custom asm dtc functions (extends asm_dtc_impl.cpp/.h)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Iuliana Ojog, 2022-04-25
|
||||
*/
|
||||
|
||||
#include "asm_dtc_impl_custom.h"
|
||||
#include <DDS/DTC/generic_dtc.h>
|
||||
#include <DDS/Generic/generic_data_reader.h>
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
DtcImplCustom::DtcImplCustom(const std::shared_ptr<DDSConnector::DdsConnector> &ddsConnector)
|
||||
: DtcImpl(ddsConnector)
|
||||
{
|
||||
}
|
||||
|
||||
bool DtcImplCustom::isAARWorkstation(const QString &wsName)
|
||||
{
|
||||
if (!isAssetEnabled())
|
||||
{
|
||||
enableAsset();
|
||||
waitForHistoricalDataAsset(4000);
|
||||
}
|
||||
|
||||
int wsId = -1;
|
||||
for (const auto &at : m_dtcAsset->readAlive())
|
||||
{
|
||||
if (at.data().assetTypeId() == AssetManagement::AssetType::MobileAfterActionVehicle &&
|
||||
QString::fromStdString(at.data().name()).toUpper() == wsName.toUpper())
|
||||
{
|
||||
wsId = at.data().id();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (wsId > 0);
|
||||
}
|
||||
|
||||
int DtcImplCustom::getAssetId(const QString &wsName)
|
||||
{
|
||||
if (!isAssetEnabled())
|
||||
{
|
||||
enableAsset();
|
||||
waitForHistoricalDataAsset(4000);
|
||||
}
|
||||
|
||||
int wsId = -1;
|
||||
for (const auto &at : m_dtcAsset->readAlive())
|
||||
{
|
||||
if ( QString::fromStdString(at.data().name()).toUpper() == wsName.toUpper())
|
||||
{
|
||||
wsId = at.data().id();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (wsId);
|
||||
}
|
||||
|
||||
|
||||
}//Interface
|
||||
}//namespace AssetManagement
|
||||
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Custom ASM dtc functions (extends asm_dtc_impl.cpp/.h)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Iuliana Ojog, 2022-04-25
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <AssetManagement/asm_dtc_impl.h>
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------
|
||||
namespace AssetManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class DtcImplCustom final : public Interface::DtcImpl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DtcImplCustom(const std::shared_ptr<DDSConnector::DdsConnector> &ddsConnector);
|
||||
bool isAARWorkstation(const QString &wsName) override;
|
||||
int getAssetId (const QString &wsName) override;
|
||||
};
|
||||
} //Interface
|
||||
} // namespace AssetManagement
|
||||
|
||||
Executable
+52
@@ -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 ASM_COMMON_EXPORT
|
||||
# ifdef BUILD_STATIC_LIBRARIES
|
||||
# define ASM_COMMON_EXPORT
|
||||
# else
|
||||
# if defined(MAKE_SVCASMCOMMON_LIB)
|
||||
# define ASM_COMMON_EXPORT Q_DECL_EXPORT
|
||||
# ifndef WIN32
|
||||
# ifdef NDDSUSERDllExport
|
||||
# undef NDDSUSERDllExport
|
||||
# endif
|
||||
# define NDDSUSERDllExport Q_DECL_EXPORT
|
||||
# endif
|
||||
# else
|
||||
# define ASM_COMMON_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef ASM_CLIENT_EXPORT
|
||||
# ifdef BUILD_STATIC_LIBRARIES
|
||||
# define ASM_CLIENT_EXPORT
|
||||
# else
|
||||
# if defined(MAKE_SVCASMCLIENT_LIB)
|
||||
# define ASM_CLIENT_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
# define ASM_CLIENT_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef ASM_SERVER_EXPORT
|
||||
# ifdef BUILD_STATIC_LIBRARIES
|
||||
# define ASM_SERVER_EXPORT
|
||||
# else
|
||||
# if defined(MAKE_SVCASMSERVER_LIB)
|
||||
# define ASM_SERVER_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
# define ASM_SERVER_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
Executable
+244
@@ -0,0 +1,244 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<service namespace="AssetManagement" abbreviation="ASM" procNames="AssetManagement" exerciseDependency="Global" groups="Core" prio="2">
|
||||
<rcs>
|
||||
<Id Id="$Id$"/>
|
||||
<HeadURL HeadURL="$HeadURL$"/>
|
||||
<Author Author="$Author$"/>
|
||||
</rcs>
|
||||
<tables>
|
||||
<table name="asm_asset">
|
||||
<column name="id" datatype="integer" isPrimaryKey="1">
|
||||
<sequence start="1" increment="1"/>
|
||||
</column>
|
||||
<column name="name" datatype="text"/>
|
||||
<column name="asset_type_id" datatype="integer" isForeignKey="1"/>
|
||||
<column name="location_id" datatype="integer" isForeignKey="1"/>
|
||||
<column name="sub_location" datatype="integer" default="0" comment="0-left, 1-right"/>
|
||||
<column name="certificate" datatype="bytea"/>
|
||||
<column name="properties" datatype="jsonb"/>
|
||||
<foreignKey name="FK_asm_asset_asm_asset_type">
|
||||
<source table="asm_asset" column="asset_type_id"/>
|
||||
<destination table="asm_asset_type" column="id"/>
|
||||
</foreignKey>
|
||||
<foreignKey name="FK_asm_asset_asm_location">
|
||||
<source table="asm_asset" column="location_id"/>
|
||||
<destination table="asm_location" column="id"/>
|
||||
</foreignKey>
|
||||
</table>
|
||||
<table name="asm_asset_type">
|
||||
<column name="id" datatype="integer" isPrimaryKey="1">
|
||||
<sequence start="1" increment="1"/>
|
||||
</column>
|
||||
<column name="name" datatype="text"/>
|
||||
</table>
|
||||
<table name="asm_egcu_relay_info" comment="EGCU-Relay-Names">
|
||||
<column name="id" datatype="integer" isPrimaryKey="1">
|
||||
<sequence start="1" increment="1"/>
|
||||
</column>
|
||||
<column name="relay_id" datatype="integer" comment="Index of Relay"/>
|
||||
<column name="name" datatype="text" comment="Name of relay"/>
|
||||
<column name="description" datatype="text" comment="description of relay"/>
|
||||
<column name="properties" datatype="text" comment="properties of relay"/>
|
||||
<constraint name="UQ_asm_egcu_relay_info_id" type="unique">
|
||||
<column name="id"/>
|
||||
</constraint>
|
||||
<constraint name="UQ_asm_egcu_relay_info_name" type="unique">
|
||||
<column name="name"/>
|
||||
</constraint>
|
||||
<constraint name="UQ_asm_egcu_relay_info_relay_id" type="unique">
|
||||
<column name="relay_id"/>
|
||||
</constraint>
|
||||
</table>
|
||||
<table name="asm_location">
|
||||
<column name="id" datatype="integer" isPrimaryKey="1">
|
||||
<sequence start="1" increment="1"/>
|
||||
</column>
|
||||
<column name="name" datatype="text"/>
|
||||
<column name="description" datatype="text"/>
|
||||
</table>
|
||||
<table name="asm_map_description">
|
||||
<column name="id" datatype="integer" isPrimaryKey="1">
|
||||
<sequence start="1" increment="1"/>
|
||||
</column>
|
||||
<column name="name" datatype="text"/>
|
||||
<column name="description" datatype="text"/>
|
||||
<column name="training_area_id" datatype="integer" isForeignKey="1"/>
|
||||
<column name="map_type_id" datatype="integer" isForeignKey="1"/>
|
||||
<column name="url" datatype="text" comment="List of map information with link to a geo-server"/>
|
||||
<column name="min_scale" datatype="real" default="-1"/>
|
||||
<column name="max_scale" datatype="real" default="-1"/>
|
||||
<column name="obj_order" datatype="integer"/>
|
||||
<column name="map_description_type_id" datatype="integer" isForeignKey="1"/>
|
||||
<foreignKey name="FK_map_map_type">
|
||||
<source table="asm_map_description" column="map_type_id"/>
|
||||
<destination table="asm_map_type" column="id"/>
|
||||
</foreignKey>
|
||||
<foreignKey name="FK_map_training_area">
|
||||
<source table="asm_map_description" column="training_area_id"/>
|
||||
<destination table="asm_training_area" column="id"/>
|
||||
</foreignKey>
|
||||
<foreignKey name="FK_asm_map_description_asm_map_description_type" referential_integrity="DeleteCascade">
|
||||
<source table="asm_map_description" column="map_description_type_id"/>
|
||||
<destination table="asm_map_description_type" column="id"/>
|
||||
</foreignKey>
|
||||
</table>
|
||||
<table name="asm_map_description_type">
|
||||
<column name="id" datatype="integer" isPrimaryKey="1">
|
||||
<sequence start="1" increment="1"/>
|
||||
</column>
|
||||
<column name="name" datatype="text"/>
|
||||
</table>
|
||||
<table name="asm_map_type">
|
||||
<column name="id" datatype="integer" isPrimaryKey="1">
|
||||
<sequence start="1" increment="1"/>
|
||||
</column>
|
||||
<column name="name" datatype="text"/>
|
||||
<constraint name="UQ_map_type_id" type="unique">
|
||||
<column name="id"/>
|
||||
</constraint>
|
||||
</table>
|
||||
<table name="asm_technical_area">
|
||||
<column name="id" datatype="integer" isPrimaryKey="1">
|
||||
<sequence start="1" increment="1"/>
|
||||
</column>
|
||||
<column name="name" datatype="text"/>
|
||||
<column name="training_area_id" datatype="integer" isForeignKey="1"/>
|
||||
<column name="position" datatype="point_2d"/>
|
||||
<column name="width" datatype="integer"/>
|
||||
<column name="length" datatype="integer"/>
|
||||
<column name="charge_type_id" datatype="integer" isForeignKey="1"/>
|
||||
<foreignKey name="FK_asm_technical_area_asm_training_area" referential_integrity="DeleteCascade">
|
||||
<source table="asm_technical_area" column="training_area_id"/>
|
||||
<destination table="asm_training_area" column="id"/>
|
||||
</foreignKey>
|
||||
<foreignKey name="FK_asm_technical_area_pdm_charge_type" referential_integrity="DeleteCascade">
|
||||
<source table="asm_technical_area" column="charge_type_id"/>
|
||||
<destination service="ProjectDataManagement" serviceAbbr="pdm" schema="pdm" table="pdm_charge_type" column="id"/>
|
||||
</foreignKey>
|
||||
</table>
|
||||
<table name="asm_training_area">
|
||||
<column name="id" datatype="integer" isPrimaryKey="1">
|
||||
<sequence start="1" increment="1"/>
|
||||
</column>
|
||||
<column name="name" datatype="text"/>
|
||||
<column name="bottom_left" datatype="point_2d"/>
|
||||
<column name="height" datatype="integer"/>
|
||||
<column name="width" datatype="integer"/>
|
||||
<column name="image" datatype="bytea"/>
|
||||
<constraint name="UQ_asm_training_area_id" type="unique">
|
||||
<column name="id"/>
|
||||
</constraint>
|
||||
</table>
|
||||
</tables>
|
||||
<views/>
|
||||
<dbServiceStructs>
|
||||
<serviceStruct name="AsmAsset" table="asm_asset"/>
|
||||
<serviceStruct name="AsmEgcuRelayInfo" table="asm_egcu_relay_info"/>
|
||||
<serviceStruct name="AsmLocation" table="asm_location"/>
|
||||
<serviceStruct name="AsmMapDescription" table="asm_map_description"/>
|
||||
<serviceStruct name="AsmTechnicalArea" table="asm_technical_area"/>
|
||||
<serviceStruct name="AsmTrainingArea" table="asm_training_area"/>
|
||||
<table name="asm_asset"/>
|
||||
<table name="asm_egcu_relay_info"/>
|
||||
<table name="asm_location"/>
|
||||
<table name="asm_map_description"/>
|
||||
<table name="asm_technical_area"/>
|
||||
<table name="asm_training_area"/>
|
||||
</dbServiceStructs>
|
||||
<topicTypes>
|
||||
<topicType name="Asset" isDataObject="1" autosubscribe="1" routeToClient="1" routeToServer="0" routeInReplay="0" baseValueType="Core::BaseEntity">
|
||||
<column name="assetTypeId" idlType="AssetType"/>
|
||||
<column name="locationId" idlType="long"/>
|
||||
<column name="subLocation" idlType="long"/>
|
||||
<column name="certificate" idlType="sequence<octet>"/>
|
||||
<column name="properties" idlType="string"/>
|
||||
</topicType>
|
||||
<topicType name="Location" isDataObject="1" autosubscribe="1" routeToClient="1" routeToServer="0" routeInReplay="0" baseValueType="Core::BaseEntity">
|
||||
<column name="description" idlType="string"/>
|
||||
</topicType>
|
||||
<topicType name="MapDescription" baseValueType="Core::BaseEntity">
|
||||
<column name="mapTypeId" idlType="MapType"/>
|
||||
<column name="trainingAreaId" idlType="long"/>
|
||||
<column name="description" idlType="string"/>
|
||||
<column name="url" idlType="string"/>
|
||||
<column name="minScale" idlType="double"/>
|
||||
<column name="maxScale" idlType="double"/>
|
||||
<column name="mapDescriptionTypeId" idlType="MapDescriptionType"/>
|
||||
</topicType>
|
||||
<topicType name="TrainingArea" isDataObject="1" autosubscribe="1" routeToClient="1" routeToServer="0" routeInReplay="1" baseValueType="Core::BaseEntity">
|
||||
<column name="bottomLeft" idlType="Core::GeoPosition2D"/>
|
||||
<column name="height" idlType="long"/>
|
||||
<column name="width" idlType="long"/>
|
||||
<column name="image" idlType="sequence<octet>"/>
|
||||
<column name="map2D" idlType="sequence<MapDescription>"/>
|
||||
<column name="scene3D" idlType="sequence<MapDescription>"/>
|
||||
<column name="elevation" idlType="sequence<MapDescription>"/>
|
||||
<column name="sceneObjects" idlType="sequence<MapDescription>"/>
|
||||
</topicType>
|
||||
<topicType name="WorkstationLogout" isDataObject="1" autosubscribe="1" routeToClient="1" routeToServer="0" routeInReplay="0" recordTopic="1">
|
||||
<column name="originatorId" idlType="long" isKey="1"/>
|
||||
<column name="ids" idlType="sequence<long>"/>
|
||||
<column name="shutdownAction" idlType="ShutdownAction" comment="if true, also shut down the workstation"/>
|
||||
<column name="sampleTime" idlType="long long"/>
|
||||
</topicType>
|
||||
<topicType name="RelayInfo" extensibility="EXTENSIBLE" isDataObject="1" autosubscribe="1" routeToClient="1" routeToServer="0" routeInReplay="0" baseValueType="Core::BaseEntity">
|
||||
<column name="description" idlType="string"/>
|
||||
<column name="property" idlType="string"/>
|
||||
</topicType>
|
||||
</topicTypes>
|
||||
<functionTopics>
|
||||
<functionTopic name="RelayInfoRemove" requestTopicType="Core::RemoveElementRequest" replyTopicType="Core::FunctionReply" requestTopicName="RelayInfoRemoveRequest" replyTopicName="RelayInfoRemoveReply" routeInReplay="0"/>
|
||||
<functionTopic name="RelayInfoModify" requestTopicType="RelayInfo" replyTopicType="Core::FunctionReply" requestTopicName="RelayInfoModifyRequest" replyTopicName="RelayInfoModifyReply" routeInReplay="0"/>
|
||||
<functionTopic name="AssetModify" requestTopicType="Asset" replyTopicType="Core::FunctionReply" requestTopicName="AssetModifyRequest" replyTopicName="AssetModifyReply" routeInReplay="0"/>
|
||||
<functionTopic name="AssetRemove" requestTopicType="Core::RemoveElementRequest" replyTopicType="Core::FunctionReply" requestTopicName="AssetRemoveRequest" replyTopicName="AssetRemoveReply" routeInReplay="0"/>
|
||||
<functionTopic name="MapDescriptionModify" requestTopicType="MapDescription" replyTopicType="Core::FunctionReply" requestTopicName="MapDescriptionModifyRequest" replyTopicName="MapDescriptionModifyReply" routeInReplay="0"/>
|
||||
<functionTopic name="MapDescriptionRemove" requestTopicType="Core::RemoveElementRequest" replyTopicType="Core::FunctionReply" requestTopicName="MapDescriptionRemoveRequest" replyTopicName="MapDescriptionRemoveReply" routeInReplay="0"/>
|
||||
<functionTopic name="TrainingAreaModify" requestTopicType="TrainingArea" replyTopicType="Core::FunctionReply" requestTopicName="TrainingAreaModifyRequest" replyTopicName="TrainingAreaModifyReply" routeInReplay="0"/>
|
||||
<functionTopic name="TrainingAreaRemove" requestTopicType="Core::RemoveElementRequest" replyTopicType="Core::FunctionReply" requestTopicName="TrainingAreaRemoveRequest" replyTopicName="TrainingAreaRemoveReply" routeInReplay="0"/>
|
||||
<functionTopic name="WorkstationLogout" requestTopicType="WorkstationLogout" replyTopicType="Core::FunctionReply" requestTopicName="WorkstationLogoutRequest" replyTopicName="WorkstationLogoutReply" routeInReplay="0"/>
|
||||
</functionTopics>
|
||||
<customDtcFunctions>
|
||||
<customDtcFunction>
|
||||
<function name="isAARWorkstation" returns="bool">
|
||||
<parameter pos="1" name="wsName" type="const QString &"/>
|
||||
</function>
|
||||
</customDtcFunction>
|
||||
<customDtcFunction>
|
||||
<function name="getAssetId" returns="int">
|
||||
<parameter pos="1" name="wsName" type="const QString &"/>
|
||||
</function>
|
||||
</customDtcFunction>
|
||||
</customDtcFunctions>
|
||||
<enumerations>
|
||||
<enumeration name="MapType" table="asm_map_type">
|
||||
<attribute key="Unknown" value="0"/>
|
||||
<attribute key="Topographic" value="1"/>
|
||||
<attribute key="Aerial" value="2"/>
|
||||
<attribute key="Feature" value="3"/>
|
||||
<attribute key="Elevation" value="4"/>
|
||||
<attribute key="SceneObjects" value="5"/>
|
||||
</enumeration>
|
||||
<enumeration name="ShutdownAction">
|
||||
<attribute key="NoAction" value="0"/>
|
||||
<attribute key="Logout" value="1"/>
|
||||
<attribute key="Shutdown" value="2"/>
|
||||
<attribute key="Reboot" value="3"/>
|
||||
</enumeration>
|
||||
<enumeration name="AssetType" table="asm_asset_type">
|
||||
<attribute key="Unknown" value="0"/>
|
||||
<attribute key="Workstation" value="1"/>
|
||||
<attribute key="Printer" value="2"/>
|
||||
<attribute key="Beamer" value="3"/>
|
||||
<attribute key="ProjectionWorkstation" value="4"/>
|
||||
<attribute key="MobileAfterActionVehicle" value="5"/>
|
||||
<attribute key="AdlerSAA" value="6"/>
|
||||
</enumeration>
|
||||
<enumeration name="MapDescriptionType" table="asm_map_description_type">
|
||||
<attribute key="Map2D" value="1"/>
|
||||
<attribute key="Scene3D" value="2"/>
|
||||
<attribute key="Elevation" value="3"/>
|
||||
<attribute key="SceneObj" value="4"/>
|
||||
</enumeration>
|
||||
</enumerations>
|
||||
<operatorRights offset="4"/>
|
||||
</service>
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Convert db structures to dds structures
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2017-07-20
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <AssetManagement/asm_db.h>
|
||||
#include <AssetManagement/asm.hpp>
|
||||
|
||||
#include <LtsUtilsCore/dds_vector.h>
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
namespace Database
|
||||
{
|
||||
inline TrainingArea convert(const AsmTrainingArea &dbData)
|
||||
{
|
||||
TrainingArea ddsData;
|
||||
|
||||
ddsData.id(dbData.id);
|
||||
ddsData.name(dbData.name.toStdString());
|
||||
ddsData.bottomLeft(Core::GeoPosition2D(dbData.bottomLeft.x(), dbData.bottomLeft.y()));
|
||||
ddsData.height(dbData.height);
|
||||
ddsData.width(dbData.width);
|
||||
ddsData.image() = LtsUtils::convert<std::vector<uint8_t>>(dbData.image);
|
||||
|
||||
// init data not in db
|
||||
ddsData.isDeleted(false);
|
||||
ddsData.isUsed(false);
|
||||
|
||||
return ddsData;
|
||||
}
|
||||
inline MapDescription convert(const AsmMapDescription &dbData)
|
||||
{
|
||||
MapDescription ddsData;
|
||||
ddsData.id(dbData.id);
|
||||
ddsData.name(dbData.name.toStdString());
|
||||
ddsData.description(dbData.description.toStdString());
|
||||
ddsData.mapDescriptionTypeId(dbData.mapDescriptionTypeId);
|
||||
ddsData.mapTypeId(dbData.mapTypeId);
|
||||
ddsData.maxScale(dbData.minScale);
|
||||
ddsData.minScale(dbData.minScale);
|
||||
ddsData.trainingAreaId(dbData.trainingAreaId);
|
||||
ddsData.url(dbData.url.toStdString());
|
||||
return ddsData;
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+50
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* DdsHandler for DDS
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hanna E. Rathje, SLSE, 2015-09-02
|
||||
*/
|
||||
|
||||
#include "dds_handler.h"
|
||||
|
||||
#include <DDS/Core/pacemaker.h>
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
|
||||
DdsHandler::DdsHandler(int domainId)
|
||||
: m_ddsConnector(std::make_shared<DDSConnector::DdsConnector>(domainId, IDL::PartitionType::Any))
|
||||
, m_logger(getLogger("DdsHandler"))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "DdsHandler(" << domainId << ") for partition: " << m_ddsConnector->getDefaultPartition();
|
||||
}
|
||||
|
||||
bool DdsHandler::init(const QStringList &qosFileList)
|
||||
{
|
||||
if (!m_ddsConnector->init(qosFileList))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error initializing dds connections - aborting";
|
||||
return false;
|
||||
}
|
||||
|
||||
// default initialize Publisher and Subscriber
|
||||
m_ddsConnector->initPublisherSubscriber();
|
||||
m_ddsConnector->enableBatchedWriter(false);
|
||||
|
||||
// Pacemaker
|
||||
m_pacemaker = std::make_shared<Core::Pacemaker>(m_ddsConnector);
|
||||
m_topicLockMaster = std::make_shared<Core::TopicLockMaster>(m_ddsConnector);
|
||||
|
||||
m_ddsDts = AssetManagement::Interface::Dts::create(m_ddsConnector);
|
||||
m_ddsFts = AssetManagement::Interface::Fts::create(m_ddsConnector);
|
||||
bool bRet = m_ddsDts->enableAll();
|
||||
INFO_LOG(m_logger) << "Dts initialised";
|
||||
|
||||
bRet &= m_ddsFts->enableAll();
|
||||
INFO_LOG(m_logger) << "Fts initialised";
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
} // Namespace ASM
|
||||
Executable
+49
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* DdsHandler for DDS
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hanna E. Rathje, SLSE, 2015-09-02
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
#include <DDS/Core/topic_lock_master.h>
|
||||
#include <AssetManagement/asm_dts.h>
|
||||
#include <AssetManagement/asm_fts.h>
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class Pacemaker;
|
||||
}
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
class DdsHandler final
|
||||
{
|
||||
public:
|
||||
explicit DdsHandler(int domainId);
|
||||
~DdsHandler() = default;
|
||||
|
||||
bool init(const QStringList &qosFileList = QStringList());
|
||||
|
||||
std::shared_ptr<DDSConnector::DdsConnector> ddsConnector() const { return m_ddsConnector; }
|
||||
std::shared_ptr<Core::Pacemaker> pacemaker() const {return m_pacemaker; }
|
||||
std::shared_ptr<Core::TopicLockMaster> topicLockMaster() const { return m_topicLockMaster; }
|
||||
|
||||
std::shared_ptr<AssetManagement::Interface::Dts> dts() const { return m_ddsDts; }
|
||||
std::shared_ptr<AssetManagement::Interface::Fts> fts() const { return m_ddsFts; }
|
||||
|
||||
private:
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
|
||||
std::shared_ptr<Core::Pacemaker> m_pacemaker;
|
||||
std::shared_ptr<Core::TopicLockMaster> m_topicLockMaster;
|
||||
std::shared_ptr<AssetManagement::Interface::Dts> m_ddsDts;
|
||||
std::shared_ptr<AssetManagement::Interface::Fts> m_ddsFts;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
|
||||
}
|
||||
+131
@@ -0,0 +1,131 @@
|
||||
/**
|
||||
* Handler for all assets
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Iuliana Ojog, SLSE, 2017-09-20
|
||||
*/
|
||||
|
||||
#include "handler_asset.h"
|
||||
#include "object_asset.h"
|
||||
#include "main_handler.h"
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
|
||||
HandlerAsset::HandlerAsset(MainHandler *mainHandler, QObject *parent)
|
||||
: QObject(parent)
|
||||
, Interface::Fts::AssetModifyRequestHandler(mainHandler->dds()->fts())
|
||||
, Interface::Fts::AssetRemoveRequestHandler(mainHandler->dds()->fts())
|
||||
, m_mainHandler(mainHandler)
|
||||
, m_logger(getLogger("HandlerAsset"))
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------
|
||||
HandlerAsset::~HandlerAsset()
|
||||
{
|
||||
qDeleteAll(m_objectAssetMap);
|
||||
}
|
||||
|
||||
//---------------------------------------------------
|
||||
bool HandlerAsset::init()
|
||||
{
|
||||
bool bRet = true;
|
||||
// create objects
|
||||
auto cb = [this, &bRet] (const Database::AsmAsset &data)
|
||||
{
|
||||
ObjectAsset *ifs(new ObjectAsset(m_mainHandler));
|
||||
Core::FunctionReplyObject ret = ifs->createObject(ObjectAsset::toDdsData(data));
|
||||
if (ret.error())
|
||||
{
|
||||
delete ifs;
|
||||
ERROR_LOG(m_logger) << ret();
|
||||
bRet = false;
|
||||
return;
|
||||
}
|
||||
m_objectAssetMap.insert(ifs->getId(), ifs);
|
||||
};
|
||||
if (!m_mainHandler->db()->select(cb) || !bRet)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error reading data from database!";
|
||||
return false;
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "m_objectAssetMap.size() = " << m_objectAssetMap.size();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//---------------------------------------------------
|
||||
void HandlerAsset::onAssetModifyRequest(const rti::core::SampleIdentity &cookie,
|
||||
const Asset &request)
|
||||
{
|
||||
const auto ret = assetModifyRequest(request);
|
||||
if (ret.error())
|
||||
WARNING_LOG(m_logger) << ret();
|
||||
m_mainHandler->dds()->fts()->assetModifyReply(cookie, ret);
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject HandlerAsset::assetModifyRequest(const Asset &request)
|
||||
{
|
||||
// modify
|
||||
if (request.id() > 0)
|
||||
{
|
||||
ObjectAsset *ifs = m_objectAssetMap.value(request.id());
|
||||
if (!ifs)
|
||||
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "Asset with id %1 not found")).arg(request.id());
|
||||
return ifs->updateObject(request);
|
||||
}
|
||||
// create
|
||||
ObjectAsset *ifs(new ObjectAsset(m_mainHandler));
|
||||
auto ret = ifs->createObject(request);
|
||||
if (ret.error())
|
||||
{
|
||||
delete ifs;
|
||||
ifs = nullptr;
|
||||
}
|
||||
else
|
||||
m_objectAssetMap.insert(ifs->getId(), ifs);
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------
|
||||
void HandlerAsset::onAssetRemoveRequest(const rti::core::SampleIdentity &cookie,
|
||||
const Core::RemoveElementRequest &request)
|
||||
{
|
||||
Core::FunctionReplyObject ret;
|
||||
ObjectAsset *ifs = m_objectAssetMap.value(request.id());
|
||||
|
||||
if (ifs == nullptr)
|
||||
{
|
||||
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "Asset with id %1 not found")).arg(request.id());
|
||||
m_mainHandler->dds()->fts()->assetRemoveReply(cookie, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_mainHandler->dds()->topicLockMaster()->isLocked(ifs->getData(), m_mainHandler->exerciseId()))
|
||||
{
|
||||
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "Asset '%1' is used by another user!")).arg(ifs->getName());
|
||||
m_mainHandler->dds()->fts()->assetRemoveReply(cookie, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
ret = ifs->removeObject();
|
||||
|
||||
if (ret.error())
|
||||
ERROR_LOG(m_logger) << ret();
|
||||
else
|
||||
{
|
||||
// delete ObjectAsset
|
||||
delete ifs;
|
||||
m_objectAssetMap.remove(request.id());
|
||||
}
|
||||
|
||||
m_mainHandler->dds()->fts()->assetRemoveReply(cookie, ret);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
} // Namespace AssetManagement
|
||||
Executable
+45
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Handler for all assets
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Iuliana Ojog, SLSE, 2017-09-20
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QHash>
|
||||
|
||||
#include "dds_handler.h"
|
||||
#include "logger.h"
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
class MainHandler;
|
||||
class ObjectAsset;
|
||||
class HandlerAsset final : public QObject
|
||||
, protected Interface::Fts::AssetModifyRequestHandler
|
||||
, protected Interface::Fts::AssetRemoveRequestHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit HandlerAsset(MainHandler *mainHandler,
|
||||
QObject *parent = nullptr);
|
||||
~HandlerAsset();
|
||||
|
||||
bool init();
|
||||
|
||||
private:
|
||||
void onAssetModifyRequest(const rti::core::SampleIdentity &cookie,
|
||||
const Asset &request) override;
|
||||
Core::FunctionReplyObject assetModifyRequest(const Asset &request);
|
||||
void onAssetRemoveRequest(const rti::core::SampleIdentity &cookie,
|
||||
const Core::RemoveElementRequest &request) override;
|
||||
|
||||
private:
|
||||
QHash<int, ObjectAsset *> m_objectAssetMap;
|
||||
MainHandler *m_mainHandler;
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
};
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* Handler for all asset locations
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Iuliana Ojog, SLSE, 2017-09-20
|
||||
*/
|
||||
|
||||
#include "handler_location.h"
|
||||
#include "main_handler.h"
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
// Database::AsmLocation => AssetManagement::Location
|
||||
static inline Location toDdsData(const Database::AsmLocation &dbData)
|
||||
{
|
||||
Location ddsData;
|
||||
|
||||
ddsData.id(dbData.id);
|
||||
ddsData.name(dbData.name.toStdString());
|
||||
ddsData.description(dbData.description.toStdString());
|
||||
|
||||
// init data not in db
|
||||
ddsData.isDeleted(false);
|
||||
ddsData.isUsed(false);
|
||||
|
||||
return ddsData;
|
||||
}
|
||||
|
||||
HandlerLocation::HandlerLocation(MainHandler *mainHandler)
|
||||
: m_mainHandler(mainHandler)
|
||||
, m_logger(getLogger("HandlerLocation"))
|
||||
{
|
||||
}
|
||||
|
||||
bool HandlerLocation::init()
|
||||
{
|
||||
int iCnt = 0;
|
||||
// create objects
|
||||
auto cb = [this, &iCnt] (const Database::AsmLocation &data)
|
||||
{
|
||||
m_mainHandler->dds()->dts()->publish(toDdsData(data));
|
||||
++iCnt;
|
||||
};
|
||||
if (!m_mainHandler->db()->select(cb))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error reading data from database!";
|
||||
return false;
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "#Locations published: " << iCnt;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // Namespace AssetManagement
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Handler for all asset locations
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Iuliana Ojog, SLSE, 2017-09-20
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
class MainHandler;
|
||||
class HandlerLocation final
|
||||
{
|
||||
public:
|
||||
explicit HandlerLocation(MainHandler *mainHandler);
|
||||
|
||||
bool init();
|
||||
private:
|
||||
MainHandler *m_mainHandler;
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
};
|
||||
}
|
||||
+131
@@ -0,0 +1,131 @@
|
||||
/**
|
||||
* Handler for all assets
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Iuliana Ojog, SLSE, 2017-09-20
|
||||
*/
|
||||
|
||||
#include "handler_relay_info.h"
|
||||
#include "object_relay_info.h"
|
||||
#include "main_handler.h"
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
|
||||
HandlerRelayInfo::HandlerRelayInfo(MainHandler *mainHandler, QObject *parent)
|
||||
: QObject(parent)
|
||||
, Interface::Fts::RelayInfoModifyRequestHandler(mainHandler->dds()->fts())
|
||||
, Interface::Fts::RelayInfoRemoveRequestHandler(mainHandler->dds()->fts())
|
||||
, m_mainHandler(mainHandler)
|
||||
, m_logger(getLogger("HandlerRelayInfo"))
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------
|
||||
HandlerRelayInfo::~HandlerRelayInfo()
|
||||
{
|
||||
qDeleteAll(m_objectRelayInfoMap);
|
||||
}
|
||||
|
||||
//---------------------------------------------------
|
||||
bool HandlerRelayInfo::init()
|
||||
{
|
||||
bool bRet = true;
|
||||
// create objects
|
||||
auto cb = [this, &bRet] (const Database::AsmEgcuRelayInfo &data)
|
||||
{
|
||||
ObjectRelayInfo *ifs(new ObjectRelayInfo(m_mainHandler));
|
||||
Core::FunctionReplyObject ret = ifs->createObject(ObjectRelayInfo::toDdsData(data));
|
||||
if (ret.error())
|
||||
{
|
||||
delete ifs;
|
||||
ERROR_LOG(m_logger) << ret();
|
||||
bRet = false;
|
||||
return;
|
||||
}
|
||||
m_objectRelayInfoMap.insert(ifs->getId(), ifs);
|
||||
};
|
||||
if (!m_mainHandler->db()->select(cb) || !bRet)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error reading data from database!";
|
||||
return false;
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "m_objectRelayInfoMap.size() = " << m_objectRelayInfoMap.size();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//---------------------------------------------------
|
||||
void HandlerRelayInfo::onRelayInfoModifyRequest(const rti::core::SampleIdentity &cookie,
|
||||
const RelayInfo &request)
|
||||
{
|
||||
const auto ret = relayInfoModifyRequest(request);
|
||||
if (ret.error())
|
||||
WARNING_LOG(m_logger) << ret();
|
||||
m_mainHandler->dds()->fts()->relayInfoModifyReply(cookie, ret);
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject HandlerRelayInfo::relayInfoModifyRequest(const RelayInfo &request)
|
||||
{
|
||||
// modify
|
||||
if (request.id() > 0)
|
||||
{
|
||||
ObjectRelayInfo *ifs = m_objectRelayInfoMap.value(request.id());
|
||||
if (!ifs)
|
||||
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "RelayInfo with id %1 not found")).arg(request.id());
|
||||
return ifs->updateObject(request);
|
||||
}
|
||||
// create
|
||||
ObjectRelayInfo *ifs(new ObjectRelayInfo(m_mainHandler));
|
||||
auto ret = ifs->createObject(request);
|
||||
if (ret.error())
|
||||
{
|
||||
delete ifs;
|
||||
ifs = nullptr;
|
||||
}
|
||||
else
|
||||
m_objectRelayInfoMap.insert(ifs->getId(), ifs);
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------
|
||||
void HandlerRelayInfo::onRelayInfoRemoveRequest(const rti::core::SampleIdentity &cookie,
|
||||
const Core::RemoveElementRequest &request)
|
||||
{
|
||||
Core::FunctionReplyObject ret;
|
||||
ObjectRelayInfo *ifs = m_objectRelayInfoMap.value(request.id());
|
||||
|
||||
if (ifs == nullptr)
|
||||
{
|
||||
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "RelayInfo with id %1 not found")).arg(request.id());
|
||||
m_mainHandler->dds()->fts()->relayInfoRemoveReply(cookie, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_mainHandler->dds()->topicLockMaster()->isLocked(ifs->getData(), m_mainHandler->exerciseId()))
|
||||
{
|
||||
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "RelayInfo '%1' is used by another user!")).arg(ifs->getName());
|
||||
m_mainHandler->dds()->fts()->relayInfoRemoveReply(cookie, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
ret = ifs->removeObject();
|
||||
|
||||
if (ret.error())
|
||||
ERROR_LOG(m_logger) << ret();
|
||||
else
|
||||
{
|
||||
// delete ObjectRelayInfo
|
||||
delete ifs;
|
||||
m_objectRelayInfoMap.remove(request.id());
|
||||
}
|
||||
|
||||
m_mainHandler->dds()->fts()->relayInfoRemoveReply(cookie, ret);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
} // Namespace AssetManagement
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Handler for all assets
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Iuliana Ojog, SLSE, 2017-09-20
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QHash>
|
||||
|
||||
#include "dds_handler.h"
|
||||
#include "logger.h"
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
class MainHandler;
|
||||
class ObjectRelayInfo;
|
||||
class HandlerRelayInfo final : public QObject
|
||||
, protected Interface::Fts::RelayInfoModifyRequestHandler
|
||||
, protected Interface::Fts::RelayInfoRemoveRequestHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit HandlerRelayInfo(MainHandler *mainHandler,
|
||||
QObject *parent = nullptr);
|
||||
~HandlerRelayInfo();
|
||||
|
||||
bool init();
|
||||
|
||||
private:
|
||||
void onRelayInfoModifyRequest(const rti::core::SampleIdentity &cookie,
|
||||
const RelayInfo &request) override;
|
||||
Core::FunctionReplyObject relayInfoModifyRequest(const RelayInfo &request);
|
||||
void onRelayInfoRemoveRequest(const rti::core::SampleIdentity &cookie,
|
||||
const Core::RemoveElementRequest &request) override;
|
||||
|
||||
private:
|
||||
QHash<int, ObjectRelayInfo*> m_objectRelayInfoMap;
|
||||
MainHandler *m_mainHandler;
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
};
|
||||
}
|
||||
+409
@@ -0,0 +1,409 @@
|
||||
/**
|
||||
* Handler for all training area objects
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hanna E. Rathje, SLSE, 2016-03-04
|
||||
*/
|
||||
|
||||
#include "handler_training_area.h"
|
||||
#include "object_training_area.h"
|
||||
#include "main_handler.h"
|
||||
#include "convert_db_to_dds.h"
|
||||
#include <ngldb/dbtransaction.h>
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
//----------------------------------------------------------------------------------------------
|
||||
HandlerTrainingArea::HandlerTrainingArea(MainHandler *mainHandler, QObject *parent)
|
||||
: QObject(parent)
|
||||
, Interface::Fts::TrainingAreaModifyRequestHandler(mainHandler->dds()->fts())
|
||||
, Interface::Fts::TrainingAreaRemoveRequestHandler(mainHandler->dds()->fts())
|
||||
, Interface::Fts::MapDescriptionModifyRequestHandler(mainHandler->dds()->fts())
|
||||
, Interface::Fts::MapDescriptionRemoveRequestHandler(mainHandler->dds()->fts())
|
||||
, m_mainHandler(mainHandler)
|
||||
, m_logger(getLogger("HandlerTrainingArea"))
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------
|
||||
HandlerTrainingArea::~HandlerTrainingArea()
|
||||
{
|
||||
qDeleteAll(m_objectTrainingAreaMap);
|
||||
qDeleteAll(m_objectMapDescriptionMap);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------
|
||||
bool HandlerTrainingArea::init()
|
||||
{
|
||||
QMap <int, MapDescriptionSeq> mapDescriptionSeqences; // key = TrainingAreaId
|
||||
|
||||
// create map description objects
|
||||
QVector<Database::AsmMapDescription> dataVecMD;
|
||||
if (!m_mainHandler->db()->select(dataVecMD))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error reading data from database!";
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const Database::AsmMapDescription &data : qAsConst(dataVecMD))
|
||||
{
|
||||
ObjectMapDescription *ifs(new ObjectMapDescription(m_mainHandler));
|
||||
Core::FunctionReplyObject ret = ifs->createObject(convert(data), data.objOrder);
|
||||
MapDescriptionSeq mapDescriptionSeq;
|
||||
if (mapDescriptionSeqences.contains(data.trainingAreaId))
|
||||
mapDescriptionSeq = mapDescriptionSeqences.value(data.trainingAreaId);
|
||||
|
||||
switch (data.mapDescriptionTypeId.underlying())
|
||||
{
|
||||
case AssetManagement::MapDescriptionType_def::Map2D:
|
||||
mapDescriptionSeq.map2D.insert(data.objOrder, data);
|
||||
INFO_LOG(m_logger) << "map2D.insert order =" << data.objOrder;
|
||||
break;
|
||||
case AssetManagement::MapDescriptionType_def::Scene3D:
|
||||
mapDescriptionSeq.scene3D.insert(data.objOrder, data);
|
||||
INFO_LOG(m_logger) << "Scene3D.insert order =" << data.objOrder;
|
||||
break;
|
||||
case AssetManagement::MapDescriptionType_def::Elevation:
|
||||
mapDescriptionSeq.elevation.insert(data.objOrder, data);
|
||||
INFO_LOG(m_logger) << "Elevation.insert order =" << data.objOrder;
|
||||
break;
|
||||
case AssetManagement::MapDescriptionType_def::SceneObj:
|
||||
mapDescriptionSeq.sceneObj.insert(data.objOrder, data);
|
||||
INFO_LOG(m_logger) << "sceneObj.insert order =" << data.objOrder;
|
||||
break;
|
||||
}
|
||||
mapDescriptionSeqences.insert(data.trainingAreaId, mapDescriptionSeq);
|
||||
if (ret.error())
|
||||
{
|
||||
delete ifs;
|
||||
ERROR_LOG(m_logger) << ret();
|
||||
return false;
|
||||
}
|
||||
m_objectMapDescriptionMap.insert(ifs->getId(), ifs);
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "m_objectMapDescriptionMap.size() = " << m_objectMapDescriptionMap.size();
|
||||
|
||||
QVector<Database::AsmTrainingArea> dataVec;
|
||||
// read all training areas from database
|
||||
if (!m_mainHandler->db()->select(dataVec))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error reading data from database!";
|
||||
return false;
|
||||
}
|
||||
|
||||
// create asm_training_area
|
||||
for (const Database::AsmTrainingArea &data : qAsConst(dataVec))
|
||||
{
|
||||
// insert sequences of map descriptions in data
|
||||
ObjectTrainingArea *ifs(new ObjectTrainingArea(m_mainHandler));
|
||||
TrainingArea taData = convert(data);
|
||||
// insert sequences
|
||||
if (mapDescriptionSeqences.contains(taData.id()) )
|
||||
{
|
||||
const MapDescriptionSeq mapDescriptionSeq = mapDescriptionSeqences.value(taData.id());
|
||||
|
||||
taData.map2D().reserve(mapDescriptionSeq.map2D.size());
|
||||
for (const auto &dbDesc : mapDescriptionSeq.map2D)
|
||||
taData.map2D().push_back(ObjectMapDescription::toDdsData(dbDesc));
|
||||
|
||||
taData.scene3D().reserve(mapDescriptionSeq.scene3D.size());
|
||||
for (const auto &dbDesc : mapDescriptionSeq.scene3D)
|
||||
taData.scene3D().push_back(ObjectMapDescription::toDdsData(dbDesc));
|
||||
|
||||
taData.elevation().reserve(mapDescriptionSeq.elevation.size());
|
||||
for (const auto &dbDesc : mapDescriptionSeq.elevation)
|
||||
taData.elevation().push_back(ObjectMapDescription::toDdsData(dbDesc));
|
||||
|
||||
taData.sceneObjects().reserve(mapDescriptionSeq.sceneObj.size());
|
||||
for (const auto &dbDesc : mapDescriptionSeq.sceneObj)
|
||||
taData.sceneObjects().push_back(ObjectMapDescription::toDdsData(dbDesc));
|
||||
}
|
||||
// end insert sequences
|
||||
Core::FunctionReplyObject ret = ifs->createObject(taData);
|
||||
if (ret.error())
|
||||
{
|
||||
delete ifs;
|
||||
ERROR_LOG(m_logger) << ret();
|
||||
return false;
|
||||
}
|
||||
m_objectTrainingAreaMap.insert(ifs->getId(), ifs);
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "m_objectTrainingAreaMap.size() = " << m_objectTrainingAreaMap.size();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------
|
||||
void HandlerTrainingArea::removeMapDescriptions(int trainingAreaId)
|
||||
{
|
||||
INFO_LOG(m_logger) << "removeMapDescriptions trainingAreaId = " << trainingAreaId
|
||||
<< " m_objectMapDescriptionMap.size = " << m_objectMapDescriptionMap.size();
|
||||
QMapIterator< int, ObjectMapDescription *> it(m_objectMapDescriptionMap);
|
||||
while ( it.hasNext())
|
||||
{
|
||||
it.next();
|
||||
INFO_LOG(m_logger) << "remove map description key = " << it.key();
|
||||
if ( it.value()->getData().trainingAreaId() == trainingAreaId)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "remove id= " << it.key();
|
||||
|
||||
ObjectMapDescription *ifs = m_objectMapDescriptionMap.value(it.key());
|
||||
|
||||
ifs->removeObject();
|
||||
|
||||
m_objectMapDescriptionMap.remove(it.key());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------
|
||||
void HandlerTrainingArea::onTrainingAreaModifyRequest(const rti::core::SampleIdentity &cookie,
|
||||
const AssetManagement::TrainingArea &request)
|
||||
{
|
||||
const auto ret = trainingAreaModifyRequest(request);
|
||||
if (ret.error())
|
||||
WARNING_LOG(m_logger) << ret();
|
||||
m_mainHandler->dds()->fts()->trainingAreaModifyReply(cookie, ret);
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject HandlerTrainingArea::trainingAreaModifyRequest(const TrainingArea &request)
|
||||
{
|
||||
TrainingArea ddsData(request);
|
||||
ObjectTrainingArea *ifs;
|
||||
|
||||
Core::FunctionReplyObject ret;
|
||||
if (request.id() > 0)
|
||||
{
|
||||
ifs = m_objectTrainingAreaMap.value(request.id());
|
||||
|
||||
if (ifs == nullptr)
|
||||
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "Training area with id %1 not found")).arg(request.id());
|
||||
ret = ifs->updateObject(ddsData);
|
||||
if (ret.error())
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
ifs = new ObjectTrainingArea(m_mainHandler);
|
||||
ret = ifs->createObject(ddsData);
|
||||
if (ret.error())
|
||||
{
|
||||
delete ifs;
|
||||
ifs = nullptr;
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
m_objectTrainingAreaMap.insert(ifs->getId(), ifs);
|
||||
}
|
||||
if (request.id() > 0) // Modify
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "modify: delete old entries in map_description";
|
||||
removeMapDescriptions(ifs->getId());
|
||||
}
|
||||
|
||||
// insert new entries
|
||||
|
||||
auto &map2D = ddsData.map2D();
|
||||
map2D.resize(request.map2D().size());
|
||||
for (unsigned int i = 0; i < request.map2D().size(); i++)
|
||||
{
|
||||
MapDescription mdData = request.map2D().at(i);
|
||||
ObjectMapDescription *md (new ObjectMapDescription(m_mainHandler));
|
||||
mdData.id(0);
|
||||
mdData.trainingAreaId(ifs->getId());
|
||||
ret = md->createObject(mdData, i);
|
||||
DEBUG_LOG(m_logger) << "insert topographic entries in map_description"
|
||||
<< " for training area id " << ifs->getId()
|
||||
<< " mapTypeId=" << mdData.mapTypeId()
|
||||
<< " mapDescriptionTypeId=" << mdData.mapDescriptionTypeId();
|
||||
if (!ret.error())
|
||||
{
|
||||
map2D[i] = md->getData();
|
||||
m_objectMapDescriptionMap.insert(md->getId(), md);
|
||||
}
|
||||
else
|
||||
{
|
||||
map2D[i] = MapDescription();
|
||||
delete md;
|
||||
}
|
||||
}
|
||||
|
||||
auto &elevation = ddsData.elevation();
|
||||
elevation.resize(request.elevation().size());
|
||||
for (unsigned int i = 0; i < request.elevation().size(); i++)
|
||||
{
|
||||
MapDescription mdData = request.elevation().at(i);
|
||||
ObjectMapDescription *md (new ObjectMapDescription(m_mainHandler));
|
||||
mdData.id(0);
|
||||
mdData.trainingAreaId(ifs->getId());
|
||||
ret = md->createObject(mdData, i);
|
||||
DEBUG_LOG(m_logger) << "insert elevation entries in map_description"
|
||||
<< " for training area id " << ifs->getId()
|
||||
<< " mapTypeId=" << mdData.mapTypeId()
|
||||
<< " mapDescriptionTypeId=" << mdData.mapDescriptionTypeId();
|
||||
if (!ret.error())
|
||||
{
|
||||
elevation[i] = md->getData();
|
||||
m_objectMapDescriptionMap.insert(md->getId(), md);
|
||||
}
|
||||
else
|
||||
{
|
||||
elevation[i] = MapDescription();
|
||||
delete md;
|
||||
}
|
||||
}
|
||||
|
||||
auto &scene3D = ddsData.scene3D();
|
||||
scene3D.resize(request.scene3D().size());
|
||||
for (unsigned int i = 0; i < request.scene3D().size(); i++)
|
||||
{
|
||||
MapDescription mdData = request.scene3D().at(i);
|
||||
ObjectMapDescription *md (new ObjectMapDescription(m_mainHandler));
|
||||
mdData.id(0);
|
||||
mdData.trainingAreaId(ifs->getId());
|
||||
ret = md->createObject(mdData, i);
|
||||
DEBUG_LOG(m_logger) << "insert scene3D entries in map_description"
|
||||
<< " for training area id " << ifs->getId()
|
||||
<< " mapTypeId=" << mdData.mapTypeId()
|
||||
<< " mapDescriptionTypeId=" << mdData.mapDescriptionTypeId();
|
||||
if (!ret.error())
|
||||
{
|
||||
scene3D[i] = md->getData();
|
||||
m_objectMapDescriptionMap.insert(md->getId(), md);
|
||||
}
|
||||
else
|
||||
{
|
||||
scene3D[i] = MapDescription();
|
||||
delete md;
|
||||
}
|
||||
}
|
||||
|
||||
auto &sceneObj = ddsData.sceneObjects();
|
||||
sceneObj.resize(request.sceneObjects().size());
|
||||
for (unsigned int i = 0; i < request.sceneObjects().size(); i++)
|
||||
{
|
||||
MapDescription mdData = request.sceneObjects().at(i);
|
||||
ObjectMapDescription *md (new ObjectMapDescription(m_mainHandler));
|
||||
mdData.id(0);
|
||||
mdData.trainingAreaId(ifs->getId());
|
||||
ret = md->createObject(mdData, i);
|
||||
DEBUG_LOG(m_logger) << "insert sceneObjects entries in map_description"
|
||||
<< " for training area id " << ifs->getId()
|
||||
<< " mapTypeId=" << mdData.mapTypeId()
|
||||
<< " mapDescriptionTypeId=" << mdData.mapDescriptionTypeId();
|
||||
if (!ret.error())
|
||||
{
|
||||
sceneObj[i] = md->getData();
|
||||
m_objectMapDescriptionMap.insert(md->getId(), md);
|
||||
}
|
||||
else
|
||||
{
|
||||
sceneObj[i] = MapDescription();
|
||||
delete md;
|
||||
}
|
||||
}
|
||||
|
||||
ddsData.id(ifs->getId());
|
||||
return ifs->updateObject(ddsData);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------
|
||||
void HandlerTrainingArea::onTrainingAreaRemoveRequest(const rti::core::SampleIdentity &cookie,
|
||||
const Core::RemoveElementRequest &request)
|
||||
{
|
||||
Core::FunctionReplyObject ret;
|
||||
ObjectTrainingArea *ifs = m_objectTrainingAreaMap.value(request.id());
|
||||
if (ifs == nullptr)
|
||||
{
|
||||
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "Training area with id %1 not found")).arg(request.id());
|
||||
m_mainHandler->dds()->fts()->trainingAreaRemoveReply(cookie, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_mainHandler->dds()->topicLockMaster()->isLocked(ifs->getData(), m_mainHandler->exerciseId()))
|
||||
{
|
||||
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "Training area '%1' is used by another user!")).arg(ifs->getName());
|
||||
m_mainHandler->dds()->fts()->trainingAreaRemoveReply(cookie, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
DBTransaction trans(m_mainHandler->db()->database());
|
||||
|
||||
ret = ifs->removeObject();
|
||||
|
||||
if (ret.error())
|
||||
ERROR_LOG(m_logger) << ret();
|
||||
else
|
||||
{
|
||||
// delete ObjectTrainingArea
|
||||
delete ifs;
|
||||
m_objectTrainingAreaMap.remove(request.id());
|
||||
removeMapDescriptions(request.id());
|
||||
trans.commit();
|
||||
}
|
||||
|
||||
m_mainHandler->dds()->fts()->trainingAreaRemoveReply(cookie, ret);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------
|
||||
void HandlerTrainingArea::onMapDescriptionModifyRequest(const rti::core::SampleIdentity &cookie,
|
||||
const MapDescription &request)
|
||||
{
|
||||
const auto ret = mapDescriptionModifyRequest(request);
|
||||
if (ret.error())
|
||||
WARNING_LOG(m_logger) << ret();
|
||||
m_mainHandler->dds()->fts()->mapDescriptionModifyReply(cookie, ret);
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject HandlerTrainingArea::mapDescriptionModifyRequest(const MapDescription &request)
|
||||
{
|
||||
ObjectMapDescription *ifs = m_objectMapDescriptionMap.value(request.id());
|
||||
|
||||
if (ifs == nullptr)
|
||||
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "MapDescription with id %1 not found")).arg(request.id());
|
||||
|
||||
return ifs->updateObject(request);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------
|
||||
void HandlerTrainingArea::onMapDescriptionRemoveRequest(const rti::core::SampleIdentity &cookie,
|
||||
const Core::RemoveElementRequest &request)
|
||||
{
|
||||
Core::FunctionReplyObject ret;
|
||||
ObjectMapDescription *ifs = m_objectMapDescriptionMap.value(request.id());
|
||||
if (ifs == nullptr)
|
||||
{
|
||||
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "MapDescription with id %1 not found")).arg(request.id());
|
||||
m_mainHandler->dds()->fts()->mapDescriptionRemoveReply(cookie, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_mainHandler->dds()->topicLockMaster()->isLocked(ifs->getData(), m_mainHandler->exerciseId()))
|
||||
{
|
||||
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "MapDescription '%1' is used by another user!")).arg(ifs->getName());
|
||||
m_mainHandler->dds()->fts()->mapDescriptionRemoveReply(cookie, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
ret = ifs->removeObject();
|
||||
|
||||
if (ret.error())
|
||||
ERROR_LOG(m_logger) << ret();
|
||||
else
|
||||
{
|
||||
// delete ObjectMapDescription
|
||||
delete ifs;
|
||||
m_objectMapDescriptionMap.remove(request.id());
|
||||
}
|
||||
|
||||
m_mainHandler->dds()->fts()->mapDescriptionRemoveReply(cookie, ret);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
} // Namespace AssetManagement
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* Handler for all training area objects
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hanna E. Rathje, SLSE, 2016-03-04
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QMap>
|
||||
#include <QVector>
|
||||
#include "asm_db_structs.h"
|
||||
#include "object_map_description.h"
|
||||
|
||||
#include "dds_handler.h"
|
||||
#include "logger.h"
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
class MainHandler;
|
||||
class ObjectTrainingArea;
|
||||
class HandlerTrainingArea final : public QObject
|
||||
, protected Interface::Fts::TrainingAreaModifyRequestHandler
|
||||
, protected Interface::Fts::TrainingAreaRemoveRequestHandler
|
||||
, protected Interface::Fts::MapDescriptionModifyRequestHandler
|
||||
, protected Interface::Fts::MapDescriptionRemoveRequestHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
struct MapDescriptionSeq
|
||||
{
|
||||
QMap <int, Database::AsmMapDescription> map2D;
|
||||
QMap <int, Database::AsmMapDescription> scene3D;
|
||||
QMap <int, Database::AsmMapDescription> elevation;
|
||||
QMap <int, Database::AsmMapDescription> sceneObj;
|
||||
};
|
||||
|
||||
public:
|
||||
explicit HandlerTrainingArea(MainHandler *mainHandler,
|
||||
QObject *parent = nullptr);
|
||||
~HandlerTrainingArea();
|
||||
|
||||
bool init();
|
||||
|
||||
private:
|
||||
void onTrainingAreaModifyRequest(const rti::core::SampleIdentity &cookie,
|
||||
const TrainingArea &request) override;
|
||||
Core::FunctionReplyObject trainingAreaModifyRequest(const TrainingArea &request);
|
||||
void onTrainingAreaRemoveRequest(const rti::core::SampleIdentity &cookie,
|
||||
const Core::RemoveElementRequest &request) override;
|
||||
void removeMapDescriptions(int trainingAreaId);
|
||||
void onMapDescriptionModifyRequest(const rti::core::SampleIdentity &cookie,
|
||||
const MapDescription &request) override;
|
||||
Core::FunctionReplyObject mapDescriptionModifyRequest(const MapDescription &request);
|
||||
void onMapDescriptionRemoveRequest(const rti::core::SampleIdentity &cookie,
|
||||
const Core::RemoveElementRequest &request) override;
|
||||
|
||||
private:
|
||||
QMap<int, ObjectTrainingArea *> m_objectTrainingAreaMap;
|
||||
QMap<int, ObjectMapDescription *> m_objectMapDescriptionMap;
|
||||
MainHandler *m_mainHandler;
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Login Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Chrsitian Roeskens, NLSE, 2018-01-18
|
||||
*/
|
||||
|
||||
#include "handler_workstation_logout.h"
|
||||
#include "main_handler.h"
|
||||
#include "dds_handler.h"
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
|
||||
constexpr int MAX_DATATOPIC_LIFETIME = 10 * 1000; //10 sec
|
||||
|
||||
HandlerWorkstationLogout::HandlerWorkstationLogout(MainHandler *mainHandler, QObject *parent)
|
||||
: QObject(parent)
|
||||
, Interface::Fts::WorkstationLogoutRequestHandler(mainHandler->dds()->fts())
|
||||
, m_logger(getLogger("HandlerWorkstationLogout"))
|
||||
, m_mainHandler(mainHandler)
|
||||
{
|
||||
}
|
||||
|
||||
HandlerWorkstationLogout::~HandlerWorkstationLogout()
|
||||
{
|
||||
qDeleteAll(m_logoutRequestMap);
|
||||
}
|
||||
|
||||
void HandlerWorkstationLogout::onWorkstationLogoutRequest(const rti::core::SampleIdentity &cookie, const WorkstationLogout &request)
|
||||
{
|
||||
if (!m_logoutRequestMap.contains(request.originatorId()))
|
||||
{
|
||||
int originatorId = request.originatorId();
|
||||
|
||||
QTimer *dtLifetimeTimer = new QTimer(this);
|
||||
dtLifetimeTimer->setSingleShot(true);
|
||||
dtLifetimeTimer->start(MAX_DATATOPIC_LIFETIME);
|
||||
|
||||
connect(dtLifetimeTimer, &QTimer::timeout, this,
|
||||
[this, originatorId]()
|
||||
{
|
||||
m_mainHandler->dds()->dts()->removeWorkstationLogoutByKey(originatorId);
|
||||
delete m_logoutRequestMap.take(originatorId);
|
||||
});
|
||||
|
||||
m_logoutRequestMap.insert(originatorId, dtLifetimeTimer);
|
||||
m_mainHandler->dds()->dts()->publish(request);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_logoutRequestMap.value(request.originatorId())->start(MAX_DATATOPIC_LIFETIME);
|
||||
m_mainHandler->dds()->dts()->publish(request);
|
||||
}
|
||||
|
||||
m_mainHandler->dds()->fts()->workstationLogoutReply(cookie, Core::FunctionReplyObject(request.originatorId()));
|
||||
}
|
||||
|
||||
bool HandlerWorkstationLogout::init()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace AssetManagement
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Login Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Chrsitian Roeskens, NLSE, 2018-01-18
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QMap>
|
||||
|
||||
#include "dds_handler.h"
|
||||
#include "logger.h"
|
||||
|
||||
class QTimer;
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
class MainHandler;
|
||||
class HandlerWorkstationLogout final : public QObject
|
||||
, protected Interface::Fts::WorkstationLogoutRequestHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit HandlerWorkstationLogout(MainHandler *mainHandler,
|
||||
QObject *parent = nullptr);
|
||||
~HandlerWorkstationLogout();
|
||||
|
||||
bool init();
|
||||
void onWorkstationLogoutRequest(const rti::core::SampleIdentity &cookie, const WorkstationLogout &request) override final;
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
MainHandler *m_mainHandler;
|
||||
QMap<int, QTimer*> m_logoutRequestMap;
|
||||
};
|
||||
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
log4j.reset=true
|
||||
log4j.rootLogger=WARN, file
|
||||
|
||||
# Service: PlayerManagement
|
||||
###########################################################
|
||||
|
||||
#log4j.logger.ASM=DEBUG
|
||||
#log4j.logger.ASM.main=DEBUG
|
||||
#log4j.logger.ASM.DbHandler=DEBUG
|
||||
#log4j.logger.ASM.DdsHandler=DEBUG
|
||||
#log4j.logger.ASM.MainHandler=DEBUG
|
||||
#log4j.logger.ASM.HandlerMapDescription=DEBUG
|
||||
#log4j.logger.ASM.HandlerTrainingArea=DEBUG
|
||||
#log4j.logger.ASM.ObjectMapDescription=DEBUG
|
||||
#log4j.logger.ASM.ObjectTrainingArea=DEBUG
|
||||
#log4j.logger.ASM.Settings=DEBUG
|
||||
#log4j.logger.ASM.Publisher=DEBUG
|
||||
#log4j.logger.ASM.Fts=DEBUG
|
||||
#log4j.logger.ASM.Test=DEBUG
|
||||
|
||||
# File
|
||||
###########################################################
|
||||
log4j.appender.file=Lts::RollingFileAppender
|
||||
log4j.appender.file.MaxFileSize=1MB
|
||||
log4j.appender.file.MaxBackupIndex=9
|
||||
log4j.appender.file.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.file.layout.ConversionPattern=%d %-5p %c |#| %m (%.50F:%L) %n
|
||||
|
||||
|
||||
# Appnd_Console
|
||||
###########################################################
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern= %d %p %c %c{1} - %m (%-.30F:%L) %n
|
||||
|
||||
|
||||
# Appnd_Syslog
|
||||
###########################################################
|
||||
log4j.appender.syslog=org.apache.log4j.SyslogAppender
|
||||
log4j.appender.syslog.Threshold=ERROR
|
||||
log4j.appender.syslog.SysLogHost=localhost
|
||||
log4j.appender.syslog.Facility=LOCAL7
|
||||
log4j.appender.syslog.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.syslog.layout.ConversionPattern= %-4r %-5p %c %x - %m
|
||||
log4j.appender.syslog.LevelRangeFilter.AcceptOnMatch=true
|
||||
log4j.appender.syslog.LevelRangeFilter.LevelMin=WARN
|
||||
log4j.appender.syslog.LevelRangeFilter.LevelMax=FATAL
|
||||
|
||||
|
||||
###########################################################
|
||||
###########################################################
|
||||
###########################################################
|
||||
# 1) Available Levels in LOG4CXX Version 0.10.0:
|
||||
# TRACE,
|
||||
# DEBUG,
|
||||
# WARN,
|
||||
# WARN,
|
||||
# ERROR
|
||||
# FATAL
|
||||
#
|
||||
# d = date/time
|
||||
# p = priority (Level)
|
||||
# c = category/channel
|
||||
# m = message
|
||||
# F = file
|
||||
# L = line
|
||||
# n = platform dependent line separator character or characters.
|
||||
# ....
|
||||
#
|
||||
# Examples for console:
|
||||
# a)
|
||||
# %d %p %c #%m# (%.50F:%L)%n
|
||||
# date/time
|
||||
# priority
|
||||
# category/channel
|
||||
# #message#
|
||||
# (Maximal 50Character des Filename von rechts:Line)
|
||||
# line separator
|
||||
#
|
||||
# b)
|
||||
# %d (%.15F:%L) %-5p %c |#| %m%n
|
||||
# date/time
|
||||
# (Maximal 15Character des Filename von rechts:Line)
|
||||
# priority, Right pad with spaces if the priority name is less than 5 characters long.
|
||||
# category/channel
|
||||
# message
|
||||
# line separator
|
||||
#
|
||||
# Examples for files:
|
||||
Executable
+37
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Building Config - logging facility
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
|
||||
LOGGER_T getLogger(const char *name)
|
||||
{
|
||||
static const char ns[] = "ASM.";
|
||||
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 AssetManagement
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Logging for AssetManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
#include "asm_export.h"
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
using LOGGER_T = NGL::INGLLogger &;
|
||||
|
||||
ASM_COMMON_EXPORT LOGGER_T getLogger(const char *name);
|
||||
inline LOGGER_T getLogger(const QString &loggerName)
|
||||
{
|
||||
return getLogger(loggerName.toUtf8().constData());
|
||||
}
|
||||
} // namespace AssetManagement
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* main for AssetManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include <nglapplication/nglcoreapplication.h>
|
||||
#include <LtsCommandLineParser/LtsCommandLineParser.h>
|
||||
|
||||
#include "main_handler.h"
|
||||
#include "logger.h"
|
||||
#include "settings.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
NGLCoreApplication app(argc, argv);
|
||||
|
||||
LtsCommandLineParser::LtsCommandLineParser options;
|
||||
if (!options.init())
|
||||
return -1;
|
||||
app.createLogger("ASM", options.exerciseId());
|
||||
|
||||
AssetManagement::Settings::setIniFile(options.iniFile());
|
||||
|
||||
int iRet = -1;
|
||||
{
|
||||
std::unique_ptr<AssetManagement::MainHandler> mainHandler(new AssetManagement::MainHandler);
|
||||
|
||||
if (!mainHandler->init(options.domainId()))
|
||||
return iRet;
|
||||
|
||||
STARTUP_LOG(app.baseLogger());
|
||||
|
||||
iRet = app.exec();
|
||||
|
||||
SHUTDOWN_LOG(app.baseLogger());
|
||||
}
|
||||
|
||||
return iRet;
|
||||
}
|
||||
+171
@@ -0,0 +1,171 @@
|
||||
/**
|
||||
* MainHandler for AssetManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "main_handler.h"
|
||||
|
||||
#include "handler_training_area.h"
|
||||
#include "handler_workstation_logout.h"
|
||||
#include "handler_asset.h"
|
||||
#include "handler_location.h"
|
||||
#include "handler_relay_info.h"
|
||||
#include "settings.h"
|
||||
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
#include <DDS/Core/pacemaker.h>
|
||||
#include <ngldb/db_service_handler.h>
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
|
||||
MainHandler::MainHandler(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_handlerTrainingArea(nullptr)
|
||||
, m_handlerWorkstationLogout(nullptr)
|
||||
, m_handlerAsset(nullptr)
|
||||
, m_handlerLocation(nullptr)
|
||||
, m_handlerRelayInfo(nullptr)
|
||||
, m_ddsHandler(nullptr)
|
||||
, m_dbHandler(nullptr)
|
||||
, m_handlerWebSocket(nullptr)
|
||||
, m_logger(getLogger("MainHandler"))
|
||||
{}
|
||||
|
||||
MainHandler::~MainHandler()
|
||||
{
|
||||
m_handlerTrainingArea = nullptr;
|
||||
m_handlerWorkstationLogout = nullptr;
|
||||
m_handlerAsset = nullptr;
|
||||
m_handlerLocation = nullptr;
|
||||
m_handlerRelayInfo = nullptr;
|
||||
m_handlerWebSocket = nullptr;
|
||||
m_ddsHandler = nullptr;
|
||||
m_dbHandler = nullptr;
|
||||
}
|
||||
|
||||
bool MainHandler::init(int domainId)
|
||||
{
|
||||
// initialize database
|
||||
m_dbHandler = std::make_shared<DbHandler>();
|
||||
|
||||
if (!m_dbHandler->init(0, Settings::settings()))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Initialisation dbHandler failed.";
|
||||
return false;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "Initialisation dbHandler succesful.";
|
||||
|
||||
// initialize DDS
|
||||
m_ddsHandler = std::make_shared<DdsHandler>(domainId);
|
||||
if (!m_ddsHandler->init())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Initialisation ddsHandler failed.";
|
||||
return false;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "Initialisation ddsHandler succesful.";
|
||||
|
||||
// read project specific data from database
|
||||
// publish project specific data
|
||||
// initialize all handlers
|
||||
if (!initAsmHandler())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Initialisation AsmHandler failed.";
|
||||
return false;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "Initialisation AsmHandler succesful.";
|
||||
|
||||
m_ddsHandler->pacemaker()->setNewState(Core::RunningState::Running);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MainHandler::initAsmHandler()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Start Initialisation AsmHandler";
|
||||
|
||||
// TrainingArea
|
||||
m_handlerTrainingArea = std::make_shared<HandlerTrainingArea>(this);
|
||||
DEBUG_LOG(m_logger) << "Reset HandlerTrainingArea succesful.";
|
||||
|
||||
if (!m_handlerTrainingArea->init())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Initialisation of HandlerTrainingArea failed.";
|
||||
return false;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "Initialisation HandlerTrainingArea succesful.";
|
||||
|
||||
// WorkstationLogout
|
||||
m_handlerWorkstationLogout = std::make_shared<HandlerWorkstationLogout>(this);
|
||||
DEBUG_LOG(m_logger) << "Reset HandlerWorkstationLogout succesful.";
|
||||
|
||||
if (!m_handlerWorkstationLogout->init())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Initialisation of HandlerWorkstationLogout failed.";
|
||||
return false;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "Initialisation HandlerWorkstationLogout succesful.";
|
||||
|
||||
// Asset
|
||||
m_handlerAsset = std::make_shared<HandlerAsset>(this);
|
||||
DEBUG_LOG(m_logger) << "Reset HandlerAsset succesful.";
|
||||
|
||||
if (!m_handlerAsset->init())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Initialisation of HandlerAsset failed.";
|
||||
return false;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "Initialisation HandlerAsset succesful.";
|
||||
|
||||
// Location
|
||||
m_handlerLocation = std::make_shared<HandlerLocation>(this);
|
||||
DEBUG_LOG(m_logger) << "Reset HandlerLocation succesful.";
|
||||
|
||||
if (!m_handlerLocation->init())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Initialisation of HandlerLocation failed.";
|
||||
return false;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "Initialisation HandlerLocation succesful.";
|
||||
|
||||
// RelayInfo
|
||||
m_handlerRelayInfo = std::make_shared<HandlerRelayInfo>(this);
|
||||
DEBUG_LOG(m_logger) << "Reset HandlerRelayInfo succesful.";
|
||||
|
||||
if (!m_handlerRelayInfo->init())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Initialisation of HandlerRelayInfo failed.";
|
||||
return false;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "Initialisation HandlerRelayInfo succesful.";
|
||||
|
||||
// WebSocketServer
|
||||
m_handlerWebSocket = std::make_shared<WebSocketInterface::WebSocketInterfaceHandler>(this);
|
||||
DEBUG_LOG(m_logger) << "Reset WebSocketInterfaceHandler succesful.";
|
||||
if (!m_handlerWebSocket->init())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Initialisation WebSocketInterfaceHandler failed.";
|
||||
return false;
|
||||
}
|
||||
m_ddsHandler->pacemaker()->addPort(m_handlerWebSocket->serverWebSocketPort(), Core::PortType::WebSocketServer);
|
||||
DEBUG_LOG(m_logger) << "Initialisation WebSocketInterfaceHandler succesful.";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<DatabaseInterface> MainHandler::db() const
|
||||
{
|
||||
return m_dbHandler->db();
|
||||
}
|
||||
|
||||
int MainHandler::exerciseId() const
|
||||
{
|
||||
if (dds())
|
||||
return dds()->ddsConnector()->getPartitionId();
|
||||
return -1;
|
||||
}
|
||||
|
||||
} // namespace Assetmanagement
|
||||
Executable
+62
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* MainHandler for AereaEffectSimulation
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <memory>
|
||||
|
||||
#include "dds_handler.h"
|
||||
#include "asm_db.h"
|
||||
#include "WebSocketInterface/websocket_interface_handler.h"
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
|
||||
namespace NGLDB
|
||||
{
|
||||
template <typename DB> class DbServiceHandler;
|
||||
}
|
||||
namespace AssetManagement
|
||||
{
|
||||
using DbHandler = NGLDB::DbServiceHandler<DatabaseInterface>;
|
||||
//class HandlerMapDescription;
|
||||
class HandlerTrainingArea;
|
||||
class HandlerWorkstationLogout;
|
||||
class HandlerAsset;
|
||||
class HandlerLocation;
|
||||
class HandlerRelayInfo;
|
||||
class MainHandler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MainHandler(QObject *parent = nullptr);
|
||||
~MainHandler();
|
||||
|
||||
bool init(int domainId);
|
||||
|
||||
std::shared_ptr<DdsHandler> dds() const { return m_ddsHandler; }
|
||||
std::shared_ptr<DatabaseInterface> db() const;
|
||||
|
||||
int exerciseId() const;
|
||||
|
||||
private:
|
||||
bool initAsmHandler();
|
||||
private:
|
||||
// std::shared_ptr<HandlerMapDescription> m_handlerMapDesc;
|
||||
std::shared_ptr<HandlerTrainingArea> m_handlerTrainingArea;
|
||||
std::shared_ptr<HandlerWorkstationLogout> m_handlerWorkstationLogout;
|
||||
std::shared_ptr<HandlerAsset> m_handlerAsset;
|
||||
std::shared_ptr<HandlerLocation> m_handlerLocation;
|
||||
std::shared_ptr<HandlerRelayInfo> m_handlerRelayInfo;
|
||||
std::shared_ptr<DdsHandler> m_ddsHandler;
|
||||
std::shared_ptr<DbHandler> m_dbHandler;
|
||||
std::shared_ptr<WebSocketInterface::WebSocketInterfaceHandler> m_handlerWebSocket;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
};
|
||||
} // namespace AssetManagement
|
||||
+169
@@ -0,0 +1,169 @@
|
||||
/**
|
||||
* Asset object
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Iuliana Ojog, SLSE, 2017-09-20
|
||||
*/
|
||||
|
||||
#include "object_asset.h"
|
||||
#include "main_handler.h"
|
||||
|
||||
#include <LtsUtils/LtsUtilsCore/dds_vector.h>
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
namespace AssetManagement
|
||||
{
|
||||
ObjectAsset::ObjectAsset(MainHandler *mainHandler)
|
||||
: m_mainHandler(mainHandler)
|
||||
, m_logger(getLogger("ObjectAsset"))
|
||||
{
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
ObjectAsset::~ObjectAsset()
|
||||
{
|
||||
if (isValid())
|
||||
m_mainHandler->dds()->dts()->removeAssetByKey(m_data.id());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool ObjectAsset::isValid() const
|
||||
{
|
||||
return m_data.id() > 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool ObjectAsset::isUsed() const
|
||||
{
|
||||
return m_data.isUsed();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Core::FunctionReplyObject ObjectAsset::createObject(const Asset &data)
|
||||
{
|
||||
m_data = data;
|
||||
|
||||
if (m_data.id() <= 0)
|
||||
{
|
||||
m_data.isUsed(false);
|
||||
|
||||
Database::AsmAsset dbData(toDbData(data));
|
||||
|
||||
if (!m_mainHandler->db()->insert(dbData))
|
||||
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting AsmAsset-data into database"));
|
||||
|
||||
m_data.id(dbData.id);
|
||||
DEBUG_LOG(m_logger) << "New assetId: " << m_data.id();
|
||||
}
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Core::FunctionReplyObject ObjectAsset::updateObject(const Asset &data)
|
||||
{
|
||||
if (!isValid())
|
||||
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Object not valid/blocked"));
|
||||
|
||||
Database::AsmAsset dbData;
|
||||
dbData = toDbData(data);
|
||||
|
||||
if (!m_mainHandler->db()->update(dbData))
|
||||
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Error updating AsmAsset-data into database"));
|
||||
|
||||
m_data = data;
|
||||
DEBUG_LOG(m_logger) << "Data changed for assetId: " << m_data.id();
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Core::FunctionReplyObject ObjectAsset::setUsed(bool isUsed)
|
||||
{
|
||||
if (!isValid())
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "Trying to update an already removed AsmAsset object"));
|
||||
|
||||
m_data.isUsed(isUsed);
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Core::FunctionReplyObject ObjectAsset::removeObject()
|
||||
{
|
||||
if (isUsed())
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "Asset still in use"));
|
||||
|
||||
if (!m_mainHandler->db()->removeAsmAsset(m_data.id()))
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "Asset with id %1 can not be removed from DB")).arg(m_data.id());
|
||||
|
||||
if (!m_mainHandler->dds()->dts()->removeAssetByKey(m_data.id()))
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "Asset with id %1 can not be removed from DDS")).arg(m_data.id());
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void ObjectAsset::onPublishData()
|
||||
{
|
||||
INFO_LOG(m_logger) << "Publish AsmAsset-data to dds (" << m_data.id() << ") ...";
|
||||
|
||||
if (!m_mainHandler->dds()->dts()->publish(m_data))
|
||||
ERROR_LOG(m_logger) << "Error publishing AsmAsset-data to dds";
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
// convert methods
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
|
||||
// AssetManagement::Asset => Database::AsmAsset
|
||||
Database::AsmAsset ObjectAsset::toDbData(const Asset &ddsData)
|
||||
{
|
||||
Database::AsmAsset dbData;
|
||||
|
||||
dbData.id = ddsData.id();
|
||||
dbData.name = QString::fromStdString(ddsData.name());
|
||||
dbData.assetTypeId = ddsData.assetTypeId();
|
||||
dbData.locationId = ddsData.locationId();
|
||||
dbData.subLocation = ddsData.subLocation();
|
||||
dbData.certificate = LtsUtils::toQByteArray(ddsData.certificate());
|
||||
dbData.properties = QString::fromStdString(ddsData.properties());
|
||||
|
||||
return dbData;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
// Database::AsmAsset => AssetManagement::Asset
|
||||
Asset ObjectAsset::toDdsData(const Database::AsmAsset &dbData)
|
||||
{
|
||||
Asset ddsData;
|
||||
|
||||
ddsData.id(dbData.id);
|
||||
ddsData.name(dbData.name.toStdString());
|
||||
ddsData.assetTypeId(dbData.assetTypeId);
|
||||
ddsData.locationId(dbData.locationId);
|
||||
ddsData.subLocation(dbData.subLocation);
|
||||
ddsData.certificate(LtsUtils::convert<std::vector<uint8_t>>(dbData.certificate));
|
||||
ddsData.properties(dbData.properties.toStdString());
|
||||
|
||||
// init data not in db
|
||||
ddsData.isDeleted(false);
|
||||
ddsData.isUsed(false);
|
||||
|
||||
return ddsData;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
|
||||
} // Namespace AssetManagement
|
||||
Executable
+58
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* Asset object
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Iuliana Ojog, SLSE, 2017-09-20
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "dds_handler.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include <DDS/Core/function_reply_object.h>
|
||||
|
||||
// Generated
|
||||
#include <AssetManagement/asm_db.h>
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
class INGLLogger;
|
||||
}
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
class MainHandler;
|
||||
|
||||
class ObjectAsset
|
||||
{
|
||||
public:
|
||||
explicit ObjectAsset(MainHandler *mainHandler);
|
||||
~ObjectAsset();
|
||||
|
||||
Core::FunctionReplyObject createObject(const Asset &data);
|
||||
Core::FunctionReplyObject updateObject(const Asset &data);
|
||||
Core::FunctionReplyObject removeObject();
|
||||
|
||||
qint32 getId() const { return m_data.id(); }
|
||||
QString getName() const { return QString::fromStdString(m_data.name()); }
|
||||
const Asset &getData() const { return m_data; }
|
||||
|
||||
bool isValid() const;
|
||||
bool isUsed() const;
|
||||
Core::FunctionReplyObject setUsed(bool isUsed);
|
||||
|
||||
// convert methods
|
||||
static Database::AsmAsset toDbData(const Asset &ddsData); // dds -> db
|
||||
static Asset toDdsData(const Database::AsmAsset &dbData); // db -> dds
|
||||
|
||||
protected:
|
||||
void onPublishData();
|
||||
|
||||
private:
|
||||
MainHandler *m_mainHandler;
|
||||
Asset m_data;
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
};
|
||||
}
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
/**
|
||||
* Map description object
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hanna E. Rathje, SLSE, 2016-03-03
|
||||
*/
|
||||
|
||||
#include "object_map_description.h"
|
||||
|
||||
#include "main_handler.h"
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
ObjectMapDescription::ObjectMapDescription(MainHandler *mainHandler)
|
||||
: m_mainHandler(mainHandler)
|
||||
, m_order(-1)
|
||||
, m_logger(getLogger("ObjectMapDescription"))
|
||||
{
|
||||
}
|
||||
|
||||
bool ObjectMapDescription::isValid() const
|
||||
{
|
||||
return m_data.id() > 0;
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectMapDescription::createObject(const MapDescription &data, int order)
|
||||
{
|
||||
m_data = data;
|
||||
|
||||
if (m_data.id() <= 0)
|
||||
{
|
||||
m_data.isUsed(false);
|
||||
|
||||
Database::AsmMapDescription dbData(toDbData(data));
|
||||
dbData.objOrder = order;
|
||||
|
||||
if (!m_mainHandler->db()->insert(dbData))
|
||||
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting AsmMapDescription-data into database"));
|
||||
|
||||
m_data.id(dbData.id);
|
||||
DEBUG_LOG(m_logger) << "New MapDescription Id: " << m_data.id();
|
||||
}
|
||||
else if (order != m_order && m_order >= 0)
|
||||
{
|
||||
Database::AsmMapDescription dbData(toDbData(data));
|
||||
dbData.objOrder = m_order;
|
||||
if (!m_mainHandler->db()->update(dbData))
|
||||
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Error updating AsmMapDescription-data into database"));
|
||||
}
|
||||
m_order = order;
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectMapDescription::updateObject(const MapDescription &data)
|
||||
{
|
||||
if (!isValid())
|
||||
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Object not valid/blocked"));
|
||||
|
||||
Database::AsmMapDescription dbData(toDbData(data));
|
||||
dbData.objOrder = m_order;
|
||||
|
||||
if (!m_mainHandler->db()->update(dbData))
|
||||
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Error updating AsmMapDescription-data into database"));
|
||||
|
||||
m_data = data;
|
||||
DEBUG_LOG(m_logger) << "Data changed for MapDescription Id: " << m_data.id();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectMapDescription::removeObject()
|
||||
{
|
||||
if (!m_mainHandler->db()->removeAsmMapDescription(m_data.id()))
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "MapDescription with id %1 can not be removed")).arg(m_data.id());
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
// convert methods
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
|
||||
// AssetManagement::MapDescription => Database::AsmMapDescription
|
||||
Database::AsmMapDescription ObjectMapDescription::toDbData(const MapDescription &ddsData)
|
||||
{
|
||||
Database::AsmMapDescription dbData;
|
||||
|
||||
dbData.id = ddsData.id();
|
||||
dbData.name = QString::fromStdString(ddsData.name());
|
||||
dbData.description = QString::fromStdString(ddsData.description());
|
||||
dbData.trainingAreaId = ddsData.trainingAreaId();
|
||||
dbData.mapTypeId = ddsData.mapTypeId();
|
||||
dbData.mapDescriptionTypeId = ddsData.mapDescriptionTypeId();
|
||||
dbData.url = QString::fromStdString(ddsData.url());
|
||||
dbData.minScale = ddsData.minScale();
|
||||
dbData.maxScale = ddsData.maxScale();
|
||||
|
||||
return dbData;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
// Database::AsmMapDescription => AssetManagement::MapDescription
|
||||
MapDescription ObjectMapDescription::toDdsData(const Database::AsmMapDescription &dbData)
|
||||
{
|
||||
MapDescription ddsData;
|
||||
|
||||
ddsData.id(dbData.id);
|
||||
ddsData.name(dbData.name.toStdString());
|
||||
ddsData.description(dbData.description.toStdString());
|
||||
ddsData.trainingAreaId(dbData.trainingAreaId);
|
||||
ddsData.mapTypeId(dbData.mapTypeId);
|
||||
ddsData.mapDescriptionTypeId(dbData.mapDescriptionTypeId);
|
||||
ddsData.url(dbData.url.toStdString());
|
||||
ddsData.minScale(dbData.minScale);
|
||||
ddsData.maxScale(dbData.maxScale);
|
||||
|
||||
// init data not in db
|
||||
ddsData.isDeleted(false);
|
||||
ddsData.isUsed(false);
|
||||
|
||||
return ddsData;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
|
||||
} // Namespace AssetManagement
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Map description object
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hanna E. Rathje, SLSE, 2016-03-03
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "logger.h"
|
||||
#include <DDS/Core/function_reply_object.h>
|
||||
|
||||
// Generated
|
||||
#include <AssetManagement/asm_db.h>
|
||||
#include <AssetManagement/asm.hpp>
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
class MainHandler;
|
||||
|
||||
class ObjectMapDescription
|
||||
{
|
||||
public:
|
||||
explicit ObjectMapDescription(MainHandler *mainHandler);
|
||||
|
||||
Core::FunctionReplyObject createObject(const MapDescription &data, int order);
|
||||
Core::FunctionReplyObject updateObject(const MapDescription &data);
|
||||
Core::FunctionReplyObject removeObject();
|
||||
|
||||
qint32 getId() const { return m_data.id(); }
|
||||
QString getName() const { return QString::fromStdString(m_data.name()); }
|
||||
const MapDescription &getData() const { return m_data; }
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
// convert methods
|
||||
static Database::AsmMapDescription toDbData(const MapDescription &ddsData); // dds -> db
|
||||
static MapDescription toDdsData(const Database::AsmMapDescription &dbData); // db -> dds
|
||||
|
||||
private:
|
||||
MainHandler *m_mainHandler;
|
||||
MapDescription m_data;
|
||||
int m_order;
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
}
|
||||
+164
@@ -0,0 +1,164 @@
|
||||
/**
|
||||
* Asset object
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Iuliana Ojog, SLSE, 2017-09-20
|
||||
*/
|
||||
|
||||
#include "object_relay_info.h"
|
||||
#include "main_handler.h"
|
||||
|
||||
#include <LtsUtils/LtsUtilsCore/dds_vector.h>
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
namespace AssetManagement
|
||||
{
|
||||
ObjectRelayInfo::ObjectRelayInfo(MainHandler *mainHandler)
|
||||
: m_mainHandler(mainHandler)
|
||||
, m_logger(getLogger("ObjectRelayInfo"))
|
||||
{
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
ObjectRelayInfo::~ObjectRelayInfo()
|
||||
{
|
||||
if (isValid())
|
||||
m_mainHandler->dds()->dts()->removeRelayInfoByKey(m_data.id());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool ObjectRelayInfo::isValid() const
|
||||
{
|
||||
return m_data.id() > 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool ObjectRelayInfo::isUsed() const
|
||||
{
|
||||
return m_data.isUsed();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Core::FunctionReplyObject ObjectRelayInfo::createObject(const RelayInfo &data)
|
||||
{
|
||||
m_data = data;
|
||||
|
||||
if (m_data.id() < 0)
|
||||
{
|
||||
m_data.isUsed(false);
|
||||
|
||||
Database::AsmEgcuRelayInfo dbData(toDbData(data));
|
||||
|
||||
if (!m_mainHandler->db()->insert(dbData))
|
||||
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting AsmEgcuRelayInfo-data into database"));
|
||||
|
||||
m_data.id(dbData.id);
|
||||
DEBUG_LOG(m_logger) << "New relayInfo Id: " << m_data.id();
|
||||
}
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Core::FunctionReplyObject ObjectRelayInfo::updateObject(const RelayInfo &data)
|
||||
{
|
||||
if (!isValid())
|
||||
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Object not valid/blocked"));
|
||||
|
||||
Database::AsmEgcuRelayInfo dbData;
|
||||
dbData = toDbData(data);
|
||||
|
||||
if (!m_mainHandler->db()->update(dbData))
|
||||
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Error updating AsmEgcuRelayInfo-data into database"));
|
||||
|
||||
m_data = data;
|
||||
DEBUG_LOG(m_logger) << "Data changed for relayInfo Id: " << m_data.id();
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Core::FunctionReplyObject ObjectRelayInfo::setUsed(bool isUsed)
|
||||
{
|
||||
if (!isValid())
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "Trying to update an already removed AsmEgcuRelayInfo object"));
|
||||
|
||||
m_data.isUsed(isUsed);
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Core::FunctionReplyObject ObjectRelayInfo::removeObject()
|
||||
{
|
||||
if (isUsed())
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "RelayInfo still in use"));
|
||||
|
||||
if (!m_mainHandler->db()->removeAsmEgcuRelayInfo(m_data.id()))
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "RelayInfo with id %1 can not be removed from DB")).arg(m_data.id());
|
||||
|
||||
if (!m_mainHandler->dds()->dts()->removeRelayInfoByKey(m_data.id()))
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "RelayInfo with id %1 can not be removed from DDS")).arg(m_data.id());
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void ObjectRelayInfo::onPublishData()
|
||||
{
|
||||
INFO_LOG(m_logger) << "Publish AsmEgcuRelayInfo-data to dds (" << m_data.id() << ") ...";
|
||||
|
||||
if (!m_mainHandler->dds()->dts()->publish(m_data))
|
||||
ERROR_LOG(m_logger) << "Error publishing AsmEgcuRelayInfo-data to dds";
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
// convert methods
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
|
||||
// AssetManagement::RelayInfo => Database::AsmEgcuRelayInfo
|
||||
Database::AsmEgcuRelayInfo ObjectRelayInfo::toDbData(const RelayInfo &ddsData)
|
||||
{
|
||||
Database::AsmEgcuRelayInfo dbData;
|
||||
|
||||
dbData.id = ddsData.id();
|
||||
dbData.relayId = ddsData.id();
|
||||
dbData.name = QString::fromStdString(ddsData.name());
|
||||
dbData.description = QString::fromStdString(ddsData.description());
|
||||
dbData.properties = QString::fromStdString(ddsData.property());
|
||||
|
||||
return dbData;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
// Database::AsmEgcuRelayInfo => AssetManagement::RelayInfo
|
||||
RelayInfo ObjectRelayInfo::toDdsData(const Database::AsmEgcuRelayInfo &dbData)
|
||||
{
|
||||
RelayInfo ddsData;
|
||||
|
||||
ddsData.id(dbData.relayId);
|
||||
ddsData.name(dbData.name.toStdString());
|
||||
ddsData.description(dbData.description.toStdString());
|
||||
ddsData.property(dbData.properties.toStdString());
|
||||
|
||||
// init data not in db
|
||||
ddsData.isDeleted(false);
|
||||
ddsData.isUsed(false);
|
||||
|
||||
return ddsData;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
|
||||
} // Namespace AssetManagement
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* Asset object
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Iuliana Ojog, SLSE, 2017-09-20
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "dds_handler.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include <DDS/Core/function_reply_object.h>
|
||||
|
||||
// Generated
|
||||
#include <AssetManagement/asm_db.h>
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
class INGLLogger;
|
||||
}
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
class MainHandler;
|
||||
|
||||
class ObjectRelayInfo
|
||||
{
|
||||
public:
|
||||
explicit ObjectRelayInfo(MainHandler *mainHandler);
|
||||
~ObjectRelayInfo();
|
||||
|
||||
Core::FunctionReplyObject createObject(const RelayInfo &data);
|
||||
Core::FunctionReplyObject updateObject(const RelayInfo &data);
|
||||
Core::FunctionReplyObject removeObject();
|
||||
|
||||
qint32 getId() const { return m_data.id(); }
|
||||
QString getName() const { return QString::fromStdString(m_data.name()); }
|
||||
const RelayInfo &getData() const { return m_data; }
|
||||
|
||||
bool isValid() const;
|
||||
bool isUsed() const;
|
||||
Core::FunctionReplyObject setUsed(bool isUsed);
|
||||
|
||||
// convert methods
|
||||
static Database::AsmEgcuRelayInfo toDbData(const RelayInfo &ddsData); // dds -> db
|
||||
static RelayInfo toDdsData(const Database::AsmEgcuRelayInfo &dbData); // db -> dds
|
||||
|
||||
protected:
|
||||
void onPublishData();
|
||||
|
||||
private:
|
||||
MainHandler *m_mainHandler;
|
||||
RelayInfo m_data;
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
};
|
||||
}
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
/**
|
||||
* * TrainingArea object
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hanna E. Rathje, SLSE, 2016-03-04
|
||||
*/
|
||||
|
||||
#include "object_training_area.h"
|
||||
|
||||
#include "main_handler.h"
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
namespace AssetManagement
|
||||
{
|
||||
ObjectTrainingArea::ObjectTrainingArea(MainHandler *mainHandler)
|
||||
: m_mainHandler(mainHandler)
|
||||
, m_logger(getLogger("ObjectTrainingArea"))
|
||||
{
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
ObjectTrainingArea::~ObjectTrainingArea()
|
||||
{
|
||||
if (isValid())
|
||||
m_mainHandler->dds()->dts()->removeTrainingAreaByKey(m_data.id());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool ObjectTrainingArea::isValid() const
|
||||
{
|
||||
return m_data.id() > 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool ObjectTrainingArea::isUsed() const
|
||||
{
|
||||
return m_data.isUsed();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Core::FunctionReplyObject ObjectTrainingArea::createObject(const TrainingArea &data)
|
||||
{
|
||||
m_data = data;
|
||||
|
||||
if (m_data.id() <= 0)
|
||||
{
|
||||
m_data.isUsed(false);
|
||||
|
||||
Database::AsmTrainingArea dbData(toDbData(data));
|
||||
|
||||
if (!m_mainHandler->db()->insert(dbData))
|
||||
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting AsmTrainingArea-data into database"));
|
||||
|
||||
m_data.id(dbData.id);
|
||||
DEBUG_LOG(m_logger) << "New mapId: " << m_data.id();
|
||||
}
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Core::FunctionReplyObject ObjectTrainingArea::updateObject(const TrainingArea &data)
|
||||
{
|
||||
if (!isValid())
|
||||
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Object not valid/blocked"));
|
||||
|
||||
Database::AsmTrainingArea dbData;
|
||||
dbData = toDbData(data);
|
||||
|
||||
if (!m_mainHandler->db()->update(dbData))
|
||||
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Error updating AsmTrainingArea-data into database"));
|
||||
|
||||
m_data = data;
|
||||
DEBUG_LOG(m_logger) << "Data changed for mapId: " << m_data.id();
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Core::FunctionReplyObject ObjectTrainingArea::setUsed(bool isUsed)
|
||||
{
|
||||
if (!isValid())
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "Trying to update an already removed AsmTrainingArea object"));
|
||||
|
||||
m_data.isUsed(isUsed);
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Core::FunctionReplyObject ObjectTrainingArea::removeObject()
|
||||
{
|
||||
if (isUsed())
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "TrainingArea still in use"));
|
||||
|
||||
if (!m_mainHandler->db()->removeAsmTrainingArea(m_data.id()))
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "TrainingArea with id %1 can not be removed from DB")).arg(m_data.id());
|
||||
|
||||
if (!m_mainHandler->dds()->dts()->removeTrainingAreaByKey(m_data.id()))
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "TrainingArea with id %1 can not be removed from DDS")).arg(m_data.id());
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void ObjectTrainingArea::onPublishData()
|
||||
{
|
||||
INFO_LOG(m_logger) << "Publish AsmTrainingArea-data to dds (" << m_data.id() << ") ...";
|
||||
|
||||
if (!m_mainHandler->dds()->dts()->publish(m_data))
|
||||
ERROR_LOG(m_logger) << "Error publishing AsmTrainingArea-data to dds";
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
// convert methods
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
|
||||
// AssetManagement::TrainingArea => Database::AsmTrainingArea
|
||||
Database::AsmTrainingArea ObjectTrainingArea::toDbData(const TrainingArea &ddsData)
|
||||
{
|
||||
Database::AsmTrainingArea dbData;
|
||||
|
||||
dbData.id = ddsData.id();
|
||||
dbData.name = QString::fromStdString(ddsData.name());
|
||||
dbData.bottomLeft = QPointF(ddsData.bottomLeft().lon(), ddsData.bottomLeft().lat());
|
||||
dbData.height = ddsData.height();
|
||||
dbData.width = ddsData.width();
|
||||
|
||||
dbData.image = QByteArray::fromRawData(reinterpret_cast<const char *>(&ddsData.image()[0]), ddsData.image().size());
|
||||
|
||||
return dbData;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
|
||||
} // Namespace AssetManagement
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* TrainingArea object
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hanna E. Rathje, SLSE, 2016-03-04
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include "dds_handler.h"
|
||||
#include "logger.h"
|
||||
#include <DDS/Core/function_reply_object.h>
|
||||
|
||||
// Generated
|
||||
#include <AssetManagement/asm_db.h>
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
class INGLLogger;
|
||||
}
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
class MainHandler;
|
||||
|
||||
class ObjectTrainingArea
|
||||
{
|
||||
public:
|
||||
explicit ObjectTrainingArea(MainHandler *mainHandler);
|
||||
~ObjectTrainingArea();
|
||||
|
||||
Core::FunctionReplyObject createObject(const TrainingArea &data);
|
||||
Core::FunctionReplyObject updateObject(const TrainingArea &data);
|
||||
Core::FunctionReplyObject removeObject();
|
||||
|
||||
qint32 getId() const { return m_data.id(); }
|
||||
QString getName() const { return QString::fromStdString(m_data.name()); }
|
||||
const TrainingArea &getData() const { return m_data; }
|
||||
|
||||
bool isValid() const;
|
||||
bool isUsed() const;
|
||||
Core::FunctionReplyObject setUsed(bool isUsed);
|
||||
|
||||
// convert methods
|
||||
static Database::AsmTrainingArea toDbData(const TrainingArea &ddsData); // dds -> db
|
||||
|
||||
protected:
|
||||
void onPublishData();
|
||||
|
||||
private:
|
||||
MainHandler *m_mainHandler;
|
||||
TrainingArea m_data;
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
};
|
||||
}
|
||||
Executable
+55
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* Settings for AssetManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "settings.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include <QtCore/QSettings>
|
||||
#include <nglsettings/nglsettings_settings.h>
|
||||
#include <ngltools/ngltools_filesystem.h>
|
||||
|
||||
#include "LtsUtils/LtsUtilsCore/lts_portrange.h"
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QPair<quint16, quint16> Settings::getWebSocketServerPortRange(int type)
|
||||
{
|
||||
return LtsUtils::fromQPoint(settings()->settings()->value(QString(QStringLiteral("ASM/webSocketServerPortRange/%1")).arg(type), QPoint()).toPoint());
|
||||
}
|
||||
|
||||
} // namespace AssetManagement
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Settings for AssetManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <QString>
|
||||
#include <QPair>
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
class Settings;
|
||||
}
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
|
||||
namespace Settings
|
||||
{
|
||||
|
||||
//!< The real NGL::Settings - object
|
||||
NGL::Settings *settings();
|
||||
void setIniFile(const QString &ini);
|
||||
QPair<quint16, quint16> getWebSocketServerPortRange(int type);
|
||||
}
|
||||
|
||||
} // namespace AssetManagement
|
||||
Reference in new issue
Block a user