From 47774baffda6f78dfea4d819345f890e373afa2d Mon Sep 17 00:00:00 2001 From: KEGustafsson Date: Tue, 16 May 2023 18:35:32 +0300 Subject: [PATCH 01/27] feature: aton meteorological data --- hooks/VDM.js | 200 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 200 insertions(+) diff --git a/hooks/VDM.js b/hooks/VDM.js index 10eb978c..edfe6639 100644 --- a/hooks/VDM.js +++ b/hooks/VDM.js @@ -268,6 +268,206 @@ module.exports = function (input, session) { }) } + if (data.avgwindspd) { + contextPrefix = 'atons.' + values.push({ + path: 'environment.averageWindSpeed', + value: data.avgwindspd, + }) + } + + if (data.windgust) { + contextPrefix = 'atons.' + values.push({ + path: 'environment.windGust', + value: data.windgust, + }) + } + + if (data.winddir) { + contextPrefix = 'atons.' + values.push({ + path: 'environment.windDirection', + value: data.winddir, + }) + } + + if (data.windgustdir) { + contextPrefix = 'atons.' + values.push({ + path: 'environment.windGustDirection', + value: data.windgustdir, + }) + } + + if (data.airtemp) { + contextPrefix = 'atons.' + values.push({ + path: 'environment.airTemperature', + value: data.airtemp, + }) + } + + if (data.relhumid) { + contextPrefix = 'atons.' + values.push({ + path: 'environment.relativeHumidity', + value: data.relhumid, + }) + } + + if (data.dewpoint) { + contextPrefix = 'atons.' + values.push({ + path: 'environment.dewPoint', + value: data.dewpoint, + }) + } + + if (data.airpress) { + contextPrefix = 'atons.' + values.push({ + path: 'environment.airPressure', + value: data.airpress, + }) + } + + if (data.airpressten) { + contextPrefix = 'atons.' + values.push({ + path: 'environment.airPressureTendency', + value: data.airpressten, + }) + } + + if (data.horvisib) { + contextPrefix = 'atons.' + values.push({ + path: 'environment.horizontalVisibility', + value: data.horvisib, + }) + } + + if (data.waterlevelten) { + contextPrefix = 'atons.' + values.push({ + path: 'environment.waterLevelTrend', + value: data.waterlevelten, + }) + } + + if (data.waterlevel) { + contextPrefix = 'atons.' + values.push({ + path: 'environment.waterLevel', + value: data.waterlevel, + }) + } + + if (data.surfcurrspd) { + contextPrefix = 'atons.' + values.push({ + path: 'environment.surfaceCurrentSpeed', + value: data.surfcurrspd, + }) + } + + if (data.surfcurrdir) { + contextPrefix = 'atons.' + values.push({ + path: 'environment.surfaceCurrentDirection', + value: data.surfcurrdir, + }) + } + + if (data.signwavewhgt) { + contextPrefix = 'atons.' + values.push({ + path: 'environment.significantWaveHeight', + value: data.signwavewhgt, + }) + } + + if (data.waveperiod) { + contextPrefix = 'atons.' + values.push({ + path: 'environment.wavePeriod', + value: data.waveperiod, + }) + } + + if (data.wavedir) { + contextPrefix = 'atons.' + values.push({ + path: 'environment.waveDirection', + value: data.wavedir, + }) + } + + if (data.swellhgt) { + contextPrefix = 'atons.' + values.push({ + path: 'environment.swellHeight', + value: data.swellhgt, + }) + } + + if (data.swellperiod) { + contextPrefix = 'atons.' + values.push({ + path: 'environment.swellPeriod', + value: data.swellperiod, + }) + } + + if (data.swelldir) { + contextPrefix = 'atons.' + values.push({ + path: 'environment.swellDirection', + value: data.swelldir, + }) + } + + if (data.seastate) { + contextPrefix = 'atons.' + values.push({ + path: 'environment.seaState', + value: data.seastate, + }) + } + + if (data.watertemp) { + contextPrefix = 'atons.' + values.push({ + path: 'environment.waterTemperature', + value: data.watertemp, + }) + } + + if (data.precipitation) { + contextPrefix = 'atons.' + values.push({ + path: 'environment.precipitation', + value: data.precipitation, + }) + } + + if (data.salinity) { + contextPrefix = 'atons.' + values.push({ + path: 'environment.salinity', + value: data.salinity, + }) + } + + if (data.ice) { + contextPrefix = 'atons.' + values.push({ + path: 'environment.ice', + value: data.ice, + }) + } + if (values.length === 0) { return null } From 8e8d859c8384519d9a9d2e31a71cd9261b1dfb5a Mon Sep 17 00:00:00 2001 From: KEGustafsson Date: Mon, 22 May 2023 02:25:45 +0000 Subject: [PATCH 02/27] fix: use SI units --- hooks/VDM.js | 260 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 172 insertions(+), 88 deletions(-) diff --git a/hooks/VDM.js b/hooks/VDM.js index edfe6639..3bbe4ec3 100644 --- a/hooks/VDM.js +++ b/hooks/VDM.js @@ -67,6 +67,50 @@ const specialManeuverMapping = { 3: 'reserved', } +const beaufortScale = { + 0: 'Flat', + 1: 'Ripples without crests', + 2: 'Small wavelets. Crests of glassy appearance, not breaking', + 3: 'Large wavelets. Crests begin to break; scattered whitecaps', + 4: 'Small waves', + 5: 'Moderate (1.2 m) longer waves. Some foam and spray', + 6: 'Large waves with foam crests and some spray', + 7: 'Sea heaps up and foam begins to streak', + 8: 'Moderately high waves with breaking crests forming spindrift. Streaks of foam', + 9: 'High waves (6-7 m) with dense foam. Wave crests start to roll over. Considerable spray', + 10: 'Very high waves. The sea surface is white and there is considerable tumbling. Visibility is reduced', + 11: 'Exceptionally high waves', + 12: 'Huge waves. Air filled with foam and spray. Sea completely white with driving spray. Visibility greatly reduced', + 13: 'not available', + 14: 'reserved', + 15: 'reserved', +} + +const statusTable = { + 0: 'steady', + 1: 'decreasing', + 2: 'increasing', + 3: 'not available', +} + +const precipitationType = { + 0: 'reserved', + 1: 'rain', + 2: 'thunderstorm', + 3: 'freezing rain', + 4: 'mixed/ice', + 5: 'snow', + 6: 'reserved', + 7: 'not available', +} + +const iceTable = { + 0: 'no', + 1: 'yes', + 2: 'reserved', + 3: 'not available', +} + module.exports = function (input, session) { const { id, sentence, parts, tags } = input const data = new Decoder(sentence, session) @@ -270,201 +314,241 @@ module.exports = function (input, session) { if (data.avgwindspd) { contextPrefix = 'atons.' - values.push({ - path: 'environment.averageWindSpeed', - value: data.avgwindspd, - }) + if (data.avgwindspd < 127) { + values.push({ + path: 'environment.averageWindSpeed', + value: utils.transform(data.avgwindspd, 'knots', 'ms'), + }) + } } if (data.windgust) { contextPrefix = 'atons.' - values.push({ - path: 'environment.windGust', - value: data.windgust, - }) + if (data.avgwindspd < 127) { + values.push({ + path: 'environment.windGust', + value: utils.transform(data.windgust, 'knots', 'ms'), + }) + } } if (data.winddir) { contextPrefix = 'atons.' - values.push({ - path: 'environment.windDirection', - value: data.winddir, - }) + if (data.winddir < 360) { + values.push({ + path: 'environment.windDirection', + value: utils.transform(data.winddir, 'deg', 'rad'), + }) + } } if (data.windgustdir) { contextPrefix = 'atons.' - values.push({ - path: 'environment.windGustDirection', - value: data.windgustdir, - }) + if (data.windgustdir < 360) { + values.push({ + path: 'environment.windGustDirection', + value: utils.transform(data.windgustdir, 'deg', 'rad'), + }) + } } if (data.airtemp) { contextPrefix = 'atons.' - values.push({ - path: 'environment.airTemperature', - value: data.airtemp, - }) + if (data.airtemp > -601 && data.airtemp < 601) { + values.push({ + path: 'environment.airTemperature', + value: utils.transform((data.airtemp / 10), 'c', 'k'), + }) + } } if (data.relhumid) { contextPrefix = 'atons.' - values.push({ - path: 'environment.relativeHumidity', - value: data.relhumid, - }) + if (data.relhumid < 101) { + values.push({ + path: 'environment.relativeHumidity', + value: data.relhumid, + }) + } } if (data.dewpoint) { contextPrefix = 'atons.' - values.push({ - path: 'environment.dewPoint', - value: data.dewpoint, - }) + if (data.dewpoint > -201 && data.dewpoint < 501) { + values.push({ + path: 'environment.dewPoint', + value: utils.transform((data.dewpoint / 10), 'c', 'k'), + }) + } } if (data.airpress) { contextPrefix = 'atons.' - values.push({ - path: 'environment.airPressure', - value: data.airpress, - }) + if (data.airpress < 403) { + values.push({ + path: 'environment.airPressure', + value: (data.airpress + 799) * 100, + }) + } } if (data.airpressten) { contextPrefix = 'atons.' values.push({ path: 'environment.airPressureTendency', - value: data.airpressten, + value: statusTable[data.airpressten], }) } if (data.horvisib) { contextPrefix = 'atons.' - values.push({ - path: 'environment.horizontalVisibility', - value: data.horvisib, - }) + if (data.horvisib < 127) { + values.push({ + path: 'environment.horizontalVisibility', + value: utils.transform((data.horvisib /10), 'nm', 'm'), + }) + } } - if (data.waterlevelten) { + if (data.waterlevel) { contextPrefix = 'atons.' - values.push({ - path: 'environment.waterLevelTrend', - value: data.waterlevelten, - }) + if (data.waterlevel < 4001) { + values.push({ + path: 'environment.waterLevel', + value: (data.waterlevel / 100) - 10, + }) + } } - if (data.waterlevel) { + if (data.waterlevelten) { contextPrefix = 'atons.' values.push({ - path: 'environment.waterLevel', - value: data.waterlevel, + path: 'environment.waterLevelTrend', + value: statusTable[data.waterlevelten], }) } if (data.surfcurrspd) { contextPrefix = 'atons.' - values.push({ - path: 'environment.surfaceCurrentSpeed', - value: data.surfcurrspd, - }) + if (data.surfcurrspd < 252) { + values.push({ + path: 'environment.surfaceCurrentSpeed', + value: utils.transform(data.surfcurrspd, 'knots', 'ms'), + }) + } } if (data.surfcurrdir) { contextPrefix = 'atons.' - values.push({ - path: 'environment.surfaceCurrentDirection', - value: data.surfcurrdir, - }) + if (data.surfcurrdir < 360) { + values.push({ + path: 'environment.surfaceCurrentDirection', + value: utils.transform(data.surfcurrdir, 'deg', 'rad'), + }) + } } if (data.signwavewhgt) { contextPrefix = 'atons.' - values.push({ - path: 'environment.significantWaveHeight', - value: data.signwavewhgt, - }) + if (data.signwavewhgt < 252) { + values.push({ + path: 'environment.significantWaveHeight', + value: data.signwavewhgt / 10, + }) + } } if (data.waveperiod) { contextPrefix = 'atons.' - values.push({ - path: 'environment.wavePeriod', - value: data.waveperiod, - }) + if (data.waveperiod < 61) { + values.push({ + path: 'environment.wavePeriod', + value: data.waveperiod, + }) + } } if (data.wavedir) { contextPrefix = 'atons.' - values.push({ - path: 'environment.waveDirection', - value: data.wavedir, - }) + if (data.wavedir < 360) { + values.push({ + path: 'environment.waveDirection', + value: utils.transform(data.wavedir, 'deg', 'rad'), + }) + } } if (data.swellhgt) { contextPrefix = 'atons.' - values.push({ - path: 'environment.swellHeight', - value: data.swellhgt, - }) + if (data.swellhgt < 252) { + values.push({ + path: 'environment.swellHeight', + value: data.swellhgt / 10, + }) + } } if (data.swellperiod) { contextPrefix = 'atons.' - values.push({ - path: 'environment.swellPeriod', - value: data.swellperiod, - }) + if (data.waveperiod < 61) { + values.push({ + path: 'environment.swellPeriod', + value: data.swellperiod, + }) + } } if (data.swelldir) { contextPrefix = 'atons.' - values.push({ - path: 'environment.swellDirection', - value: data.swelldir, - }) + if (data.wavedir < 360) { + values.push({ + path: 'environment.swellDirection', + value: utils.transform(data.swelldir, 'deg', 'rad'), + }) + } } if (data.seastate) { contextPrefix = 'atons.' values.push({ path: 'environment.seaState', - value: data.seastate, + value: beaufortScale[data.seastate], }) } if (data.watertemp) { contextPrefix = 'atons.' - values.push({ - path: 'environment.waterTemperature', - value: data.watertemp, - }) + if (data.watertemp > -101 && data.watertemp < 501) { + values.push({ + path: 'environment.waterTemperature', + value: utils.transform((data.watertemp / 10), 'c', 'k'), + }) + } } if (data.precipitation) { contextPrefix = 'atons.' values.push({ path: 'environment.precipitation', - value: data.precipitation, + value: precipitationType[data.precipitation], }) } if (data.salinity) { contextPrefix = 'atons.' - values.push({ - path: 'environment.salinity', - value: data.salinity, - }) + if (data.salinity < 502) { + values.push({ + path: 'environment.salinity', + value: data.salinity / 10, + }) + } } if (data.ice) { contextPrefix = 'atons.' values.push({ path: 'environment.ice', - value: data.ice, + value: beaufortScale[data.ice], }) } From c2262437c6a60d39ab56ea9dd0b519f0c16c4470 Mon Sep 17 00:00:00 2001 From: KEGustafsson Date: Mon, 22 May 2023 02:34:40 +0000 Subject: [PATCH 03/27] fix: ice table correction --- hooks/VDM.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/VDM.js b/hooks/VDM.js index 3bbe4ec3..2e2dccdc 100644 --- a/hooks/VDM.js +++ b/hooks/VDM.js @@ -548,7 +548,7 @@ module.exports = function (input, session) { contextPrefix = 'atons.' values.push({ path: 'environment.ice', - value: beaufortScale[data.ice], + value: iceTable[data.ice], }) } From c9938f98cbe10267e5745d0cfd9ccc9e81e039c2 Mon Sep 17 00:00:00 2001 From: KEGustafsson Date: Wed, 7 Jun 2023 23:40:18 +0300 Subject: [PATCH 04/27] fixes to meteo data functions --- hooks/VDM.js | 60 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/hooks/VDM.js b/hooks/VDM.js index 2e2dccdc..2e4300d2 100644 --- a/hooks/VDM.js +++ b/hooks/VDM.js @@ -324,7 +324,7 @@ module.exports = function (input, session) { if (data.windgust) { contextPrefix = 'atons.' - if (data.avgwindspd < 127) { + if (data.windgust < 127) { values.push({ path: 'environment.windGust', value: utils.transform(data.windgust, 'knots', 'ms'), @@ -394,10 +394,12 @@ module.exports = function (input, session) { if (data.airpressten) { contextPrefix = 'atons.' - values.push({ - path: 'environment.airPressureTendency', - value: statusTable[data.airpressten], - }) + if (data.airpressten < 3) { + values.push({ + path: 'environment.airPressureTendency', + value: statusTable[data.airpressten], + }) + } } if (data.horvisib) { @@ -405,7 +407,7 @@ module.exports = function (input, session) { if (data.horvisib < 127) { values.push({ path: 'environment.horizontalVisibility', - value: utils.transform((data.horvisib /10), 'nm', 'm'), + value: utils.transform((data.horvisib / 10), 'nm', 'm'), }) } } @@ -422,10 +424,12 @@ module.exports = function (input, session) { if (data.waterlevelten) { contextPrefix = 'atons.' - values.push({ - path: 'environment.waterLevelTrend', - value: statusTable[data.waterlevelten], - }) + if (data.waterlevelten < 3) { + values.push({ + path: 'environment.waterLevelTrend', + value: statusTable[data.waterlevelten], + }) + } } if (data.surfcurrspd) { @@ -433,7 +437,7 @@ module.exports = function (input, session) { if (data.surfcurrspd < 252) { values.push({ path: 'environment.surfaceCurrentSpeed', - value: utils.transform(data.surfcurrspd, 'knots', 'ms'), + value: utils.transform((data.surfcurrspd / 10), 'knots', 'ms'), }) } } @@ -490,7 +494,7 @@ module.exports = function (input, session) { if (data.swellperiod) { contextPrefix = 'atons.' - if (data.waveperiod < 61) { + if (data.swellperiod < 61) { values.push({ path: 'environment.swellPeriod', value: data.swellperiod, @@ -500,7 +504,7 @@ module.exports = function (input, session) { if (data.swelldir) { contextPrefix = 'atons.' - if (data.wavedir < 360) { + if (data.swelldir < 360) { values.push({ path: 'environment.swellDirection', value: utils.transform(data.swelldir, 'deg', 'rad'), @@ -510,10 +514,12 @@ module.exports = function (input, session) { if (data.seastate) { contextPrefix = 'atons.' - values.push({ - path: 'environment.seaState', - value: beaufortScale[data.seastate], - }) + if (data.seastate < 13) { + values.push({ + path: 'environment.seaState', + value: beaufortScale[data.seastate], + }) + } } if (data.watertemp) { @@ -528,10 +534,12 @@ module.exports = function (input, session) { if (data.precipitation) { contextPrefix = 'atons.' - values.push({ - path: 'environment.precipitation', - value: precipitationType[data.precipitation], - }) + if (data.precipitation < 7) { + values.push({ + path: 'environment.precipitation', + value: precipitationType[data.precipitation], + }) + } } if (data.salinity) { @@ -546,10 +554,12 @@ module.exports = function (input, session) { if (data.ice) { contextPrefix = 'atons.' - values.push({ - path: 'environment.ice', - value: iceTable[data.ice], - }) + if (data.ice < 3) { + values.push({ + path: 'environment.ice', + value: iceTable[data.ice], + }) + } } if (values.length === 0) { From b727a2b3e4ceb4683c3a9bdb92ac8530c7428d05 Mon Sep 17 00:00:00 2001 From: Karl-Erik Gustafsson Date: Mon, 25 Dec 2023 12:35:04 +0200 Subject: [PATCH 05/27] fix: contextPrefix and paths changed --- hooks/VDM.js | 100 +++++++++++++++++++++++++-------------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/hooks/VDM.js b/hooks/VDM.js index 2e4300d2..426e2516 100644 --- a/hooks/VDM.js +++ b/hooks/VDM.js @@ -313,250 +313,250 @@ module.exports = function (input, session) { } if (data.avgwindspd) { - contextPrefix = 'atons.' + contextPrefix = 'meteo.' if (data.avgwindspd < 127) { values.push({ - path: 'environment.averageWindSpeed', + path: 'environment.observations.wind.averageSpeed', value: utils.transform(data.avgwindspd, 'knots', 'ms'), }) } } if (data.windgust) { - contextPrefix = 'atons.' + contextPrefix = 'meteo.' if (data.windgust < 127) { values.push({ - path: 'environment.windGust', + path: 'environment.observations.wind.gust', value: utils.transform(data.windgust, 'knots', 'ms'), }) } } if (data.winddir) { - contextPrefix = 'atons.' + contextPrefix = 'meteo.' if (data.winddir < 360) { values.push({ - path: 'environment.windDirection', + path: 'environment.observations.wind.direction', value: utils.transform(data.winddir, 'deg', 'rad'), }) } } if (data.windgustdir) { - contextPrefix = 'atons.' + contextPrefix = 'meteo.' if (data.windgustdir < 360) { values.push({ - path: 'environment.windGustDirection', + path: 'environment.observations.wind.gustDirection', value: utils.transform(data.windgustdir, 'deg', 'rad'), }) } } if (data.airtemp) { - contextPrefix = 'atons.' + contextPrefix = 'meteo.' if (data.airtemp > -601 && data.airtemp < 601) { values.push({ - path: 'environment.airTemperature', + path: 'environment.observations.air.temperature', value: utils.transform((data.airtemp / 10), 'c', 'k'), }) } } if (data.relhumid) { - contextPrefix = 'atons.' + contextPrefix = 'meteo.' if (data.relhumid < 101) { values.push({ - path: 'environment.relativeHumidity', + path: 'environment.observations.relativeHumidity', value: data.relhumid, }) } } if (data.dewpoint) { - contextPrefix = 'atons.' + contextPrefix = 'meteo.' if (data.dewpoint > -201 && data.dewpoint < 501) { values.push({ - path: 'environment.dewPoint', + path: 'environment.observations.dewPoint', value: utils.transform((data.dewpoint / 10), 'c', 'k'), }) } } if (data.airpress) { - contextPrefix = 'atons.' + contextPrefix = 'meteo.' if (data.airpress < 403) { values.push({ - path: 'environment.airPressure', + path: 'environment.observations.air.pressure', value: (data.airpress + 799) * 100, }) } } if (data.airpressten) { - contextPrefix = 'atons.' + contextPrefix = 'meteo.' if (data.airpressten < 3) { values.push({ - path: 'environment.airPressureTendency', + path: 'environment.observations.air.pressureTendency', value: statusTable[data.airpressten], }) } } if (data.horvisib) { - contextPrefix = 'atons.' + contextPrefix = 'meteo.' if (data.horvisib < 127) { values.push({ - path: 'environment.horizontalVisibility', + path: 'environment.observations.horizontalVisibility', value: utils.transform((data.horvisib / 10), 'nm', 'm'), }) } } if (data.waterlevel) { - contextPrefix = 'atons.' + contextPrefix = 'meteo.' if (data.waterlevel < 4001) { values.push({ - path: 'environment.waterLevel', + path: 'environment.observations.water.level', value: (data.waterlevel / 100) - 10, }) } } if (data.waterlevelten) { - contextPrefix = 'atons.' + contextPrefix = 'meteo.' if (data.waterlevelten < 3) { values.push({ - path: 'environment.waterLevelTrend', + path: 'environment.observations.water.levelTrend', value: statusTable[data.waterlevelten], }) } } if (data.surfcurrspd) { - contextPrefix = 'atons.' + contextPrefix = 'meteo.' if (data.surfcurrspd < 252) { values.push({ - path: 'environment.surfaceCurrentSpeed', + path: 'environment.observations.surfaceCurrent.speed', value: utils.transform((data.surfcurrspd / 10), 'knots', 'ms'), }) } } if (data.surfcurrdir) { - contextPrefix = 'atons.' + contextPrefix = 'meteo.' if (data.surfcurrdir < 360) { values.push({ - path: 'environment.surfaceCurrentDirection', + path: 'environment.observations.surfaceCurrent.direction', value: utils.transform(data.surfcurrdir, 'deg', 'rad'), }) } } if (data.signwavewhgt) { - contextPrefix = 'atons.' + contextPrefix = 'meteo.' if (data.signwavewhgt < 252) { values.push({ - path: 'environment.significantWaveHeight', + path: 'environment.observations.wave.significantHeight', value: data.signwavewhgt / 10, }) } } if (data.waveperiod) { - contextPrefix = 'atons.' + contextPrefix = 'meteo.' if (data.waveperiod < 61) { values.push({ - path: 'environment.wavePeriod', + path: 'environment.observations.wave.period', value: data.waveperiod, }) } } if (data.wavedir) { - contextPrefix = 'atons.' + contextPrefix = 'meteo.' if (data.wavedir < 360) { values.push({ - path: 'environment.waveDirection', + path: 'environment.observations.wave.direction', value: utils.transform(data.wavedir, 'deg', 'rad'), }) } } if (data.swellhgt) { - contextPrefix = 'atons.' + contextPrefix = 'meteo.' if (data.swellhgt < 252) { values.push({ - path: 'environment.swellHeight', + path: 'environment.observations.swell.height', value: data.swellhgt / 10, }) } } if (data.swellperiod) { - contextPrefix = 'atons.' + contextPrefix = 'meteo.' if (data.swellperiod < 61) { values.push({ - path: 'environment.swellPeriod', + path: 'environment.observations.swell.period', value: data.swellperiod, }) } } if (data.swelldir) { - contextPrefix = 'atons.' + contextPrefix = 'meteo.' if (data.swelldir < 360) { values.push({ - path: 'environment.swellDirection', + path: 'environment.observations.swell.direction', value: utils.transform(data.swelldir, 'deg', 'rad'), }) } } if (data.seastate) { - contextPrefix = 'atons.' + contextPrefix = 'meteo.' if (data.seastate < 13) { values.push({ - path: 'environment.seaState', + path: 'environment.observations.seaState', value: beaufortScale[data.seastate], }) } } if (data.watertemp) { - contextPrefix = 'atons.' + contextPrefix = 'meteo.' if (data.watertemp > -101 && data.watertemp < 501) { values.push({ - path: 'environment.waterTemperature', + path: 'environment.observations.water.temperature', value: utils.transform((data.watertemp / 10), 'c', 'k'), }) } } if (data.precipitation) { - contextPrefix = 'atons.' + contextPrefix = 'meteo.' if (data.precipitation < 7) { values.push({ - path: 'environment.precipitation', + path: 'environment.observations.precipitation', value: precipitationType[data.precipitation], }) } } if (data.salinity) { - contextPrefix = 'atons.' + contextPrefix = 'meteo.' if (data.salinity < 502) { values.push({ - path: 'environment.salinity', + path: 'environment.observations.water.salinity', value: data.salinity / 10, }) } } if (data.ice) { - contextPrefix = 'atons.' + contextPrefix = 'meteo.' if (data.ice < 3) { values.push({ - path: 'environment.ice', + path: 'environment.observations.water.ice', value: iceTable[data.ice], }) } From 9ce8418b4161d071e9b7a63ea87f2e01a41cb54f Mon Sep 17 00:00:00 2001 From: Karl-Erik Gustafsson Date: Mon, 25 Dec 2023 22:45:47 +0200 Subject: [PATCH 06/27] fix: meteo data path modifications --- hooks/VDM.js | 111 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 67 insertions(+), 44 deletions(-) diff --git a/hooks/VDM.js b/hooks/VDM.js index 426e2516..80e462f0 100644 --- a/hooks/VDM.js +++ b/hooks/VDM.js @@ -159,16 +159,6 @@ module.exports = function (input, session) { }) } - if (data.lon && data.lat) { - values.push({ - path: 'navigation.position', - value: { - longitude: data.lon, - latitude: data.lat, - }, - }) - } - if (data.length) { values.push({ path: 'design.length', @@ -312,11 +302,13 @@ module.exports = function (input, session) { }) } + const meteoLocation = `${data.lon.toString().replace('.', '_')}__${data.lat.toString().replace('.', '_')}` + if (data.avgwindspd) { contextPrefix = 'meteo.' if (data.avgwindspd < 127) { values.push({ - path: 'environment.observations.wind.averageSpeed', + path: `environment.observations.${meteoLocation}.wind.averageSpeed`, value: utils.transform(data.avgwindspd, 'knots', 'ms'), }) } @@ -326,7 +318,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.windgust < 127) { values.push({ - path: 'environment.observations.wind.gust', + path: `environment.observations.${meteoLocation}.wind.gust`, value: utils.transform(data.windgust, 'knots', 'ms'), }) } @@ -336,7 +328,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.winddir < 360) { values.push({ - path: 'environment.observations.wind.direction', + path: `environment.observations.${meteoLocation}.wind.direction`, value: utils.transform(data.winddir, 'deg', 'rad'), }) } @@ -346,7 +338,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.windgustdir < 360) { values.push({ - path: 'environment.observations.wind.gustDirection', + path: `environment.observations.${meteoLocation}.wind.gustDirection`, value: utils.transform(data.windgustdir, 'deg', 'rad'), }) } @@ -356,7 +348,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.airtemp > -601 && data.airtemp < 601) { values.push({ - path: 'environment.observations.air.temperature', + path: `environment.observations.${meteoLocation}.air.temperature`, value: utils.transform((data.airtemp / 10), 'c', 'k'), }) } @@ -366,7 +358,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.relhumid < 101) { values.push({ - path: 'environment.observations.relativeHumidity', + path: `environment.observations.${meteoLocation}.air.relativeHumidity`, value: data.relhumid, }) } @@ -376,7 +368,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.dewpoint > -201 && data.dewpoint < 501) { values.push({ - path: 'environment.observations.dewPoint', + path: `environment.observations.${meteoLocation}.air.dewPoint`, value: utils.transform((data.dewpoint / 10), 'c', 'k'), }) } @@ -386,7 +378,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.airpress < 403) { values.push({ - path: 'environment.observations.air.pressure', + path: `environment.observations.${meteoLocation}.air.pressure`, value: (data.airpress + 799) * 100, }) } @@ -396,7 +388,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.airpressten < 3) { values.push({ - path: 'environment.observations.air.pressureTendency', + path: `environment.observations.${meteoLocation}.air.pressureTendency`, value: statusTable[data.airpressten], }) } @@ -406,7 +398,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.horvisib < 127) { values.push({ - path: 'environment.observations.horizontalVisibility', + path: `environment.observations.${meteoLocation}.air.horizontalVisibility`, value: utils.transform((data.horvisib / 10), 'nm', 'm'), }) } @@ -416,7 +408,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.waterlevel < 4001) { values.push({ - path: 'environment.observations.water.level', + path: `environment.observations.${meteoLocation}.water.level`, value: (data.waterlevel / 100) - 10, }) } @@ -426,7 +418,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.waterlevelten < 3) { values.push({ - path: 'environment.observations.water.levelTrend', + path: `environment.observations.${meteoLocation}.water.levelTrend`, value: statusTable[data.waterlevelten], }) } @@ -436,7 +428,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.surfcurrspd < 252) { values.push({ - path: 'environment.observations.surfaceCurrent.speed', + path: `environment.observations.${meteoLocation}.surfaceCurrent.speed`, value: utils.transform((data.surfcurrspd / 10), 'knots', 'ms'), }) } @@ -446,7 +438,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.surfcurrdir < 360) { values.push({ - path: 'environment.observations.surfaceCurrent.direction', + path: `environment.observations.${meteoLocation}.surfaceCurrent.direction`, value: utils.transform(data.surfcurrdir, 'deg', 'rad'), }) } @@ -456,7 +448,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.signwavewhgt < 252) { values.push({ - path: 'environment.observations.wave.significantHeight', + path: `environment.observations.${meteoLocation}.wave.significantHeight`, value: data.signwavewhgt / 10, }) } @@ -466,7 +458,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.waveperiod < 61) { values.push({ - path: 'environment.observations.wave.period', + path: `environment.observations.${meteoLocation}.wave.period`, value: data.waveperiod, }) } @@ -476,7 +468,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.wavedir < 360) { values.push({ - path: 'environment.observations.wave.direction', + path: `environment.observations.${meteoLocation}.wave.direction`, value: utils.transform(data.wavedir, 'deg', 'rad'), }) } @@ -486,7 +478,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.swellhgt < 252) { values.push({ - path: 'environment.observations.swell.height', + path: `environment.observations.${meteoLocation}.swell.height`, value: data.swellhgt / 10, }) } @@ -496,7 +488,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.swellperiod < 61) { values.push({ - path: 'environment.observations.swell.period', + path: `environment.observations.${meteoLocation}.swell.period`, value: data.swellperiod, }) } @@ -506,7 +498,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.swelldir < 360) { values.push({ - path: 'environment.observations.swell.direction', + path: `environment.observations.${meteoLocation}.swell.direction`, value: utils.transform(data.swelldir, 'deg', 'rad'), }) } @@ -516,7 +508,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.seastate < 13) { values.push({ - path: 'environment.observations.seaState', + path: `environment.observations.${meteoLocation}.seaState`, value: beaufortScale[data.seastate], }) } @@ -526,7 +518,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.watertemp > -101 && data.watertemp < 501) { values.push({ - path: 'environment.observations.water.temperature', + path: `environment.observations.${meteoLocation}.water.temperature`, value: utils.transform((data.watertemp / 10), 'c', 'k'), }) } @@ -536,7 +528,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.precipitation < 7) { values.push({ - path: 'environment.observations.precipitation', + path: `environment.observations.${meteoLocation}.precipitation`, value: precipitationType[data.precipitation], }) } @@ -546,7 +538,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.salinity < 502) { values.push({ - path: 'environment.observations.water.salinity', + path: `environment.observations.${meteoLocation}.water.salinity`, value: data.salinity / 10, }) } @@ -556,7 +548,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.ice < 3) { values.push({ - path: 'environment.observations.water.ice', + path: `environment.observations.${meteoLocation}.ice`, value: iceTable[data.ice], }) } @@ -566,15 +558,46 @@ module.exports = function (input, session) { return null } - const delta = { - context: contextPrefix + `urn:mrn:imo:mmsi:${data.mmsi}`, - updates: [ - { - source: tags.source, - timestamp: tags.timestamp, - values: values, - }, - ], + if (contextPrefix !== 'meteo.'){ + if (data.lon && data.lat) { + values.push({ + path: 'navigation.position', + value: { + longitude: data.lon, + latitude: data.lat, + }, + }) + } + const delta = { + context: contextPrefix + `urn:mrn:imo:mmsi:${data.mmsi}`, + updates: [ + { + source: tags.source, + timestamp: tags.timestamp, + values: values, + }, + ], + } + } else { + if (data.lon && data.lat) { + values.push({ + path: `environment.observations.${meteoLocation}`, + value: { + longitude: data.lon, + latitude: data.lat, + }, + }) + } + const delta = { + context: contextPrefix + `urn:mrn:imo:mmsi:${data.mmsi}`, + updates: [ + { + $source: `location__${data.lat}__${data.lon}`, + timestamp: tags.timestamp, + values: values, + }, + ], + } } return delta From f30118a1ec354485ff30c20a7ba11c1076a251f9 Mon Sep 17 00:00:00 2001 From: Karl-Erik Gustafsson Date: Mon, 25 Dec 2023 23:30:38 +0200 Subject: [PATCH 07/27] fix: testing --- hooks/VDM.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/hooks/VDM.js b/hooks/VDM.js index 80e462f0..db78fa01 100644 --- a/hooks/VDM.js +++ b/hooks/VDM.js @@ -20,6 +20,8 @@ const debug = require('debug')('signalk-parser-nmea0183/VDM') const utils = require('@signalk/nmea0183-utilities') const Decoder = require('ggencoder').AisDecode const schema = require('@signalk/signalk-schema') +let delta +let meteoLocation const stateMapping = { 0: 'motoring', @@ -302,7 +304,9 @@ module.exports = function (input, session) { }) } - const meteoLocation = `${data.lon.toString().replace('.', '_')}__${data.lat.toString().replace('.', '_')}` + if (data.lon && data.lat) { + meteoLocation = data.lon.toString().replace('.', '_') + "__" + data.lat.toString().replace('.', '_') + } if (data.avgwindspd) { contextPrefix = 'meteo.' @@ -558,21 +562,21 @@ module.exports = function (input, session) { return null } - if (contextPrefix !== 'meteo.'){ + if (contextPrefix === 'meteo.'){ if (data.lon && data.lat) { values.push({ - path: 'navigation.position', + path: `environment.observations.${meteoLocation}`, value: { longitude: data.lon, latitude: data.lat, }, }) } - const delta = { + delta = { context: contextPrefix + `urn:mrn:imo:mmsi:${data.mmsi}`, updates: [ { - source: tags.source, + $source: `location__${data.lat}__${data.lon}`, timestamp: tags.timestamp, values: values, }, @@ -581,18 +585,18 @@ module.exports = function (input, session) { } else { if (data.lon && data.lat) { values.push({ - path: `environment.observations.${meteoLocation}`, + path: 'navigation.position', value: { longitude: data.lon, latitude: data.lat, }, }) } - const delta = { + delta = { context: contextPrefix + `urn:mrn:imo:mmsi:${data.mmsi}`, updates: [ { - $source: `location__${data.lat}__${data.lon}`, + source: tags.source, timestamp: tags.timestamp, values: values, }, From f00ce24683e8b2bc321c3a3455e3c744de4fd180 Mon Sep 17 00:00:00 2001 From: Karl-Erik Gustafsson Date: Tue, 26 Dec 2023 09:42:08 +0200 Subject: [PATCH 08/27] fix: paths for surfaceCurrents --- hooks/VDM.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hooks/VDM.js b/hooks/VDM.js index db78fa01..ad9ee007 100644 --- a/hooks/VDM.js +++ b/hooks/VDM.js @@ -432,7 +432,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.surfcurrspd < 252) { values.push({ - path: `environment.observations.${meteoLocation}.surfaceCurrent.speed`, + path: `environment.observations.${meteoLocation}.water.surfaceCurrentSpeed`, value: utils.transform((data.surfcurrspd / 10), 'knots', 'ms'), }) } @@ -442,7 +442,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.surfcurrdir < 360) { values.push({ - path: `environment.observations.${meteoLocation}.surfaceCurrent.direction`, + path: `environment.observations.${meteoLocation}.water.surfaceCurrentDirection`, value: utils.transform(data.surfcurrdir, 'deg', 'rad'), }) } From 82ebd919b221a75c052487f4a9e6fa8545eb9109 Mon Sep 17 00:00:00 2001 From: Karl-Erik Gustafsson Date: Tue, 26 Dec 2023 21:11:10 +0200 Subject: [PATCH 09/27] fix: regrouping paths --- hooks/VDM.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/hooks/VDM.js b/hooks/VDM.js index ad9ee007..44099bd3 100644 --- a/hooks/VDM.js +++ b/hooks/VDM.js @@ -312,7 +312,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.avgwindspd < 127) { values.push({ - path: `environment.observations.${meteoLocation}.wind.averageSpeed`, + path: `environment.observations.${meteoLocation}.air.windAverageSpeed`, value: utils.transform(data.avgwindspd, 'knots', 'ms'), }) } @@ -322,7 +322,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.windgust < 127) { values.push({ - path: `environment.observations.${meteoLocation}.wind.gust`, + path: `environment.observations.${meteoLocation}.air.windGust`, value: utils.transform(data.windgust, 'knots', 'ms'), }) } @@ -332,7 +332,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.winddir < 360) { values.push({ - path: `environment.observations.${meteoLocation}.wind.direction`, + path: `environment.observations.${meteoLocation}.air.windDirection`, value: utils.transform(data.winddir, 'deg', 'rad'), }) } @@ -342,7 +342,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.windgustdir < 360) { values.push({ - path: `environment.observations.${meteoLocation}.wind.gustDirection`, + path: `environment.observations.${meteoLocation}.air.windGustDirection`, value: utils.transform(data.windgustdir, 'deg', 'rad'), }) } @@ -452,7 +452,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.signwavewhgt < 252) { values.push({ - path: `environment.observations.${meteoLocation}.wave.significantHeight`, + path: `environment.observations.${meteoLocation}.water.waveSignificantHeight`, value: data.signwavewhgt / 10, }) } @@ -462,7 +462,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.waveperiod < 61) { values.push({ - path: `environment.observations.${meteoLocation}.wave.period`, + path: `environment.observations.${meteoLocation}.water.wavePeriod`, value: data.waveperiod, }) } @@ -472,7 +472,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.wavedir < 360) { values.push({ - path: `environment.observations.${meteoLocation}.wave.direction`, + path: `environment.observations.${meteoLocation}.water.waveDirection`, value: utils.transform(data.wavedir, 'deg', 'rad'), }) } @@ -482,7 +482,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.swellhgt < 252) { values.push({ - path: `environment.observations.${meteoLocation}.swell.height`, + path: `environment.observations.${meteoLocation}.water.swellHeight`, value: data.swellhgt / 10, }) } @@ -492,7 +492,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.swellperiod < 61) { values.push({ - path: `environment.observations.${meteoLocation}.swell.period`, + path: `environment.observations.${meteoLocation}.water.swellPeriod`, value: data.swellperiod, }) } @@ -502,7 +502,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.swelldir < 360) { values.push({ - path: `environment.observations.${meteoLocation}.swell.direction`, + path: `environment.observations.${meteoLocation}.water.swellDirection`, value: utils.transform(data.swelldir, 'deg', 'rad'), }) } @@ -512,7 +512,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.seastate < 13) { values.push({ - path: `environment.observations.${meteoLocation}.seaState`, + path: `environment.observations.${meteoLocation}.water.seaState`, value: beaufortScale[data.seastate], }) } @@ -532,7 +532,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.precipitation < 7) { values.push({ - path: `environment.observations.${meteoLocation}.precipitation`, + path: `environment.observations.${meteoLocation}.air.precipitation`, value: precipitationType[data.precipitation], }) } @@ -552,7 +552,7 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' if (data.ice < 3) { values.push({ - path: `environment.observations.${meteoLocation}.ice`, + path: `environment.observations.${meteoLocation}.water.ice`, value: iceTable[data.ice], }) } From 51f24e021fc49c99b85bc220daf377d544a01de7 Mon Sep 17 00:00:00 2001 From: Karl-Erik Gustafsson Date: Fri, 12 Jan 2024 17:32:38 +0200 Subject: [PATCH 10/27] fix: paths updated and using new features from ggencoder --- hooks/VDM.js | 310 ++++++++++++++++++++------------------------------- 1 file changed, 118 insertions(+), 192 deletions(-) diff --git a/hooks/VDM.js b/hooks/VDM.js index 44099bd3..a9fe4c34 100644 --- a/hooks/VDM.js +++ b/hooks/VDM.js @@ -305,303 +305,229 @@ module.exports = function (input, session) { } if (data.lon && data.lat) { - meteoLocation = data.lon.toString().replace('.', '_') + "__" + data.lat.toString().replace('.', '_') + values.push({ + path: 'navigation.position', + value: { + longitude: data.lon, + latitude: data.lat, + }, + }) } if (data.avgwindspd) { contextPrefix = 'meteo.' - if (data.avgwindspd < 127) { - values.push({ - path: `environment.observations.${meteoLocation}.air.windAverageSpeed`, - value: utils.transform(data.avgwindspd, 'knots', 'ms'), - }) - } + values.push({ + path: `environment.air.windAverageSpeed`, + value: utils.transform(data.avgwindspd, 'knots', 'ms'), + }) } if (data.windgust) { contextPrefix = 'meteo.' - if (data.windgust < 127) { - values.push({ - path: `environment.observations.${meteoLocation}.air.windGust`, - value: utils.transform(data.windgust, 'knots', 'ms'), - }) - } + values.push({ + path: `environment.air.windGust`, + value: utils.transform(data.windgust, 'knots', 'ms'), + }) } if (data.winddir) { contextPrefix = 'meteo.' - if (data.winddir < 360) { - values.push({ - path: `environment.observations.${meteoLocation}.air.windDirection`, - value: utils.transform(data.winddir, 'deg', 'rad'), - }) - } + values.push({ + path: `environment.air.windDirection`, + value: utils.transform(data.winddir, 'deg', 'rad'), + }) } if (data.windgustdir) { contextPrefix = 'meteo.' - if (data.windgustdir < 360) { - values.push({ - path: `environment.observations.${meteoLocation}.air.windGustDirection`, - value: utils.transform(data.windgustdir, 'deg', 'rad'), - }) - } + values.push({ + path: `environment.air.windGustDirection`, + value: utils.transform(data.windgustdir, 'deg', 'rad'), + }) } if (data.airtemp) { contextPrefix = 'meteo.' - if (data.airtemp > -601 && data.airtemp < 601) { - values.push({ - path: `environment.observations.${meteoLocation}.air.temperature`, - value: utils.transform((data.airtemp / 10), 'c', 'k'), - }) - } + values.push({ + path: `environment.air.temperature`, + value: utils.transform(data.airtemp, 'c', 'k'), + }) } if (data.relhumid) { contextPrefix = 'meteo.' - if (data.relhumid < 101) { - values.push({ - path: `environment.observations.${meteoLocation}.air.relativeHumidity`, - value: data.relhumid, - }) - } + values.push({ + path: `environment.air.relativeHumidity`, + value: data.relhumid, + }) } if (data.dewpoint) { contextPrefix = 'meteo.' - if (data.dewpoint > -201 && data.dewpoint < 501) { - values.push({ - path: `environment.observations.${meteoLocation}.air.dewPoint`, - value: utils.transform((data.dewpoint / 10), 'c', 'k'), - }) - } + values.push({ + path: `environment.air.dewPoint`, + value: utils.transform(data.dewpoint, 'c', 'k'), + }) } if (data.airpress) { contextPrefix = 'meteo.' - if (data.airpress < 403) { - values.push({ - path: `environment.observations.${meteoLocation}.air.pressure`, - value: (data.airpress + 799) * 100, - }) - } + values.push({ + path: `environment.air.pressure`, + value: data.airpress * 100, + }) + } if (data.airpressten) { contextPrefix = 'meteo.' - if (data.airpressten < 3) { - values.push({ - path: `environment.observations.${meteoLocation}.air.pressureTendency`, - value: statusTable[data.airpressten], - }) - } + values.push({ + path: `environment.air.pressureTendency`, + value: statusTable[data.airpressten], + }) } if (data.horvisib) { contextPrefix = 'meteo.' - if (data.horvisib < 127) { - values.push({ - path: `environment.observations.${meteoLocation}.air.horizontalVisibility`, - value: utils.transform((data.horvisib / 10), 'nm', 'm'), - }) - } + values.push({ + path: `environment.air.horizontalVisibility`, + value: utils.transform(data.horvisib, 'nm', 'm'), + }) } if (data.waterlevel) { contextPrefix = 'meteo.' - if (data.waterlevel < 4001) { - values.push({ - path: `environment.observations.${meteoLocation}.water.level`, - value: (data.waterlevel / 100) - 10, - }) - } + values.push({ + path: `environment.water.level`, + value: data.waterlevel, + }) } if (data.waterlevelten) { contextPrefix = 'meteo.' - if (data.waterlevelten < 3) { - values.push({ - path: `environment.observations.${meteoLocation}.water.levelTrend`, - value: statusTable[data.waterlevelten], - }) - } + values.push({ + path: `environment.water.levelTrend`, + value: statusTable[data.waterlevelten], + }) } if (data.surfcurrspd) { contextPrefix = 'meteo.' - if (data.surfcurrspd < 252) { - values.push({ - path: `environment.observations.${meteoLocation}.water.surfaceCurrentSpeed`, - value: utils.transform((data.surfcurrspd / 10), 'knots', 'ms'), - }) - } + values.push({ + path: `environment.water.surfaceCurrentSpeed`, + value: utils.transform(data.surfcurrspd, 'knots', 'ms'), + }) } if (data.surfcurrdir) { contextPrefix = 'meteo.' - if (data.surfcurrdir < 360) { - values.push({ - path: `environment.observations.${meteoLocation}.water.surfaceCurrentDirection`, - value: utils.transform(data.surfcurrdir, 'deg', 'rad'), - }) - } + values.push({ + path: `environment.water.surfaceCurrentDirection`, + value: utils.transform(data.surfcurrdir, 'deg', 'rad'), + }) } if (data.signwavewhgt) { contextPrefix = 'meteo.' - if (data.signwavewhgt < 252) { - values.push({ - path: `environment.observations.${meteoLocation}.water.waveSignificantHeight`, - value: data.signwavewhgt / 10, - }) - } + values.push({ + path: `environment.water.waveSignificantHeight`, + value: data.signwavewhgt, + }) } if (data.waveperiod) { contextPrefix = 'meteo.' - if (data.waveperiod < 61) { - values.push({ - path: `environment.observations.${meteoLocation}.water.wavePeriod`, - value: data.waveperiod, - }) - } + values.push({ + path: `environment.water.wavePeriod`, + value: data.waveperiod, + }) } if (data.wavedir) { contextPrefix = 'meteo.' - if (data.wavedir < 360) { - values.push({ - path: `environment.observations.${meteoLocation}.water.waveDirection`, - value: utils.transform(data.wavedir, 'deg', 'rad'), - }) - } + values.push({ + path: `environment.water.waveDirection`, + value: utils.transform(data.wavedir, 'deg', 'rad'), + }) } if (data.swellhgt) { contextPrefix = 'meteo.' - if (data.swellhgt < 252) { - values.push({ - path: `environment.observations.${meteoLocation}.water.swellHeight`, - value: data.swellhgt / 10, - }) - } + values.push({ + path: `environment.water.swellHeight`, + value: data.swellhgt, + }) } if (data.swellperiod) { contextPrefix = 'meteo.' - if (data.swellperiod < 61) { - values.push({ - path: `environment.observations.${meteoLocation}.water.swellPeriod`, - value: data.swellperiod, - }) - } + values.push({ + path: `environment.water.swellPeriod`, + value: data.swellperiod, + }) } if (data.swelldir) { contextPrefix = 'meteo.' - if (data.swelldir < 360) { - values.push({ - path: `environment.observations.${meteoLocation}.water.swellDirection`, - value: utils.transform(data.swelldir, 'deg', 'rad'), - }) - } + values.push({ + path: `environment.water.swellDirection`, + value: utils.transform(data.swelldir, 'deg', 'rad'), + }) } if (data.seastate) { contextPrefix = 'meteo.' - if (data.seastate < 13) { - values.push({ - path: `environment.observations.${meteoLocation}.water.seaState`, - value: beaufortScale[data.seastate], - }) - } + values.push({ + path: `environment.water.seaState`, + value: beaufortScale[data.seastate], + }) } if (data.watertemp) { contextPrefix = 'meteo.' - if (data.watertemp > -101 && data.watertemp < 501) { - values.push({ - path: `environment.observations.${meteoLocation}.water.temperature`, - value: utils.transform((data.watertemp / 10), 'c', 'k'), - }) - } + values.push({ + path: `environment.water.temperature`, + value: utils.transform(data.watertemp, 'c', 'k'), + }) } if (data.precipitation) { contextPrefix = 'meteo.' - if (data.precipitation < 7) { - values.push({ - path: `environment.observations.${meteoLocation}.air.precipitation`, - value: precipitationType[data.precipitation], - }) - } + values.push({ + path: `environment.air.precipitation`, + value: precipitationType[data.precipitation], + }) } if (data.salinity) { contextPrefix = 'meteo.' - if (data.salinity < 502) { - values.push({ - path: `environment.observations.${meteoLocation}.water.salinity`, - value: data.salinity / 10, - }) - } + values.push({ + path: `environment.water.salinity`, + value: data.salinity, + }) } if (data.ice) { contextPrefix = 'meteo.' - if (data.ice < 3) { - values.push({ - path: `environment.observations.${meteoLocation}.water.ice`, - value: iceTable[data.ice], - }) - } + values.push({ + path: `environment.water.ice`, + value: iceTable[data.ice], + }) } if (values.length === 0) { return null } - - if (contextPrefix === 'meteo.'){ - if (data.lon && data.lat) { - values.push({ - path: `environment.observations.${meteoLocation}`, - value: { - longitude: data.lon, - latitude: data.lat, - }, - }) - } - delta = { - context: contextPrefix + `urn:mrn:imo:mmsi:${data.mmsi}`, - updates: [ - { - $source: `location__${data.lat}__${data.lon}`, - timestamp: tags.timestamp, - values: values, - }, - ], - } - } else { - if (data.lon && data.lat) { - values.push({ - path: 'navigation.position', - value: { - longitude: data.lon, - latitude: data.lat, - }, - }) - } - delta = { - context: contextPrefix + `urn:mrn:imo:mmsi:${data.mmsi}`, - updates: [ - { - source: tags.source, - timestamp: tags.timestamp, - values: values, - }, - ], - } + + delta = { + context: contextPrefix + `urn:mrn:imo:mmsi:${data.mmsikey || data.mmsi}`, + updates: [ + { + source: tags.source, + timestamp: tags.timestamp, + values: values, + }, + ], } return delta From 57072d6329a4d911ac1bc777967d854da9033de8 Mon Sep 17 00:00:00 2001 From: Karl-Erik Gustafsson Date: Fri, 12 Jan 2024 17:37:09 +0200 Subject: [PATCH 11/27] fix: cleanup --- hooks/VDM.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/hooks/VDM.js b/hooks/VDM.js index a9fe4c34..6ce4ff35 100644 --- a/hooks/VDM.js +++ b/hooks/VDM.js @@ -20,8 +20,6 @@ const debug = require('debug')('signalk-parser-nmea0183/VDM') const utils = require('@signalk/nmea0183-utilities') const Decoder = require('ggencoder').AisDecode const schema = require('@signalk/signalk-schema') -let delta -let meteoLocation const stateMapping = { 0: 'motoring', From aac5656b576f57cf49b73bd29bca112ac566716c Mon Sep 17 00:00:00 2001 From: Karl-Erik Gustafsson Date: Wed, 17 Jan 2024 18:49:38 +0200 Subject: [PATCH 12/27] fix: new paths and logic for meteo data --- .github/workflows/test.yml | 8 +- hooks/VDM.js | 271 +++++++++---------------------------- 2 files changed, 67 insertions(+), 212 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5eabbec1..4e83d9cd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,15 +8,15 @@ jobs: strategy: matrix: - node-version: [10.x, 16.x] + node-version: [16.x, 18.x] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - run: npm install - run: npm test env: - CI: true \ No newline at end of file + CI: true diff --git a/hooks/VDM.js b/hooks/VDM.js index 6ce4ff35..2dbf6dde 100644 --- a/hooks/VDM.js +++ b/hooks/VDM.js @@ -20,6 +20,10 @@ const debug = require('debug')('signalk-parser-nmea0183/VDM') const utils = require('@signalk/nmea0183-utilities') const Decoder = require('ggencoder').AisDecode const schema = require('@signalk/signalk-schema') +const knotsToMs = (v) => utils.transform(v, 'knots', 'ms') +const degToRad = (v) => utils.transform(v, 'deg', 'rad') +const cToK = (v) => utils.transform(v, 'c', 'k') +const nmToM = (v) => utils.transform(v, 'nm', 'm') const stateMapping = { 0: 'motoring', @@ -68,19 +72,19 @@ const specialManeuverMapping = { } const beaufortScale = { - 0: 'Flat', - 1: 'Ripples without crests', - 2: 'Small wavelets. Crests of glassy appearance, not breaking', - 3: 'Large wavelets. Crests begin to break; scattered whitecaps', - 4: 'Small waves', - 5: 'Moderate (1.2 m) longer waves. Some foam and spray', - 6: 'Large waves with foam crests and some spray', - 7: 'Sea heaps up and foam begins to streak', - 8: 'Moderately high waves with breaking crests forming spindrift. Streaks of foam', - 9: 'High waves (6-7 m) with dense foam. Wave crests start to roll over. Considerable spray', - 10: 'Very high waves. The sea surface is white and there is considerable tumbling. Visibility is reduced', - 11: 'Exceptionally high waves', - 12: 'Huge waves. Air filled with foam and spray. Sea completely white with driving spray. Visibility greatly reduced', + 0: 'Calm, 0–0.2 m/s', + 1: 'Light air, 0.3–1.5 m/s', + 2: 'Light breeze, 1.6–3.3 m/s', + 3: 'Gentle breeze, 3.4–5.4 m/s', + 4: 'Moderate breeze, 5.5–7.9 m/s', + 5: 'Fresh breeze, 8–10.7 m/s', + 6: 'Strong breeze, 10.8–13.8 m/s', + 7: 'High wind, 13.9–17.1 m/s', + 8: 'Gale, 17.2–20.7 m/s', + 9: 'Strong gale, 20.8–24.4 m/s', + 10: 'Storm, 24.5–28.4 m/s', + 11: 'Violent storm, 28.5–32.6 m/s', + 12: 'Hurricane-force, ≥ 32.7 m/s', 13: 'not available', 14: 'reserved', 15: 'reserved', @@ -312,204 +316,55 @@ module.exports = function (input, session) { }) } - if (data.avgwindspd) { - contextPrefix = 'meteo.' - values.push({ - path: `environment.air.windAverageSpeed`, - value: utils.transform(data.avgwindspd, 'knots', 'ms'), - }) - } - - if (data.windgust) { - contextPrefix = 'meteo.' - values.push({ - path: `environment.air.windGust`, - value: utils.transform(data.windgust, 'knots', 'ms'), - }) - } - - if (data.winddir) { - contextPrefix = 'meteo.' - values.push({ - path: `environment.air.windDirection`, - value: utils.transform(data.winddir, 'deg', 'rad'), - }) - } - - if (data.windgustdir) { - contextPrefix = 'meteo.' - values.push({ - path: `environment.air.windGustDirection`, - value: utils.transform(data.windgustdir, 'deg', 'rad'), - }) - } - - if (data.airtemp) { - contextPrefix = 'meteo.' - values.push({ - path: `environment.air.temperature`, - value: utils.transform(data.airtemp, 'c', 'k'), - }) - } - - if (data.relhumid) { - contextPrefix = 'meteo.' - values.push({ - path: `environment.air.relativeHumidity`, - value: data.relhumid, - }) - } - - if (data.dewpoint) { - contextPrefix = 'meteo.' - values.push({ - path: `environment.air.dewPoint`, - value: utils.transform(data.dewpoint, 'c', 'k'), - }) - } - - if (data.airpress) { - contextPrefix = 'meteo.' - values.push({ - path: `environment.air.pressure`, - value: data.airpress * 100, - }) - - } - - if (data.airpressten) { - contextPrefix = 'meteo.' - values.push({ - path: `environment.air.pressureTendency`, - value: statusTable[data.airpressten], - }) - } - - if (data.horvisib) { - contextPrefix = 'meteo.' - values.push({ - path: `environment.air.horizontalVisibility`, - value: utils.transform(data.horvisib, 'nm', 'm'), - }) - } - - if (data.waterlevel) { - contextPrefix = 'meteo.' - values.push({ - path: `environment.water.level`, - value: data.waterlevel, - }) - } - - if (data.waterlevelten) { - contextPrefix = 'meteo.' - values.push({ - path: `environment.water.levelTrend`, - value: statusTable[data.waterlevelten], - }) - } - - if (data.surfcurrspd) { - contextPrefix = 'meteo.' - values.push({ - path: `environment.water.surfaceCurrentSpeed`, - value: utils.transform(data.surfcurrspd, 'knots', 'ms'), - }) - } - - if (data.surfcurrdir) { - contextPrefix = 'meteo.' - values.push({ - path: `environment.water.surfaceCurrentDirection`, - value: utils.transform(data.surfcurrdir, 'deg', 'rad'), - }) - } - - if (data.signwavewhgt) { - contextPrefix = 'meteo.' - values.push({ - path: `environment.water.waveSignificantHeight`, - value: data.signwavewhgt, - }) - } - - if (data.waveperiod) { - contextPrefix = 'meteo.' - values.push({ - path: `environment.water.wavePeriod`, - value: data.waveperiod, - }) - } - - if (data.wavedir) { - contextPrefix = 'meteo.' - values.push({ - path: `environment.water.waveDirection`, - value: utils.transform(data.wavedir, 'deg', 'rad'), - }) - } - - if (data.swellhgt) { - contextPrefix = 'meteo.' - values.push({ - path: `environment.water.swellHeight`, - value: data.swellhgt, - }) - } - - if (data.swellperiod) { - contextPrefix = 'meteo.' - values.push({ - path: `environment.water.swellPeriod`, - value: data.swellperiod, - }) - } - - if (data.swelldir) { - contextPrefix = 'meteo.' - values.push({ - path: `environment.water.swellDirection`, - value: utils.transform(data.swelldir, 'deg', 'rad'), - }) - } - - if (data.seastate) { - contextPrefix = 'meteo.' - values.push({ - path: `environment.water.seaState`, - value: beaufortScale[data.seastate], - }) - } - - if (data.watertemp) { - contextPrefix = 'meteo.' - values.push({ - path: `environment.water.temperature`, - value: utils.transform(data.watertemp, 'c', 'k'), - }) - } - - if (data.precipitation) { - contextPrefix = 'meteo.' - values.push({ - path: `environment.air.precipitation`, - value: precipitationType[data.precipitation], - }) - } - - if (data.salinity) { - contextPrefix = 'meteo.' - values.push({ - path: `environment.water.salinity`, - value: data.salinity, - }) - } + [ + ['avgwindspd', 'wind.averageSpeed', knotsToMs], + ['windgust', 'wind.gust', knotsToMs], + ['winddir', 'wind.directionTrue', degToRad], + ['windgustdir', 'wind.gustDirectionTrue', degToRad], + ['airtemp', 'outside.temperature', cToK], + ['relhumid', 'outside.relativeHumidity', (v) => v], + ['dewpoint', 'outside.dewPointTemperature', cToK], + ['airpress', 'outside.pressure', (v) => v * 100], + ['airpressten', 'outside.pressureTendency', (v) => v], + ['airpressten', 'outside.pressureTendencyType', (v) => statusTable[v]], + ['horvisib', 'outside.horizontalVisibility', nmToM], + ['waterlevel', 'water.level', (v) => v], + ['waterlevelten', 'water.levelTendency', (v) => v], + ['waterlevelten', 'water.levelTendencyType', (v) => statusTable[v]], + ['signwavewhgt', 'water.waves.significantHeight', (v) => v], + ['waveperiod', 'water.waves.period', (v) => v], + ['wavedir', 'water.waves.direction', degToRad], + ['swellhgt', 'water.swell.height', (v) => v], + ['swellperiod', 'water.swell.period', (v) => v], + ['swelldir', 'water.swell.directionTrue', degToRad], + ['seastate', 'water.seaState', (v) => v], + ['seastate', 'water.seaState.beaufortScale', (v) => beaufortScale[v]], + ['watertemp', 'water.temperature', cToK], + ['precipitation', 'outside.precipitation', (v) => v], + ['precipitation', 'outside.precipitationType', (v) => precipitationType[precipitation]], + ['salinity', 'water.salinity', (v) => v], + ['ice', 'water.ice', (v) => v], + ['ice', 'water.iceType', (v) => iceTable[data.ice]], + ].forEach(([propName, path, f]) => { + if (data[propName] !== undefined) { + contextPrefix = 'meteo.' + values.push({ + path, + value: f(data[`environment.observation.${propName}`]), + }) + } + }) - if (data.ice) { + if (data.surfcurrspd !== undefined || data.surfcurrdir !== undefined) { contextPrefix = 'meteo.' + const drift = utils.transform(data.surfcurrspd, 'knots', 'ms') + const set = utils.transform(data.surfcurrdir, 'deg', 'rad') values.push({ - path: `environment.water.ice`, - value: iceTable[data.ice], + path: 'environment.observations.current', + value: { + set, + drift, + }, }) } From 82b35cf40ea7dbbbc005c08ae342945756eff523 Mon Sep 17 00:00:00 2001 From: Karl-Erik Gustafsson Date: Wed, 17 Jan 2024 18:57:08 +0200 Subject: [PATCH 13/27] fix: declaration for delta --- hooks/VDM.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/VDM.js b/hooks/VDM.js index 2dbf6dde..5561a6b2 100644 --- a/hooks/VDM.js +++ b/hooks/VDM.js @@ -372,7 +372,7 @@ module.exports = function (input, session) { return null } - delta = { + const delta = { context: contextPrefix + `urn:mrn:imo:mmsi:${data.mmsikey || data.mmsi}`, updates: [ { From b96217d57c648f346bc7599f6928f0d83163dabb Mon Sep 17 00:00:00 2001 From: Karl-Erik Gustafsson Date: Wed, 17 Jan 2024 22:59:29 +0200 Subject: [PATCH 14/27] fix: error corrections and fine tunings --- hooks/VDM.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/hooks/VDM.js b/hooks/VDM.js index 5561a6b2..89f202c9 100644 --- a/hooks/VDM.js +++ b/hooks/VDM.js @@ -20,10 +20,10 @@ const debug = require('debug')('signalk-parser-nmea0183/VDM') const utils = require('@signalk/nmea0183-utilities') const Decoder = require('ggencoder').AisDecode const schema = require('@signalk/signalk-schema') -const knotsToMs = (v) => utils.transform(v, 'knots', 'ms') +const knotsToMs = (v) => parseFloat(utils.transform(v, 'knots', 'ms').toFixed(2)) const degToRad = (v) => utils.transform(v, 'deg', 'rad') -const cToK = (v) => utils.transform(v, 'c', 'k') -const nmToM = (v) => utils.transform(v, 'nm', 'm') +const cToK = (v) => parseFloat(utils.transform(v, 'c', 'k').toFixed(2)) +const nmToM = (v) => parseFloat(utils.transform(v, 'nm', 'm').toFixed(2)) const stateMapping = { 0: 'motoring', @@ -300,6 +300,9 @@ module.exports = function (input, session) { } if (typeof data.fid !== 'undefined') { + if (data.fid == 31 || data.fid == 11 || data.fid == 33 ){ + contextPrefix = 'meteo.' + } values.push({ path: 'sensors.ais.functionalId', value: data.fid, @@ -349,8 +352,8 @@ module.exports = function (input, session) { if (data[propName] !== undefined) { contextPrefix = 'meteo.' values.push({ - path, - value: f(data[`environment.observation.${propName}`]), + path: `environment.observation.` + path, + value: f(data[propName]), }) } }) From bdb0e42d868d3f2b27fda7e3b477cdc1e25ae210 Mon Sep 17 00:00:00 2001 From: Karl-Erik Gustafsson Date: Sat, 20 Jan 2024 00:06:01 +0200 Subject: [PATCH 15/27] fix: regrouping path values and meteo date added --- hooks/VDM.js | 105 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 94 insertions(+), 11 deletions(-) diff --git a/hooks/VDM.js b/hooks/VDM.js index 89f202c9..145402a1 100644 --- a/hooks/VDM.js +++ b/hooks/VDM.js @@ -328,26 +328,15 @@ module.exports = function (input, session) { ['relhumid', 'outside.relativeHumidity', (v) => v], ['dewpoint', 'outside.dewPointTemperature', cToK], ['airpress', 'outside.pressure', (v) => v * 100], - ['airpressten', 'outside.pressureTendency', (v) => v], - ['airpressten', 'outside.pressureTendencyType', (v) => statusTable[v]], - ['horvisib', 'outside.horizontalVisibility', nmToM], ['waterlevel', 'water.level', (v) => v], - ['waterlevelten', 'water.levelTendency', (v) => v], - ['waterlevelten', 'water.levelTendencyType', (v) => statusTable[v]], ['signwavewhgt', 'water.waves.significantHeight', (v) => v], ['waveperiod', 'water.waves.period', (v) => v], ['wavedir', 'water.waves.direction', degToRad], ['swellhgt', 'water.swell.height', (v) => v], ['swellperiod', 'water.swell.period', (v) => v], ['swelldir', 'water.swell.directionTrue', degToRad], - ['seastate', 'water.seaState', (v) => v], - ['seastate', 'water.seaState.beaufortScale', (v) => beaufortScale[v]], ['watertemp', 'water.temperature', cToK], - ['precipitation', 'outside.precipitation', (v) => v], - ['precipitation', 'outside.precipitationType', (v) => precipitationType[precipitation]], ['salinity', 'water.salinity', (v) => v], - ['ice', 'water.ice', (v) => v], - ['ice', 'water.iceType', (v) => iceTable[data.ice]], ].forEach(([propName, path, f]) => { if (data[propName] !== undefined) { contextPrefix = 'meteo.' @@ -358,6 +347,85 @@ module.exports = function (input, session) { } }) + if (data.ice !== undefined) { + contextPrefix = 'meteo.' + const ice = data.ice + const comment = iceTable[data.ice] + values.push({ + path: 'environment.observations.water', + value: { + ice, + comment, + }, + }) + } + + if (data.precipitation !== undefined) { + contextPrefix = 'meteo.' + const precipitation = data.precipitation + const comment = precipitationType[data.precipitation] + values.push({ + path: 'environment.observations.outside', + value: { + precipitation, + comment, + }, + }) + } + + if (data.seastate !== undefined) { + contextPrefix = 'meteo.' + const seastate = data.seastate + const comment = beaufortScale[data.seastate] + values.push({ + path: 'environment.observations.water', + value: { + seastate, + comment, + }, + }) + } + + if (data.waterlevelten !== undefined) { + contextPrefix = 'meteo.' + const tendency = data.waterlevelten + const comment = statusTable[data.waterlevelten] + values.push({ + path: 'environment.observations.waterlevel', + value: { + tendency, + comment, + }, + }) + } + + if (data.airpressten !== undefined) { + contextPrefix = 'meteo.' + const tendency = data.airpressten + const comment = statusTable[data.airpressten] + values.push({ + path: 'environment.observations.pressure', + value: { + tendency, + comment, + }, + }) + } + + if (data.horvisib !== undefined && data.horvisibrange !== undefined) { + contextPrefix = 'meteo.' + const horizontal = utils.transform(data.horvisib, 'nm', 'm') + const comment = data.horvisibrange + const raw = data.horvisibraw + values.push({ + path: 'environment.observations.visibility', + value: { + horizontal, + comment, + }, + }) + } + if (data.surfcurrspd !== undefined || data.surfcurrdir !== undefined) { contextPrefix = 'meteo.' const drift = utils.transform(data.surfcurrspd, 'knots', 'ms') @@ -371,6 +439,21 @@ module.exports = function (input, session) { }) } + if (data.utcday !== undefined && data.utchour !== undefined && data.utcminute !== undefined) { + contextPrefix = 'meteo.' + const utcday = data.utcday + const utchour = data.utchour + const utcminute = data.utcminute + values.push({ + path: 'environment.observations.date', + value: { + utcday, + utchour, + utcminute, + }, + }) + } + if (values.length === 0) { return null } From f56dc2ae663a6b43ce0562d8e92f92d592a5f69b Mon Sep 17 00:00:00 2001 From: Karl-Erik Gustafsson Date: Sat, 20 Jan 2024 12:22:08 +0200 Subject: [PATCH 16/27] fix: water.waves.direction to True --- hooks/VDM.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/VDM.js b/hooks/VDM.js index 145402a1..da25d64d 100644 --- a/hooks/VDM.js +++ b/hooks/VDM.js @@ -331,7 +331,7 @@ module.exports = function (input, session) { ['waterlevel', 'water.level', (v) => v], ['signwavewhgt', 'water.waves.significantHeight', (v) => v], ['waveperiod', 'water.waves.period', (v) => v], - ['wavedir', 'water.waves.direction', degToRad], + ['wavedir', 'water.waves.directionTrue', degToRad], ['swellhgt', 'water.swell.height', (v) => v], ['swellperiod', 'water.swell.period', (v) => v], ['swelldir', 'water.swell.directionTrue', degToRad], From 401d1405e9107ca14e3ce1de8f31bfd1fbefbbaa Mon Sep 17 00:00:00 2001 From: Karl-Erik Gustafsson Date: Sat, 20 Jan 2024 16:49:34 +0200 Subject: [PATCH 17/27] fix: combine functions --- hooks/VDM.js | 105 +++++++++++++++------------------------------------ 1 file changed, 30 insertions(+), 75 deletions(-) diff --git a/hooks/VDM.js b/hooks/VDM.js index da25d64d..18f03bab 100644 --- a/hooks/VDM.js +++ b/hooks/VDM.js @@ -345,100 +345,55 @@ module.exports = function (input, session) { value: f(data[propName]), }) } - }) + }); - if (data.ice !== undefined) { - contextPrefix = 'meteo.' - const ice = data.ice - const comment = iceTable[data.ice] - values.push({ - path: 'environment.observations.water', - value: { - ice, - comment, - }, - }) - } - - if (data.precipitation !== undefined) { - contextPrefix = 'meteo.' - const precipitation = data.precipitation - const comment = precipitationType[data.precipitation] - values.push({ - path: 'environment.observations.outside', - value: { - precipitation, - comment, - }, - }) - } - - if (data.seastate !== undefined) { - contextPrefix = 'meteo.' - const seastate = data.seastate - const comment = beaufortScale[data.seastate] - values.push({ - path: 'environment.observations.water', - value: { - seastate, - comment, - }, - }) - } - - if (data.waterlevelten !== undefined) { - contextPrefix = 'meteo.' - const tendency = data.waterlevelten - const comment = statusTable[data.waterlevelten] - values.push({ - path: 'environment.observations.waterlevel', - value: { - tendency, - comment, - }, - }) - } + [ + ['ice', 'water.ice', iceTable], + ['precipitation', 'outside.precipitation', precipitationType], + ['seastate', 'water.seastate', beaufortScale], + ['waterlevelten', 'water.levelTendency', statusTable], + ['airpressten', 'outside.pressureTendency', statusTable], + ].forEach(([propName, path, f]) => { + if (data[propName] !== undefined) { + contextPrefix = 'meteo.' + const comment = f[data[propName]] + const value = data[propName] + values.push({ + path: `environment.observation.` + path, + value: { + value, + comment, + } + }) + } + }); - if (data.airpressten !== undefined) { + if (data.surfcurrspd !== undefined || data.surfcurrdir !== undefined) { contextPrefix = 'meteo.' - const tendency = data.airpressten - const comment = statusTable[data.airpressten] + const drift = utils.transform(data.surfcurrspd, 'knots', 'ms') + const set = utils.transform(data.surfcurrdir, 'deg', 'rad') values.push({ - path: 'environment.observations.pressure', + path: 'environment.observations.current', value: { - tendency, - comment, + set, + drift, }, }) } if (data.horvisib !== undefined && data.horvisibrange !== undefined) { contextPrefix = 'meteo.' - const horizontal = utils.transform(data.horvisib, 'nm', 'm') + const value = utils.transform(data.horvisib, 'nm', 'm') const comment = data.horvisibrange - const raw = data.horvisibraw values.push({ - path: 'environment.observations.visibility', + path: 'environment.observations.horizontalVisibility', value: { - horizontal, + value, comment, }, }) } - if (data.surfcurrspd !== undefined || data.surfcurrdir !== undefined) { - contextPrefix = 'meteo.' - const drift = utils.transform(data.surfcurrspd, 'knots', 'ms') - const set = utils.transform(data.surfcurrdir, 'deg', 'rad') - values.push({ - path: 'environment.observations.current', - value: { - set, - drift, - }, - }) - } - if (data.utcday !== undefined && data.utchour !== undefined && data.utcminute !== undefined) { contextPrefix = 'meteo.' const utcday = data.utcday From 70c956715225416c3e3111c91a9b2c8133a4eba3 Mon Sep 17 00:00:00 2001 From: Karl-Erik Gustafsson Date: Sun, 21 Jan 2024 11:28:06 +0200 Subject: [PATCH 18/27] fix: minor changes to paths --- hooks/VDM.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hooks/VDM.js b/hooks/VDM.js index 18f03bab..02820053 100644 --- a/hooks/VDM.js +++ b/hooks/VDM.js @@ -350,9 +350,9 @@ module.exports = function (input, session) { [ ['ice', 'water.ice', iceTable], ['precipitation', 'outside.precipitation', precipitationType], - ['seastate', 'water.seastate', beaufortScale], - ['waterlevelten', 'water.levelTendency', statusTable], - ['airpressten', 'outside.pressureTendency', statusTable], + ['seastate', 'water.seaState', beaufortScale], + ['waterlevelten', 'water.level.tendency', statusTable], + ['airpressten', 'outside.pressure.tendency', statusTable], ].forEach(([propName, path, f]) => { if (data[propName] !== undefined) { contextPrefix = 'meteo.' From 406f45df00647babc2a5adf5b8d805e1c87f76ae Mon Sep 17 00:00:00 2001 From: Karl-Erik Gustafsson Date: Sun, 21 Jan 2024 15:35:14 +0200 Subject: [PATCH 19/27] fix: meteo observation date to ISO string --- hooks/VDM.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/hooks/VDM.js b/hooks/VDM.js index 02820053..3cecec35 100644 --- a/hooks/VDM.js +++ b/hooks/VDM.js @@ -396,16 +396,15 @@ module.exports = function (input, session) { if (data.utcday !== undefined && data.utchour !== undefined && data.utcminute !== undefined) { contextPrefix = 'meteo.' - const utcday = data.utcday - const utchour = data.utchour - const utcminute = data.utcminute + const y = new Date().getUTCFullYear(); + const m = new Date().getUTCMonth() + 1; + const d = data.utcday; + const h = data.utchour; + const min = data.utcminute; + const date = `${y}-${m.toString().padStart(2, '0')}-${d.toString().padStart(2, '0')}T${h.toString().padStart(2, '0')}:${min.toString().padStart(2, '0')}:00.000Z`; values.push({ path: 'environment.observations.date', - value: { - utcday, - utchour, - utcminute, - }, + value: date, }) } From f1196216450bf1cf7ad16b1e139cb84b7e841b15 Mon Sep 17 00:00:00 2001 From: Karl-Erik Gustafsson Date: Sun, 21 Jan 2024 21:41:14 +0200 Subject: [PATCH 20/27] fix: overRange for horizontalVisibility --- hooks/VDM.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hooks/VDM.js b/hooks/VDM.js index 3cecec35..b4e47fc1 100644 --- a/hooks/VDM.js +++ b/hooks/VDM.js @@ -351,8 +351,8 @@ module.exports = function (input, session) { ['ice', 'water.ice', iceTable], ['precipitation', 'outside.precipitation', precipitationType], ['seastate', 'water.seaState', beaufortScale], - ['waterlevelten', 'water.level.tendency', statusTable], - ['airpressten', 'outside.pressure.tendency', statusTable], + ['waterlevelten', 'water.levelTendency', statusTable], + ['airpressten', 'outside.pressureTendency', statusTable], ].forEach(([propName, path, f]) => { if (data[propName] !== undefined) { contextPrefix = 'meteo.' @@ -384,12 +384,12 @@ module.exports = function (input, session) { if (data.horvisib !== undefined && data.horvisibrange !== undefined) { contextPrefix = 'meteo.' const value = utils.transform(data.horvisib, 'nm', 'm') - const comment = data.horvisibrange + const overRange = data.horvisibrange values.push({ path: 'environment.observations.horizontalVisibility', value: { value, - comment, + overRange, }, }) } From cb2c2081445ea1a3659712efa1d437943b93d937 Mon Sep 17 00:00:00 2001 From: Karl-Erik Gustafsson Date: Mon, 22 Jan 2024 20:24:26 +0200 Subject: [PATCH 21/27] fix: format --- hooks/VDM.js | 69 +++++++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 30 deletions(-) diff --git a/hooks/VDM.js b/hooks/VDM.js index b4e47fc1..96b71ef3 100644 --- a/hooks/VDM.js +++ b/hooks/VDM.js @@ -20,7 +20,8 @@ const debug = require('debug')('signalk-parser-nmea0183/VDM') const utils = require('@signalk/nmea0183-utilities') const Decoder = require('ggencoder').AisDecode const schema = require('@signalk/signalk-schema') -const knotsToMs = (v) => parseFloat(utils.transform(v, 'knots', 'ms').toFixed(2)) +const knotsToMs = (v) => + parseFloat(utils.transform(v, 'knots', 'ms').toFixed(2)) const degToRad = (v) => utils.transform(v, 'deg', 'rad') const cToK = (v) => parseFloat(utils.transform(v, 'c', 'k').toFixed(2)) const nmToM = (v) => parseFloat(utils.transform(v, 'nm', 'm').toFixed(2)) @@ -72,19 +73,19 @@ const specialManeuverMapping = { } const beaufortScale = { - 0: 'Calm, 0–0.2 m/s', - 1: 'Light air, 0.3–1.5 m/s', - 2: 'Light breeze, 1.6–3.3 m/s', - 3: 'Gentle breeze, 3.4–5.4 m/s', - 4: 'Moderate breeze, 5.5–7.9 m/s', - 5: 'Fresh breeze, 8–10.7 m/s', - 6: 'Strong breeze, 10.8–13.8 m/s', - 7: 'High wind, 13.9–17.1 m/s', - 8: 'Gale, 17.2–20.7 m/s', - 9: 'Strong gale, 20.8–24.4 m/s', - 10: 'Storm, 24.5–28.4 m/s', - 11: 'Violent storm, 28.5–32.6 m/s', - 12: 'Hurricane-force, ≥ 32.7 m/s', + 0: 'calm, 0–0.2 m/s', + 1: 'light air, 0.3–1.5 m/s', + 2: 'light breeze, 1.6–3.3 m/s', + 3: 'gentle breeze, 3.4–5.4 m/s', + 4: 'moderate breeze, 5.5–7.9 m/s', + 5: 'fresh breeze, 8–10.7 m/s', + 6: 'strong breeze, 10.8–13.8 m/s', + 7: 'high wind, 13.9–17.1 m/s', + 8: 'gale, 17.2–20.7 m/s', + 9: 'strong gale, 20.8–24.4 m/s', + 10: 'storm, 24.5–28.4 m/s', + 11: 'violent storm, 28.5–32.6 m/s', + 12: 'hurricane-force, ≥ 32.7 m/s', 13: 'not available', 14: 'reserved', 15: 'reserved', @@ -300,7 +301,7 @@ module.exports = function (input, session) { } if (typeof data.fid !== 'undefined') { - if (data.fid == 31 || data.fid == 11 || data.fid == 33 ){ + if (data.fid == 31 || data.fid == 11 || data.fid == 33) { contextPrefix = 'meteo.' } values.push({ @@ -319,7 +320,7 @@ module.exports = function (input, session) { }) } - [ + ;[ ['avgwindspd', 'wind.averageSpeed', knotsToMs], ['windgust', 'wind.gust', knotsToMs], ['winddir', 'wind.directionTrue', degToRad], @@ -345,9 +346,9 @@ module.exports = function (input, session) { value: f(data[propName]), }) } - }); + }) - [ + ;[ ['ice', 'water.ice', iceTable], ['precipitation', 'outside.precipitation', precipitationType], ['seastate', 'water.seaState', beaufortScale], @@ -356,17 +357,17 @@ module.exports = function (input, session) { ].forEach(([propName, path, f]) => { if (data[propName] !== undefined) { contextPrefix = 'meteo.' - const comment = f[data[propName]] - const value = data[propName] + const comment = f[data[propName]] + const value = data[propName] values.push({ path: `environment.observation.` + path, value: { value, comment, - } + }, }) } - }); + }) if (data.surfcurrspd !== undefined || data.surfcurrdir !== undefined) { contextPrefix = 'meteo.' @@ -394,14 +395,22 @@ module.exports = function (input, session) { }) } - if (data.utcday !== undefined && data.utchour !== undefined && data.utcminute !== undefined) { + if ( + data.utcday !== undefined && + data.utchour !== undefined && + data.utcminute !== undefined + ) { contextPrefix = 'meteo.' - const y = new Date().getUTCFullYear(); - const m = new Date().getUTCMonth() + 1; - const d = data.utcday; - const h = data.utchour; - const min = data.utcminute; - const date = `${y}-${m.toString().padStart(2, '0')}-${d.toString().padStart(2, '0')}T${h.toString().padStart(2, '0')}:${min.toString().padStart(2, '0')}:00.000Z`; + const y = new Date().getUTCFullYear() + const m = new Date().getUTCMonth() + 1 + const d = data.utcday + const h = data.utchour + const min = data.utcminute + const date = `${y}-${m.toString().padStart(2, '0')}-${d + .toString() + .padStart(2, '0')}T${h.toString().padStart(2, '0')}:${min + .toString() + .padStart(2, '0')}:00.000Z` values.push({ path: 'environment.observations.date', value: date, @@ -411,7 +420,7 @@ module.exports = function (input, session) { if (values.length === 0) { return null } - + const delta = { context: contextPrefix + `urn:mrn:imo:mmsi:${data.mmsikey || data.mmsi}`, updates: [ From 9821a261a7830e8a08976890a9f70262cd82c97e Mon Sep 17 00:00:00 2001 From: KEGustafsson Date: Sat, 27 Jan 2024 01:49:09 +0200 Subject: [PATCH 22/27] fix: paths adjustments and minor formats --- hooks/VDM.js | 100 +++++++++++++++++++++++---------------------------- 1 file changed, 45 insertions(+), 55 deletions(-) diff --git a/hooks/VDM.js b/hooks/VDM.js index 96b71ef3..46a94c07 100644 --- a/hooks/VDM.js +++ b/hooks/VDM.js @@ -73,18 +73,18 @@ const specialManeuverMapping = { } const beaufortScale = { - 0: 'calm, 0–0.2 m/s', - 1: 'light air, 0.3–1.5 m/s', - 2: 'light breeze, 1.6–3.3 m/s', - 3: 'gentle breeze, 3.4–5.4 m/s', - 4: 'moderate breeze, 5.5–7.9 m/s', - 5: 'fresh breeze, 8–10.7 m/s', - 6: 'strong breeze, 10.8–13.8 m/s', - 7: 'high wind, 13.9–17.1 m/s', - 8: 'gale, 17.2–20.7 m/s', - 9: 'strong gale, 20.8–24.4 m/s', - 10: 'storm, 24.5–28.4 m/s', - 11: 'violent storm, 28.5–32.6 m/s', + 0: 'calm, 0-0.2 m/s', + 1: 'light air, 0.3-1.5 m/s', + 2: 'light breeze, 1.6-3.3 m/s', + 3: 'gentle breeze, 3.4-5.4 m/s', + 4: 'moderate breeze, 5.5-7.9 m/s', + 5: 'fresh breeze, 8-10.7 m/s', + 6: 'strong breeze, 10.8-13.8 m/s', + 7: 'high wind, 13.9-17.1 m/s', + 8: 'gale, 17.2-20.7 m/s', + 9: 'strong gale, 20.8-24.4 m/s', + 10: 'storm, 24.5-28.4 m/s', + 11: 'violent storm, 28.5-32.6 m/s', 12: 'hurricane-force, ≥ 32.7 m/s', 13: 'not available', 14: 'reserved', @@ -338,61 +338,51 @@ module.exports = function (input, session) { ['swelldir', 'water.swell.directionTrue', degToRad], ['watertemp', 'water.temperature', cToK], ['salinity', 'water.salinity', (v) => v], + ['surfcurrspd', 'water.current.drift', knotsToMs], + ['surfcurrdir', 'water.current.set', degToRad], ].forEach(([propName, path, f]) => { if (data[propName] !== undefined) { contextPrefix = 'meteo.' values.push({ - path: `environment.observation.` + path, + path: `environment.` + path, value: f(data[propName]), }) } }) - - ;[ - ['ice', 'water.ice', iceTable], - ['precipitation', 'outside.precipitation', precipitationType], - ['seastate', 'water.seaState', beaufortScale], - ['waterlevelten', 'water.levelTendency', statusTable], - ['airpressten', 'outside.pressureTendency', statusTable], - ].forEach(([propName, path, f]) => { - if (data[propName] !== undefined) { - contextPrefix = 'meteo.' - const comment = f[data[propName]] - const value = data[propName] - values.push({ - path: `environment.observation.` + path, - value: { - value, - comment, - }, - }) - } - }) - - if (data.surfcurrspd !== undefined || data.surfcurrdir !== undefined) { - contextPrefix = 'meteo.' - const drift = utils.transform(data.surfcurrspd, 'knots', 'ms') - const set = utils.transform(data.surfcurrdir, 'deg', 'rad') - values.push({ - path: 'environment.observations.current', - value: { - set, - drift, - }, + ;[ + ['ice', 'water.ice', iceTable], + ['precipitation', 'outside.precipitation', precipitationType], + ['seastate', 'water.seaState', beaufortScale], + ['waterlevelten', 'water.levelTendency', statusTable], + ['airpressten', 'outside.pressureTendency', statusTable], + ].forEach(([propName, path, f]) => { + if (data[propName] !== undefined) { + contextPrefix = 'meteo.' + values.push( + { + path: `environment.` + path, + value: f[data[propName]], + }, + { + path: `environment.` + path + `Value`, + value: data[propName], + } + ) + } }) - } if (data.horvisib !== undefined && data.horvisibrange !== undefined) { contextPrefix = 'meteo.' - const value = utils.transform(data.horvisib, 'nm', 'm') - const overRange = data.horvisibrange - values.push({ - path: 'environment.observations.horizontalVisibility', - value: { - value, - overRange, + values.push( + { + path: 'environment.horizontalVisibility', + value: utils.transform(data.horvisib, 'nm', 'm'), }, - }) + { + path: 'environment.horizontalVisibility.overRange', + value: data.horvisibrange, + } + ) } if ( @@ -412,7 +402,7 @@ module.exports = function (input, session) { .toString() .padStart(2, '0')}:00.000Z` values.push({ - path: 'environment.observations.date', + path: 'environment.date', value: date, }) } From 9b0b3526bc23be0e04e4b99f9688a8555503d04d Mon Sep 17 00:00:00 2001 From: KEGustafsson Date: Sun, 4 Feb 2024 21:56:38 +0200 Subject: [PATCH 23/27] fix: ouside added to horizontalVisibility paths --- hooks/VDM.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hooks/VDM.js b/hooks/VDM.js index 46a94c07..1fd92b50 100644 --- a/hooks/VDM.js +++ b/hooks/VDM.js @@ -375,11 +375,11 @@ module.exports = function (input, session) { contextPrefix = 'meteo.' values.push( { - path: 'environment.horizontalVisibility', + path: 'environment.outside.horizontalVisibility', value: utils.transform(data.horvisib, 'nm', 'm'), }, { - path: 'environment.horizontalVisibility.overRange', + path: 'environment.outside.horizontalVisibility.overRange', value: data.horvisibrange, } ) From 6887a9d2a80ca2c5560095a9b67874dbb8c2c519 Mon Sep 17 00:00:00 2001 From: Teppo Kurki Date: Sat, 10 Feb 2024 05:57:31 +0200 Subject: [PATCH 24/27] add meteo test --- test/VDM.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/VDM.js b/test/VDM.js index effe144b..2e5b7c3e 100644 --- a/test/VDM.js +++ b/test/VDM.js @@ -237,4 +237,23 @@ describe('VDM', function () { .filter((pathValue) => pathValue.path === '')[3] .value.registrations.imo.should.equal('IMO 1010258') }) + + it('meteo converts ok', () => { + const delta = new Parser().parse( + '!AIVDM,1,1,,A,8@2R5Ph0GhOCT1a2VvkrgwvlFR06EuOwgqrqwnSwe7wvlOwwsAwwnSGmwvwt,0*40' + ) + delta.context.should.equal('meteo.urn:mrn:imo:mmsi:002655619.366097') + const output = [ + ['environment.water.level', -0.17], + ['environment.water.levelTendency', 'steady'], + ['environment.water.levelTendencyValue', 0], + ['environment.date', '2024-02-22T15:42:00.000Z'] + ] + output.forEach(([path, value]) => + delta.updates[0].values + .find((pathValue) => pathValue.path === path) + .value.should.equal(value) + ) + }) + }) From f7ad7c5ddcf76e10e2e3796e524517331d0bc937 Mon Sep 17 00:00:00 2001 From: KEGustafsson Date: Sun, 11 Feb 2024 15:13:41 +0200 Subject: [PATCH 25/27] fix: VDM meteo tests --- test/VDM.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/VDM.js b/test/VDM.js index 2e5b7c3e..c957a615 100644 --- a/test/VDM.js +++ b/test/VDM.js @@ -242,12 +242,13 @@ describe('VDM', function () { const delta = new Parser().parse( '!AIVDM,1,1,,A,8@2R5Ph0GhOCT1a2VvkrgwvlFR06EuOwgqrqwnSwe7wvlOwwsAwwnSGmwvwt,0*40' ) - delta.context.should.equal('meteo.urn:mrn:imo:mmsi:002655619.366097') + delta.context.should.equal('meteo.urn:mrn:imo:mmsi:002655619:366097') + const currentYear = new Date().getFullYear(); const output = [ ['environment.water.level', -0.17], ['environment.water.levelTendency', 'steady'], ['environment.water.levelTendencyValue', 0], - ['environment.date', '2024-02-22T15:42:00.000Z'] + ['environment.date', currentYear + '-02-22T15:42:00.000Z'] ] output.forEach(([path, value]) => delta.updates[0].values From c8528158656363b70774cafda3c854140bf5c7aa Mon Sep 17 00:00:00 2001 From: KEGustafsson Date: Sun, 11 Feb 2024 22:01:05 +0200 Subject: [PATCH 26/27] add: more VDM meteo test cases --- test/VDM.js | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/test/VDM.js b/test/VDM.js index c957a615..92889dcc 100644 --- a/test/VDM.js +++ b/test/VDM.js @@ -238,7 +238,7 @@ describe('VDM', function () { .value.registrations.imo.should.equal('IMO 1010258') }) - it('meteo converts ok', () => { + it('meteo single sentence converts ok', () => { const delta = new Parser().parse( '!AIVDM,1,1,,A,8@2R5Ph0GhOCT1a2VvkrgwvlFR06EuOwgqrqwnSwe7wvlOwwsAwwnSGmwvwt,0*40' ) @@ -257,4 +257,32 @@ describe('VDM', function () { ) }) + it('meteo dual sentence converts ok', () => { + const meteoSentences = [ + '!AIVDM,2,1,4,A,8@2R5Ph0GhENJAb8wnScjAJ:AB06EuOwgwl?wnSwe7wvlOwwsAwwnSGm,0*15', + '!AIVDM,2,2,4,A,wvwt,0*10', + ] + const parser = new Parser() + let delta = parser.parse(meteoSentences[0]) + should.equal(delta, null) + delta = parser.parse(meteoSentences[1]) + delta.context.should.equal('meteo.urn:mrn:imo:mmsi:002655619:967728') + delta.updates[0].values[3].value.longitude.should.equal(11.7283) + delta.updates[0].values[3].value.latitude.should.equal(57.9669) + const currentYear = new Date().getFullYear() + const output = [ + ['sensors.ais.designatedAreaCode', 1], + ['sensors.ais.functionalId', 31], + ['environment.wind.averageSpeed', 9.26], + ['environment.wind.gust', 11.32], + ['environment.wind.directionTrue', 4.817108736604238], + ['environment.wind.gustDirectionTrue', 4.817108736604238], + ['environment.date', currentYear + '-02-20T14:47:00.000Z'], + ] + output.forEach(([path, value]) => + delta.updates[0].values + .find((pathValue) => pathValue.path === path) + .value.should.equal(value) + ) + }) }) From 6b943d7038b63a67703f7234f7d0bcb3bc878c9d Mon Sep 17 00:00:00 2001 From: Teppo Kurki Date: Sat, 17 Feb 2024 08:18:36 +0200 Subject: [PATCH 27/27] ggencoder@1.0.8 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 62f626cb..f03792a8 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "dependencies": { "@signalk/nmea0183-utilities": "^0.8.0", "@signalk/signalk-schema": "^1.7.1", - "ggencoder": "^1.0.4", + "ggencoder": "^1.0.8", "moment-timezone": "^0.5.21", "split": "^1.0.1" },