88 lines
2.7 KiB
C++
88 lines
2.7 KiB
C++
#ifndef _ZJD_SUB_IEC101_UNBALANCED_PROCESS_H_
|
|
#define _ZJD_SUB_IEC101_UNBALANCED_PROCESS_H_
|
|
|
|
#include "iec101.h"
|
|
|
|
class CIEC101SecondaryUnbalancedProcessItem : public CIEC101ProcessItem
|
|
{
|
|
public:
|
|
CIEC101SecondaryUnbalancedProcessItem() {};
|
|
virtual ~CIEC101SecondaryUnbalancedProcessItem() {};
|
|
public:
|
|
void Attach(int uid, int physicsAddress = 0, int commonAddress = 0, int originatorAddress = 0)
|
|
{
|
|
CIEC101ProcessItem::Attach(uid, physicsAddress, commonAddress, m_originatorAddress);
|
|
primaryLinkBalanced.otherStationAddress = physicsAddress;
|
|
common_address = commonAddress;
|
|
applicationlParameters.originatorAddress = originatorAddress;
|
|
}
|
|
void setAppLayerDataCount(int yx = 0, int yc = 0, int ym = 0)
|
|
{
|
|
total_yx = yx;
|
|
total_yc = yc;
|
|
total_ym = ym;
|
|
yx_pos = 0;
|
|
yc_pos = 0;
|
|
ym_pos = 0;
|
|
}
|
|
};
|
|
|
|
class CIEC101SecondaryUnbalancedProcess : public CIEC101SecondaryProcess
|
|
{
|
|
private:
|
|
enumIEC101_LinkLayerState m_state;
|
|
QWORD m_lastReceivedMsg;
|
|
int m_idleTimeout; /* connection timeout in ms */
|
|
public:
|
|
CIEC101SecondaryUnbalancedProcess()
|
|
{
|
|
m_linkLayer.mode = llSecUnbalanced;
|
|
m_state = LL_STATE_IDLE;
|
|
}
|
|
virtual ~CIEC101SecondaryUnbalancedProcess() {};
|
|
BOOLEAN OnPreCreate(int id);
|
|
BOOLEAN Run(void);
|
|
BOOLEAN OnTimer(void);
|
|
|
|
CIEC101ProcessItem *CreateItem(int ord)
|
|
{
|
|
return dynamic_cast<CIEC101ProcessItem *>(new CIEC101SecondaryUnbalancedProcessItem);
|
|
}
|
|
|
|
void Slave_setLinkLayerAddressOtherStation(CIEC101ProcessItem* pItem, int address)
|
|
{
|
|
pItem->address = address;
|
|
}
|
|
|
|
int OnPackageReceived(BYTE* pBuf, int count, int ord = -1);
|
|
private:
|
|
void llsu_setState(enumIEC101_LinkLayerState newState)
|
|
{
|
|
if (m_state != newState)
|
|
{
|
|
m_state = newState;
|
|
}
|
|
}
|
|
BOOLEAN checkFCB(pIEC101_LinkLayerSecondaryUnbalanced self, BOOLEAN fcb)
|
|
{
|
|
if (fcb != self->expectedFcb) return FALSE;
|
|
self->expectedFcb = !(self->expectedFcb);
|
|
return TRUE;
|
|
}
|
|
void ResetCUReceived(CIEC101ProcessItem* pItem, bool onlyFCB)
|
|
{
|
|
if (onlyFCB)
|
|
{
|
|
//vLog(LOG_DEBUG, "CS101 slave: Reset FCB received\n");
|
|
}
|
|
else
|
|
{
|
|
//vLog(LOG_DEBUG, "Received reset CU\n");
|
|
pItem->userDataClass1Queue.flush();
|
|
pItem->userDataClass2Queue.flush();
|
|
}
|
|
}
|
|
void LinkLayerSecondaryUnbalanced_ReceivedMessage(CIEC101ProcessItem* self, BYTE fc, BOOLEAN isBroadcast, BOOLEAN fcb, BOOLEAN fcv, BYTE* msg, int userDataStart, int userDataLength);
|
|
};
|
|
|
|
#endif // _ZJD_SUB_IEC101_UNBALANCED_PROCESS_H_
|