add example for task data exchange usage
This commit is contained in:
parent
6758c59a3a
commit
0db0dd4322
|
@ -2,6 +2,7 @@
|
||||||
//we only compile for some boards
|
//we only compile for some boards
|
||||||
#ifdef BOARD_TEST
|
#ifdef BOARD_TEST
|
||||||
#include "GwExampleTask.h"
|
#include "GwExampleTask.h"
|
||||||
|
#include "GwIExampleTask.h"
|
||||||
#include "GwApi.h"
|
#include "GwApi.h"
|
||||||
#include "GWConfig.h"
|
#include "GWConfig.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -99,6 +100,9 @@ void exampleTask(GwApi *api){
|
||||||
GwApi::BoatValue *valueList[]={longitude,latitude,testValue};
|
GwApi::BoatValue *valueList[]={longitude,latitude,testValue};
|
||||||
GwApi::Status status;
|
GwApi::Status status;
|
||||||
int counter=api->addCounter("usertest");
|
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){
|
while(true){
|
||||||
delay(1000);
|
delay(1000);
|
||||||
/*
|
/*
|
||||||
|
@ -198,7 +202,14 @@ void exampleTask(GwApi *api){
|
||||||
status.n2kTx);
|
status.n2kTx);
|
||||||
//increment some counter
|
//increment some counter
|
||||||
api->increment(counter,"Test");
|
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);
|
vTaskDelete(NULL);
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,11 @@
|
||||||
/**
|
/**
|
||||||
* an interface for the example task
|
* an interface for the example task
|
||||||
*/
|
*/
|
||||||
class ExampleIf : public GwApi::TaskInterfaces::Base{
|
class ExampleTaskIf : public GwApi::TaskInterfaces::Base{
|
||||||
public:
|
public:
|
||||||
long count=0;
|
long count=0;
|
||||||
String someValue;
|
String someValue;
|
||||||
};
|
};
|
||||||
DECLARE_TASKIF(exampleTask,ExampleIf);
|
DECLARE_TASKIF(exampleTask,ExampleTaskIf);
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in New Issue