📄 locmsgdef.h
字号:
//**************************************************************************
//
//
//**************************************************************************
//
// Filename : Msghdler.h
//
// Subsystem :
//
// Description: Protocol message handlers.
//
//**************************************************************************
#ifndef __MSGHDLER_H__
#define __MSGHDLER_H__
// protocol handle function definition
//
// RTU I/O module and point table for AEC device
// =============================================
// AI 0 - 5 (32 x 6) ; analog input
// PA 6 - 6 (32 x 1) ; pulse accumulator
// VW 7 - 10 (32 x 4) ; system parameters
// AO 11 - 11 (32 x 1) ; analog output
// DI 12 - 21 (32 x 10) ; digital input
// DO 22 - 25 (32 x 4) ; digital output
// DO 26 - 28 (32 x 3) ; device reset
// DO 29 - 31 (32 x 3) ; control word
#define AINORMSLOT 0
#define PANORMSLOT 6
#define VWNORMSLOT 7
#define AONORMSLOT 11
#define DINORMSLOT 12
#define DIPROTSLOT 16
#define DONORMSLOT 22
#define DORESTSLOT 26
#define DOPARMSLOT 29
#define PNTGRPMAX 32
#define DIPROOFFSET 17
#define DIGDATBYT 4
#define ANADATNUM 40
#define SOEDATNUM 15
#define DOONVALUE 0xff
#define RESETVALUE 0x0100
#define CHINVALUE 0x0000
#define ENGIVALUE 0x0100
#define SP2400VAL 0x0100
#define SP4800VAL 0x0200
#define SP9600VAL 0x0300
#define SETWORDORG 100
#define PRMWORDORG 200
#define CTLWORDORG 300
#define CTLWORDON 0x55
#define CTLWORDOFF 0xaa
#define CURRRATIO 1450
#define ZCURRATIO 14400
#define VOLTRATIO 1380
#define FREQRATIO 1666666.66f
// relay control command type, SAME define as in relay database
#define RLY_VALQRY 1 /* relay set value query command */
#define RLY_VALCHG 2 /* relay working set exchange command */
#define RLY_CONQRY 3 /* relay out connection query command */
#define RLY_RECCLR 4 /* relay record data clean command */
#define RLY_RECLST 5 /* relay record list fetch command */
#define RLY_RECGET 6 /* relay record data fetch command */
#define RLY_VALSET 7 /* relay set value change command */
#define RLY_CONSET 8 /* relay set value change command */
#define RLY_DEVRST 9 /* relay device reset command */
#define RLY_PAINIT 10 /* relay pa value init command */
#define RLY_UI0GET 11 /* relay 3U0 and 3I0 fetch command */
/*
* AEC controller polling commands
*/
#define M_EXCP 0x7F /* modbus exception response mask */
#define FUNC_2 2 /* read DI input status */
#define FUNC_3 3 /* read holding register(s) */
#define FUNC_5 5 /* write single coil */
#define FUNC_6 6 /* preset single output register */
#define FUNC_12 0x0C /* read DI SOE message */
#define FUNC_16 0x10 /* preset time sync */
#define COIL_ON 0xFF00 /* turn COIL on function */
#define COIL_OFF 0 /* turn COIL off function */
#define HR_MAX 4096 /* max num of register from one read*/
#define MODMXVAL 65536 /* max register number for PLC */
/* (psuedo) usefull macros */
#define byte_swap(value) (((value)>>8)|((value)<<8))
/* function 2 - read DI Input status */
typedef struct modbus_f2
{
unsigned char addr; /* slave address */
unsigned char func; /* function code - 2 */
unsigned short int reg; /* starting register */
unsigned short int num; /* number of points */
unsigned short int crc; /* Modbus CRC-16 */
} F2CMD;
#define MODBUS_F2_SIZ 8 /* func 2 size */
typedef struct modbus_f2_reply
{
unsigned char addr; /* slave address */
unsigned char func; /* function code - 2 */
unsigned short int num; /* # 8 bit packed bytes */
unsigned char pts[DIGDATBYT]; /* points */
unsigned short int crc; /* Modbus CRC-16 */
} F2RSP;
#define MODBUS_F2_REPLY_SIZ (DIGDATBYT + 6) /* func 2 reply size */
/* function 3 - read holding register */
typedef struct modbus_f3
{
unsigned char addr; /* slave address */
unsigned char func; /* function code - 3 */
unsigned short int reg; /* starting register */
unsigned short int num; /* number of registers */
unsigned short int crc; /* Modbus CRC-16 */
} F3CMD;
#define MODBUS_F3_SIZ 8 /* func 3 size */
typedef struct modbus_f3_reply
{
unsigned char addr; /* slave address */
unsigned char func; /* function code - 3 */
unsigned short int num; /* #registers * 2 */
unsigned short int reg[ANADATNUM]; /* registers */
unsigned short int crc; /* Modbus CRC-16 */
} F3RSP;
#define MODBUS_F3_REPLY_SIZ (ANADATNUM * 2 + 6) /* func 3 reply size */
/* function 5 - write single coil */
typedef struct modbus_f5 {
unsigned char addr; /* slave address */
unsigned char func; /* function code - 5 */
unsigned short int coil; /* coil number */
unsigned short int num; /* number of registers */
unsigned char value; /* coil code (FF = ON) */
unsigned short int crc; /* crc-16 */
} F5CMD;
#define MODBUS_F5_SIZ 9 /* func 5 size */
typedef struct modbus_f5_reply {
unsigned char addr; /* slave address */
unsigned char func; /* function code - 5 */
unsigned short int coil; /* coil number */
unsigned short int num; /* number of registers */
unsigned short int crc; /* crc-16 */
} F5RSP;
#define MODBUS_F5_REPLY_SIZ 8 /* func 5 reply size */
/* function 6 - preset parameters register */
typedef struct modbus_f6 {
unsigned char addr; /* slave address */
unsigned char func; /* function code - 6 */
unsigned short int reg; /* register number */
unsigned short int len; /* register length */
unsigned char val[1]; /* register value */
unsigned short int crc; /* crc-16 */
} F6CMD;
#define MODBUS_F6_SIZ 9 /* func 6 size */
typedef struct modbus_f6_reply {
unsigned char addr; /* slave address */
unsigned char func; /* function code - 6 */
unsigned short int reg; /* register number */
unsigned short int len; /* register length */
unsigned short int crc; /* crc-16 */
} F6RSP;
#define MODBUS_F6_REPLY_SIZ 8 /* func 6 reply size */
/* function 12 - read slave soe message */
typedef struct modbus_f12 {
unsigned char addr; /* slave address */
unsigned char func; /* function code - 12 */
unsigned short int reg; // starting register
unsigned short int num; // number of registers set
unsigned short int crc;
} F12CMD;
#define MODBUS_F12_SIZ 8 /* func 12 size */
typedef struct modbus_f12_reply {
unsigned char addr; /* slave address */
unsigned char func; /* function code - 12 */
unsigned short int num; /* # data bytes */
unsigned char ms[2]; /* ms number, BCD */
unsigned char sec; /* seconds, BCD */
unsigned char min; /* minutes, BCD */
unsigned char hour; /* hours, BCD */
unsigned char day; /* days, BCD */
unsigned char mon; /* monthes, BCD */
unsigned char year; /* years, BCD */
unsigned char type; /* 1: di, 2: relay */
unsigned char idx; /* record index */
unsigned char state[4]; /* state */
unsigned char attr; /* attribute */
unsigned short int crc; /* crc-16 */
} F12RSP;
#define MODBUS_F12_REPLY_SIZ 21 /* func 12 reply size */
typedef struct modbus_f12_no_reply {
unsigned char addr; /* slave address */
unsigned char func; /* function code - 12 */
unsigned short int num; /* # data bytes */
unsigned short int crc; /* crc-16 */
} F12NORSP;
#define MODBUS_F12_NO_REPLY_SIZ 6 /* func 12 null reply size */
/* function 16 - preset slave time sync */
typedef struct modbus_f16 {
unsigned char addr; /* slave address */
unsigned char func; /* function code - 6 */
unsigned short int reg; /* register number */
unsigned short int len; /* register length */
unsigned char tim[6]; /* date/time */
unsigned short int crc; /* crc-16 */
} F16CMD;
#define MODBUS_F16_SIZ 14
typedef struct modbus_f16_reply {
unsigned char addr;
unsigned char func;
unsigned short int reg; // starting register
unsigned short int num; // number of registers set
unsigned short int crc;
} F16RSP;
#define MODBUS_F16_REPLY_SIZ 8
static char const *evtstr[10] = {
"电流 =", "电压 =", "频率 =", "零序电流 =", "零序电压 =",
"正序电流 =", "负序电流 =", "温度 =", "横差 =", "功率 ="
};
// AEC device type
#define AECRTUTYPE 650
#endif /* __MSGHDLER_H__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -