GrpcPrint/PrintS/PLC/Command/KeepAliveCommand.h

56 lines
1.4 KiB
C
Raw Normal View History

2024-03-19 17:45:12 +08:00
#pragma once
#include "PLCComand.h"
#include "../SysParam.h"
class KeepAliveCommand :public PLCCommand
{
public:
KeepAliveCommand(PLCReveiver* receiver) :PLCCommand(receiver) {}
~KeepAliveCommand(){ if (m_CtrlCommand)delete m_CtrlCommand; }
void Init()
{
m_CtrlCommand = new S7Command(S7_COMMAND_WRITE, 2);
TS7DataItem* pItem = m_CtrlCommand->getDataItems();
pItem[0].Area = S7AreaDB;
pItem[0].DBNumber = m_PCKeepAlice->GetDBNumber();
pItem[0].Start = m_PCKeepAlice->GetAddr();
pItem[0].WordLen = S7WLBit;
pItem[0].Amount = 1;
bool* tempKeepAlive= new bool[1];
pItem[0].pdata = tempKeepAlive;
m_KeepAliveValue = tempKeepAlive;
pItem[1].Area = S7AreaDB;
pItem[1].DBNumber = m_DevicePrinting->GetDBNumber();
pItem[1].Start = m_DevicePrinting->GetAddr();
pItem[1].WordLen = S7WLBit;
pItem[1].Amount = 1;
bool* tempDevicePrinting = new bool[1];
pItem[1].pdata = tempDevicePrinting;
m_DevicePrintingValue = tempDevicePrinting;
m_CtrlCommand->m_Ref = this;
m_CtrlCommand->isNeedDel = false;
}
void SetKeepAliveValue()
{
*m_KeepAliveValue = m_PrintKeepAliveFlag;
}
void SetDevicePrintingValue(bool bvalue) {
*m_DevicePrintingValue = bvalue;
}
public:
SysParamBool* m_PCKeepAlice; //PC<50><43><EFBFBD><EFBFBD>-<2D><>PLC
SysParamBool* m_DevicePrinting; //<2F><EFBFBD><E8B1B8>ӡ״̬
uint64_t m_PrintKeepAliveTimetick;
bool m_PrintKeepAliveFlag;
private:
bool* m_KeepAliveValue;
bool* m_DevicePrintingValue;
};