Files
qt-migration-legatus/qt5-before/dlbo/Lts/Services/EffectShowClient/object_order.cpp
T
torstenandCopilot 7173785915 Qt6 Migration: Complete migration with DDS/RTI support and build validation
Major Changes:
- Merged latest Qt5 devel content from dlbo (292 files changed, 7 new dirs)
- Consolidated forward-declarations and include folders
- Removed unneeded modules per Niklas' repo check list

Build System Fixes:
- Fixed CMake VERSION_GREATER syntax in ParticipantManagement/CMakeLists.txt
- Added VLC packages (libvlc-dev, vlc-plugin-base) to docker_build.sh
- Added PostgreSQL dev packages (libpq-dev, postgresql-server-dev-all) to Dockerfile
- Fixed locale warnings (ANSI_X3.4-1968 → C.UTF-8)
- Fixed ArcGIS SDK path warnings when BUILD_ARCGIS=OFF

Code Generation Fixes:
- Fixed IDL enum collisions (PortType→CorePortType/DdsutPortType, PdmEventType)
- Fixed Grantlee template svc_translation.cpp.grantlee:
  - Changed {{ idl_enum.name }}_def:: to {{ idl_enum.name }}::
  - Fixed .underlying() calls for C++11 scoped enums (enum class)
- Removed generated files from repo (moc_*, *_dtc.h, *_ftc.h)

Validation:
- BUILD_RTI=ON: SUCCESS
- BUILD_RTI=OFF: SUCCESS
- C++17 standard maintained for RTI 7.7 compatibility
- Ubuntu 26.04 Docker environment verified

Remaining Warnings (expected):
- BgViewer, KDChart, KDReports, Poppler-Qt6 not found (optional features)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-09-15 18:20:26 +00:00

190 lines
6.0 KiB
C++

/**
* Handler for the HMI language
* $Id$
* $HeadURL$
* $Author$
*/
#include "object_order.h"
#include "esc_operator_rights.h"
#include "logger.h"
#include "main_handler.h"
#include <QHostInfo>
namespace EffectShowClient
{
ObjectOrder::ObjectOrder(MainHandler *mainHandler, QObject *parent)
: QObject(parent)
, m_mainHandler(mainHandler)
, m_logger(getLogger("ObjectOrder"))
{
}
ObjectOrder::~ObjectOrder()
{
if (m_data.id > 0)
m_mainHandler->dds()->dts()->removeOrderByKey(m_data.id);
}
Core::FunctionReplyObject ObjectOrder::createObject(const Database::EscOrder &data)
{
m_data = data;
if (m_data.id <= 0)
{
if (!m_mainHandler->db()->insert(m_data))
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting Order into database."));
DEBUG_LOG(m_logger) << "New Order created Id: " << m_data.id;
}
// Publish Data via DTS
onPublishData();
return Core::FunctionReplyObject(m_data.id);
}
Core::FunctionReplyObject ObjectOrder::updateObject(const Database::EscOrder &data)
{
if (data.id <= 0)
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "Object not valid/blocked"));
m_data = data;
if (!m_mainHandler->db()->update(m_data))
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "Error updating Order into database"));
DEBUG_LOG(m_logger) << "Data changed for Changed Id: " << m_data.id;
// Publish Data via DTS
onPublishData();
return Core::FunctionReplyObject(m_data.id);
}
Core::FunctionReplyObject ObjectOrder::removeObject()
{
if (!m_mainHandler->db()->removeEscOrder(m_data.id))
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "Order %1 can not be removed")).arg(m_data.id);
return Core::FunctionReplyObject(m_data.id);
}
void ObjectOrder::onPublishData()
{
EffectShowClient::Order ddsData;
ddsData.id(m_data.id);
ddsData.areaDepth(m_data.areaDepth);
ddsData.areaWidth(m_data.areaWidth);
ddsData.areaRotation(m_data.areaRotation);
ddsData.duration(m_data.duration);
ddsData.idOrder(m_data.idOrder);
ddsData.numOfVolley(m_data.numOfVolley);
ddsData.shotsPerVolley(m_data.shotsPerVolley);
EffectShowManagement::OrderConfirmation_e oc = EffectShowManagement::OrderConfirmation_e::inner_enum(m_data.orderConfirmation);
ddsData.orderConfirmation(oc);
ddsData.position(Core::GeoPosition2D(m_data.centerPosition.x(), m_data.centerPosition.y()));
ddsData.lowerLeftPosition(Core::GeoPosition2D(m_data.lowerLeftPosition.x(), m_data.lowerLeftPosition.y()));
ddsData.startTime(m_data.startTime);
ddsData.typeOfOrder(m_data.typeOfOrder);
ddsData.info(m_data.info.toStdString());
INFO_LOG(m_logger) << "Publish EscOrder-data to dds (" << m_data.id << ") ...";
if (oc == EffectShowManagement::OrderConfirmation_e::WaitingForAcceptance)
createNotificationRequest();
if (!m_mainHandler->dds()->dts()->publish(ddsData))
ERROR_LOG(m_logger) << "Error publishing EscOrder-data to dds";
}
//-----------------------------------------------------------------------------
void ObjectOrder::getCreateNotificationRequestData(NotificationManagement::CreateNotification &data)
{
qint64 currentTime = QDateTime::currentMSecsSinceEpoch();
// 100 seconds
qint64 expiryTime = currentTime + 100 * 1000;
NotificationManagement::NomNotification notif;
QString localHostName = QHostInfo::localHostName().toUpper();
int addressId = m_mainHandler->dds()->dtcAsm()->getAssetId(localHostName);
if ( m_data.typeOfOrder == 1)
{
QString title = QString::fromUtf8(tr_lts("Notification", "DMF Order")); // deutsch Wirkdarstellungen
notif.title(title.toStdString());
}
else
{
QString title = QString::fromUtf8(tr_lts("Notification", "Relocation Order")); // deutsch Stellungswechsel
notif.title(title.toStdString());
}
QString content = QString::fromUtf8(tr_lts("Notification","<a href='lts://escOrderList/%1'>Open Dialog</a>"));
std::vector<std::string> args;
args.reserve(1);
const QString str = QString::number(m_data.typeOfOrder);
args.emplace_back(str.toStdString());
notif.content(content.toStdString());
notif.contentArgs(args);
notif.timeStamp(m_mainHandler->dds()->currentPartitionTime());
notif.expiryTime(expiryTime);
notif.priority(NotificationManagement::Priority_def::High);
notif.processedPriority(NotificationManagement::Priority_def::Low);
notif.messageType(NotificationManagement::MessageType_def::Info);
notif.exerciseId(m_mainHandler->dds()->getExerciseId());
NotificationManagement::Address wsAddr;
wsAddr.addressId(addressId);
wsAddr.isRead(false);
QString name = localHostName;
wsAddr.name(name.toStdString());
wsAddr.addressType(NotificationManagement::AddressType_def::Workstation);
notif.recipientIds().reserve(1);
notif.recipientIds().push_back(wsAddr);
NotificationManagement::Address addrSender;
addrSender.addressId(EffectShowClient::Offset);
addrSender.name(QStringLiteral("svcEffectShowClient").toStdString());
addrSender.addressType(NotificationManagement::AddressType_def::Service);
notif.sender(addrSender);
data.notification(notif);
} // end of getCreateNotificationRequestData()
void ObjectOrder::createNotificationRequest()
{
NotificationManagement::CreateNotification data;
getCreateNotificationRequestData(data);
INFO_LOG(m_logger) << "trying to send CreateNotificationRequest";
if (!m_mainHandler->dds()->ftcNom()->createNotificationRequest(data, this))
{
ERROR_LOG(m_logger) << "Error requesting create data";
}
}
//-----------------------------------------------------------------------------
void ObjectOrder::onCreateNotificationReply(const Core::FunctionReplyObject &replyObject)
{
INFO_LOG(m_logger) << "Got createReply with id " << replyObject.id() << " and errorString " << replyObject.translated();
if (replyObject.error())
{
ERROR_LOG(m_logger) << "Error requesting CreateNotification";
return;
}
else
DEBUG_LOG(m_logger) << "Requesting create data ok. Got new id:" << replyObject.id() << " ... ok.";
} // end of onNotificationCreateReply()
} // Namespace EffectShowClient