- BUILD_RTI conditional compilation für RTI Connext DDS dependencies - Namespace fixes in core_dtc.h (Core:: → DDS::Core::) - CMakeLists.txt: BUILD_RTI option und conditional dependencies - Handler minelayer: namespace closing mit BUILD_RTI guard - Build erfolgreich mit BUILD_RTI=OFF validiert Signed-off-by: Torsten Wierschin <torsten.wierschin@life-maps.com>
69 lines
1.5 KiB
C++
Executable File
69 lines
1.5 KiB
C++
Executable File
|
|
|
|
|
|
#include "ttci_channel.h"
|
|
|
|
#include "ttci_device.h"
|
|
#include <NGLLogger/NGLLoggerBootstrap.h>
|
|
|
|
namespace TrainingAreaBaseOC
|
|
{
|
|
|
|
Channel::Channel(QChar channel, bool bIsBinary, QObject *parent) : QObject(parent)
|
|
, m_channel(channel)
|
|
, m_bIsBinary(bIsBinary)
|
|
, m_device(nullptr)
|
|
.getNGLLogger("SCTT.Channel")),
|
|
m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger()) {}
|
|
|
|
void Channel::setDevice(Device *dev)
|
|
{
|
|
if (m_device)
|
|
disconnect(m_device);
|
|
m_device = dev;
|
|
connect(dev, &Device::destroyed,
|
|
this, &Channel::onDeviceDestroyed);
|
|
connect(dev, &Device::dataAvailable,
|
|
this, &Channel::onDataAvailable, Qt::QueuedConnection);
|
|
connect(dev, &Device::disconnectedFromEq,
|
|
this, &Channel::disconnectedFromEq);
|
|
}
|
|
|
|
bool Channel::writeData(const QByteArray &data)
|
|
{
|
|
if (!m_device || !m_device->isOpen())
|
|
{
|
|
WARNING_LOG(m_logger) << "Error writing data - device is not open" ;
|
|
return false;
|
|
}
|
|
|
|
QByteArray payload;
|
|
if (m_bIsBinary)
|
|
payload = data;
|
|
else
|
|
{
|
|
payload.reserve(data.size());
|
|
for (const char c : data)
|
|
{
|
|
if (c == 0x0a)
|
|
continue;
|
|
payload += c;
|
|
}
|
|
}
|
|
return m_device->writeData(m_channel, payload);
|
|
}
|
|
|
|
void Channel::onDeviceDestroyed()
|
|
{
|
|
m_device = nullptr;
|
|
}
|
|
|
|
void Channel::onDataAvailable(const QByteArray &data)
|
|
{
|
|
TRACE_LOG(m_logger) << "Data available from "
|
|
<< ", we are: " << m_channel
|
|
<< ", data: '" << data << "'" ;
|
|
emit dataAvailable(data);
|
|
}
|
|
}
|