@sailingrotevista/rotevista-dash 6.0.12 → 6.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +24 -17
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -16,11 +16,11 @@ module.exports = function (app) {
|
|
|
16
16
|
let routeRegistered = false;
|
|
17
17
|
let unsubscribes = [];
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
// Database dello storico in RAM sul server (Sintonizzato Pro v6.0)
|
|
20
|
+
let histories = { stw: [], sog: [], depth: [], tws: [], vmg: [], aws: [], twd: [] };
|
|
21
|
+
let graphTempBuf = { stw: [], sog: [], depth: [], tws: [], vmg: [], aws: [], twd: [] };
|
|
22
|
+
let lastUpdates = { stw: 0, sog: 0, depth: 0, tws: 0, vmg: 0, aws: 0, twd: 0 };
|
|
23
|
+
let raw = {};
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* plugin.start: Inizializza il plugin.
|
|
@@ -128,18 +128,25 @@ module.exports = function (app) {
|
|
|
128
128
|
const cog = raw["navigation.courseOverGroundTrue"] || 0;
|
|
129
129
|
|
|
130
130
|
if (aws !== undefined && awa !== undefined) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
131
|
+
const awsKts = aws * 1.94384;
|
|
132
|
+
const stwKts = stw * 1.94384;
|
|
133
|
+
const tw_water_x = awsKts * Math.cos(awa) - stwKts;
|
|
134
|
+
const tw_water_y = awsKts * Math.sin(awa);
|
|
135
|
+
const tws = Math.sqrt(tw_water_x * tw_water_x + tw_water_y * tw_water_y);
|
|
136
|
+
|
|
137
|
+
manageHistory('tws', tws);
|
|
138
|
+
|
|
139
|
+
const twa = Math.atan2(tw_water_y, tw_water_x);
|
|
140
|
+
const vmg = Math.abs(stwKts * Math.cos(twa));
|
|
141
|
+
manageHistory('vmg', vmg);
|
|
142
|
+
|
|
143
|
+
// --- CALCOLO TWD STRATEGICO SERVER-SIDE ---
|
|
144
|
+
if (hdg !== undefined) {
|
|
145
|
+
// Calcolo della direzione del vento reale rispetto al nord (TWD) in radianti
|
|
146
|
+
const twd = (hdg + twa + 2 * Math.PI) % (2 * Math.PI);
|
|
147
|
+
manageHistory('twd', twd);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
143
150
|
}
|
|
144
151
|
|
|
145
152
|
/**
|