Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Proxies/Buildings/BuildingControlUnit/BSM/bsm_api.cpp
T
2026-10-03 09:20:13 +02:00

95 lines
2.9 KiB
C++
Executable File

#include "bsm_api.h"
#include "bsm_socket_handler.h"
#include <TrainingAreaBase/logger.h>
namespace BuildingControlUnit
{
namespace BSM
{
Api::Api(QObject *parent)
: QObject(parent)
, m_logger(TrainingAreaBase::getLogger("BSM.Api"))
, m_socketHandler(new SocketHandler(this))
{
connect(m_socketHandler, &SocketHandler::opticalShot,
this, &Api::opticalShot);
connect(m_socketHandler, &SocketHandler::opticalShotOC,
this, &Api::opticalShotOC);
connect(m_socketHandler, &SocketHandler::bsmStateChanged,
this, &Api::bsmStateChanged);
}
Api::~Api()
{
delete m_socketHandler;
}
bool Api::init(const BuildingBsmConfig &bsmConfig)
{
return m_socketHandler->init(bsmConfig);
}
bool Api::triggerFlashlight(int bsmId, const QString &hostname, int numberOfFlashes, int pauseBetweenFlashesSec)
{
DEBUG_LOG(m_logger) << "triggerFlashlight bsmId=" << bsmId
<< " hostname=" << hostname
<< " numberOfFlashes=" << numberOfFlashes
<< " pauseBetweenFlashesSec=" << pauseBetweenFlashesSec;
return m_socketHandler->triggerFlashlight(bsmId, hostname, numberOfFlashes, pauseBetweenFlashesSec);
}
bool Api::triggerFlashlightPulse(int bsmId, const QString &hostname,
int numberOfFlashes,
int pauseDuration,
int choppedConfiguration,
int flashDuration)
{
DEBUG_LOG(m_logger) << "triggerFlashlightPulse bsmId=" << bsmId
<< " hostname=" << hostname
<< " numberOfFlashes=" << numberOfFlashes
<< " pauseDuration=" << pauseDuration
<< " choppedConfiguration=" << choppedConfiguration
<< " flashDuration=" << flashDuration;
return m_socketHandler->triggerFlashlightPulse(bsmId, hostname, numberOfFlashes, pauseDuration, choppedConfiguration, flashDuration);
}
bool Api::triggerFlashlights( int numberOfFlashes,
int pauseDuration,
int choppedConfiguration,
int flashDuration)
{
DEBUG_LOG(m_logger) << "triggerFlashlights numberOfFlashes=" << numberOfFlashes
<< " pauseDuration=" << pauseDuration
<< " choppedConfiguration" << choppedConfiguration
<< " flashDuration=" << flashDuration;
return m_socketHandler->triggerFlashlights( numberOfFlashes, pauseDuration, choppedConfiguration, flashDuration);
}
QVector<BsmState> Api::bsmStates() const
{
return m_socketHandler->bsmStates();
}
bool Api::getBsmConfiguration(int bsmId)
{
return m_socketHandler->getBsmConfiguration(bsmId);
}
bool Api::getBsmBitTimeout(int bsmId)
{
return m_socketHandler->getBsmBitTimeout(bsmId);
}
bool Api::getBsmTechnicalStatus(int bsmId)
{
return m_socketHandler->getBsmTechnicalStatus(bsmId);
}
}
}