|
@@ -73,6 +73,8 @@ static void appAfterSlp2(void *pdata, slpManLpState state);
|
|
|
void montior_timer_callback(TimerHandle_t xTimer);
|
|
|
void work_timer_callback(TimerHandle_t xTimer);
|
|
|
void BattWorkStateDelayFunc(UINT8 battWorkCurrentState);
|
|
|
+INT8 rentalEndDetectFunc(void);
|
|
|
+void BattLockFunc(void);
|
|
|
static void setDefaultAppDataValue(void);
|
|
|
void appLoadConfig(void);
|
|
|
void appSaveConfig(void);
|
|
@@ -216,10 +218,6 @@ static void MainTask(void* arg)
|
|
|
{
|
|
|
BattChrgEndFlag=TRUE;
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- BattChrgEndFlag=FALSE;
|
|
|
- }
|
|
|
if(AppDataInfo.ErrorMsg != 0)
|
|
|
{
|
|
|
if(osOK==osMutexAcquire(Error_Mutex, 100))
|
|
@@ -850,7 +848,11 @@ static void setDefaultAppDataInfo(void)
|
|
|
AppDataInfo.AccMileage = 0;
|
|
|
AppDataInfo.SysReStart = 0;
|
|
|
AppDataInfo.RelayControl = 0;
|
|
|
+ AppDataInfo.userLock = 0;
|
|
|
+ AppDataInfo.rentalLock = 0;
|
|
|
AppDataInfo.ErrorMsg = 0;
|
|
|
+ AppDataInfo.rentaltype = 0;
|
|
|
+ memset(AppDataInfo.ExpiryTimeArray, 0x00, sizeof(AppDataInfo.ExpiryTimeArray));
|
|
|
return;
|
|
|
}
|
|
|
void BattWorkStateDelayFunc(UINT8 battWorkCurrentState)
|
|
@@ -880,3 +882,110 @@ void BattWorkStateDelayFunc(UINT8 battWorkCurrentState)
|
|
|
workDelayCounter = 0;
|
|
|
}
|
|
|
}
|
|
|
+INT8 rentalEndDetectFunc(void)
|
|
|
+{
|
|
|
+ OsaUtcTimeTValue TimeStracture;
|
|
|
+ UTC8TimeType UTC8Time,ExpiryTime;
|
|
|
+ UINT16 year;
|
|
|
+ UINT8 month,day,hour,minute,sec;
|
|
|
+ INT8 readRet;
|
|
|
+ readRet = appGetSystemTimeUtcSync(&TimeStracture);
|
|
|
+ if(readRet==0)
|
|
|
+ {
|
|
|
+ year=(TimeStracture.UTCtimer1&0xffff0000)>>16;
|
|
|
+ month=(TimeStracture.UTCtimer1&0xff00)>>8;
|
|
|
+ day=TimeStracture.UTCtimer1&0xff;
|
|
|
+ hour=(TimeStracture.UTCtimer2&0xff000000)>>24;
|
|
|
+ minute=(TimeStracture.UTCtimer2&0xff0000)>>16;
|
|
|
+ sec=(TimeStracture.UTCtimer2&0xff00)>>8;
|
|
|
+ UTCToBeijing((UTC8TimeType *)&UTC8Time,year,month,day,hour,minute,sec);
|
|
|
+
|
|
|
+ if(((UTC8Time.year - 0x07D0) & 0xFF)==AppDataInfo.ExpiryTimeArray[0])//年份相等判定月份
|
|
|
+ {
|
|
|
+ if(UTC8Time.month==AppDataInfo.ExpiryTimeArray[1])//月份相等判定日期
|
|
|
+ {
|
|
|
+ if(UTC8Time.day==AppDataInfo.ExpiryTimeArray[2])//日期相等判定小时
|
|
|
+ {
|
|
|
+ if(UTC8Time.hour<=AppDataInfo.ExpiryTimeArray[3])//小时相等不锁定,小时超出锁定
|
|
|
+ {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(UTC8Time.day>AppDataInfo.ExpiryTimeArray[2])
|
|
|
+ {
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ else if(UTC8Time.day<AppDataInfo.ExpiryTimeArray[2])
|
|
|
+ {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(UTC8Time.month>AppDataInfo.ExpiryTimeArray[1])//实际月份大于终止月份
|
|
|
+ {
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ else if(UTC8Time.month<AppDataInfo.ExpiryTimeArray[1])//实际月份小于终止月份
|
|
|
+ {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(((UTC8Time.year - 0x07D0) & 0xFF)>AppDataInfo.ExpiryTimeArray[0])//实际年份大于终止年份
|
|
|
+ {
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ else if(((UTC8Time.year - 0x07D0) & 0xFF)<AppDataInfo.ExpiryTimeArray[0])//年比较,实际年份小于终止年份
|
|
|
+ {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return 0;//没有获取到时间返回
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+void BattLockFunc(void)
|
|
|
+{
|
|
|
+ if(AppDataInfo.rentaltype==0)//测试模式
|
|
|
+ {
|
|
|
+ ;
|
|
|
+ }
|
|
|
+ else if (AppDataInfo.rentaltype==1)//零售模式
|
|
|
+ {
|
|
|
+ if(AppDataInfo.rentalLock==TRUE)
|
|
|
+ {
|
|
|
+ AppDataInfo.userLock = FALSE;
|
|
|
+ AppDataInfo.rentalLock=FALSE;
|
|
|
+ AppDataInfo.appDataModify=TRUE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(AppDataInfo.rentaltype==2)// 租赁模式
|
|
|
+ {
|
|
|
+ if(rentalEndDetectFunc()==1 && AppDataInfo.rentalLock==FALSE)//租期判定是否超期函数
|
|
|
+ {
|
|
|
+ AppDataInfo.rentalLock=TRUE;
|
|
|
+ AppDataInfo.appDataModify=TRUE;
|
|
|
+ }
|
|
|
+ else if(rentalEndDetectFunc()==0 && AppDataInfo.rentalLock==TRUE)
|
|
|
+ {
|
|
|
+ AppDataInfo.rentalLock=FALSE;
|
|
|
+ AppDataInfo.appDataModify=TRUE;
|
|
|
+ AppDataInfo.userLock = FALSE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(AppDataInfo.rentalLock==FALSE&&AppDataInfo.userLock==FALSE)
|
|
|
+ {
|
|
|
+ AppNVMData.isBattLocked = FALSE;
|
|
|
+ AppNVMData.appDataModify = TRUE;
|
|
|
+ }
|
|
|
+ else if(AppDataInfo.rentalLock==TRUE||AppDataInfo.userLock==TRUE)
|
|
|
+ {
|
|
|
+ AppNVMData.isBattLocked = TRUE;
|
|
|
+ AppNVMData.appDataModify = TRUE;
|
|
|
+ }
|
|
|
+}
|