/***************************************************************************** * @copyright 2024-202, . POWER SUPPLY CO., LTD. * @file logic_main.h * @brief xxxx * @author Gary * @date 2024/09/29 * @remark 初修订 *****************************************************************************/ #pragma once #include #include #include #include #include "logic_comm.h" #define MAX_TASK_NUM 10 // 在头文件中配置任务链 #define INIT_TASK_GROUP() \ { \ task_group[E_TACTIC_MODE_START] = init_task_list(1, example_task1); \ task_group[E_TACTIC_MODE_DEBUG] = init_task_list(2, logicFun_protect,logicFun_powerDistr); \ task_group[E_TACTIC_MODE_PEAKVALLY] = init_task_list(3, logicFun_peakValley,logicFun_protect,logicFun_powerDistr); \ task_group[E_TACTIC_MODE_DEMANDRES] = init_task_list(1, example_task1); \ task_group[E_TACTIC_MODE_LOADTRACK] = init_task_list(1, example_task1); \ task_group[E_TACTIC_MODE_DMDCTRL] = init_task_list(1, example_task1); \ task_group[E_TACTIC_MODE_PFCTRL] = init_task_list(1, example_task1); \ } typedef int (*task_func_t)(); // 定义函数指针类型,返回值为int typedef enum { E_RUN_ONCE, //单次运行 E_RUN_period //周期运行 } task_run_type; typedef struct tast_register_execute { // protocol_type_master_e protocolType; // 任务 // task_run_type taskType; // 任务类型 // uint16_t taskPeriod; // 任务间隔 ms task_func_t task; // 任务指针 struct tast_register_execute* next; // 指向下一个任务 } tast_register_execute; extern tast_register_execute* task_group[E_TACTIC_MODE_END]; void example_task1(); //初始化任务链表,支持多个任务函数指针 tast_register_execute* init_task_list(int count, ...); /***************************************************************************** * @brief 创建任务调度线程 * @param[in] 无 * @return 无 *****************************************************************************/ void* creatLogicTaskThread(void* arg); /********************************************************************* * @brief 新建任务模块的初始化工作 * @param[in] 无 * @return 0:sucessful;1:fault *********************************************************************/ int creatLogicCtrTaskEntry();