From 3798c47c47a0db7a7b5c27b6dcdb614aff903ee9 Mon Sep 17 00:00:00 2001 From: quantenschaum <woxpox@posteo.de> Date: Thu, 18 Jul 2024 21:51:52 +0200 Subject: [PATCH 01/18] =?UTF-8?q?#26=20force=20angles=20to=20=C2=B1180?= =?UTF-8?q?=C2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sail_Instrument/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sail_Instrument/plugin.py b/Sail_Instrument/plugin.py index d87a343..adbc7c5 100644 --- a/Sail_Instrument/plugin.py +++ b/Sail_Instrument/plugin.py @@ -476,7 +476,7 @@ def run(self): data["DOT"] = dot if dot >= 0 else None data["DRT"] = draught if draught >= 0 else None - data = {k: v for k, v in data.items() if len(k) == 3} + data = {k: (to180(v) if k.endswith("A") else v) for k, v in data.items() if len(k) == 3} data = d = CourseData(**data) # compute missing values From 6eaa93d3394daa6bb1f6b87cc72e02512a6268d8 Mon Sep 17 00:00:00 2001 From: quantenschaum <woxpox@posteo.de> Date: Thu, 18 Jul 2024 21:57:29 +0200 Subject: [PATCH 02/18] #27 windplot: use time from data not from browser --- Sail_Instrument/plugin.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sail_Instrument/plugin.js b/Sail_Instrument/plugin.js index 752faf5..8ee1afa 100644 --- a/Sail_Instrument/plugin.js +++ b/Sail_Instrument/plugin.js @@ -167,7 +167,6 @@ var WindPlotWidget = { let valid = typeof(v)=="number" && isFinite(v); if(!valid) return; - let now=Date.now(); let time=data.TIME.valueOf(); let tmax=data.history, n=5; @@ -250,7 +249,7 @@ var WindPlotWidget = { let c=""; ctx.beginPath(); for (k of hist.keys()) { - let t=(now-k)/1000; + let t=(time-k)/1000; if(t>tmax){ hist.delete(k); continue; } let x=xc+val(hist.get(k))*dx/2; let y=y0+t*dy/tmax; From 3d681b65af29954b77b030e4321ac97fecc2b350 Mon Sep 17 00:00:00 2001 From: quantenschaum <woxpox@posteo.de> Date: Thu, 18 Jul 2024 22:09:13 +0200 Subject: [PATCH 03/18] check for None --- Sail_Instrument/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sail_Instrument/plugin.py b/Sail_Instrument/plugin.py index adbc7c5..a6ed5fa 100644 --- a/Sail_Instrument/plugin.py +++ b/Sail_Instrument/plugin.py @@ -476,7 +476,7 @@ def run(self): data["DOT"] = dot if dot >= 0 else None data["DRT"] = draught if draught >= 0 else None - data = {k: (to180(v) if k.endswith("A") else v) for k, v in data.items() if len(k) == 3} + data = {k: (to180(v) if k.endswith("A") and v else v) for k, v in data.items() if len(k) == 3} data = d = CourseData(**data) # compute missing values From ba77235f2eec186174318238eadcffbd2b8f0b4e Mon Sep 17 00:00:00 2001 From: quantenschaum <woxpox@posteo.de> Date: Fri, 19 Jul 2024 01:27:52 +0200 Subject: [PATCH 04/18] #29 range=0 => auto range --- Sail_Instrument/plugin.js | 132 ++++++++++++++++++++++++++++++-------- Sail_Instrument/plugin.py | 4 +- 2 files changed, 108 insertions(+), 28 deletions(-) diff --git a/Sail_Instrument/plugin.js b/Sail_Instrument/plugin.js index 8ee1afa..a119afb 100644 --- a/Sail_Instrument/plugin.js +++ b/Sail_Instrument/plugin.js @@ -147,6 +147,14 @@ var WindPlotWidget = { TWAF: 'nav.gps.sail_instrument.TWAF', TWDF: 'nav.gps.sail_instrument.TWDF', TWSF: 'nav.gps.sail_instrument.TWSF', + COG: 'nav.gps.course', + SOG: 'nav.gps.speed', + HDT: 'nav.gps.sail_instrument.HDT', + STW: 'nav.gps.sail_instrument.STW', + HEL: 'nav.gps.sail_instrument.HEL', + DBS: 'nav.gps.sail_instrument.DBS', + DBT: 'nav.gps.sail_instrument.DBT', + DBK: 'nav.gps.sail_instrument.DBK', }, initFunction: function() {}, finalizeFunction: function() {}, @@ -165,42 +173,119 @@ var WindPlotWidget = { let v = data[data.quantity]; let valid = typeof(v)=="number" && isFinite(v); +// console.log(data.quantity,v); if(!valid) return; let time=data.TIME.valueOf(); let tmax=data.history, n=5; - var m=data.range; - var c0 = d=>d.TWA<0 ? red : green; - var c1 = d=>Math.abs(d.TWA)<70 ? blue : Math.abs(d.TWA)<130 ? "#06c4d1": "#b304de"; + var hist=window.windplothist; + if(typeof(hist)=="undefined"){ + window.windplothist=hist=new Map(); + } + hist.set(time,data); + + function maxrange(name,c){ + let min=data[name]; let max=min; + if(typeof(c)!="undefined"){ + min=max=0; + } + for (let [k,d] of hist) { + let v = d[name]; + if(typeof(c)!="undefined"){ + v = to180(v-c); + } + if(v){ + min = Math.min(min,v); + max = Math.max(max,v); + } + } + return Math.ceil(Math.max(1,max-min)); + } + + var q = data.quantity; + var r = data.range; + var xtick = x => x.toFixed(1).replace(".0",""); + var c0 = d => d.AWA<0 ? red : d.AWA>0 ? green : blue; + var c1 = d => Math.abs(d.TWA)<70 ? blue : Math.abs(d.TWA)<130 ? "#06c4d1": "#b304de"; + var v1 = false; + if(data.quantity=="AWA"){ - var c=Math.round(data.AWAF); + var c = Math.round(data.AWAF); + var m = r>0 ? r : maxrange(q,c); + var xtick = x => to180(x).toFixed(1).replace(".0",""); var v0 = d=>to180(d.AWA-c)/m; var v1 = d=>to180(d.AWAF-c)/m; + } else if(data.quantity=="TWA"){ - var c=Math.round(data.TWAF); + var c = Math.round(data.TWAF); + var m = r>0 ? r : maxrange(q,c); + var xtick = x => to180(x).toFixed(1).replace(".0",""); var v0 = d=>to180(d.TWA-c)/m; var v1 = d=>to180(d.TWAF-c)/m; + } else if(data.quantity=="TWD"){ - var c=Math.round(data.TWDF); + var c = Math.round(data.TWDF); + var m = r>0 ? r : maxrange(q,c); + var xtick = x => to360(x).toFixed(1).replace(".0",""); var v0 = d=>to180(d.TWD-c)/m; var v1 = d=>to180(d.TWDF-c)/m; + } else if(data.quantity=="TWS"){ - var c=Math.round(knots(data.TWSF)*10)/10; - var m=c; + var c = r>0 ? r/2 : Math.round(knots(data.TWSF)*10)/10; + var m = c; var v0 = d=>(knots(d.TWS)-c)/m; var v1 = d=>(knots(d.TWSF)-c)/m; var c0 = d=>"gray"; -// var c1 = d=>blue; + } else if(data.quantity=="AWS"){ - var c=Math.round(knots(data.AWSF)*10)/10; - var m=c; + var c = r>0 ? r/2 : Math.round(knots(data.AWSF)*10)/10; + var m = c; var v0 = d=>(knots(d.AWS)-c)/m; var v1 = d=>(knots(d.AWSF)-c)/m; var c0 = d=>"gray"; -// var c1 = d=>blue; + + } else if(data.quantity=="COG"){ + var c = Math.round(data.COG); + var m = r>0 ? r : maxrange(q,c); + var xtick = x => to360(x).toFixed(1).replace(".0",""); + var v0 = d=>to180(d.COG-c)/m; + var c0 = d=>blue; + + } else if(data.quantity=="SOG"){ + var c = Math.round(knots(data.SOG)*10)/10; + var m = c; + var v0 = d=>(knots(d.SOG)-c)/m; + var c0 = d=>"gray"; + + } else if(data.quantity=="HDT"){ + var c = Math.round(data.HDT); + var m = r>0 ? r : maxrange(q,c); + var xtick = x => to360(x).toFixed(1).replace(".0",""); + var v0 = d=>to180(d.HDT-c)/m; + var c0 = d=>blue; + + } else if(data.quantity=="STW"){ + var c = r>0 ? r/2 : Math.round(knots(data.STW)*10)/10; + var m = c; + var v0 = d=>(knots(d.STW)-c)/m; + var c0 = d=>"gray"; + + } else if(data.quantity=="HEL"){ + var c = 0; + var m = r>0 ? r : maxrange(q); + var v0 = d=>d.HEL/m; + var c0 = d=>blue; + + } else if(data.quantity=="DBS"){ + var c = r>0 ? r/2 : Math.round(knots(data.DBS)*10)/10; m = c; + var m = c; + var v0 = d=>(d.DBS-c)/m; + var c0 = d=>blue; } +// console.log(q,data[q],r,c,m); + var f=w<400 ? 0 : Math.min(w/40,30); var o=1.4*f; @@ -211,12 +296,12 @@ var WindPlotWidget = { ctx.textAlign = "center"; o=0.45*f; ctx.font = "bold "+f.toFixed(0)+"px sans-serif"; - ctx.fillText( c.toFixed(1).replace(".0",""), xc,y0-o); + ctx.fillText(xtick(c), xc,y0-o); ctx.font = f.toFixed(0)+"px sans-serif"; - ctx.fillText((c-m/1).toFixed(1).replace(".0",""), x0,y0-o); - ctx.fillText((c-m/2).toFixed(1).replace(".0",""), xc-dx/4,y0-o); - ctx.fillText((c+m/2).toFixed(1).replace(".0",""), xc+dx/4,y0-o); - ctx.fillText((c+m/1).toFixed(1).replace(".0",""), x1,y0-o); + ctx.fillText(xtick(c-m/1), x0,y0-o); + ctx.fillText(xtick(c+m/1), x1,y0-o); + ctx.fillText(xtick(c-m/2), xc-dx/4,y0-o); + ctx.fillText(xtick(c+m/2), xc+dx/4,y0-o); ctx.beginPath(); ctx.moveTo(xc,y0); @@ -236,20 +321,15 @@ var WindPlotWidget = { } ctx.stroke(); - var hist=window.windplothist; - if(typeof(hist)=="undefined"){ - window.windplothist=hist=new Map(); - } - hist.set(time,data); - function line(val,col,width,dash=[]){ + if(!val) return; ctx.lineWidth = width; ctx.setLineDash(dash); let p=[Number.NaN,0]; let c=""; ctx.beginPath(); for (k of hist.keys()) { - let t=(time-k)/1000; + let t=Math.max(0,time-k)/1000; if(t>tmax){ hist.delete(k); continue; } let x=xc+val(hist.get(k))*dx/2; let y=y0+t*dy/tmax; @@ -283,7 +363,7 @@ var WindPlotWidget = { var WindPlotParams = { quantity: { type: 'SELECT', - list: ['TWD','TWS','TWA','AWA','AWS'], + list: ['TWD','TWS','TWA','AWA','AWS','COG','SOG','HDT','STW','HEL','DBS'], default: 'TWD' }, history: { @@ -292,7 +372,7 @@ var WindPlotParams = { }, range: { type: 'NUMBER', - default: 20 + default: 0 }, }; avnav.api.registerWidget(WindPlotWidget, WindPlotParams); diff --git a/Sail_Instrument/plugin.py b/Sail_Instrument/plugin.py index a6ed5fa..e593022 100644 --- a/Sail_Instrument/plugin.py +++ b/Sail_Instrument/plugin.py @@ -29,7 +29,7 @@ import shutil import sys import time -from math import sin, cos, radians, degrees, sqrt, atan2, isfinite, copysign, nan +from math import sin, cos, radians, degrees, sqrt, atan2, isfinite, copysign import numpy import scipy.interpolate @@ -465,7 +465,7 @@ def run(self): self.msg += ", manually entered wind" if data["HEL"] is None and self.heels and all(d.has(k) for k in ("TWAF", "TWSF")): - data["HEL"] = self.heels.value(d["TWAF"], d["TWSF"] * KNOTS) + data["HEL"] = copysign(self.heels.value(d["TWAF"], d["TWSF"] * KNOTS), -d["TWAF"]) self.msg += ", heel from polar" if data["HEL"] is not None: From 1c464da0dfe77f230d7558e8f6d665e590159f30 Mon Sep 17 00:00:00 2001 From: quantenschaum <woxpox@posteo.de> Date: Fri, 19 Jul 2024 14:36:07 +0200 Subject: [PATCH 05/18] fixed DBS graph, keep 1800s of history --- Sail_Instrument/plugin.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sail_Instrument/plugin.js b/Sail_Instrument/plugin.js index a119afb..3e5e18b 100644 --- a/Sail_Instrument/plugin.js +++ b/Sail_Instrument/plugin.js @@ -278,7 +278,7 @@ var WindPlotWidget = { var c0 = d=>blue; } else if(data.quantity=="DBS"){ - var c = r>0 ? r/2 : Math.round(knots(data.DBS)*10)/10; m = c; + var c = r>0 ? r/2 : Math.round(data.DBS*10)/10; var m = c; var v0 = d=>(d.DBS-c)/m; var c0 = d=>blue; @@ -330,7 +330,8 @@ var WindPlotWidget = { ctx.beginPath(); for (k of hist.keys()) { let t=Math.max(0,time-k)/1000; - if(t>tmax){ hist.delete(k); continue; } + if(t>tmax){ continue; } + if(t>1800){ hist.delete(k); continue; } let x=xc+val(hist.get(k))*dx/2; let y=y0+t*dy/tmax; let s = col(hist.get(k)); From f9d537eaaacb2e5492dcb030fc53ac2a44e98b95 Mon Sep 17 00:00:00 2001 From: quantenschaum <woxpox@posteo.de> Date: Thu, 22 Aug 2024 12:41:29 +0200 Subject: [PATCH 06/18] added wind definitions --- docs/3-Calculated-Data.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/3-Calculated-Data.md b/docs/3-Calculated-Data.md index f07592f..c4a7e6d 100644 --- a/docs/3-Calculated-Data.md +++ b/docs/3-Calculated-Data.md @@ -173,7 +173,19 @@ This equation corresponds to the triangle/parallelogram on the right side of the ### Wind -In general, angles (xxA, relative to heading) and directions (xxD rel. to true north) are always converted by adding/subtracting true heading HDT. +- AWS = Apparent Wind Speed = wind speed relativ of boat, measured by the wind sensor +- AWA = Apparent Wind Angle = angle between the direction of the apparent wind (where it comes from) and the direction the bow is pointing to (heading), measured by the wind sensor +- AWD = Apparent Wind Direction = direction of the wind relative to true north (usually not used) +- TWS = True Wind Speed = wind speed relative to the surface of the water, true wind is calculated from apparent wind, heading, waterspeed (and leeway) +- TWA = True Wind Angle = angle between the direction of the true wind and heading +- TWD = True Wind Direction = direction of the true wind relative to true north +- GWS = Ground Wind Speed = wind speed relative to the ground, ground wind is calculated from apparent wind, heading, course and speed over ground, in the weather forecast +- GWA = Ground Wind Angle = angle between the direction of the ground wind and heading (usually not used) +- GWD = Ground Wind Direction = direction of the ground wind relative to true north, in the weather forecast + + In general, angles (xxA, relative to heading) and directions (xxD rel. to true north) are always converted by adding/subtracting true heading HDT. + +$$ xxD = xxA + HDT, xxA = xxD - HDT $$ True wind, which is the wind vector relative to water, can be obtained from apparent wind measured by the wind meter (direction and speed) and water speed. To get the angle right, leeway also enters the equation. From 87e1d5bc8ee24e6b0a1cac065b667a50cd5e881a Mon Sep 17 00:00:00 2001 From: quantenschaum <woxpox@posteo.de> Date: Thu, 22 Aug 2024 12:44:49 +0200 Subject: [PATCH 07/18] added wind definitions --- docs/3-Calculated-Data.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/3-Calculated-Data.md b/docs/3-Calculated-Data.md index c4a7e6d..9748034 100644 --- a/docs/3-Calculated-Data.md +++ b/docs/3-Calculated-Data.md @@ -173,8 +173,8 @@ This equation corresponds to the triangle/parallelogram on the right side of the ### Wind -- AWS = Apparent Wind Speed = wind speed relativ of boat, measured by the wind sensor -- AWA = Apparent Wind Angle = angle between the direction of the apparent wind (where it comes from) and the direction the bow is pointing to (heading), measured by the wind sensor +- AWS = Apparent Wind Speed = wind speed relativ to boat, measured by the wind sensor +- AWA = Apparent Wind Angle = angle between the direction of apparent wind (where it comes from) and direction the bow is pointing to (heading), measured by the wind sensor - AWD = Apparent Wind Direction = direction of the wind relative to true north (usually not used) - TWS = True Wind Speed = wind speed relative to the surface of the water, true wind is calculated from apparent wind, heading, waterspeed (and leeway) - TWA = True Wind Angle = angle between the direction of the true wind and heading From d8a7a1f36fd7cf82fb8d14595386299a8a8258aa Mon Sep 17 00:00:00 2001 From: quantenschaum <woxpox@posteo.de> Date: Fri, 23 Aug 2024 21:52:40 +0200 Subject: [PATCH 08/18] updated vactor drawing --- docs/Images/vectors.svg | 85 +++++++++++++++++++++++++++++++++-------- 1 file changed, 69 insertions(+), 16 deletions(-) diff --git a/docs/Images/vectors.svg b/docs/Images/vectors.svg index e8f544e..bc2e9db 100644 --- a/docs/Images/vectors.svg +++ b/docs/Images/vectors.svg @@ -24,12 +24,12 @@ inkscape:deskcolor="#505050" inkscape:document-units="mm" showgrid="false" - inkscape:zoom="1.6454054" - inkscape:cx="396.5588" - inkscape:cy="561.25984" - inkscape:window-width="2121" + inkscape:zoom="2.3269546" + inkscape:cx="299.10338" + inkscape:cy="659.01586" + inkscape:window-width="2784" inkscape:window-height="2091" - inkscape:window-x="1216" + inkscape:window-x="540" inkscape:window-y="29" inkscape:window-maximized="0" inkscape:current-layer="layer1" @@ -5150,13 +5150,6 @@ cx="141.38208" cy="175.96532" r="0.27324086" /> - <path - id="path1727" - style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" - d="m 128.38333,197.85981 0.85167,-1.17875 -1.17874,-0.85169" - sodipodi:nodetypes="ccc" - inkscape:transform-center-x="0.58016704" - inkscape:transform-center-y="0.15858348" /> <path id="path1730" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" @@ -5189,12 +5182,72 @@ inkscape:transform-center-x="0.56875872" inkscape:transform-center-y="-0.15544898" /> </g> + <g + id="g1447"> + <path + id="path1727" + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="m 128.38333,197.85981 0.85167,-1.17875 -1.17874,-0.85169" + sodipodi:nodetypes="ccc" + inkscape:transform-center-x="0.58016704" + inkscape:transform-center-y="0.15858348" /> + <path + id="path2859" + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="m 129.10379,197.73841 0.85167,-1.17875 -1.17874,-0.85169" + sodipodi:nodetypes="ccc" + inkscape:transform-center-x="0.58016704" + inkscape:transform-center-y="0.15858348" /> + </g> <path - id="path2859" + id="path1443" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" - d="m 129.10379,197.73841 0.85167,-1.17875 -1.17874,-0.85169" + d="m 53.197327,153.65242 0.62829,-1.31151 -1.31151,-0.62829" sodipodi:nodetypes="ccc" - inkscape:transform-center-x="0.58016704" - inkscape:transform-center-y="0.15858348" /> + inkscape:transform-center-x="0.63477872" + inkscape:transform-center-y="0.33808102" /> + <g + id="g1453" + transform="translate(-94.562223,-46.042422)"> + <path + id="path1449" + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="m 128.38333,197.85981 0.85167,-1.17875 -1.17874,-0.85169" + sodipodi:nodetypes="ccc" + inkscape:transform-center-x="0.58016704" + inkscape:transform-center-y="0.15858348" /> + <path + id="path1451" + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="m 129.10379,197.73841 0.85167,-1.17875 -1.17874,-0.85169" + sodipodi:nodetypes="ccc" + inkscape:transform-center-x="0.58016704" + inkscape:transform-center-y="0.15858348" /> + </g> + <g + id="g1461" + transform="translate(-90.666202,-45.177075)"> + <path + id="path1455" + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="m 113.14253,203.24741 1.17777,-0.85305 -0.85306,-1.17775" + sodipodi:nodetypes="ccc" + inkscape:transform-center-x="0.56875872" + inkscape:transform-center-y="-0.15544898" /> + <path + id="path1457" + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="m 113.83164,203.35555 1.17777,-0.85305 -0.85306,-1.17775" + sodipodi:nodetypes="ccc" + inkscape:transform-center-x="0.56875872" + inkscape:transform-center-y="-0.15544898" /> + <path + id="path1459" + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="m 114.50728,203.46157 1.17777,-0.85305 -0.85306,-1.17775" + sodipodi:nodetypes="ccc" + inkscape:transform-center-x="0.56875872" + inkscape:transform-center-y="-0.15544898" /> + </g> </g> </svg> From 520664f68206f98304c333ee4afc8e8c487aca72 Mon Sep 17 00:00:00 2001 From: quantenschaum <woxpox@posteo.de> Date: Fri, 23 Aug 2024 22:47:49 +0200 Subject: [PATCH 09/18] added option to hide rings in sail instrument overlay and aspect ratio of the mini wind plot --- Sail_Instrument/plugin.js | 42 +++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/Sail_Instrument/plugin.js b/Sail_Instrument/plugin.js index 3e5e18b..d0f5fc4 100644 --- a/Sail_Instrument/plugin.js +++ b/Sail_Instrument/plugin.js @@ -134,6 +134,7 @@ var WindPlotWidget = { unit: "°", history: 600, range: 20, + aspect: 1, quantity: "TWD", storeKeys: { TIME: 'nav.gps.rtime', @@ -160,6 +161,9 @@ var WindPlotWidget = { finalizeFunction: function() {}, renderCanvas: function(canvas, data) { // console.log(data); + let time=data.TIME.valueOf(); + let tmax=data.history, n=5; + let ctx = canvas.getContext('2d'); ctx.save(); canvas.style.height='99%'; @@ -167,7 +171,7 @@ var WindPlotWidget = { let w = bcr.width, h = bcr.height; if(w<150){ canvas.style.height=''; - h = w; + h = w*data.aspect; } canvas.width=w; canvas.height=h; @@ -176,9 +180,6 @@ var WindPlotWidget = { // console.log(data.quantity,v); if(!valid) return; - let time=data.TIME.valueOf(); - let tmax=data.history, n=5; - var hist=window.windplothist; if(typeof(hist)=="undefined"){ window.windplothist=hist=new Map(); @@ -375,6 +376,10 @@ var WindPlotParams = { type: 'NUMBER', default: 0 }, + aspect: { + type: 'NUMBER', + default: 1 + }, }; avnav.api.registerWidget(WindPlotWidget, WindPlotParams); @@ -498,6 +503,10 @@ var Sail_Instrument_OverlayParameter = { type: 'NUMBER', default: 1 }, + Rings: { + type: 'BOOLEAN', + default: true + }, }; let Sail_Instrument_Overlay = { @@ -570,16 +579,17 @@ function drawWindWidget(ctx,size, maprotation, data){ // console.log("wind widget",data); if (typeof(maprotation) == 'undefined') { return; } var vmin = typeof(data.VMIN) == 'undefined' ? 0 : data.VMIN; - DrawKompassring(ctx, size, maprotation); + var rings = typeof(data.Rings) == 'undefined' ? true : data.Rings; + if(rings) DrawKompassring(ctx, size, maprotation); if (data.HDT>=0) { - DrawOuterRing(ctx, size, maprotation + data.HDT); + if(rings) DrawOuterRing(ctx, size, maprotation + data.HDT); } else { return; // cannot draw anything w/o HDT } if (knots(data.DFTF)>=vmin && data.SETF>=0) { drawTideArrow(ctx, size, maprotation + data.SETF , "teal", knots(data.DFTF).toFixed(1)); } - if (knots(data.TWSF)>=1) { + if (knots(data.TWSF)>=1 && rings) { if(data.POLAR){ drawPolar(ctx,size,maprotation,data,"black"); } @@ -599,14 +609,16 @@ function drawWindWidget(ctx,size, maprotation, data){ if (knots(data.TWSF)>=1) { DrawWindpfeilIcon(ctx, size, maprotation + data.TWDF, blue, data.HDT==data.COG ? 'G' : 'T'); } - if (data.BRG>=0) { - DrawWPIcon(ctx, size, maprotation + data.BRG); - } - if (knots(data.SOG)>=vmin && data.COG>=0) { - DrawEierUhr(ctx, size, maprotation + data.COG, orange); - } - if (data.HDT>=0) { - DrawCourseBox(ctx, size, maprotation + data.HDT, black, Math.round(data.HDT)); + if(rings) { + if (data.BRG>=0) { + DrawWPIcon(ctx, size, maprotation + data.BRG); + } + if (knots(data.SOG)>=vmin && data.COG>=0) { + DrawEierUhr(ctx, size, maprotation + data.COG, orange); + } + if (data.HDT>=0) { + DrawCourseBox(ctx, size, maprotation + data.HDT, black, Math.round(data.HDT)); + } } } From fc69553d1df57700c980af0cf060c7bbfe6926e3 Mon Sep 17 00:00:00 2001 From: quantenschaum <woxpox@posteo.de> Date: Fri, 23 Aug 2024 23:01:07 +0200 Subject: [PATCH 10/18] added VPP = STW/VPOL*100 satisfies #30 --- Sail_Instrument/plugin.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sail_Instrument/plugin.py b/Sail_Instrument/plugin.py index e593022..635252b 100644 --- a/Sail_Instrument/plugin.py +++ b/Sail_Instrument/plugin.py @@ -572,6 +572,8 @@ def laylines(self, data): self.msg += ", laylines from table" data.VPOL = self.polar.value(twa, tws * KNOTS) * MPS + if data.has("VPOL","STW"): + data.VPP = data.STW/data.VPOL*100 self.msg += ", calculate VPOL" if self.config[SHOW_POLAR]: From 267346aea4fc2fe4a524ea40a3857d05df7634e7 Mon Sep 17 00:00:00 2001 From: quantenschaum <woxpox@posteo.de> Date: Fri, 23 Aug 2024 23:18:40 +0200 Subject: [PATCH 11/18] fixed history cleanup --- Sail_Instrument/plugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sail_Instrument/plugin.js b/Sail_Instrument/plugin.js index d0f5fc4..606a855 100644 --- a/Sail_Instrument/plugin.js +++ b/Sail_Instrument/plugin.js @@ -331,8 +331,8 @@ var WindPlotWidget = { ctx.beginPath(); for (k of hist.keys()) { let t=Math.max(0,time-k)/1000; - if(t>tmax){ continue; } if(t>1800){ hist.delete(k); continue; } + if(t>tmax){ continue; } let x=xc+val(hist.get(k))*dx/2; let y=y0+t*dy/tmax; let s = col(hist.get(k)); From 98701d6c02e838ce3869e4d2b2a973e27852f908 Mon Sep 17 00:00:00 2001 From: quantenschaum <woxpox@posteo.de> Date: Fri, 23 Aug 2024 23:55:35 +0200 Subject: [PATCH 12/18] adjusted to360() function --- Sail_Instrument/plugin.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/Sail_Instrument/plugin.py b/Sail_Instrument/plugin.py index 635252b..22f2dae 100644 --- a/Sail_Instrument/plugin.py +++ b/Sail_Instrument/plugin.py @@ -869,8 +869,6 @@ def angle(self, a): def to360(a): "limit a to [0,360)" - while a < 0: - a += 360 return a % 360 From fee5f1f64e4c6c904ead3ca110597b3eb9b5b4fd Mon Sep 17 00:00:00 2001 From: quantenschaum <woxpox@posteo.de> Date: Sat, 24 Aug 2024 15:38:59 +0200 Subject: [PATCH 13/18] do not draw overlay if pos=0,0 --- Sail_Instrument/plugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sail_Instrument/plugin.js b/Sail_Instrument/plugin.js index 606a855..c3e01d6 100644 --- a/Sail_Instrument/plugin.js +++ b/Sail_Instrument/plugin.js @@ -550,7 +550,7 @@ let Sail_Instrument_Overlay = { if (data.Widgetposition == 'Mapcenter') { ctx.translate(canvas.width/2, canvas.height/2); } else if (data.Widgetposition == 'Boatposition') { - if (typeof(data.POS) != 'undefined') { + if (typeof(data.POS) != 'undefined' && data.POS.lat!=0 && data.POS.lon!=0) { coordinates = this.lonLatToPixel(data.POS.lon, data.POS.lat) ctx.translate(coordinates[0], coordinates[1]); } else { From bfd4bd7d6e80a8cc3a5bed85ece78bda6a7b7951 Mon Sep 17 00:00:00 2001 From: quantenschaum <woxpox@posteo.de> Date: Sun, 25 Aug 2024 13:19:17 +0200 Subject: [PATCH 14/18] skip if there is no TIME --- Sail_Instrument/plugin.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sail_Instrument/plugin.js b/Sail_Instrument/plugin.js index c3e01d6..b2e5057 100644 --- a/Sail_Instrument/plugin.js +++ b/Sail_Instrument/plugin.js @@ -160,7 +160,8 @@ var WindPlotWidget = { initFunction: function() {}, finalizeFunction: function() {}, renderCanvas: function(canvas, data) { -// console.log(data); + // console.log(data); + if(typeof(data.TIME)=="undefined") return; let time=data.TIME.valueOf(); let tmax=data.history, n=5; From 06703194675c2b1465dba53fa05ea6a7ac5dae7d Mon Sep 17 00:00:00 2001 From: quantenschaum <woxpox@posteo.de> Date: Wed, 11 Sep 2024 17:23:29 +0200 Subject: [PATCH 15/18] explicitly set source when writing data --- Sail_Instrument/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sail_Instrument/plugin.py b/Sail_Instrument/plugin.py index 22f2dae..35f8a3c 100644 --- a/Sail_Instrument/plugin.py +++ b/Sail_Instrument/plugin.py @@ -361,7 +361,7 @@ def writeValue(self, data, key, path): return a = self.api.getSingleValue(path, includeInfo=True) if a is None or SOURCE in a.source: - self.api.addData(path, data[key]) + self.api.addData(path, data[key], source=SOURCE) def mag_variation(self, lat, lon): if not self.variation_model: From ce8360ebcf973886657e2615e7c71789e4eac58a Mon Sep 17 00:00:00 2001 From: quantenschaum <woxpox@posteo.de> Date: Wed, 11 Sep 2024 17:35:04 +0200 Subject: [PATCH 16/18] merged master --- Sail_Instrument/plugin.js | 1 - Sail_Instrument/plugin.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Sail_Instrument/plugin.js b/Sail_Instrument/plugin.js index 3fc5eb3..b735aa8 100644 --- a/Sail_Instrument/plugin.js +++ b/Sail_Instrument/plugin.js @@ -332,7 +332,6 @@ var WindPlotWidget = { ctx.beginPath(); for (k of hist.keys()) { let t=Math.max(0,time-k)/1000; - if(t>1800){ continue; } if(t>1800){ hist.delete(k); continue; } if(t>tmax){ continue; } let x=xc+val(hist.get(k))*dx/2; diff --git a/Sail_Instrument/plugin.py b/Sail_Instrument/plugin.py index da4adaa..e5d6a26 100644 --- a/Sail_Instrument/plugin.py +++ b/Sail_Instrument/plugin.py @@ -52,7 +52,7 @@ except: pass -PLUGIN_VERSION = 20240731 +PLUGIN_VERSION = 20240911 SOURCE = "Sail_Instrument" MIN_AVNAV_VERSION = 20230705 KNOTS = 1.94384 # knots per m/s From 05304282000a07f843ee55b44259bf658813302c Mon Sep 17 00:00:00 2001 From: quantenschaum <woxpox@posteo.de> Date: Tue, 17 Sep 2024 17:26:52 +0200 Subject: [PATCH 17/18] removed experimental workaround --- Sail_Instrument/plugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sail_Instrument/plugin.py b/Sail_Instrument/plugin.py index e5d6a26..f4c41f4 100644 --- a/Sail_Instrument/plugin.py +++ b/Sail_Instrument/plugin.py @@ -497,8 +497,8 @@ def run(self): calculated -= present data.VMIN = self.config[VMIN] - for k in ("COG","SOG","HDT","STW"): - if data.misses(k): data[k] = -1 # explicitly mark as undefined + # for k in ("COG","SOG","HDT","STW"): + # if data.misses(k): data[k] = -1 # explicitly mark as undefined, workaround for for k in data.keys(): # print(f"{PATH_PREFIX + k}={data[k]}") From 2f32112795d7c3184f6451d22c53d3d947c1ba15 Mon Sep 17 00:00:00 2001 From: quantenschaum <woxpox@posteo.de> Date: Tue, 17 Sep 2024 17:27:31 +0200 Subject: [PATCH 18/18] removed experimental workaround --- Sail_Instrument/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sail_Instrument/plugin.py b/Sail_Instrument/plugin.py index f4c41f4..0388f08 100644 --- a/Sail_Instrument/plugin.py +++ b/Sail_Instrument/plugin.py @@ -498,7 +498,7 @@ def run(self): data.VMIN = self.config[VMIN] # for k in ("COG","SOG","HDT","STW"): - # if data.misses(k): data[k] = -1 # explicitly mark as undefined, workaround for + # if data.misses(k): data[k] = -1 # explicitly mark as undefined, workaround for https://github.com/wellenvogel/avnav/issues/347 for k in data.keys(): # print(f"{PATH_PREFIX + k}={data[k]}")