📄 common.h
字号:
#ifndef _COMMON_H_
#define _COMMON_H_
#include <conio.h>
#include <bios.h>
#include <dos.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <stdarg.h>
#include <process.h>
#include "sc_cfg.h"
#define OS_ENTER_CRITICAL() asm CLI
#define OS_EXIT_CRITICAL() asm STI
#define MPCMIC 0
#define MPC104 1
#define UPARR 0x4800
#define DNARR 0x5000
#define ESC 0x011b
#define RTARR 0x4d00
#define LTARR 0x4b00
#define PGUP 0x4900
#define PGDN 0x5100
#define HOME 0x4700
#define END 0x4F00
#define ENTER 0x1c0d
#define F1 0x3b00
#define F2 0x3c00
#define F3 0x3d00
#define F4 0x3e00
#define F5 0x3f00
#define F6 0x4000
#define F7 0x4100
#define F8 0x4200
#define F9 0x4300
#define F10 0x4400
#define F12 0x8600
#define BACKSP 0x0e08
#define POINT 0x342e
// protocol identifier
#define NEW_BB_CDT 0x00 //
#define LFP 0x01 //
#define IEC101 0x02 //
#define IEC102 0x03 //
#define IEC103 0x04
#define GPS 0x05 //GPS
#define DL645 0x06
#define DCMODBUS 0x07
#define MODBUS 0x08
#define SPABUS 0x09
#define GST 0x0a
#define TTC31X 0x0b
#define DCJZ 0x0c // jiu zhou dian qi
#define STMODBUS 0x0d // standard modicon modbus
#define DISA 0x0e // disa3
// port identifier
#define PORT0 0
#define PORT1 1
#define PORT2 2
#define PORT3 3
#define PORT4 4
#define PORT5 5
#define PORT6 6
#define PORT7 7
#define PORT8 8
#define PORT9 9
#define PORT10 10
#define PORT11 11
#define PORT12 12
#define PORT13 13
#define PORT14 14
#define PORT15 15
#define BOARD_SOURCE 100
#define WINDOW 255
typedef unsigned char INT8U;
typedef unsigned int INT16U;
typedef unsigned long INT32U;
typedef unsigned char BOOLEAN;
#define TRUE 1
#define FALSE 0
typedef struct {
INT16U year;
INT16U month;
INT16U day;
INT16U weekday;
INT16U hour;
INT16U minute;
INT16U second;
INT16U msecond;
} sclock; // clock struct to give system time
// dprintf() use struct
typedef struct {
INT8U x;
INT8U y;
INT8U color;
} tpattern_t;
//-----------------------
// uart receive buffer
typedef struct {
int count;
int start;
int next;
int size;
INT8U buf[RX_COM_BUF_SIZE];
} rxring_t;
//---------------------
// uart transfer buffer
typedef struct {
int count;
int curptr;
BOOLEAN flaguse;
int size;
INT8U buf[TX_COM_BUF_SIZE];
} txring_t;
//---------------------
// store scada data
typedef struct {
INT16U Yx[MAX_YX_LIMIT / 16];
INT16U Yc[MAX_YC_LIMIT];
INT32U Ym[MAX_YM_LIMIT];
} memdb_data_t;
//-------------------
typedef struct {
INT16U address;
INT8U intno;
} hardset_t; // hardware set
typedef struct {
BOOLEAN dispkeyflag;
BOOLEAN keyinstate;
BOOLEAN keyinover;
INT8U lenlimit;
INT8U size;
char count;
INT8U keybuf[KEYIN_BUF_SIZE];
} keyin_buf_t;
typedef struct {
INT16U Baud;
INT8U DataBit;
INT8U StopBit;
INT8U Parity;
INT8U Protocol;
INT8U DevStartAddr;
INT8U DevEndAddr;
BOOLEAN isWork;
BOOLEAN isReady;
INT16U BaseAddr;
} PortSet_t;
//-------------------------
// message window control struct
typedef struct {
BOOLEAN displaymode;
BOOLEAN pause_flag;
BOOLEAN win_update;
BOOLEAN poll;
char win_type;
char port_no;
INT8U xmax;
INT8U tymax;
INT8U rymax;
INT8U xmin;
INT8U tymin;
INT8U rymin;
INT8U tx; // cdt send cursor x polling cursor x
INT8U ty; // cdt send cursor y polling cursor y
INT8U rx; // cdt receive cursor x
INT8U ry; // cdt receive cursor y
} message_win_t;
//----------------------------------
typedef struct {
sclock clk;
BOOLEAN checktimeflag;
} check_time_t;
typedef struct {
INT8U state;
INT8U readobj;
} pcheck_t;
// record soe infomation
typedef struct {
INT8U day;
INT8U hour;
INT8U minute;
INT8U second;
INT16U msecond;
INT16U status_switch_no;
} soe_record_t;
//----------------------
// buffer soe and send
typedef struct {
INT16U count[MAX_PORT];
INT16U size;
INT16U read[MAX_PORT];
INT16U write;
soe_record_t buf[SOE_BUF_SIZE];
} soe_buf_t;
//---------------------------------
// record yx change infomation used in nbb protocol
typedef struct {
INT8U func_code;
INT16U yx_code[2];
} yxbw_record_t;
//-------------------------------------------------
// buffer yx change status and send in nbb protocol
typedef struct {
INT16U count[MAX_PORT];
INT16U size;
INT16U read[MAX_PORT];
INT16U write;
yxbw_record_t buf[YXBW_BUF_SIZE];
} yxbw_buf_t;
//-----------------------------------------------
typedef struct {
char pwd[6];
INT8U ykobj;
INT8U ykcmd;
BOOLEAN preset;
BOOLEAN exec;
BOOLEAN esc;
INT8U checkresult; //=0x55:no in =0xcc ok =0x33 error
BOOLEAN useflag;
BOOLEAN pwdokflag;
} yk_display_t;
#define YKCCLOSE 0xcc
#define YKCTRIP 0x33
#define YKCEXEC 0xaa
#define YKCESC 0x55
#define YKCNONE 0x00
#define YKRNONE 0x55
#define YKROK 0xcc
#define YKRERROR 0x33
#define YKRTOUT 0xaa
typedef struct {
// properties
// 0-255
INT8U ykobj;
// CLOSE=cc, TRIP=33
INT8U ykcmd;
// EXEC=aa, ESC=55
INT8U ykexecmd;
// yk process state
INT8U ykstate;
//YKSNONE 0x33 YKSPRESET 0xcc YKSEXEC 0xaa YKSESC 0x55
// yk timer
INT16U timer;
// yk timer up limit
INT16U timerlimit;
// check result of yk
INT8U ykcheckresult;
//YKRNONE 0x55 YKROK 0xcc YKRERROR 0x33 YKRTOUT 0xaa
// p1-p8 window
INT8U yksrc;
// board port two type
INT8U ykexeman;
// yk status of progress
BOOLEAN doing;
// yk ret = TRUE else FALSE
BOOLEAN retflag;
} yk_register_t;
typedef struct {
INT8U ykobj;
INT8U ykcmd;
BOOLEAN noerr;
} yk_preset_err_t;
typedef struct {
INT8U yk_cmd;
INT8U dev_no;
INT8U type;
INT8U yk_no;
INT8U yk_des;
INT8U check_result;
BOOLEAN Y_PRESET;
BOOLEAN Y_CHECK;
BOOLEAN Y_EXEC;
BOOLEAN Y_ESC;
} port_yk_info_t;
typedef struct {
INT8U portno;
INT8U devno;
INT8U type;
INT16U info;
BOOLEAN reset;
INT8U channel;
} YxDefine_t;
typedef struct {
INT8U portno;
INT8U devno;
INT8U type;
INT16U info;
INT8U order;
} YcDefine_t;
typedef struct {
INT8U portno;
INT8U devno;
INT8U type;
INT16U info;
INT8U datalen;
} YmDefine_t;
typedef struct {
INT8U portno;
INT8U devno;
INT8U type;
INT16U info;
} YkDefine_t;
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -