修复了UDP通信的BUG并优化了相关代码,增加了json报告功能

This commit is contained in:
zjk
2024-11-23 17:28:51 +08:00
parent abd91d0e88
commit 6374e60b91
14 changed files with 881 additions and 464 deletions
+24 -3
View File
@@ -29,9 +29,19 @@
#include "udpComm.h"
#include "pmSysvariable.h"
#define VAR_TO_STR(var) #var
#define IPORT 5000
#define MAX_UDP_PKT_SIZE 65535
#define SKEW_TOLERANCE 5
#define PM_STATE_VAR "uPower_pmState_st"
#define PM_CURRENTSTATE_VAR "uPower_currentState_st"
#define PM_DISSTATE_VAR "uPower_disSysState_st"
#define PM_LIBATSTATE_VAR "uPower_liBatState_st"
#define PM_FCSSTATE_VAR "uPower_fcsState_st"
class PowerManger : public AppCastingMOOSApp
{
public:
@@ -53,8 +63,9 @@ class PowerManger : public AppCastingMOOSApp
XPCUdpSocket* setUdpScoket(long lPort);
bool updatePmState();
bool updateTime(){m_current_time = MOOSTime();}
void updateTime(){m_current_time = MOOSTime();}
bool IsSkewed(double dfTimeNow, double * pdfSkew = NULL);
string getTypeName(const string typeName);
bool buildPowerSysReport();
bool buildDisributionReport();
@@ -62,13 +73,22 @@ class PowerManger : public AppCastingMOOSApp
bool buildPredictionReport();
protected: // app variables
//系统状态
unsigned char workCondition;
unsigned char currentMod;
unsigned char powerState;
unsigned char falutLevel;
vector<unsigned int> faultCode;
unsigned int soc;
unsigned long int sustainableTime;
pmState m_pmCurrentState;
// 当前传输状态
msg_CcuStateFbMsg m_CcuCurrentState;
msg_disHighVolBusFbMsg m_disHighVolBusCurrentState;
msg_disHighAVolBusFbMsg m_disHighAVolBusCurrentState;
msg_disHighBVolBusFbMsg m_disHighBVolBusCurrentState;
msg_disLowBusFbMsg m_disLowBusState;
private: // Configuration variables
udpComm m_udpComm;
XPCUdpSocket *m_pCcuUdpComm;
@@ -79,7 +99,8 @@ class PowerManger : public AppCastingMOOSApp
double m_current_time;
// CMOOSThread m_SendThread;
private: // State variables
private: //
bool inline saveStringToJsonFile(const string &strJson, const string &strFileName);
};
#endif