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.
314 lines
8.3 KiB
314 lines
8.3 KiB
#include "app_common.h"
|
|
#include "../clib/md5.h"
|
|
#include "../msp/uart0.h"
|
|
#include "../msp/uart2.h"
|
|
#include "../app/app_task_gm35.h"
|
|
#include "../app/app_paraid.h"
|
|
#include "../app/app_task_relay.h"
|
|
|
|
struct printer_maintenance_global G;
|
|
U8 ccmodbus_len = 0;
|
|
|
|
#define KEY_RFID_MAP_SIZE 30
|
|
U32 code key_rfid_map[KEY_RFID_MAP_SIZE] =
|
|
{
|
|
/// key, rfid
|
|
//0x01,1, ///S1 ///key_map[0] key_map[1]
|
|
//0x02,11, ///S2 ///key_map[n] key_map[n+1]
|
|
0x02,0x02000020, ///呼叫 S2
|
|
0x12,0x02000001, ///分诊 S12
|
|
0x03,0x03010301, ///一线 S3 医生1
|
|
0x03,0x03010302, ///一线 S3 医生2
|
|
0x16,0x02000059, ///采血 S13
|
|
0x04,0x02000025, ///心电 S4
|
|
0x17,0x02000003, ///CT S14
|
|
0x08,0x03020301, ///二线 S5 医生1
|
|
0x08,0x03020302, ///二线 S5 医生2
|
|
0x18,0x01000008, ///谈话 S15
|
|
0x09,0x01000009, ///签字 S6
|
|
0x1D,0x02000060, ///团注 S16
|
|
0x0A,0x02000005, ///介入 S7
|
|
0x1F,0x0100000C, ///置鞘(穿刺) S17
|
|
0x0B,0x02000023, ///病房 S8
|
|
//0x1d,9, ///S16
|
|
//0x1f,10, ///S17
|
|
//0x1e,0 /// 清零按键,无需亮灯
|
|
};
|
|
|
|
U32 key_rfid_map_out(U32 key)
|
|
{
|
|
U8 n;
|
|
for(n = 0; n < KEY_RFID_MAP_SIZE; n+=2)
|
|
{
|
|
if(key == key_rfid_map[n])
|
|
{
|
|
return key_rfid_map[n+1];
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
U32 rfid_key_map_out(U32 rfid)
|
|
{
|
|
U8 n;
|
|
for(n = 0; n < KEY_RFID_MAP_SIZE; n+=2)
|
|
{
|
|
if(rfid == key_rfid_map[n+1])
|
|
{
|
|
return key_rfid_map[n];
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
|
|
void L2_register_init()
|
|
{
|
|
U8 i = 0;
|
|
G.p.slaverId = 0x10;
|
|
G.p.wisdom_car_no = 0x93; //第一台车91,第二台车92
|
|
G.p.thrombolytic_ratio = 9; //0.9
|
|
G.p.bolus_ratio = 1; //0.9
|
|
G.p.hold_ratio = 9; //0.1
|
|
|
|
G.total_weight = 0;
|
|
G.pi_weight = 0;
|
|
G.jing_weight = 0;
|
|
G.thrombolytic_val = G.bolus_val = G.hold_val = 0;
|
|
G.asga.xaxis = G.asga.yaxis = G.asga.zaxis = 0;
|
|
G.rfidval = G.rfidHospitalNo = 0;
|
|
|
|
for(i=0;i<6;i++)
|
|
{
|
|
G.rfid[i] = 0;
|
|
}
|
|
|
|
for(i=0;i<MD_SLAVER_INFO_MAX;i++)
|
|
{
|
|
G.md_slaver_info[i].mask = 0;
|
|
}
|
|
G.md_slaver_info[0].slaver = SLAVER_DW20_ID;
|
|
G.md_slaver_info[0].oper = MODBUS_OPER_READ;
|
|
G.md_slaver_info[0].reg = 0x02;
|
|
G.md_slaver_info[0].regnum = 0x02;
|
|
G.md_slaver_info[0].mask = 2; //0->无效 1:暂时有效 2->永久有效
|
|
|
|
G.md_slaver_info[1].slaver = SLAVER_ASGA03_ID; //倾角XYZ
|
|
G.md_slaver_info[1].oper = MODBUS_OPER_READ;
|
|
G.md_slaver_info[1].reg = 0x04;
|
|
G.md_slaver_info[1].regnum = 0x03;
|
|
G.md_slaver_info[1].mask = 2;
|
|
|
|
G.md_slaver_info[2].slaver = SLAVER_SHOW01_ID; //重量2,溶栓,团注,维��?
|
|
G.md_slaver_info[2].oper = MODBUS_OPER_WRITE_M;
|
|
G.md_slaver_info[2].reg = 0x02;
|
|
G.md_slaver_info[2].regnum = 0x05;
|
|
G.md_slaver_info[2].bytes = G.md_slaver_info[2].regnum * 2;
|
|
G.md_slaver_info[2].buf = (U8*)&G.jing_weight;
|
|
G.md_slaver_info[2].mask = 0;
|
|
|
|
G.md_slaver_info[3].slaver = SLAVER_SHOW01_ID; //RFID
|
|
G.md_slaver_info[3].oper = MODBUS_OPER_WRITE_M;
|
|
G.md_slaver_info[3].reg = 0x07;
|
|
G.md_slaver_info[3].regnum = 0x01;
|
|
G.md_slaver_info[3].bytes = G.md_slaver_info[3].regnum * 2;
|
|
G.md_slaver_info[3].buf = (U8*)&G._key;
|
|
G.md_slaver_info[3].mask = 0;
|
|
|
|
G.md_slaver_info[4].slaver = SLAVER_SHOW01_ID; //显示板按键
|
|
G.md_slaver_info[4].oper = MODBUS_OPER_READ;
|
|
G.md_slaver_info[4].reg = 0x08;
|
|
G.md_slaver_info[4].regnum = 0x01;
|
|
G.md_slaver_info[4].mask = 2;
|
|
|
|
G.md_slaver_info[5].slaver = SLAVER_ASGA03_UPDOWN_ID; //升降倾角
|
|
G.md_slaver_info[5].oper = MODBUS_OPER_READ;
|
|
G.md_slaver_info[5].reg = 0x04;
|
|
G.md_slaver_info[5].regnum = 0x03;
|
|
G.md_slaver_info[5].mask = 2;
|
|
|
|
for(i=0;i<CCMD_SLAVER_INFO_MAX;i++)
|
|
{
|
|
G.ccmd_slaver_info[i].mask = 0;
|
|
}
|
|
|
|
#if 0
|
|
G.ccmd_slaver_info[0].slaver = SLAVER_TCP_SERVER_ID; //服务��? //登陆包,写平车编��?
|
|
G.ccmd_slaver_info[0].oper = MODBUS_OPER_WRITE_M;
|
|
G.ccmd_slaver_info[0].reg = 0x01;
|
|
G.ccmd_slaver_info[0].regnum = 0x01;
|
|
G.ccmd_slaver_info[0].bytes = G.ccmd_slaver_info[0].regnum * 2;
|
|
G.ccmd_slaver_info[0].buf = (U8*)&G.p.wisdom_car_no;
|
|
G.ccmd_slaver_info[0].mask = 0;
|
|
#else
|
|
G.ccmd_slaver_info[0].slaver = SLAVER_TCP_SERVER_ID; //服务��? //登陆包,写平车编��?
|
|
G.ccmd_slaver_info[0].oper = MODBUS_OPER_AUTH;
|
|
G.ccmd_slaver_info[0].mask = 0;
|
|
#endif
|
|
G.ccmd_slaver_info[1].slaver = SLAVER_TCP_SERVER_ID; //服务��? //心跳包,写心跳寄存器
|
|
G.ccmd_slaver_info[1].oper = MODBUS_OPER_WRITE_M;
|
|
G.ccmd_slaver_info[1].reg = 0x02;
|
|
G.ccmd_slaver_info[1].regnum = 0x01;
|
|
G.ccmd_slaver_info[1].bytes = G.ccmd_slaver_info[1].regnum * 2;
|
|
G.ccmd_slaver_info[1].buf = (U8*)&G.p.reserved1;
|
|
G.ccmd_slaver_info[1].mask = 0;
|
|
|
|
G.ccmd_slaver_info[2].slaver = SLAVER_TCP_SERVER_ID; //服务��? //流程开始包
|
|
G.ccmd_slaver_info[2].oper = MODBUS_OPER_WRITE_M;
|
|
G.ccmd_slaver_info[2].reg = 0x03;
|
|
G.ccmd_slaver_info[2].regnum = 0x01;
|
|
G.ccmd_slaver_info[2].bytes = G.ccmd_slaver_info[2].regnum * 2;
|
|
G.ccmd_slaver_info[2].buf = (U8*)&G.flowStartVal;
|
|
G.ccmd_slaver_info[2].mask = 0;
|
|
|
|
G.ccmd_slaver_info[3].slaver = SLAVER_TCP_SERVER_ID; //服务��?
|
|
G.ccmd_slaver_info[3].oper = MODBUS_OPER_WRITE_M;
|
|
G.ccmd_slaver_info[3].reg = 0x10;
|
|
G.ccmd_slaver_info[3].regnum = 0x0B;
|
|
G.ccmd_slaver_info[3].bytes = G.ccmd_slaver_info[3].regnum * 2;
|
|
G.ccmd_slaver_info[3].buf = (U8*)&G.jing_weight;
|
|
G.ccmd_slaver_info[3].mask = 0;
|
|
|
|
G.modbusstmp = 0;
|
|
G.authed = 0;
|
|
G.flowStarted = 0;
|
|
G.flowStartVal = 1;
|
|
|
|
G._keyled = G._key = 0;
|
|
|
|
G.reset = 0;
|
|
G.debug = 0;
|
|
}
|
|
|
|
void L3_protocol_handler_uart0_fun(TS_PH3_ccmodbus *ccmodbus)
|
|
{
|
|
switch(ccmodbus->oper)
|
|
{
|
|
case OPER_SET_DEBUG:
|
|
G.debug = ccmodbus->buf[0];
|
|
break;
|
|
}
|
|
}
|
|
|
|
#if 0
|
|
void L3_protocol_handler_uart4_fun(U8 *pPara)
|
|
{
|
|
#if 0
|
|
if(g_at_send_status.module_ok == 0)
|
|
{
|
|
if(StrStartsWith(pPara,"OK")) //module ok
|
|
{
|
|
g_at_send_status.module_ok = 1;
|
|
}
|
|
}
|
|
else if(g_at_send_status.sim_ok == 0)
|
|
{
|
|
if(StrStartsWith(pPara,"+CCID")) //sim ok
|
|
{
|
|
L0_uart0_uc('s');
|
|
libc_memcpy(G.ccid,pPara+7,20);
|
|
g_at_send_status.sim_ok = 1;
|
|
}
|
|
}
|
|
else if(g_at_send_status.net_ok == 0)
|
|
{
|
|
if(StrStartsWith(pPara,"+CREG: 1,1")) //net ok
|
|
{
|
|
L0_uart0_uc('n');
|
|
g_at_send_status.net_ok = 1;
|
|
}
|
|
}
|
|
else if(g_at_send_status.gprs_ok == 0)
|
|
{
|
|
if(StrStartsWith(pPara,"+CGATT:1")) //gprs ok
|
|
{
|
|
L0_uart0_uc('g');
|
|
g_at_send_status.gprs_ok = 1;
|
|
}
|
|
}
|
|
else if(g_at_send_status.conn_ok == 0)
|
|
{
|
|
if(StrStartsWith(pPara,"ALREAY") || StrStartsWith(pPara,"CONNECT OK") /*|| StrStartsWith(pPara,"STATE:CONNECT OK")*/) //conn ok
|
|
{ //ALREAY CONNECT??????????????��???????????????????????��????????????????????��?��???????
|
|
|
|
L0_uart0_uc('c');
|
|
g_at_send_status.conn_ok = 1;
|
|
}
|
|
}
|
|
else if(g_at_send_status.conn_ok == 1)
|
|
{
|
|
if(StrStartsWith(pPara,"CLOSE") || StrStartsWith(pPara,"STATE:CLOSED")) //conn close //CLOSE OK / CLOSED
|
|
{
|
|
L0_uart0_uc('d');
|
|
g_at_send_status.conn_ok = 0;
|
|
g_at_send_status.tcp_close_stmp = s_nos_tick.t_1s;
|
|
}
|
|
}
|
|
#else
|
|
if(g_at_send_status.conn_ok == 0)
|
|
{
|
|
if(StrStartsWith(pPara,"CONNECT OK") || StrStartsWith(pPara,"STATE:CONNECT OK") /*|| StrStartsWith(pPara,"ALREAY")*/ ) //conn ok
|
|
{ //ALREAY CONNECT不需要判断了,使用AT+CTPSTATUS指令进行查询连接状态
|
|
|
|
L0_uart0_uc('c');
|
|
g_at_send_status.conn_ok = 1;
|
|
}
|
|
else if(g_at_send_status.module_ok == 0)
|
|
{
|
|
if(StrStartsWith(pPara,"OK")) //module ok
|
|
{
|
|
g_at_send_status.module_ok = 1;
|
|
}
|
|
}
|
|
else if(g_at_send_status.sim_ok == 0)
|
|
{
|
|
if(StrStartsWith(pPara,"+CCID")) //sim ok
|
|
{
|
|
L0_uart0_uc('s');
|
|
libc_memcpy(G.ccid,pPara+7,20);
|
|
getPwd(G.ccid, G.ccid_passwd);
|
|
g_at_send_status.sim_ok = 1;
|
|
}
|
|
}
|
|
else if(g_at_send_status.net_ok == 0)
|
|
{
|
|
if(StrStartsWith(pPara,"+CREG: 1,1")) //net ok
|
|
{
|
|
L0_uart0_uc('n');
|
|
g_at_send_status.net_ok = 1;
|
|
}
|
|
}
|
|
else if(g_at_send_status.gprs_ok == 0)
|
|
{
|
|
if(StrStartsWith(pPara,"+CGATT:1")) //gprs ok
|
|
{
|
|
L0_uart0_uc('g');
|
|
g_at_send_status.gprs_ok = 1;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if(StrStartsWith(pPara,"CLOSE") || StrStartsWith(pPara,"STATE:CLOSED")) //conn close //CLOSE OK / CLOSED
|
|
{
|
|
L0_uart0_uc('d');
|
|
g_at_send_status.conn_ok = 0;
|
|
}
|
|
}
|
|
#endif
|
|
}
|
|
#endif
|
|
|
|
void L2_do_board_reset(void)
|
|
{
|
|
G.reset = 1; //wdt stop feed
|
|
GM35_DISABLE(); //gm35 poweroff
|
|
}
|
|
|
|
void L2_do_gm35_reset(void)
|
|
{
|
|
GM35_DISABLE(); //gm35 poweroff
|
|
Lc_delay_ms(5000);
|
|
GM35_ENABLE();
|
|
}
|
|
|
|
|