📄 centerinterface.c
字号:
#include "typedef.h"
#include "global.h"
#include <string.h>
#include "common_function.h"
#include "menubuffer.h"
#include "nvram.h"
#include "message.h"
#include "Trans_process.h"
extern xdata SYSTEM_INFO systemInfo;
extern xdata STATION_TONE stationTone[128];//上下行车站数据
extern xdata BUS_INFO busInfo;//线路当前信息
extern xdata TERM_PARA termPara;//线路参数
extern xdata SIMCARD_INFO simInfo;
/*func2,该函数被*/
void get_cur_tranStation(unsigned char *value)
{
*value = busInfo.tranCurStation;
}
/*****************************************************
*获取站台ID
*station 1~128;func2
******************************************************/
void get_station_id(unsigned char station, unsigned char *value)
{
memcpy(value, stationTone[station-1].id, MAX_STATIONID_SIZE);
}
/*向指定的3字节内存填入当前日期,顺序为年月日;func2*/
void get_term_data(unsigned char *value)
{
unsigned char *ptr;
ptr = value;
*ptr++ = bin2bcd(systemInfo.year);
*ptr++ = bin2bcd(systemInfo.mon);
*ptr++ = bin2bcd(systemInfo.day);
}
/*本函数为获取原分体机中的终端参数;在一体机中可能需要改变!!!
func2,这里TERM_PARA也要重新定义*/
//TERM_PARA* get_termpara()
/*获取终端当前装载的6条线路*/
void get_lineIDloaded(unsigned char* value)
{
unsigned int i;
for (i=0; i<6; i++)
{
memcpy(value, termPara.line[i].lineID, 4);
value += 4;
}
}
/*SIMCARD_INFO需要定义 func2*/
SIMCARD_INFO* get_simcard()
{
return &simInfo;
}
/*nlen:为 pValue的长度*/
/*关键数据区域的写,需要加上有效标志*/
void save_to_keyArea(unsigned char cmdId, unsigned char *pValue, unsigned char nlen)
{
/* unsigned char tmpBuf[4];
unsigned char i;
tmpBuf[0] = 0x58;
tmpBuf[1] = 0x76;
for (i=0; i<nlen; i++)
tmpBuf[2+i] = *(pValue+i);
nvram_write(cmdId, tmpBuf);*/
}
void set_keyArea_value(unsigned int v1, unsigned char v2, unsigned char v3, unsigned char v4)
{
unsigned char tmpBuf[7];
systemInfo.autoSendTime = v1;
systemInfo.onlineTime = v2;
systemInfo.arriveMeter = v3;
systemInfo.leftMeter = v4;
tmpBuf[0] = 0x56;
tmpBuf[1] = 0x78;
memcpy(tmpBuf+2, (unsigned char*)(&v1), 2);
tmpBuf[4] = v2;
tmpBuf[5] = v3;
tmpBuf[6] = v4;
nvram_write(NVRAM_AUTO_SEND, tmpBuf);
}
void set_online_time(unsigned char *value)
{
systemInfo.onlineTime = *value;
save_to_keyArea(NVRAM_ONLINE, value, 1);
}
void set_arrive_meter(unsigned char *value)
{
systemInfo.arriveMeter = *value;
//需要增加写E2
save_to_keyArea(NVRAM_ARRIVE_METER, value, 1);
}
void set_left_meter(unsigned char *value)
{
systemInfo.leftMeter = *value;
//需要增加写E2
save_to_keyArea(NVRAM_LEFT_METER, value, 1);
}
void set_auto_time(unsigned int *value)
{
systemInfo.autoSendTime = *value;
save_to_keyArea(NVRAM_AUTO_SEND, value, 2);//save_to_keyArea(NVRAM_AUTO_SEND, (unsigned char*)value, 2);
}
/*获取线路ID,func2*/
void get_line_id(unsigned char *value)
{
memcpy(value, busInfo.id, 4);
}
/*心跳间隔,func2*/
void get_online_time(unsigned char *value)
{
*value = systemInfo.onlineTime;
}
/*GPS发送间隔,func2*/
void get_auto_time(unsigned int *value)
{
*value = systemInfo.autoSendTime;
}
/*设置运营或非运营,func2*/
void set_work_state(unsigned char *value)
{
systemInfo.runMode = *value;
}
/*将中心返回的登陆信息的应答填充到formatbuffer中*/
void set_loginmsg_response(Byte msgLen, Byte* msgPtr, Word msgID)
{
FORMAT_BUFFER* pBuffer;
SET_WORKSTATUS* pStatus;
pBuffer = get_format_buffer();
set_formatbuffer_status(RESPONSE_VALID);
pBuffer->id = msgID;
pStatus = (SET_WORKSTATUS*)(pBuffer->buf);
*(msgPtr+msgLen) = 0;
pStatus->len = message_convert_tolength(pStatus->content, msgPtr+1);
pStatus->status = *msgPtr;
}
void set_telephone_list(unsigned char *value)
{
nvram_write(NVRAM_TELEPHONE_LIST, value);
}
void workState_porcess(void)
{
static char data timeCount=0;
if(0 == systemInfo.landFlag)//( systemInfo.runMode == RUN_NOSTATUS )
{
timeCount ++;
if( timeCount >= 15 )
{
timeCount = 0;
//查看是否已经正确获取到了终端参数
if (simInfo.validFlag == TERM_PARA_VALID)
make_assess_message(6);
}
}
else
timeCount = 15;//这样只要发现中途要注册,则马上注册
}
void set_menucurspeed(Uint16 value)
{
Uint32 tmp32;
tmp32 = value;
tmp32 = tmp32*37;
tmp32 /= 2000;
systemInfo.curSpeed = tmp32;
}
Byte get_menucurspeed()
{
return systemInfo.curSpeed;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -