@sailingrotevista/rotevista-dash 4.0.14 → 4.0.16
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 +37 -67
- package/package.json +1 -1
- package/style.css +28 -0
package/app.js
CHANGED
|
@@ -12,36 +12,23 @@
|
|
|
12
12
|
// 1. CONFIGURAZIONE E DEFAULT
|
|
13
13
|
// ==========================================================================
|
|
14
14
|
let CONFIG = {
|
|
15
|
-
alarms: {
|
|
16
|
-
depthDanger: 2.5,
|
|
17
|
-
depthWarning: 5.0
|
|
18
|
-
},
|
|
19
|
-
// Gestione parametri di stabilità e medie
|
|
15
|
+
alarms: { depthDanger: 2.5, depthWarning: 5.0 },
|
|
20
16
|
averaging: {
|
|
21
|
-
smoothWindow: 2000,
|
|
22
|
-
longWindow: 30000,
|
|
23
|
-
stabilityTolerance: 2000,
|
|
24
|
-
stabilityThreshold: 0.85,
|
|
25
|
-
minSpeed:
|
|
17
|
+
smoothWindow: 2000,
|
|
18
|
+
longWindow: 30000,
|
|
19
|
+
stabilityTolerance: 2000,
|
|
20
|
+
stabilityThreshold: 0.85,
|
|
21
|
+
minSpeed: 1,
|
|
26
22
|
stabilityBreakout: 15
|
|
27
23
|
},
|
|
28
|
-
|
|
29
|
-
graphs: {
|
|
30
|
-
reef1: 15.0, // Soglia primo reef (Orange)
|
|
31
|
-
reef2: 20.0, // Soglia secondo reef (Red)
|
|
32
|
-
historyMinutes: 5, // Finestra temporale visualizzata
|
|
33
|
-
samples: 60 // Numero di punti di campionamento
|
|
34
|
-
},
|
|
35
|
-
// Configurazioni scale automatiche
|
|
24
|
+
graphs: { reef1: 20.0, reef2: 25.0, historyMinutes: 10, samples: 60 },
|
|
36
25
|
scales: {
|
|
37
|
-
stw: { stdMax:
|
|
38
|
-
sog: { stdMax:
|
|
39
|
-
tws: { stdMax:
|
|
40
|
-
depth: { stdMax:
|
|
26
|
+
stw: { stdMax: 8, hercSpan: 4, step: 2 },
|
|
27
|
+
sog: { stdMax: 8, hercSpan: 4, step: 2 },
|
|
28
|
+
tws: { stdMax: 15, hercSpan: 10, step: 5 },
|
|
29
|
+
depth: { stdMax: 10, hercSpan: 10, step: 10 }
|
|
41
30
|
},
|
|
42
|
-
server: {
|
|
43
|
-
fallbackIp: "192.168.111.240:3000"
|
|
44
|
-
}
|
|
31
|
+
server: { fallbackIp: "192.168.111.240:3000" }
|
|
45
32
|
};
|
|
46
33
|
|
|
47
34
|
const RENDER_INTERVAL_MS = 1000;
|
|
@@ -254,9 +241,16 @@ function playGybeAlarm() {
|
|
|
254
241
|
}
|
|
255
242
|
|
|
256
243
|
function checkDepthAlarm(m) {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
244
|
+
// Rimuoviamo sempre le classi prima di riapplicarle
|
|
245
|
+
ui.depth.classList.remove('alarm-warning', 'alarm-danger', 'blink-alarm');
|
|
246
|
+
|
|
247
|
+
// Logica di confronto dinamica
|
|
248
|
+
if (m < CONFIG.alarms.depthDanger) {
|
|
249
|
+
ui.depth.classList.add('alarm-danger', 'blink-alarm');
|
|
250
|
+
playBingBing(); // Il tuo suono di allarme
|
|
251
|
+
} else if (m < CONFIG.alarms.depthWarning) {
|
|
252
|
+
ui.depth.classList.add('alarm-warning');
|
|
253
|
+
}
|
|
260
254
|
}
|
|
261
255
|
|
|
262
256
|
function updateLeewayDisplay(deg) {
|
|
@@ -560,56 +554,32 @@ function startDisplayLoop() {
|
|
|
560
554
|
// 8. CONFIGURAZIONE E GRAFICI UTILS
|
|
561
555
|
// ==========================================================================
|
|
562
556
|
/**
|
|
563
|
-
* Recupera la configurazione
|
|
557
|
+
* Recupera la configurazione e forza la sovrascrittura di ogni parametro.
|
|
564
558
|
*/
|
|
565
559
|
async function fetchServerConfig() {
|
|
566
560
|
try {
|
|
567
561
|
const response = await fetch('/rotevista-config');
|
|
568
|
-
if (!response.ok) throw new Error(`HTTP
|
|
569
|
-
|
|
562
|
+
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
|
|
570
563
|
const data = await response.json();
|
|
571
|
-
|
|
572
|
-
// DEBUG 1: Visualizza i dati esattamente come arrivano dal server
|
|
573
|
-
console.log("📥 [DEBUG] Dati grezzi ricevuti dal server:", data);
|
|
574
|
-
|
|
575
|
-
const parse = (obj) => {
|
|
576
|
-
for (let k in obj) {
|
|
577
|
-
if (typeof obj[k] === 'object' && obj[k] !== null) parse(obj[k]);
|
|
578
|
-
else if (!isNaN(obj[k]) && typeof obj[k] === 'string' && obj[k] !== "")
|
|
579
|
-
obj[k] = parseFloat(obj[k]);
|
|
580
|
-
}
|
|
581
|
-
return obj;
|
|
582
|
-
};
|
|
583
564
|
|
|
584
|
-
|
|
565
|
+
// Stampa di debug per verificare cosa riceve il client
|
|
566
|
+
console.log("🔍 Configurazione ricevuta dal Server:", data);
|
|
585
567
|
|
|
586
|
-
//
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
if (actual.alarms) Object.assign(CONFIG.alarms, actual.alarms);
|
|
591
|
-
if (actual.graphs) Object.assign(CONFIG.graphs, actual.graphs);
|
|
568
|
+
// Merge intelligente dei dati ricevuti nel CONFIG esistente
|
|
569
|
+
Object.assign(CONFIG.alarms, data.alarms || {});
|
|
570
|
+
Object.assign(CONFIG.graphs, data.graphs || {});
|
|
571
|
+
Object.assign(CONFIG.averaging, data.averaging || {});
|
|
592
572
|
|
|
593
|
-
//
|
|
594
|
-
if (
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
"Parametro": ["longWindow", "minSpeed", "stabilityThreshold", "stabilityBreakout"],
|
|
599
|
-
"Valore Attuale": [
|
|
600
|
-
CONFIG.averaging.longWindow,
|
|
601
|
-
CONFIG.averaging.minSpeed,
|
|
602
|
-
CONFIG.averaging.stabilityThreshold,
|
|
603
|
-
CONFIG.averaging.stabilityBreakout
|
|
604
|
-
]
|
|
605
|
-
});
|
|
573
|
+
// Per le scale, siccome sono nidificate, facciamo un loop
|
|
574
|
+
if (data.scales) {
|
|
575
|
+
for (let key in data.scales) {
|
|
576
|
+
if (CONFIG.scales[key]) Object.assign(CONFIG.scales[key], data.scales[key]);
|
|
577
|
+
}
|
|
606
578
|
}
|
|
607
|
-
|
|
608
|
-
if (actual.scales) Object.assign(CONFIG.scales, actual.scales);
|
|
609
579
|
|
|
610
|
-
console.log("✅
|
|
580
|
+
console.log("✅ Configurazione applicata. Alarmi attivi:", CONFIG.alarms);
|
|
611
581
|
} catch (err) {
|
|
612
|
-
console.warn("⚠️
|
|
582
|
+
console.warn("⚠️ Utilizzo default locali. Motivo:", err.message);
|
|
613
583
|
}
|
|
614
584
|
}
|
|
615
585
|
|
package/package.json
CHANGED
package/style.css
CHANGED
|
@@ -134,6 +134,34 @@ body {
|
|
|
134
134
|
.box-tack .value.dual-val { font-size: clamp(0.9rem, 28cqh, 10cqw) !important; }
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
/* ==========================================================================
|
|
138
|
+
AGGIUNTA: Gestione Allarmi Profondità
|
|
139
|
+
========================================================================== */
|
|
140
|
+
|
|
141
|
+
.alarm-warning {
|
|
142
|
+
color: #e67e22 !important; /* Arancione per Warning */
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.alarm-danger {
|
|
146
|
+
color: #c0392b !important; /* Rosso per Danger */
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.blink-alarm {
|
|
150
|
+
animation: blink-depth 0.8s infinite alternate;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
@keyframes blink-depth {
|
|
154
|
+
from { opacity: 1; }
|
|
155
|
+
to { opacity: 0.3; }
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/* Override per la Night Mode: se siamo in modalità notte,
|
|
159
|
+
il rosso deve restare ben visibile o diventare più acceso */
|
|
160
|
+
body.night-mode .alarm-danger {
|
|
161
|
+
color: #ff0000 !important;
|
|
162
|
+
text-shadow: 0 0 10px rgba(255, 0, 0, 0.8) !important;
|
|
163
|
+
}
|
|
164
|
+
|
|
137
165
|
/* ==========================================================================
|
|
138
166
|
5. TACTICAL FOCUS MODE
|
|
139
167
|
========================================================================== */
|