优化结构

This commit is contained in:
zjk
2025-04-07 21:18:02 +08:00
parent ebf1701335
commit 7ef9ec5ac0
10 changed files with 785 additions and 248 deletions
+69
View File
@@ -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