From 967ed27086713d5dddc079340b1b1ff93f57ee8c Mon Sep 17 00:00:00 2001 From: Sydney Smit Date: Wed, 7 Sep 2022 15:05:10 +0200 Subject: [PATCH 1/4] Added an uptime to sensors --- belaUI.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/belaUI.js b/belaUI.js index e72b0c4..07e9550 100644 --- a/belaUI.js +++ b/belaUI.js @@ -1280,8 +1280,13 @@ function updateSensorsJetson() { sensors['SoC temperature'] = socTemp; } catch (err) {}; + try { + isStreaming ? sensors['Uptime'] = `${new Date(Date.now() - streamStartTime).toISOString().substring(11, 16)}` : null; + } catch (error) {}; + broadcastMsg('sensors', sensors, getms() - ACTIVE_TO); } + if (setup['hw'] == 'jetson') { updateSensorsJetson(); setInterval(updateSensorsJetson, 1000); @@ -1461,6 +1466,7 @@ async function updateConfig(conn, params, callback) { /* Streaming status */ let isStreaming = false; +let streamStartTime = null; function updateStatus(status) { isStreaming = status; broadcastMsg('status', {is_streaming: isStreaming}); @@ -1574,11 +1580,13 @@ function start(conn, params) { }); updateStatus(true); + streamStartTime = Date.now(); }); } function stop() { updateStatus(false); + streamStartTime = null; // Remove the exit handlers which would restart the processes for (const p of streamingProcesses) { From 5f151c8152f45e2a3610365fac596010678a8eea Mon Sep 17 00:00:00 2001 From: Sydney Smit Date: Wed, 7 Sep 2022 15:11:51 +0200 Subject: [PATCH 2/4] Cleanup --- belaUI.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/belaUI.js b/belaUI.js index 07e9550..2f8da14 100644 --- a/belaUI.js +++ b/belaUI.js @@ -1281,7 +1281,7 @@ function updateSensorsJetson() { } catch (err) {}; try { - isStreaming ? sensors['Uptime'] = `${new Date(Date.now() - streamStartTime).toISOString().substring(11, 16)}` : null; + if (isStreaming) sensors['Uptime'] = `${new Date(Date.now() - streamStartTime).toISOString().substring(11, 16)}`; } catch (error) {}; broadcastMsg('sensors', sensors, getms() - ACTIVE_TO); @@ -1586,7 +1586,6 @@ function start(conn, params) { function stop() { updateStatus(false); - streamStartTime = null; // Remove the exit handlers which would restart the processes for (const p of streamingProcesses) { From 86c558bd7219d5c5fe81091f8f991b272297a897 Mon Sep 17 00:00:00 2001 From: Sydney Smit Date: Wed, 7 Sep 2022 15:36:31 +0200 Subject: [PATCH 3/4] changed uptime to system uptime --- belaUI.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/belaUI.js b/belaUI.js index 2f8da14..c783815 100644 --- a/belaUI.js +++ b/belaUI.js @@ -1258,6 +1258,7 @@ function notificationSendPersistent(conn) { /* Hardware monitoring */ let sensors = {}; +let systemStartTime = Date.now(); function updateSensorsJetson() { try { let socVoltage = fs.readFileSync('/sys/bus/i2c/drivers/ina3221x/6-0040/iio:device0/in_voltage0_input', 'utf8'); @@ -1281,7 +1282,7 @@ function updateSensorsJetson() { } catch (err) {}; try { - if (isStreaming) sensors['Uptime'] = `${new Date(Date.now() - streamStartTime).toISOString().substring(11, 16)}`; + sensors['System uptime'] = `${new Date(Date.now() - systemStartTime).toISOString().substring(11, 16)}`; } catch (error) {}; broadcastMsg('sensors', sensors, getms() - ACTIVE_TO); @@ -1466,7 +1467,6 @@ async function updateConfig(conn, params, callback) { /* Streaming status */ let isStreaming = false; -let streamStartTime = null; function updateStatus(status) { isStreaming = status; broadcastMsg('status', {is_streaming: isStreaming}); @@ -1580,7 +1580,6 @@ function start(conn, params) { }); updateStatus(true); - streamStartTime = Date.now(); }); } From 4f7666b4b9f1220d53c49fda13f9d3d69ecdda1f Mon Sep 17 00:00:00 2001 From: Sydney Smit Date: Wed, 7 Sep 2022 15:38:04 +0200 Subject: [PATCH 4/4] Added seconds to system uptime --- belaUI.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/belaUI.js b/belaUI.js index c783815..8077674 100644 --- a/belaUI.js +++ b/belaUI.js @@ -1258,7 +1258,7 @@ function notificationSendPersistent(conn) { /* Hardware monitoring */ let sensors = {}; -let systemStartTime = Date.now(); +const systemStartTime = Date.now(); function updateSensorsJetson() { try { let socVoltage = fs.readFileSync('/sys/bus/i2c/drivers/ina3221x/6-0040/iio:device0/in_voltage0_input', 'utf8'); @@ -1282,7 +1282,7 @@ function updateSensorsJetson() { } catch (err) {}; try { - sensors['System uptime'] = `${new Date(Date.now() - systemStartTime).toISOString().substring(11, 16)}`; + sensors['System uptime'] = `${new Date(Date.now() - systemStartTime).toISOString().substring(11, 19)}`; } catch (error) {}; broadcastMsg('sensors', sensors, getms() - ACTIVE_TO);