This commit is contained in:
parent
ffa56c820d
commit
f7aa152393
|
@ -0,0 +1,33 @@
|
||||||
|
#include "UTPacket.h"
|
||||||
|
|
||||||
|
|
||||||
|
UTRet UTCom::DoFunc(Buffer & line, MemoryStream & ret)
|
||||||
|
{
|
||||||
|
return Good;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
byte PortID; // 端口号
|
||||||
|
byte Type; // 数据类型
|
||||||
|
ushort Length; // 数据长度
|
||||||
|
void * Next()const { return (void*)(&Length + Length + 1); };
|
||||||
|
}PacketHead;
|
||||||
|
|
||||||
|
|
||||||
|
bool UTPacket::PressTMsg(const BinaryPair& args, Stream& result)
|
||||||
|
{
|
||||||
|
byte data[2048];
|
||||||
|
Buffer buff(data,sizeof(data));
|
||||||
|
args.Get("Data", buff);
|
||||||
|
|
||||||
|
PacketHead * head = (PacketHead*)buff.GetBuffer();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
#ifndef __UTPacket_H__
|
||||||
|
#define __UTPacket_H__
|
||||||
|
|
||||||
|
#include "Sys.h"
|
||||||
|
#include "TokenNet\TokenMessage.h"
|
||||||
|
#include "Message\BinaryPair.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum UTRet :int
|
||||||
|
{
|
||||||
|
Good = 1,
|
||||||
|
CmdError = 2,
|
||||||
|
PortError =3,
|
||||||
|
NoPort = 4,
|
||||||
|
Error = -1,
|
||||||
|
};
|
||||||
|
|
||||||
|
// unvarnished transmission 透传端口基类
|
||||||
|
class UTPort
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
String * Name; // 传输口名称
|
||||||
|
byte ID;
|
||||||
|
virtual UTRet DoFunc(Buffer & line, MemoryStream & ret) = 0; // line 为输入命令,ret为返回值。
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
// 放到其他地方去 不要放在此处。
|
||||||
|
class UTCom:public UTPort
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// SerialPort * Port;
|
||||||
|
virtual UTRet DoFunc(Buffer & line, MemoryStream & ret);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// unvarnished transmission 透传报文
|
||||||
|
class UTPacket
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// List<UTPort*> Ports; // 透传传输口集合
|
||||||
|
|
||||||
|
|
||||||
|
bool PressTMsg(const BinaryPair& args, Stream& result);
|
||||||
|
// Client.Register("UTPacket",&UTPacket::PressTMsg,this);
|
||||||
|
|
||||||
|
//UTPort * CreateUTPort(byte portid);
|
||||||
|
|
||||||
|
virtual void Show() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue