omit #nnn on instance mode single, prepare listing unmapped
This commit is contained in:
parent
03740a9034
commit
1d24fd3732
|
@ -72,13 +72,7 @@ private:
|
||||||
|
|
||||||
String buildXdrEntry(GwXDRFoundMapping &mapping,double value){
|
String buildXdrEntry(GwXDRFoundMapping &mapping,double value){
|
||||||
char buffer[40];
|
char buffer[40];
|
||||||
String name=mapping.definition->xdrName;
|
String name=mapping.getTransducerName();
|
||||||
if (mapping.definition->instanceMode == GwXDRMappingDef::IS_AUTO ||
|
|
||||||
mapping.definition->instanceMode == GwXDRMappingDef::IS_SINGLE
|
|
||||||
){
|
|
||||||
name+="#";
|
|
||||||
name+=String(mapping.instanceId);
|
|
||||||
}
|
|
||||||
if (mapping.type->tonmea){
|
if (mapping.type->tonmea){
|
||||||
value=(* (mapping.type->tonmea))(value);
|
value=(* (mapping.type->tonmea))(value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "GwXDRMappings.h"
|
#include "GwXDRMappings.h"
|
||||||
#include "N2kMessages.h"
|
#include "N2kMessages.h"
|
||||||
|
|
||||||
double PtoBar(double v)
|
double PtoBar(double v)
|
||||||
{
|
{
|
||||||
if (N2kIsNA(v))
|
if (N2kIsNA(v))
|
||||||
|
@ -189,6 +190,16 @@ GwXDRMappingDef *GwXDRMappingDef::fromString(String s)
|
||||||
}
|
}
|
||||||
return rt;
|
return rt;
|
||||||
}
|
}
|
||||||
|
String GwXDRMappingDef::getTransducerName(int instance)
|
||||||
|
{
|
||||||
|
String name = xdrName;
|
||||||
|
if (instanceMode == GwXDRMappingDef::IS_AUTO)
|
||||||
|
{
|
||||||
|
name += "#";
|
||||||
|
name += String(instance);
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
GwXDRMappings::GwXDRMappings(GwLog *logger, GwConfigHandler *config)
|
GwXDRMappings::GwXDRMappings(GwLog *logger, GwConfigHandler *config)
|
||||||
{
|
{
|
||||||
|
@ -373,6 +384,20 @@ bool GwXDRMappings::addUnknown(GwXDRCategory category,int selector,int field,int
|
||||||
uk=(uk<<7) + (field & 0x7f);
|
uk=(uk<<7) + (field & 0x7f);
|
||||||
if (instance < 0 || instance > 255) instance=256; //unknown
|
if (instance < 0 || instance > 255) instance=256; //unknown
|
||||||
uk=(uk << 9) + (instance & 0x1ff);
|
uk=(uk << 9) + (instance & 0x1ff);
|
||||||
unknown.push_back(uk);
|
unknown.insert(uk);
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
char * GwXDRMappings::getUnMapped(){
|
||||||
|
const int ESIZE=13;
|
||||||
|
int sz=(unknown.size()+1)*ESIZE;
|
||||||
|
char *rt=new char[sz];
|
||||||
|
*rt=0;
|
||||||
|
char *ptr=rt;
|
||||||
|
for (auto it=unknown.begin();it!=unknown.end();it++){
|
||||||
|
snprintf(ptr,ESIZE-1,"%lu,",*it);
|
||||||
|
*(ptr+ESIZE-1)=0;
|
||||||
|
while (*ptr != 0) ptr++;
|
||||||
|
}
|
||||||
|
return rt;
|
||||||
}
|
}
|
|
@ -5,6 +5,7 @@
|
||||||
#include <WString.h>
|
#include <WString.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <unordered_set>
|
||||||
//enum must match the defines in xdrconfig.json
|
//enum must match the defines in xdrconfig.json
|
||||||
typedef enum {
|
typedef enum {
|
||||||
XDRTEMP=0,
|
XDRTEMP=0,
|
||||||
|
@ -124,6 +125,7 @@ class GwXDRMappingDef{
|
||||||
rt += xdrUnit;
|
rt += xdrUnit;
|
||||||
return rt;
|
return rt;
|
||||||
}
|
}
|
||||||
|
String getTransducerName(int instance);
|
||||||
private:
|
private:
|
||||||
static bool handleToken(String tok,int index,GwXDRMappingDef *def);
|
static bool handleToken(String tok,int index,GwXDRMappingDef *def);
|
||||||
};
|
};
|
||||||
|
@ -157,6 +159,9 @@ class GwXDRFoundMapping{
|
||||||
empty=false;
|
empty=false;
|
||||||
}
|
}
|
||||||
GwXDRFoundMapping(){}
|
GwXDRFoundMapping(){}
|
||||||
|
String getTransducerName(){
|
||||||
|
return definition->getTransducerName(instanceId);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class GwXDRMappings{
|
class GwXDRMappings{
|
||||||
|
@ -165,7 +170,7 @@ class GwXDRMappings{
|
||||||
GwConfigHandler *config;
|
GwConfigHandler *config;
|
||||||
GwXDRMapping::N138Map n183Map;
|
GwXDRMapping::N138Map n183Map;
|
||||||
GwXDRMapping::N2KMap n2kMap;
|
GwXDRMapping::N2KMap n2kMap;
|
||||||
std::vector<unsigned long> unknown;
|
std::unordered_set<unsigned long> unknown;
|
||||||
GwXDRFoundMapping selectMapping(GwXDRMapping::MappingList *list,int instance,const char * key);
|
GwXDRFoundMapping selectMapping(GwXDRMapping::MappingList *list,int instance,const char * key);
|
||||||
bool addUnknown(GwXDRCategory category,int selector,int field=0,int instance=-1);
|
bool addUnknown(GwXDRCategory category,int selector,int field=0,int instance=-1);
|
||||||
public:
|
public:
|
||||||
|
@ -175,6 +180,8 @@ class GwXDRMappings{
|
||||||
//the returned mapping will exactly contain one mapping def
|
//the returned mapping will exactly contain one mapping def
|
||||||
GwXDRFoundMapping getMapping(String xName,String xType,String xUnit);
|
GwXDRFoundMapping getMapping(String xName,String xType,String xUnit);
|
||||||
GwXDRFoundMapping getMapping(GwXDRCategory category,int selector,int field=0,int instance=-1);
|
GwXDRFoundMapping getMapping(GwXDRCategory category,int selector,int field=0,int instance=-1);
|
||||||
|
//returns a newly created buffer - user must destroy!
|
||||||
|
char * getUnMapped();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue