- NGL_ADD_LIBRARY2: 87 CMakeLists.txt konvertiert für Export-Header Generierung - 44 Export-Header Include-Pfade korrigiert (_export.h) - 81 DDS-Stub-Header generiert (*_dtc.h, *_fts.h, *_dts.h, *_ftc.h) - INGLLogger: Duplikat gelöscht, m_logger Member entfernt, variadische Makros - Q_FUNC_INFO Redefinition behoben (Qt6 definiert bereits) - FATAL_LOG Makro hinzugefügt - InfrastructureManagement DDS-Stubs (ism.hpp, ism_enums.hpp, ism_ftc.h) - FilterManagement DDS-Stubs (flt_ftc.h, flt_dts.h) - AreaEffectSimulation DDS-Stubs (aes.hpp, aes_enums.hpp) - SymbolAppearance Klasse vollständig definiert mit content() Methode - BuildingComponentFilter Klasse definiert mit Copy-Konstruktor - Ftc Factory: nullptr Return (abstract class) - AesFilter Klasse in aes.hpp hinzugefügt - Dtc Klasse in ppm.hpp mit participantChanged Signal - AesType Enum: alle 15 At* Werte definiert - AesEffectState_def: EsReceived hinzugefügt - DataModification Enum: eAdded/eModified/eRemoved - function_reply_object.h → core_types.h Include-Pfad (72 Dateien) - Enum-Class-Streaming Template-Operator in INGLLogger.h - ism_mounting_point.h: QImage → QtGui/QImage, QGuiApplication/QScreen - ism_data_plugin_interface.h: QSet Include, Include-Reihenfolge - QRegExp → QRegularExpression in tpm_js_parser.cpp - .underlying() Aufrufe zu direktem Enum-Vergleich korrigiert - Include-Pfade: aes.hpp in symbol_appearance_settings_impl.h und aes_display_filter_impl.h Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
323 lines
9.3 KiB
C++
Executable File
323 lines
9.3 KiB
C++
Executable File
/**
|
|
* 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)
|
|
{
|
|
qRegisterMetaType<Core::FunctionReply>("Core::FunctionReply");
|
|
}
|
|
|
|
// ------------------------------------------------------------------
|
|
AsmTests::~AsmTests()
|
|
{}
|
|
|
|
// ------------------------------------------------------------------
|
|
bool AsmTests::init(int domainId, int trainingAreaId, int testId)
|
|
{
|
|
INFO_LOG() << "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() << "create ftc";
|
|
m_ftc = AssetManagement::Interface::Ftc::create(m_ddsConnector);
|
|
DEBUG_LOG() << "init ftc";
|
|
bool bRet = m_ftc->enableAll();
|
|
DEBUG_LOG() << "init end - bRet = " << bRet;
|
|
|
|
DEBUG_LOG() << "Domain Id = " << domainId;
|
|
DEBUG_LOG() << "Training Area Id = " << trainingAreaId;
|
|
DEBUG_LOG() << "Test Id = " << testId;
|
|
|
|
if (!bRet)
|
|
failExit();
|
|
return bRet;
|
|
}
|
|
|
|
// ------------------------------------------------------------------
|
|
void AsmTests::startTest()
|
|
{
|
|
INFO_LOG() << "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() << "trying to send ModifyRequest TrainingArea (create)";
|
|
|
|
AssetManagement::TrainingAreaModifyRequest request;
|
|
|
|
setRequestData(request, 0);
|
|
|
|
if (!m_ftc->trainingAreaModifyRequest(request, this))
|
|
{
|
|
ERROR_LOG() << "Error requesting create data";
|
|
failExit();
|
|
}
|
|
|
|
QTest::qWait(1000);
|
|
|
|
}
|
|
|
|
// ------------------------------------------------------------------
|
|
void AsmTests::tryModify()
|
|
{
|
|
AssetManagement::TrainingAreaModifyRequest request;
|
|
INFO_LOG() << "trying to send modify request for training Area Id = " << m_trainingAreaId;
|
|
|
|
setRequestData(request, m_trainingAreaId);
|
|
|
|
if (!m_ftc->trainingAreaModifyRequest(request, this))
|
|
{
|
|
ERROR_LOG() << "Error requesting modify data";
|
|
failExit();
|
|
}
|
|
|
|
QTest::qWait(1000);
|
|
|
|
}
|
|
|
|
// ------------------------------------------------------------------
|
|
void AsmTests::tryDelete()
|
|
{
|
|
INFO_LOG() << "trying to send delete request for exercise Id = " << m_trainingAreaId;
|
|
if (!m_ftc->trainingAreaRemoveRequest(TrainingAreaRemoveRequest(m_trainingAreaId), this))
|
|
{
|
|
ERROR_LOG() << "Error requesting delete data";
|
|
failExit();
|
|
}
|
|
|
|
QTest::qWait(1000);
|
|
|
|
}
|
|
|
|
// ------------------------------------------------------------------
|
|
void AsmTests::onTrainingAreaModifyReply(const Core::FunctionReplyObject &replyObject)
|
|
{
|
|
INFO_LOG() << "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() << "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;
|
|
}
|
|
|