Initial commit

This commit is contained in:
torsten committed 2026-08-13 18:33:10 +02:00
commit b7d90b9afe
16245 files changed
+3396666

No files matched your search

+185
View File
@@ -0,0 +1,185 @@
#
# $Id$
# $HeadURL$
# $Author$
#
INCLUDE(MacroRTIDDSGen)
INCLUDE(MacroCodeGenIdl)
SET(xml_FILE esc_service.xml)
#
# --- Library svcEscCommon --------------------------------------------------------------------------------
#
SET(SRCS_common
esc_export.h
logger.cpp
logger.h
)
# Generate esc_enums.idl / esc.idl
CODEGEN_IDL_SVC(SRCS_common ${xml_FILE})
# Generate esc_db_impl.cpp/.h, esc_db.h
CODEGEN_DATABASE(SRCS_common ${xml_FILE})
# Generate *.cpp/*.hpp from idl
RTIDDSGEN(SRCS_common esc_enums.idl)
RTIDDSGEN(SRCS_common esc.idl)
# Generate esc_dt[s,c]_types.h, esc_ft[s,c]_types.h
CODEGEN_TOPIC_TYPEDEFS(SRCS_common ${xml_FILE})
# Generate esc_[d|f]tc.h
CODEGEN_CLIENT_TOPICS_IFC(SRCS_common ${xml_FILE})
NGL_ADD_LIBRARY(AAR SV WS svcEscCommon SHARED ${SRCS_common})
NGL_TARGET_INCLUDE_DIRECTORIES(svcEscCommon
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../
${CMAKE_CURRENT_BINARY_DIR}/../
)
NGL_TARGET_LINK_LIBRARIES(svcEscCommon
PRIVATE
RTI::nddscpp2
PUBLIC
Qt5::Core
svcEsmCommon
ddscore
ngldb
NGLLogger
)
NGL_INSTALL_TARGET(svcEscCommon)
#
# --- Library svcEscClient --------------------------------------------------------------------------------
#
SET(SRCS_client
esc_export.h
)
# generate esc_[d|f]tc.h, esc_[d|f]tc_impl.[cpp|h]
CODEGEN_CLIENT_TOPICS_IMPL(SRCS_client ${xml_FILE})
NGL_ADD_LIBRARY(AAR SV WS svcEscClient SHARED ${SRCS_client})
NGL_TARGET_INCLUDE_DIRECTORIES(svcEscClient
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../
${CMAKE_CURRENT_BINARY_DIR}/../
)
NGL_TARGET_LINK_LIBRARIES(svcEscClient
PRIVATE
RTI::nddscpp2
ddsconnector
PUBLIC
svcEscCommon
ddsftc
)
NGL_INSTALL_TARGET(svcEscClient)
#
# --- Library svcEscServer --------------------------------------------------------------------------------
#
SET(SRCS_server
esc_export.h
)
# generate esc_[d|f]ts.h, esc_[d|f]ts_impl.[cpp|h]
CODEGEN_SERVER_TOPICS(SRCS_server ${xml_FILE})
NGL_ADD_LIBRARY(AAR SV svcEscServer SHARED ${SRCS_server})
NGL_TARGET_INCLUDE_DIRECTORIES(svcEscServer
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../
${CMAKE_CURRENT_BINARY_DIR}/../
)
NGL_TARGET_LINK_LIBRARIES(svcEscServer
PRIVATE
RTI::nddscpp2
ddsconnector
ddsfts
ngldb
PUBLIC
svcEscCommon
)
NGL_INSTALL_TARGET(svcEscServer)
#
# --- Topic Type Plugin --------------------------------------------------------------
#
CREATE_TOPIC_TYPE_PLUGIN(${xml_FILE})
#
# --- Executable svcEffectShowClient (sESC) -------------------------------------------------
#
SET(SRCS_exe
esc_helper.h
main.cpp
main_handler.cpp
main_handler.h
handler_order.cpp
handler_order.h
handler_operating_condition.cpp
handler_operating_condition.h
handler_firing_explosion.cpp
handler_firing_explosion.h
handler_firing_smoke.cpp
handler_firing_smoke.h
handler_tab_data.cpp
handler_tab_data.h
handler_vehicle.cpp
handler_vehicle.h
object_order.cpp
object_order.h
esc_convert_from_tab.cpp
esc_convert_from_tab.h
esc_convert_to_tab.cpp
esc_convert_to_tab.h
dds_handler.cpp
dds_handler.h
settings.cpp
settings.h
${xml_FILE}
connection_handler.h
connection_handler.cpp
connection_handler_serial.h
connection_handler_serial.cpp
connection_handler_tcp.h
connection_handler_tcp.cpp
control_unit_handler.h
control_unit_handler.cpp
)
# Generate esc.sql, esc.xml
CODEGEN_SQL(SRCS_exe ${xml_FILE})
NGL_ADD_SVC_ICON(SRCS_exe)
NGL_ADD_EXECUTABLE(AAR SV svcEffectShowClient ${SRCS_exe})
NGL_TARGET_LINK_LIBRARIES(svcEffectShowClient
Qt5::Core
Qt5::SerialPort
Qt5::Network
svcEscCommon
svcEscServer
svcCoreClient
svcTabClient
svcAsmClient
svcNomClient
svcEsmServer
ddsconnector
nglsettings
ProjectConfig
LtsCommandLineParser
LtsSerialPortQuerry
NGLLogger
LtsUtilsCore
nglcoreapplication
ngltools
)
NGL_INSTALL_TARGET(svcEffectShowClient)
NGL_INSTALL(AAR SV FILES log4cxx_esc.props DESTINATION bin)
NGL_ADD_TARGET_LINK(svcEffectShowClient sESC)
# Uncomment if necessary
#ADD_SUBDIRECTORY(UnitTests)
#ADD_SUBDIRECTORY(ModuleTests)
+22
View File
@@ -0,0 +1,22 @@
/**
* Connection Handler for the serial connection to the sfm
* $Id$
* $HeadURL$
* $Author$
* Created by Philipp Dassow, NLST, 2018-01-29
*/
#include "connection_handler.h"
namespace EffectShowClient
{
ConnectionHandler::ConnectionHandler(QObject *parent)
: ConnectionHandlerSerial(parent)
{}
ConnectionHandler::~ConnectionHandler()
{
}
}
+29
View File
@@ -0,0 +1,29 @@
/**
* Connection Handler for the RS232 serial connection to the sfm
* $Id$
* $HeadURL$
* $Author$
* Created by Philipp Dassow, NLST, 2018-01-29
*/
#pragma once
#include "logger.h"
#include "connection_handler_tcp.h"
#include "connection_handler_serial.h"
namespace EffectShowClient
{
class ConnectionHandler : public ConnectionHandlerSerial
{
Q_OBJECT
public:
explicit ConnectionHandler(QObject *parent = nullptr);
~ConnectionHandler();
};
} // namespace EffectShowClient
+207
View File
@@ -0,0 +1,207 @@
/**
* Connection Handler for the serial connection to the sfm
* $Id$
* $HeadURL$
* $Author$
* Created by Philipp Dassow, NLST, 2018-01-29
*/
#include "connection_handler_serial.h"
#include <LtsUtilsCore/sfm_bytemessage_converter.h>
#include <QTimer>
namespace EffectShowClient
{
ConnectionHandlerSerial::ConnectionHandlerSerial(QObject *parent)
: QObject(parent)
, m_spQuerry(new LtsSerialPortQuerry::LtsSerialPortQuerry(this))
, m_serialPort(nullptr)
, m_receiveTimeoutTimer(new QTimer(this))
, m_currentDataRead(QByteArray())
, m_portName(QStringLiteral("COM5"))
, m_readBuffer(new QByteArray())
, m_logger(getLogger("ConnectionHandlerSerial"))
{
m_receiveTimeoutTimer->setInterval(1700);
connect(m_spQuerry, &LtsSerialPortQuerry::LtsSerialPortQuerry::connectionEstablished, this, &ConnectionHandlerSerial::open);
m_spQuerry->restartQuerry();
connect(m_receiveTimeoutTimer, &QTimer::timeout, m_spQuerry, &LtsSerialPortQuerry::LtsSerialPortQuerry::continueQuerry);
connect(m_receiveTimeoutTimer, &QTimer::timeout, this, &ConnectionHandlerSerial::disconnectedFromSerialConverter);
}
ConnectionHandlerSerial::~ConnectionHandlerSerial()
{
DEBUG_LOG(m_logger) << "ConnectionHandlerSerial::~ConnectionHandlerSerial";
}
bool ConnectionHandlerSerial::init()
{
return true;
}
bool ConnectionHandlerSerial::send(const QByteArray &binaryData)
{
// Checking port ---------------------------------------------
if (!m_serialPort)
{
DEBUG_LOG(m_logger) << "Port is not initialized!";
return false;
}
if (!m_serialPort->isOpen())
{
DEBUG_LOG(m_logger) << "Port is not opened!";
return false;
}
// Sending data ---------------------------------------------
const QByteArray writeThis = LtsUtils::byteStreamFromEscMessage(binaryData);
DEBUG_LOG(m_logger) << "Send HEX:" << writeThis.toHex(' ');
qint64 byteswritten = m_serialPort->write(writeThis);
DEBUG_LOG(m_logger) << "Binary data:" << binaryData.size();
DEBUG_LOG(m_logger) << "Try sending: " << writeThis.size();
// Check for errors ---------------------------------------------
if (byteswritten == -1)
{
DEBUG_LOG(m_logger) << "Failed to write data to port " << m_serialPort->portName() << " error: " << m_serialPort->errorString();
return false;
}
else if (byteswritten != writeThis.size())
{
DEBUG_LOG(m_logger) << "Failed to write all data to port " << m_serialPort->portName() << " error: " << m_serialPort->errorString();
return false;
}
return true;
}
bool ConnectionHandlerSerial::open()
{
m_serialPort = m_spQuerry->currentSerialPort();
connect(m_serialPort, &QSerialPort::readyRead, this, &ConnectionHandlerSerial::read);
m_currentDataRead.clear();
m_receiveTimeoutTimer->start();
DEBUG_LOG(m_logger) << "(Re)openend serial port " << m_serialPort->portName() << " baudrate: " << m_serialPort->baudRate();
emit connectedToSerialConverter();
return true;
}
bool ConnectionHandlerSerial::isOpen() const
{
return m_serialPort->isOpen();
}
void ConnectionHandlerSerial::read()
{
const QByteArray ba = m_serialPort->readAll();
m_currentDataRead.append(ba);
//DEBUG_LOG(m_logger) << "Binary data from sfm: " << ba.toHex(' ');
DEBUG_LOG(m_logger) << "Data size" << ba.size();
int idxStart = -1;
int idxEnd = -1;
while ((idxStart = m_currentDataRead.indexOf(0x02)) >= 0 &&
(idxEnd = m_currentDataRead.indexOf(0x03)) >= 0) // while complete message frame in buffer
{
//whatever happens: remove current frame from data
//m_currentDataRead = m_currentDataRead.mid(idxEnd+1);
QByteArray message = m_currentDataRead.mid(idxStart, (idxEnd - idxStart) + 1);
m_currentDataRead = m_currentDataRead.mid(idxEnd + 1);
DEBUG_LOG(m_logger) << "Data Message found: " << message.toHex(' ');
message = LtsUtils::byteStreamToEscMessage(message);
if (message.size() > 2)
{
ERROR_LOG(m_logger) << "Message to long: " << message.size();
continue;
}
DEBUG_LOG(m_logger) << "Frame from sfm as binary " << message.toHex();
//got message now remove frame
unsigned int byte = 0;
byte = message.at(0) & 0xFF;
DEBUG_LOG(m_logger) << "ConnectionHandlerSerial::read var byte is" << byte;
if (!isValidCommandByte(byte))
{
ERROR_LOG(m_logger) << "ConnectionHandlerSerial::read Commandbyte is invalid. Returning";
return;
}
// If first byte is not between 43 and 91, then we need the second byte, because all other commands have payload. Just not this single piece of
if (byte < 43 ||
byte > 91)
{
if (message.size() > 1 &&
!isValidPayloadByte(message.at(1)))
{
ERROR_LOG(m_logger) << "ConnectionHandlerSerial::read Payloadbyte is invalid. Returning";
continue;
}
}
if (message.size() != 2)
{
ERROR_LOG(m_logger) << "ConnectionHandlerSerial::read No 2nd byte was appended (QByteArray has bad size). Returning.";
continue;
}
DEBUG_LOG(m_logger) << "Binary data from serial port: " << message.toHex(' ');
m_receiveTimeoutTimer->start();
emit received(message);
}
if (m_serialPort->bytesAvailable() > 0)
DEBUG_LOG(m_logger) << "Still " << m_serialPort->bytesAvailable() << " available to be read";
}
bool ConnectionHandlerSerial::isValidCommandByte(const unsigned char command)
{
DEBUG_LOG(m_logger) << "ConnectionHandlerSerial::isValidCommandByte" << command << (command == 192 ||
command == 240 ||
command == 244 ||
command == 255 ||
command == 144 ||
command == 202 ||
command == 224 ||
command == 213 ||
command == 15 ||
command == 42 ||
(command >= 43 &&
command <= 91));
return (command == 192 ||
command == 240 ||
command == 244 ||
command == 255 ||
command == 144 ||
command == 202 ||
command == 224 ||
command == 213 ||
command == 15 ||
command == 42 ||
(command >= 43 &&
command <= 91));
}
bool ConnectionHandlerSerial::isValidPayloadByte(const unsigned char payload)
{
Q_UNUSED(payload);
return true;
}
}
+61
View File
@@ -0,0 +1,61 @@
/**
* Connection Handler for the RS232 serial connection to the sfm
* $Id$
* $HeadURL$
* $Author$
* Created by Philipp Dassow, NLST, 2018-01-29
*/
#pragma once
#include "logger.h"
#include <LtsSerialPortQuerry/lts_serial_port_querry.h>
#include <QObject>
#include <QTimer>
#include <QSerialPort>
namespace EffectShowClient
{
class ConnectionHandlerSerial : public QObject
{
Q_OBJECT
public:
explicit ConnectionHandlerSerial(QObject *parent = nullptr);
~ConnectionHandlerSerial();
bool init();
bool send(const QByteArray &binaryData);
bool open();
bool isOpen() const;
signals:
/**
* @brief received emits a byte pair with command and payload byte when a available. It is guaranteed that there will be 2 bytes
* @param ba is a byte pair, with command 1st and payload 2nd.
*/
void received(const QByteArray &ba);
void connectedToSerialConverter();
void disconnectedFromSerialConverter();
private slots:
void read();
private:
bool isValidCommandByte(const unsigned char command);
bool isValidPayloadByte(const unsigned char payload);
LtsSerialPortQuerry::LtsSerialPortQuerry *m_spQuerry;
QSerialPort *m_serialPort;
QTimer *m_receiveTimeoutTimer;
QByteArray m_currentDataRead;
QString m_portName;
QByteArray *m_readBuffer;
NGL::INGLLogger &m_logger;
};
} // namespace EffectShowClient
+248
View File
@@ -0,0 +1,248 @@
/**
* Connection Handler for the serial connection to the sfm
* $Id$
* $HeadURL$
* $Author$
* Created by Philipp Dassow, NLST, 2018-01-29
*/
#include "connection_handler_tcp.h"
#include "settings.h"
#include <LtsUtilsCore/sfm_bytemessage_converter.h>
#include <QTimer>
namespace EffectShowClient
{
ConnectionHandlerTcp::ConnectionHandlerTcp(QObject *parent)
: QObject(parent)
, m_socket(nullptr)
, m_timer(new QTimer(this))
, m_currentDataRead(QByteArray())
, m_logger(getLogger("ConnectionHandlerTcp"))
{
m_timer->setInterval(5000);
connect(m_timer, &QTimer::timeout, this, &ConnectionHandlerTcp::open);
}
ConnectionHandlerTcp::~ConnectionHandlerTcp()
{
m_socket->close();
delete m_socket;
}
bool ConnectionHandlerTcp::init()
{
m_socket = new QTcpSocket();
connect(m_socket, &QTcpSocket::readyRead, this, &ConnectionHandlerTcp::read);
connect(m_socket, &QTcpSocket::disconnected, this, &ConnectionHandlerTcp::open);
connect(m_socket, QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error), this, &ConnectionHandlerTcp::handleError);
connect(m_socket, &QTcpSocket::connected, this, &ConnectionHandlerTcp::connectedToSerialConverter);
open(); //open it and start regardless
return true;
}
bool ConnectionHandlerTcp::send(const QByteArray &message)
{
if (!m_socket)
return false;
if (!m_socket->isOpen())
{
ERROR_LOG(m_logger) << "Port is not opened!";
return false;
}
const QByteArray writeThis = LtsUtils::byteStreamFromEscMessage(message);
DEBUG_LOG(m_logger) << "Send HEX:" << writeThis.toHex(' ');
qint64 byteswritten = m_socket->write(writeThis);
DEBUG_LOG(m_logger) << "Binary data:" << message.size();
DEBUG_LOG(m_logger) << "Try sending: " << message.size();
// Check for errors ---------------------------------------------
if (byteswritten == -1)
{
ERROR_LOG(m_logger) << "Failed to write data to port " << m_socket->peerPort() << " error: " << m_socket->errorString();
m_timer->start();
return false;
}
else if (byteswritten != writeThis.size())
{
ERROR_LOG(m_logger) << "Failed to write all data to port " << m_socket->peerPort() << " error: " << m_socket->errorString();
return false;
}
return true;
}
bool ConnectionHandlerTcp::open()
{
m_timer->stop();
m_socket->connectToHost(Settings::hostName(), Settings::port());
if (!m_socket->waitForConnected())
{
ERROR_LOG(m_logger) << "Could not (re)open tcp destination " << m_socket->peerName() << ":" << m_socket->peerPort() << ", error: " << m_socket->errorString();
return false;
}
INFO_LOG(m_logger) << "(Re)openend tcp destination " << m_socket->peerName() << ":" << m_socket->peerPort();
return true;
}
void ConnectionHandlerTcp::close()
{
m_socket->close();
}
bool ConnectionHandlerTcp::isOpen() const
{
return m_socket->isOpen();
}
void ConnectionHandlerTcp::read()
{
const QByteArray ba = m_socket->readAll();
m_currentDataRead.append(ba);
//DEBUG_LOG(m_logger) << "Binary data from sfm: " << ba.toHex(' ');
DEBUG_LOG(m_logger) << "Data size" << ba.size();
int idxStart = -1;
int idxEnd = -1;
while ((idxStart = m_currentDataRead.indexOf(0x02)) >= 0 &&
(idxEnd = m_currentDataRead.indexOf(0x03)) >= 0) // while complete message frame in buffer
{
//whatever happens: remove current frame from data
//m_currentDataRead = m_currentDataRead.mid(idxEnd+1);
QByteArray message = m_currentDataRead.mid(idxStart, (idxEnd - idxStart) + 1);
m_currentDataRead = m_currentDataRead.mid(idxEnd + 1);
DEBUG_LOG(m_logger) << "Data Message found: " << message.toHex(' ');
message = LtsUtils::byteStreamToEscMessage(message);
if (message.size() > 2)
{
ERROR_LOG(m_logger) << "Message to long: " << message.size();
continue;
}
DEBUG_LOG(m_logger) << "Frame from sfm as binary " << message.toHex();
//got message now remove frame
unsigned int byte = 0;
byte = message.at(0) & 0xFF;
DEBUG_LOG(m_logger) << "ConnectionHandler::read var byte is" << byte;
if (!isValidCommandByte(byte))
{
ERROR_LOG(m_logger) << "ConnectionHandler::read Commandbyte is invalid. Returning";
return;
}
// If first byte is not between 43 and 91, then we need the second byte, because all other commands have payload. Just not this single piece of
if (byte <= 41 ||
byte >= 91)
{
if (message.size() > 1 &&
!isValidPayloadByte(message.at(1)))
{
ERROR_LOG(m_logger) << "ConnectionHandler::read Payloadbyte is invalid. Returning";
continue;
}
}
if (message.size() != 2)
{
ERROR_LOG(m_logger) << "ConnectionHandler::read No 2nd byte was appended (QByteArray has bad size). Returning.";
continue;
}
DEBUG_LOG(m_logger) << "Binary data from serial port: " << message.toHex(' ');
emit received(message);
}
if (m_socket->bytesAvailable() > 0)
DEBUG_LOG(m_logger) << "Still " << m_socket->bytesAvailable() << " available to be read";
}
void ConnectionHandlerTcp::handleError(QAbstractSocket::SocketError error)
{
DEBUG_LOG(m_logger) << "Spontaneous error " << error << " doesn't have to be an error ...";
const QString errStr(QStringLiteral("QTcpSocket::SocketError ") + QString::number(error) +
QStringLiteral(" from tcp port ") + QString::number(m_socket->peerPort()) +
QStringLiteral(" error: ") + m_socket->errorString());
switch (error)
{
case QTcpSocket::SocketError::ConnectionRefusedError:
case QTcpSocket::SocketError::SocketAccessError:
case QTcpSocket::SocketError::SocketResourceError:
{
ERROR_LOG(m_logger) << "Closing port WITHOUT trying to reopen it.";
close();
m_timer->start();
Q_FALLTHROUGH();
}
case QTcpSocket::SocketError::RemoteHostClosedError:
{
ERROR_LOG(m_logger) << errStr;
m_timer->start();
break;
}
default:
{
ERROR_LOG(m_logger) << errStr;
close();
m_timer->start();
break;
}
}
}
bool ConnectionHandlerTcp::isValidCommandByte(const unsigned char command)
{
DEBUG_LOG(m_logger) << "ConnectionHandler::isValidCommandByte" << command << (command == 192 ||
command == 240 ||
command == 244 ||
command == 255 ||
command == 144 ||
command == 202 ||
command == 224 ||
command == 213 ||
command == 15 ||
command == 42 ||
command == 41 ||
(command >= 43 &&
command <= 91));
return (command == 192 ||
command == 240 ||
command == 244 ||
command == 255 ||
command == 144 ||
command == 202 ||
command == 224 ||
command == 213 ||
command == 15 ||
command == 42 ||
command == 41 ||
(command >= 43 &&
command <= 91));
}
bool ConnectionHandlerTcp::isValidPayloadByte(const unsigned char payload)
{
Q_UNUSED(payload);
return true;
}
}
+59
View File
@@ -0,0 +1,59 @@
/**
* Connection Handler for the RS232 serial connection to the sfm
* $Id$
* $HeadURL$
* $Author$
* Created by Philipp Dassow, NLST, 2018-01-29
*/
#pragma once
#include <QObject>
#include <QTcpSocket>
#include <LtsUtilsCore/sfm_bytemessage_converter.h>
#include "logger.h"
class QTimer;
namespace EffectShowClient
{
class ConnectionHandlerTcp : public QObject
{
Q_OBJECT
public:
explicit ConnectionHandlerTcp(QObject *parent = nullptr);
~ConnectionHandlerTcp();
bool init();
bool send(const QByteArray &message);
bool open();
void close();
bool isOpen() const;
signals:
/**
* @brief received emits a byte pair with command and payload byte when a available. It is guaranteed that there will be 2 bytes
* @param ba is a byte pair, with command 1st and payload 2nd.
*/
void received(const QByteArray &ba);
void connectedToSerialConverter();
private slots:
void read();
void handleError(QAbstractSocket::SocketError error);
private:
bool isValidCommandByte(const unsigned char command);
bool isValidPayloadByte(const unsigned char payload);
QTcpSocket *m_socket;
QTimer *m_timer;
QByteArray m_currentDataRead;
NGL::INGLLogger &m_logger;
};
} // namespace EffectShowClient
+292
View File
@@ -0,0 +1,292 @@
/**
* Controler interface for the DMF vehicle terminal
* $Id$
* $HeadURL$
* $Author$
* Created by Florian Schult, NLSE, 2018-06-06
*/
#include "control_unit_handler.h"
#include "connection_handler.h"
namespace EffectShowClient
{
ControlUnitHandler::ControlUnitHandler(QObject *parent)
: QObject(parent)
, m_connectionHandler(new ConnectionHandler(this))
, m_timer(new QTimer(this))
, m_feature(EffectShowManagement::Feature_e::NotSpecified)
, m_logger(getLogger("ControlUnitHandler"))
{
m_timer->setInterval(10000);
connect(m_timer, &QTimer::timeout, this, &ControlUnitHandler::onConnectedToSerialConveter);
m_timer->start();
}
ControlUnitHandler::~ControlUnitHandler()
{
delete m_connectionHandler;
}
bool ControlUnitHandler::init()
{
if (!m_connectionHandler->init())
{
DEBUG_LOG(m_logger) << "Could not init ConnectionHandler";
return false;
}
connect(m_connectionHandler, &ConnectionHandler::received, this, &ControlUnitHandler::onDataReceived);
connect(m_connectionHandler, &ConnectionHandler::connectedToSerialConverter, this, &ControlUnitHandler::onConnectedToSerialConveter);
connect(m_connectionHandler, &ConnectionHandler::connectedToSerialConverter, this, &ControlUnitHandler::vehicleConnected);
connect(m_connectionHandler, &ConnectionHandler::disconnectedFromSerialConverter, this, &ControlUnitHandler::onDisconnectedFromSerialConveter);
send(CommandSignal::FT_SE_CB_FZRSTYP);
return true;
}
bool ControlUnitHandler::send(const CommandSignal command, const unsigned int roundCount)
{
unsigned int commandByte = 0;
// Check and use input
switch (command)
{
case CommandSignal::FT_SE_CB_WERFER_STATUS:
{
if (roundCount <= 48)
commandByte = command + roundCount;
else
{
DEBUG_LOG(m_logger) << "Bad round count for command FT_SE_CB_WERFER_STATUS";
return false;
}
break;
}
case CommandSignal::FT_SE_CB_WERFER_MUNITION:
{
if (roundCount <= 48)
commandByte = command + roundCount;
else
{
DEBUG_LOG(m_logger) << "Bad round count for command FT_SE_CB_WERFER_MUNITION";
return false;
}
break;
}
default:
{
commandByte = command;
break;
}
}
DEBUG_LOG(m_logger) << "Sending int/byte to connectionHandler: " << commandByte << QString::number(commandByte, 2); // todorm
// emit sending(QString(QStringLiteral("%1 - %2")).arg(QString::number(commandByte, 2).rightJustified(8, QLatin1Char('0'))).arg(commandByte));
QByteArray data;
data.append(commandByte & 0xFF);
data.resize(1);
// emit hasWarnings();
return m_connectionHandler->send(data);
}
void ControlUnitHandler::onDataReceived(const QByteArray &ba)
{
if (ba.size() >= 1)
{
TRACE_LOG(m_logger) << "ControlUnitHandler::onDataReceived ba.at(0) " << (ba.at(0));
TRACE_LOG(m_logger) << "ControlUnitHandler::onDataReceived ba.at(0) & 0xFF " << (ba.at(0) & 0xFF);
}
else
{
DEBUG_LOG(m_logger) << "ControlUnitHandler::onDataReceived ba is empty";
return;
}
if (ba.size() >= 2)
{
TRACE_LOG(m_logger) << "ControlUnitHandler::onDataReceived ba.at(1) " << (ba.at(1));
TRACE_LOG(m_logger) << "ControlUnitHandler::onDataReceived ba.at(1) & 0xFF " << (ba.at(1) & 0xFF);
}
const unsigned int data = ba.at(0);
if (data >= SE_FT_CB_WERFER_MUNITION && data < 93)
{
DEBUG_LOG(m_logger) << "ControlUnitHandler::SE_FT_CB_WERFER_MUNITION: " << data;
DEBUG_LOG(m_logger) << "ControlUnitHandler::SE_FT_CB_WERFER_MUNITION real: " << data - SE_FT_CB_WERFER_MUNITION;
emit vehicleRoundCount(data - SE_FT_CB_WERFER_MUNITION);
return;
}
// todo catch exception SE_FT_CB_WERFER_MUNITION, it does not have any payload... ->
// What a shitty design... seriously :/
/*
* variable 'byte' has 32 bits: XXXX XXXX XXXX XXXX
* command part: XXXX XXXX
* payload: XXXX XXXX
*
* we copy the left 8 bit to a new variable 'commandByte' to check it against
* our defined ReturningSignals enum.
*/
TRACE_LOG(m_logger) << "ControlUnitHandler::onDataReceived ba " << ba;
const unsigned int commandByte = ba.at(0) & 0xFF;
TRACE_LOG(m_logger) << "ControlUnitHandler::onDataReceived byte " << commandByte;
const unsigned int byte = ba.at(1) & 0xFF;
TRACE_LOG(m_logger) << "ControlUnitHandler::onDataReceived cmdbyte" << byte;
TRACE_LOG(m_logger) << "onDataReceived byte: " << byte << " commandByte: " << commandByte;
switch (commandByte)
{
case ReturningSignal::SE_FT_CB_SCHALTER_STATUS:
{
SafetyStatus sst;
sst.loadingBoardWall = !(byte & BIT_POSITION_3);
// sst.loadingBoardWall = byte & BIT_POSITION_3;
if (m_feature != EffectShowManagement::Feature_e::Smoke)
sst.loadingBoardWall = false;
sst.safetyWarning = byte & BIT_POSITION_4;
sst.temperaturWarning = byte & BIT_POSITION_5;
sst.emergencyStop = byte & BIT_POSITION_6;
sst.safetyOn = byte & BIT_POSITION_7;
if (sst.safetyOn && !sst.safetyWarning && !sst.temperaturWarning && !sst.emergencyStop)
emit safetyStatus(SafetyConfirmation_e::SafetyConfirmed);
else if (sst.safetyWarning && !sst.temperaturWarning && !sst.emergencyStop)
emit safetyStatus(SafetyConfirmation_e::SafetyExpiring);
else
emit safetyStatus(SafetyConfirmation_e::SafetyNotConfirmed);
DEBUG_LOG(m_logger) << "safety warning ";
emit safetyWarnings(sst);
break;
}
case ReturningSignal::SE_FT_CB_FZRSTYP:
{
if (byte & BIT_POSITION_5)
m_feature = EffectShowManagement::Feature_e::Explosion24;
else if (byte & BIT_POSITION_6)
m_feature = EffectShowManagement::Feature_e::Explosion48;
else if (byte & BIT_POSITION_7)
m_feature = EffectShowManagement::Feature_e::Smoke;
else
m_feature = EffectShowManagement::Feature_e::NotSpecified;
DEBUG_LOG(m_logger) << "Got Vehicle Type " << m_feature;
emit vehicleType(m_feature);
break;
}
case ReturningSignal::SE_FT_CB_ERROR_STATUS: //tne fehler
{
CardRidges scr;
scr.cardrige1 = byte & BIT_POSITION_7;
scr.cardrige2 = byte & BIT_POSITION_6;
scr.cardrige3 = byte & BIT_POSITION_5;
scr.cardrige4 = byte & BIT_POSITION_4;
scr.cardrige5 = byte & BIT_POSITION_3;
DEBUG_LOG(m_logger) << " CB STATUS FEUER " << byte;
emit vehicleErrorStatus(scr);
break;
}
case ReturningSignal::SE_FT_CB_UBATT: // Followed by 0-255 = 0V - 51V | dez * 0,2 = V
{
emit vehicleBattery((double)byte * 0.2);
break;
}
case ReturningSignal::SE_FT_CB_WERFER_STATUS:
{
CardRidges scr;
scr.cardrige1 = byte & BIT_POSITION_7;
scr.cardrige2 = byte & BIT_POSITION_6;
scr.cardrige3 = byte & BIT_POSITION_5;
scr.cardrige4 = byte & BIT_POSITION_4;
scr.cardrige5 = byte & BIT_POSITION_3;
//emit vehicleSmokeCardridgesStatus(scr);
DEBUG_LOG(m_logger) << " WERFER STATUS ";
emit vehicleFireUnits(scr);
break;
}
case ReturningSignal::SE_FT_CB_NK_STATUS:
{
CardRidges scr;
scr.cardrige1 = byte & BIT_POSITION_7;
scr.cardrige2 = byte & BIT_POSITION_6;
scr.cardrige3 = byte & BIT_POSITION_5;
scr.cardrige4 = byte & BIT_POSITION_4;
scr.cardrige5 = byte & BIT_POSITION_3;
DEBUG_LOG(m_logger) << " NB STATUS ";
emit vehicleSmokeCardridgesStatus(scr);
break;
}
case ReturningSignal::SE_FT_CB_NK_ZUENDUNGS_STATUS:
{
CardRidges scr;
scr.cardrige1 = byte & BIT_POSITION_7;
scr.cardrige2 = byte & BIT_POSITION_6;
scr.cardrige3 = byte & BIT_POSITION_5;
scr.cardrige4 = byte & BIT_POSITION_4;
scr.cardrige5 = byte & BIT_POSITION_3;
emit vehicleSmokeCardridgesFireStatus(scr);
break;
}
case ReturningSignal::SE_FT_CB_RECHNER_BEENDEN:
{
emit vehicleShutDown();
break;
}
case ReturningSignal::SE_FT_CB_SALVE_ERLEDIGT:
{
DEBUG_LOG(m_logger) << "Volley Done";
emit vehicleFinshedVolley(byte);
break;
}
case ReturningSignal::SE_FT_CB_SALVE_UNTERBROCHEN:
{
DEBUG_LOG(m_logger) << "Volley Stopped!!";
emit vehicleStoppedVolley(byte);
//add error to ui
CardRidges scr;
scr.cardrige2 = true;
emit vehicleErrorStatus(scr);
break;
}
case ReturningSignal::SE_FT_CB_SICHERHEIT_WIDERRUFEN:
{
DEBUG_LOG(m_logger) << "Sicherheit widerrufen!!";
emit vehicleSafetyRevoked();
break;
}
default:
{
DEBUG_LOG(m_logger) << "onDataReceived switch default";
break;
}
}
TRACE_LOG(m_logger) << "end of onDataReceived";
}
void ControlUnitHandler::onConnectedToSerialConveter()
{
DEBUG_LOG(m_logger) << "Send Type Request";
send(CommandSignal::FT_SE_CB_FZRSTYP);
}
void ControlUnitHandler::onDisconnectedFromSerialConveter()
{
m_feature = EffectShowManagement::Feature_e::NotSpecified;
emit vehicleType(m_feature);
emit vehicleStoppedVolley(0); //abbort fire just in case
}
} // namespace EffectShowClient
+70
View File
@@ -0,0 +1,70 @@
/**
* Controler interface for the DMF vehicle terminal
* $Id$
* $HeadURL$
* $Author$
* Created by Florian Schult, NLSE, 2018-06-06
*/
#pragma once
#include "logger.h"
#include "handler_vehicle.h"
#include "esc_helper.h"
#include <QObject>
#include <QTimer>
namespace EffectShowClient
{
class ConnectionHandler;
class ControlUnitHandler : public QObject
{
Q_OBJECT
public:
public:
explicit ControlUnitHandler(QObject *parent = nullptr);
~ControlUnitHandler();
bool init();
// Commands to the controler
bool send(const CommandSignal command, const unsigned int roundCount = 0);
signals:
// Messages from the control unit to main/vehicle/etc
void safetyStatus(const SafetyConfirmation_e &safetyConfirmation);
void safetyWarnings(const SafetyStatus &safetyWarning);
void vehicleType(const EffectShowManagement::Feature_e &type);
void vehicleBattery(double battery);
void vehicleRoundCount(int loadedRunds);
void vehilceSmokeAmmunition(int ammunition);
void vehicleShutDown();
void vehicleConnected();
void vehicleSafetyRevoked();
void vehicleFinshedVolley(int rounds);
void vehicleStoppedVolley(int rounds);
void vehicleFireUnits(const CardRidges &cardRidge);
void vehicleErrorStatus(const CardRidges &cardRidge);
void vehicleSmokeCardridgesStatus(const CardRidges &cardRidge);
void vehicleSmokeCardridgesFireStatus(const CardRidges &cardRidge);
private slots:
void onDataReceived(const QByteArray &ba);
void onConnectedToSerialConveter();
void onDisconnectedFromSerialConveter();
private:
ConnectionHandler *m_connectionHandler;
QTimer *m_timer;
EffectShowManagement::Feature_e m_feature;
NGL::INGLLogger &m_logger;
};
} // namespace EffectShowClient
+94
View File
@@ -0,0 +1,94 @@
/**
* DdsHandler for DDS
* $Id$
* $HeadURL$
* $Author$
* Created by Hanna E. Rathje, SLSE, 2015-09-02
*/
#include "dds_handler.h"
#include <DDS/Core/pacemaker.h>
namespace EffectShowClient
{
DdsHandler::DdsHandler(int domainId, int exerciseId)
: m_ddsConnector(std::make_shared<DDSConnector::DdsConnector>(domainId, IDL::PartitionType::Any, exerciseId))
, m_exerciseId(exerciseId)
, m_logger(getLogger("DdsHandler"))
{
DEBUG_LOG(m_logger) << "DdsHandler(" << domainId << ") for partition: " << m_ddsConnector->getDefaultPartition();
}
bool DdsHandler::init(const QStringList &qosFileList)
{
if (!m_ddsConnector->init(qosFileList))
{
ERROR_LOG(m_logger) << "Error initializing dds connections - aborting";
return false;
}
// default initialize Publisher and Subscriber
m_ddsConnector->initPublisherSubscriber();
m_dtcCore = Core::Interface::Dtc::create(m_ddsConnector);
bool bRet = m_dtcCore->enablePartitionTime();
// Pacemaker
m_pacemaker = std::make_shared<Core::Pacemaker>(m_ddsConnector);
m_ddsDts = EffectShowClient::Interface::Dts::create(m_ddsConnector);
m_ddsFts = EffectShowClient::Interface::Fts::create(m_ddsConnector);
bRet &= m_ddsDts->enableAll();
INFO_LOG(m_logger) << "Dts initialised";
bRet &= m_ddsFts->enableAll();
INFO_LOG(m_logger) << "Fts initialised";
if (!bRet)
return false;
// Subscripe for Training Area Base
m_dtcTab = TrainingAreaBase::Interface::Dtc::create(m_ddsConnector);
if (!m_dtcTab->enableFireSmokeMarkerData())
{
ERROR_LOG(m_logger) << "Error initializing TrainingAreaBase DTC";
return false;
}
m_ftcTab = TrainingAreaBase::Interface::Ftc::create(m_ddsConnector);
if (!m_ftcTab->enableSendFireSmokeMarkerData())
{
ERROR_LOG(m_logger) << "Error initializing TrainingAreaBase FTC";
return false;
}
// Subscripe for NOM
m_ftcNom = NotificationManagement::Interface::Ftc::create(m_ddsConnector);
if (!m_ftcNom->enableCreateNotification())
{
ERROR_LOG(m_logger) << "Error initializing NotificationManagement FTC";
return false;
}
// Subscripe for ASM
m_dtcAsm = AssetManagement::Interface::Dtc::create(m_ddsConnector);
if (!m_dtcAsm->enableAsset())
{
ERROR_LOG(m_logger) << "Error initializing AssetManagement DTC";
return false;
}
return true;
}
qint64 DdsHandler::currentPartitionTime() const
{
return m_dtcCore->partitionTime().timeStamp();
}
} // Namespace EffectShowClient
+64
View File
@@ -0,0 +1,64 @@
/**
* DdsHandler for DDS
* $Id$
* $HeadURL$
* $Author$
* Created by Hanna E. Rathje, SLSE, 2015-09-02
*/
#pragma once
#include <DDS/DDSConnector/dds_connector.h>
#include <DDS/Core/core_dtc.h>
#include <EffectShowClient/esc_dts.h>
#include <EffectShowClient/esc_fts.h>
#include <TrainingAreaBase/tab_dtc.h>
#include <TrainingAreaBase/tab_ftc.h>
#include <AssetManagement/asm_dtc.h>
#include <NotificationManagement/nom_ftc.h>
#include "logger.h"
namespace Core
{
class Pacemaker;
}
namespace EffectShowClient
{
class DdsHandler final
{
public:
DdsHandler(int domainId, int exerciseId);
bool init(const QStringList &qosFileList = QStringList());
int getExerciseId() const { return m_exerciseId;}
qint64 currentPartitionTime() const;
std::shared_ptr<Core::Pacemaker> pacemaker() const { return m_pacemaker; }
std::shared_ptr<DDSConnector::DdsConnector> ddsConnector() const { return m_ddsConnector; }
std::shared_ptr<DDSConnector::DdsConnector> dds() const { return m_ddsConnector; }
std::shared_ptr<EffectShowClient::Interface::Dts> dts() const { return m_ddsDts; }
std::shared_ptr<EffectShowClient::Interface::Fts> fts() const { return m_ddsFts; }
std::shared_ptr<TrainingAreaBase::Interface::Dtc> dtcTab() const { return m_dtcTab; }
std::shared_ptr<TrainingAreaBase::Interface::Ftc> ftcTab() const { return m_ftcTab; }
std::shared_ptr<NotificationManagement::Interface::Ftc> ftcNom() const { return m_ftcNom; }
std::shared_ptr<AssetManagement::Interface::Dtc> dtcAsm() const { return m_dtcAsm; }
std::shared_ptr<Core::Interface::Dtc> dtcCore() const { return m_dtcCore;}
private:
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
std::shared_ptr<Core::Pacemaker> m_pacemaker;
std::shared_ptr<Core::Interface::Dtc> m_dtcCore;
std::shared_ptr<EffectShowClient::Interface::Dts> m_ddsDts;
std::shared_ptr<EffectShowClient::Interface::Fts> m_ddsFts;
std::shared_ptr<TrainingAreaBase::Interface::Dtc> m_dtcTab;
std::shared_ptr<TrainingAreaBase::Interface::Ftc> m_ftcTab;
std::shared_ptr<NotificationManagement::Interface::Ftc> m_ftcNom;
std::shared_ptr<AssetManagement::Interface::Dtc> m_dtcAsm;
int m_exerciseId;
NGL::INGLLogger &m_logger;
};
} // namespace EffectShowClient
+231
View File
@@ -0,0 +1,231 @@
/**
* @RDE_HEADER@
* MeteoDataManagement - Static Meteo Data Edit Dialog
* $Id$
* $HeadURL$
* $Author$
* Created by hjl, SLSE, 2016-10-17
*/
#include "esc_convert_from_tab.h"
#include <LtsUtilsCore/qbytearray_byteaccess.h>
namespace EffectShowClient
{
namespace ConvertFromTab
{
//=============================================================================
RxTelegram_e isTelegram(const TrainingAreaBase::FireSmokeMarkerData &data)
{
if (data.payload().size() == 0)
return RxTelegram_e::unknown;
switch (data.payload().at(0))
{
case 150: return RxTelegram_e::EffectShowOrder;
case 155: return RxTelegram_e::RelocationOrder;
case 152: return RxTelegram_e::EffectShowStop;
case 151: return RxTelegram_e::EffectShowContinue;
case 153: return RxTelegram_e::OrderRetract;
case 154: return RxTelegram_e::StatusRequest;
case 156: return RxTelegram_e::MeteoData;
}
return RxTelegram_e::unknown;
}
static inline Core::GeoPosition2D convertGeoPos(const QByteArray &tele, size_t &k)
{
double lon, lat;
LtsUtils::get8Byte(tele, k, lon);
LtsUtils::get8Byte(tele, k, lat);
return Core::GeoPosition2D(lon, lat);
}
//=============================================================================
EffectShowOrder_t convertEffectShowOrder(const TrainingAreaBase::FireSmokeMarkerData &data)
{
EffectShowOrder_t effectShowOrder;
if (data.payload().size() == 0)
return effectShowOrder;
Q_ASSERT(data.payload().size() != 48);
const QByteArray tele(QByteArray::fromRawData(
reinterpret_cast<const char *>(&data.payload().at(0)),
data.payload().size()));
size_t k = 1;
LtsUtils::get2Byte(tele, k, effectShowOrder.idEffectShow);
uint64_t tmp;
LtsUtils::get4Byte(tele, k, tmp); // interpret as unsigned
effectShowOrder.startTime = tmp;
effectShowOrder.centerPosition = convertGeoPos(tele, k);
LtsUtils::get1Byte(tele, k, tmp); effectShowOrder.areaWidth = tmp;
LtsUtils::get1Byte(tele, k, tmp); effectShowOrder.areaDepth = tmp;
// 50m squares
effectShowOrder.areaWidth *= 50;
effectShowOrder.areaDepth *= 50;
qint16 angle;
LtsUtils::get2Byte(tele, k, angle);
effectShowOrder.rotation = double(angle) * 0.01;
effectShowOrder.lowerLeftPosition = convertGeoPos(tele, k);
LtsUtils::get1Byte(tele, k, effectShowOrder.numOfVolley);
LtsUtils::get1Byte(tele, k, effectShowOrder.shotsInTotal);
LtsUtils::get1Byte(tele, k, effectShowOrder.typeOfAmmunition);
LtsUtils::get2Byte(tele, k, tmp); effectShowOrder.duration = tmp;
const size_t len = tele.size();
QByteArray ba;
while (k < len)
ba += tele.at(k++);
effectShowOrder.name = QString::fromUtf8(ba);
return effectShowOrder;
}
//=============================================================================
RelocationOrder_t convertRelocationOrder(const TrainingAreaBase::FireSmokeMarkerData &data)
{
RelocationOrder_t relocationOrder;
if (data.payload().size() == 0)
return relocationOrder;
Q_ASSERT(data.payload().size() >= 7);
const QByteArray tele(QByteArray::fromRawData(
reinterpret_cast<const char *>(&data.payload().at(0)),
data.payload().size()));
size_t k = 1;
LtsUtils::get2Byte(tele, k, relocationOrder.idRelocation);
uint64_t tmp;
LtsUtils::get4Byte(tele, k, tmp); // interpret as unsigned
relocationOrder.executionTime = tmp;
relocationOrder.centerPosition = convertGeoPos(tele, k);
const size_t len = tele.size();
QByteArray ba;
while (k < len)
ba += tele.at(k++);
relocationOrder.infoText = QString::fromUtf8(ba);
return relocationOrder;
}
//=============================================================================
int convertEffectShowStop(const TrainingAreaBase::FireSmokeMarkerData &data)
{
int idEffectShow = 0;
if (data.payload().size() == 0)
return idEffectShow;
Q_ASSERT(data.payload().size() != 3);
const QByteArray tele(QByteArray::fromRawData(
reinterpret_cast<const char *>(&data.payload().at(0)),
data.payload().size()));
size_t k = 1;
LtsUtils::get2Byte(tele, k, idEffectShow);
return idEffectShow;
}
//=============================================================================
EffectShowContinue_t convertEffectShowContinue(const TrainingAreaBase::FireSmokeMarkerData &data)
{
EffectShowContinue_t effectShowContinue;
if (data.payload().size() == 0)
return effectShowContinue;
Q_ASSERT(data.payload().size() != 7);
const QByteArray tele(QByteArray::fromRawData(
reinterpret_cast<const char *>(&data.payload().at(0)),
data.payload().size()));
size_t k = 1;
LtsUtils::get2Byte(tele, k, effectShowContinue.idEffectShow);
uint64_t tmp;
LtsUtils::get4Byte(tele, k, tmp); // interpret as unsigned
effectShowContinue.executionTime = tmp;
return effectShowContinue;
}
//=============================================================================
OrderRetract_t convertOrderRetract(const TrainingAreaBase::FireSmokeMarkerData &data)
{
OrderRetract_t orderRetract;
if (data.payload().size() == 0)
return orderRetract;
Q_ASSERT(data.payload().size() != 4);
const QByteArray tele(QByteArray::fromRawData(
reinterpret_cast<const char *>(&data.payload().at(0)),
data.payload().size()));
size_t k = 1;
LtsUtils::get1Byte(tele, k, orderRetract.orderType);
LtsUtils::get2Byte(tele, k, orderRetract.id);
return orderRetract;
}
//=============================================================================
bool convertStatusRequest(const TrainingAreaBase::FireSmokeMarkerData &data)
{
if (data.payload().size() <2)
return false;
Q_ASSERT(data.payload().size() != 2);
const std::vector<uint8_t> &tele = data.payload();
return (tele.at(1) == 154);
}
//=============================================================================
EffectShowClient::MeteoNearVehicle convertMeteoData(const TrainingAreaBase::FireSmokeMarkerData &data)
{
EffectShowClient::MeteoNearVehicle meteoData;
if (data.payload().size() == 0)
{
meteoData.isValid(false);
return meteoData;
}
Q_ASSERT(data.payload().size() != 11);
const QByteArray tele(QByteArray::fromRawData(
reinterpret_cast<const char *>(&data.payload().at(0)),
data.payload().size()));
qint16 word = 0;
size_t k = 1;
LtsUtils::get2Byte(tele, k, word);
meteoData.temperature(double(word) / 10.0);
LtsUtils::get2Byte(tele, k, word);
meteoData.humidity(double(word));
LtsUtils::get2Byte(tele, k, word);
meteoData.pressure(double(word));
LtsUtils::get2Byte(tele, k, word);
meteoData.windDirection(double(word) * 0.01);
LtsUtils::get2Byte(tele, k, word);
meteoData.windSpeed(double(word));
meteoData.isValid(true);
return meteoData;
}
} // namespace ConvertFromTab
} // namespace EffectShowClient
+125
View File
@@ -0,0 +1,125 @@
/**
* @RDE_HEADER@
* MeteoDataManagement - Static Meteo Data Edit Dialog
* $Id$
* $HeadURL$
* $Author$
* Created by hjl, SLSE, 2016-10-17
*/
#pragma once
#include <TrainingAreaBase/tab_dtc.h>
#include <EffectShowClient/esc_dts.h>
#include <QString>
namespace EffectShowClient
{
/**
* @brief Converts the data telegrams to be read from Training Area Base proxy.
*
* For the telegram data to be converted see GUEZSB60_ICD-0046C.
*/
namespace ConvertFromTab
{
/**
* @brief Rx Telegram types.
*/
enum class RxTelegram_e { EffectShowOrder, RelocationOrder, EffectShowStop, EffectShowContinue, OrderRetract, StatusRequest, MeteoData, unknown };
/**
* @brief Returns the type of telegram related to the received data.
* @return The type of the telegram
*/
RxTelegram_e isTelegram(const TrainingAreaBase::FireSmokeMarkerData &data);
/**
* @brief Order effect show.
*/
struct EffectShowOrder_t
{
qint16 idEffectShow = 0; // ID effect show
qint64 startTime = 0; // GPS time
Core::GeoPosition2D centerPosition; // center pos effect area
int areaWidth = 0; // [0..300]
int areaDepth = 0; // [0..300]
double rotation = 0; // [deg]
Core::GeoPosition2D lowerLeftPosition; // lower left corner effect area
qint8 numOfVolley = 0; // number of volley
qint8 shotsInTotal = 0; // shots in total
qint8 typeOfAmmunition = 0; // type of ammunition
qint16 duration = 0; // duration of the effect show
QString name;
};
/**
* @brief Returns Effect Show order from telegram.
* @param[out] effectShowOrder Effect Show order from telegram.
*/
EffectShowOrder_t convertEffectShowOrder(const TrainingAreaBase::FireSmokeMarkerData &data);
/**
* @brief Order Relocation of Effect Show Actor.
*/
struct RelocationOrder_t
{
qint16 idRelocation = 0;
qint64 executionTime = 0; // GPS time [s]
Core::GeoPosition2D centerPosition; // center pos effect area
QString infoText; // max ASCII-char: 40
};
/**
* @brief Returns the order to relocation from the telegram.
* @param[out] relocationOrder Relocation Order from telegram
*/
RelocationOrder_t convertRelocationOrder(const TrainingAreaBase::FireSmokeMarkerData &data);
/**
* @brief Returns the order to stop the effect show from telegram.
* param[out] idEffectShow ID of the effect show to be stoped
*/
int convertEffectShowStop(const TrainingAreaBase::FireSmokeMarkerData &data);
/**
* @brief Order continue Effect Show.
*/
struct EffectShowContinue_t
{
qint16 idEffectShow = 0; // ID of effect show
qint64 executionTime = 0; // GPS time [s]
};
/**
* @brief Returns the order to continue the effect show from telegram.
* @param[out] effectShowContinue Order to continue the effect show
*/
EffectShowContinue_t convertEffectShowContinue(const TrainingAreaBase::FireSmokeMarkerData &data);
/**
* @brief Retract order.
*/
struct OrderRetract_t
{
qint8 orderType = 0; // 0=Relocation; 1=Effect Show
qint16 id = 0; // Id of Relocation or Effect Show
};
/**
* @brief Returns the order to be retract from telegram.
* param[out] rectractPrder Order to rectract the effect show
*/
OrderRetract_t convertOrderRetract(const TrainingAreaBase::FireSmokeMarkerData &data);
/**
* @brief Returns the status request from telegram.
* return (true)Status request.
*/
bool convertStatusRequest(const TrainingAreaBase::FireSmokeMarkerData &data);
/**
* @brief Returns the meteo data from Telegram.
* @param[out] meteoData Meteo data from the telegram.
*/
EffectShowClient::MeteoNearVehicle convertMeteoData(const TrainingAreaBase::FireSmokeMarkerData &data);
}
} //namespace EffectShowManagement
+64
View File
@@ -0,0 +1,64 @@
/**
* @RDE_HEADER@
* MeteoDataManagement - Static Meteo Data Edit Dialog
* $Id$
* $HeadURL$
* $Author$
* Created by hjl, SLSE, 2016-10-17
*/
#include "esc_convert_to_tab.h"
#include <LtsUtilsCore/qbytearray_byteaccess.h>
#include <LtsUtilsCore/dds_vector.h>
#include <QByteArray>
namespace EffectShowClient
{
namespace ConvertToTab
{
//=============================================================================
std::vector<uint8_t> convertOrderConfirmation(const OrderConfirmation_t &orderConfirmation)
{
QByteArray ba;
ba.reserve(45);
LtsUtils::set1Byte(120, ba);
LtsUtils::set1Byte(int(orderConfirmation.orderType), ba);
LtsUtils::set2Byte(orderConfirmation.orderId, ba);
LtsUtils::set1Byte(orderConfirmation.confirmation.underlying(), ba);
const QByteArray txt = orderConfirmation.answerText.toUtf8();
const int len = txt.length() > 39 ? 39 : txt.length();
for (int i = 0; i < len; ++i)
LtsUtils::set1Byte(txt.at(i), ba);
return LtsUtils::convert<std::vector<uint8_t>>(ba);
}
//=============================================================================
std::vector<uint8_t> convertVehicleStatus(const VehicleStatus_t &vehicleStatus)
{
QByteArray ba;
ba.reserve(5);
LtsUtils::set1Byte(121, ba);
LtsUtils::set1Byte(vehicleStatus.operational ? 1 : 0, ba);
LtsUtils::set1Byte(vehicleStatus.ammunitionMagazine, ba);
LtsUtils::set1Byte(vehicleStatus.ammunitionAvailable, ba);
uint8_t byte = 0;
if (vehicleStatus.inclinationSensorFail) byte = byte | 0x80;
if (vehicleStatus.navigationFail) byte = byte | 0x40;
if (vehicleStatus.airSpeedMeterFail) byte = byte | 0x20;
if (vehicleStatus.controlComputerFail) byte = byte | 0x10;
if (vehicleStatus.magazineFail) byte = byte | 0x08;
byte = byte | ((uint8_t)vehicleStatus.feature << 1);
LtsUtils::set1Byte(byte, ba);
return LtsUtils::convert<std::vector<uint8_t>>(ba);
}
} // namespace ConvertToTab
} // namespace EffectShowClient
+69
View File
@@ -0,0 +1,69 @@
/**
* @RDE_HEADER@
* MeteoDataManagement - Static Meteo Data Edit Dialog
* $Id$
* $HeadURL$
* $Author$
* Created by hjl, SLSE, 2016-10-17
*/
#pragma once
#include <TrainingAreaBase/tab_dtc.h>
#include <EffectShowManagement/esm_dtc.h>
#include <QString>
namespace EffectShowClient
{
/**
* @brief Converts the data telegrams to be sent to Training Area Base proxy.
*
* For the telegram data to be converted see GUEZSB60_ICD-0046C.
*/
namespace ConvertToTab
{
/**
* @brief Order types.
*/
enum class OrderType_e { Relocation = 0, EffectShow = 1 };
/**
* @brief Order confirmation data. ICD Tele: DMF-Auftragsbestaetigung; Parameter: Bestaetigung
*/
struct OrderConfirmation_t
{
OrderType_e orderType = OrderType_e::Relocation; // 0=Relocation; 1=Effect Show
qint16 orderId = 0; // Id of relocation or effect show
EffectShowManagement::OrderConfirmation_e confirmation = EffectShowManagement::OrderConfirmation_e::WaitingForAcceptance;
QString answerText;
};
/**
* @brief Returns the telegram for order confirmation data.
* @param[in] orderConfirmation Order Confirmation
* @return Telegram for order confirmation data
*/
std::vector<uint8_t> convertOrderConfirmation(const OrderConfirmation_t &orderConfirmation);
/**
* @brief Order confirmation data. ICD Tele: DMF-Auftragsbestaetigung; Parameter: Bestaetigung
*/
struct VehicleStatus_t
{
int operational = 0;
int ammunitionMagazine = 0;
int ammunitionAvailable = 0;
int feature = 0;
bool inclinationSensorFail = false;
bool navigationFail = false;
bool airSpeedMeterFail = false;
bool controlComputerFail = false;
bool magazineFail = false;
};
/**
* @brief Returns the telegram for effect show vehicle status data.
* @param[in] vehicleStatus Vehicle Status data
* @return Telegram for vehicle status data
*/
std::vector<uint8_t> convertVehicleStatus(const VehicleStatus_t &vehicleStatus);
} // namespace ConvertToTab
} //namespace EffectShowClient
+52
View File
@@ -0,0 +1,52 @@
/**
* Export definitions
* $Id$
* $HeadURL$
* $Author$
* Created by Hanna E. Rathje, SLSE, 2015-08-04
*/
#pragma once
#include <QtCore/qglobal.h>
#ifndef ESC_COMMON_EXPORT
# ifdef BUILD_STATIC_LIBRARIES
# define ESC_COMMON_EXPORT
# else
# if defined(MAKE_SVCESCCOMMON_LIB)
# define ESC_COMMON_EXPORT Q_DECL_EXPORT
# ifndef WIN32
# ifdef NDDSUSERDllExport
# undef NDDSUSERDllExport
# endif
# define NDDSUSERDllExport Q_DECL_EXPORT
# endif
# else
# define ESC_COMMON_EXPORT Q_DECL_IMPORT
# endif
# endif
#endif
#ifndef ESC_CLIENT_EXPORT
# ifdef BUILD_STATIC_LIBRARIES
# define ESC_CLIENT_EXPORT
# else
# if defined(MAKE_SVCESCCLIENT_LIB)
# define ESC_CLIENT_EXPORT Q_DECL_EXPORT
# else
# define ESC_CLIENT_EXPORT Q_DECL_IMPORT
# endif
# endif
#endif
#ifndef ESC_SERVER_EXPORT
# ifdef BUILD_STATIC_LIBRARIES
# define ESC_SERVER_EXPORT
# else
# if defined(MAKE_SVCESCSERVER_LIB)
# define ESC_SERVER_EXPORT Q_DECL_EXPORT
# else
# define ESC_SERVER_EXPORT Q_DECL_IMPORT
# endif
# endif
#endif
+96
View File
@@ -0,0 +1,96 @@
/**
* Handler for player data
* $Id$
* $HeadURL$
* $Author$
* Created by gr, SLSE, 2017-02-20
*/
#pragma once
#include <QObject>
namespace EffectShowClient
{
constexpr int PRE_START_TIME = 5 * 1000;
constexpr int POST_END_TIME = 30 * 1000;
struct StatusExplosionFiring_t
{
qint64 remainingTime_s = 0;
int remainingShots = 0;
int shotsPerVolley = 0;
int remainingVolley = 0;
};
struct StatusSmokeFiring_t
{
int remainingDistance_m = 0;
int remainingTime_s = 0;
};
enum CommandSignal : const unsigned char
{
FT_SE_CB_SCHALTER_STATUS = 192,
FT_SE_CB_FZRSTYP = 240,
FT_SE_CB_ERROR_STATUS = 244,
FT_SE_CB_UBATT = 255,
FT_SE_CB_WERFER_STATUS = 128, // Plus round count (0-48) 128-176 | Plunging fire
FT_SE_CB_NK_STATUS = 202,
FT_SE_CB_NK_ZUENDUNGS_STATUS = 224,
FT_SE_CB_SALVE_ERLEDIGT = 15,
FT_SE_CB_SICHERHEIT_WIDERRUFEN = 41,
FT_SE_CB_SALVE_UNTERBRECHEN = 42,
FT_SE_CB_WERFER_MUNITION = 43 // Plus round count (0-5) 43-91 | Explo
};
enum ReturningSignal : const unsigned char
{
SE_FT_CB_WERFER_MUNITION = 43, // direct round count... so stupid... 43-91 | Smoke
SE_FT_CB_SCHALTER_STATUS = 192,
SE_FT_CB_FZRSTYP = 240,
SE_FT_CB_ERROR_STATUS = 244,
SE_FT_CB_UBATT = 255, // Followed by 0-255 = 0V - 51V | dez * 0,2 = V
SE_FT_CB_WERFER_STATUS = 144, // Followed by round count (0-48) 144-192 | Plunging fire
SE_FT_CB_NK_STATUS = 202,
SE_FT_CB_NK_ZUENDUNGS_STATUS = 224,
SE_FT_CB_RECHNER_BEENDEN = 213,
SE_FT_CB_SALVE_ERLEDIGT = 15,
SE_FT_CB_SICHERHEIT_WIDERRUFEN = 41,
SE_FT_CB_SALVE_UNTERBROCHEN = 42
};
enum BitPosition : const unsigned char
{
BIT_POSITION_0 = 1, // 0000 0001
BIT_POSITION_1 = 2, // 0000 0010
BIT_POSITION_2 = 4, // 0000 0100
BIT_POSITION_3 = 8, // 0000 1000
BIT_POSITION_4 = 16, // 0001 0000
BIT_POSITION_5 = 32, // 0010 0000
BIT_POSITION_6 = 64, // 0100 0000
BIT_POSITION_7 = 128 // 1000 0000
};
struct CardRidges
{
bool cardrige1 = false;
bool cardrige2 = false;
bool cardrige3 = false;
bool cardrige4 = false;
bool cardrige5 = false;
};
struct SafetyStatus
{
bool safetyWarning = false;
bool temperaturWarning = false;
bool emergencyStop = false;
bool safetyOn = false;
bool loadingBoardWall = false;
};
enum class EffectShowControl_e : int { Start, Stop, Continue, Abort, StopTimer };
}
Q_DECLARE_METATYPE(EffectShowClient::CardRidges)
+165
View File
@@ -0,0 +1,165 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<service namespace="EffectShowClient" abbreviation="ESC" procNames="EffectShowClient" exerciseDependency="Exercise" groups="ExercisePreparation,ExerciseExecution,ExercisePaused">
<rcs>
<Id Id="$Id: ea_export_script.txt 41311 2018-04-23 09:43:45Z ehrlicher $"/>
<HeadURL HeadURL="$HeadURL: svn://slssvn/TDS/branches/product/devel/trunk/Lts/Common/CodeGen/ea_export_script.txt $"/>
<Author Author="$Author: ehrlicher $"/>
</rcs>
<tables>
<table name="esc_order">
<column name="id" datatype="integer" isPrimaryKey="1">
<sequence start="1" increment="1"/>
</column>
<column name="center_position" datatype="point_2d"/>
<column name="id_order" datatype="integer"/>
<column name="num_of_volley" datatype="integer"/>
<column name="shots_per_volley" datatype="integer"/>
<column name="order_confirmation" datatype="integer"/>
<column name="start_time" datatype="bigint"/>
<column name="duration" datatype="bigint"/>
<column name="lower_left_position" datatype="point_2d"/>
<column name="area_width" datatype="integer"/>
<column name="area_depth" datatype="integer"/>
<column name="area_rotation" datatype="real"/>
<column name="type_of_ammunition" datatype="integer"/>
<column name="type_of_order" datatype="integer" comment="0 = Relocation 1 = Effect Show"/>
<column name="info" datatype="text"/>
<constraint name="UQ_esc_order_id" type="unique">
<column name="id"/>
</constraint>
</table>
</tables>
<views/>
<dbServiceStructs>
<serviceStruct name="EscOrder" table="esc_order"/>
<table name="esc_order"/>
</dbServiceStructs>
<topicTypes>
<topicType name="SendReadinessRequest">
<column name="readiness" idlType="boolean"/>
</topicType>
<topicType name="FiringExplosionEntity" isDataObject="1" autosubscribe="1" routeToClient="1" routeToServer="0" routeInReplay="0">
<column name="numberOfVolley" idlType="long"/>
<column name="numberOfShot" idlType="long"/>
<column name="duration" idlType="long long"/>
<column name="safetyConfirmation" idlType="SafetyConfirmation_e"/>
<column name="idEffectShow" idlType="long"/>
<column name="firingClearanceTime" idlType="long long" isOptional="1"/>
<column name="endOfFiringClearanceTime" idlType="long long" isOptional="1"/>
<column name="idOrder" idlType="long"/>
<column name="remainingShots" idlType="long"/>
<column name="remainingTime" idlType="long"/>
<column name="remainingVolleys" idlType="long"/>
<column name="fireEnabled" idlType="boolean"/>
<column name="carriedOutEnabled" idlType="boolean"/>
<column name="isActive" idlType="boolean"/>
</topicType>
<topicType name="FiringSmokeEntity" isDataObject="1" autosubscribe="1" routeToClient="1" routeToServer="0" routeInReplay="0">
<column name="lengthOfFogZone" idlType="long"/>
<column name="directionOfFogZone" idlType="double"/>
<column name="safetyConfirmation" idlType="SafetyConfirmation_e"/>
<column name="idEffectShow" idlType="long"/>
<column name="firingClearanceTime" idlType="long long" isOptional="1"/>
<column name="endOfFiringClearanceTime" idlType="long long" isOptional="1"/>
<column name="idOrder" idlType="long"/>
<column name="remainingDistance" idlType="long"/>
<column name="remainingTime" idlType="long long"/>
<column name="duration" idlType="long long"/>
<column name="carriedOutEnabled" idlType="boolean"/>
</topicType>
<topicType name="MeteoNearVehicle" isDataObject="1" autosubscribe="1" routeToClient="1" routeToServer="0" routeInReplay="0">
<column name="temperature" idlType="double"/>
<column name="humidity" idlType="double"/>
<column name="pressure" idlType="double"/>
<column name="windSpeed" idlType="double"/>
<column name="windDirection" idlType="double"/>
<column name="isValid" idlType="boolean"/>
</topicType>
<topicType name="OperatingConditionEntity" isDataObject="1" autosubscribe="1" routeToClient="1" routeToServer="0" routeInReplay="0">
<column name="ammunitionMagazine" idlType="long"/>
<column name="ammunitionAvailable" idlType="long"/>
<column name="firingUnitReadyFwdLh" idlType="boolean"/>
<column name="firingUnitReadyAftLh" idlType="boolean"/>
<column name="firingUnitReadyFwdRh" idlType="boolean"/>
<column name="firingUnitReadyAftRh" idlType="boolean"/>
<column name="batteryVoltage" idlType="double"/>
<column name="vehicleFeature" idlType="EffectShowManagement::Feature_e"/>
<column name="smokeCartridge1" idlType="StatusSmokeCartridge_e"/>
<column name="smokeCartridge2" idlType="StatusSmokeCartridge_e"/>
<column name="smokeCartridge3" idlType="StatusSmokeCartridge_e"/>
<column name="smokeCartridge4" idlType="StatusSmokeCartridge_e"/>
<column name="smokeCartridge5" idlType="StatusSmokeCartridge_e"/>
<column name="temperatureWarning" idlType="boolean"/>
<column name="loadingBoardWall" idlType="boolean"/>
<column name="emergencyStop" idlType="boolean"/>
<column name="errorSmoke" idlType="boolean"/>
<column name="errorFireUnit" idlType="boolean"/>
<column name="errorPanel" idlType="boolean"/>
<column name="errorEquipment" idlType="boolean"/>
<column name="errorGeneral" idlType="boolean"/>
<column name="readiness" idlType="boolean"/>
</topicType>
<topicType name="Order" isDataObject="1" autosubscribe="1" routeToClient="1" routeToServer="0" routeInReplay="0" baseValueType="Core::BaseEntity">
<column name="position" idlType="Core::GeoPosition2D"/>
<column name="lowerLeftPosition" idlType="Core::GeoPosition2D"/>
<column name="idOrder" idlType="long"/>
<column name="startTime" idlType="long long" isOptional="1"/>
<column name="duration" idlType="long long"/>
<column name="numOfVolley" idlType="long"/>
<column name="shotsPerVolley" idlType="long"/>
<column name="orderConfirmation" idlType="EffectShowManagement::OrderConfirmation_e"/>
<column name="areaWidth" idlType="long"/>
<column name="areaDepth" idlType="long"/>
<column name="areaRotation" idlType="long"/>
<column name="typeOfOrder" idlType="long"/>
<column name="info" idlType="string"/>
</topicType>
<topicType name="ManuallyExplosionRequest">
<column name="numberOfVolley" idlType="long"/>
<column name="numberOfShot" idlType="long"/>
<column name="duration" idlType="long long"/>
<column name="pbFire" idlType="boolean"/>
<column name="pbAbort" idlType="boolean"/>
<column name="pbInterrupt" idlType="boolean"/>
<column name="pbCarriedOut" idlType="boolean"/>
</topicType>
<topicType name="ManuallySmokeRequest">
<column name="lengthOfFogZone" idlType="long"/>
<column name="directionOfFogZone" idlType="long"/>
<column name="pbAbort" idlType="boolean"/>
<column name="pbCarriedOut" idlType="boolean"/>
</topicType>
<topicType name="OrderModifyRequest">
<column name="id" idlType="long"/>
<column name="orderConfirmation" idlType="EffectShowManagement::OrderConfirmation_e"/>
<column name="answerText" idlType="string"/>
</topicType>
<topicType name="SendAmmunitionRequest">
<column name="ammunitionMagazine" idlType="long"/>
<column name="ammunitionAvailable" idlType="long"/>
</topicType>
<topicType name="SendSafetyRevokeRequest">
<column name="revoke" idlType="boolean"/>
</topicType>
</topicTypes>
<functionTopics>
<functionTopic name="SendReadiness" requestTopicType="SendReadinessRequest" replyTopicType="Core::FunctionReply" requestTopicName="SendReadinessRequest" replyTopicName="SendReadinessReply" routeInReplay="0"/>
<functionTopic name="ManuallyExplosion" requestTopicType="ManuallyExplosionRequest" replyTopicType="Core::FunctionReply" requestTopicName="ManuallyExplosionRequest" replyTopicName="ManuallyExplosionReply" routeInReplay="0"/>
<functionTopic name="ManuallySmoke" requestTopicType="ManuallySmokeRequest" replyTopicType="Core::FunctionReply" requestTopicName="ManuallySmokeRequest" replyTopicName="ManuallySmokeReply" routeInReplay="0"/>
<functionTopic name="OrderModify" requestTopicType="OrderModifyRequest" replyTopicType="Core::FunctionReply" requestTopicName="OrderModifyRequest" replyTopicName="OrderModifyReply" routeInReplay="0"/>
<functionTopic name="SendAmmunition" requestTopicType="SendAmmunitionRequest" replyTopicType="Core::FunctionReply" requestTopicName="SendAmmunitionRequest" replyTopicName="SendAmmunitionReply" routeInReplay="0"/>
<functionTopic name="SendSafetyRevoke" requestTopicType="SendSafetyRevokeRequest" replyTopicType="Core::FunctionReply" requestTopicName="SendSafetyRevokeRequest" replyTopicName="SendSafetyRevokeReply" routeInReplay="0"/>
</functionTopics>
<enumerations>
<enumeration name="SafetyConfirmation_e">
<attribute key="SafetyNotConfirmed" value="0"/>
<attribute key="SafetyExpiring" value="1"/>
<attribute key="SafetyConfirmed" value="2"/>
</enumeration>
<enumeration name="StatusSmokeCartridge_e">
<attribute key="NotReady" value="0"/>
<attribute key="Ready" value="1"/>
<attribute key="Smoking" value="2"/>
</enumeration>
</enumerations>
</service>
+304
View File
@@ -0,0 +1,304 @@
/**
* Handler for all exercise objects
* $Id$
* $HeadURL$
* $Author$
* Created by Hanna E. Rathje, SLSE, 2015-09-03
*/
#include "handler_firing_explosion.h"
#include "esc_db.h"
#include "main_handler.h"
#include "handler_tab_data.h"
#include "handler_order.h"
#include "handler_vehicle.h"
#include "control_unit_handler.h"
#include <QTimer>
#include <QCoreApplication>
#include <NGLLogger/NGLLoggerBootstrap.h>
namespace EffectShowClient
{
//=============================================================================
HandlerFiringExplosion::HandlerFiringExplosion(MainHandler *mainHandler,
QObject *parent)
: QObject(parent)
, ManuallyExplosionRequestHandler(mainHandler->dds()->fts())
, m_mainHandler(mainHandler)
, m_logger(getLogger("HandlerFiringExplosion"))
{
}
//=============================================================================
HandlerFiringExplosion::~HandlerFiringExplosion()
{}
//=============================================================================
bool HandlerFiringExplosion::init()
{
connect(m_mainHandler->handlerOrder().get(), &HandlerOrder::effectShowStarted,
this, &HandlerFiringExplosion::onEffectShowStarted);
connect(m_mainHandler->handlerOrder().get(), &HandlerOrder::effectShowInterrupted,
this, &HandlerFiringExplosion::onEffectShowInterrupted);
connect(m_mainHandler->handlerOrder().get(), &HandlerOrder::endHandlerFiring,
this, &HandlerFiringExplosion::onEndHandlerFiring);
connect(m_mainHandler->handlerTabData().get(), &HandlerTabData::effectShowStopped,
this, &HandlerFiringExplosion::onEffectShowStopped);
connect(m_mainHandler->handlerOrder().get(), &HandlerOrder::startHandlerFiring,
this, &HandlerFiringExplosion::onStartHandlerFiring);
connect(m_mainHandler->handlerTabData().get(), &HandlerTabData::effectShowContinued,
this, &HandlerFiringExplosion::onEffectShowContinued);
connect(m_mainHandler->handlerControlUnit().get(), &ControlUnitHandler::safetyStatus,
this, &HandlerFiringExplosion::onSafetyConfirmation);
connect(m_mainHandler->handlerVehicle().get(), &HandlerVehicle::readyForExplosionFiring,
this, &HandlerFiringExplosion::onReadyForExplosionFiring);
connect(m_mainHandler->handlerVehicle().get(), &HandlerVehicle::statusExplosionFiring,
this, &HandlerFiringExplosion::onStatusExplosionFiring);
return true;
}
//=============================================================================
void HandlerFiringExplosion::setFiringClearanceDuration()
{
if (m_firingExplosionEntity.firingClearanceTime().is_set())
{
qint64 pre = m_firingExplosionEntity.firingClearanceTime().get();
qint64 post = pre;
pre -= PRE_START_TIME;
post += m_firingExplosionEntity.duration() + POST_END_TIME; //as we already start "duration" earlier
m_firingExplosionEntity.firingClearanceTime().set(pre);
m_firingExplosionEntity.endOfFiringClearanceTime().set(post);
// m_firingExplosionEntity.firingClearanceTime().set(m_firingExplosionEntity.firingClearanceTime().get() - (2 * m_firingClearanceDuration));
}
else
m_firingExplosionEntity.endOfFiringClearanceTime().reset();
m_mainHandler->dds()->dts()->publish(m_firingExplosionEntity);
}
//-----------------------------------------------------------------------------
void HandlerFiringExplosion::onStartHandlerFiring(const Database::EscOrder &escOrder)
{
DEBUG_LOG(m_logger) << "onStartHandlerFiring()";
DEBUG_LOG(m_logger) << "numOfVolley: " << escOrder.numOfVolley
<< "shotsInTotal: " << escOrder.shotsPerVolley
<< "duration: " << escOrder.duration;
if (escOrder.numOfVolley < 0)
return;
//we are interrupted
m_firingExplosionEntity.idEffectShow(escOrder.id);
m_firingExplosionEntity.fireEnabled(false);
m_firingExplosionEntity.carriedOutEnabled(false);
m_firingExplosionEntity.idOrder(escOrder.idOrder);
if (m_isNew)
{
m_firingExplosionEntity.numberOfVolley(escOrder.numOfVolley);
m_firingExplosionEntity.numberOfShot(escOrder.shotsPerVolley);
m_firingExplosionEntity.remainingVolleys(escOrder.numOfVolley);
m_firingExplosionEntity.remainingShots(m_firingExplosionEntity.numberOfShot());
DEBUG_LOG(m_logger) << "Changed number of Shots Remain: " << m_firingExplosionEntity.numberOfShot();
m_isNew = false;
}
m_firingExplosionEntity.duration(escOrder.duration * 1000);
m_firingExplosionEntity.remainingTime(escOrder.duration * 1000); //here to avoid traffic?
if (escOrder.startTime > 0)
m_firingExplosionEntity.firingClearanceTime().set(escOrder.startTime);
else
{
WARNING_LOG(m_logger) << "reset clearance time";
m_firingExplosionEntity.firingClearanceTime().reset();
}
if (m_firingExplosionEntity.duration() <= 0 ||
m_firingExplosionEntity.numberOfShot() <= 0 ||
m_firingExplosionEntity.numberOfVolley() <= 0)
{
WARNING_LOG(m_logger) << "Won't start Explosion ";
return;
}
setFiringClearanceDuration();
m_mainHandler->handlerVehicle()->setExplosionParameter(m_firingExplosionEntity.remainingVolleys(),
m_firingExplosionEntity.remainingShots(),
m_firingExplosionEntity.remainingTime());
}
//-----------------------------------------------------------------------------
void HandlerFiringExplosion::onEndHandlerFiring(const Database::EscOrder &escOrder)
{
DEBUG_LOG(m_logger) << "onStopHandlerFiring()";
DEBUG_LOG(m_logger) << "numOfVolley: " << escOrder.numOfVolley
<< "shotsInTotal: " << escOrder.shotsPerVolley
<< "duration: " << escOrder.duration;
if (escOrder.numOfVolley < 0 || escOrder.idOrder != m_firingExplosionEntity.idOrder())
return;
m_firingExplosionEntity.idEffectShow(0);
m_firingExplosionEntity.fireEnabled(false);
m_firingExplosionEntity.isActive(false);
m_firingExplosionEntity.idOrder(0);
m_firingExplosionEntity.numberOfVolley(0);
m_firingExplosionEntity.numberOfShot(0);
m_firingExplosionEntity.remainingShots(0);
m_firingExplosionEntity.remainingVolleys(0);
m_firingExplosionEntity.duration(0);
m_firingExplosionEntity.firingClearanceTime(dds::core::optional<rti::core::int64>());
m_firingExplosionEntity.endOfFiringClearanceTime(dds::core::optional<rti::core::int64>());
m_firingExplosionEntity.fireEnabled(false);
m_firingExplosionEntity.carriedOutEnabled(false);
m_firingExplosionEntity.remainingTime(0); //here to avoid traffic?
m_mainHandler->dds()->dts()->publish(m_firingExplosionEntity);
m_isNew = true;
//reset effect show
}
//-----------------------------------------------------------------------------
void HandlerFiringExplosion::onEffectShowStopped(qint16 idEffectShow)
{
if (idEffectShow != m_firingExplosionEntity.idEffectShow())
{
ERROR_LOG(m_logger) << "EffectShow IDs not consistent: " << idEffectShow << " / " << m_firingExplosionEntity.idEffectShow();
return;
}
m_firingExplosionEntity.isActive(false);
}
//-----------------------------------------------------------------------------
void HandlerFiringExplosion::onEffectShowContinued(const ConvertFromTab::EffectShowContinue_t &effectShowContinue)
{
if (effectShowContinue.idEffectShow != m_firingExplosionEntity.idEffectShow())
{
ERROR_LOG(m_logger) << "EffectShow IDs not consistent: " << effectShowContinue.idEffectShow << " / " << m_firingExplosionEntity.idEffectShow();
return;
}
}
//-----------------------------------------------------------------------------
void HandlerFiringExplosion::onSafetyConfirmation(const SafetyConfirmation_e &safetyConfirmation)
{
m_firingExplosionEntity.safetyConfirmation(safetyConfirmation);
if (m_lastState == SafetyConfirmation_e::SafetyConfirmed && safetyConfirmation == SafetyConfirmation_e::SafetyNotConfirmed)
m_mainHandler->handlerVehicle()->effectShowControl(EffectShowControl_e::StopTimer);
if (m_lastState != safetyConfirmation && m_firingExplosionEntity.safetyConfirmation() == EffectShowClient::SafetyConfirmation_e::SafetyNotConfirmed &&
m_firingExplosionEntity.isActive() && !m_firingExplosionEntity.carriedOutEnabled())
{
if (m_firingExplosionEntity.idEffectShow() > 0)
m_mainHandler->handlerOrder()->updateOrderWithId(m_firingExplosionEntity.idEffectShow(), QString(), EffectShowManagement::OrderConfirmation_e_def::InterruptExecution);
onEffectShowInterrupted();
}
m_lastState = safetyConfirmation;
m_mainHandler->dds()->dts()->publish(m_firingExplosionEntity);
}
//-----------------------------------------------------------------------------
void HandlerFiringExplosion::onReadyForExplosionFiring(bool ready)
{
m_firingExplosionEntity.fireEnabled(ready);
m_mainHandler->dds()->dts()->publish(m_firingExplosionEntity);
}
//-----------------------------------------------------------------------------
void HandlerFiringExplosion::onStatusExplosionFiring(const StatusExplosionFiring_t &statusExplosionFiring)
{
m_firingExplosionEntity.remainingTime(statusExplosionFiring.remainingTime_s);
m_firingExplosionEntity.remainingShots(statusExplosionFiring.remainingShots);
m_firingExplosionEntity.carriedOutEnabled(m_firingExplosionEntity.isActive() && (m_isInterrupted || statusExplosionFiring.remainingTime_s <= 0));
m_firingExplosionEntity.remainingVolleys(statusExplosionFiring.remainingVolley);
m_mainHandler->dds()->dts()->publish(m_firingExplosionEntity);
}
void HandlerFiringExplosion::onEffectShowStarted()
{
DEBUG_LOG(m_logger) << "onEffectShowStarted";
m_mainHandler->handlerVehicle()->setExplosionParameter(m_firingExplosionEntity.remainingVolleys(),
m_firingExplosionEntity.remainingShots(),
m_firingExplosionEntity.remainingTime());
m_isInterrupted = false;
m_firingExplosionEntity.isActive(true);
m_firingExplosionEntity.fireEnabled(false);
m_firingExplosionEntity.carriedOutEnabled(false);
m_mainHandler->dds()->dts()->publish(m_firingExplosionEntity);
}
bool HandlerFiringExplosion::onEffectShowInterrupted()
{
if (m_isInterrupted == true)
return false;
if (!m_firingExplosionEntity.isActive() && m_isInterrupted == false)
{
DEBUG_LOG(m_logger) << "onEffectShowInterrupted is active so return";
return false;
}
DEBUG_LOG(m_logger) << "onEffectShowInterrupted";
m_mainHandler->handlerControlUnit()->send(CommandSignal::FT_SE_CB_SICHERHEIT_WIDERRUFEN);
m_mainHandler->handlerVehicle()->effectShowControl(EffectShowControl_e::StopTimer);
m_isInterrupted = true;
m_firingExplosionEntity.isActive(true);
m_firingExplosionEntity.fireEnabled(true);
m_firingExplosionEntity.carriedOutEnabled(true);
m_mainHandler->dds()->dts()->publish(m_firingExplosionEntity);
return true;
}
//-----------------------------------------------------------------------------
void HandlerFiringExplosion::onManuallyExplosionRequest(const rti::core::SampleIdentity &cookie,
const ManuallyExplosionRequest &request)
{
DEBUG_LOG(m_logger) << "onManuallyExplosionRequest ";
//override order!
if (m_firingExplosionEntity.idEffectShow() == 0)
{
m_firingExplosionEntity.firingClearanceTime().reset();
m_firingExplosionEntity.endOfFiringClearanceTime().reset();
m_firingExplosionEntity.fireEnabled(false);
m_firingExplosionEntity.carriedOutEnabled(false);
}
m_isInterrupted = false;
m_mainHandler->dds()->fts()->manuallyExplosionReply(cookie, Core::FunctionReplyObject());
if (request.pbInterrupt())
{
m_mainHandler->handlerVehicle()->effectShowControl(EffectShowControl_e::Stop);
onEffectShowInterrupted();
}
if (!request.pbFire() && !request.pbAbort() && !request.pbCarriedOut())
m_mainHandler->handlerVehicle()->setExplosionParameter(request.numberOfVolley(), request.numberOfShot(), request.duration());
if (request.pbAbort() || request.pbCarriedOut())
{
m_firingExplosionEntity.isActive(false);
m_firingExplosionEntity.carriedOutEnabled(false);
if (request.pbAbort())
m_mainHandler->handlerVehicle()->effectShowControl(EffectShowControl_e::Abort);
// m_firingExplosionEntity.numberOfVolley(0);
// m_firingExplosionEntity.numberOfShot(0);
m_firingExplosionEntity.remainingShots(0);
m_firingExplosionEntity.remainingShots(0);
m_firingExplosionEntity.remainingVolleys(0);
// m_firingExplosionEntity.duration(0);
m_firingExplosionEntity.remainingTime(0);
m_firingExplosionEntity.firingClearanceTime().reset();
m_firingExplosionEntity.endOfFiringClearanceTime().reset();
}
else if (!request.pbInterrupt())
{
// m_firingExplosionEntity.idOrder(0);
m_firingExplosionEntity.numberOfVolley(request.numberOfVolley());
m_firingExplosionEntity.numberOfShot(request.numberOfShot());
m_firingExplosionEntity.remainingShots(request.numberOfShot());
m_firingExplosionEntity.remainingVolleys(request.numberOfVolley());
m_firingExplosionEntity.duration(request.duration());
m_firingExplosionEntity.remainingTime(request.duration());
}
if (request.pbFire())
{
m_mainHandler->handlerVehicle()->recalcEverything();
m_firingExplosionEntity.isActive(true);
m_mainHandler->handlerVehicle()->effectShowControl(EffectShowControl_e::Start);
}
}
} // Namespace EffectShowClient
+69
View File
@@ -0,0 +1,69 @@
/**
* Handler for all Language HMI objects
* $Id$
* $HeadURL$
* $Author$
* Created by Hanna E. Rathje, SLSE, 2015-09-03
*/
#pragma once
#include <QObject>
#include <QMap>
#include <EffectShowClient/esc_db.h>
#include "handler_vehicle.h"
#include "dds_handler.h"
#include "esc_convert_from_tab.h"
#include "logger.h"
#include "esc_helper.h"
namespace EffectShowClient
{
class MainHandler;
class HandlerFiringExplosion : public QObject
, protected Interface::Fts::ManuallyExplosionRequestHandler
{
Q_OBJECT
public:
explicit HandlerFiringExplosion(MainHandler *mainHandler,
QObject *parent = nullptr);
~HandlerFiringExplosion();
bool init();
struct OrderExecutionStatus_t
{
int remainingShots = 0;
int remainingTime = 0;
bool enablePbFire = false;
bool enablePbCarriedOut = false;
};
void setFiringClearanceDuration();
bool onEffectShowInterrupted();
int getCurrentorderId() { return m_firingExplosionEntity.idOrder(); }
private Q_SLOTS:
void onStartHandlerFiring(const Database::EscOrder &escOrder);
void onEndHandlerFiring(const Database::EscOrder &escOrder);
void onEffectShowStopped(qint16 idEffectShow);
void onEffectShowContinued(const ConvertFromTab::EffectShowContinue_t &effectShowContinue);
void onSafetyConfirmation(const SafetyConfirmation_e &safetyConfirmation);
void onReadyForExplosionFiring(bool ready);
void onStatusExplosionFiring(const StatusExplosionFiring_t &statusExplosionFiring);
void onEffectShowStarted();
private:
void onManuallyExplosionRequest(const rti::core::SampleIdentity &cookie,
const ManuallyExplosionRequest &request);
private:
MainHandler *m_mainHandler;
EffectShowClient::FiringExplosionEntity m_firingExplosionEntity;
bool m_isInterrupted = false;
bool m_isNew = true;
SafetyConfirmation_e m_lastState;
NGL::INGLLogger &m_logger;
};
}
+183
View File
@@ -0,0 +1,183 @@
/**
* Handler for all exercise objects
* $Id$
* $HeadURL$
* $Author$
* Created by Hanna E. Rathje, SLSE, 2015-09-03
*/
#include "handler_firing_smoke.h"
#include "esc_db.h"
#include "main_handler.h"
#include "control_unit_handler.h"
#include "handler_tab_data.h"
#include "handler_order.h"
#include "handler_vehicle.h"
#include <QTimer>
#include <QCoreApplication>
#include <NGLLogger/NGLLoggerBootstrap.h>
namespace EffectShowClient
{
//=============================================================================
HandlerFiringSmoke::HandlerFiringSmoke(MainHandler *mainHandler,
QObject *parent)
: QObject(parent)
, ManuallySmokeRequestHandler(mainHandler->dds()->fts())
, m_mainHandler(mainHandler)
, m_logger(getLogger("HandlerFiringSmoke"))
{
DEBUG_LOG(m_logger) << "HandlerFiringSmoke ctor";
}
//=============================================================================
HandlerFiringSmoke::~HandlerFiringSmoke()
{}
//=============================================================================
bool HandlerFiringSmoke::init()
{
connect(m_mainHandler->handlerOrder().get(), &HandlerOrder::startHandlerFiring,
this, &HandlerFiringSmoke::onStartHandlerFiring);
connect(m_mainHandler->handlerOrder().get(), &HandlerOrder::endHandlerFiring,
this, &HandlerFiringSmoke::onEndHandlerFiring);
connect(m_mainHandler->handlerTabData().get(), &HandlerTabData::effectShowStopped,
this, &HandlerFiringSmoke::onEffectShowStopped);
connect(m_mainHandler->handlerTabData().get(), &HandlerTabData::effectShowContinued,
this, &HandlerFiringSmoke::onEffectShowContinued);
connect(m_mainHandler->handlerControlUnit().get(), &ControlUnitHandler::safetyStatus,
this, &HandlerFiringSmoke::onSafetyConfirmation);
return true;
}
//=============================================================================
void HandlerFiringSmoke::setFiringClearanceDuration()
{
if (m_firingSmokeEntity.firingClearanceTime().is_set())
{
qint64 pre = m_firingSmokeEntity.firingClearanceTime().get();
qint64 post = pre;
pre -= PRE_START_TIME;
post += m_firingSmokeEntity.duration() + POST_END_TIME;
m_firingSmokeEntity.firingClearanceTime().set(pre);
m_firingSmokeEntity.endOfFiringClearanceTime().set(post);
}
else
m_firingSmokeEntity.endOfFiringClearanceTime().reset();
m_mainHandler->dds()->dts()->publish(m_firingSmokeEntity);
}
//-----------------------------------------------------------------------------
void HandlerFiringSmoke::onStartHandlerFiring(const Database::EscOrder &escOrder)
{
m_firingSmokeEntity.idEffectShow(escOrder.idOrder);
m_firingSmokeEntity.lengthOfFogZone(escOrder.areaWidth);
m_firingSmokeEntity.duration(escOrder.duration * 1000);
m_firingSmokeEntity.idOrder(escOrder.id);
if (escOrder.startTime > 0)
m_firingSmokeEntity.firingClearanceTime().set(escOrder.startTime);
else
m_firingSmokeEntity.firingClearanceTime().reset();
if (m_firingSmokeEntity.lengthOfFogZone() <= 0 ||
m_firingSmokeEntity.duration() <= 0)
{
WARNING_LOG(m_logger) << "Won't start Smoke ";
DEBUG_LOG(m_logger) << "areaWidth: " << escOrder.areaWidth
<< "duration: " << escOrder.duration;
return;
}
setFiringClearanceDuration();
}
//-----------------------------------------------------------------------------
void HandlerFiringSmoke::onEndHandlerFiring(const Database::EscOrder &escOrder)
{
Q_UNUSED(escOrder)
m_firingSmokeEntity.remainingDistance(0);
m_firingSmokeEntity.remainingTime(0);
m_firingSmokeEntity.carriedOutEnabled(false);
m_firingSmokeEntity.directionOfFogZone(0);
m_firingSmokeEntity.endOfFiringClearanceTime().reset();
m_firingSmokeEntity.idOrder(0);
m_firingSmokeEntity.idEffectShow(0);
m_firingSmokeEntity.firingClearanceTime().reset();
m_mainHandler->dds()->dts()->publish(m_firingSmokeEntity);
}
//-----------------------------------------------------------------------------
void HandlerFiringSmoke::onEffectShowStopped(qint16 idEffectShow)
{
if (idEffectShow != m_firingSmokeEntity.idEffectShow())
{
ERROR_LOG(m_logger) << "EffectShow IDs not consistent: " << idEffectShow << " / " << m_firingSmokeEntity.idEffectShow();
return;
}
}
//-----------------------------------------------------------------------------
void HandlerFiringSmoke::onEffectShowContinued(const ConvertFromTab::EffectShowContinue_t &effectShowContinue)
{
if (effectShowContinue.idEffectShow != m_firingSmokeEntity.idEffectShow())
{
ERROR_LOG(m_logger) << "EffectShow IDs not consistent: " << effectShowContinue.idEffectShow << " / " << m_firingSmokeEntity.idEffectShow();
return;
}
}
//-----------------------------------------------------------------------------
void HandlerFiringSmoke::onSafetyConfirmation(const SafetyConfirmation_e &safetyConfirmation)
{
m_firingSmokeEntity.safetyConfirmation(safetyConfirmation);
m_mainHandler->dds()->dts()->publish(m_firingSmokeEntity);
}
//-----------------------------------------------------------------------------
void HandlerFiringSmoke::onStatusSmokeFiring(const StatusSmokeFiring_t &statusSmokeFiring)
{
m_firingSmokeEntity.remainingDistance(statusSmokeFiring.remainingDistance_m);
m_firingSmokeEntity.remainingTime(statusSmokeFiring.remainingTime_s);
m_firingSmokeEntity.carriedOutEnabled(statusSmokeFiring.remainingTime_s <= 0);
m_mainHandler->dds()->dts()->publish(m_firingSmokeEntity);
}
void HandlerFiringSmoke::setSmoking()
{
if (m_firingSmokeEntity.idOrder() > 0) //send new order change into execution
{
m_mainHandler->handlerOrder()->updateOrderWithId(m_firingSmokeEntity.idOrder(), QStringLiteral(""), EffectShowManagement::OrderConfirmation_e::Execution);
}
}
//-----------------------------------------------------------------------------
void HandlerFiringSmoke::onManuallySmokeRequest(const rti::core::SampleIdentity &cookie,
const ManuallySmokeRequest &request)
{
DEBUG_LOG(m_logger) << "onManuallySmokeRequest";
//override order!
if (m_firingSmokeEntity.idOrder() == 0)
{
m_firingSmokeEntity.firingClearanceTime().reset();
m_firingSmokeEntity.endOfFiringClearanceTime().reset();
m_firingSmokeEntity.carriedOutEnabled(false);
}
m_firingSmokeEntity.lengthOfFogZone(request.lengthOfFogZone());
m_firingSmokeEntity.directionOfFogZone(request.directionOfFogZone());
m_firingSmokeEntity.remainingDistance(request.lengthOfFogZone());
m_firingSmokeEntity.duration(m_mainHandler->handlerVehicle()->burningTimeSmokeCartridge_s());
m_firingSmokeEntity.remainingTime(m_firingSmokeEntity.duration());
m_mainHandler->dds()->fts()->manuallySmokeReply(cookie, Core::FunctionReplyObject());
if (!request.pbAbort() && !request.pbCarriedOut())
m_mainHandler->handlerVehicle()->setSmokeParameter(request.lengthOfFogZone(), request.directionOfFogZone());
if (request.pbAbort())
m_mainHandler->handlerVehicle()->effectShowControl(EffectShowControl_e::Abort);
}
} // Namespace EffectShowClient
+58
View File
@@ -0,0 +1,58 @@
/**
* Handler for all Language HMI objects
* $Id$
* $HeadURL$
* $Author$
* Created by Hanna E. Rathje, SLSE, 2015-09-03
*/
#pragma once
#include <QObject>
#include <QMap>
#include <EffectShowClient/esc_db.h>
#include "handler_vehicle.h"
#include "dds_handler.h"
#include "esc_convert_from_tab.h"
#include "logger.h"
#include "esc_helper.h"
namespace EffectShowClient
{
class MainHandler;
class HandlerFiringSmoke : public QObject
, protected Interface::Fts::ManuallySmokeRequestHandler
{
Q_OBJECT
public:
explicit HandlerFiringSmoke(MainHandler *mainHandler,
QObject *parent = nullptr);
~HandlerFiringSmoke();
bool init();
void setFiringClearanceDuration();
int getCurrentorderId() { return m_firingSmokeEntity.idOrder(); }
void setSmoking();
private Q_SLOTS:
void onStartHandlerFiring(const Database::EscOrder &escOrder);
void onEndHandlerFiring(const Database::EscOrder &escOrder);
void onEffectShowStopped(qint16 idEffectShow);
void onEffectShowContinued(const ConvertFromTab::EffectShowContinue_t &effectShowContinue);
void onSafetyConfirmation(const SafetyConfirmation_e &safetyConfirmation);
void onStatusSmokeFiring(const StatusSmokeFiring_t &statusSmokeFiring);
private:
void onManuallySmokeRequest(const rti::core::SampleIdentity &cookie,
const ManuallySmokeRequest &request);
private:
MainHandler *m_mainHandler;
EffectShowClient::FiringSmokeEntity m_firingSmokeEntity;
NGL::INGLLogger &m_logger;
};
}
@@ -0,0 +1,322 @@
/**
* Handler for all exercise objects
* $Id$
* $HeadURL$
* $Author$
* Created by Hanna E. Rathje, SLSE, 2015-09-03
*/
#include "handler_operating_condition.h"
#include "esc_db.h"
#include "main_handler.h"
#include "handler_vehicle.h"
#include "control_unit_handler.h"
#include "handler_firing_explosion.h"
#include "handler_firing_smoke.h"
#include "handler_tab_data.h"
#include <QCoreApplication>
#include <NGLLogger/NGLLoggerBootstrap.h>
namespace EffectShowClient
{
//=============================================================================
HandlerOperatingCondition::HandlerOperatingCondition(MainHandler *mainHandler,
QObject *parent)
: QObject(parent)
, SendAmmunitionRequestHandler(mainHandler->dds()->fts())
, SendSafetyRevokeRequestHandler(mainHandler->dds()->fts())
, SendReadinessRequestHandler(mainHandler->dds()->fts())
, m_mainHandler(mainHandler)
, m_isOperational(false)
, m_oldErrorState(false)
, m_operationalStatusTimer(new QTimer)
, m_logger(getLogger("HandlerOperatingCondition"))
{}
//=============================================================================
HandlerOperatingCondition::~HandlerOperatingCondition()
{}
//=============================================================================
bool HandlerOperatingCondition::init()
{
m_operatingCondition.readiness(m_isOperational);
connect(m_mainHandler->handlerVehicle().get(), &HandlerVehicle::vehicleBattery,
this, &HandlerOperatingCondition::onVehicleBattery);
connect(m_mainHandler->handlerVehicle().get(), &HandlerVehicle::vehicleSmokeCardridgesFireStatus,
this, &HandlerOperatingCondition::onVehicleSmokeCardridgesFireStatus);
connect(m_mainHandler->handlerVehicle().get(), &HandlerVehicle::vehicleSmokeCardridgesStatus,
this, &HandlerOperatingCondition::onVehicleSmokeCardridgesStatus);
connect(m_mainHandler->handlerVehicle().get(), &HandlerVehicle::vehicleFireUnits,
this, &HandlerOperatingCondition::onVehicleFireUnits);
connect(m_mainHandler->handlerControlUnit().get(), &ControlUnitHandler::safetyWarnings,
this, &HandlerOperatingCondition::onSafetyStatus);
connect(m_mainHandler->handlerControlUnit().get(), &ControlUnitHandler::vehicleErrorStatus,
this, &HandlerOperatingCondition::onVehicleErrorStatus);
connect(m_mainHandler->handlerControlUnit().get(), &ControlUnitHandler::vehicleRoundCount,
this, &HandlerOperatingCondition::onVehicleRoundCount);
connect(m_mainHandler->handlerControlUnit().get(), &ControlUnitHandler::vehicleConnected,
this, &HandlerOperatingCondition::onConnectionToSerial);
connect(m_mainHandler->handlerControlUnit().get(), &ControlUnitHandler::vehicleFinshedVolley,
this, &HandlerOperatingCondition::onVolleyRounds);
connect(m_mainHandler->handlerControlUnit().get(), &ControlUnitHandler::vehicleStoppedVolley,
this, &HandlerOperatingCondition::onVolleyRounds);
connect(m_mainHandler->handlerVehicle().get(), &HandlerVehicle::vehicleType,
this, &HandlerOperatingCondition::onVehicleType);
connect(m_operationalStatusTimer, &QTimer::timeout,
this, &HandlerOperatingCondition::onOperationalStatusTimeout);
return true;
}
void HandlerOperatingCondition::onVehicleBattery(double battery)
{
m_operatingCondition.batteryVoltage(battery);
if (!m_mainHandler->dds()->dts()->publish(m_operatingCondition))
ERROR_LOG(m_logger) << "Error publishing OperatingConditionEntity-data Battery to dds";
}
void HandlerOperatingCondition::onVehicleSmokeCardridgesFireStatus(const CardRidges &fireStatus)
{
int numberOfSmokingCardridgesOld = int(m_smokingCardridges.cardrige1) + int(m_smokingCardridges.cardrige2)
+ int(m_smokingCardridges.cardrige3) + int(m_smokingCardridges.cardrige4)
+ int(m_smokingCardridges.cardrige5);
//not fireing should be updated in next CardRidgeStatus
m_smokingCardridges = fireStatus;
int numberOfSmokingCardridgesNew = int(m_smokingCardridges.cardrige1) + int(m_smokingCardridges.cardrige2)
+ int(m_smokingCardridges.cardrige3) + int(m_smokingCardridges.cardrige4)
+ int(m_smokingCardridges.cardrige5);
int count = numberOfSmokingCardridgesNew - numberOfSmokingCardridgesOld;
if (count > 0)
{
m_operatingCondition.ammunitionAvailable(std::max(0, m_operatingCondition.ammunitionAvailable() - count));
m_operatingCondition.ammunitionMagazine(std::max(0, m_operatingCondition.ammunitionMagazine() - count));
//we are burning now
ConvertToTab::VehicleStatus_t vehicleStatus;
getVehicleStatus(vehicleStatus);
m_mainHandler->handlerFiringSmoke()->setSmoking();
m_mainHandler->handlerTabData()->vehicleStatus(vehicleStatus);
} // if
if (fireStatus.cardrige1)
m_operatingCondition.smokeCartridge1(StatusSmokeCartridge_e_def::Smoking);
if (fireStatus.cardrige2)
m_operatingCondition.smokeCartridge2(StatusSmokeCartridge_e_def::Smoking);
if (fireStatus.cardrige3)
m_operatingCondition.smokeCartridge3(StatusSmokeCartridge_e_def::Smoking);
if (fireStatus.cardrige4)
m_operatingCondition.smokeCartridge4(StatusSmokeCartridge_e_def::Smoking);
if (fireStatus.cardrige5)
m_operatingCondition.smokeCartridge5(StatusSmokeCartridge_e_def::Smoking);
if (!m_mainHandler->dds()->dts()->publish(m_operatingCondition))
ERROR_LOG(m_logger) << "Error publishing OperatingConditionEntity-data (Somoking) to dds";
}
void HandlerOperatingCondition::onVehicleSmokeCardridgesStatus(const CardRidges &fireStatus)
{
m_readyCardridges = fireStatus;
if (!m_smokingCardridges.cardrige1)
m_operatingCondition.smokeCartridge1(m_readyCardridges.cardrige1 ? StatusSmokeCartridge_e_def::Ready : StatusSmokeCartridge_e_def::NotReady);
if (!m_smokingCardridges.cardrige2)
m_operatingCondition.smokeCartridge2(m_readyCardridges.cardrige2 ? StatusSmokeCartridge_e_def::Ready : StatusSmokeCartridge_e_def::NotReady);
if (!m_smokingCardridges.cardrige3)
m_operatingCondition.smokeCartridge3(m_readyCardridges.cardrige3 ? StatusSmokeCartridge_e_def::Ready : StatusSmokeCartridge_e_def::NotReady);
if (!m_smokingCardridges.cardrige4)
m_operatingCondition.smokeCartridge4(m_readyCardridges.cardrige4 ? StatusSmokeCartridge_e_def::Ready : StatusSmokeCartridge_e_def::NotReady);
if (!m_smokingCardridges.cardrige5)
m_operatingCondition.smokeCartridge5(m_readyCardridges.cardrige5 ? StatusSmokeCartridge_e_def::Ready : StatusSmokeCartridge_e_def::NotReady);
if (!m_mainHandler->dds()->dts()->publish(m_operatingCondition))
ERROR_LOG(m_logger) << "Error publishing OperatingConditionEntity-data to dds";
}
void HandlerOperatingCondition::onVehicleFireUnits(const CardRidges &fireStatus)
{
m_operatingCondition.firingUnitReadyFwdLh(fireStatus.cardrige1);
m_operatingCondition.firingUnitReadyFwdRh(fireStatus.cardrige2);
m_operatingCondition.firingUnitReadyAftRh(fireStatus.cardrige3);
m_operatingCondition.firingUnitReadyAftLh(fireStatus.cardrige4);
if (!m_mainHandler->dds()->dts()->publish(m_operatingCondition))
ERROR_LOG(m_logger) << "Error publishing OperatingConditionEntity-data (fireStatus) to dds";
}
void HandlerOperatingCondition::onVehicleErrorStatus(const CardRidges &errorStatus)
{
m_operatingCondition.errorSmoke(errorStatus.cardrige1);
m_operatingCondition.errorFireUnit(errorStatus.cardrige2);
m_operatingCondition.errorPanel(errorStatus.cardrige3);
m_operatingCondition.errorEquipment(errorStatus.cardrige4);
m_operatingCondition.errorGeneral(errorStatus.cardrige5);
if (!m_mainHandler->dds()->dts()->publish(m_operatingCondition))
ERROR_LOG(m_logger) << "Error publishing OperatingConditionEntity-data (errorStatus) to dds";
if (isErrorDmf() != m_oldErrorState)
{
m_oldErrorState = isErrorDmf();
ConvertToTab::VehicleStatus_t vehicleStatus;
getVehicleStatus(vehicleStatus);
m_mainHandler->handlerTabData()->vehicleStatus(vehicleStatus);
}
}
void HandlerOperatingCondition::onOperationalStatusTimeout()
{
DEBUG_LOG(m_logger) << "Operational status timeout. Setting operational status to: not operational.";
m_isOperational = false;
m_operatingCondition.readiness(m_isOperational);
sendStatus();
}
bool HandlerOperatingCondition::isErrorDmf()
{
return (m_operatingCondition.errorSmoke() ||
m_operatingCondition.errorFireUnit() ||
m_operatingCondition.errorPanel() ||
m_operatingCondition.errorEquipment() ||
m_operatingCondition.errorGeneral()
);
}
void HandlerOperatingCondition::onConnectionToSerial()
{
DEBUG_LOG(m_logger) << "Connected to Serial: send ammunition Magazine to Control Unit Count: " << m_operatingCondition.ammunitionMagazine();
m_mainHandler->handlerVehicle()->setAmmunitionParameter(m_operatingCondition.ammunitionMagazine());
}
void HandlerOperatingCondition::onVehicleType(const EffectShowManagement::Feature_e &type)
{
m_operatingCondition.vehicleFeature(type);
if (!m_mainHandler->dds()->dts()->publish(m_operatingCondition))
ERROR_LOG(m_logger) << "Error publishing OperatingConditionEntity-data (vehicle type) to dds";
}
void HandlerOperatingCondition::onSafetyStatus(const SafetyStatus &status)
{
m_operatingCondition.temperatureWarning(status.temperaturWarning);
m_operatingCondition.loadingBoardWall(status.loadingBoardWall);
m_operatingCondition.emergencyStop(status.emergencyStop);
if (!m_mainHandler->dds()->dts()->publish(m_operatingCondition))
ERROR_LOG(m_logger) << "Error publishing OperatingConditionEntity-data (SafetyStatus) to dds";
}
void HandlerOperatingCondition::onVehicleRoundCount(int loadedRounds)
{
DEBUG_LOG(m_logger) << "Got RoundCount Reply from Unit " << loadedRounds;
m_operatingCondition.ammunitionMagazine(loadedRounds);
if (!m_mainHandler->dds()->dts()->publish(m_operatingCondition))
ERROR_LOG(m_logger) << "Error publishing OperatingConditionEntity-data (ammunition magazine) to dds";
}
void HandlerOperatingCondition::onVolleyRounds(int usedRounds)
{
DEBUG_LOG(m_logger) << "Got used rounds " << usedRounds;
m_operatingCondition.ammunitionMagazine(m_operatingCondition.ammunitionMagazine() - usedRounds);
if (m_operatingCondition.ammunitionMagazine() < 0)
m_operatingCondition.ammunitionMagazine(0);
m_operatingCondition.ammunitionAvailable(m_operatingCondition.ammunitionAvailable() - usedRounds);
if (m_operatingCondition.ammunitionAvailable() < 0)
m_operatingCondition.ammunitionAvailable(0);
if (!m_mainHandler->dds()->dts()->publish(m_operatingCondition))
ERROR_LOG(m_logger) << "Error publishing OperatingConditionEntity-data (ammunition magazine used) to dds";
}
void HandlerOperatingCondition::sendStatus()
{
ConvertToTab::VehicleStatus_t vehicleStatus;
getVehicleStatus(vehicleStatus);
m_mainHandler->handlerTabData()->vehicleStatus(vehicleStatus);
}
void HandlerOperatingCondition::getVehicleStatus(ConvertToTab::VehicleStatus_t &vehicleStatus)
{
vehicleStatus.ammunitionAvailable = m_operatingCondition.ammunitionAvailable();
vehicleStatus.ammunitionMagazine = m_operatingCondition.ammunitionMagazine();
vehicleStatus.feature = static_cast<int>(m_operatingCondition.vehicleFeature().underlying());
vehicleStatus.operational = (!m_operatingCondition.errorGeneral() && m_isOperational);
vehicleStatus.magazineFail = m_oldErrorState;
vehicleStatus.controlComputerFail = m_operatingCondition.errorPanel();
}
//-----------------------------------------------------------------------------
void HandlerOperatingCondition::onSendAmmunitionRequest(const rti::core::SampleIdentity &cookie,
const SendAmmunitionRequest &request)
{
DEBUG_LOG(m_logger) << "onSendAmmunitionRequest";
//take available ammo and send excon
//then wait for reply from unit
m_operatingCondition.ammunitionAvailable(request.ammunitionAvailable());
m_mainHandler->dds()->fts()->sendAmmunitionReply(cookie, Core::FunctionReplyObject());
// provision of the control computer with the equipped shots
m_mainHandler->handlerVehicle()->setAmmunitionParameter(request.ammunitionMagazine());
// Sending of telegram: DMF-Einsatzbereitschafts-Status to the operating application
ConvertToTab::VehicleStatus_t vehicleStatus;
getVehicleStatus(vehicleStatus);
if (vehicleStatus.feature == EffectShowManagement::Feature_e::Smoke)
{
//as smoke did not answer
vehicleStatus.ammunitionMagazine = request.ammunitionMagazine();
}
m_mainHandler->handlerTabData()->vehicleStatus(vehicleStatus);
}
void HandlerOperatingCondition::onSendSafetyRevokeRequest(const rti::core::SampleIdentity &cookie,
const SendSafetyRevokeRequest &request)
{
DEBUG_LOG(m_logger) << "onSendSafetyRevokeRequest with " << request.revoke();
m_mainHandler->dds()->fts()->sendSafetyRevokeReply(cookie, Core::FunctionReplyObject());
if (request.revoke())
{
m_mainHandler->handlerVehicle()->effectShowControl(EffectShowControl_e::StopTimer);
m_mainHandler->handlerControlUnit()->send(CommandSignal::FT_SE_CB_SICHERHEIT_WIDERRUFEN);
m_mainHandler->handlerFiringExplosion()->onEffectShowInterrupted();
}
}
void HandlerOperatingCondition::onSendReadinessRequest(const rti::core::SampleIdentity &cookie,
const SendReadinessRequest &request)
{
DEBUG_LOG(m_logger) << "onSendReadinessRequest";
//Confirm or Revoke Readiness
//send to EXCON
m_isOperational = request.readiness();
m_mainHandler->dds()->fts()->sendReadinessReply(cookie, Core::FunctionReplyObject());
// Sending of telegram: DMF-Einsatzbereitschafts-Status to the operating application
ConvertToTab::VehicleStatus_t vehicleStatus;
getVehicleStatus(vehicleStatus);
m_mainHandler->handlerTabData()->vehicleStatus(vehicleStatus);
//now change operating condition in hope that tetra worked
m_operatingCondition.readiness(m_isOperational);
if (!m_mainHandler->dds()->dts()->publish(m_operatingCondition))
ERROR_LOG(m_logger) << "Error publishing OperatingConditionEntity-data readiness) to dds";
if (m_isOperational)
{
DEBUG_LOG(m_logger) << "Operating condition: operational. Starting timer.";
m_operationalStatusTimer->start(15 * 60 * 1000);
}
else
{
DEBUG_LOG(m_logger) << "Operating condition: not operational. Stopping timer.";
m_operationalStatusTimer->stop();
}
}
} // Namespace EffectShowClient
@@ -0,0 +1,78 @@
/**
* Handler for all Language HMI objects
* $Id$
* $HeadURL$
* $Author$
* Created by Hanna E. Rathje, SLSE, 2015-09-03
*/
#pragma once
#include <QObject>
#include <QMap>
#include "handler_vehicle.h"
#include "dds_handler.h"
#include "control_unit_handler.h"
#include "logger.h"
namespace EffectShowClient
{
class MainHandler;
class HandlerOperatingCondition : public QObject
, protected Interface::Fts::SendAmmunitionRequestHandler
, protected Interface::Fts::SendSafetyRevokeRequestHandler
, protected Interface::Fts::SendReadinessRequestHandler
{
Q_OBJECT
public:
explicit HandlerOperatingCondition(MainHandler *mainHandler,
QObject *parent = nullptr);
~HandlerOperatingCondition();
bool init();
void sendStatus();
private slots:
void onVehicleBattery(double battery);
void onVehicleSmokeCardridgesFireStatus(const CardRidges &fireStatus);
void onVehicleSmokeCardridgesStatus(const CardRidges &fireStatus);
void onVehicleFireUnits(const CardRidges &fireStatus);
void onVehicleErrorStatus(const CardRidges &errorStatus);
void onVehicleType(const EffectShowManagement::Feature_e &type);
void onConnectionToSerial();
void onSafetyStatus(const SafetyStatus &status);
void onVehicleRoundCount(int loadedRounds);
void onVolleyRounds(int usedRounds);
void onOperationalStatusTimeout();
/**
* @brief Get vehicle status
* @param vehicleStatus Status of the vehicle needed by telegram: DMF-Einsatzbereitschafts-Status
*/
void getVehicleStatus(ConvertToTab::VehicleStatus_t &vehicleStatus);
private:
void onSendAmmunitionRequest(const rti::core::SampleIdentity &cookie,
const SendAmmunitionRequest &request);
void onSendSafetyRevokeRequest(const rti::core::SampleIdentity &cookie,
const SendSafetyRevokeRequest &request);
void onSendReadinessRequest(const rti::core::SampleIdentity &cookie,
const SendReadinessRequest &request);
bool isErrorDmf();
private:
MainHandler *m_mainHandler{nullptr};
CardRidges m_readyCardridges;
CardRidges m_smokingCardridges;
bool m_isOperational;
bool m_oldErrorState;
QTimer *m_operationalStatusTimer{nullptr};
NGL::INGLLogger &m_logger;
EffectShowClient::OperatingConditionEntity m_operatingCondition;
};
}
+296
View File
@@ -0,0 +1,296 @@
/**
* Handler for all exercise objects
* $Id$
* $HeadURL$
* $Author$
* Created by Hanna E. Rathje, SLSE, 2015-09-03
*/
#include "handler_order.h"
#include "object_order.h"
#include "esc_db.h"
#include "main_handler.h"
#include "handler_firing_explosion.h"
#include "handler_firing_smoke.h"
#include "control_unit_handler.h"
#include "handler_tab_data.h"
#include "handler_vehicle.h"
#include <QCoreApplication>
#include <NGLLogger/NGLLoggerBootstrap.h>
namespace EffectShowClient
{
//=============================================================================
HandlerOrder::HandlerOrder(MainHandler *mainHandler,
QObject *parent)
: QObject(parent)
, OrderModifyRequestHandler(mainHandler->dds()->fts())
, m_mainHandler(mainHandler)
, m_logger(getLogger("HandlerOrder"))
{}
//=============================================================================
HandlerOrder::~HandlerOrder()
{}
//=============================================================================
bool HandlerOrder::init()
{
bool bRet = true;
// create Orders objects
auto cbOrder = [this, &bRet](const Database::EscOrder & data)
{
ObjectOrder *ifs(new ObjectOrder(m_mainHandler, this));
Core::FunctionReplyObject ret = ifs->createObject(data);
if (ret.error())
{
delete ifs;
ERROR_LOG(m_logger) << ret();
bRet = false;
return;
}
m_orderObjMap.insert(ifs->getId(), ifs);
};
if (!m_mainHandler->db()->select(cbOrder) || !bRet)
{
ERROR_LOG(m_logger) << "Error reading data from database!";
return false;
}
DEBUG_LOG(m_logger) << "m_orderObjMap.size() = " << m_orderObjMap.size();
return true;
}
//=============================================================================
void HandlerOrder::createOrder(const ConvertFromTab::EffectShowOrder_t &effectShowOrder)
{
Database::EscOrder data;
for (auto it = m_orderObjMap.begin(); it != m_orderObjMap.end(); ++it)
{
if (it.value()->getData().idOrder == effectShowOrder.idEffectShow)
data = it.value()->getData();
}
bool sendStart = ((data.orderConfirmation == EffectShowManagement::OrderConfirmation_e_def::FiringReadiness)
|| (data.orderConfirmation == EffectShowManagement::OrderConfirmation_e_def::Execution)
|| (data.orderConfirmation == EffectShowManagement::OrderConfirmation_e_def::InterruptExecution));
data.typeOfOrder = 1;
data.idOrder = effectShowOrder.idEffectShow;
data.startTime = effectShowOrder.startTime * 1000; // s -> msec
data.duration = effectShowOrder.duration;
if (data.duration < 5)
data.duration = 5;
data.lowerLeftPosition = QPointF(effectShowOrder.lowerLeftPosition.lon(), effectShowOrder.lowerLeftPosition.lat());
data.centerPosition = QPointF(effectShowOrder.centerPosition.lon(), effectShowOrder.centerPosition.lat());
data.areaWidth = effectShowOrder.areaWidth;
data.areaDepth = effectShowOrder.areaDepth;
data.areaRotation = effectShowOrder.rotation;
data.numOfVolley = effectShowOrder.numOfVolley;
data.shotsPerVolley = effectShowOrder.shotsInTotal;
data.typeOfAmmunition = effectShowOrder.typeOfAmmunition;
//data.orderConfirmation = EffectShowManagement::OrderConfirmation_e_def::WaitingForAcceptance; //no reset
data.info = effectShowOrder.name;
ObjectOrder *ifs(new ObjectOrder(m_mainHandler, this));
Core::FunctionReplyObject ret = ifs->createObject(data);
if (ret.error())
{
delete ifs;
ERROR_LOG(m_logger) << ret();
return;
}
m_orderObjMap.insert(ifs->getId(), ifs);
if (data.orderConfirmation == EffectShowManagement::OrderConfirmation_e_def::Execution && data.startTime == 0)
{
m_mainHandler->handlerControlUnit()->send(CommandSignal::FT_SE_CB_SICHERHEIT_WIDERRUFEN);
m_mainHandler->handlerControlUnit()->send(CommandSignal::FT_SE_CB_SALVE_UNTERBRECHEN);
m_mainHandler->handlerVehicle()->effectShowControl(EffectShowControl_e::Stop);
}
bool orignalIsTimeout = ((data.orderConfirmation == EffectShowManagement::OrderConfirmation_e_def::Execution) && data.startTime > 0 && (data.startTime + data.duration < QDateTime::currentMSecsSinceEpoch())) ;
if (sendStart && !orignalIsTimeout)
emit startHandlerFiring(data);
}
//=============================================================================
void HandlerOrder::createOrder(const ConvertFromTab::RelocationOrder_t &relocationOrder)
{
Database::EscOrder data;
data.typeOfOrder = 0;
data.idOrder = relocationOrder.idRelocation;
data.startTime = relocationOrder.executionTime * 1000; // s -> msec
data.centerPosition = QPointF(relocationOrder.centerPosition.lon(), relocationOrder.centerPosition.lat());
data.orderConfirmation = EffectShowManagement::OrderConfirmation_e_def::WaitingForAcceptance;
data.info = relocationOrder.infoText;
ObjectOrder *ifs(new ObjectOrder(m_mainHandler, this));
Core::FunctionReplyObject ret = ifs->createObject(data);
if (ret.error())
{
delete ifs;
ERROR_LOG(m_logger) << ret();
return;
}
m_orderObjMap.insert(ifs->getId(), ifs);
}
//=============================================================================
void HandlerOrder::removeOrder(const ConvertFromTab::OrderRetract_t &orderRetract)
{
for (auto it = m_orderObjMap.begin(); it != m_orderObjMap.end(); ++it)
{
if (it.value()->getData().typeOfOrder == orderRetract.orderType)
//ERROR_LOG(m_logger) << "current idorder =" ;
if (it.value()->getData().idOrder == orderRetract.id)
{
int id = it.key();
Core::FunctionReplyObject ret;
int def = it.value()->getData().orderConfirmation;
ret = it.value()->removeObject();
if (ret.error())
ERROR_LOG(m_logger) << LOGFUNCTION << ret();
else
{
if (def == EffectShowManagement::OrderConfirmation_e_def::Execution ||
def == EffectShowManagement::OrderConfirmation_e_def::InterruptExecution ||
def == EffectShowManagement::OrderConfirmation_e_def::FiringReadiness)
{
DEBUG_LOG(m_logger) << "EndFireHandler from Remove";
emit endHandlerFiring(it.value()->getData());
//Stop the current execution
m_mainHandler->handlerControlUnit()->send(CommandSignal::FT_SE_CB_SALVE_UNTERBRECHEN);
m_mainHandler->handlerControlUnit()->send(CommandSignal::FT_SE_CB_SICHERHEIT_WIDERRUFEN);
m_mainHandler->handlerVehicle()->effectShowControl(EffectShowControl_e::Abort);
m_mainHandler->handlerVehicle()->effectShowControl(EffectShowControl_e::StopTimer);
}
delete it.value();
m_orderObjMap.remove(id);
}
}
}
}
void HandlerOrder::sendOrderConfirmation(const ConvertToTab::OrderConfirmation_t &oc)
{
ERROR_LOG(m_logger) << "Send Order Confirmation to Excon " << oc.orderId << " / ";
m_mainHandler->handlerTabData()->orderConfirmation(oc);
}
//-----------------------------------------------------------------------------
void HandlerOrder::onOrderModifyRequest(const rti::core::SampleIdentity &cookie,
const OrderModifyRequest &request)
{
DEBUG_LOG(m_logger) << "Order: " << request.id() << " Order: " << request.orderConfirmation();
if (request.id() > 0)
{
ObjectOrder *ifs = m_orderObjMap.value(request.id());
if (ifs == nullptr)
m_mainHandler->dds()->fts()->orderModifyReply(cookie, Core::FunctionReplyObject(request.id(), tr_lts("dds", "Order with id %1 not found")).arg(request.id()));
else
{
ifs->setOrderConfirmation(request.orderConfirmation().underlying());
auto ret = ifs->updateObject();
if (ret.error())
{
m_mainHandler->dds()->fts()->orderModifyReply(cookie, ret);
ERROR_LOG(m_logger) << "Update Order object failed.";
return;
}
if (updateOrder(ifs, QString::fromStdString(request.answerText()), request.orderConfirmation()))
m_mainHandler->dds()->fts()->orderModifyReply(cookie, Core::FunctionReplyObject(request.id()));
else
m_mainHandler->dds()->fts()->orderModifyReply(cookie, Core::FunctionReplyObject(request.id(), tr_lts("dds", "Order with id %1 not found")).arg(request.id()));
}
}
else
{
m_mainHandler->dds()->fts()->orderModifyReply(cookie, Core::FunctionReplyObject(request.id()));
ERROR_LOG(m_logger) << "Illegal Order ID";
}
}
bool HandlerOrder::updateOrder(ObjectOrder *order,
const QString &answerText, EffectShowManagement::OrderConfirmation_e orderConf)
{
ConvertToTab::OrderConfirmation_t oc;
const Database::EscOrder &escOrder = order->getData();
oc.orderId = escOrder.idOrder;
oc.orderType = ConvertToTab::OrderType_e(escOrder.typeOfOrder);
oc.confirmation = orderConf.underlying();
oc.answerText = answerText;
sendOrderConfirmation(oc);
ERROR_LOG(m_logger) << "Update Order " << oc.orderId << " / ";
switch (orderConf.underlying())
{
case EffectShowManagement::OrderConfirmation_e_def::FiringReadiness:
emit startHandlerFiring(order->getData());
break;
case EffectShowManagement::OrderConfirmation_e_def::Execution:
DEBUG_LOG(m_logger) << "start execution";
m_mainHandler->handlerVehicle()->effectShowControl(EffectShowClient::EffectShowControl_e::Start);
emit effectShowStarted();
break;
case EffectShowManagement::OrderConfirmation_e_def::InterruptExecution:
//stop current volley
m_mainHandler->handlerVehicle()->effectShowControl(EffectShowClient::EffectShowControl_e::Stop);
//revoke safety
emit effectShowInterrupted();
break;
case EffectShowManagement::OrderConfirmation_e_def::Abort:
if (checkForActiveOrder(escOrder.idOrder))
{
DEBUG_LOG(m_logger) << "idOrder is " << escOrder.idOrder << " send abbort as is active";
m_mainHandler->handlerControlUnit()->send(CommandSignal::FT_SE_CB_SALVE_UNTERBRECHEN);
m_mainHandler->handlerVehicle()->effectShowControl(EffectShowControl_e::Abort);
}
Q_FALLTHROUGH();
case EffectShowManagement::OrderConfirmation_e_def::Nonacceptance:
case EffectShowManagement::OrderConfirmation_e_def::OrderCarriedOut:
case EffectShowManagement::OrderConfirmation_e_def::PositionReached:
{
if (orderConf.underlying() == EffectShowManagement::OrderConfirmation_e_def::PositionReached &&
oc.orderType != ConvertToTab::OrderType_e::Relocation)
return true;
emit endHandlerFiring(order->getData());
ConvertFromTab::OrderRetract_t oct;
oct.id = escOrder.idOrder;
oct.orderType = qint8(escOrder.typeOfOrder);
removeOrder(oct);
break;
}
default:
ERROR_LOG(m_logger) << "Unhandled EffectShowManagement::OrderConfirmation_e_def in HandlerOrder::onOrderModifyRequest"; // todo
break;
}
return true;
}
void HandlerOrder::updateOrderWithId(int orderId, const QString &answerText, EffectShowManagement::OrderConfirmation_e orderConf)
{
ObjectOrder *ifs = m_orderObjMap.value(orderId);
if (ifs == nullptr)
return;
ifs->setOrderConfirmation(orderConf.underlying());
auto ret = ifs->updateObject();
if (ret.error())
ERROR_LOG(m_logger) << "Error Updating Order " << orderId << " / ";
updateOrder(ifs, answerText, orderConf);
}
bool HandlerOrder::checkForActiveOrder(int orderId)
{
DEBUG_LOG(m_logger) << "check for active Order " << orderId << " ";
if (orderId <= 0)
return false;
return ((m_mainHandler->handlerFiringExplosion()->getCurrentorderId() == orderId )||( m_mainHandler->handlerFiringSmoke()->getCurrentorderId() == orderId));
}
} // Namespace EffectShowClient
+59
View File
@@ -0,0 +1,59 @@
/**
* Handler for all Language HMI objects
* $Id$
* $HeadURL$
* $Author$
* Created by Hanna E. Rathje, SLSE, 2015-09-03
*/
#pragma once
#include <QObject>
#include <QMap>
#include <EffectShowClient/esc_db.h>
#include "dds_handler.h"
#include "esc_convert_from_tab.h"
#include "esc_convert_to_tab.h"
#include "logger.h"
namespace EffectShowClient
{
class ObjectOrder;
class MainHandler;
class HandlerOrder : public QObject
, protected Interface::Fts::OrderModifyRequestHandler
{
Q_OBJECT
public:
explicit HandlerOrder(MainHandler *mainHandler,
QObject *parent = nullptr);
~HandlerOrder();
bool init();
void createOrder(const ConvertFromTab::EffectShowOrder_t &effectShowOrder);
void createOrder(const ConvertFromTab::RelocationOrder_t &relocationOrder);
void removeOrder(const ConvertFromTab::OrderRetract_t &orderRetract);
void sendOrderConfirmation(const ConvertToTab::OrderConfirmation_t &oc);
void sendOrderConfirmationFromId(const ConvertToTab::OrderConfirmation_t &oc);
void updateOrderWithId(int orderId, const QString &answerText, EffectShowManagement::OrderConfirmation_e orderConf);
bool updateOrder(ObjectOrder* order,
const QString &answerText, EffectShowManagement::OrderConfirmation_e orderConf);
bool checkForActiveOrder(int orderId);
Q_SIGNALS:
void startHandlerFiring(const Database::EscOrder &escOrder);
void endHandlerFiring(const Database::EscOrder &escOrder);
void effectShowStarted();
void effectShowInterrupted();
private:
void onOrderModifyRequest(const rti::core::SampleIdentity &cookie,
const OrderModifyRequest &request) override final;
private:
QMap<int, ObjectOrder *> m_orderObjMap;
MainHandler *m_mainHandler;
NGL::INGLLogger &m_logger;
};
}
+145
View File
@@ -0,0 +1,145 @@
/**
* Handler for player data
* $Id$
* $HeadURL$
* $Author$
* Created by hjl, SLSE, 2017-02-20
*/
#include <QVector>
#include "main_handler.h"
#include "handler_tab_data.h"
#include "handler_order.h"
#include "handler_operating_condition.h"
#include "esc_convert_from_tab.h"
#include "settings.h"
namespace EffectShowClient
{
//=============================================================================
HandlerTabData::HandlerTabData(MainHandler *mainHandler,
QObject *parent)
: QObject(parent)
, m_mainHandler(mainHandler)
, m_logger(getLogger("HandlerTabData"))
{
} // end of ctor()
//=============================================================================
HandlerTabData::~HandlerTabData()
{
} // end of dtor()
//=============================================================================
bool HandlerTabData::init()
{
DEBUG_LOG(m_logger) << "Begin HandlerTabData";
auto dtcTab = m_mainHandler->dds()->dtcTab();
connect(dtcTab.get(), &TrainingAreaBase::Interface::Dtc::fireSmokeMarkerDataChanged,
this, &HandlerTabData::onFireSmokeMarkerDataChanged);
// Get current data for all Fire Smoke Marker
{
auto cb = [this](const TrainingAreaBase::FireSmokeMarkerData & fireSmokeMarker)
{
onFireSmokeMarkerDataChanged(fireSmokeMarker, DataModification::eAdded);
};
if (!dtcTab->fireSmokeMarkerDatas(cb))
return false;
}
DEBUG_LOG(m_logger) << "End HandlerTabData";
return true;
} // end of init()
//=============================================================================
void HandlerTabData::orderConfirmation(const ConvertToTab::OrderConfirmation_t &orderConfirmation)
{
DEBUG_LOG(m_logger) << "Trigger Sending of Order Confirmation ";
TrainingAreaBase::SendFireSmokeMarkerDataRequest out;
out.payload(ConvertToTab::convertOrderConfirmation(orderConfirmation));
m_mainHandler->dds()->ftcTab()->sendFireSmokeMarkerDataRequest(out, this);
}
//=============================================================================
void HandlerTabData::vehicleStatus(const ConvertToTab::VehicleStatus_t &vehicleStatus)
{
DEBUG_LOG(m_logger) << "Trigger Sending of Vehicle Status ";
TrainingAreaBase::SendFireSmokeMarkerDataRequest out;
out.payload(ConvertToTab::convertVehicleStatus(vehicleStatus));
m_mainHandler->dds()->ftcTab()->sendFireSmokeMarkerDataRequest(out, this);
}
//=============================================================================
void HandlerTabData::onSendFireSmokeMarkerDataReply(const Core::FunctionReplyObject &reply)
{
if (reply.error())
ERROR_LOG(m_logger) << "Fire Smoke Marker Data could not be send: " << reply.str();
else
DEBUG_LOG(m_logger) << "Fire Smoke Marker Data send successfully to TAB!";
}
//-----------------------------------------------------------------------------
void HandlerTabData::onFireSmokeMarkerDataChanged(const TrainingAreaBase::FireSmokeMarkerData &data, DataModification modType)
{
if (modType == DataModification::eRemoved)
return;
DEBUG_LOG(m_logger) << "Got Fire Smoke Marker " << data.sampleTime();
switch (ConvertFromTab::isTelegram(data))
{
case ConvertFromTab::RxTelegram_e::EffectShowOrder:
{
DEBUG_LOG(m_logger) << "Got Effect Show Order";
m_mainHandler->handlerOrder()->createOrder(ConvertFromTab::convertEffectShowOrder(data));
break;
}
case ConvertFromTab::RxTelegram_e::RelocationOrder:
{
DEBUG_LOG(m_logger) << "Got Relocation order ";
m_mainHandler->handlerOrder()->createOrder(ConvertFromTab::convertRelocationOrder(data));
break;
}
case ConvertFromTab::RxTelegram_e::EffectShowStop:
{
DEBUG_LOG(m_logger) << "Got Effect Show Stop ";
emit effectShowStopped(ConvertFromTab::convertEffectShowStop(data));
break;
}
case ConvertFromTab::RxTelegram_e::EffectShowContinue:
{
DEBUG_LOG(m_logger) << "Got Effect Show Continue ";
emit effectShowContinued(ConvertFromTab::convertEffectShowContinue(data));
break;
}
case ConvertFromTab::RxTelegram_e::OrderRetract:
{
DEBUG_LOG(m_logger) << "Got Order Retract ";
m_mainHandler->handlerOrder()->removeOrder(ConvertFromTab::convertOrderRetract(data));
break;
}
case ConvertFromTab::RxTelegram_e::StatusRequest:
{
DEBUG_LOG(m_logger) << "Got Status Request " ;
if (ConvertFromTab::convertStatusRequest(data))
{
m_mainHandler->handlerOperatingCondition()->sendStatus();
}
break;
}
case ConvertFromTab::RxTelegram_e::MeteoData:
{
DEBUG_LOG(m_logger) << "Got Meteo Data ";
if (!m_mainHandler->dds()->dts()->publish(ConvertFromTab::convertMeteoData(data)))
ERROR_LOG(m_logger) << "Error publishing MeteoNearVehicle to dds";
break;
}
case ConvertFromTab::RxTelegram_e::unknown:
break;
}
}
//-----------------------------------------------------------------------------
} // namespace EffectShowClient
+70
View File
@@ -0,0 +1,70 @@
/**
* Handler for player data
* $Id$
* $HeadURL$
* $Author$
* Created by gr, SLSE, 2017-02-20
*/
#pragma once
#include "dds_handler.h"
#include "logger.h"
#include "esc_convert_from_tab.h"
#include "esc_convert_to_tab.h"
#include <TrainingAreaBase/tab_dtc.h>
namespace EffectShowClient
{
class MainHandler;
/**
* @brief Handler for data exchange with the Training Aeria Base (TAB) Proxy.
*
* (1)Receives the telegrams from central operating station via Training Area Base proxy.\n
* (2)Sends Telegrams to central operating station via Training Area Base proxy.\n
*/
class HandlerTabData : public QObject
, protected TrainingAreaBase::Interface::Ftc::SendFireSmokeMarkerDataReplyHandler
{
Q_OBJECT
public:
explicit HandlerTabData(MainHandler *mainHandler,
QObject *parent = nullptr);
~HandlerTabData();
/**
* @brief Receives the relevant telegrams from TAB after service start
*/
bool init();
/**
* @brief Triggers TAB to send order confirmation telegram to central operating station.
* @param[in] orderConfirmation Data for order confirmation telegram
*/
void orderConfirmation(const ConvertToTab::OrderConfirmation_t &orderConfirmation);
/**
* @brief Triggers TAB to send the vehicle status telegramm to central operating station.
* @param[in] vehicleStatus Data for vehicle status telegram
*/
void vehicleStatus(const ConvertToTab::VehicleStatus_t &vehicleStatus);
protected:
void onSendFireSmokeMarkerDataReply(const Core::FunctionReplyObject &reply) override final;
Q_SIGNALS:
void effectShowStopped(qint16 idEffectShow);
void effectShowContinued(const ConvertFromTab::EffectShowContinue_t &effectShowContinue);
private Q_SLOTS:
void onFireSmokeMarkerDataChanged(const TrainingAreaBase::FireSmokeMarkerData &data, DataModification modType);
private: // attributes
MainHandler *m_mainHandler;
NGL::INGLLogger &m_logger;
};
} // namespace EffectShowClient
+287
View File
@@ -0,0 +1,287 @@
/**
* Handler for player data
* $Id$
* $HeadURL$
* $Author$
* Created by hjl, SLSE, 2017-02-20
*/
#include "handler_vehicle.h"
#include "main_handler.h"
#include "esc_helper.h"
#include "control_unit_handler.h"
#include <QCoreApplication>
#include <NGLLogger/NGLLoggerBootstrap.h>
#include <QTimer>
namespace EffectShowClient
{
//=============================================================================
HandlerVehicle::HandlerVehicle(MainHandler *mainHandler,
QObject *parent)
: QObject(parent)
, m_mainHandler(mainHandler)
, m_volleyTimer(new QTimer(this))
, m_remainingTimer(new QTimer(this))
, m_logger(getLogger("HandlerVehicle"))
{
DEBUG_LOG(m_logger) << "HandlerVehicle ctor";
m_volleyTimer->setSingleShot(true);
m_remainingTimer->setInterval(1000);
m_statusExplosionFiring.remainingTime_s = -1;
m_statusSmokeFiring.remainingTime_s = -1;
}
//=============================================================================
HandlerVehicle::~HandlerVehicle()
{
//delete m_mainHandler;
}
//=============================================================================
bool HandlerVehicle::init()
{
DEBUG_LOG(m_logger) << "HandlerVehicle::init()";
connect(m_mainHandler->handlerControlUnit().get(), &ControlUnitHandler::vehicleBattery, this, &HandlerVehicle::vehicleBattery);
connect(m_mainHandler->handlerControlUnit().get(), &ControlUnitHandler::vehicleFinshedVolley, this, &HandlerVehicle::onVolleyFinished);
//connect(m_mainHandler->handlerControlUnit().get(), &ControlUnitHandler::vehicleShutDown, this, &HandlerVehicle::vehicleShutDown);
connect(m_mainHandler->handlerControlUnit().get(), &ControlUnitHandler::vehicleSmokeCardridgesFireStatus, this, &HandlerVehicle::vehicleSmokeCardridgesFireStatus);
connect(m_mainHandler->handlerControlUnit().get(), &ControlUnitHandler::vehicleSmokeCardridgesStatus, this, &HandlerVehicle::vehicleSmokeCardridgesStatus);
connect(m_mainHandler->handlerControlUnit().get(), &ControlUnitHandler::vehicleFireUnits, this, &HandlerVehicle::vehicleFireUnits);
connect(m_mainHandler->handlerControlUnit().get(), &ControlUnitHandler::vehicleStoppedVolley, this, &HandlerVehicle::onVolleyStopped);
connect(m_mainHandler->handlerControlUnit().get(), &ControlUnitHandler::vehicleType, this, &HandlerVehicle::vehicleType);
connect(m_volleyTimer, &QTimer::timeout, this, &HandlerVehicle::onStartVolley);
connect(m_remainingTimer, &QTimer::timeout, this, &HandlerVehicle::onRemainingTimerTimeOut);
return true;
}
//=============================================================================
bool HandlerVehicle::isOperational() const
{
return true; // TODO: Decision for operational !!!!!
}
//=============================================================================
void HandlerVehicle::setAmmunitionParameter(int numberOfShotsMagazine)
{
//we send the ammunition and wait for return
m_mainHandler->handlerControlUnit()->send(CommandSignal::FT_SE_CB_WERFER_MUNITION, numberOfShotsMagazine);
}
//=============================================================================
int HandlerVehicle::burningTimeSmokeCartridge_s() const
{
return 80 * 1000; // TODO:
}
//=============================================================================
void HandlerVehicle::setExplosionParameter(int numberOfVolley, int numberOfShot, qint64 duration)
{
DEBUG_LOG(m_logger) << "Duration: " << duration << " number of shots: " << numberOfShot << " number of volles" << numberOfVolley;
m_statusExplosionFiring.remainingShots = numberOfShot;
m_statusExplosionFiring.remainingTime_s = duration;
m_statusExplosionFiring.remainingVolley = numberOfVolley;
m_oldTime = duration;
//spread shots
spreadShotsInVolleys(numberOfShot, numberOfVolley);
m_currentVolley = 0;
m_statusExplosionFiring.shotsPerVolley = m_shotsInVolley.value(m_currentVolley);
// duration is 60sec
// 10 volley
// 6 shots per volley
emit readyForExplosionFiring(true);
}
void HandlerVehicle::recalcEverything()
{
spreadShotsInVolleys(m_statusExplosionFiring.remainingShots, m_statusExplosionFiring.remainingVolley);
m_currentVolley = 0;
}
//=============================================================================
void HandlerVehicle::setSmokeParameter(int lengthOfFogZone, int directionOfFogZone)
{
Q_UNUSED(directionOfFogZone);
m_statusSmokeFiring.remainingDistance_m = lengthOfFogZone;
m_statusSmokeFiring.remainingTime_s = burningTimeSmokeCartridge_s();
EffectShowClient::SafetyConfirmation_e sc = EffectShowClient::SafetyConfirmation_e_def::SafetyConfirmed;
emit safetyConfirmation(sc);
emit readyForSmokeFiring(true);
effectShowControl(EffectShowControl_e::Start);
}
//=============================================================================
void HandlerVehicle::effectShowControl(EffectShowControl_e effectShowControl)
{
m_remainingTimer->stop();
switch (effectShowControl)
{
case EffectShowControl_e::Start:
{
emit statusExplosionFiring(m_statusExplosionFiring);
onStartVolley();
return;
}
case EffectShowControl_e::Stop:
{
emit statusExplosionFiring(m_statusExplosionFiring);
//stop volley
m_mainHandler->handlerControlUnit()->send(CommandSignal::FT_SE_CB_SALVE_UNTERBRECHEN);
break;
}
case EffectShowControl_e::Continue:
{
emit statusExplosionFiring(m_statusExplosionFiring);
onStartVolley();
break;
}
case EffectShowControl_e::Abort:
{
m_mainHandler->handlerControlUnit()->send(CommandSignal::FT_SE_CB_SALVE_UNTERBRECHEN);
m_statusExplosionFiring.remainingTime_s = 0;
m_statusExplosionFiring.remainingShots = 0;
m_statusExplosionFiring.remainingVolley = 0;
EffectShowClient::SafetyConfirmation_e sc = EffectShowClient::SafetyConfirmation_e_def::SafetyNotConfirmed;
emit safetyConfirmation(sc);
break;
}
case EffectShowControl_e::StopTimer:
{
m_oldTime = m_statusExplosionFiring.remainingTime_s;
break;
}
}
}
//========================================================m_statusExplosionFiring=====================
void HandlerVehicle::spreadShotsInVolleys(int shots, int volleys)
{
m_shotsInVolley.clear();
m_pauseAfterVolley.clear();
qint64 pauseTime = m_statusExplosionFiring.remainingTime_s - (shots * m_timeBetweenShots);
if (volleys == 1)
{
m_shotsInVolley.insert(0, shots);
m_pauseAfterVolley.insert(0, 0);
}
else
{
while (shots > 0)
{
for (int volley = 0; volley < volleys; volley++)
{
m_shotsInVolley.insert(volley, m_shotsInVolley.value(volley) + 1);
shots--;
if (shots <= 0)
break;
}
}
while (pauseTime > 0)
{
for (int volley = 0; volley < (volleys - 1); volley++)
{
m_pauseAfterVolley.insert(volley, m_pauseAfterVolley.value(volley) + 1);
pauseTime--;
if (pauseTime <= 0)
break;
}
}
}
}
void HandlerVehicle::onVolleyStopped(int shots)
{
DEBUG_LOG(m_logger) << "Volles Stopped after " << shots << " rounds";
//m_statusExplosionFiring.remainingTime_s = 0;
//stopp timer and take current seconds
m_remainingTimer->stop();
m_volleyTimer->stop();
m_statusExplosionFiring.remainingShots = m_statusExplosionFiring.remainingShots - shots;
if (m_statusExplosionFiring.remainingVolley > 0 && shots > 0)
{
m_oldTime = m_statusExplosionFiring.remainingTime_s;
m_currentVolley++;
m_statusExplosionFiring.remainingVolley--;
if (m_statusExplosionFiring.remainingShots > 0 && m_statusExplosionFiring.remainingVolley <= 0)
{
m_statusExplosionFiring.remainingVolley = 1;
m_currentVolley--;
}
}
emit statusExplosionFiring(m_statusExplosionFiring);
}
void HandlerVehicle::onVolleyFinished(int shots)
{
DEBUG_LOG(m_logger) << "Volley finished after shots: " << shots;
m_remainingTimer->stop();
if (m_volleyTimer->isActive())
m_volleyTimer->stop();
m_statusExplosionFiring.remainingShots = m_statusExplosionFiring.remainingShots - shots;
//calc remaining time
qint64 pauseTime = 0;
if (m_currentVolley > 0)
pauseTime = m_pauseAfterVolley.value(m_currentVolley - 1);
//m_statusExplosionFiring.remainingTime_s = m_statusExplosionFiring.remainingTime_s - (m_timeBetweenShots * (shots - 1)) - pauseTime;
m_statusExplosionFiring.remainingTime_s = m_oldTime - (m_timeBetweenShots * shots) - pauseTime;
DEBUG_LOG(m_logger) << "Remaining time: " << m_statusExplosionFiring.remainingTime_s;
m_oldTime = m_statusExplosionFiring.remainingTime_s;
if (m_statusExplosionFiring.remainingTime_s < 0 || m_statusExplosionFiring.remainingShots == 0)
m_statusExplosionFiring.remainingTime_s = 0;
if (m_statusExplosionFiring.remainingShots < 0)
m_statusExplosionFiring.remainingShots = 0;
if (m_statusExplosionFiring.remainingVolley > 0)
m_statusExplosionFiring.remainingVolley--;
emit statusExplosionFiring(m_statusExplosionFiring);
if (m_statusExplosionFiring.remainingShots > 0 && m_statusExplosionFiring.remainingTime_s > 0)
{
m_volleyTimer->start(m_pauseAfterVolley.value(m_currentVolley));
m_remainingTimer->start();
}
else
{
//finished now so revoke
m_mainHandler->handlerControlUnit()->send(CommandSignal::FT_SE_CB_SICHERHEIT_WIDERRUFEN);
}
m_currentVolley++;
}
void HandlerVehicle::onStartVolley()
{
DEBUG_LOG(m_logger) << "Send Start Volley";
if (!m_remainingTimer->isActive())
m_remainingTimer->start();
if (m_volleyTimer->isActive())
m_volleyTimer->stop();
m_mainHandler->handlerControlUnit()->send(CommandSignal::FT_SE_CB_WERFER_STATUS, m_shotsInVolley.value(m_currentVolley));
}
void HandlerVehicle::onRemainingTimerTimeOut()
{
m_statusExplosionFiring.remainingTime_s -= 1000;
if (m_statusExplosionFiring.remainingTime_s < 0)
m_statusExplosionFiring.remainingTime_s = 0;
if (m_statusExplosionFiring.remainingTime_s == 0)
{
m_remainingTimer->stop();
if (m_volleyTimer->isActive())
m_volleyTimer->stop();
}
emit statusExplosionFiring(m_statusExplosionFiring);
}
} // namespace EffectShowClient
+133
View File
@@ -0,0 +1,133 @@
/**
* Handler for player data
* $Id$
* $HeadURL$
* $Author$
* Created by gr, SLSE, 2017-02-20
*/
#pragma once
#include "EffectShowClient/esc_db.h"
#include "esc_convert_to_tab.h"
#include "logger.h"
#include "esc_helper.h"
#include <QObject>
#include <QTimer>
#include <QMap>
namespace EffectShowClient
{
class MainHandler;
/**
* @brief Handler for data exchange with the equipment of the vhicle.
*
* (1)Receives data inputs from the vehicle.\n
* (2)Sends data outputs to the vhicle.\n
*/
class HandlerVehicle : public QObject
{
Q_OBJECT
public:
explicit HandlerVehicle(MainHandler *mainHandler,
QObject *parent = nullptr);
~HandlerVehicle();
/**
* @brief Initialization of the data exchange with the vehicle equipment.
*/
bool init();
/**
* @brief Returns whether the vehicle is operational.
* @return (true)The Vehicle is operational
*/
bool isOperational() const;
/**
* @brief Provides the number of available shots and equipped shots.
* @param[in] numberOfShotsAvailable Number of shots available
* @param[in] numberOfShotsMagazine Number of shots equipped
*/
void setAmmunitionParameter(int numberOfShotsMagazine);
/**
* @brief Returns the burning time of a smoke cartridge.
* @return Burning time of a smoke cartridge [s]
*/
int burningTimeSmokeCartridge_s() const;
/**
* @brief Sets explosion parameter.
* @param[in] numberOfVolley Number of volley. The volleys are evenly distributed throughout the duration.
* @param[in] numberofShot Number of shots overall.
* @param[in] duration Duration[ms] over all volleys.
*/
void setExplosionParameter(int numberOfVolley, int numberOfShot, qint64 duration);
/**
* @brief Recalculates all spreads.
*/
void recalcEverything();
/**
* @brief Sets smoke prameter.
* @param[in] lengthOfFogZone Length of fog zone [m]
* @param[in] directionOfFogZone Direction of fog zone [deg]
*/
void setSmokeParameter(int lengthOfFogZone, int directionOfFogZone);
/**
* @brief Controls the effect show.
* @param[in] effectShowControl Effect show control parameter.
*/
void effectShowControl(EffectShowClient::EffectShowControl_e effectShowControl);
private:
void spreadShotsInVolleys(int shots, int volleys);
signals:
void safetyConfirmation(const EffectShowClient::SafetyConfirmation_e &safetyConfirmed);
void statusExplosionFiring(const StatusExplosionFiring_t &statusExplosion);
void statusSmokeFiring(const StatusSmokeFiring_t &statusExplosion);
void readyForExplosionFiring(bool ready);
void readyForSmokeFiring(bool ready);
void vehicleBattery(double battery);
void vehicleSmokeRounds(int smokeRounds);
void vehilceSmokeAmmunition(int ammunition);
void vehicleShutDown();
void vehicleFinshedVolley(int rounds);
void vehicleStoppedVolley(int rounds);
void vehicleFireUnits(const CardRidges &cardRidges);
void vehicleSmokeCardridgesStatus(const CardRidges &cardRidges);
void vehicleSmokeCardridgesFireStatus(const CardRidges &cardRidges);
void vehicleType(EffectShowManagement::Feature_e type);
private slots:
void onStartVolley();
void onRemainingTimerTimeOut();
void onVolleyStopped(int shots);
void onVolleyFinished(int shots);
// void onSafetyUpdate(const SafetyConfirmation_e safety);
private: // attributes
MainHandler *m_mainHandler{nullptr};
QTimer *m_volleyTimer{nullptr};
QTimer *m_remainingTimer{nullptr};
double m_timeBetweenShots{800};
int m_currentVolley{0};
qint64 m_oldTime{0};
StatusExplosionFiring_t m_statusExplosionFiring;
StatusSmokeFiring_t m_statusSmokeFiring;
QMap<int, int> m_shotsInVolley;
QMap<int, double> m_pauseAfterVolley;
NGL::INGLLogger &m_logger;
};
} // namespace EffectShowClient
+80
View File
@@ -0,0 +1,80 @@
log4j.reset=true
log4j.rootLogger=WARN, file
# Service: EffectShowClient
###########################################################
#log4j.logger.ESC=DEBUG
#log4j.logger.ESC.main=DEBUG
#log4j.logger.ESC.DdsHandler=DEBUG
#log4j.logger.ESC.MainHandler=DEBUG
#
# Lts::RollingFileAppender
log4j.appender.file=Lts::RollingFileAppender
log4j.appender.file.MaxFileSize=1MB
log4j.appender.file.MaxBackupIndex=9
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d %-5p %c |#| %m (%.50F:%L) %n
# Appnd_Console
###########################################################
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern= %d %p %c %c{1} - %m (%-.30F:%L) %n
# Appnd_Syslog
###########################################################
log4j.appender.syslog=org.apache.log4j.SyslogAppender
log4j.appender.syslog.Threshold=ERROR
log4j.appender.syslog.SysLogHost=localhost
log4j.appender.syslog.Facility=LOCAL7
log4j.appender.syslog.layout=org.apache.log4j.PatternLayout
log4j.appender.syslog.layout.ConversionPattern= %-4r %-5p %c %x - %m
log4j.appender.syslog.LevelRangeFilter.AcceptOnMatch=true
log4j.appender.syslog.LevelRangeFilter.LevelMin=INFO
log4j.appender.syslog.LevelRangeFilter.LevelMax=FATAL
###########################################################
###########################################################
###########################################################
# 1) Available Levels in LOG4CXX Version 0.10.0:
# TRACE,
# DEBUG,
# INFO,
# WARN,
# ERROR
# FATAL
#
# d = date/time
# p = priority (Level)
# c = category/channel
# m = message
# F = file
# L = line
# n = platform dependent line separator character or characters.
# ....
#
# Examples for console:
# a)
# %d %p %c #%m# (%.50F:%L)%n
# date/time
# priority
# category/channel
# #message#
# (Maximal 50Character des Filename von rechts:Line)
# line separator
#
# b)
# %d (%.15F:%L) %-5p %c |#| %m%n
# date/time
# (Maximal 15Character des Filename von rechts:Line)
# priority, Right pad with spaces if the priority name is less than 5 characters long.
# category/channel
# message
# line separator
#
# Examples for files:
+37
View File
@@ -0,0 +1,37 @@
/**
* @RDE_HEADER@
* Building Config - logging facility
* $Id$
* $HeadURL$
* $Author$
*/
#include "logger.h"
#include <NGLLogger/NGLLoggerBootstrap.h>
namespace EffectShowClient
{
LOGGER_T getLogger(const char *name)
{
static const char ns[] = "ESC.";
std::string loggerName;
const size_t len = strlen(name);
loggerName.reserve(sizeof(ns) + len);
loggerName.append(ns, sizeof(ns) - 1);
loggerName.append(name, len);
try
{
return NGL::NGLLoggerBootstrap::getNGLRootLogger().
getNGLLogger(loggerName);
}
catch (const std::exception &ex)
{
fprintf(stderr, "Error retrieving logger: %s", ex.what());
abort();
}
}
} // namespace EffectShowClient
+23
View File
@@ -0,0 +1,23 @@
/**
* @RDE_HEADER@
* Logging for EffectShowClient
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include <NGLLogger/INGLLogger.h>
#include "esc_export.h"
namespace EffectShowClient
{
using LOGGER_T = NGL::INGLLogger &;
ESC_COMMON_EXPORT LOGGER_T getLogger(const char *name);
inline LOGGER_T getLogger(const QString &loggerName)
{
return getLogger(loggerName.toUtf8().constData());
}
} // namespace EffectShowClient
+44
View File
@@ -0,0 +1,44 @@
/**
* @RDE_HEADER@
* main for EffectShowClient
* $Id$
* $HeadURL$
* $Author$
*/
#include <nglapplication/nglcoreapplication.h>
#include <LtsCommandLineParser/LtsCommandLineParser.h>
#include <QNetworkProxy>
#include "main_handler.h"
#include "logger.h"
#include "settings.h"
int main(int argc, char **argv)
{
NGLCoreApplication app(argc, argv);
QNetworkProxy::setApplicationProxy(QNetworkProxy());
LtsCommandLineParser::LtsCommandLineParser options;
if (!options.init())
return -1;
app.createLogger("ESC", options.exerciseId());
EffectShowClient::Settings::setIniFile(options.iniFile());
int iRet = -3;
{
std::unique_ptr<EffectShowClient::MainHandler> mainHandler(new EffectShowClient::MainHandler);
if (!mainHandler->init(options.domainId(), options.exerciseId()))
return iRet;
STARTUP_LOG(app.baseLogger());
iRet = app.exec();
SHUTDOWN_LOG(app.baseLogger());
}
return iRet;
}
+132
View File
@@ -0,0 +1,132 @@
/**
* MainHandler for AssetManagement
* $Id$
* $HeadURL$
* $Author$
*/
#include "main_handler.h"
#include "handler_order.h"
#include "handler_operating_condition.h"
#include "handler_firing_explosion.h"
#include "handler_firing_smoke.h"
#include "handler_tab_data.h"
#include "handler_vehicle.h"
#include "control_unit_handler.h"
#include "settings.h"
#include <DDS/Core/pacemaker.h>
namespace EffectShowClient
{
MainHandler::MainHandler(QObject *parent)
: QObject(parent)
, m_ddsHandler(nullptr)
, m_dbHandler(nullptr)
, m_handlerOrder(nullptr)
, m_handlerOperatingCondition(nullptr)
, m_handlerFiringExplosion(nullptr)
, m_handlerFiringSmoke(nullptr)
, m_handlerTabData(nullptr)
, m_handlerVehicle(nullptr)
, m_handlerControlUnit(nullptr)
, m_logger(getLogger("MainHandler"))
{}
MainHandler::~MainHandler()
{
m_handlerOrder = nullptr;
m_handlerOperatingCondition = nullptr;
m_handlerFiringExplosion = nullptr;
m_handlerFiringSmoke = nullptr;
m_handlerTabData = nullptr;
m_handlerVehicle = nullptr;
m_handlerControlUnit = nullptr;
m_dbHandler = nullptr;
m_ddsHandler = nullptr;
}
bool MainHandler::init(int domainId, int exerciseId)
{
// initialize database
m_dbHandler = std::make_shared<DbHandler>();
if (!m_dbHandler->init(exerciseId, Settings::settings()))
{
ERROR_LOG(m_logger) << "Initialisation dbHandler failed.";
return false;
}
DEBUG_LOG(m_logger) << "Initialisation dbHandler succesful.";
// initialize DDS
m_ddsHandler = std::make_shared<DdsHandler>(domainId, exerciseId);
if (!m_ddsHandler->init())
{
ERROR_LOG(m_logger) << "Initialisation ddsHandler failed.";
return false;
}
DEBUG_LOG(m_logger) << "Initialisation ddsHandler succesful.";
// init control unit handler
m_handlerControlUnit = std::make_shared<EffectShowClient::ControlUnitHandler>(this);
if (!m_handlerControlUnit->init())
{
ERROR_LOG(m_logger) << "Initialisation control unit handler failed.";
return false;
}
DEBUG_LOG(m_logger) << "Initialisation control unit handler succesful.";
// create handler
m_handlerOrder = std::make_shared<HandlerOrder>(this, this);
m_handlerOperatingCondition = std::make_shared<HandlerOperatingCondition>(this, this);
m_handlerFiringExplosion = std::make_shared<HandlerFiringExplosion>(this, this);
m_handlerFiringSmoke = std::make_shared<HandlerFiringSmoke>(this, this);
m_handlerTabData = std::make_shared<EffectShowClient::HandlerTabData>(this, this);
m_handlerVehicle = std::make_shared<EffectShowClient::HandlerVehicle>(this, this);
// ini handler
if (!m_handlerOrder->init())
{
ERROR_LOG(m_logger) << "Initialisation HandlerOrder failed.";
return false;
}
if (!m_handlerOperatingCondition->init())
{
ERROR_LOG(m_logger) << "Initialisation handlerOperatingCondition failed.";
return false;
}
if (!m_handlerFiringExplosion->init())
{
ERROR_LOG(m_logger) << "Initialisation handlerFiringExplosion failed.";
return false;
}
if (!m_handlerFiringSmoke->init())
{
ERROR_LOG(m_logger) << "Initialisation handlerFiringSmoke failed.";
return false;
}
if (!m_handlerTabData->init())
{
ERROR_LOG(m_logger) << "Initialisation HandlerTabData failed.";
return false;
}
if (!m_handlerVehicle->init())
{
ERROR_LOG(m_logger) << "Initialisation handlerVehicle failed.";
return false;
}
m_ddsHandler->pacemaker()->setNewState(Core::RunningState::Running);
return true;
}
} // namespace EffectShowClient
+65
View File
@@ -0,0 +1,65 @@
/**
* MainHandler for AereaEffectSimulation
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include <QObject>
#include <memory>
#include "dds_handler.h"
#include <ngldb/db_service_handler.h>
#include "esc_db.h"
#include "logger.h"
namespace NGLDB
{
template <typename DB> class DbServiceHandler;
}
namespace EffectShowClient
{
using DbHandler = NGLDB::DbServiceHandler<DatabaseInterface>;
class HandlerOrder;
class HandlerOperatingCondition;
class HandlerFiringExplosion;
class HandlerFiringSmoke;
class HandlerTabData;
class HandlerVehicle;
class ControlUnitHandler;
class MainHandler : public QObject
{
Q_OBJECT
public:
explicit MainHandler(QObject *parent = nullptr);
~MainHandler();
bool init(int domainId, int exerciseId);
std::shared_ptr<DdsHandler> dds() const { return m_ddsHandler; }
std::shared_ptr<DatabaseInterface> db() const { return m_dbHandler->db(); }
std::shared_ptr<HandlerOrder> handlerOrder() const { return m_handlerOrder; }
std::shared_ptr<HandlerOperatingCondition> handlerOperatingCondition() const { return m_handlerOperatingCondition; }
std::shared_ptr<HandlerFiringExplosion> handlerFiringExplosion() const { return m_handlerFiringExplosion; }
std::shared_ptr<HandlerFiringSmoke> handlerFiringSmoke() const { return m_handlerFiringSmoke; }
std::shared_ptr<HandlerTabData> handlerTabData() const { return m_handlerTabData; }
std::shared_ptr<HandlerVehicle> handlerVehicle() const { return m_handlerVehicle; }
std::shared_ptr<ControlUnitHandler> handlerControlUnit() const { return m_handlerControlUnit; }
private:
std::shared_ptr<DdsHandler> m_ddsHandler;
std::shared_ptr<DbHandler> m_dbHandler;
std::shared_ptr<HandlerOrder> m_handlerOrder;
std::shared_ptr<HandlerOperatingCondition> m_handlerOperatingCondition;
std::shared_ptr<HandlerFiringExplosion> m_handlerFiringExplosion;
std::shared_ptr<HandlerFiringSmoke> m_handlerFiringSmoke;
std::shared_ptr<HandlerTabData> m_handlerTabData;
std::shared_ptr<HandlerVehicle> m_handlerVehicle;
std::shared_ptr<ControlUnitHandler> m_handlerControlUnit;
NGL::INGLLogger &m_logger;
};
} // namespace EffectShowClient
+189
View File
@@ -0,0 +1,189 @@
/**
* 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
+58
View File
@@ -0,0 +1,58 @@
/**
* Exercise object
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include "dds_handler.h"
#include "logger.h"
#include <QObject>
#include <NotificationManagement/nom_ftc.h>
#include <DDS/Core/function_reply_object.h>
// Generated
#include <EffectShowClient/esc_db.h>
namespace EffectShowClient
{
class MainHandler;
class ObjectOrder
: public QObject
, protected NotificationManagement::Interface::Ftc::CreateNotificationReplyHandler
{
Q_OBJECT
public:
explicit ObjectOrder(MainHandler *mainHandler, QObject *parent = nullptr);
~ObjectOrder();
Core::FunctionReplyObject createObject(const Database::EscOrder &data);
Core::FunctionReplyObject updateObject(const Database::EscOrder &data);
Core::FunctionReplyObject removeObject();
int getId() const { return m_data.id; }
const Database::EscOrder &getData() const { return m_data; }
void setOrderConfirmation(int orderConfirmation) { m_data.orderConfirmation = orderConfirmation; }
Core::FunctionReplyObject updateObject() { return updateObject(m_data); }
protected:
// Callbackfunctions for FTC
void onCreateNotificationReply(const Core::FunctionReplyObject &replyObject) override final;
protected Q_SLOTS:
void onPublishData();
private:
void createNotificationRequest();
void getCreateNotificationRequestData(NotificationManagement::CreateNotification &data);
MainHandler *m_mainHandler;
Database::EscOrder m_data;
NGL::INGLLogger &m_logger;
};
} // namespace EffectShowClient
+52
View File
@@ -0,0 +1,52 @@
/**
* Settings for EffectShowClient
* $Id$
* $HeadURL$
* $Author$
*/
#include "settings.h"
#include <QtCore/QSettings>
#include <nglsettings/nglsettings_settings.h>
#include <ngltools/ngltools_filesystem.h>
namespace EffectShowClient
{
class NGLSettingsClass : public NGL::Settings
{
public:
NGLSettingsClass()
: NGL::Settings(s_iniFile.isEmpty() ? NGL::findProjectConfigFile() : s_iniFile)
{}
static void setIniFile(const QString &fn)
{
s_iniFile = fn;
}
static QString s_iniFile;
};
QString NGLSettingsClass::s_iniFile;
Q_GLOBAL_STATIC(NGLSettingsClass, s)
//-----------------------------------------------------------------------------
NGL::Settings *Settings::settings()
{
return s();
}
//-----------------------------------------------------------------------------
void Settings::setIniFile(const QString &ini)
{
NGLSettingsClass::setIniFile(ini);
}
QString Settings::hostName()
{
return settings()->settings()->value(QLatin1String("TcpPort/HostName"), QStringLiteral("192.168.184.1")).toString();
}
quint32 Settings::port()
{
return settings()->settings()->value(QLatin1String("TcpPort/Port"), 8005).toUInt();
}
} // namespace EffectShowClient
+27
View File
@@ -0,0 +1,27 @@
/**
* Settings for EffectShowClient
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include <QString>
namespace NGL
{
class Settings;
}
namespace EffectShowClient
{
namespace Settings
{
NGL::Settings *settings();
void setIniFile(const QString &ini);
// tcp port configuration
QString hostName();
quint32 port();
}
} // namespace EffectShowClient