#include "ticket.h" static T_UINT32 ticket; //清空投票 void ticketReset(void){ int i; ticket=0; for(i=0;i=2){//延时2秒睡 sleepDlyTime=0; //开启下次唤醒的定时器,也就是发心跳的时刻即可 value=geMintWaitCnt(); if(value>0){ sleeptime=value*1000; snprintf(info, sizeof(info),"WaitEventTime:%d\r\n",value); outterInfo(info, strlen(info)); //wlog_info("lastSleepTime:%d",value); timeThread=LSAPI_OSI_ThreadCurrent(); if(NULL == ptimer_t) ptimer_t = LSAPI_OSI_TimerCreate(timeThread, Timeroutcallback, NULL); if(NULL != ptimer_t){ if(FALSE==LSAPI_OSI_TimerStart(ptimer_t, sleeptime)){ wlog_warn("sleep timer start failed"); goto TICKET_END; } }else{ wlog_warn("sleep timer create failed"); goto TICKET_END; } lastSleepTime=LSAPI_OSI_UpTime(); LSAPI_OSI_Event_t event = {}; timerSleepStatus=TRUE; while(1){ LSAPI_OSI_EventWait(timeThread, &event); if(event.id==USER_EVENT_TIMEOUT) break; } value=(LSAPI_OSI_UpTime()-lastSleepTime)/1000; ticketReset(); timerSleepStatus=FALSE; //检测是否为负值,是否有可能获取时间的API会出现异常,导致出现负值,如果是负值,则使用sleeptime,可能有一秒误差,但没关系 if(value<0) value=sleeptime/1000;//fanghu addWaitCnt(value);//更新相关计数器 } } } TICKET_END: PTTimerStart(ptPool, &ptTimer,100);//need set to 1 seconds PT_WAIT_UNTIL(pt, PTTimerIsExpired(&ptTimer)); } PT_END(pt); } static T_INT32 geMintWaitCnt(void){ //获取所有计数器,并得出最小值 #define VALUE_SIZE 6 T_INT32 value[VALUE_SIZE],temp,i; temp=NO_SLEEP_TIME; for(i=0;itemp)?temp:value[i]; } return temp; } static void addWaitCnt(T_INT32 value){ //更新所有计数器值 authLoginCntUpdate(value); miapCntUpdate(value); locationCntUpdate(value); //gnss,near使用的是本地时间,不需要更新 heartCntUpdate(value); } /*定时显示一下票箱状态*/ void ticketStatusShow(void){ static unsigned char cnt=0; char info[100]="TICKET:"; char tbuf[10]; unsigned char i; if(cnt==0){ if(ticket==0) wlog_info("TICKET:Idle"); else{ for(i=TICKET_PT_DOMAIN;i=10) cnt=0;//10秒打印一次 }