代码拉取完成,页面将自动刷新
#ifndef BASE_APPLICATION_H
#define BASE_APPLICATION_H
#include "FreeRTOS.h"
#include "task.h"
#include <vector>
#define BASEAPPLICATION_USING_EVENT 0u
#if BASEAPPLICATION_USING_EVENT
#include "queue.h"
#define BASEAPPLICATION_EVENT_QUEUE_LENGTH 3u
#endif
class BaseApplication;
class BaseApplication
{
private:
uint32_t _stackDepth; // 任务栈深度(字节)
bool ApplicationRunFlag; // 程序启动运行标志位
bool ApplicationExitFlag; // 程序退出完毕标志位
bool ApplicationPauseFlag; // 程序暂停标志位
TaskHandle_t taskHandle; // 程序线程句柄
BaseApplication *parent; // 父对象
std::vector<BaseApplication *> *childList; // 子程序列表
static constexpr int defaultMainTaskStackDepth = 256;
#if BASEAPPLICATION_USING_EVENT
static constexpr int defaultEventTaskStackDepth = 256;
static constexpr int quitEvent = 0x12345678;
uint32_t eventTaskStackDepth;
QueueHandle_t eventQueue;
#endif
protected:
// 子类需要实现的方法
virtual void Setup(void) {} // 程序运行前调用一次
virtual void Loop(void) = 0; // 程序运行时循环调用
virtual void Exit(void) {} // 程序退出时调用一次
#if BASEAPPLICATION_USING_EVENT
virtual void EventHandler(int event) = 0; // 程序事件处理
#endif
friend void ApplicationTask(void *arg);
friend void EventTask(void *arg);
public:
BaseApplication(uint32_t stackDepth = defaultMainTaskStackDepth);
~BaseApplication();
void Run(void);
void Pause(void);
void AddChild(BaseApplication *child);
void RunChild(int index);
#if BASEAPPLICATION_USING_EVENT
void SetEventTaskStackDepth(uint32_t stackDepth) { eventTaskStackDepth = stackDepth; }
bool SendEvent(int event);
#endif
/**
* @brief 停止程序
*/
void Stop(void) { ApplicationRunFlag = false; }
};
#endif
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。