diff --git a/extra_script.py b/extra_script.py index 8d58014..89efc93 100644 --- a/extra_script.py +++ b/extra_script.py @@ -7,6 +7,8 @@ import inspect import json from datetime import datetime Import("env") +#print(env.Dump()) +OWN_FILE="extra_script.py" GEN_DIR='generated' CFG_FILE='web/config.json' XDR_FILE='web/xdrconfig.json' @@ -43,6 +45,11 @@ def isCurrent(infile,outfile): otime=os.path.getmtime(outfile) itime=os.path.getmtime(infile) if (otime >= itime): + own=os.path.join(basePath(),OWN_FILE) + if os.path.exists(own): + owntime=os.path.getmtime(own) + if owntime > otime: + return False print("%s is newer then %s, no need to recreate"%(outfile,infile)) return True return False diff --git a/lib/nmea2kto0183/N2kDataToNMEA0183.cpp b/lib/nmea2kto0183/N2kDataToNMEA0183.cpp index b5bddf8..99c2615 100644 --- a/lib/nmea2kto0183/N2kDataToNMEA0183.cpp +++ b/lib/nmea2kto0183/N2kDataToNMEA0183.cpp @@ -72,13 +72,7 @@ private: String buildXdrEntry(GwXDRFoundMapping &mapping,double value){ char buffer[40]; - String name=mapping.definition->xdrName; - if (mapping.definition->instanceMode == GwXDRMappingDef::IS_AUTO || - mapping.definition->instanceMode == GwXDRMappingDef::IS_SINGLE - ){ - name+="#"; - name+=String(mapping.instanceId); - } + String name=mapping.getTransducerName(); if (mapping.type->tonmea){ value=(* (mapping.type->tonmea))(value); } diff --git a/lib/xdrmappings/GwXDRMappings.cpp b/lib/xdrmappings/GwXDRMappings.cpp index b7f88e7..a0a70bb 100644 --- a/lib/xdrmappings/GwXDRMappings.cpp +++ b/lib/xdrmappings/GwXDRMappings.cpp @@ -1,5 +1,6 @@ #include "GwXDRMappings.h" #include "N2kMessages.h" + double PtoBar(double v) { if (N2kIsNA(v)) @@ -189,6 +190,16 @@ GwXDRMappingDef *GwXDRMappingDef::fromString(String s) } 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) { @@ -373,6 +384,20 @@ bool GwXDRMappings::addUnknown(GwXDRCategory category,int selector,int field,int uk=(uk<<7) + (field & 0x7f); if (instance < 0 || instance > 255) instance=256; //unknown uk=(uk << 9) + (instance & 0x1ff); - unknown.push_back(uk); + unknown.insert(uk); 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; } \ No newline at end of file diff --git a/lib/xdrmappings/GwXDRMappings.h b/lib/xdrmappings/GwXDRMappings.h index 66328c0..3c7e7f0 100644 --- a/lib/xdrmappings/GwXDRMappings.h +++ b/lib/xdrmappings/GwXDRMappings.h @@ -5,6 +5,7 @@ #include #include #include +#include //enum must match the defines in xdrconfig.json typedef enum { XDRTEMP=0, @@ -124,6 +125,7 @@ class GwXDRMappingDef{ rt += xdrUnit; return rt; } + String getTransducerName(int instance); private: static bool handleToken(String tok,int index,GwXDRMappingDef *def); }; @@ -157,6 +159,9 @@ class GwXDRFoundMapping{ empty=false; } GwXDRFoundMapping(){} + String getTransducerName(){ + return definition->getTransducerName(instanceId); + } }; class GwXDRMappings{ @@ -165,7 +170,7 @@ class GwXDRMappings{ GwConfigHandler *config; GwXDRMapping::N138Map n183Map; GwXDRMapping::N2KMap n2kMap; - std::vector unknown; + std::unordered_set unknown; GwXDRFoundMapping selectMapping(GwXDRMapping::MappingList *list,int instance,const char * key); bool addUnknown(GwXDRCategory category,int selector,int field=0,int instance=-1); public: @@ -175,6 +180,8 @@ class GwXDRMappings{ //the returned mapping will exactly contain one mapping def GwXDRFoundMapping getMapping(String xName,String xType,String xUnit); GwXDRFoundMapping getMapping(GwXDRCategory category,int selector,int field=0,int instance=-1); + //returns a newly created buffer - user must destroy! + char * getUnMapped(); };