EXPORT_C TInt CComponentBase::CheckedRunError(TInt aError) { if (aError==KErrDiskFull || aError==KErrNoMemory) return KErrDiskFull; TUid uid; TInt id; TInt version; ComponentId(uid, id, version); iErrorCount++; CC_TRAPD(err, StopL()); if (err!=KErrNone || iErrorCount>MaxErrorCount()) { ComponentRecovery().ReportError(uid, id, ComponentErrorInfoMgr().GetLastErrorInfo(MakeErrorCode(uid.iUid, aError))); iActiveState=MRecovery::EFailed; ReportState(); ComponentAppContext().SetCurrentComponent(TUid::Uid(0), 0); return KErrNone; } iActiveState=MRecovery::ERestarting; iStatus=KRequestPending; Cancel(); SetActive(); iTimer.After(iStatus, TTimeIntervalMicroSeconds32( iWaitTime*1000 ) ); iWaitTime *= 1.5; ReportState(); ComponentAppContext().SetCurrentComponent(TUid::Uid(0), 0); return KErrNone; }
/****************************************************************** ** 函数名: TIMy_IRQHandler ** 输 入: none ** 描 述: 该定时器用作检测和LED控制计时使用 ** 全局变量: ** 调用模块: ** 作 者: zcs ** 日 期: 2015-04-21 ** 修 改: ** 日 期: ** 版 本: 1.0 *******************************************************************/ void TIMy_IRQHandler(void) { /******作为计时使用,并为定时状态报告和心跳检测提供时间,0.1ms进入一次*****/ if (TIM_GetITStatus(TIMy,TIM_IT_Update) != RESET) { TIM_ClearITPendingBit(TIMy, TIM_FLAG_Update); TIMy_timecount++; if (TIMy_timecount > Time5sCount) //定时一个5s时间 { TIMy_timecount = 0; heart_time_count++; if(heart_time_count > MAX_HEART_TIME) //心跳检测最大等待时间 { heart_time_count = 0; if (system_start) { // topdeath = TRUE; } } } if (RepPar.time_start) //命令重复次数检测,规定时间内重复次数超过设定数值,则认为重复超限,急停设备 { RepPar.time_count++; if (RepPar.time_count > RepTimeLit){ //到达重复命令预定时间 RepPar.time_limit = TRUE; RepPar.time_count = 0; RepPar.time_start = FALSE; } } if (ErrPar.time_start) //命令错误次数检测,规定时间内错误次数超过设定数值,则认为错误超限,急停设备 { ErrPar.time_count++; if (ErrPar.time_count > ErrTimeLit){ //到达错误命令预定时间 ErrPar.time_limit = TRUE; ErrPar.time_count = 0; ErrPar.time_start = FALSE; } } if (ImpPar.time_start) //阻抗采集限制时间,超过一定时间没有得到数据返回,则跳过该次采集 { ImpPar.time_count++; if (ImpPar.time_count > ImpValTimeLit){ ImpPar.time_limit = TRUE; ImpPar.time_count = 0; ImpPar.time_start = FALSE; } } led_time_count++; //指示灯计时器 // HandleRecData(); //处理接收队列数据 ReportState(); //心跳检测 } }
EXPORT_C void CComponentBase::CheckedRunL() { TUid uid; TInt id; TInt version; ComponentId(uid, id, version); ComponentAppContext().SetCurrentComponent(uid, id); switch(iActiveState) { case MRecovery::EStarting: case MRecovery::ERestarting: StartL(); iActiveState=MRecovery::ERunning; break; case MRecovery::ERunning: ComponentRunL(); break; } ReportState(); ComponentAppContext().SetCurrentComponent(TUid::Uid(0), 0); }