1414 lines
42 KiB
C++
1414 lines
42 KiB
C++
#ifndef _ZJD_PUBLIC_DATA_H_
|
||
#define _ZJD_PUBLIC_DATA_H_
|
||
|
||
const char VERSION_NO[] = "1.3.0001";
|
||
|
||
#include "zjdtypes.h"
|
||
#include "config.h"
|
||
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
#include <string.h>
|
||
#include <ctype.h>
|
||
#include <time.h>
|
||
#include <assert.h>
|
||
#include <stdarg.h>
|
||
#include <sys/timeb.h>
|
||
#include <cstring>
|
||
|
||
#ifdef WIN32
|
||
#include "pthread.h"
|
||
#include <WinSock2.h>
|
||
#include <WS2tcpip.h>
|
||
|
||
typedef char optval_t;
|
||
typedef int socklen_t;
|
||
|
||
#define msleep(msec) Sleep(msec)
|
||
#define sleep(sec) Sleep(sec * 1000)
|
||
|
||
void usleep(unsigned long usec);
|
||
int close(SOCKET s);
|
||
int ioctl(SOCKET s, long cmd, u_long FAR* argp);
|
||
int gettimeofday(struct timeval *tp, struct timezone *tz);
|
||
int settimeofday(struct timeval *tp, struct timezone *tz);
|
||
struct tm *localtime_r(long *close, struct tm *res);
|
||
#else
|
||
#include <errno.h>
|
||
#include <error.h>
|
||
#include <unistd.h>
|
||
#include <fcntl.h>
|
||
#include <termios.h>
|
||
#include <pthread.h>
|
||
#include <sys/time.h>
|
||
#include <sys/times.h>
|
||
#include <sys/types.h>
|
||
#include <sys/stat.h>
|
||
#include <sys/socket.h>
|
||
#include <sys/ioctl.h>
|
||
#include <sys/select.h>
|
||
#include <linux/rtc.h>
|
||
#include <netinet/in.h>
|
||
#include <arpa/inet.h>
|
||
#include <linux/kd.h>
|
||
#include <net/if.h>
|
||
#include <netdb.h>
|
||
#include <sys/syscall.h>
|
||
#if 0
|
||
#include "threadpool.h"
|
||
#define THREADPOOL_MAX_NUM 68
|
||
#endif
|
||
typedef int optval_t;
|
||
typedef int SOCKET;
|
||
#endif //WIN32
|
||
#include <string>
|
||
#include <vector>
|
||
#include <sys/stat.h>
|
||
#include "zlog/zlog.h"
|
||
|
||
#define MEMERY_1M 65536 //设置位64K
|
||
#define DELAY_RUN 5000
|
||
#define DELAY_TIMER 50 //ms
|
||
#define TIME_BASE (1000 / DELAY_TIMER)
|
||
#define TIME_TICKS (DELAY_TIMER * 1000)
|
||
#define MAX_PATH 260
|
||
|
||
#if !defined(UNUSED)
|
||
#define UNUSED(A) (void)(A)
|
||
#endif
|
||
|
||
#ifndef SOCKET_ERROR
|
||
#define SOCKET_ERROR -1
|
||
#endif
|
||
#ifndef INVALID_SOCKET
|
||
#define INVALID_SOCKET -1
|
||
#endif
|
||
|
||
#define MAX_UNIT_ADDR_SIZE 256 /*最大单元地址长度*/
|
||
#define MAX_UNIT_POINT_PARAM_SIZE 64 /*最大测点参数长度*/
|
||
#define MAX_UNIT_PARAM_SIZE 256 /*最大单元参数长度*/
|
||
#define MAX_PROC_OPTION_SIZE 2048 /*最大协议参数长度*/
|
||
#define MAX_NAME_SIZE 64
|
||
#define MAX_MODEL_SIZE 64
|
||
#define MAX_PSW_SIZE 64
|
||
#define MAX_ID_LENGTH 64
|
||
|
||
#define MAX_PORT_BUFFER_SIZE 2048
|
||
#define MAX_NET_BUFFER_SIZE 4096
|
||
#define MAX_DISPLAY_BUFFER_SIZE 0x8000
|
||
|
||
#define HARDWARE_PORTS_NUM 20
|
||
#define PROCESSES_NUM 64
|
||
#define PROCESS_UNIT_NUM 256
|
||
#define UNIT_NUM 256
|
||
#define UNIT_YX_MAX 0x1500
|
||
#define UNIT_YC_MAX 0x2000
|
||
#define UNIT_YM_MAX 0xB00
|
||
#define UNIT_YK_MAX 0x100
|
||
#define UNIT_YT_MAX 0x100
|
||
#define DATABASE_YX_NUM 0x80000
|
||
#define DATABASE_YC_NUM 0xA0000
|
||
#define DATABASE_YM_NUM 0x40000
|
||
#define DATABASE_YK_NUM 0x5000
|
||
#define DATABASE_YT_NUM 0x5000
|
||
#define DATABASE_YXBW_NUM 0x20000
|
||
#define DATABASE_SOE_NUM 0x20000
|
||
#define DATABASE_YCBW_NUM 0x20000
|
||
#define DATABASE_YK_LOG_NUM 1024
|
||
#define DATABASE_YT_LOG_NUM 1024
|
||
#define DATABASE_CTRL_LOG_NUM 1024
|
||
#define DATABASE_LIMIT_NUM 1024
|
||
#define PROCESS_WATCHDOG_TIME 90
|
||
#define UNIT_WATCHDOG_TIME 180
|
||
|
||
#define PROCESS_MODE_MASTER 0
|
||
#define PROCESS_MODE_SLAVE 1
|
||
#define PROCESS_MODE_DUPLEX 2
|
||
|
||
#if !defined(PARITY_NONE)
|
||
#define PARITY_NONE 0
|
||
#endif
|
||
|
||
#if !defined(PARITY_ODD)
|
||
#define PARITY_ODD 1
|
||
#endif
|
||
|
||
#if !defined(PARITY_EVEN)
|
||
#define PARITY_EVEN 2
|
||
#endif
|
||
|
||
#if !defined(PARITY_MARK)
|
||
#define PARITY_MARK 3
|
||
#endif
|
||
|
||
#if !defined(PARITY_SPACE)
|
||
#define PARITY_SPACE 4
|
||
#endif
|
||
|
||
#define DPI_ON 0x02
|
||
#define DPI_OFF 0x01
|
||
|
||
#define SPI_ON 0x01
|
||
#define SPI_OFF 0x00
|
||
|
||
#define US_NOUSE 0x00
|
||
#define US_OFFLINE 0x10
|
||
#define US_ONLINE 0x20
|
||
#define US_SLEEP 0x40
|
||
|
||
#define SLAVER_UNIT 0x00
|
||
#define MASTER_UNIT 0x01
|
||
|
||
#define VALID_VALUE 0
|
||
#define INVALID_VALUE 1
|
||
|
||
#define FILE_SYSTEM_CONFIG "system.zjd"
|
||
#define FILE_HARDWARE_CONFIG "hardware.zjd"
|
||
#define FILE_PROCESS_CONFIG "process.zjd"
|
||
#define FILE_UNIT_CONFIG "units.zjd"
|
||
#define FILE_NODE_CONFIG "node.zjd"
|
||
#define FILE_UNIT_YX_CONFIG "%s/uyx%03d.zjd"
|
||
#define FILE_UNIT_YC_CONFIG "%s/uyc%03d.zjd"
|
||
#define FILE_UNIT_YM_CONFIG "%s/uym%03d.zjd"
|
||
#define FILE_UNIT_YK_CONFIG "%s/uyk%03d.zjd"
|
||
#define FILE_UNIT_YT_CONFIG "%s/uyt%03d.zjd"
|
||
#define FILE_DATABASE_CONFIG "database.zjd"
|
||
#define FILE_CALC_YX_CONFIG "calcyx.zjd"
|
||
#define FILE_CALC_YC_CONFIG "calcyc.zjd"
|
||
#define FILE_FORMULA_CONFIG "formula.zjd"
|
||
#define FILE_UNIT_STATIC "units.sta"
|
||
#define FILE_UNIT_YX_STATIC "%s/uyx%03d.sta"
|
||
#define FILE_UNIT_YC_STATIC "%s/uyc%03d.sta"
|
||
#define FILE_UNIT_YM_STATIC "%s/uym%03d.sta"
|
||
#define FILE_UNIT_YK_STATIC "%s/uyk%03d.sta"
|
||
#define FILE_UNIT_YT_STATIC "%s/uyt%03d.sta"
|
||
#define FILE_DATABASE_YX_STATIC "dbyx.sta"
|
||
#define FILE_DATABASE_YC_STATIC "dbyc.sta"
|
||
#define FILE_DATABASE_YM_STATIC "dbym.sta"
|
||
#define FILE_DATABASE_YK_STATIC "dbyk.sta"
|
||
#define FILE_DATABASE_YT_STATIC "dbyt.sta"
|
||
#define FILE_YXBW_LOG "yxbw%02d_%02d.log"
|
||
#define FILE_SOE_LOG "soe%02d_%02d.log"
|
||
#define FILE_YCBW_LOG "ycbw%02d_%02d.log"
|
||
#define FILE_YK_LOG "yk%02d_%02d.log"
|
||
#define FILE_YT_LOG "yk%02d_%02d.log"
|
||
#define FILE_RUN_LOG "run%02d.log"
|
||
#define FILE_SYS_RUNLOG "SysRun.Log"
|
||
#define FILE_PASSWORD_DATA "zjd3100.pwd"
|
||
|
||
|
||
//通讯协议定义
|
||
#define PROTOCOL_NONE 0 //未使用
|
||
#define PROTOCOL_HOST_UNBALANCED_IEC101 1 //不平衡方式IEC101主
|
||
#define PROTOCOL_HOST_BALANCED_IEC101 2 //平衡方式IEC101主
|
||
#define PROTOCOL_SUB_UNBALANCED_IEC101 3 //不平衡方式IEC101从
|
||
#define PROTOCOL_SUB_BALANCED_IEC101 4 //平衡方式IEC101从
|
||
#define PROTOCOL_HOST_IEC104 8 //IEC104主
|
||
#define PROTOCOL_SUB_IEC104 9 //IEC104从
|
||
#define PROTOCOL_HOST_CDT 10 //CDT主
|
||
#define PROTOCOL_SUB_CDT 11 //CDT从
|
||
#define PROTOCOL_HOST_MODBUS_RTU 12 //MODBUS RTU主
|
||
#define PROTOCOL_SUB_MODBUS_RTU 13 //MODBUS RTU从
|
||
#define PROTOCOL_HOST_MODBUS_ASCII 14 //MODBUS ASCII主
|
||
#define PROTOCOL_HOST_MODBUS_TCP 16 //MODBUS tcp主
|
||
#define PROTOCOL_SUB_MODBUS_TCP 17 //MODBUS RTU over tcp从
|
||
#define PROTOCOL_HOST_MODBUS_RTU_TCP 18 //MODBUS RTU over tcp主
|
||
#define PROTOCOL_HOST_MODBUS_RTU_NCY 19 //NCY-6100系列微机保护装置MODBUS RTU主
|
||
#define PROTOCOL_HOST_MODBUS_RTU_LIYEZG 20 //浙江立业电器MODBUS RTU主
|
||
#define PROTOCOL_RTU_STATE 21 //主控状态
|
||
#define PROTOCOL_LOCAL_DEBUG 22 //本地调试
|
||
#define PROTOCOL_SUB_XT9712 23 //XT9712从
|
||
#define PROTOCOL_HISDATA 24 //历史数据协议
|
||
#define PROTOCOL_BF_FTP 25 //倍福FTP数据协议
|
||
#define PROTOCOL_HOST_NSA 27 //NSA主
|
||
#define PROTOCOL_HOST_DLT645V2007 30 //dlt645v2007协议
|
||
#define PROTOCOL_HOST_DLT645V2007_HR 31 //中电华瑞dlt645v2007协议
|
||
#define PROTOCOL_HOST_DLT645V2007_OVERTCP 32 //中电华瑞dlt645v2007 over tcp协议
|
||
#define PROTOCOL_CALC 37 //计算
|
||
#define PROTOCOL_DLT_1867 40 //需求响应协议dlt1867-2008
|
||
#define PROTOCOL_SUB_GDW104 47 //国网104从
|
||
#define PROTOCOL_AGC 50 //功率自动控制app
|
||
#define PROTOCOL_AVC 51 //电压自动控制app
|
||
#define PROTOCOL_HW_MQTT 72 //华为物联平台ROMA
|
||
#define PROTOCOL_ISS_MQTT 73 //软通动力mqtt
|
||
#define PROTOCOL_LM_MQTT 74 //罗米mqtt
|
||
#define PROTOCOL_GRPC_PUBLISH 76 //gRPC上传发布
|
||
#define PROTOCOL_GRPC_SUBSCRIBE 77 //gRPC下载订阅
|
||
#define PROTOCOL_OPCUA 78 //opcua协议
|
||
#define PROTOCOL_HOST_MODBUS_RTU_RDS100AFT 80 //珠海瑞捷电气股份有限公司RD系列保护装置MODBUS RTU主
|
||
#define PROTOCOL_HOST_MODBUS_RTU_APF 81 //江苏沃海电气有限公司APF(SVG)MODBUS RTU主
|
||
|
||
|
||
#define YKS_IDLE 0
|
||
#define YKS_SELREQ 1
|
||
#define YKS_SELING 2
|
||
#define YKS_SELED 3
|
||
#define YKS_ABRREQ 4
|
||
#define YKS_EXEREQ 5
|
||
#define YKS_EXEING 6
|
||
#define YKS_EXEED 7
|
||
#define YKS_ABRED 8
|
||
|
||
#define YKR_IDLE 0
|
||
#define YKR_SUCC 1
|
||
#define YKR_FAIL 2
|
||
#define YKR_OVER 3
|
||
#define YKR_OPER 4
|
||
|
||
#define YXBWT_AUTO 0
|
||
#define YXBWT_DEV 1
|
||
|
||
#define YCBWT_AUTO 0
|
||
|
||
#define YKT_NULL 0
|
||
#define YKT_SELREQ 1
|
||
#define YKT_SELOUT 2
|
||
#define YKT_SELRET 3
|
||
#define YKT_ABRREQ 4
|
||
#define YKT_EXEREQ 5
|
||
#define YKT_EXEOUT 6
|
||
#define YKT_EXERET 7
|
||
|
||
#define YKS_AUTO 0
|
||
#define YKS_MANU 1
|
||
#define YKS_PROC 2
|
||
|
||
////////////////////////////////
|
||
#define YTS_IDLE 0
|
||
#define YTS_SELREQ 1
|
||
#define YTS_SELING 2
|
||
#define YTS_SELED 3
|
||
#define YTS_ABRREQ 4
|
||
#define YTS_EXEREQ 5
|
||
#define YTS_EXEING 6
|
||
#define YTS_EXEED 7
|
||
#define YTS_ABRED 8
|
||
|
||
#define YTR_IDLE 0
|
||
#define YTR_SUCC 1
|
||
#define YTR_FAIL 2
|
||
#define YTR_OVER 3
|
||
#define YTR_OPER 4
|
||
|
||
#define YTT_NULL 0
|
||
#define YTT_SELREQ 1
|
||
#define YTT_SELOUT 2
|
||
#define YTT_SELRET 3
|
||
#define YTT_ABRREQ 4
|
||
#define YTT_EXEREQ 5
|
||
#define YTT_EXEOUT 6
|
||
|
||
#define YTS_AUTO 0
|
||
#define YTS_MANU 1
|
||
#define YTS_PROC 2
|
||
////////////////////////////////
|
||
|
||
//数据库存储
|
||
#define DATA_TYPE_YX 0x0001
|
||
#define DATA_TYPE_YC 0x0002
|
||
#define DATA_TYPE_YM 0x0004
|
||
|
||
#define FREZ_TYPE_HOUR 0x1000
|
||
#define FREZ_TYPE_DAY 0x2000
|
||
#define FREZ_TYPE_MON 0x4000
|
||
|
||
#if !defined(wMax)
|
||
#define wMax(a,b) (((a) > (b)) ? (a) : (b))
|
||
#endif
|
||
|
||
#if !defined(wMin)
|
||
#define wMin(a,b) (((a) < (b)) ? (a) : (b))
|
||
#endif
|
||
|
||
#if !defined(MAKEWORD)
|
||
#define MAKEWORD(low,high) ((WORD)(((BYTE)(low)) | ((WORD)((BYTE)(high))) << 8))
|
||
#endif
|
||
|
||
#if !defined(MAKEDWORD)
|
||
#define MAKEDWORD(low,high) ((DWORD)(((WORD)(low)) | ((DWORD)((WORD)(high))) << 16))
|
||
#endif
|
||
|
||
#if !defined(LOWORD)
|
||
#define LOWORD(l) ((WORD)(l))
|
||
#endif
|
||
|
||
#if !defined(HIWORD)
|
||
#define HIWORD(l) ((WORD)(((DWORD)(l) >> 16) & 0xffff))
|
||
#endif
|
||
|
||
#if !defined(LOBYTE)
|
||
#define LOBYTE(w) ((BYTE)(w))
|
||
#endif
|
||
|
||
#if !defined(HIBYTE)
|
||
#define HIBYTE(w) ((BYTE)(((WORD)(w) >> 8) & 0xff))
|
||
#endif
|
||
|
||
#define MAX_SYMBOL_SUM 100
|
||
#define MAX_SYMBOL_LEN 10
|
||
#define MAX_KEYWORD_SUM 20
|
||
#define MAX_STACK_LEN 400
|
||
#define MAX_PAIRCLASS_SUM 5
|
||
|
||
#define COMPUTE_SYMBOL 1
|
||
#define ASSIGN_SYMBOL 2
|
||
#define RELATION_SYMBOL 3
|
||
#define LOGICAL_SYMBOL 4
|
||
#define DIVIDE_SYMBOL 5
|
||
#define CONST_SYMBOL 6
|
||
#define VAR_SYMBOL 7
|
||
#define CONDITION_SYMBOL 8
|
||
#define SPECIAL_SYMBOL 9
|
||
|
||
#define DATAS 0
|
||
#define TWOCOMPS 1
|
||
#define ONECOMPS 2
|
||
#define LEFTBRACKET 3
|
||
#define RIGHTBRACKET 4
|
||
|
||
#define SE_TWOCOMPS 0
|
||
#define SE_ONECOMPS 1
|
||
#define SE_SPECIALCONST 2
|
||
#define SE_VARS 3
|
||
#define SE_TEMPVARS 4
|
||
#define SE_CONSTS 5
|
||
#define SE_ASSIGN 6
|
||
|
||
#define MAX_EXP_COUNT 20
|
||
#define MAX_VAR_SUM 24
|
||
#define MAX_CONST_SUM 14
|
||
#define MAX_TEMP_SUM 50
|
||
#define MAX_IF_LEN 50
|
||
#define MAX_THEN_LEN 50
|
||
#define MAX_ELSE_LEN 50
|
||
|
||
#define MAX_DATATYPE_SUM (MAX_VAR_SUM + MAX_CONST_SUM + MAX_TEMP_SUM)
|
||
#define MAX_VAR_LEN (MAX_VAR_SUM * 8)
|
||
#define MAX_CONST_LEN (MAX_CONST_SUM * 8)
|
||
#define MAX_TOKEN_LEN 20
|
||
#define MAX_COMPUTE_DATA_SUM 10
|
||
#define MAX_DATA_STACK_LEN 100
|
||
|
||
#define DT_CHAR 1 // c
|
||
#define DT_SHORTINT 2 // s
|
||
#define DT_INT 3 // i
|
||
#define DT_FLOAT 4 // f
|
||
|
||
#define ADD 1 // +
|
||
#define SUB 2 // -
|
||
#define MUL 3 // *
|
||
#define DIV 4 // /
|
||
#define MOD 5 // %
|
||
#define ABS 6 // ABS
|
||
#define SIN 7 // SIN
|
||
#define COS 8 // COS
|
||
#define LSC 9 // <
|
||
#define LEC 10 // <=
|
||
#define EQC 11 // ==
|
||
#define GEC 12 // >=
|
||
#define GTC 13 // >
|
||
#define AND 14 // &&
|
||
#define OR 15 // ||
|
||
#define LBRACKET 16 // (
|
||
#define RBRACKET 17 // )
|
||
#define CP_TRUE 18 // T
|
||
#define CP_FAUSE 19 // F
|
||
#define TIMEC 20 // TIME
|
||
#define LMBRACKET 21 // [
|
||
#define RMBRACKET 22 // ]
|
||
#define SQRT 23 // SQRT
|
||
#define LLBRACKET 30 // {
|
||
#define RLBRACKET 31 // }
|
||
#define SEMICOLON 32 // ;
|
||
#define ASSIGN 33 // =
|
||
#define IF 34 // IF
|
||
#define THEN 35 // THEN
|
||
#define ELSE 36 // ELSE
|
||
#define EOS 40 // #
|
||
#define CP_MAX 41 // MAX
|
||
#define CP_MIN 42 // MIN
|
||
#define PERIOD 43 // ,
|
||
#define VAR_MIN 51 //* [ dataid]
|
||
#define VAR_MAX 150
|
||
|
||
#define TEMP_VAR_MIN 151 // t00 ~ t49
|
||
#define TEMP_VAR_MAX 200
|
||
#define CONST_MIN 201
|
||
#define CONST_MAX 250
|
||
|
||
#define MAX_SOURCE_FORMULA_LEN 1024
|
||
#define MAX_TARGET_FORMULA_LEN 1024
|
||
#define FORMULA_STRING_LENGTH 200
|
||
|
||
#pragma pack(1)
|
||
|
||
//for formulas
|
||
typedef struct DATAID
|
||
{
|
||
short iotype;
|
||
short uid;
|
||
short point;
|
||
} DATAID, *PDATAID;
|
||
|
||
struct FORMULA_STRUCT
|
||
{
|
||
short m_form_no;
|
||
BYTE m_slice;
|
||
DATAID m_result_no;
|
||
char m_form_str[FORMULA_STRING_LENGTH];
|
||
BYTE m_var_list[200];
|
||
BYTE m_var_num;
|
||
BYTE m_obj_str[100];
|
||
BYTE m_obj_clist[120];
|
||
BYTE m_obj_cnum;
|
||
BYTE m_obj_vlist[200];
|
||
BYTE m_obj_vnum;
|
||
BYTE m_if_len;
|
||
BYTE m_if_part[50];
|
||
BYTE m_then_len;
|
||
BYTE m_then_part[50];
|
||
BYTE m_else_len;
|
||
BYTE m_else_part[50];
|
||
LONG m_curslice;
|
||
};
|
||
|
||
struct TARGET_FORMULA_CTRL_STRU
|
||
{
|
||
LONG var_num;
|
||
LONG const_num;
|
||
LONG if_len;
|
||
LONG then_len;
|
||
LONG else_len;
|
||
};
|
||
|
||
struct DATA_DESCRIBLE_STRU
|
||
{
|
||
LONG data_type;
|
||
char data_value[4];
|
||
};
|
||
|
||
#define HOST_NAME_LENGTH 32
|
||
#define MAX_NODE_NUM 4
|
||
typedef struct
|
||
{
|
||
char m_machine_name[HOST_NAME_LENGTH];
|
||
BYTE m_netnode_no;
|
||
BYTE m_tcitype;
|
||
DWORD m_target_addr;
|
||
short m_target_port;
|
||
QLONG irn;
|
||
} NODE_STRUCT;
|
||
|
||
typedef struct
|
||
{
|
||
struct
|
||
{
|
||
BOOLEAN enable;
|
||
char name[MAX_NAME_SIZE];
|
||
} interfaces;
|
||
NODE_STRUCT m_node[MAX_NODE_NUM];
|
||
} struNodeOption;
|
||
|
||
typedef struct
|
||
{
|
||
char name[MAX_NAME_SIZE];
|
||
char pass[MAX_PSW_SIZE];
|
||
} struUserInfor;
|
||
|
||
typedef struct
|
||
{
|
||
unionCP56Time now;
|
||
BOOLEAN logined;
|
||
BOOLEAN watchdog_type;
|
||
BOOLEAN log_enabled;
|
||
BOOLEAN single;
|
||
BOOLEAN bOldConfig; //是否为原配置文件
|
||
char yk_pass[MAX_PSW_SIZE];
|
||
short yk_keep;
|
||
short interval_time;
|
||
WORD zjd_log_bind_port;
|
||
DWORD zjd_log_bind_addr;
|
||
DWORD ticks;
|
||
DWORD timers;
|
||
DWORD auto_reset_interval;
|
||
} struSystem;
|
||
|
||
typedef struct
|
||
{
|
||
char name[MAX_NAME_SIZE];
|
||
BOOLEAN state;
|
||
LONG baud;
|
||
BYTE data;
|
||
BYTE parity;
|
||
BYTE stop;
|
||
short timeout;
|
||
} struPort;
|
||
|
||
typedef struct
|
||
{
|
||
BYTE in_buf[MAX_PORT_BUFFER_SIZE];
|
||
BYTE out_buf[MAX_PORT_BUFFER_SIZE];
|
||
short in_load;
|
||
short in_save;
|
||
short out_load;
|
||
short out_save;
|
||
} struPortBuffer;
|
||
|
||
typedef struct
|
||
{
|
||
struPort ports[HARDWARE_PORTS_NUM];
|
||
} struHardware;
|
||
|
||
#define SELFRESETTING 0
|
||
#define LATCHED 1
|
||
#define PULSED 2
|
||
|
||
typedef struct
|
||
{
|
||
BOOLEAN yx1Enable; //function 1
|
||
BOOLEAN yx2Enable; //function 3
|
||
BOOLEAN yc1Enable; //function 3
|
||
BOOLEAN yc2Enable; //function 3
|
||
BOOLEAN yc3Enable;
|
||
BOOLEAN yc4Enable;
|
||
BOOLEAN ym1Enable;
|
||
BOOLEAN ym2Enable;
|
||
BYTE yx1FuncCode;
|
||
BYTE yx2FuncCode;
|
||
BYTE yc1FuncCode;
|
||
BYTE yc2FuncCode;
|
||
BYTE yc3FuncCode;
|
||
BYTE yc4FuncCode;
|
||
BYTE ym1FuncCode;
|
||
BYTE ym2FuncCode;
|
||
WORD yx1Begin;
|
||
short yx1Count;
|
||
WORD yx2Begin;
|
||
short yx2Count;
|
||
WORD yc1Begin;
|
||
short yc1Count;
|
||
WORD yc2Begin;
|
||
short yc2Count;
|
||
WORD yc3Begin;
|
||
short yc3Count;
|
||
WORD yc4Begin;
|
||
short yc4Count;
|
||
WORD ym1Begin;
|
||
short ym1Count;
|
||
WORD ym2Begin;
|
||
short ym2Count;
|
||
} struModbusOption;
|
||
|
||
typedef struct
|
||
{
|
||
WORD idcode[MAX_PROC_OPTION_SIZE/2];
|
||
} struDLT645Option;
|
||
|
||
//add by assouan for network options
|
||
typedef struct
|
||
{
|
||
BOOLEAN ignored_source;
|
||
BYTE socket_type;
|
||
WORD bind_port;
|
||
WORD target_port;
|
||
DWORD bind_addr;
|
||
DWORD target_addr;
|
||
} struNetWorkOption;
|
||
//end
|
||
|
||
typedef struct
|
||
{
|
||
BOOLEAN use_owner_config; //单元配置是否启用
|
||
struModbusOption modbus;
|
||
} struUnitModbusOption;
|
||
|
||
typedef struct
|
||
{
|
||
BYTE addressLength;
|
||
BYTE sizeOfTypeId; /* size of the type id (default = 1 - don't change) */
|
||
BYTE sizeOfVSQ; /* don't change */
|
||
BYTE sizeOfCOT; /* size of COT (1/2 - default = 2 -> COT includes OA) */
|
||
BYTE originatorAddress; /* originator address (OA) to use (0-255) */
|
||
BYTE sizeOfCA; /* size of common address (CA) of ASDU (1/2 - default = 2) */
|
||
BYTE sizeOfIOA; /* size of information object address (IOA) (1/2/3 - default = 3) */
|
||
BYTE maxSizeOfASDU; /* maximum size of the ASDU that is generated - the maximum maximum value is 249 for IEC 104 and 254 for IEC 101 */
|
||
BOOLEAN useSingleCharACK; //Use Single Charachter 0xE5 as Link Layer acknowledgement
|
||
BOOLEAN use_full_time; //Specification of the format of time tags for process information:
|
||
//- short format: CP24Time2a (minutes and milliseconds up to 59.59999)
|
||
//- long format: CP56Time2a (complete date and time representation, 2 charachter year representation 00 to 99)
|
||
BOOLEAN use_ack_commands_on_reception; //Specification whether Activation confirmation shall be send immediatelay after receiption of a command
|
||
//Necessary if the primary station uses a fix timeout period with low tolerance
|
||
//Has no affect on the source of Activation Termination
|
||
BOOLEAN use_double_trans_mode; //If enabled: (and if Transit with Timestamp is enabled)
|
||
//Information in monitoring direction will be transitted twice:
|
||
//1. With high priority, without time stamp.
|
||
//2. With low priority, with time stamp.
|
||
//(Pulse counter PCV are not affected)
|
||
BOOLEAN use_exclusive; //If enabled, the serial interfaces of a redundant
|
||
//subdevice communication line will be accessed exclusive.
|
||
//That means as long as one interface is accessed all other interfaces of
|
||
//this redundant line are blocked.
|
||
BYTE dir_bit; //Specification of the direction bit DIR of the Link layer control Field
|
||
//to be used by the transmitter
|
||
//Value range: 0 or 1
|
||
//Relevant in balanced mode only
|
||
BYTE communication_retry; //Maximun number of transission repetitions
|
||
//in case of consecutive transmission disturbances
|
||
//Value range: 1 to 255
|
||
//Relevant at slave interface in balanced mode only
|
||
WORD cycle_time_test_link; //Specification whether Test Link messages shall be sent
|
||
//If selected, Test Link message will be sent if within the specified time
|
||
//no Application message had been sent
|
||
//Relevant in balanced mode only
|
||
WORD time_out; //Link Layer response/confirmation time out interval in seconds.
|
||
//Relevant at Master interface in balanced and unbalanced mode and
|
||
//at slave interface in balanced mode only.
|
||
//Value range: 1 to 6000
|
||
WORD cycle_time_offline; //Specification whether offline supervision of the primary station shall take place
|
||
//Relevant at slave interface and unblanced mode only
|
||
WORD background_scan_cycle; //If enabled:
|
||
//Background scan according to IEC60870-5-101/104
|
||
//will be send with the configured cycle time.
|
||
WORD timeoutForACK;
|
||
WORD timeoutRepeat;
|
||
BYTE EI_Priority; //链路初始化结束
|
||
BYTE CD_Priority; //延时采集
|
||
BYTE CS_Priority; //时钟同步
|
||
BYTE YK_Priority; //遥控遥调
|
||
BYTE TS_Priority; //测试
|
||
BYTE RP_Priority; //过程复位
|
||
BYTE IC_Priority; //总召唤
|
||
BYTE CI_Priority; //召唤累积量
|
||
BYTE YXBW_Priority; //遥信变位
|
||
BYTE EVENT_Priority; //事件记录
|
||
BYTE CYC_Priority; //循环数据
|
||
BYTE Back_Priority; //背景扫描
|
||
BYTE YCBW_Priority; //变位遥测
|
||
BYTE Unknow_Priority; //未知的应用确认
|
||
BYTE File_Priority; //文件传输
|
||
BYTE Group_Priority; //组召唤
|
||
|
||
BOOLEAN double_link_ack; //是否双向链路确认,在平衡方式时使用
|
||
BOOLEAN start_station; //是否启动站,在平衡方式时使用
|
||
|
||
WORD yx_start_address; //遥信起始地址
|
||
WORD yc_start_address; //遥测起始地址
|
||
WORD ym_start_address; //遥脉起始地址
|
||
|
||
BYTE yc_type; //默认遥测类型
|
||
BOOLEAN use_cycle_interrogation_command;//使用循环总召唤,仅用于主协议
|
||
WORD t4; //总召唤间隔,仅用于主协议
|
||
WORD t5; //召唤电度量间隔,仅用于主协议
|
||
} struIEC101Option;
|
||
|
||
typedef struct
|
||
{
|
||
struNetWorkOption net;
|
||
BYTE yx_type;
|
||
BYTE yc_type;
|
||
BYTE yk_type;
|
||
BOOLEAN need_resend; //是否重发
|
||
BOOLEAN need_cyc_send; //循环上送全遥测及全遥信
|
||
char cot_size; //
|
||
char asdu_addr_size; //Length of Address fixed to 16 bit
|
||
//Structured address with underscore as delimiter
|
||
//Example: 3_5_8 defines 16-bit address with 3 structure elements:
|
||
//3 bit most significant
|
||
//5 bit medium signigicant
|
||
//8 bit least significant
|
||
char info_addr_size; //Length of Information Object Address fixed to 24 bit!
|
||
//Structured address with underscore as delimiter
|
||
//Example: 3_5_6_3_7 defines 24-bit address with 5 structure elements.
|
||
BOOLEAN use_ack_commands_on_reception; //Specification whether Activation confirmation shall be send immediatelay after receiption of a command
|
||
//Necessary if the primary station uses a fix timeout period with low tolerance
|
||
//Has no affect on the source of Activation Termination
|
||
BYTE t1; //t1: Time-out of send APDUs or test APDUs
|
||
//1 to 255 seconds; default value: 15 seconds
|
||
BYTE t2; //t2: Time-out for acknowledges in case of no data messages
|
||
//1 to 255 seconds; default value: 10 seconds
|
||
//t2 < t1
|
||
BYTE t0; //T0: Time-out for connecting the server.
|
||
WORD t3; //T3: Time-out for sending test frames in case of a long idle state
|
||
//1 to 65535 seconds; default value: 20 seconds
|
||
short k; //k: maximun differance receive sequence number to send sequence count variable
|
||
//1 to 32767 APDUs; default value: 12 APDUs
|
||
short w; //Latest acknowledge after receiving w I format APDUs
|
||
//1 to 32767 APDUs; default value: 8 APDUs
|
||
//(w should not exceed tow-thirds of k)
|
||
WORD background_scan_cycle; //If enabled:
|
||
//Background scan according to IEC60870-5-101/104
|
||
//will be send with the configured cycle time.
|
||
WORD yx_start_address; //遥信起始地址,仅用于从协议
|
||
WORD yc_start_address; //遥测起始地址,仅用于从协议
|
||
WORD ym_start_address; //遥脉起始地址,仅用于从协议
|
||
|
||
BOOLEAN use_cycle_interrogation_command;//使用循环总召唤,仅用于主协议
|
||
WORD t4; //总召唤间隔,仅用于主协议
|
||
WORD t5; //召唤电度量间隔,仅用于主协议
|
||
DWORD irn; //用于加密上传协议时的编码
|
||
|
||
BOOLEAN send_start_dt; //发送启动帧
|
||
BOOLEAN use_send_test; //使用发送测试帧
|
||
BYTE send_test_type; //发送测试帧类型
|
||
BOOLEAN use_send_end_of_initialisation; //发送初始化结束帧
|
||
BOOLEAN use_ns_nr_check; //nsnr检查
|
||
BYTE bres1;
|
||
BYTE bres2;
|
||
WORD wres1;
|
||
} struIEC104Option;
|
||
|
||
#define XT9712_YC_TYPE_DEFAULT 0
|
||
#define XT9712_YC_TYPE_FLOAT 1
|
||
typedef struct
|
||
{
|
||
struNetWorkOption net;
|
||
BYTE yc_type;
|
||
BYTE res;
|
||
WORD yx_max;
|
||
WORD yc_max;
|
||
WORD ym_max;
|
||
} struXT9712Option;
|
||
|
||
#define IEC103_YK_USE_ASDU64 0 //南瑞、南京电研遥控方式
|
||
#define IEC103_YK_USE_ASDU20 1 //国外遥控方式 一般命令
|
||
#define IEC103_YK_USE_ASDU10 2 //南自遥控方式 通用数据
|
||
typedef struct
|
||
{
|
||
BYTE yk_type; //遥控方式
|
||
BOOLEAN FCB; //复位帧计数位
|
||
BOOLEAN CU; //复位通信单元
|
||
BOOLEAN IGI; //总召唤
|
||
BOOLEAN SYNC; //对时
|
||
BOOLEAN single_SYNC; //单个装置对时
|
||
BYTE retry_times; //重试次数
|
||
BYTE ignore_DFC; //忽略DFC位
|
||
DWORD igi_gap; //总召唤间隔
|
||
DWORD retry_time; //重连时间
|
||
} struIEC103Option;
|
||
|
||
typedef struct
|
||
{
|
||
BYTE group_num;
|
||
BYTE group_no;
|
||
BOOLEAN query1;
|
||
BOOLEAN query2;
|
||
BOOLEAN yc_query;
|
||
BOOLEAN yx_query;
|
||
BOOLEAN analogue_query;
|
||
BOOLEAN ym_query;
|
||
} struNSAOption;
|
||
|
||
typedef struct
|
||
{
|
||
char client_id[MAX_ID_LENGTH];
|
||
char device_id[MAX_ID_LENGTH];
|
||
char host[128];
|
||
char username[128];
|
||
char password[128];
|
||
char topic_version[128];
|
||
|
||
WORD target_port;
|
||
LONG connectTimeout;
|
||
LONG keepAliveInterval;
|
||
LONG connectInterval;
|
||
LONG publishInterval;
|
||
} struISSMQTTOption;
|
||
|
||
typedef struct
|
||
{
|
||
char client_id[MAX_ID_LENGTH];
|
||
char device_id[MAX_ID_LENGTH];
|
||
char host[128];
|
||
char username[128];
|
||
char password[128];
|
||
char topic[128];
|
||
|
||
WORD target_port;
|
||
LONG connectTimeout;
|
||
LONG keepAliveInterval;
|
||
LONG connectInterval;
|
||
} struLMMQTTOption;
|
||
|
||
typedef union
|
||
{
|
||
BYTE data[MAX_PROC_OPTION_SIZE];
|
||
struModbusOption modbus;
|
||
struDLT645Option dlt645;
|
||
struNetWorkOption network;
|
||
struIEC104Option iec104;
|
||
struIEC103Option iec103;
|
||
struIEC101Option iec101;
|
||
} unionProcOption;
|
||
|
||
typedef struct
|
||
{
|
||
char name[(MAX_NAME_SIZE << 2)];
|
||
BYTE type;
|
||
BYTE state;
|
||
BOOLEAN time_accept; //accept set time command from this proc
|
||
BYTE proto;
|
||
BYTE order; //CARD or PORT order
|
||
BYTE mode; //slave mode or master mode or duplex mode
|
||
short time_gap; //send out time from this proc 18.2c/s
|
||
short poll_gap; //send out command 18.2c/s
|
||
short softdog; //software watchdog counter
|
||
short units[PROCESS_UNIT_NUM];
|
||
unionProcOption option;
|
||
QLONG irn;
|
||
} struProcess;
|
||
|
||
typedef struct
|
||
{
|
||
short order;
|
||
BYTE value;
|
||
BYTE qds; //品质描述
|
||
BOOLEAN yxbw;
|
||
BYTE m_param[MAX_UNIT_POINT_PARAM_SIZE];
|
||
DWORD update_time;
|
||
QLONG irn;
|
||
} struUnitYX;
|
||
|
||
typedef struct
|
||
{
|
||
char name[(MAX_NAME_SIZE << 2)];
|
||
} struUnitYXStatic;
|
||
|
||
#if 0
|
||
#define EXTREME_SAMPLE_NUM 32
|
||
#endif
|
||
typedef struct
|
||
{
|
||
short order;
|
||
short factor; //比例系数
|
||
LONG value; //遥测值
|
||
float coef;
|
||
float base;
|
||
BYTE qds; //品质描述
|
||
BOOLEAN ycbw; //遥测变位标识
|
||
short change_pos;
|
||
BYTE m_param[MAX_UNIT_POINT_PARAM_SIZE];
|
||
DWORD update_time;
|
||
QLONG irn;
|
||
} struUnitYC;
|
||
|
||
typedef struct
|
||
{
|
||
char name[(MAX_NAME_SIZE << 2)];
|
||
} struUnitYCStatic;
|
||
|
||
typedef struct
|
||
{
|
||
short order;
|
||
LONG value;
|
||
union {
|
||
float flVal;
|
||
DWORD code;
|
||
};
|
||
BYTE qds;
|
||
} struYCBW;
|
||
|
||
typedef struct
|
||
{
|
||
short order;
|
||
DWORD value;
|
||
float coef;
|
||
float base;
|
||
BYTE m_param[MAX_UNIT_POINT_PARAM_SIZE];
|
||
DWORD update_time;
|
||
QLONG irn;
|
||
} struUnitYM;
|
||
|
||
typedef struct
|
||
{
|
||
char name[(MAX_NAME_SIZE << 2)];
|
||
} struUnitYMStatic;
|
||
|
||
typedef struct
|
||
{
|
||
short order;
|
||
BOOLEAN selected;
|
||
BYTE m_param[MAX_UNIT_POINT_PARAM_SIZE];
|
||
QLONG irn;
|
||
} struUnitYK;
|
||
|
||
typedef struct
|
||
{
|
||
char name[(MAX_NAME_SIZE << 2)];
|
||
} struUnitYKStatic;
|
||
|
||
typedef struct
|
||
{
|
||
short order;
|
||
BOOLEAN selected;
|
||
BYTE m_param[MAX_UNIT_POINT_PARAM_SIZE];
|
||
QLONG irn;
|
||
} struUnitYT;
|
||
|
||
typedef struct
|
||
{
|
||
char name[(MAX_NAME_SIZE << 2)];
|
||
} struUnitYTStatic;
|
||
|
||
typedef struct
|
||
{
|
||
BYTE state;
|
||
BYTE type;
|
||
BYTE addr[MAX_UNIT_ADDR_SIZE];
|
||
BYTE m_param[MAX_UNIT_PARAM_SIZE]; //每个单元有256个字节的参数。
|
||
short yxcount;
|
||
short yccount;
|
||
short ymcount;
|
||
short ykcount;
|
||
short ytcount;
|
||
short softdog;
|
||
LONG yxbwload;
|
||
LONG soeload;
|
||
LONG ycbwload;
|
||
LONG value; //单元状态
|
||
struUnitYX* yxs;
|
||
#if USE_32BITS
|
||
LONG res1;
|
||
#endif
|
||
struUnitYC* ycs;
|
||
#if USE_32BITS
|
||
LONG res2;
|
||
#endif
|
||
struUnitYM* yms;
|
||
#if USE_32BITS
|
||
LONG res3;
|
||
#endif
|
||
struUnitYK* yks;
|
||
#if USE_32BITS
|
||
LONG res4;
|
||
#endif
|
||
struUnitYT* yts;
|
||
#if USE_32BITS
|
||
LONG res5;
|
||
#endif
|
||
QLONG irn;
|
||
} struUnit;
|
||
|
||
typedef struct
|
||
{
|
||
char name[(MAX_NAME_SIZE<<2)];
|
||
char model[MAX_MODEL_SIZE];
|
||
|
||
char nodeId[MAX_ID_LENGTH];
|
||
char deviceId[MAX_ID_LENGTH];
|
||
char manufacturerId[MAX_ID_LENGTH];
|
||
} struUnitStatic;
|
||
|
||
typedef struct
|
||
{
|
||
struHardware hardware;
|
||
struProcess processes[PROCESSES_NUM];
|
||
struUnit units[UNIT_NUM];
|
||
} struConfig;
|
||
|
||
typedef struct
|
||
{
|
||
BYTE value; //状态支持SPI及DPI
|
||
BYTE qds; //品质描述
|
||
BYTE inv; //<0>=不取反,<1>=取反
|
||
short auto_reset; //自动复归
|
||
short op_unit;
|
||
DWORD bw_time; //变位时刻
|
||
DWORD update_time;//变位时刻
|
||
} struYX;
|
||
|
||
typedef struct
|
||
{
|
||
char name[(MAX_NAME_SIZE << 2)];
|
||
} struYXStatic;
|
||
|
||
typedef struct
|
||
{
|
||
BYTE qds; //品质描述
|
||
short op_unit;
|
||
LONG value; //遥测值
|
||
float coef;
|
||
float base;
|
||
DWORD update_time; //变位时刻
|
||
} struYC;
|
||
|
||
typedef struct
|
||
{
|
||
char name[(MAX_NAME_SIZE << 2)];
|
||
} struYCStatic;
|
||
|
||
typedef struct
|
||
{
|
||
float coef;
|
||
float base;
|
||
DWORD value; //遥脉值
|
||
DWORD update_time; //变位时刻
|
||
short op_unit;
|
||
short res;
|
||
} struYM;
|
||
|
||
typedef struct
|
||
{
|
||
char name[(MAX_NAME_SIZE << 2)];
|
||
} struYMStatic;
|
||
|
||
typedef struct
|
||
{
|
||
BOOLEAN value;
|
||
short state;
|
||
short result;
|
||
DWORD op_time;
|
||
short op_unit;
|
||
} struYK;
|
||
|
||
typedef struct
|
||
{
|
||
char name[(MAX_NAME_SIZE << 2)];
|
||
} struYKStatic;
|
||
|
||
typedef struct
|
||
{
|
||
LONG value;
|
||
short state;
|
||
short result;
|
||
DWORD op_time;
|
||
short op_unit;
|
||
} struYT;
|
||
|
||
typedef struct
|
||
{
|
||
char name[(MAX_NAME_SIZE << 2)];
|
||
} struYTStatic;
|
||
|
||
typedef struct
|
||
{
|
||
unionCP56Time st;
|
||
BYTE value;
|
||
BYTE qds;
|
||
BYTE type;
|
||
short order;
|
||
short uid;
|
||
short point;
|
||
} struYXBW;
|
||
|
||
typedef struct
|
||
{
|
||
unionCP56Time st;
|
||
BYTE value;
|
||
BYTE qds;
|
||
short order;
|
||
short uid;
|
||
short point;
|
||
} struSOE;
|
||
|
||
typedef struct
|
||
{
|
||
unionCP56Time st;
|
||
LONG value;
|
||
BYTE qds; //品质描述
|
||
BYTE type;
|
||
short order;
|
||
short uid;
|
||
short point;
|
||
} struYCBWBuffer;
|
||
|
||
typedef struct
|
||
{
|
||
struYX *yxs;
|
||
struYC *ycs;
|
||
struYM *yms;
|
||
struYK *yks;
|
||
struYT *yts;
|
||
} struDatabase;
|
||
|
||
typedef struct
|
||
{
|
||
WORD year;
|
||
BYTE month;
|
||
BYTE day;
|
||
BYTE hour;
|
||
BYTE minute;
|
||
BYTE second;
|
||
BYTE type;
|
||
BYTE data[32];
|
||
} struRunLog;
|
||
|
||
typedef struct
|
||
{
|
||
unionCP56Time st;
|
||
BYTE value;
|
||
BYTE type; //SELREQ\SELOUT\SELRET\ABRREQ\EXEREQ\EXEOUT
|
||
BYTE source; //NONE\LOCAL\PROC
|
||
short point; //DATABASE PT
|
||
short uid; //unit id
|
||
} struYKLog;
|
||
|
||
typedef struct
|
||
{
|
||
unionCP56Time st;
|
||
DWORD value;
|
||
BYTE type; //SELREQ\SELOUT\SELRET\ABRREQ\EXEREQ\EXEOUT
|
||
BYTE source; //NONE\LOCAL\PROC
|
||
short point; //DATABASE PT
|
||
short uid; //unit id
|
||
} struYTLog;
|
||
|
||
typedef struct
|
||
{
|
||
BOOLEAN enabled;
|
||
char res;
|
||
short mon_port;
|
||
short mon_unit;
|
||
DWORD load;
|
||
DWORD save;
|
||
DWORD rx_count;
|
||
DWORD tx_count;
|
||
DWORD rf_count;
|
||
DWORD tf_count;
|
||
char *buf;
|
||
} struDispBuffer;
|
||
|
||
typedef struct
|
||
{
|
||
BOOLEAN enabled;
|
||
char res;
|
||
DWORD load;
|
||
DWORD save;
|
||
char *buf;
|
||
} struMsgBuffer;
|
||
|
||
typedef struct
|
||
{
|
||
LONG count;
|
||
struYCBW data[UNIT_YC_MAX];
|
||
} YCBWBuffer;
|
||
|
||
typedef struct
|
||
{
|
||
LONG order;
|
||
BYTE qds;
|
||
BOOLEAN value;
|
||
} struYXData;
|
||
|
||
typedef struct
|
||
{
|
||
LONG order;
|
||
BYTE qds;
|
||
BOOLEAN value;
|
||
unionCP56Time ct;
|
||
} struEventsData;
|
||
|
||
typedef struct
|
||
{
|
||
LONG count;
|
||
struYXData data[DATABASE_YXBW_NUM];
|
||
} YXBWBuffer;
|
||
|
||
typedef struct
|
||
{
|
||
LONG count;
|
||
struEventsData data[DATABASE_SOE_NUM];
|
||
} EventBuffer;
|
||
|
||
#pragma pack()
|
||
|
||
typedef struct {
|
||
DWORD value;
|
||
const char* strptr;
|
||
} value_string;
|
||
|
||
static const value_string yk_state[] = {
|
||
{ YKS_IDLE, "YKS_IDLE" },
|
||
{ YKS_SELREQ, "YKS_SELREQ" },
|
||
{ YKS_SELING, "YKS_SELING" },
|
||
{ YKS_SELED, "YKS_SELED" },
|
||
{ YKS_ABRREQ, "YKS_ABRREQ" },
|
||
{ YKS_EXEREQ, "YKS_EXEREQ" },
|
||
{ YKS_EXEING, "YKS_EXEING" },
|
||
{ YKS_EXEED, "YKS_EXEED" },
|
||
{ YKS_ABRED, "YKS_ABRED" }
|
||
};
|
||
|
||
static const value_string yk_result[] = {
|
||
{ YKR_IDLE, "YKR_IDLE" },
|
||
{ YKR_SUCC, "YKR_SUCC" },
|
||
{ YKR_FAIL, "YKR_FAIL" },
|
||
{ YKR_OVER, "YKR_OVER" },
|
||
{ YKR_OPER, "YKR_OPER" }
|
||
};
|
||
|
||
static const value_string yt_state[] = {
|
||
{ YTS_IDLE, "YTS_IDLE" },
|
||
{ YTS_SELREQ, "YTS_SELREQ" },
|
||
{ YTS_SELING, "YTS_SELING" },
|
||
{ YTS_SELED, "YTS_SELED" },
|
||
{ YTS_ABRREQ, "YTS_ABRREQ" },
|
||
{ YTS_EXEREQ, "YTS_EXEREQ" },
|
||
{ YTS_EXEING, "YTS_EXEING" },
|
||
{ YTS_EXEED, "YTS_EXEED" },
|
||
{ YTS_ABRED, "YTS_ABRED" }
|
||
};
|
||
|
||
static const value_string yt_result[] = {
|
||
{ YTR_IDLE, "YTR_IDLE" },
|
||
{ YTR_SUCC, "YTR_SUCC" },
|
||
{ YTR_FAIL, "YTR_FAIL" },
|
||
{ YTR_OVER, "YTR_OVER" },
|
||
{ YTR_OPER, "YTR_OPER" }
|
||
};
|
||
|
||
class CYCBW;
|
||
class CYXBW;
|
||
class CSOE;
|
||
class CYKLog;
|
||
class CYTLog;
|
||
class CProcess;
|
||
|
||
extern BOOLEAN systemRunFlag;
|
||
extern BOOLEAN synchronized;
|
||
extern BOOLEAN zlog_inited;
|
||
extern struSystem system32;
|
||
extern struConfig config;
|
||
extern struDatabase database;
|
||
extern CYCBW ycbw;
|
||
extern CYXBW yxbw;
|
||
extern CSOE soe;
|
||
extern CYKLog yklog;
|
||
extern CYTLog ytlog;
|
||
extern CProcess* procs[PROCESSES_NUM];
|
||
extern struUnitStatic static_units[UNIT_NUM];
|
||
extern struDispBuffer channelBuffer;
|
||
extern struMsgBuffer msgBuffer;
|
||
extern struNodeOption nodes;
|
||
extern char configpath[MAX_PATH]; //配置文件所在目录
|
||
extern char configfile[MAX_PATH]; //配置文件
|
||
#if 0
|
||
extern threadpool_t pool;
|
||
#endif
|
||
typedef struct
|
||
{
|
||
//网络配置信息
|
||
struNetWorkOption network;
|
||
//mqtt接入信息
|
||
char client_id[128];
|
||
char username[128];
|
||
char password[128];
|
||
char device_id[128];
|
||
char devType[32];
|
||
char devName[32];
|
||
char mfgInfo[32];
|
||
char version[32];
|
||
char hardVersion[32];
|
||
|
||
LONG connectTimeout;
|
||
LONG keepAliveInterval;
|
||
LONG connectInterval;
|
||
LONG dataSendInterval;
|
||
LONG statusUpdateInterval;
|
||
} struMQTTOption;
|
||
|
||
#define QOS_LEVEL_0 0
|
||
#define QOS_LEVEL_1 1
|
||
#define QOS_LEVEL_2 2
|
||
|
||
#define MQTT_DEFAULT_PORT 1883
|
||
|
||
#if 0
|
||
typedef struct ANYWARN
|
||
{
|
||
BYTE type;
|
||
BYTE warnType;
|
||
} ANYWARN, *PANYWARN;
|
||
|
||
typedef struct YX_WARN {
|
||
BYTE type;
|
||
BYTE warnType;
|
||
BYTE unitID;
|
||
BYTE realVal;
|
||
short dotNo;
|
||
unionCP56Time warnTime;
|
||
} YX_WARN,*PYX_WARN;
|
||
|
||
typedef struct YC_WARN {
|
||
BYTE type;
|
||
BYTE warnType;
|
||
BYTE unitID;
|
||
short dotNo;
|
||
float realVal;
|
||
unionCP56Time warnTime;
|
||
} YC_WARN, *PYC_WARN;
|
||
|
||
typedef struct UNIT_WARN {
|
||
BYTE type;
|
||
BYTE warnType;
|
||
BYTE unitID;
|
||
BYTE realVal;
|
||
unionCP56Time warnTime;
|
||
} UNIT_WARN, *PUNIT_WARN;
|
||
|
||
typedef union WARN {
|
||
ANYWARN any_warn;
|
||
YX_WARN yx_warn;
|
||
YC_WARN yc_warn;
|
||
UNIT_WARN unit_warn;
|
||
} WARN, *PWARN;
|
||
|
||
typedef struct _tag_SEND_WARNBUF {
|
||
LONG total_warn;
|
||
LONG id;
|
||
WARN warn[1];
|
||
} SEND_WARNBUF, *PSEND_WARNBUF;
|
||
|
||
#endif
|
||
#pragma pack()
|
||
|
||
//////////////////////////////////////////////////////////////////////////
|
||
const char* val_to_str(DWORD val, const value_string* vs, const char* fmt);
|
||
void StringToHex(const char* pStr, BYTE* pData);
|
||
void HexToString(const BYTE* pData, char* pStr, int count);
|
||
BOOLEAN get_system_time(unionCP56Time* lpSystemTime);
|
||
BOOLEAN set_system_time(unionCP56Time* lpSystemTime);
|
||
DWORD bcd_to_int(const BYTE *bcd, int length);
|
||
void int_to_bcd(int dec, BYTE *bcd, int length);
|
||
DWORD BufToVal(BYTE* buf, int lenth, BOOLEAN bBigEndian = FALSE);
|
||
int ValToBuf(BYTE* buf, DWORD val, int lenth, BOOLEAN bBigEndian = FALSE);
|
||
int unionCP56TimeToBuf(BYTE* buf, unionCP56Time st);
|
||
int GetFileSize(const char* fname);
|
||
time_t unionCP56TimetoTime_t(unionCP56Time* st);
|
||
unionCP56Time Time_ttounionCP56Time(time_t st);
|
||
QWORD getTimeInMs();
|
||
//////////////////////////////////////////////////////////////////////////
|
||
typedef enum
|
||
{
|
||
LOG_NULL = 0,
|
||
LOG_ERROR = 1,
|
||
LOG_WARN = 2,
|
||
LOG_INFO = 3,
|
||
LOG_DEBUG = 4
|
||
} eLogLevel;
|
||
|
||
#ifdef __cplusplus
|
||
extern "C"
|
||
{
|
||
#endif
|
||
void yk(void);
|
||
void yt(void);
|
||
void dumpLogs(void);
|
||
BOOLEAN initialize_system(BOOLEAN, BOOLEAN, const char*, char*);
|
||
BOOLEAN initialize_thread(void);
|
||
BOOLEAN destroy_thread(void);
|
||
BOOLEAN WriteDatabaseCFG(void);
|
||
BOOLEAN WriteSystemCFG(void);
|
||
BOOLEAN WriteStaticUnitCFG(void);
|
||
BOOLEAN ReadStaticUnitCFG(void);
|
||
void vLog(eLogLevel eLevel, const char* szFmt, ...);
|
||
#if 0
|
||
int validate_utf8(const char *str, int len);
|
||
int random_bytes(void *bytes, int count);
|
||
#endif
|
||
DWORD ReadMsgRingBuff(char *rbuff, DWORD len);
|
||
#ifdef __cplusplus
|
||
}
|
||
#endif
|
||
|
||
#endif //_ZJD_PUBLIC_DATA_H_
|
||
|