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>
133 lines
3.7 KiB
C++
133 lines
3.7 KiB
C++
/**
|
|
* MainHandler for Buildings
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Christian Ehrlicher, SLSE, 2016-04-14
|
|
*/
|
|
|
|
#include "main_handler.h"
|
|
#include "settings.h"
|
|
#include <DDS/Core/pacemaker.h>
|
|
#include <AssetManagement/asm_dtc.h>
|
|
#include <QObject>
|
|
|
|
namespace Buildings
|
|
{
|
|
MainHandler::MainHandler(QObject *parent)
|
|
: QObject(parent)
|
|
, m_logger(getLogger("MainHandler"))
|
|
{}
|
|
|
|
MainHandler::~MainHandler()
|
|
{
|
|
m_bcHandler = nullptr;
|
|
m_ismHandler = nullptr;
|
|
m_pdmHandler = nullptr;
|
|
m_ppmHandler = nullptr;
|
|
m_ddsHandler = nullptr;
|
|
m_dbHandler = nullptr;
|
|
m_relayInfoHandler = nullptr;
|
|
m_webSocketHandler = nullptr;
|
|
}
|
|
|
|
bool MainHandler::init(int domainId, int exerciseId)
|
|
{
|
|
bool bRet = initInternal(domainId, exerciseId);
|
|
|
|
|
|
DEBUG_LOG(m_logger) << "WebSocketInterfaceHandler initialized Port=" << m_webSocketHandler->listenPort();
|
|
m_ddsHandler->pacemaker()->addPort(m_webSocketHandler->listenPort(), Core::PortType::WebSocketServer);
|
|
|
|
if (bRet)
|
|
{
|
|
DEBUG_LOG(m_logger) << "svcBuildings successfully initialized";
|
|
m_ddsHandler->pacemaker()->setNewState(Core::RunningState::Running);
|
|
}
|
|
else
|
|
{
|
|
ERROR_LOG(m_logger) << "Error initializing svcBuildings...";
|
|
if (m_ddsHandler && m_ddsHandler->pacemaker())
|
|
m_ddsHandler->pacemaker()->setNewState(Core::RunningState::StartingError);
|
|
}
|
|
return bRet;
|
|
}
|
|
|
|
bool MainHandler::initInternal(int domainId, int exerciseId)
|
|
{
|
|
INFO_LOG(m_logger) << "MainHandler::init domainId = " << domainId
|
|
<< " exerciseId = " << exerciseId;
|
|
|
|
m_dbHandler = std::make_shared<DbHandler>();
|
|
if (!m_dbHandler->init(exerciseId, Settings::settings()))
|
|
{
|
|
ERROR_LOG(m_logger) << "Could not init DbHandler";
|
|
return false;
|
|
}
|
|
INFO_LOG(m_logger) << "DbHandler initialized";
|
|
|
|
// initialize DDS
|
|
m_ddsHandler = std::make_shared<DdsHandler>(domainId, exerciseId);
|
|
if (!m_ddsHandler->init())
|
|
return false;
|
|
|
|
m_ismHandler = std::make_shared<IsmHandler>(this);
|
|
if (!m_ismHandler->init())
|
|
return false;
|
|
|
|
m_pdmHandler = std::make_shared<PdmHandler>(this);
|
|
|
|
m_bcHandler = std::make_shared<BuildingControlHandler>(this);
|
|
if (!m_bcHandler->init())
|
|
return false;
|
|
|
|
m_ppmHandler = std::make_shared<PpmHandler>(this);
|
|
if (!m_ppmHandler->init())
|
|
return false;
|
|
|
|
m_relayInfoHandler = std::make_shared<RelayInfoHandler>(this);
|
|
if (!m_relayInfoHandler->init())
|
|
return false;
|
|
|
|
// WebSocketServer
|
|
m_webSocketHandler = std::make_shared<WebSocketHandler>(m_bcHandler,this);
|
|
|
|
if (!m_webSocketHandler->init(Settings::getWebSocketServerPortRange(1)))
|
|
return false;
|
|
|
|
QObject::connect(m_ismHandler.get(), &IsmHandler::buildingChanged,
|
|
m_bcHandler.get(), &BuildingControlHandler::onBuildingChanged);
|
|
QObject::connect(m_ismHandler.get(), &IsmHandler::buildingRemoved,
|
|
m_bcHandler.get(), &BuildingControlHandler::onBuildingRemoved);
|
|
QObject::connect(m_ismHandler.get(), &IsmHandler::setEffectStates,
|
|
m_bcHandler.get(), &BuildingControlHandler::setEffectStates);
|
|
|
|
m_asmDtc = AssetManagement::Interface::Dtc::create(ddsHandler()->ddsConnector());
|
|
|
|
auto cbRelayInfos = [this](const AssetManagement::RelayInfo & c)
|
|
{
|
|
m_bcHandler->onRelayInfoChanged(c, DataModification::eAdded);
|
|
};
|
|
|
|
m_asmDtc->waitForHistoricalDataRelayInfo();
|
|
m_asmDtc->relayInfos(cbRelayInfos);
|
|
|
|
QObject::connect(m_asmDtc.get(), &AssetManagement::Interface::Dtc::relayInfoChanged,
|
|
m_bcHandler.get(), &BuildingControlHandler::onRelayInfoChanged);
|
|
|
|
return true;
|
|
}
|
|
|
|
int MainHandler::exerciseId() const
|
|
{
|
|
return m_ddsHandler->ddsConnector()->getPartitionId();
|
|
}
|
|
|
|
std::shared_ptr<DatabaseInterface> MainHandler::db() const
|
|
{
|
|
return m_dbHandler->db();
|
|
}
|
|
|
|
|
|
} // namespace Buildings
|