Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,132 @@
|
||||
// **************************************************************************
|
||||
//
|
||||
// (C) Copyright 2009 Swiss SIMTEC AG
|
||||
//
|
||||
// **************************************************************************
|
||||
//
|
||||
// $HeadURL$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $LastChangedRevision$
|
||||
//
|
||||
// **************************************************************************
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "PrtCnvThread.hpp"
|
||||
#include <queue>
|
||||
#include <set>
|
||||
|
||||
class QTcpServer;
|
||||
class QMutex;
|
||||
|
||||
namespace N_CoPrtCnv
|
||||
{
|
||||
class CoPrtCnvCentralTelegram;
|
||||
}
|
||||
|
||||
namespace PrtCnv
|
||||
{
|
||||
class PrtCnvInjectionSocket;
|
||||
/**
|
||||
* This class represents a thread, which acts as TCP-Server. The LogView-
|
||||
* application can connect to it and send radio- or central-telegrams. The
|
||||
* telegrams will be stored within this class and can be taken by another thread.
|
||||
* This mechanism will be used for inject telegrams to protocol-converter.
|
||||
*
|
||||
* @author alois.wismer
|
||||
* @version 1.0
|
||||
* @created 05-Aug-2010 11:17:06
|
||||
*/
|
||||
class PrtCnvInjectionThread : public PrtCnvThread
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
~PrtCnvInjectionThread();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a_parent
|
||||
*/
|
||||
explicit PrtCnvInjectionThread(PrtCnvThreadStarter* a_parent);
|
||||
|
||||
|
||||
int32_t create(NGL::Settings *settings) override;
|
||||
|
||||
|
||||
int32_t init() override;
|
||||
|
||||
/**
|
||||
* Starts the thread and listen for TCP-clients
|
||||
*/
|
||||
int32_t start() override;
|
||||
|
||||
/**
|
||||
* Returns the next central-telegram to be injected. It will automatically be
|
||||
* taken out of the list.
|
||||
* The caller is responsible to delete the telegram, if no longer used.
|
||||
* Returns NULL if no central-telegram available
|
||||
*/
|
||||
N_CoPrtCnv::CoPrtCnvCentralTelegram *getNextCentralInjectionTelegram();
|
||||
|
||||
/**
|
||||
* Returns the next radio-telegram to be injected. It will automatically be taken
|
||||
* out of the list.
|
||||
* The caller is responsible to delete the telegram, if no longer used.
|
||||
* Returns NULL if no radio-telegram available
|
||||
*/
|
||||
N_CoPrtCnv::CoPrtCnvCentralTelegram *getNextRadioInjectionTelegram();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a_telegram
|
||||
*/
|
||||
void addToCentralList(N_CoPrtCnv::CoPrtCnvCentralTelegram *a_telegram);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a_telegram
|
||||
*/
|
||||
void addToRadioList(N_CoPrtCnv::CoPrtCnvCentralTelegram *a_telegram);
|
||||
|
||||
protected: /**
|
||||
* The port of the injection-server (configurable with key 'Port' in group
|
||||
* [Injection])
|
||||
*/
|
||||
uint16_t m_Port;
|
||||
/**
|
||||
* true if injection-server is enabled (configurable with key 'Enable' in group
|
||||
* [Injection])
|
||||
*/
|
||||
bool m_Enabled;
|
||||
QTcpServer *m_Server;
|
||||
|
||||
|
||||
std::queue<N_CoPrtCnv::CoPrtCnvCentralTelegram *> m_CentralTelegramList;
|
||||
QMutex *m_CentralListMutex;
|
||||
|
||||
|
||||
std::queue<N_CoPrtCnv::CoPrtCnvCentralTelegram *> m_RadioTelegramList;
|
||||
QMutex *m_RadioListMutex;
|
||||
|
||||
|
||||
std::set<PrtCnvInjectionSocket*> m_SocketList;
|
||||
|
||||
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* Connects a TCP-client
|
||||
*/
|
||||
void connectClient();
|
||||
/**
|
||||
* Disconnects a TCP-client
|
||||
*
|
||||
* @param a_injectionSocket
|
||||
*/
|
||||
void disconnectClient(PrtCnvInjectionSocket* a_injectionSocket);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user