mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2025-12-14 06:23:07 +01:00
make data store times configurable
This commit is contained in:
@@ -355,6 +355,7 @@ void GwXDRMappings::begin()
|
||||
GwXDRFoundMapping GwXDRMappings::selectMapping(GwXDRMapping::MappingList *list, int instance, const char *key)
|
||||
{
|
||||
GwXDRMapping *candidate = NULL;
|
||||
unsigned long invalidTime=config->getInt(GwConfigDefinitions::timoSensor);
|
||||
for (auto mit = list->begin(); mit != list->end(); mit++)
|
||||
{
|
||||
GwXDRMappingDef *def = (*mit)->definition;
|
||||
@@ -369,7 +370,7 @@ GwXDRFoundMapping GwXDRMappings::selectMapping(GwXDRMapping::MappingList *list,
|
||||
{
|
||||
LOG_DEBUG(GwLog::DEBUG + 1, "selected mapping %s for %s, i=%d",
|
||||
def->toString().c_str(), key, instance);
|
||||
return GwXDRFoundMapping(*mit, instance);
|
||||
return GwXDRFoundMapping(*mit,invalidTime, instance);
|
||||
}
|
||||
if (instance < 0)
|
||||
{
|
||||
@@ -393,7 +394,7 @@ GwXDRFoundMapping GwXDRMappings::selectMapping(GwXDRMapping::MappingList *list,
|
||||
{
|
||||
LOG_DEBUG(GwLog::DEBUG + 1, "selected mapping %s for %s, i=%d",
|
||||
candidate->definition->toString().c_str(), key, instance);
|
||||
return GwXDRFoundMapping(candidate, instance>=0?instance:candidate->definition->instanceId);
|
||||
return GwXDRFoundMapping(candidate, invalidTime,instance>=0?instance:candidate->definition->instanceId);
|
||||
}
|
||||
LOG_DEBUG(GwLog::DEBUG + 1, "no instance mapping found for key=%s, i=%d", key, instance);
|
||||
return GwXDRFoundMapping();
|
||||
@@ -472,8 +473,9 @@ String GwXDRMappings::getXdrEntry(String mapping, double value,int instance){
|
||||
}
|
||||
GwXDRType *type = findType(code, &typeIndex);
|
||||
bool first=true;
|
||||
unsigned long invalidTime=config->getInt(GwConfigDefinitions::timoSensor);
|
||||
while (type){
|
||||
GwXDRFoundMapping found(def,type);
|
||||
GwXDRFoundMapping found(def,type,invalidTime);
|
||||
found.instanceId=instance;
|
||||
if (first) first=false;
|
||||
else rt+=",";
|
||||
|
||||
@@ -167,15 +167,18 @@ class GwXDRFoundMapping : public GwBoatItemNameProvider{
|
||||
GwXDRType *type=NULL;
|
||||
int instanceId=-1;
|
||||
bool empty=true;
|
||||
GwXDRFoundMapping(GwXDRMappingDef *definition,GwXDRType *type){
|
||||
unsigned long timeout=0;
|
||||
GwXDRFoundMapping(GwXDRMappingDef *definition,GwXDRType *type, unsigned long timeout){
|
||||
this->definition=definition;
|
||||
this->type=type;
|
||||
this->timeout=timeout;
|
||||
empty=false;
|
||||
}
|
||||
GwXDRFoundMapping(GwXDRMapping* mapping,int instance=0){
|
||||
GwXDRFoundMapping(GwXDRMapping* mapping,unsigned long timeout,int instance){
|
||||
this->definition=mapping->definition;
|
||||
this->type=mapping->type;
|
||||
this->instanceId=instance;
|
||||
this->timeout=timeout;
|
||||
empty=false;
|
||||
}
|
||||
GwXDRFoundMapping(){}
|
||||
@@ -195,6 +198,9 @@ class GwXDRFoundMapping : public GwBoatItemNameProvider{
|
||||
return "formatXdr:"+type->xdrtype+":"+type->boatDataUnit;
|
||||
};
|
||||
virtual ~GwXDRFoundMapping(){}
|
||||
virtual unsigned long getInvalidTime() override{
|
||||
return timeout;
|
||||
}
|
||||
};
|
||||
|
||||
//the class GwXDRMappings is not intended to be deleted
|
||||
|
||||
Reference in New Issue
Block a user