| | |
| | | Output_Set_1 = 2,
|
| | | };
|
| | |
|
| | | enum enPortType
|
| | | enum enPortHardType
|
| | | {
|
| | | PortType_Com = 0, //¼ÆËã»úͨѶ
|
| | | PortType_Gen = 1, //ͨÓÃͨѶ£¬×ÔÓÉ¿Ú
|
| | | PortType_KLink = 2, //KlinkͨѶ
|
| | | PortType_KBus = 3, //KBusͨѶ
|
| | | PortType_KNet = 4, // KNetͨѶ
|
| | | PortType_ModbusRTU = 5, //Modbus RTU ͨѶ
|
| | | PortHardType_None = 0, // 空接口,无类型
|
| | | PortHardType_SOFT = 1, // 软件虚拟接口,可能是隧道等.
|
| | | PortHardType_UART = 2, // 串行接口
|
| | | PortHardType_RS232 = 3, // 232接口
|
| | | PortHardType_RS485 = 4, // 485接口
|
| | | PortHardType_SLP = 5, // 单总线接口
|
| | | PortHardType_RF = 6, // 无线接口
|
| | | PortHardType_LORA = 7, // LoRa无线接口
|
| | | PortHardType_OPTI = 8, // 光纤接口
|
| | | PortHardType_ETH = 9, // 以太网接口
|
| | | PortHardType_WIFI = 10, // WiFi接口
|
| | | PortHardType_BT = 11, // 以太网接口
|
| | |
|
| | | };
|
| | | static CString PortHardTypeToStr(int nPortHardType)
|
| | | {
|
| | | static CString s1;
|
| | | switch (nPortHardType)
|
| | | {
|
| | | case PortHardType_None:
|
| | | return _T("NULL");
|
| | | case PortHardType_SOFT: // = 1, // 软件虚拟接口,可能是隧道等.
|
| | | return _T("Soft");
|
| | | case PortHardType_UART: // = 2, // 串行接口
|
| | | return _T("UART");
|
| | | case PortHardType_RS232: //= 3, // 232接口
|
| | | return _T("RS232");
|
| | | case PortHardType_RS485: //= 4, // 485接口
|
| | | return _T("RS485");
|
| | | case PortHardType_SLP: //= 5, // 单总线接口
|
| | | return _T("SLP");
|
| | | case PortHardType_RF: //= 6, // 无线接口
|
| | | return _T("RF");
|
| | | case PortHardType_LORA: //= 7, // LoRa无线接口
|
| | | return _T("LoRa");
|
| | | case PortHardType_OPTI: //= 8, // 光纤接口
|
| | | return _T("Opti");
|
| | | case PortHardType_ETH: //= 9, // 以太网接口
|
| | | return _T("ETH");
|
| | | case PortHardType_WIFI: //= 10, // WiFi接口
|
| | | return _T("WiFi");
|
| | | case PortHardType_BT: //= 11, // 以太网接口 |
| | | return _T("BT");
|
| | | default:
|
| | | return _T("UNKNOWN");
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | enum enPortUseType
|
| | | {
|
| | | PortUse_Default = 0, //默认
|
| | | PortUse_Console = 1, //控制台接口
|
| | | PortUse_KLink = 2, //KLink通讯
|
| | | PortUse_KBus = 3, //KBus通讯
|
| | | PortUse_KNet = 4, // KNet通讯
|
| | | PortUse_SLP = 5, // SLP单总线
|
| | | PortUse_KRF = 6, // 无线通讯
|
| | | PortUse_ModbusRTU = 7, //Modbus RTU 通讯
|
| | | PortUse_ModbusTCP = 8, //Modbus TCP 通讯
|
| | | PortUse_Com = 9, // 计算机通讯
|
| | | PortUse_Gen = 10, //通用通讯,自由口
|
| | | };
|
| | |
|
| | | static CString PortUseTypeToStr(int nPortHardType)
|
| | | {
|
| | | static CString s1;
|
| | | switch (nPortHardType)
|
| | | {
|
| | | case PortUse_Default: // = 0 默认
|
| | | return _T("NULL");
|
| | | case PortUse_Console: // = 1, //控制台接口
|
| | | return _T("终端");
|
| | | case PortUse_KLink: // = 2, //KLink通讯
|
| | | return _T("KLink");
|
| | | case PortUse_KBus: //= 3, // KNet通讯
|
| | | return _T("KBus");
|
| | | case PortUse_KNet: //= 4, // 串行接口
|
| | | return _T("KNet");
|
| | | case PortHardType_SLP: //= 5, // SLP单总线
|
| | | return _T("KSLP");
|
| | | case PortUse_KRF: //= 6, // 无线通讯
|
| | | return _T("KwRF");
|
| | | case PortUse_ModbusRTU: //= 7, // Modbus RTU 通讯
|
| | | return _T("ModbusRTU");
|
| | | case PortUse_ModbusTCP: //= 8, // Modbus TCP 通讯
|
| | | return _T("ModbusTCP");
|
| | | case PortUse_Com: //= 9, // 计算机通讯
|
| | | return _T("");
|
| | | case PortUse_Gen: //= 10, // 通用通讯,自由口
|
| | | return _T("WiFi");
|
| | | default:
|
| | | return _T("UNKNOWN");
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | enum enServiceReqs
|
| | | {
|
| | | ReqNone,
|
| | | ReqInit,
|
| | | ReqReset,
|
| | | ReqStop,
|
| | | ReqRun,
|
| | | ReqBlinkLED,
|
| | | ReqStartDiag,
|
| | | ReqStopDiag,
|
| | | ReqPortChildInfo,
|
| | | ReqPortChnInfo,
|
| | | ReqUpdateFirm,
|
| | | ReqUpdateFirmInfo,
|
| | |
|
| | | ReqTransFirmware,
|
| | | ReqTransCfg,
|
| | | ReqTransProg,
|
| | | ReqTransData,
|
| | | ReqTransBlink,
|
| | | ReqTransChild,
|
| | | ReqTransInfo,
|
| | | ReqTransOutBandData,
|
| | | ReqRead1Bit,
|
| | | ReqWrite1Bit,
|
| | | ReqReadBits,
|
| | | ReqWriteBits,
|
| | | ReqReadData,
|
| | | ReqWriteData,
|
| | | ReqRemoteTran,
|
| | | };
|
| | |
|
| | | typedef struct tagPortAbility
|
| | | {
|
| | | USHORT ChildList : 1;
|
| | | USHORT AccessChild : 1;
|
| | | USHORT TranProg : 1;
|
| | | USHORT TranCfg : 1;
|
| | | USHORT Diag : 1;
|
| | | USHORT TranOutBandData : 1;
|
| | | USHORT Tunnel : 1;
|
| | | USHORT TranFirmware : 1;
|
| | | USHORT TranBlink : 1;
|
| | | }stPortAbility;
|
| | |
|
| | | // 各端口 互联 通信
|
| | | typedef int (*CommFuncDef)(int ReqId, int nParam, void* pData, int len1);
|
| | | typedef struct tagPortDef
|
| | | {
|
| | | union {
|
| | | USHORT nPortType;
|
| | | struct {
|
| | | UCHAR nPortHardType;
|
| | | UCHAR nPortUseType;
|
| | | };
|
| | | };
|
| | | USHORT ability; //能力, 获取子机信息等。
|
| | | UCHAR bEnable;
|
| | | UCHAR bRunning;
|
| | | UCHAR StationId;
|
| | | UCHAR bMaster;
|
| | | UCHAR nMaxStations;
|
| | | UCHAR nCurStations;
|
| | | UCHAR nHealth;
|
| | | short PortConfigType;
|
| | | short PortConfigSize;
|
| | | short PortRunStatType;
|
| | | short PortRunStatSize;
|
| | |
|
| | | // CommFuncDef ReqCommFunc;
|
| | | // func2 CommReq;
|
| | |
|
| | | }stPortDef, * pstPortDef;
|
| | |
|
| | | enum enKeventType
|
| | | {
|
| | |
| | | EventTypeProg = 8,
|
| | | EventTypeForce = 9,
|
| | | EventTypeClearEvent = 10,
|
| | |
|
| | |
|
| | | EventType
|
| | | };
|
| | |
|
| | | typedef struct tagDevPortDef
|
| | | {
|
| | | union {
|
| | | USHORT nPortType;
|
| | | struct {
|
| | | UCHAR nPortHardType;
|
| | | UCHAR nPortUseType;
|
| | | };
|
| | | };
|
| | | UCHAR bEnabled;
|
| | | UCHAR bRunning;
|
| | | UCHAR StationID;
|
| | | UCHAR bMaster;
|
| | | UCHAR MaxStations;
|
| | | UCHAR CurStations;
|
| | | UCHAR Health;
|
| | |
|
| | | }stDevPortDef;
|
| | |
|
| | | typedef struct tagDeviceDef
|
| | | {
|
| | | USHORT nDeviceTypeVer;
|
| | | USHORT nProgVer;
|
| | | UCHAR InBitCount;
|
| | | UCHAR OutBitCount;
|
| | | unsigned short nPortCount;
|
| | | stDevPortDef Ports[8]; //最多8个通讯端口
|
| | | }stDeviceDef;
|
| | |
|
| | | typedef struct tagDeviceInfo // KBus 子机基本信息 |
| | | {
|
| | | unsigned short DeviceType; // 子机类型
|
| | | union {
|
| | | unsigned short DeviceVer; // 子机版本
|
| | | struct {
|
| | | unsigned char DeviceVerMinor;
|
| | | unsigned char DeviceVerMajor;
|
| | | };
|
| | | };
|
| | | unsigned char InBitCount; // 输入开关量数量
|
| | | unsigned char OutBitCount; // 输出开关量数量
|
| | | unsigned char ExInBitCount; // 扩展的输入开关量数量
|
| | | unsigned char ExOutBitCount; // 扩展的输出开关量数量
|
| | | unsigned char DWStartAddr; // 输出数据字数
|
| | | unsigned char OutDWCount; // 输出数据字数
|
| | | unsigned char AIWCount; // 输入模拟量通道(字)数 // 16位为一个字(通道)
|
| | | unsigned char AQWCount; // 输出模拟量通道(字)数 // 16位为一个字(通道)
|
| | | // unsigned char AIBits; // 每通道位数 // 16位以下
|
| | | // unsigned char AQbits; // 每通道位数 // 16位以下
|
| | |
|
| | |
|
| | | }stDeviceInfo;
|
| | |
|
| | | typedef struct tagInfoBlock // 20 bytes
|
| | | {
|
| | | // USHORT nBlockLenth;
|
| | | USHORT nDeviceTypeVer; //device type x.y
|
| | | // UCHAR nDevierVer;
|
| | | union {
|
| | | USHORT nProgVer; //prog version x.y
|
| | | struct {
|
| | | UCHAR nProgVerMinor;
|
| | | UCHAR nProgVerMajor;
|
| | | };
|
| | | };
|
| | |
|
| | | USHORT nKLinkVer; //x.y
|
| | | USHORT nKBusVer; //x.y
|
| | | // USHORT nKNetVer; //x.y
|
| | |
| | |
|
| | | }stFactoryData, *pFactoryData;
|
| | |
|
| | | typedef struct tagNewAppInfoBlock
|
| | | {
|
| | | unsigned short Sign;
|
| | | unsigned short Version;
|
| | | unsigned int Length;
|
| | | unsigned int nCRC;
|
| | |
|
| | | }stNewAppInfoBlock, * pNewAppInfoBlock;
|
| | |
|
| | | typedef struct tagKMFuncParam
|
| | | {
|
| | |
| | | BYTE Hold2 : 4;
|
| | | }stOutputHoldParam;
|
| | | // 硬件描述文件
|
| | | typedef struct tagOutMapping
|
| | | {
|
| | | USHORT bitPos : 4;
|
| | | USHORT byteAddr : 8;
|
| | | USHORT type : 4;
|
| | | }stOutMapping;
|
| | |
|
| | | typedef struct tagCfgBlockInfo
|
| | | {
|
| | | UCHAR nBlockType;
|
| | | UCHAR nBlockSize;
|
| | | }stCfgBlockInfo;
|
| | |
|
| | | //#pragma pack(2)
|
| | |
|
| | | typedef struct tagKMSysCfg //120 Bytes total
|
| | | {
|
| | | USHORT Version; // SC0 // 2 Bytes
|
| | | USHORT workmode; // SC1 // 2 Bytes 0=From jumper
|
| | | USHORT SwitchFunc; // SC2 // 2 Bytes
|
| | | USHORT Space1; // 2 bytes
|
| | | USHORT nCfgBlockCount; // 2 Bytes
|
| | |
|
| | | stComPortParam PortParams[2]; // 28 Bytes
|
| | | stInputFilterParam InputParams[16]; //8 Bytes
|
| | | stComPortParam PortParams[2]; // 8 Bytes
|
| | | stInputFilterParam InputParams[16]; //16 Bytes
|
| | | stOutputHoldParam OutputParams[16]; //16 Bytes
|
| | | USHORT OutMappings[6]; //12 Bytes //输出映射
|
| | |
|
| | | UINT Space2[12]; //48 bytes
|
| | | union {
|
| | | USHORT value; //12 Bytes //输出映射
|
| | | struct {
|
| | | USHORT bitPos : 4;
|
| | | USHORT byteAddr : 8;
|
| | | USHORT type : 4;
|
| | | };
|
| | | }OutMappings[8];
|
| | |
|
| | | }stKMSysCfg, *pKMSysCfg;
|
| | | USHORT nProgBank;
|
| | | USHORT nProgSize;
|
| | | USHORT nAnnoSize;
|
| | | USHORT nCount;
|
| | |
|
| | | stCfgBlockInfo CfgBlockInfos[8];
|
| | | UINT cfgvar8; // 4 Bytes
|
| | | UINT cfgvar9; // 4 Bytes
|
| | | UINT cfgvar10; // 4 Bytes
|
| | | // UINT cfgvar11; // 4 Bytes
|
| | | // UINT cfgvar12; // 4 Bytes
|
| | | // UINT cfgvar13; // 4 Bytes
|
| | | // UINT cfgvar14; // 4 Bytes
|
| | | // UINT cfgvar15; // 4 Bytes
|
| | | // UINT cfgvar16; // 4 Bytes
|
| | | // UINT Space1[4]; //16 Bytes
|
| | |
|
| | | }stKMSysCfg, * pstKMSysCfg;
|
| | |
|
| | | typedef struct tagStoredKMSysCfg
|
| | | {
|
| | | unsigned short Sign1;
|
| | | unsigned short Seq1;
|
| | | stKMSysCfg theKMSysCfg;
|
| | | unsigned short CRC1;
|
| | | unsigned short EndSign1;
|
| | | }stStoredKMSysCfg, * pStoredKMSysCfg;
|
| | |
|
| | |
|
| | | typedef struct tagTimer
|
| | |
| | | OP_TMR = 0xDC, //
|
| | | OP_TMX = 0xDD, //
|
| | | OP_TMY = 0xFA, //
|
| | |
|
| | | OP_END = 0xFF,
|
| | | };
|
| | |
|
| | | typedef struct stBinProg1
|