优化结构
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
#ifndef LOWER_COMM_MANAGER_H
|
||||
#define LOWER_COMM_MANAGER_H
|
||||
#define UNIX
|
||||
|
||||
#include "MOOS/libMOOS/Comms/XPCUdpSocket.h"
|
||||
#include "MOOS/libMOOS/Utils/MOOSThread.h"
|
||||
#include "MOOS/libMOOS/Utils/MOOSLock.h"
|
||||
#include "ccuUdpMsg.h"
|
||||
#include "pmSysvariable.h"
|
||||
#include <queue>
|
||||
#include <map>
|
||||
#include <functional>
|
||||
#include <atomic>
|
||||
#include <vector>
|
||||
#include "udpComm.h"
|
||||
|
||||
class PowerManger; // 前向声明
|
||||
|
||||
class LowerCommManager {
|
||||
public:
|
||||
LowerCommManager(PowerManger* pm, long myPort, long ccuPort, const std::string& cccHost);
|
||||
~LowerCommManager();
|
||||
|
||||
//processPeriodicTasks
|
||||
void processPeriodicTasks();
|
||||
//clearMsgQueue
|
||||
void clearMsgQueue();
|
||||
|
||||
public:
|
||||
CMOOSLock m_CommMutex; // 保护UDP通信资源
|
||||
|
||||
// 初始化UDP通信
|
||||
bool initUdpComm();
|
||||
|
||||
// 更新设备状态
|
||||
bool updateDeviceStates();
|
||||
|
||||
// 发送CCU控制命令
|
||||
bool sendCcuCommand(const ccuColCmd cmd);
|
||||
bool sendDisSysCommand(const disSysBreakerList& cmd);
|
||||
|
||||
// 获取通信状态
|
||||
int getConnectionState() const { return m_connectState; }
|
||||
|
||||
// 启动/停止监听线程
|
||||
void startListenThread();
|
||||
void stopListenThread();
|
||||
|
||||
//转换函数
|
||||
char getBreakerOption(char cmd);
|
||||
|
||||
public:
|
||||
long m_port;
|
||||
long m_ccuPort;
|
||||
std::string m_ccuHost;
|
||||
std::string m_host;
|
||||
|
||||
PowerManger* m_pm;
|
||||
udpComm* m_udpComm;
|
||||
XPCUdpSocket* m_udpSocket;
|
||||
|
||||
CMOOSThread m_ListenThread;
|
||||
int m_connectState;
|
||||
|
||||
// UDP监听线程函数
|
||||
bool listenThreadFunc();
|
||||
};
|
||||
|
||||
#endif // LOWER_COMM_MANAGER_H
|
||||
Reference in New Issue
Block a user