@sailingrotevista/rotevista-dash 7.0.27 → 7.0.28

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.
Files changed (3) hide show
  1. package/app.js +7 -13
  2. package/index.js +7 -18
  3. package/package.json +1 -1
package/app.js CHANGED
@@ -216,7 +216,7 @@ function checkDepthAlarm(m) {
216
216
  function computeTrueWind() {
217
217
  const aws = store.raw["environment.wind.speedApparent"], awa = store.raw["environment.wind.angleApparent"];
218
218
  const stw = store.raw["navigation.speedThroughWater"], sog = store.raw["navigation.speedOverGround"] || 0;
219
- const hdg = store.raw["navigation.headingTrue"] || 0; // Il COG qui non serve più per il calcolo stabile
219
+ const hdg = store.raw["navigation.headingTrue"]; // Rimosso il default a 0 fittizio all'avvio
220
220
  if (aws === undefined || awa === undefined) return;
221
221
 
222
222
  const now = store.timestamps["environment.wind.speedApparent"] || Date.now();
@@ -281,9 +281,10 @@ function computeTrueWind() {
281
281
  // ==========================================================================
282
282
  const hasNativeTwd = store.timestamps["environment.wind.directionTrue"] && (Date.now() - store.timestamps["environment.wind.directionTrue"] < 5000);
283
283
 
284
- if (!hasNativeTwd && tws_water > 0.05) {
284
+ // Eseguiamo il calcolo del TWD di fallback solo se la Prua (hdg) è realmente disponibile in memoria,
285
+ // evitando di inquinare i buffer all'avvio con lo zero fittizio
286
+ if (!hasNativeTwd && tws_water > 0.05 && hdg !== undefined) {
285
287
  // Calcolo TWD stabile e immune dal rollio: Prua + TWA
286
- // Elimina i sobbalzi legati al brandeggio del COG e dello scarroccio fasullo
287
288
  let twd = (hdg + twa + 2 * Math.PI) % (2 * Math.PI);
288
289
  store.raw["environment.wind.directionTrue"] = twd;
289
290
  safePush(store.smoothBuf.twd, twd, now);
@@ -1017,16 +1018,9 @@ async function fetchServerHistory() {
1017
1018
  }));
1018
1019
  }
1019
1020
 
1020
- // --- SILLABAZIONE STRATEGICA DELLA BUSSOLA METEO (TWD) ---
1021
- if (data.twd && data.twd.length > 0) {
1022
- store.longBuf.twd = data.twd.map(p => ({
1023
- val: p.val,
1024
- time: p.time + timeDelta, // Allinea il tempo strategico del radar
1025
- sin: Math.sin(p.val),
1026
- cos: Math.cos(p.val)
1027
- }));
1028
- console.log(`📈 Memoria strategica TWD sincronizzata dal server (${data.twd.length} punti).`);
1029
- }
1021
+ // Sincronizziamo lo storico dei minuti per il radar, ma lasciamo che il buffer rapido 'store.longBuf.twd'
1022
+ // parta pulito all'avvio. Si popolerà istantaneamente a 3Hz con i soli dati in tempo reale,
1023
+ // garantendo una reattività della direzione del vento (TWD) immediata e priva di sbalzi all'avvio.
1030
1024
  console.log("📈 Storico dei grafici pre-popolato caricato dal server.");
1031
1025
  }
1032
1026
  } catch (err) {
package/index.js CHANGED
@@ -161,11 +161,10 @@ module.exports = function (app) {
161
161
  const lastVal = raw[path];
162
162
  const lastTime = lastPathProcessTimes[path] || 0;
163
163
 
164
- // FILTRO DEDUPLICAZIONE CON HEARTBEAT DI SICUREZZA A 10 SECONDI:
165
- // Se il nuovo dato è identico al precedente e sono passati meno di 10 secondi dall'ultimo invio,
166
- // scartiamo subito l'elaborazione risparmiando cicli di CPU sul server.
167
- // La soglia dei 10s garantisce la compatibilità con il Gap Detection dei grafici client.
168
- if (lastVal !== undefined && isValueEqual(val, lastVal) && (now - lastTime < 10000)) {
164
+ // FILTRO DEDUPLICAZIONE CON HEARTBEAT DI SICUREZZA A 4 SECONDI:
165
+ // Ridotto a 4 secondi per garantire che anche con timeline corte (5 min, secchiello da 5s)
166
+ // il server scriva sempre almeno un punto nei buffer, evitando buchi nello storico.
167
+ if (lastVal !== undefined && isValueEqual(val, lastVal) && (now - lastTime < 4000)) {
169
168
  return;
170
169
  }
171
170
 
@@ -470,11 +469,6 @@ module.exports = function (app) {
470
469
  if (!isFinite(finalValue)) return;
471
470
  finalValue = Math.max(0, finalValue);
472
471
  histories[type].push({ val: finalValue, time: now });
473
-
474
- // EMISSIONE DEL DELTA: Se abbiamo calcolato il TWS di fallback, lo trasmettiamo a Signal K
475
- if (type === 'tws' && (now - lastNativeTwsTime > 5000)) {
476
- emitDelta('environment.wind.speedTrue', finalValue / 1.94384); // Converte nodi in m/s
477
- }
478
472
  } else {
479
473
  // Salvataggio specifico del TWD contenente l'oggetto { val, min, max, time }
480
474
  histories['twd'].push({
@@ -484,12 +478,6 @@ module.exports = function (app) {
484
478
  time: now
485
479
  });
486
480
 
487
- // EMISSIONE DEL DELTA: Se abbiamo calcolato il TWD di fallback, lo trasmettiamo a Signal K
488
- if (now - lastNativeTwdTime > 5000) {
489
- // Standard Signal K: trasmettiamo solo il valore medio (float numerico in radianti)
490
- emitDelta('environment.wind.directionTrue', finalValue.val);
491
- }
492
-
493
481
  // --- TRIGGER DI CONGELAMENTO ARCO (Ogni :00 e :30 dell'orologio) ---
494
482
  const current30mSlot = Math.floor(now / 1800000) * 1800000;
495
483
  if (lastFrozen30mSlot === 0) {
@@ -881,7 +869,7 @@ module.exports = function (app) {
881
869
  /**
882
870
  * emitDelta: Scrive ed emette un aggiornamento di rotta direttamente nel
883
871
  * server principale di Signal K per renderlo disponibile a tutti i client WebSocket.
884
- */
872
+
885
873
  function emitDelta(path, value) {
886
874
  if (typeof app.handleMessage === 'function') {
887
875
  app.handleMessage(plugin.id, {
@@ -901,7 +889,8 @@ module.exports = function (app) {
901
889
  });
902
890
  }
903
891
  }
904
-
892
+ */
893
+
905
894
  /**
906
895
  * pruneStaleHistories: Pota in background i punti storici obsoleti dei sensori spenti.
907
896
  * Evita il congelamento dei grafici sul tablet e previene sprechi di RAM sul server.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sailingrotevista/rotevista-dash",
3
- "version": "7.0.27",
3
+ "version": "7.0.28",
4
4
  "description": "Wind Dashboard with navigation and course aids",
5
5
  "main": "index.js",
6
6
  "publishConfig": {