From fa2509c5afca697ddb0e5ceeac95af51d20baa48 Mon Sep 17 00:00:00 2001 From: ranchuan Date: Mon, 20 Nov 2023 18:06:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=87=8D=E5=A4=8D=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E6=8C=87=E5=AE=9A=E4=BB=BB=E5=8A=A1=E7=9A=84=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- checher_slave.uvoptx | 2 +- source/ReadMe.txt | 2 + source/elec_det/elec_det.c | 55 ++++++++++++++++++++++++++ source/elec_det/elec_det.h | 4 ++ source/elec_det/interface/CheckerExt.c | 49 ++++++++++++++++++++++- source/elec_det/interface/CheckerExt.h | 1 + source/elec_det/interface/EWChecker.c | 1 + source/main/compiler_info.h | 2 +- 8 files changed, 112 insertions(+), 4 deletions(-) diff --git a/checher_slave.uvoptx b/checher_slave.uvoptx index 5266f3a..eb9ef06 100644 --- a/checher_slave.uvoptx +++ b/checher_slave.uvoptx @@ -1548,7 +1548,7 @@ rt_thread - 0 + 1 0 0 0 diff --git a/source/ReadMe.txt b/source/ReadMe.txt index 5fc2827..2a56adc 100644 --- a/source/ReadMe.txt +++ b/source/ReadMe.txt @@ -269,4 +269,6 @@ 2023.11.17 添加扩展任务 用于小板端执行异常判定 ew程序下载批量验证成功 +2023.11.20 + 添加重复执行指定任务的任务 diff --git a/source/elec_det/elec_det.c b/source/elec_det/elec_det.c index fe045a8..4984481 100644 --- a/source/elec_det/elec_det.c +++ b/source/elec_det/elec_det.c @@ -29,6 +29,17 @@ #define PLAN_MAX_TASK 64 +#define TASK_PAR_BACK_LEN 10 + + +typedef struct{ + CheckerTask_Info_st task_par; + int par_count; + int ret_count; + int rtv_index;// 返回值下标 + uint16_t params[10]; +}task_par_back; + typedef struct{ CheckerTask_Info_st* task_info_array[PLAN_MAX_TASK];//方案参数结构体指针 @@ -41,6 +52,8 @@ typedef struct{ int task_num; int scheme_inited; array_def *data; + task_par_back *task_back_table[TASK_PAR_BACK_LEN]; + int task_back_index; }self_def; @@ -423,6 +436,48 @@ int elec_check_load_task_param(uint8_t task_index) memcpy(checker_runcfg.params,checker_runcfg.task_info.params,checker_runcfg.param_count*2); return 0; } + +// 备份任务运行环境,0成功 +int elec_task_env_back(void) +{ + self_def *s=&g_self; + task_par_back *b=0; + if(s->task_back_index>=TASK_PAR_BACK_LEN){ + return 1; + } + s->task_back_table[s->task_back_index]=calloc(1,sizeof(task_par_back)); + b=s->task_back_table[s->task_back_index]; + if(b==0){ + return 2; + } + b->par_count=checker_runcfg.param_count; + b->ret_count=checker_runcfg.rtv_count; + b->rtv_index=checker_runcfg.rtv_index; + memcpy(&b->task_par, &checker_runcfg.task_info,sizeof(CheckerTask_Info_st)); + memcpy(b->params,checker_runcfg.params,checker_runcfg.param_count*2); + s->task_back_index++; + return 0; +} +// 恢复任务运行环境,0成功 +int elec_task_env_restore(void) +{ + self_def *s=&g_self; + task_par_back *b=0; + if(s->task_back_index<=0){ + return 1; + } + b=s->task_back_table[s->task_back_index-1]; + checker_runcfg.param_count=b->par_count; + checker_runcfg.rtv_count=b->ret_count; + checker_runcfg.rtv_index=b->rtv_index; + memcpy(&checker_runcfg.task_info,&b->task_par, sizeof(CheckerTask_Info_st)); + memcpy(checker_runcfg.params,b->params,checker_runcfg.param_count*2); + free(b); + s->task_back_index--; + return 0; +} + + // 根据任务id获取检测函数 CheckerTask elec_get_task_fun(CheckerTask *tasks_fun_table[],uint8_t chip_type,uint8_t taskid) { diff --git a/source/elec_det/elec_det.h b/source/elec_det/elec_det.h index e6f14ed..6672c62 100644 --- a/source/elec_det/elec_det.h +++ b/source/elec_det/elec_det.h @@ -44,6 +44,10 @@ int elec_check_load_task_param(uint8_t task_index); void elec_exe_task(void); +int elec_task_env_back(void); + +int elec_task_env_restore(void); + #endif diff --git a/source/elec_det/interface/CheckerExt.c b/source/elec_det/interface/CheckerExt.c index c8d9f7d..9d6965d 100644 --- a/source/elec_det/interface/CheckerExt.c +++ b/source/elec_det/interface/CheckerExt.c @@ -4,7 +4,7 @@ #include "elec_judge.h" #include "CheckerExt.h" #include "basechecker.h" - +#include "elec_det.h" @@ -69,7 +69,52 @@ par0:要执行的任务序号 return:无 exe:如果要执行的任务序号不小于此任务则此任务失败 }*/ -//void CheckerExt_Repeat +static int calc_skip_num(int index); +void CheckerExt_Repeat(void) +{ + int index; + uint16_t ret=0; + int self_index=checker_runcfg.task_info.runindex; + if(checker_runcfg.param_count<1){ + ret=1; + goto end; + } + index=checker_runcfg.params[0]; + if(index>=self_index){ + ret=2; + goto end; + } + if(elec_task_env_back()){ + ret=3; + goto end; + } + if(elec_check_load_task_param(index)){ + ret=4; + goto end; + } + checker_runcfg.rtv_index=calc_skip_num(index); + elec_exe_task(); + if(elec_task_env_restore()){ + ret=5; + goto end; + } + + end: + Checker_MaskResult(ret,self_index); +} +// 计算在taskindex之前有多少个返回值 +static int calc_skip_num(int index) +{ + const scheme_def *s=check_scheme(); + const scheme_task_def *t; + int num=0; + for(int i=0;itask[i]; + num+=t->item_num; + } + return num; +} CheckerTask exttaskArray[CHECKER_EXTID_COUNT]={ diff --git a/source/elec_det/interface/CheckerExt.h b/source/elec_det/interface/CheckerExt.h index 9b69411..65c41ff 100644 --- a/source/elec_det/interface/CheckerExt.h +++ b/source/elec_det/interface/CheckerExt.h @@ -17,6 +17,7 @@ extern CheckerTask exttaskArray[CHECKER_EXTID_COUNT]; void CheckerExt_CalcErr(void); +void CheckerExt_Repeat(void); diff --git a/source/elec_det/interface/EWChecker.c b/source/elec_det/interface/EWChecker.c index bf95a7e..0d04600 100644 --- a/source/elec_det/interface/EWChecker.c +++ b/source/elec_det/interface/EWChecker.c @@ -858,6 +858,7 @@ EW_Test_PowerOFF, //26 关总线 EW_Updata, //27 升级 EW_Test_ChgEnergy, //28 充能统计 CheckerExt_CalcErr, //29 计算异常 +CheckerExt_Repeat, //30 重新执行一次指定任务 (void*)0 //数组结束 }; diff --git a/source/main/compiler_info.h b/source/main/compiler_info.h index a746d2b..317a07a 100644 --- a/source/main/compiler_info.h +++ b/source/main/compiler_info.h @@ -6,7 +6,7 @@ -#define BUILD_DATE "2023-11-18 14:06:40" +#define BUILD_DATE "2023-11-20 10:44:09" #define SOFT_VERSION "2.06"