- 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>
191 lines
5.2 KiB
C++
Executable File
191 lines
5.2 KiB
C++
Executable File
/**
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Philipp Last, NLSE, 2018-01-11
|
|
*/
|
|
|
|
#include "handler_san_nine_liner.h"
|
|
#include <utility>
|
|
#include "object_san_nine_liner.h"
|
|
#include "object_san_category_line.h"
|
|
#include "san_category_line_json.h"
|
|
#include <LtsCoordTrans/lts_coord_trans.h>
|
|
|
|
#include "settings.h"
|
|
|
|
#include <QJsonDocument>
|
|
|
|
namespace Evaluations
|
|
{
|
|
|
|
HandlerSanNineLiner::HandlerSanNineLiner(const std::shared_ptr<DdsHandler> &ddsHandler,
|
|
const std::shared_ptr<DatabaseInterface> &db)
|
|
: Interface::Fts::SanNineLinerModifyRequestHandler(ddsHandler->fts())
|
|
, Interface::Fts::SanNineLinerRemoveRequestHandler(ddsHandler->fts())
|
|
, m_ddsHandler(ddsHandler)
|
|
, m_db(db)
|
|
{}
|
|
|
|
HandlerSanNineLiner::~HandlerSanNineLiner()
|
|
{
|
|
qDeleteAll(m_mapObjectSanNineLiner);
|
|
}
|
|
|
|
bool HandlerSanNineLiner::init()
|
|
{
|
|
bool bRet = true;
|
|
// Comment
|
|
auto cbSanNineLiner = [this, &bRet] (const Database::SanNineLiner &data)
|
|
{
|
|
ObjectSanNineLiner *ifs(new ObjectSanNineLiner(m_ddsHandler, m_db));
|
|
Core::FunctionReplyObject ret = ifs->createObject(data);
|
|
if (ret.error())
|
|
{
|
|
delete ifs;
|
|
ERROR_LOG() << ret();
|
|
bRet = false;
|
|
return;
|
|
}
|
|
m_mapObjectSanNineLiner.insert(ifs->getId(), ifs);
|
|
};
|
|
if (!m_db->select(cbSanNineLiner) || !bRet)
|
|
{
|
|
ERROR_LOG() << "Error reading data from database!";
|
|
return false;
|
|
}
|
|
|
|
// add categoryLine to sanNineLiner object
|
|
auto cb = [this] (const Database::SanCategoryLine &data)
|
|
{
|
|
ObjectSanNineLiner *objSan = m_mapObjectSanNineLiner.value(data.nineLinerId);
|
|
if (!objSan)
|
|
{
|
|
WARNING_LOG() << "Cannot find nineLiner Id = " << data.nineLinerId
|
|
<< " for categoryLineId " << data.id;
|
|
return;
|
|
}
|
|
objSan->addLineCategory(data);
|
|
};
|
|
|
|
if (!m_db->select(cb))
|
|
{
|
|
ERROR_LOG() << "Error reading data from database!";
|
|
return false;
|
|
}
|
|
|
|
// publish
|
|
for (ObjectSanNineLiner *objSan : std::as_const(m_mapObjectSanNineLiner))
|
|
objSan->onPublishData();
|
|
|
|
return true;
|
|
}
|
|
|
|
void HandlerSanNineLiner::onSanNineLinerModifyRequest(const rti::core::SampleIdentity &cookie,
|
|
const SanNineLinerModifyRequest &request)
|
|
{
|
|
Database::SanNineLiner data;
|
|
data.id = request.id();
|
|
data.lastModified = request.lastModified();
|
|
data.position = QPointF(request.line1_position().lon(), request.line1_position().lat());
|
|
|
|
LtsCoordTrans::UtmCoordinate coord(LtsCoordTrans::UtmCoordinate::fromGeographic(request.line1_position().lon(),
|
|
request.line1_position().lat()));
|
|
data.positionXM = coord.x;
|
|
data.positionYM = coord.y;
|
|
|
|
data.radioFrequencySuffixCallsign = QString::fromStdString(request.line2_radioFrequencyCallSignSuffix());
|
|
|
|
INFO_LOG() << "lines: " << request.lines();
|
|
|
|
Core::FunctionReplyObject ret;
|
|
ObjectSanNineLiner *ifs = nullptr;
|
|
if (request.id() <= 0)
|
|
{
|
|
ifs = new ObjectSanNineLiner(m_ddsHandler, m_db);
|
|
ret = ifs->createObject(data);
|
|
|
|
if (ret.error())
|
|
{
|
|
delete ifs;
|
|
ifs = nullptr;
|
|
ERROR_LOG() << ret();
|
|
}
|
|
else
|
|
{
|
|
m_mapObjectSanNineLiner.insert(ifs->getId(), ifs);
|
|
data.id = ifs->getId();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
data.id = request.id();
|
|
ifs = m_mapObjectSanNineLiner.value(data.id);
|
|
ret = ifs->updateObject(data);
|
|
}
|
|
|
|
if (!ifs)
|
|
{
|
|
m_ddsHandler->fts()->sanNineLinerModifyReply(cookie, ret);
|
|
return;
|
|
}
|
|
|
|
// delete old entries
|
|
if (!m_db->removeCategoryLinesPerNineLiner(data.id))
|
|
ERROR_LOG() << "Error while deleting old entries for nineLinerId " << data.id;
|
|
|
|
ifs->removeCategoryLines();
|
|
|
|
// line3 - line9 in object_san_category_line
|
|
INFO_LOG() << "data.id: " << data.id;
|
|
|
|
QVector<Database::SanCategoryLine> linesCategory = SanCategoryLine::fromJson(request.lines(), data.id);
|
|
INFO_LOG() << "LinesCategory count: " << linesCategory.count();
|
|
|
|
for (Database::SanCategoryLine cl : std::as_const(linesCategory))
|
|
{
|
|
ObjectSanCategoryLine *ifsCl(new ObjectSanCategoryLine(m_ddsHandler, m_db));
|
|
ret = ifsCl->createObject(cl);
|
|
if (ret.error())
|
|
ERROR_LOG() << ret();
|
|
else
|
|
{
|
|
cl.id = ifsCl->getId();
|
|
ifs->addLineCategory(cl);
|
|
}
|
|
}
|
|
|
|
ifs->onPublishData();
|
|
ret.setId(ifs->getId());
|
|
|
|
m_ddsHandler->fts()->sanNineLinerModifyReply(cookie, ret);
|
|
}
|
|
|
|
void HandlerSanNineLiner::onSanNineLinerRemoveRequest(const rti::core::SampleIdentity &cookie,
|
|
const Core::RemoveElementRequest &request)
|
|
{
|
|
|
|
ObjectSanNineLiner *ifs = m_mapObjectSanNineLiner.value(request.id());
|
|
|
|
Core::FunctionReplyObject ret;
|
|
if (!ifs)
|
|
{
|
|
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "SanNineLiner with id %1 not found")).arg(request.id());
|
|
m_ddsHandler->fts()->sanNineLinerRemoveReply(cookie, ret);
|
|
return;
|
|
}
|
|
|
|
if (!m_db->removeCategoryLinesPerNineLiner(request.id()))
|
|
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "SanCategoryLine with id %1 not found")).arg(request.id());
|
|
else
|
|
{
|
|
ifs->removeObject();
|
|
m_mapObjectSanNineLiner.remove(request.id());
|
|
}
|
|
|
|
m_ddsHandler->fts()->sanNineLinerRemoveReply(cookie, ret);
|
|
}
|
|
|
|
|
|
} // Namespace Evaluations
|