From 09b583ebd68b0f8b4aba871e40ae45050dc93173 Mon Sep 17 00:00:00 2001 From: andreas Date: Fri, 11 Oct 2024 16:14:22 +0200 Subject: [PATCH] also set water temperature (MTW) from PGN 130312 - with condition --- lib/config/GwConverterConfig.h | 2 + lib/nmea2kto0183/N2kDataToNMEA0183.cpp | 16 ++++- web/config.json | 99 ++++++++++++++------------ 3 files changed, 72 insertions(+), 45 deletions(-) diff --git a/lib/config/GwConverterConfig.h b/lib/config/GwConverterConfig.h index 546d885..d0dbc6a 100644 --- a/lib/config/GwConverterConfig.h +++ b/lib/config/GwConverterConfig.h @@ -70,6 +70,7 @@ class GwConverterConfig{ int min2KInterval=50; int rmcInterval=1000; int rmcCheckTime=4000; + int winst312=256; std::vector windMappings; void init(GwConfigHandler *config, GwLog*logger){ minXdrInterval=config->getInt(GwConfigDefinitions::minXdrInterval,100); @@ -82,6 +83,7 @@ class GwConverterConfig{ rmcInterval=config->getInt(GwConfigDefinitions::sendRMCi,1000); if (rmcInterval < 0) rmcInterval=0; if (rmcInterval > 0 && rmcInterval <100) rmcInterval=100; + winst312=config->getInt(GwConfigDefinitions::winst312,256); for (auto && it:windConfigs){ String cfg=config->getString(it.second); WindMapping mapping(it.first,cfg); diff --git a/lib/nmea2kto0183/N2kDataToNMEA0183.cpp b/lib/nmea2kto0183/N2kDataToNMEA0183.cpp index a64e498..1056c87 100644 --- a/lib/nmea2kto0183/N2kDataToNMEA0183.cpp +++ b/lib/nmea2kto0183/N2kDataToNMEA0183.cpp @@ -1344,7 +1344,6 @@ private: return; SendMessage(NMEA0183Msg); - i++; } GwXDRFoundMapping mapping=xdrMappings->getMapping(XDRTEMP,TempSource,0,0); @@ -1379,6 +1378,21 @@ private: LOG_DEBUG(GwLog::DEBUG,"unable to parse PGN %d",msg.PGN); return; } + if (TemperatureSource == N2kts_SeaTemperature && + (config.winst312 == TemperatureInstance || config.winst312 == 256)) { + updateDouble(boatData->WTemp, Temperature); + tNMEA0183Msg NMEA0183Msg; + + if (!NMEA0183Msg.Init("MTW", talkerId)) + return; + if (!NMEA0183Msg.AddDoubleField(KelvinToC(Temperature))) + return; + if (!NMEA0183Msg.AddStrField("C")) + return; + + SendMessage(NMEA0183Msg); + } + GwXDRFoundMapping mapping=xdrMappings->getMapping(XDRTEMP,(int)TemperatureSource,0,TemperatureInstance); if (updateDouble(&mapping,Temperature)){ LOG_DEBUG(GwLog::DEBUG+1,"found temperature mapping %s",mapping.definition->toString().c_str()); diff --git a/web/config.json b/web/config.json index 69df271..ca155ec 100644 --- a/web/config.json +++ b/web/config.json @@ -219,16 +219,56 @@ "category":"converter" }, { - "name":"checkRMCt", + "name": "checkRMCt", "label": "check RMC time", "type": "number", "description": "start sending RMC if we did not see an external RMC after this much ms", - "default":"4000", + "default": "4000", "min": 1000, - "check":"checkMinMax", - "category":"converter" - }, - { + "check": "checkMinMax", + "category": "converter" + }, + { + "name": "timeouts", + "type": "array", + "replace": [ + { + "n": "Default", + "d": "4000", + "l": "default", + "t": "NMEA" + }, + { + "n": "Sensor", + "d": "60000", + "l": "sensor", + "t": "sensor" + }, + { + "n": "Long", + "d": "32000", + "l": "long", + "t": "special NMEA" + }, + { + "n": "Ais", + "d": "120000", + "l": "ais", + "t": "ais" + } + ], + "children": [ + { + "name": "timo$n", + "label": "timeout $l", + "default": "$d", + "type": "number", + "description": "data timeouts(ms) for $t data", + "category": "converter" + } + ] + }, + { "name": "stbRudderI", "label":"stb rudder instance", "type": "number", @@ -305,44 +345,15 @@ ] }, { - "name": "timeouts", - "type": "array", - "replace":[ - { - "n":"Default", - "d":"4000", - "l": "default", - "t": "NMEA" - }, - { - "n":"Sensor", - "d":"60000", - "l": "sensor", - "t": "sensor" - }, - { - "n":"Long", - "d":"32000", - "l": "long", - "t": "special NMEA" - }, - { - "n":"Ais", - "d":"120000", - "l": "ais", - "t": "ais" - } - ], - "children":[ - { - "name":"timo$n", - "label":"timeout $l", - "default": "$d", - "type": "number", - "description": "data timeouts(ms) for $t data", - "category": "converter" - } - ] + "name": "winst312", + "label": "130312 WTemp iid", + "type": "number", + "check": "checkMinMax", + "min": -1, + "max": 256, + "description": "the temp instance of PGN 130312 used for water temperature, use -1 for none, 256 for any", + "default": "256", + "category":"converter" }, { "name": "usbActisense",