添加任务插槽,未写完
This commit is contained in:
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@@ -8,6 +8,7 @@
|
||||
"board.h": "c",
|
||||
"prot_uc.h": "c",
|
||||
"tran_for_slave.h": "c",
|
||||
"ewupdata.h": "c"
|
||||
"ewupdata.h": "c",
|
||||
"elec_task_slot.h": "c"
|
||||
}
|
||||
}
|
@@ -798,7 +798,7 @@
|
||||
|
||||
<Group>
|
||||
<GroupName>stm32lib</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
|
@@ -185,6 +185,7 @@
|
||||
<uocXRam>0</uocXRam>
|
||||
<RvdsVP>0</RvdsVP>
|
||||
<RvdsMve>0</RvdsMve>
|
||||
<RvdsCdeCp>0</RvdsCdeCp>
|
||||
<hadIRAM2>0</hadIRAM2>
|
||||
<hadIROM2>0</hadIROM2>
|
||||
<StupSel>8</StupSel>
|
||||
@@ -351,7 +352,7 @@
|
||||
<NoWarn>0</NoWarn>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<useXO>0</useXO>
|
||||
<uClangAs>0</uClangAs>
|
||||
<ClangAsOpt>4</ClangAsOpt>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
@@ -803,7 +804,7 @@
|
||||
<NoWarn>2</NoWarn>
|
||||
<uSurpInc>2</uSurpInc>
|
||||
<useXO>2</useXO>
|
||||
<uClangAs>2</uClangAs>
|
||||
<ClangAsOpt>0</ClangAsOpt>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
@@ -1907,7 +1908,7 @@
|
||||
<NoWarn>2</NoWarn>
|
||||
<uSurpInc>2</uSurpInc>
|
||||
<useXO>2</useXO>
|
||||
<uClangAs>2</uClangAs>
|
||||
<ClangAsOpt>0</ClangAsOpt>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
@@ -2403,7 +2404,7 @@
|
||||
<NoWarn>2</NoWarn>
|
||||
<uSurpInc>2</uSurpInc>
|
||||
<useXO>2</useXO>
|
||||
<uClangAs>2</uClangAs>
|
||||
<ClangAsOpt>0</ClangAsOpt>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
@@ -2502,7 +2503,7 @@
|
||||
<NoWarn>2</NoWarn>
|
||||
<uSurpInc>2</uSurpInc>
|
||||
<useXO>2</useXO>
|
||||
<uClangAs>2</uClangAs>
|
||||
<ClangAsOpt>0</ClangAsOpt>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
@@ -2581,7 +2582,7 @@
|
||||
<NoWarn>2</NoWarn>
|
||||
<uSurpInc>2</uSurpInc>
|
||||
<useXO>2</useXO>
|
||||
<uClangAs>2</uClangAs>
|
||||
<ClangAsOpt>0</ClangAsOpt>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
@@ -2655,7 +2656,7 @@
|
||||
<TargetName>app</TargetName>
|
||||
<ToolsetNumber>0x4</ToolsetNumber>
|
||||
<ToolsetName>ARM-ADS</ToolsetName>
|
||||
<pCCUsed>5060750::V5.06 update 6 (build 750)::ARMCC</pCCUsed>
|
||||
<pCCUsed>5060960::V5.06 update 7 (build 960)::.\ARMCC</pCCUsed>
|
||||
<uAC6>0</uAC6>
|
||||
<TargetOption>
|
||||
<TargetCommonOption>
|
||||
@@ -2830,6 +2831,7 @@
|
||||
<uocXRam>0</uocXRam>
|
||||
<RvdsVP>0</RvdsVP>
|
||||
<RvdsMve>0</RvdsMve>
|
||||
<RvdsCdeCp>0</RvdsCdeCp>
|
||||
<hadIRAM2>0</hadIRAM2>
|
||||
<hadIROM2>0</hadIROM2>
|
||||
<StupSel>8</StupSel>
|
||||
@@ -2996,7 +2998,7 @@
|
||||
<NoWarn>0</NoWarn>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<useXO>0</useXO>
|
||||
<uClangAs>0</uClangAs>
|
||||
<ClangAsOpt>4</ClangAsOpt>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
@@ -4345,6 +4347,7 @@
|
||||
<uocXRam>0</uocXRam>
|
||||
<RvdsVP>0</RvdsVP>
|
||||
<RvdsMve>0</RvdsMve>
|
||||
<RvdsCdeCp>0</RvdsCdeCp>
|
||||
<hadIRAM2>0</hadIRAM2>
|
||||
<hadIROM2>0</hadIROM2>
|
||||
<StupSel>8</StupSel>
|
||||
@@ -4511,7 +4514,7 @@
|
||||
<NoWarn>0</NoWarn>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<useXO>0</useXO>
|
||||
<uClangAs>0</uClangAs>
|
||||
<ClangAsOpt>4</ClangAsOpt>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
|
@@ -282,3 +282,6 @@
|
||||
使用定时器来精确控制数据发送的时间间隙,保证和其他小板不冲突
|
||||
2023.12.7
|
||||
广播命令根据数据量自动计算发送数据的窗口时间
|
||||
2023.12.10
|
||||
添加任务插槽,未写完
|
||||
|
||||
|
@@ -27,6 +27,16 @@
|
||||
#include "interface/CheckerExt.h"
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
此文件定义了电子模块与外界软件程序交互的接口
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#define PLAN_MAX_TASK 64
|
||||
|
||||
#define TASK_PAR_BACK_LEN 10
|
||||
|
@@ -377,8 +377,8 @@ void elec_judge(elec_judge_def *e,int task_num,uint8_t *exe_ack,
|
||||
for(int i=0;i<task_num;i++)
|
||||
{
|
||||
// 只判定已执行的任务
|
||||
if(BIT_CHECK(exe_flag,i)){
|
||||
task=&e->scheme->task[i];
|
||||
if(BIT_CHECK(exe_flag,i)){
|
||||
if(task->taskid<e->judge_fun_num){
|
||||
e->judge_fun_table[task->taskid](e,i,data);
|
||||
}else if((task->taskid>=CHECKER_MAXID_COUNT)&&
|
||||
|
130
source/elec_det/elec_task_slot.c
Normal file
130
source/elec_det/elec_task_slot.c
Normal file
@@ -0,0 +1,130 @@
|
||||
|
||||
#include "elec_task_slot.h"
|
||||
#include "board.h"
|
||||
#include "stdlib.h"
|
||||
#include "string.h"
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
此文件定义动态任务插入的机制
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#define ERR_TABLE_SIZE 10
|
||||
|
||||
typedef struct _task_node{
|
||||
task_def task;
|
||||
struct _task_node *next;
|
||||
}task_node;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct{
|
||||
int node_num;
|
||||
task_node *head;
|
||||
task_node *current;
|
||||
int err_num;
|
||||
uint8_t err_table[ERR_TABLE_SIZE]
|
||||
}task_slot_def;
|
||||
|
||||
|
||||
|
||||
void task_slot_delete(void)
|
||||
{
|
||||
task_slot_def *t=app_variable("task_slot",0,0);
|
||||
if(t){
|
||||
task_node *n=t->head;
|
||||
task_node *old=0;
|
||||
while(n){
|
||||
old=n;
|
||||
n=n->next;
|
||||
free(old);
|
||||
}
|
||||
free(t);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 初始化
|
||||
void *task_slot_init(void)
|
||||
{
|
||||
task_slot_def *t=app_variable("task_slot",0,0);
|
||||
if(t==0){
|
||||
t=calloc(1,sizeof(task_slot_def));
|
||||
app_variable("task_slot",t,0);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 添加一个任务
|
||||
int task_slot_add_item(void *context,task_def *item)
|
||||
{
|
||||
task_slot_def *t=context;
|
||||
if(t==0){
|
||||
return -1;
|
||||
}
|
||||
task_node **n=&t->head;
|
||||
task_node *tail;
|
||||
tail=calloc(1,sizeof(task_node));
|
||||
memcpy(tail,item,sizeof(task_node));
|
||||
while(*n){
|
||||
n=&(*n)->next;
|
||||
}
|
||||
(*n)=tail;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 找到下一个slot
|
||||
task_def *task_slot_next(void *context,uint8_t slot_index)
|
||||
{
|
||||
task_slot_def *t=context;
|
||||
if(t==0){
|
||||
return 0;
|
||||
}
|
||||
task_node *n;
|
||||
while(t->current){
|
||||
n=t->current;
|
||||
t->current=n->next;
|
||||
if(n->task.slot_index==slot_index){
|
||||
return &n->task;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int task_slot_add_err(void *context,uint8_t err)
|
||||
{
|
||||
task_slot_def *t=context;
|
||||
if(t==0){
|
||||
return -1;
|
||||
}
|
||||
int index=-1;
|
||||
for(int i=0;i<ERR_TABLE_SIZE;i++){
|
||||
if(t->err_table[i]==0){
|
||||
if(index<0) index=i;
|
||||
}
|
||||
if(t->err_table[i]==err){
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(index>=0){
|
||||
t->err_table[index]=err;
|
||||
t->err_num++;
|
||||
return 0;
|
||||
}
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
30
source/elec_det/elec_task_slot.h
Normal file
30
source/elec_det/elec_task_slot.h
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
#ifndef elec_task_slot_h__
|
||||
#define elec_task_slot_h__
|
||||
|
||||
#include "board.h"
|
||||
|
||||
#pragma pack (1)
|
||||
typedef struct{
|
||||
uint8_t slot_index;
|
||||
uint8_t task_id;
|
||||
uint8_t par_count;// 参数个数
|
||||
uint8_t ret_count;// 返回值个数
|
||||
uint8_t errcode;
|
||||
uint8_t params[20];
|
||||
uint8_t rets[20];
|
||||
}task_def;
|
||||
#pragma pack ()
|
||||
|
||||
void *task_slot_init(void);
|
||||
|
||||
int task_slot_add_item(void *context,task_def *item);
|
||||
|
||||
task_def *task_slot_next(void *context,uint8_t slot_index);
|
||||
|
||||
int task_slot_add_err(void *context,uint8_t err);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -5,6 +5,7 @@
|
||||
#include "CheckerExt.h"
|
||||
#include "basechecker.h"
|
||||
#include "elec_det.h"
|
||||
#include "elec_task_slot.h"
|
||||
|
||||
|
||||
|
||||
@@ -117,7 +118,57 @@ static int calc_skip_num(int index)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*rc{
|
||||
执行动态插入的任务,
|
||||
找到此插槽的所有动态任务并依次执行,如未找到则直接返回
|
||||
par0:要执行的任务插槽
|
||||
return:无
|
||||
exe:动态插入的任务执行失败则此任务失败
|
||||
}*/
|
||||
void CheckerExt_Slot(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];
|
||||
task_def *t=0;
|
||||
void *task_slot=task_slot_init();
|
||||
if(task_slot==0){
|
||||
goto end;
|
||||
}
|
||||
if(elec_task_env_back()){
|
||||
ret=2;
|
||||
goto end;
|
||||
}
|
||||
while(t=task_slot_next(task_slot,(uint8_t)index),t){
|
||||
// t->
|
||||
}
|
||||
if(elec_task_env_restore()){
|
||||
ret=5;
|
||||
goto end;
|
||||
}
|
||||
end:
|
||||
Checker_MaskResult(ret,self_index);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
CheckerTask exttaskArray[CHECKER_EXTID_COUNT]={
|
||||
CheckerExt_CalcErr,
|
||||
CheckerExt_Repeat,
|
||||
};
|
||||
|
||||
|
@@ -6,7 +6,7 @@
|
||||
|
||||
|
||||
|
||||
#define BUILD_DATE "2023-12-08 08:46:40"
|
||||
#define BUILD_DATE "2023-12-09 12:34:57"
|
||||
#define SOFT_VERSION "2.07"
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user