1
0
mirror of https://github.com/thooge/esp32-nmea2000-obp60.git synced 2025-12-16 07:23:07 +01:00

allow a counter for user tasks, reorganize generated config handling

This commit is contained in:
andreas
2023-10-14 19:20:21 +02:00
parent f52428366f
commit 6cdaab4d60
11 changed files with 205 additions and 119 deletions

View File

@@ -2,16 +2,24 @@
#define _GWUSERCODE_H
#include <Arduino.h>
#include <map>
#include "GwApi.h"
#include "GwJsonDocument.h"
class GwLog;
class GwApi;
typedef void (*GwUserTaskFunction)(GwApi *);
class GwApiInternal : public GwApi{
public:
~GwApiInternal(){}
virtual void fillStatus(GwJsonDocument &status){};
virtual int getJsonSize(){return 0;};
};
class GwUserTask{
public:
String name;
TaskFunction_t task=NULL;
GwUserTaskFunction usertask=NULL;
bool isUserTask=false;
GwApi *api=NULL;
GwApiInternal *api=NULL;
int stackSize=2000;
GwUserTask(String name,TaskFunction_t task,int stackSize=2000){
this->name=name;
@@ -25,17 +33,21 @@ class GwUserTask{
this->stackSize=stackSize;
}
};
class GwUserCode{
GwLog *logger;
GwApi *api;
GwApiInternal *api;
SemaphoreHandle_t *mainLock;
void startAddOnTask(GwApi *api,GwUserTask *task,int sourceId,String name);
void startAddOnTask(GwApiInternal *api,GwUserTask *task,int sourceId,String name);
public:
typedef std::map<String,String> Capabilities;
GwUserCode(GwApi *api, SemaphoreHandle_t *mainLock);
GwUserCode(GwApiInternal *api, SemaphoreHandle_t *mainLock);
void startUserTasks(int baseId);
void startInitTasks(int baseId);
void startAddonTask(String name,TaskFunction_t task, int id);
Capabilities *getCapabilities();
void fillStatus(GwJsonDocument &status);
int getJsonSize();
};
#endif