You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
226 lines
4.4 KiB
226 lines
4.4 KiB
#ifndef _APP_COMMON_H
|
|
#define _APP_COMMON_H
|
|
|
|
#include "../clib/type.h"
|
|
#include "../tpc/tpc_uart.h"
|
|
#include "../tpc/tpc_modbus.h"
|
|
#include "../tpc/tpc_ccmodbus.h"
|
|
|
|
#define APP_VERSION_HEX 0x12 //高4位主版本,低4位次版本
|
|
|
|
// #define BOARD_MAIN03_A9
|
|
// #define BOARD_MAIN04_GM35
|
|
#define BOARD_MAIN04_GM35_M42
|
|
|
|
#ifdef BOARD_MAIN03_A9
|
|
#define APP_VERSION "MA10_A9_v2.0.6"
|
|
|
|
#elif defined BOARD_MAIN04_GM35
|
|
#define APP_VERSION "MA10_GM35_v2.0.6"
|
|
|
|
#elif defined BOARD_MAIN04_GM35_M42
|
|
#define APP_VERSION "MA10_GM35_v3.0.2"
|
|
|
|
#else
|
|
#define APP_VERSION "MA10_X_v2.0.6"
|
|
#endif
|
|
|
|
#define PAPER_BOX_NUM 3
|
|
#define RELAY_NUM 8
|
|
|
|
enum RunMode
|
|
{
|
|
MODE_RUN = 0x00,
|
|
MODE_DEBUG_COMMON = 0x01,
|
|
MODE_DEBUG_IR = 0x02,
|
|
MODE_DEBUG_GM35 = 0x03,
|
|
MODE_PAPER_CALIB = 0x04,
|
|
};
|
|
|
|
enum CCMODBUS_ADDR
|
|
{
|
|
ADDR_UPPER = 0x10,
|
|
ADDR_SERVER = 0x11,
|
|
ADDR_Maintenance = 0x12,
|
|
};
|
|
|
|
enum CCMODBUS_OPER
|
|
{
|
|
OPER_RELAY = 0x95,
|
|
OPER_REPORT = 0x93,
|
|
OPER_ISP = 0x80,
|
|
|
|
OPER_CALIB_MODE = 0x50,
|
|
OPER_CALIB = 0x51,
|
|
OPER_CALIB_READ = 0x52,
|
|
OPER_PAPER_COUNT = 0x53,
|
|
OPER_SET_485_ID = 0x54,
|
|
OPER_CALIB_LEAVE = 0x5a,
|
|
|
|
OPER_GPRS_HEART = 0x00,
|
|
// OPER_GPRS_ACK = 0x95,
|
|
OPER_GPRS_REPORT = 0x97,
|
|
};
|
|
|
|
enum TS_485_OPER
|
|
{
|
|
OPER_ANGLE_DAT = 0x90,
|
|
OPER_ANGLE_SET_ID = 0x91,
|
|
};
|
|
|
|
#define MASTER_ID 0x00
|
|
#define SLAVER_ID_MIN 0x01
|
|
#define SLAVER_ID_MAX 0x03
|
|
#define SLAVER_ID_N 0xee
|
|
|
|
typedef struct printer_paper
|
|
{
|
|
U8 version; //版本号(板卡对应版本号)APP_VERSION_HEX
|
|
vU16 paperNum:10; //10bit纸张数据 表示最大量程1024 实际170张
|
|
vU16 cameraIndex:4; //摄像头编号
|
|
vU16 cameraNotWorking:1; //是否正常工作
|
|
vU16 LowPower:1; // =1 lowPower 提醒需要充电,或者未连接电池
|
|
}TS_P_paper;
|
|
|
|
typedef struct boardstatus
|
|
{
|
|
U8 a9Status;
|
|
U8 a9RecvDataInterval;
|
|
U8 wdtStatus;
|
|
}TS_BoardStatus;
|
|
|
|
typedef struct printer_paper_calib
|
|
{
|
|
U16 num0; //x0
|
|
U16 angle0; //y0
|
|
U16 num1; //x1
|
|
U16 angle1; //y1
|
|
}TS_PaperCalib;
|
|
|
|
/**
|
|
* 用户协议
|
|
*/
|
|
//数据上报协议
|
|
typedef struct printer_report
|
|
{
|
|
TS_P_paper papers[PAPER_BOX_NUM-1];
|
|
TS_BoardStatus boardstatus;
|
|
U8 ir;
|
|
}TS_Printer_Report;
|
|
|
|
//校准协议
|
|
typedef struct
|
|
{
|
|
U8 no; //paper box no
|
|
U8 point; //校准点
|
|
U8 paperNum0; //当前纸张数量高位
|
|
U8 paperNum1; //当前纸张数量低位
|
|
}TS_Paper_Upper_Calib;
|
|
|
|
typedef struct
|
|
{
|
|
U8 no; //paper box no
|
|
}TS_Paper_Upper_Calib_Read;
|
|
|
|
typedef struct
|
|
{
|
|
U16 num0; //x0
|
|
U16 angle0; //y0
|
|
U16 num1; //x1
|
|
U16 angle1; //y1
|
|
}TS_Paper_Upper_calib_ack;
|
|
|
|
//读取当前纸张数量
|
|
typedef struct
|
|
{
|
|
U8 no; //paper box no
|
|
}TS_Paper_Count;
|
|
|
|
typedef struct
|
|
{
|
|
U8 no; //paper box no
|
|
U8 num[2]; //高位在前
|
|
}TS_Paper_Count_Ack;
|
|
|
|
//设置当前angle id
|
|
typedef struct
|
|
{
|
|
U8 id; //paper box no
|
|
}TS_Angle_SetId;
|
|
|
|
//gprs相关协议
|
|
typedef struct
|
|
{
|
|
U8 version;
|
|
}TS_gprs_heart;
|
|
|
|
/**
|
|
* Register Memory Map
|
|
*/
|
|
#define SLAVER_DW20_ID 0x11
|
|
#define SLAVER_ASGA03_ID 0x12
|
|
#define SLAVER_SHOW01_ID 0x13
|
|
#define SLAVER_TCP_SERVER_ID 0x14
|
|
|
|
#define MD_SLAVER_INFO_MAX 5
|
|
#define CCMD_SLAVER_INFO_MAX 4
|
|
|
|
//需要持久化的参数,不能超过72字节,否则会导致eeprom溢出
|
|
typedef struct global_param_changable
|
|
{
|
|
U16 slaverId; //从设备ID
|
|
U16 wisdom_car_no; //平车编号
|
|
U16 thrombolytic_ratio; //溶栓重量比 x 10
|
|
U16 bolus_ratio; //团注计量比 x 100
|
|
U16 hold_ratio; //维持计量比 x 100
|
|
U16 reserved1[16-5]; //保留
|
|
}GlobalNeedPersistParam;
|
|
|
|
typedef struct cc_asga_info
|
|
{
|
|
U16 xaxis;
|
|
U16 yaxis;
|
|
U16 zaxis;
|
|
}CCAsGaInfo;
|
|
|
|
typedef struct printer_maintenance_global
|
|
{
|
|
GlobalNeedPersistParam p;
|
|
|
|
S32 total_weight;
|
|
U16 thrombolytic_val;
|
|
U16 bolus_val;
|
|
U16 hold_val;
|
|
CCAsGaInfo asga;
|
|
U16 rfid;
|
|
S32 weight[4];
|
|
//U16 reserved2[16 - 9];
|
|
|
|
MD_SLAVER_INFO md_slaver_info[MD_SLAVER_INFO_MAX];
|
|
CCMD_SLAVER_INFO ccmd_slaver_info[CCMD_SLAVER_INFO_MAX];
|
|
|
|
vU32 modbusstmp;
|
|
U8 authed;
|
|
U8 flowStarted;
|
|
|
|
U8 ccid[21]; //保存ccid卡号空间 20+'\0'
|
|
TS_BoardStatus boardstatus;
|
|
U8 _keyled;
|
|
U8 _rfid;
|
|
}PMGlobal;
|
|
|
|
|
|
//寄存器内存基地址
|
|
#define REG_MEM_BASE ((U16*)(&G)) //寄存器基础地址(本文件外部不应该使用该宏定义)
|
|
//变量地址转寄存器
|
|
#define MEM_2_REG(mem) (((U16*)(mem) - REG_MEM_BASE))
|
|
//寄存器转变量地址
|
|
#define REG_2_MEM(reg) (REG_MEM_BASE + (U16)((reg))) //寄存及从0地址开始
|
|
|
|
|
|
extern struct printer_maintenance_global G;
|
|
extern void Lu_register_init(void);
|
|
extern void L3_protocol_handler_uart4_fun(U8 *pPara);
|
|
|
|
#endif
|
|
|
|
|