123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- // CcosFileHandle.h
- #pragma once
- #define CCOSFILEHANDLE_API
- #define CCOSFILEHANDLE_C_API extern "C"
- #include <string>
- #include <cstdint> // 添加标准整数类型头文件
- #include "Definitions.h"
- #include "ResDataObject.h"
- using namespace std;
- // 命令响应枚举
- typedef enum _Cmd_Echo {
- CMD_ECHO_IGNORE = -1,
- CMD_ECHO_NOTARGET,
- CMD_ECHO_NG,
- CMD_ECHO_OK,
- CMD_ECHO_MAX
- }CMD_ECHO;
- // 数据包命令枚举
- #ifndef _Packet_Cmd
- typedef enum _Packet_Cmd {
- PACKET_CMD_NONE = -1,
- PACKET_CMD_OPEN,
- PACKET_CMD_CLOSE,
- PACKET_CMD_GET,
- PACKET_CMD_UPDATE,//更新对象
- PACKET_CMD_ADD,
- PACKET_CMD_DEL,
- PACKET_CMD_EXE,
- PACKET_CMD_DATA,
- PACKET_CMD_MSG,
- PACKET_CMD_ONLINE,//设备掉线后重新注册到Root
- PACKET_CMD_PART_UPDATE,//只更新对象的子节点
- PACKET_CMD_SET,
- PACKET_CMD_MAX
- }PACKET_CMD;
- #endif
- // 数据包命令字符串表示
- const string _Packet_Cmd_String[] = {
- "Open",
- "Close",
- "Get",
- "Update",
- "Add",
- "Del",
- "Action",
- "Data",
- "Message",
- "Online",
- "PartUpdate",
- "Set"
- };
- // 数据包类型枚举
- typedef enum _Packet_Type {
- PACKET_TYPE_NONE = -1,
- PACKET_TYPE_REQ,
- PACKET_TYPE_RES,
- PACKET_TYPE_NOTIFY,
- PACKET_TYPE_MAX
- }PACKET_TYPE;
- // 文件标志位枚举
- typedef enum _Ccos_File_Flags {
- IMAGE_FH = 1,
- ACTION = 2,
- NOTIFY_MSG = 4,
- NOTIFY_UPDATE = 8,
- NOTIFY_DATA = 16,
- NOTIFY_ACTION = 32,
- ALL_ACCESS = 64 - 1,
- ABSCRACT_ONLINE = 128
- }CCOS_FILE_FLAGS;
- // 操作同步模式枚举
- typedef enum _Action_Sync_Mode {
- ACTION_SYNC,
- ACTION_ASYNC,
- }ACTION_SYNC_MODE;
- // 数据包相关宏定义
- #define CCOS_PACK_IDX ("IDX")
- #define CCOS_PACK_TYPE ("TYPE")
- #define CCOS_PACK_TYPE_REQ ("REQUEST")
- #define CCOS_PACK_TYPE_RES ("RESPONSE")
- #define CCOS_PACK_TYPE_NOTIFY ("NOTIFY")
- #define CCOS_PACK_CMD ("CMD")
- #define CCOS_PACKET_SYNC ("SYNC")
- #define CCOS_PACK_HANDLE ("HANDLE")
- #define CCOS_PACK_HANDLE_ROUTE ("ROUTE")
- #define CCOS_PACK_HANDLE_FLAGS ("FLAGS")
- #define CCOS_PACK_HANDLE_LANG ("LANG")
- #define CCOS_PACKET_HANDLE_KEY ("HANDLEID")
- #define CCOS_PACK_HANDLE_OWNERID ("OWNERID")
- #define CCOS_PACK_HANDLE_DEVID ("DEVID")
- #define CCOS_PACK_TARGET_BUSID ("EBUSID")
- #define CCOS_PACK_TARGET_MACHINEID ("MACHINEID")
- #define CCOS_PACK_TARGET_PROCID ("PROCID")
- #define CCOS_PACK_TARGET_ADDR ("ADDR")
- #define CCOS_PACK_KEY ("KEY")
- #define CCOS_PACK_ACTION ("Action")
- #define CCOS_PACK_CONTEXT ("CONTEXT")
- #define CCOS_PACK_RETURN ("RET")
- #define CCOS_PACK_CODE ("CODE")
- #define CCOS_PACK_MSG ("MSG")
- #define CCOS_PACKET_VER ("Ver")
- #define CCOS_PACKET_VER_NOW ("3")
- #define CCOS_TOPIC ("TOPIC")
- #define CCOS_PUBLISH ("PUBLISH")
- #define CCOS_RESP_TOPIC ("RespTopic")
- #define CCOS_TRANSACTION ("Transaction")
- #define CCOS_CLIENT_ROOT_TOPIC ("CCOS/CLIENT/PLATFORM")
- #define CCOS_CLIENT_ID_PREFIX ("CCOS_CLIENT_")
- // 数据包路由方向枚举
- // any: 先发往本地,如果本地无目的地,再次发往Eth
- // Local: 仅本地
- // Eth: 仅远程机器
- typedef enum _Ccos_Packet_Route {
- CCOS_PACKET_ROUTE_NOTARGET = -1,//无法发送
- CCOS_PACKET_ROUTE_ANY,//任何可能的方向
- CCOS_PACKET_ROUTE_LOCAL,//仅本地机器
- CCOS_PACKET_ROUTE_ETH,//仅远程机器
- CCOS_PACKET_ROUTE_MAX
- }CCOS_PACKET_ROUTE;
- // 目标地址类
- class CCOSFILEHANDLE_API CcosTargetAddress {
- string* m_pKey;
- string* m_ValString;
- ResDataObject* m_pTargetObject;
- public:
- CcosTargetAddress(void);
- CcosTargetAddress(const CcosTargetAddress& tValue);
- virtual ~CcosTargetAddress(void);
- virtual const char* GetVal();
- bool operator ==(const CcosTargetAddress& target);
- CcosTargetAddress& operator = (const CcosTargetAddress& tValue);
- void GetResDataObject(ResDataObject& obj);
- bool SetResDataObject(ResDataObject& obj);
- virtual bool SetVal(const char* pValString);
- void SetKey(const char* pKey);
- const char* GetKey();
- ResDataObject& operator [](const char* pKey);
- void PrintOut();//测试用
- };
- // 设备文件句柄类
- class CCOSFILEHANDLE_API CcosDevFileHandle {
- string* m_pKey;
- string* m_ValString;
- ResDataObject* m_pRoute;//0:any,1:local,2:eth
- ResDataObject* m_pFlags;
- ResDataObject* m_pLang;
- ResDataObject* m_pHandleId;
- CcosTargetAddress* m_pOwner;
- CcosTargetAddress* m_pDev;
- public:
- CcosDevFileHandle(void);
- CcosDevFileHandle(const CcosDevFileHandle& tValue);
- virtual ~CcosDevFileHandle(void);
- void SetKey(const char* pKey);
- const char* GetKey();
- void GetResDataObject(ResDataObject& obj);
- bool SetResDataObject(ResDataObject& obj);
- virtual const char* GetVal();
- virtual bool SetVal(const char* pValString);
- CcosTargetAddress& GetTarget(bool Owner = true);
- CcosDevFileHandle& operator = (const CcosDevFileHandle& tValue);
- ResDataObject& operator [](const char* pKey);
- bool operator ==(const CcosDevFileHandle& target);
- void PrintOut();//测试用
- };
|