#pragma once
|
#include <functional>
|
#include <string>
|
#include "Context.h"
|
#include "Intent.h"
|
#include "McBool.h"
|
#include "McString.h"
|
#include "McInt.h"
|
|
|
class CPLC;
|
class CComponent
|
{
|
public:
|
CComponent();
|
virtual ~CComponent();
|
|
|
public:
|
virtual std::string& getClassName() = 0;
|
void setPlc(CPLC* pPlc);
|
void setName(const char* pszName);
|
std::string& getName();
|
void setDescription(const char* pszDescription);
|
std::string& getDescription();
|
void setIndex(int index);
|
int getIndex();
|
virtual void onRecvBroadcast(void* pSender, CIntent* pIntent);
|
virtual void onData(int id, const void* pData, int size);
|
virtual void init();
|
virtual void term();
|
virtual int run();
|
virtual int stop();
|
virtual void OnTimer(UINT nTimerid);
|
virtual void Serialize(CArchive& ar);
|
static float toFloat(const char* pszAddr);
|
int WriteInt(int unitId, int addr, int value);
|
int WriteData(MC::SOFT_COMPONENT softComponent, unsigned int addr,
|
const char* pszData, unsigned int length, ONWRITE funOnWrite);
|
|
public:
|
inline void Lock() { EnterCriticalSection(&m_criticalSection); }
|
inline void Unlock() { LeaveCriticalSection(&m_criticalSection); }
|
|
protected:
|
void SendBroadcast(CIntent* pIntent);
|
|
protected:
|
CPLC* m_pPlc;
|
IMcChannel* m_pChannel1;
|
int m_nIndex;
|
std::string m_strName;
|
std::string m_strDescription;
|
CRITICAL_SECTION m_criticalSection;
|
|
protected:
|
BOOL m_bRunning;
|
};
|