| |

VerySource

 Forgot password?
 Register
Search
Author: barstear

Structural design issues, experts please come in

[Copy link]

2

Threads

13

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

 Author| Post time: 2020-12-21 18:45:01
| Show all posts
Ashamed, the project is in short order, and there is no time to organize and post it.
The following code is not organized, and it can generally explain the idea.
interface IStateSender
{
virtual BOOL InitSender() = 0;
virtual void OnReportState() = 0;
virtual void OnReportStateWithMsg(DeviceMsg devMsg, /*OUT*/ void* data) = 0;
virtual void RegStateCollector(IStatesCollector* pCollector) =0;
virtual int ToDoWork(DeviceMsg devMsg, /*IN*/ void* data) = 0;
virtual DevType SenderType() = 0;
};

interface IStatesCollector
{
virtual int OnRecvedDevMsg(DeviceMsg devMsg, void* pParam) = 0;
virtual void RegStateSender(IStateSender* pSender) = 0;
virtual void RegStatesCollector(IStatesCollector* pCollecter) = 0;
};

class CDispatchCenter: public IStatesCollector //it's CWhat.
{
public:
static CDispatchCenter* Instance();
static void Release();

virtual int OnRecvedDevMsg(DeviceMsg devMsg, void* pParam);
virtual void RegStateSender(IStateSender* pSender);
virtual void RegStatesCollector(IStatesCollector* pCollector);

protected:
CDispatchCenter();
virtual ~CDispatchCenter();

void OnSocketMsg(_tagCommuCmd* pParam);
void DispatchMsg(DeviceMsg devMsg, void* pParam);

protected:
static CDispatchCenter* _instance;
IStateSender* _arrSender[Dev_Count];
list<IStatesCollector*> _lstCollector;
CRealTimeStates* _rts;

typedef list<IStateSender*>::iterator SenderIterator;
typedef list<IStatesCollector*>::iterator CollectorIterator;
};

enum MotorDeviceMsg
{
MDMsg_Nothing = -1,
MDMsg_AutoRun =0,
MDMsg_ManuRun,
MDMsg_Stop,
MDMsg_ArrivedStation,
MDMsg_IncSpeed,
MDMsg_DecSpeed,
MDMsg_TurningByAngle,
MDMsg_Count,
};

typedef struct _tagMotor_A2D_Msg //A2D: application to device
{
MotorDeviceMsg msg;
BOOL isStation;
MovedControl mc;
MotorStatues ms[M_Count];
} MotorMsgArg;

class CMotorProxy: public IStateSender
{
public:
CMotorProxy();
virtual ~CMotorProxy();

virtual BOOL InitSender();
virtual void OnReportState();
virtual void OnReportStateWithMsg(DeviceMsg devMsg, void* data);
virtual void RegStateCollector(IStatesCollector* pCollector);
virtual int ToDoWork(DeviceMsg devMsg, /*IN*/ void* data);
virtual DevType SenderType();

protected:
CMotor* _motor;
IStatesCollector* _collecter;

};

class CCmdProxy: public IStatesCollector
{
public:
static CCmdProxy* Instance();
static void Release();

void OnSocketMsg(INT nCmd, const char* data, int len);
virtual int OnRecvedDevMsg(DeviceMsg devMsg, void* pParam);
virtual void RegStateSender(IStateSender* pSender){}
virtual void RegStatesCollector(IStatesCollector* pCollecter);

protected:
CCmdProxy();
virtual ~CCmdProxy();

void AutoRunTask(const char* data, int len);
void ManualRunTask(const char* data, int len);
void PantiltTask(const char* data, int len);
void IOCtrlTask(const char* data, int len);
void CameraTask(const char* data, int len);
void AudioTask(const char* data, int len);
protected:
static CCmdProxy* _instance;
IStatesCollector* _dispCenter;
};
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list