📄 common.h
字号:
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// File name common.h
// Defined all type and structures used by many process
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <conio.h>
#include <bios.h>
#include <dos.h>
#include <stdio.h>
#include <math.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <iostream.h>
#include <time.h>
#include <ctype.h>
typedef unsigned char INT8U;
typedef unsigned int INT16U;
typedef unsigned long INT32U;
typedef unsigned int BYTE;
typedef unsigned int WORD;
typedef unsigned long DWORD;
typedef unsigned char BOOLEAN;
typedef struct {WORD Yx[32];WORD Yc[256];DWORD Ym[128];} sportdata;
// BOOLEAN enum //
#define TRUE 1
#define FALSE 0
#define ON 0xaa
#define OFF 0x55
//below is used in mainprog.cpp and windows.cpp
#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
#define OPTIONS 0
#define INFO 1
#define LOCALFUNC 2
#define STATE 3
#define FORMS 4
#define HELP 5
/* bauderate */
#define B50 0x00
#define B75 0x01
#define B110 0x02
#define B134 0x03
#define B150 0x04
#define B300 0x05
#define B600 0x06
#define B1200 0x07
#define B1800 0x08
#define B2400 0x09
#define B4800 0x0a
#define B7200 0x0b
#define B9600 0x0c
#define B19200 0x0d
#define B38400 0x0e
#define B57600 0x0f
#define B115200 0x10
/* data bite */
#define BIT_5 0
#define BIT_6 1
#define BIT_7 2
#define BIT_8 3
/* stop bite */
#define STOP_1 0
#define STOP_15 1
#define STOP_2 2
//Parity Values
#define PARITY_EVEN 0
#define PARITY_ODD 1
#define PARITY_NONE 2
/* Xon/Xoff */
#define Xon 0x00
#define Xoff 0x01
// protocol identifier //
#define NEW_BB_CDT 0x00 //NBB
#define WUHAN_CDT 0x01 //WUHAN
#define YANTAI_CDT 0x02 //YANTAI
#define XINAN_CDT 0x03 //XIAN
#define HUABEI_CDT 0x04 //HUABEI
#define U4F 0x05 //U4F
#define CDC8890 0x06 //8890
#define MB88 0x07 //MB88
#define SC1801 0x08 //1801
#define HDLC_SDLC 0x09 //HDLC
#define GPS 0x0a //GPS
#define ISA 0x0b //ISA
#define DFP201 0x0c //DFP201
#define DFP500 0x0d //DFP500
#define BASLER 0x0e //BASLER
#define WEISHENG 0x0f //WSDNB
#define LFP 0x12 //LFP
#define ZLP 0x11
#define ACSAMPLE 0x13 //AC485 or AC422 for AC Sample
// port identifier //
#define PORT1 0
#define PORT2 1
#define PORT3 2
#define PORT4 3
#define PORT5 4 //GGG5.12
#define PORT6 5
#define PORT7 6
#define PORT8 7
#define COM1 8
#define COM2 9
#define CAN1 10
#define CAN2 11
#define POSITIVE 0x55
#define MINUS 0xaa
#define EQUAL 0x00
// time value
#define WAIT2US 320 // 320 in mmx266; 80 in dx100
// max board number
#define DEVICENUM 30
#define MAXYXBOARD 16
#define MAXYCBOARD 4
#define MAXYMBOARD 4
#define TOTALPORTNO 8
#define MAXPORTNO 10
#define MAXYXNO 1024
#define MAXYCNO 512
#define MAXYMNO 128
#define MAXYKNO 256
#define MAXBOARDYX 512
#define MAXBOARDYC 256
#define MAXBOARDYM 128
#define MAXBOARDYK 128
// card base address
#define BP3724 0x02d0
#define BP36401 0x0200
#define BP36402 0x0340
#define BP3718 0x0300
#define BPDMU 0xdc00
// card interrupt no
#define I36401 10
#define I36402 15
#define I3718 7
// card nick name
#define C3724 2
#define C36401 0
#define C36402 1
#define C3718 3
#define RINGSIZE 256
#define SOEBUFSIZE 256
#define YXBWBUFSIZE 256
//below is used in comm.h
struct ring_t //used in comm.cpp nbb.cpp type is defined for defined inring[] and outring[]
{
int count; //number of chars now in the buffer
int start; //where next character can be retrieved
int cnext; //where next character can be stored
int size; //size of the buffer
INT8U buffer[RINGSIZE]; //address of the character buffer
};//struct ring_t //used in comm.cpp nbb.cpp
//below used in winows.cpp
struct hardset_t
{
BOOLEAN state;
unsigned int address;
unsigned int intno;
unsigned int xk4; //hardwareset[1] [2] :intregadd
unsigned int yt2;
unsigned int yk8;
};//struct test_para_t
extern struct hardset_t hardwareset[7];
//hardware[0]:DMU_PC hardware[1]: MoxaCard1 hardware[2]: MoxaCard2
//hardware[3]:DI_Card hardware[4]: DO_Card1 hardware[5]: DO_Card2
//hardware[6]:A/D_Card
//below used in winows.cpp
struct portset_t
{
BYTE BaudRate;
BYTE DataBits;
BYTE StopBits;
BYTE Parity;
BYTE AC_sample;
BYTE protocol;
BYTE len_a;
BYTE len_b;
BYTE len_c;
BYTE len_d1;
BYTE len_d2;
BYTE start_address; //protection start address
BYTE mon_num; //if a protection
BOOLEAN ext_flag; //extending or not
BYTE query_gap; //in second
BYTE chk_time_gap; //in second
};//struct portset_t
extern struct portset_t port_set[10];
//above used in winows.cpp
//below used in windows.cpp
struct datasource_t
{
unsigned int total_yx; //0 143
unsigned int dmusub_yx; //not compress
unsigned int dmustate_yx;
unsigned int board_yx; //not compress
unsigned int protect_yx;
unsigned int zlp_yx;
unsigned int zlp_yc;
unsigned int dnb_ym;
unsigned int protect_yk;
unsigned int total_yc;
unsigned int port_yc;
unsigned int dmuyt_yc;
unsigned int board_yc;
unsigned int protect_yc;
unsigned int total_ym;
unsigned int dmu_ym;
unsigned int board_ym;
unsigned int port_ym;
unsigned int total_yk;
unsigned int dmu_yk;
unsigned int board_yk;
unsigned int yk_escape_time;
unsigned int lfp_yk;
unsigned int basleryxnum;
unsigned int basleryxstartno; // 19 162
};//struct datasource_t
extern struct datasource_t datasource;
struct diagnose_t
{
int dmupc;
int moxa1;
int moxa2;
int di;
int do1;
int do2;
int ad; //0xcc OK 0x33 error //0x55 none
int port[10];
};//struct diagnose_t
extern struct diagnose_t diag_result;
struct message_buf_t
{
int bytenum;
int rstart;
int rnext;
int rcount;
int rsize;
int rx;
int ry;
BYTE rbuff[512];
int tstart;
int tnext;
int tcount;
int tsize;
int tx;
int ty;
BYTE tbuff[512];
};//struct message_buf_t
extern struct message_buf_t message_buf;
struct check_time_t
{
int portno;
struct date d;
struct time t;
BOOLEAN checktimeflag;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -