Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+220
@@ -0,0 +1,220 @@
|
||||
/**
|
||||
* Canag Handler for de/encoding LtsUtils::SfmMessage
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, NLST, 2018-01-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QObject>
|
||||
#include <QByteArray>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
#include <QPair>
|
||||
#include <QTimer>
|
||||
#include <QTcpSocket>
|
||||
|
||||
|
||||
#include <LtsUtilsCore/sfm_bytemessage_converter.h>
|
||||
|
||||
#include "handler_aes_data.h"
|
||||
#include "send_to_tab.h"
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
namespace TrainingAreaBaseOC
|
||||
{
|
||||
class ConnectionHandler;
|
||||
class MainHandler;
|
||||
class RecvFromTab;
|
||||
|
||||
enum class DdlState
|
||||
{
|
||||
NotStarted = 0,
|
||||
Initiated = 1,
|
||||
Downloading = 2
|
||||
};
|
||||
|
||||
class TxDdlHandler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TxDdlHandler();
|
||||
|
||||
void addData(const QByteArray &data);
|
||||
|
||||
signals:
|
||||
void send(const QByteArray &data);
|
||||
|
||||
public slots:
|
||||
void process(const QByteArray &data);
|
||||
|
||||
private slots:
|
||||
void startNextDomainDownload();
|
||||
void sendAbortOrRestartTimeout();
|
||||
|
||||
private:
|
||||
const qint32 s_maxResendCnt = 5;
|
||||
|
||||
struct DdlData
|
||||
{
|
||||
QByteArray data = QByteArray();
|
||||
qint32 offset = 0;
|
||||
};
|
||||
|
||||
void initiateDomainDownload();
|
||||
void domainDownload();
|
||||
void sendAbort(quint8 error = 0);
|
||||
|
||||
DdlState m_state;
|
||||
qint32 m_segmentToggle;
|
||||
qint32 m_sentCnt;
|
||||
QTimer *m_responseTimer;
|
||||
|
||||
QList<DdlData> m_dataToSend;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
|
||||
class RxDdlHandler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit RxDdlHandler(bool isMultiplexed = false);
|
||||
|
||||
void process(const QByteArray &data);
|
||||
|
||||
signals:
|
||||
void send(const QByteArray &data);
|
||||
void received(const QByteArray &data);
|
||||
void receivedMultiplexed(const QByteArray &data, quint32 multiplexer);
|
||||
|
||||
private:
|
||||
void sendDPConfirmation(const quint32 ccs, const quint32 toggle, const quint32 wirkfeldMultiplex = 0);
|
||||
|
||||
bool m_isMultiplexed = false;
|
||||
DdlState m_state = DdlState::NotStarted;
|
||||
|
||||
quint32 m_multiplexer = 0;
|
||||
QByteArray m_messageData;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
|
||||
class CanagHandler : public QObject
|
||||
, public SendToTab
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CanagHandler(MainHandler *mainHandler);
|
||||
~CanagHandler();
|
||||
|
||||
bool init();
|
||||
|
||||
bool txData(const OcTelegrams::DemandCyclicPositions &data) override;
|
||||
bool txData(const OcTelegrams::TechnicalStateOc &data) override;
|
||||
bool txData(const OcTelegrams::DemandSelftestSfm &data) override;
|
||||
bool txData(const TrainingAreaBase::TetraIcd::OpaquePayloadDataBase &data) override;
|
||||
|
||||
signals:
|
||||
void sendMessage(const LtsUtils::SfmMessage &);
|
||||
public slots:
|
||||
void handleSfmTelegram(const LtsUtils::SfmMessage &message);
|
||||
private slots:
|
||||
void sendDemandDeviceId();
|
||||
void sendDeviceMessage();
|
||||
void sendOcExcon(const QByteArray &data);
|
||||
void sendFireSmokeMarkerExcon(const QByteArray &data);
|
||||
void sendExconOc(const QByteArray &data);
|
||||
void sendExconFireSmokeMarker(const QByteArray &data);
|
||||
void sendSfmAwes(const QByteArray &data);
|
||||
void sendConnectionTestSfm();
|
||||
void receivedExconOc(const QByteArray &data);
|
||||
void receivedExconFireSmokeMarker(const QByteArray &data);
|
||||
void receivedSfmAwes(const QByteArray &data, quint32 multiplexer);
|
||||
void sfmAliveTimeout();
|
||||
void sendFreeText();
|
||||
void sendSyncTime(uint32_t syncTimeSec);
|
||||
|
||||
private:
|
||||
void send(const LtsUtils::SfmMessage &message);
|
||||
void send(quint32 canId, const QByteArray &data);
|
||||
|
||||
void openSocket();
|
||||
|
||||
void readSettings();
|
||||
void fillMessageMap();
|
||||
|
||||
void demandInitialSfmData();
|
||||
void sendDemandTechnicalStateSfm();
|
||||
void sendDemandSpecificsEquipment();
|
||||
void sendDemandSpecificsExercise();
|
||||
|
||||
void handleDisplayMessage(const LtsUtils::SfmMessage &message);
|
||||
|
||||
enum CanId
|
||||
{
|
||||
DemandDeviceId = 1,
|
||||
DeviceId = 2,
|
||||
Time = 7,
|
||||
EnterLeaveAes = 80,
|
||||
ParameterSfmTx = 243,
|
||||
ParameterSfmRx = 244,
|
||||
ParameterOcRx = 263,
|
||||
ParameterOcTx = 264,
|
||||
TechnicalStateSfm = 452,
|
||||
TechnicalStateOc = 466,
|
||||
FireSmokeMarkerExconDataRx = 510,
|
||||
FireSmokeMarkerExconDataTx = 511,
|
||||
ExconFireSmokeMarkerDataRx = 512,
|
||||
ExconFireSmokeMarkerDataTx = 513,
|
||||
ExconOcDataRx = 520,
|
||||
ExconOcDataTx = 521,
|
||||
OcExconDataRx = 522,
|
||||
OcExconDataTx = 523,
|
||||
DemandAwesData = 530,
|
||||
AwesDataRx = 531,
|
||||
AwesDataTx = 532,
|
||||
Position = 540,
|
||||
DemandCyclicPosition = 545,
|
||||
DisplayMessage = 684,
|
||||
SpecificsExercise = 732,
|
||||
SpecificsOc = 738,
|
||||
SpecificsEquipment = 742,
|
||||
EquipmentId = 765,
|
||||
ConnectionTestSfm = 1101,
|
||||
ConnectionTestSfmReply = 1102,
|
||||
WakeUp = 1760,
|
||||
WakeUpSfm = 1773
|
||||
};
|
||||
|
||||
MainHandler *m_mainHandler;
|
||||
std::shared_ptr<ConnectionHandler> m_connectionHandler;
|
||||
std::shared_ptr<HandlerAesData> m_handlerAesData;
|
||||
std::shared_ptr<RecvFromTab> m_rxHandler;
|
||||
|
||||
QByteArray m_freeText;
|
||||
|
||||
QTimer *m_deviceMessageTimer;
|
||||
QTimer *m_freeTextCollectionTimer;
|
||||
QTimer *m_sfmAliveTimer;
|
||||
QTimer *m_sfmConnectionCheckTimer;
|
||||
|
||||
QTcpSocket *m_syncSocket;
|
||||
|
||||
OcTelegrams::TechnicalStateSfm m_technicalStateSfm; // not just the telegram technicalState of the sfm but also total sfm connection check
|
||||
bool m_sfmConnectionEstablished;
|
||||
|
||||
QMap<CanId, LtsUtils::SfmMessage *> m_messages;
|
||||
QMap<CanId, TxDdlHandler *> m_txDdlHandler;
|
||||
QMap<CanId, RxDdlHandler *> m_rxDdlHandler;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
|
||||
} // namespace TrainingAreaBaseOC
|
||||
Reference in new issue
Block a user