From 649bb01645c43745d1259875d1e45970b0125a37 Mon Sep 17 00:00:00 2001 From: Maxim Date: Thu, 7 May 2026 15:21:22 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=B8=D0=BD=D0=B4=D0=B8=D0=BA=D0=B0=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B0=20=D1=83=D1=80=D0=BE=D0=B2=D0=BD=D1=8F=20=D1=81?= =?UTF-8?q?=D0=B8=D0=B3=D0=BD=D0=B0=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/server/main.go | 4 ++-- cmd/server/web/css/style.css | 7 +++--- cmd/server/web/dashboard.html | 1 - cmd/server/web/js/app.js | 41 ++++++++++++++++------------------- 4 files changed, 24 insertions(+), 29 deletions(-) diff --git a/cmd/server/main.go b/cmd/server/main.go index 591a96e..934ff62 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -33,9 +33,9 @@ func (a *API) HandleHealth(w http.ResponseWriter, r *http.Request) { latest, ok := a.buf.GetLatest() idle := time.Since(a.buf.LastWriteTime()) - status := "ok" + status := "На связи" if idle > 15*time.Second { - status = "degraded" + status = "Нет связи" } writeJSON(w, map[string]any{ diff --git a/cmd/server/web/css/style.css b/cmd/server/web/css/style.css index bcbc77c..38a9a58 100644 --- a/cmd/server/web/css/style.css +++ b/cmd/server/web/css/style.css @@ -246,10 +246,9 @@ h1 { transition: background-color 0.3s, border-color 0.3s; } -.sig-bar-1 { height: 25%; } -.sig-bar-2 { height: 50%; } -.sig-bar-3 { height: 75%; } -.sig-bar-4 { height: 100%; } +.sig-bar-1 { height: 33%; } +.sig-bar-2 { height: 66%; } +.sig-bar-3 { height: 100%; } /* Активные — зелёная заливка */ .sig-bar.active-1, diff --git a/cmd/server/web/dashboard.html b/cmd/server/web/dashboard.html index e1affb7..f0a566e 100644 --- a/cmd/server/web/dashboard.html +++ b/cmd/server/web/dashboard.html @@ -34,7 +34,6 @@
-
diff --git a/cmd/server/web/js/app.js b/cmd/server/web/js/app.js index 41fa28b..850e566 100644 --- a/cmd/server/web/js/app.js +++ b/cmd/server/web/js/app.js @@ -16,27 +16,22 @@ function setBar(id, value) { document.getElementById(id).style.width = value + "%"; } -// ===== SIGNAL ICON ===== -function setSignal(percent) { +// ===== SIGNAL ICON (0-3 уровня) ===== +function setSignal(level) { const bars = document.querySelectorAll(".sig-bar"); bars.forEach(b => { b.classList.remove("active-1", "active-2", "active-3", "active-4"); b.classList.add("dim"); }); - if (percent > 75) { + if (level >= 3) { bars[0].classList.add("active-1"); bars[0].classList.remove("dim"); bars[1].classList.add("active-2"); bars[1].classList.remove("dim"); bars[2].classList.add("active-3"); bars[2].classList.remove("dim"); - bars[3].classList.add("active-4"); bars[3].classList.remove("dim"); - } else if (percent > 50) { + } else if (level >= 2) { bars[0].classList.add("active-1"); bars[0].classList.remove("dim"); bars[1].classList.add("active-2"); bars[1].classList.remove("dim"); - bars[2].classList.add("active-3"); bars[2].classList.remove("dim"); - } else if (percent > 25) { - bars[0].classList.add("active-1"); bars[0].classList.remove("dim"); - bars[1].classList.add("active-2"); bars[1].classList.remove("dim"); - } else if (percent > 0) { + } else if (level >= 1) { bars[0].classList.add("active-1"); bars[0].classList.remove("dim"); } } @@ -78,7 +73,7 @@ async function update() { const uptime = Math.round(h.uptime_sec || 0); document.getElementById("meta").textContent = - "аптайм: " + uptime + "s | буфер: " + filled; + "работа: " + uptime + "s | буфер: " + filled; // ===== HISTORY ===== const arr = Array.isArray(hist.bytes) ? hist.bytes : []; @@ -90,21 +85,23 @@ async function update() { " = значение: " + (Number(b) & 0xFF) ).join("
"); - // ===== FILTER (последние 9 значений) ===== - const last = arr.slice(-9).map(v => Number(v) & 0xFF); + // ===== ПОСЛЕДНЕЕ ЗНАЧЕНИЕ (без фильтра) ===== + const raw = arr.length > 0 ? (arr[arr.length - 1] & 0xFF) : 0; - const filtered = median(last); + // ===== ПАРСИНГ БИТ ===== + const barValue = raw & 0x3F; // биты 0-5 (0-63) + const signalLevel = (raw >> 6) & 0x3; // биты 6-7 (0-3) - // ===== NORMALIZE ===== - const percent = (filtered / 255) * 100; - - // ===== SMOOTH ===== + // ===== PROGRESS BAR (0-63 -> 0-100%) ===== + const percent = (barValue / 63) * 100; const smooth = smoothBar(percent); - - // ===== ONLY CHANNEL 1 ===== setBar("bar1", smooth); - document.getElementById("last-byte").textContent = filtered; - setSignal(smooth); + + // ===== SIGNAL ICON ===== + setSignal(signalLevel, raw); + + // ===== LAST BYTE ===== + document.getElementById("last-byte").textContent = barValue; } catch (e) { console.error("UPDATE ERROR:", e);