correct backward xdr mapping for unknown instance, prefer instance mode single for unmapped, improve traces
This commit is contained in:
parent
236c417fb5
commit
84483024ac
|
@ -216,7 +216,10 @@ private:
|
|||
if (found.empty) continue;
|
||||
value=found.valueFromXdr(value);
|
||||
if (!boatData->update(value,msg.sourceId,&found)) continue;
|
||||
LOG_DEBUG(GwLog::DEBUG,"found mapped XDR %s, value %f",transducerName,value);
|
||||
LOG_DEBUG(GwLog::DEBUG,"found mapped XDR %s:%s, value %f",
|
||||
transducerName.c_str(),
|
||||
found.definition->toString().c_str(),
|
||||
value);
|
||||
foundMappings.push_back(XdrMappingAndValue(found,value));
|
||||
}
|
||||
static const int maxFields=20;
|
||||
|
@ -291,7 +294,7 @@ private:
|
|||
}
|
||||
}
|
||||
else{
|
||||
if (fillFieldList(current, fields, 12,13)){
|
||||
if (fillFieldList(current, fields, 10,13)){
|
||||
SetN2kPGN127488(n2kMsg,current.mapping.instanceId,
|
||||
fields[10],fields[11],fields[12]);
|
||||
send(n2kMsg, buildN2KKey(n2kMsg, current.mapping));
|
||||
|
|
|
@ -325,43 +325,50 @@ void GwXDRMappings::begin()
|
|||
* select the best matching mapping
|
||||
* depending on the instance id
|
||||
*/
|
||||
GwXDRFoundMapping GwXDRMappings::selectMapping(GwXDRMapping::MappingList *list,int instance,const char * key){
|
||||
GwXDRMapping *candidate=NULL;
|
||||
for (auto mit=list->begin();mit != list->end();mit++){
|
||||
GwXDRMappingDef *def=(*mit)->definition;
|
||||
//if there is no instance we take a mapping with instance type ignore
|
||||
//otherwise we prefer a matching instance before we use auto/ignore
|
||||
if (instance < 0){
|
||||
if (def->instanceMode != GwXDRMappingDef::IS_IGNORE) continue;
|
||||
LOG_DEBUG(GwLog::DEBUG,"selected mapping %s for %s",def->toString().c_str(),key);
|
||||
return GwXDRFoundMapping(*mit);
|
||||
}
|
||||
else{
|
||||
switch(def->instanceMode){
|
||||
case GwXDRMappingDef::IS_SINGLE:
|
||||
if (def->instanceId == instance){
|
||||
LOG_DEBUG(GwLog::DEBUG+1,"selected mapping %s for %s, i=%d",
|
||||
def->toString().c_str(),key,instance);
|
||||
return GwXDRFoundMapping(*mit,instance);
|
||||
}
|
||||
case GwXDRMappingDef::IS_AUTO:
|
||||
candidate=*mit;
|
||||
break;
|
||||
case GwXDRMappingDef::IS_IGNORE:
|
||||
if (candidate == NULL) candidate=*mit;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
GwXDRFoundMapping GwXDRMappings::selectMapping(GwXDRMapping::MappingList *list, int instance, const char *key)
|
||||
{
|
||||
GwXDRMapping *candidate = NULL;
|
||||
for (auto mit = list->begin(); mit != list->end(); mit++)
|
||||
{
|
||||
GwXDRMappingDef *def = (*mit)->definition;
|
||||
//if there is no instance (coming from xdr with no instance) we take a mapping with instance type ignore
|
||||
//or the first explicit mapping
|
||||
//for coming from xdr we only should have one mapping in the list
|
||||
//but auto will not match for unknwn instance
|
||||
switch (def->instanceMode)
|
||||
{
|
||||
case GwXDRMappingDef::IS_SINGLE:
|
||||
if (def->instanceId == instance)
|
||||
{
|
||||
LOG_DEBUG(GwLog::DEBUG + 1, "selected mapping %s for %s, i=%d",
|
||||
def->toString().c_str(), key, instance);
|
||||
return GwXDRFoundMapping(*mit, instance);
|
||||
}
|
||||
if (instance < 0)
|
||||
{
|
||||
if (candidate == NULL)
|
||||
candidate = *mit;
|
||||
}
|
||||
case GwXDRMappingDef::IS_AUTO:
|
||||
if (instance >= 0)
|
||||
candidate = *mit;
|
||||
break;
|
||||
case GwXDRMappingDef::IS_IGNORE:
|
||||
if (candidate == NULL)
|
||||
candidate = *mit;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (candidate != NULL){
|
||||
LOG_DEBUG(GwLog::DEBUG+1,"selected mapping %s for %s, i=%d",
|
||||
candidate->definition->toString().c_str(),key,instance);
|
||||
return GwXDRFoundMapping(candidate,instance);
|
||||
if (candidate != NULL)
|
||||
{
|
||||
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);
|
||||
}
|
||||
LOG_DEBUG(GwLog::DEBUG+1,"no instance mapping found for key=%s, i=%d",key,instance);
|
||||
LOG_DEBUG(GwLog::DEBUG + 1, "no instance mapping found for key=%s, i=%d", key, instance);
|
||||
return GwXDRFoundMapping();
|
||||
}
|
||||
GwXDRFoundMapping GwXDRMappings::getMapping(String xName,String xType,String xUnit){
|
||||
|
|
|
@ -161,7 +161,7 @@ class GwXDRFoundMapping : public GwBoatItemNameProvider{
|
|||
this->type=type;
|
||||
empty=false;
|
||||
}
|
||||
GwXDRFoundMapping(GwXDRMapping* mapping,int instance=-1){
|
||||
GwXDRFoundMapping(GwXDRMapping* mapping,int instance=0){
|
||||
this->definition=mapping->definition;
|
||||
this->type=mapping->type;
|
||||
this->instanceId=instance;
|
||||
|
|
|
@ -719,7 +719,7 @@ function convertUnassigned(value){
|
|||
if (parseInt(s.v) == selector) selectorName=s.l;
|
||||
});
|
||||
rt.l=cname+","+selectorName+","+fieldName+","+instance;
|
||||
rt.v=cid+",1,"+selector+","+field+",1,"+instance+",";
|
||||
rt.v=cid+",1,"+selector+","+field+",0,"+instance+",";
|
||||
return rt;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue