1
0
mirror of https://github.com/thooge/esp32-nmea2000-obp60.git synced 2025-12-13 05:53:06 +01:00

add new function getBoatDataValues to api for easier access

This commit is contained in:
wellenvogel
2021-12-03 17:00:51 +01:00
parent b4b08fa12d
commit 04d90447e8
7 changed files with 106 additions and 7 deletions

View File

@@ -5,9 +5,16 @@
#include "NMEA0183Msg.h"
#include "GWConfig.h"
#include "GwBoatData.h"
#include <map>
#include <vector>
//API to be used for additional tasks
class GwApi{
public:
typedef std::map<String,double> ValueMap;
typedef std::vector<String> StringList;
/**
* thread safe methods - can directly be called from a user task
*/
virtual GwRequestQueue *getQueue()=0;
virtual void sendN2kMessage(const tN2kMsg &msg, bool convert=true)=0;
/**
@@ -16,10 +23,27 @@ class GwApi{
virtual void sendNMEA0183Message(const tNMEA0183Msg &msg, int sourceId,bool convert=true)=0;
virtual void sendNMEA0183Message(const tNMEA0183Msg &msg, bool convert=true)=0;
virtual int getSourceId()=0;
/**
* the returned config data must only be read in a user task
* writing to it is not thread safe and could lead to crashes
*/
virtual GwConfigHandler *getConfig()=0;
virtual GwLog *getLogger()=0;
virtual GwBoatData *getBoatData()=0;
virtual const char* getTalkerId()=0;
/**
* get a set of boat data values by their names
* the returned map will have the keys being the strings in the names list
* the values are the boat data values converted to double
* invalid values are not returned in the map
* this method is thread safe and can directly be used from a user task
*/
virtual ValueMap getBoatDataValues(StringList)=0;
/**
* not thread safe methods
* accessing boat data must only be executed from within the main thread
* you need to use the request pattern as shown in GwExampleTask.cpp
*/
virtual GwBoatData *getBoatData()=0;
virtual ~GwApi(){}
};
#ifndef DECLARE_USERTASK