Skip to content

Commit

Permalink
add example for task data exchange usage
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas committed Oct 24, 2023
1 parent 6758c59 commit 0db0dd4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
13 changes: 12 additions & 1 deletion lib/exampletask/GwExampleTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//we only compile for some boards
#ifdef BOARD_TEST
#include "GwExampleTask.h"
#include "GwIExampleTask.h"
#include "GwApi.h"
#include "GWConfig.h"
#include <vector>
Expand Down Expand Up @@ -99,6 +100,9 @@ void exampleTask(GwApi *api){
GwApi::BoatValue *valueList[]={longitude,latitude,testValue};
GwApi::Status status;
int counter=api->addCounter("usertest");
int apiResult=0;
ExampleTaskIf e1=apiGetExampleTaskIf(api,apiResult);
LOG_DEBUG(GwLog::LOG,"exampleIf before rs=%d,v=%d,s=%s",apiResult,e1.count,e1.someValue.c_str());
while(true){
delay(1000);
/*
Expand Down Expand Up @@ -198,7 +202,14 @@ void exampleTask(GwApi *api){
status.n2kTx);
//increment some counter
api->increment(counter,"Test");

ExampleTaskIf e2=apiGetExampleTaskIf(api,apiResult);
LOG_DEBUG(GwLog::LOG,"exampleIf before update rs=%d,v=%d,s=%s",apiResult,e2.count,e2.someValue.c_str());
e1.count+=1;
e1.someValue="running";
bool rs=apiSetExampleTaskIf(api,e1);
LOG_DEBUG(GwLog::LOG,"exampleIf update rs=%d,v=%d,s=%s",(int)rs,e1.count,e1.someValue.c_str());
ExampleTaskIf e3=apiGetExampleTaskIf(api,apiResult);
LOG_DEBUG(GwLog::LOG,"exampleIf after update rs=%d,v=%d,s=%s",apiResult,e3.count,e3.someValue.c_str());
}
vTaskDelete(NULL);

Expand Down
4 changes: 2 additions & 2 deletions lib/exampletask/GwIExampleTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
/**
* an interface for the example task
*/
class ExampleIf : public GwApi::TaskInterfaces::Base{
class ExampleTaskIf : public GwApi::TaskInterfaces::Base{
public:
long count=0;
String someValue;
};
DECLARE_TASKIF(exampleTask,ExampleIf);
DECLARE_TASKIF(exampleTask,ExampleTaskIf);

#endif

0 comments on commit 0db0dd4

Please sign in to comment.