63 lines
1.4 KiB
C
63 lines
1.4 KiB
C
|
#pragma once
|
|||
|
#include "BaseClient.h"
|
|||
|
#include "../Log/ScannerPowerLog.h"
|
|||
|
#include "../config/bean/RunCfg.h"
|
|||
|
#include "../config/bean/AlarmCfg.h"
|
|||
|
#include "../config/bean/ExtCfg.h"
|
|||
|
|
|||
|
class ScannerPowerBean {
|
|||
|
|
|||
|
public:
|
|||
|
ScannerPowerBean()
|
|||
|
{
|
|||
|
m_Log = new ScannerPowerLog();
|
|||
|
m_LogTick = GetTickCount64();
|
|||
|
m_Voltage = 0.0f;
|
|||
|
m_Current = 0.0f;
|
|||
|
m_VoltageAlarm = false;
|
|||
|
m_VoltageAlarmTick = m_LogTick;
|
|||
|
|
|||
|
}
|
|||
|
~ScannerPowerBean()
|
|||
|
{
|
|||
|
if (m_Log)delete m_Log;
|
|||
|
}
|
|||
|
public:
|
|||
|
float m_Voltage;
|
|||
|
float m_Current;
|
|||
|
bool m_VoltageAlarm;
|
|||
|
ScannerPowerLog* m_Log;
|
|||
|
uint64_t m_LogTick;
|
|||
|
uint64_t m_VoltageAlarmTick;
|
|||
|
};
|
|||
|
|
|||
|
class ScannerPowerClient :public TcpClient
|
|||
|
{
|
|||
|
public:
|
|||
|
ScannerPowerClient(CommunicationCfg* pconfig);
|
|||
|
~ScannerPowerClient();
|
|||
|
void Init();
|
|||
|
void InitCommand();
|
|||
|
void ResetCycleCommand();
|
|||
|
void GetValue(int index,ScannerPowerBean& spb) {
|
|||
|
if (m_Datas.find(index) == m_Datas.end())return;
|
|||
|
EnterCriticalSection(&m_ValueCS);
|
|||
|
spb.m_Voltage = m_Datas[index]->m_Voltage;
|
|||
|
spb.m_Current = m_Datas[index]->m_Current;
|
|||
|
LeaveCriticalSection(&m_ValueCS);
|
|||
|
}
|
|||
|
void SetJobId(int jobid) { m_JobId = jobid; }
|
|||
|
int GetValueCount() { return m_Datas.size(); }
|
|||
|
private:
|
|||
|
void static PorcInfo(void* pobject, Command* pcommand);
|
|||
|
void static PorcInfo2(void* pobject, Command* pcommand);
|
|||
|
|
|||
|
private:
|
|||
|
map<unsigned char, ScannerPowerBean*> m_Datas;
|
|||
|
AlarmCfg* m_VoltageAlarmCfg;
|
|||
|
int m_JobId;
|
|||
|
RunCfg* m_RunCfg;
|
|||
|
ExtCfg* m_ExtCfg;
|
|||
|
};
|
|||
|
|