@sailingrotevista/rotevista-dash 7.0.35 → 7.0.37
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/app.js +21 -19
- package/index.js +14 -15
- package/package.json +1 -1
package/app.js
CHANGED
|
@@ -342,7 +342,7 @@ function processIncomingData(path, val, source, timeMs) {
|
|
|
342
342
|
if (path === "environment.depth.belowTransducer" && (val < -2.0 || val > 500)) {
|
|
343
343
|
return;
|
|
344
344
|
}
|
|
345
|
-
|
|
345
|
+
|
|
346
346
|
const now = timeMs || Date.now();
|
|
347
347
|
const score = getSourcePriorityScore(source);
|
|
348
348
|
|
|
@@ -373,7 +373,7 @@ function processIncomingData(path, val, source, timeMs) {
|
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
375
|
|
|
376
|
-
// Aggiorna lo stato raw e sincronizza il timestamp del watchdog sull'orologio locale (Date.now()) per evitare falsi timeout
|
|
376
|
+
// Aggiorna lo stato raw e sincronizza il timestamp del watchdog sull'orologio locale (Date.now()) per evitare falsi timeout
|
|
377
377
|
const localNow = Date.now();
|
|
378
378
|
store.timestamps[path] = localNow;
|
|
379
379
|
store.raw[path] = val;
|
|
@@ -401,25 +401,21 @@ function processIncomingData(path, val, source, timeMs) {
|
|
|
401
401
|
lastPathProcessTimes[path] = now;
|
|
402
402
|
|
|
403
403
|
// Da qui in poi, l'inserimento nei buffer fisici avviene rigorosamente a 1Hz:
|
|
404
|
-
//if (path === "environment.wind.angleApparent") {
|
|
405
|
-
// safePush(store.smoothBuf.awa, val, now);
|
|
406
|
-
// safePush(store.longBuf.awa, val, now);
|
|
407
|
-
//}
|
|
408
404
|
|
|
409
|
-
//
|
|
405
|
+
// Intercetta il TWD nativo e lo spinge nei buffer della bussola radar
|
|
410
406
|
if (path === "environment.wind.directionTrue") {
|
|
411
407
|
let directionVal = (val && typeof val === 'object' && val.val !== undefined) ? val.val : val;
|
|
412
408
|
safePush(store.smoothBuf.twd, directionVal, now);
|
|
413
409
|
safePush(store.longBuf.twd, directionVal, now);
|
|
414
410
|
}
|
|
415
411
|
|
|
416
|
-
//
|
|
412
|
+
// Intercetta il TWS nativo e lo memorizza in tempo reale
|
|
417
413
|
if (path === "environment.wind.speedTrue") {
|
|
418
414
|
let speedVal = (val && typeof val === 'object' && val.val !== undefined) ? val.val : val;
|
|
419
415
|
store.raw["environment.wind.speedTrue"] = speedVal;
|
|
420
416
|
}
|
|
421
417
|
|
|
422
|
-
//
|
|
418
|
+
// Intercetta TWA nativo (Angolo Vento Reale)
|
|
423
419
|
if (path === "environment.wind.angleTrueWater") {
|
|
424
420
|
let angleVal = (val && typeof val === 'object' && val.val !== undefined) ? val.val : val;
|
|
425
421
|
store.raw["environment.wind.angleTrueWater"] = angleVal;
|
|
@@ -428,7 +424,7 @@ function processIncomingData(path, val, source, timeMs) {
|
|
|
428
424
|
// --- GESTIONE PRUA VERA / MAGNETICA CON AUTODIVIAZIONE ---
|
|
429
425
|
if (path === "navigation.headingTrue") {
|
|
430
426
|
store.timestamps["navigation.headingTrueNative"] = now; // Marca la presenza di un sensore nativo di prua vera
|
|
431
|
-
store.timestamps["navigation.headingTrue"] =
|
|
427
|
+
store.timestamps["navigation.headingTrue"] = localNow;
|
|
432
428
|
safePush(store.smoothBuf.hdg, val, now);
|
|
433
429
|
safePush(store.longBuf.hdg, val, now);
|
|
434
430
|
}
|
|
@@ -441,7 +437,7 @@ function processIncomingData(path, val, source, timeMs) {
|
|
|
441
437
|
|
|
442
438
|
// Registra il valore calcolato mantenendo attivo il watchdog senza bloccare i successivi pacchetti magnetici
|
|
443
439
|
store.raw["navigation.headingTrue"] = calculatedTrueHdg;
|
|
444
|
-
store.timestamps["navigation.headingTrue"] =
|
|
440
|
+
store.timestamps["navigation.headingTrue"] = localNow;
|
|
445
441
|
safePush(store.smoothBuf.hdg, calculatedTrueHdg, now);
|
|
446
442
|
safePush(store.longBuf.hdg, calculatedTrueHdg, now);
|
|
447
443
|
}
|
|
@@ -457,7 +453,7 @@ function processIncomingData(path, val, source, timeMs) {
|
|
|
457
453
|
const sog = store.raw["navigation.speedOverGround"] || 0;
|
|
458
454
|
if (!hasCompass && sog > 0.77) { // 0.77 m/s = 1.5 nodi
|
|
459
455
|
store.raw["navigation.headingTrue"] = val;
|
|
460
|
-
store.timestamps["navigation.headingTrue"] =
|
|
456
|
+
store.timestamps["navigation.headingTrue"] = localNow;
|
|
461
457
|
safePush(store.smoothBuf.hdg, val, now);
|
|
462
458
|
safePush(store.longBuf.hdg, val, now);
|
|
463
459
|
}
|
|
@@ -629,21 +625,27 @@ function updateWindTrend() {
|
|
|
629
625
|
// ==========================================================================
|
|
630
626
|
|
|
631
627
|
/**
|
|
632
|
-
* upUI: Aggiornamento valori digitali
|
|
628
|
+
* upUI: Aggiornamento valori digitali con tolleranza d'emergenza sul dato istantaneo
|
|
633
629
|
*/
|
|
634
630
|
const upUI = (el, obj, instantRaw, isCompass = false) => {
|
|
635
|
-
|
|
631
|
+
// Se la media obj non è momentaneamente disponibile, usa il dato istantaneo raw come paracadute
|
|
632
|
+
const displayRad = (obj && obj.val !== null && !isNaN(obj.val)) ? obj.val : instantRaw;
|
|
633
|
+
|
|
634
|
+
if (displayRad === undefined || displayRad === null || isNaN(displayRad)) {
|
|
636
635
|
el.innerHTML = "---°";
|
|
637
636
|
el.classList.remove('unstable-data');
|
|
638
637
|
} else {
|
|
639
|
-
let valDeg = Math.round(radToDeg(
|
|
638
|
+
let valDeg = Math.round(radToDeg(displayRad));
|
|
640
639
|
let mainVal = (isCompass ? ((valDeg + 360) % 360).toString().padStart(3, '0') : valDeg) + "°";
|
|
641
|
-
let dev = (obj.dev > 1 && obj.dev < 90) ? `<span style="font-size: 0.8em; opacity: 0.4; margin-left: 6px;">±${obj.dev}</span>` : "";
|
|
640
|
+
let dev = (obj && obj.dev > 1 && obj.dev < 90) ? `<span style="font-size: 0.8em; opacity: 0.4; margin-left: 6px;">±${obj.dev}</span>` : "";
|
|
642
641
|
el.innerHTML = mainVal + dev;
|
|
643
642
|
|
|
644
|
-
let diff = Math.abs((radToDeg(instantRaw) - radToDeg(obj.val) + 540) % 360 - 180);
|
|
645
|
-
if (isNavigating && (!obj.stable || obj.dev > CONFIG.averaging.stabilityBreakout || diff > CONFIG.averaging.stabilityBreakout))
|
|
646
|
-
|
|
643
|
+
let diff = (obj && instantRaw !== undefined) ? Math.abs((radToDeg(instantRaw) - radToDeg(obj.val) + 540) % 360 - 180) : 0;
|
|
644
|
+
if (isNavigating && (obj && (!obj.stable || obj.dev > CONFIG.averaging.stabilityBreakout || diff > CONFIG.averaging.stabilityBreakout))) {
|
|
645
|
+
el.classList.add('unstable-data');
|
|
646
|
+
} else {
|
|
647
|
+
el.classList.remove('unstable-data');
|
|
648
|
+
}
|
|
647
649
|
}
|
|
648
650
|
};
|
|
649
651
|
|
package/index.js
CHANGED
|
@@ -246,22 +246,21 @@ module.exports = function (app) {
|
|
|
246
246
|
// Già gestito e normalizzato dal filtro passa-basso superiore
|
|
247
247
|
}
|
|
248
248
|
else if (path === 'environment.wind.speedTrue') {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
else if (path === 'navigation.headingTrue') {
|
|
253
|
-
lastNativeHeadingTrueTime = now; // Rilevata prua vera nativa dalla rete NMEA
|
|
254
|
-
}
|
|
255
|
-
// --- DECODIFICA PRUA MAGNETICA SERVER-SIDE ---
|
|
256
|
-
else if (path === 'navigation.headingMagnetic') {
|
|
257
|
-
// Converte in prua vera solo se non c'è una bussola vera nativa attiva negli ultimi 5s
|
|
258
|
-
const hasNativeTrueHdg = (now - lastNativeHeadingTrueTime < 5000);
|
|
259
|
-
if (!hasNativeTrueHdg) {
|
|
260
|
-
const variation = raw['navigation.magneticVariation'] || 0;
|
|
261
|
-
raw['navigation.headingTrue'] = (smoothedVal + variation + 2 * Math.PI) % (2 * Math.PI);
|
|
249
|
+
lastNativeTwsTime = now; // Rilevato TWS nativo della centralina!
|
|
250
|
+
manageHistory('tws', smoothedVal * 1.94384);
|
|
262
251
|
}
|
|
263
|
-
|
|
264
|
-
|
|
252
|
+
else if (path === 'navigation.headingTrue') {
|
|
253
|
+
lastNativeHeadingTrueTime = now; // Rilevata prua vera nativa dalla rete NMEA
|
|
254
|
+
}
|
|
255
|
+
// --- DECODIFICA PRUA MAGNETICA SERVER-SIDE ---
|
|
256
|
+
else if (path === 'navigation.headingMagnetic') {
|
|
257
|
+
const hasNativeTrueHdg = (now - lastNativeHeadingTrueTime < 5000);
|
|
258
|
+
if (!hasNativeTrueHdg) {
|
|
259
|
+
const variation = raw['navigation.magneticVariation'] || 0;
|
|
260
|
+
raw['navigation.headingTrue'] = (smoothedVal + variation + 2 * Math.PI) % (2 * Math.PI);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
else if (path === 'environment.wind.directionTrue') {
|
|
265
264
|
lastNativeTwdTime = now; // Rilevato TWD nativo della centralina!
|
|
266
265
|
manageHistory('twd', smoothedVal);
|
|
267
266
|
}
|