add error example, improve debug messages

This commit is contained in:
andreas 2023-10-24 15:10:13 +02:00
parent 0db0dd4322
commit 155c7a8d1c
2 changed files with 20 additions and 3 deletions

View File

@ -7,6 +7,20 @@
#include "GWConfig.h"
#include <vector>
/**
* INVALID!!! - the next interface declaration will not work
* as it is not in the correct header file
* it is just included here to show you how errors
* could be created.
* if you call the apiSetExampleNotWorkingIf method
* it will always return false
*/
class ExampleNotWorkingIf: public GwApi::TaskInterfaces::Base{
public:
int someValue=99;
};
DECLARE_TASKIF(exampleTask,ExampleNotWorkingIf);
/**
* an init function that ist being called before other initializations from the core
*/
@ -103,6 +117,9 @@ void exampleTask(GwApi *api){
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());
ExampleNotWorkingIf nw1;
bool nwrs=apiSetExampleNotWorkingIf(api,nw1);
LOG_DEBUG(GwLog::LOG,"exampleNotWorking update returned %d",(int)nwrs);
while(true){
delay(1000);
/*

View File

@ -107,15 +107,15 @@ class TaskInterfacesStorage{
GWSYNCHRONIZED(&lock);
auto it=registrations().find(name);
if (it == registrations().end()){
LOG_DEBUG(GwLog::ERROR,"invalid set %s not known",name.c_str());
LOG_DEBUG(GwLog::ERROR,"TaskInterfaces: invalid set %s not known",name.c_str());
return false;
}
if (it->second.file != file){
LOG_DEBUG(GwLog::ERROR,"invalid set %s wrong file, expected %s , got %s",name.c_str(),it->second.file.c_str(),file.c_str());
LOG_DEBUG(GwLog::ERROR,"TaskInterfaces: invalid set %s wrong file, expected %s , got %s",name.c_str(),it->second.file.c_str(),file.c_str());
return false;
}
if (it->second.task != task){
LOG_DEBUG(GwLog::ERROR,"invalid set %s wrong task, expected %s , got %s",name.c_str(),it->second.task.c_str(),task.c_str());
LOG_DEBUG(GwLog::ERROR,"TaskInterfaces: invalid set %s wrong task, expected %s , got %s",name.c_str(),it->second.task.c_str(),task.c_str());
return false;
}
auto vit=values.find(name);