📄 zjpro.h
字号:
typedef unsigned char uint8;
typedef unsigned int uint16;
typedef unsigned long uint32;
typedef signed char int8;
typedef signed int int16;
typedef signed long int32;
extern struct RTCTime
{
unsigned char rYear; // 年
unsigned char rMonth; // 月
unsigned char rDate; // 日
unsigned char rHour; // 时
unsigned char rMinute; // 分
unsigned char rSecond; // 秒
unsigned char rWeek; // 周
};
extern void SetRTCTime(struct RTCTime);
#define UARTADDR 0x2827 // uart2-0x2827,uart3-0x282f,uart4-0x2837,uart5-0x283f
#define UARTSERI 2
// 收发缓存长度定义
#define UBUFFLEN 40 // 全局缓存长度定义
uint8 ProBuff[UBUFFLEN];
#define DEFRBUFF 0
#define DEFTBUFF 0
typedef struct BuffRam
{
uint8 xdata *buffadd;
uint8 bufflen;
uint8 buffplen;
uint8 xdata *pbuff; // 查询指针
// uint8 xdata *rpbuff; // 接受指针
}BUFFRAM;
BUFFRAM xdata Ubuff[1];
typedef union Drive1107
{
struct _drive
{
unsigned FRBA : 1; // 接受缓存标记 0正确,1数据缓存满
unsigned FTB : 1; // 发送缓存标记 0正确,1数据缓存满
unsigned FByte : 1; // 字节校验错标记 0正确,1错误
unsigned FBOT : 1; // 字节超时标记位 0正确,1超时
unsigned FFOT : 1; // 帧超时标记位 0正确,1超时
unsigned UMOD : 3; // 串口通讯模式 0等待,1接受,2发送,3切换准备,4接受完毕
unsigned RBPS : 4; // 电表建议通讯波特率 0-300,1-600,2-1200,3-2400,4-4800,5-9600
unsigned CBPS : 4; // 电表当前使用波特率 0-300,1-600,2-1200,3-2400,4-4800,5-9600
}bits;
uint16 value;
}DRIVE1107;
DRIVE1107 UDS; // universal driver state
typedef struct ProCot
{
uint8 MeterSeri[6]; // 通讯表号
uint8 CtrlByte; // 控制字
uint8 Lenth; // 数据域长度
uint8 xdata *pd; // 数据域首地址指针
}PROCOT;
PROCOT xdata InterPro;
uint8 ERROR_FLG;
typedef struct Iec645
{
uint16 OutsideInst; // 外部数据标识
uint16 InterInst; // 内部协议ID号
uint8 DLen; // 数据项长度
// uint8 IA; // 指令类型(1--清零,否则为0)
uint16 DAddr; // 数据存放地址(读地址)
// uint16 WAddrA; // 写地址1
// uint16 WAddrB; // 写地址2
// union _I07
// {
// struct _Is07
// {
// unsigned DT : 1; // 数据格式 0-ascii,1-BCD
// unsigned DAT : 2; // 数据地址类型 0-FLASH,1-RAM,2-EEPROM,3-自定义
// unsigned RWA : 2; // 数据读写属性 0-可读可写,1-只读,2-只写
// unsigned FA : 3; // 小数点位置 0-无小数点,1~7依次表示1~7位小数
// }bits;
// uint8 value;
// }US;
}IEC645;
typedef union InterProDataFlag
{
uint16 value;
struct _itp
{
unsigned FC : 4; // Fee Catalog费率项
unsigned HD : 4; // Historic Data历史数据
unsigned PC : 4; // Power Catalog供电方向
unsigned AC : 2; // Attribute Catalog有无功
unsigned DC : 2; // Data Catalog数据类型
}bits;
}IPDF;
typedef struct InterPro
{
uint8 CtrlByte; // 控制字
IPDF DF; // 数据标识
uint8 xdata *pbuff; // 数据指针
uint8 bufflen; // 数据长度
}ITP;
ITP InstPro; // 内部指令协议结构体(传递信息)
uint8 xdata MeterCode[4];
#define MSANo 2
uint8 code MSAccess[MSANo][6]=
{
0x99,0x99,0x99,0x99,0x99,0x99,
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA
};
uint8 xdata MeterSeri[6] = {0x99,0x99,0x99,0x99,0x99,0x99};
struct RTCTime pSetRTC;
#define TABLENUMBER 85
IEC645 code InstList[TABLENUMBER] =
{
0x32c0,0x8200, 6,MeterSeri,//0,0,0,0,
0x1090,0x8202, 4,0x0000,//0,0,0,0,
0x1094,0x8003, 4,0x0001,//0,0,0,0,
0x1f98,0x8400,20,0x0120,//0,0,0,0,
0x1098,0x8000, 4,0x2010,//0,0,0,0,
0x1f90,0xc000,20,0x0012,//0,0,0,0,
0x10a0,0xabcd, 3,0x0023,
0x1fa0,0xabcd,15,0x0023,
0x10a4,0xabcd, 3,0x0023,
0x10a8,0xabcd, 3,0x0023,
0x1fa4,0xabcd,15,0x0023,
0x1fa8,0xabcd,15,0x0023,
0x17c1,0xabcd, 2,0x0023,
0x19c1,0xabcd, 4,0x0023,
0x30c0,0xabcd, 3,0x0023,
0x1f94,0xabcd,20,0x0023,
0x10b0,0xabcd, 4,0x0023,
0x1fb0,0xabcd,20,0x0023,
0x10b4,0xabcd, 4,0x0023,
0x1fb4,0xabcd,20,0x0023,
0x10b8,0xabcd, 4,0x0023,
0x1fb8,0xabcd,20,0x0023,
0x10c0,0xabcd, 4,0x0023,
0x10b2,0xabcd, 4,0x0023,
0x11c0,0xabcd, 3,0x0023,
0x15c1,0xabcd, 1,0x0023,
0x3ac0,0xabcd, 1,0x0023,
0xc1c8,0xabcd, 1,0x0023,
0x2090,0xabcd, 4,0x0023,
0xe0c8,0xabcd, 4,0x0023,
0xe1c8,0xabcd, 4,0x0023,
0xe2c8,0xabcd, 4,0x0023,
0xe3c8,0xabcd, 5,0x0023,
0xe4c8,0xabcd, 5,0x0023,
0xe5c8,0xabcd, 5,0x0023,
0xe6c8,0xabcd, 3,0x0023,
0x20b3,0xabcd, 3,0x0023,
0x50b3,0xabcd, 4,0x0023,
0xf0c8,0xabcd,15,0x0023,
0xf1c8,0xabcd,15,0x0023,
0xf2c8,0xabcd,15,0x0023,
0xf3c8,0xabcd,15,0x0023,
0xf4c8,0xabcd,15,0x0023,
0xf5c8,0xabcd,15,0x0023,
0xf6c8,0xabcd,15,0x0023,
0xf7c8,0xabcd,15,0x0023,
0xf8c8,0xabcd,15,0x0023,
0xf9c8,0xabcd,15,0x0023,
0xf0c9,0xabcd,15,0x0023,
0xf1c9,0xabcd,15,0x0023,
0xf2c9,0xabcd,15,0x0023,
0xf3c9,0xabcd,15,0x0023,
0xf4c9,0xabcd,15,0x0023,
0xf5c9,0xabcd,15,0x0023,
0xf6c9,0xabcd,15,0x0023,
0xf7c9,0xabcd,15,0x0023,
0xf8c9,0xabcd,15,0x0023,
0xf9c9,0xabcd,15,0x0023,
0x20cf,0xabcd, 7,0x0023,
0x21cf,0xabcd, 7,0x0023,
0x22cf,0xabcd, 7,0x0023,
0x10cf,0xabcd, 4,0x0023,
0x11cf,0xabcd, 3,0x0023,
0x12cf,0xabcd, 4,0x0023,
0x13cf,0xabcd, 3,0x0023,
0x14cf,0xabcd, 4,0x0023,
0x15cf,0xabcd, 3,0x0023,
0x16cf,0xabcd, 5,0x0023,
0x17cf,0xabcd, 5,0x0023,
0x18cf,0xabcd, 5,0x0023,
0x19cf,0xabcd, 5,0x0023,
0x1acf,0xabcd, 5,0x0023,
0x1bcf,0xabcd, 5,0x0023,
0x22d1,0xabcd,20,0x0023,
0x23d1,0xabcd,20,0x0023,
0x24d1,0xabcd,20,0x0023,
0x25d1,0xabcd,20,0x0023,
0x26d1,0xabcd,20,0x0023,
0x27d1,0xabcd,20,0x0023,
0x28d1,0xabcd,20,0x0023,
0x29d1,0xabcd,20,0x0023,
0x2ad1,0xabcd,20,0x0023,
0x13e8,0xabcd, 1,0x0023,
0x14e8,0xabcd, 1,0x0023,
0xe0ee,0xabcd, 1,0x0023
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -