succd: add safety status to web frontend
This commit is contained in:
parent
eb7707f1a0
commit
908727608a
|
@ -60,6 +60,7 @@ func (d *daemon) httpIndex(w http.ResponseWriter, r *http.Request) {
|
||||||
volts, mbar := d.pirani()
|
volts, mbar := d.pirani()
|
||||||
rp := d.rpGet()
|
rp := d.rpGet()
|
||||||
dp := d.dpGet()
|
dp := d.dpGet()
|
||||||
|
failsafe, highpressure := d.safetyStatusGet()
|
||||||
|
|
||||||
loadB, err := os.ReadFile("/proc/loadavg")
|
loadB, err := os.ReadFile("/proc/loadavg")
|
||||||
load := "unknown"
|
load := "unknown"
|
||||||
|
@ -74,6 +75,8 @@ func (d *daemon) httpIndex(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
templateIndex.Execute(w, map[string]any{
|
templateIndex.Execute(w, map[string]any{
|
||||||
|
"failsafe": failsafe,
|
||||||
|
"highpressure": highpressure,
|
||||||
"volts": formatVolts(volts),
|
"volts": formatVolts(volts),
|
||||||
"mbar": formatMbar(mbar),
|
"mbar": formatMbar(mbar),
|
||||||
"rp": rp,
|
"rp": rp,
|
||||||
|
@ -107,7 +110,10 @@ func (d *daemon) httpStream(w http.ResponseWriter, r *http.Request) {
|
||||||
rp := d.rpGet()
|
rp := d.rpGet()
|
||||||
dp := d.dpGet()
|
dp := d.dpGet()
|
||||||
rough, high := d.vacuumStatusGet()
|
rough, high := d.vacuumStatusGet()
|
||||||
|
failsafe, highpressure := d.safetyStatusGet()
|
||||||
v := struct {
|
v := struct {
|
||||||
|
Failsafe bool
|
||||||
|
HighPressure bool
|
||||||
Volts string
|
Volts string
|
||||||
Mbar string
|
Mbar string
|
||||||
MbarFloat float32
|
MbarFloat float32
|
||||||
|
@ -116,6 +122,8 @@ func (d *daemon) httpStream(w http.ResponseWriter, r *http.Request) {
|
||||||
RoughReached bool
|
RoughReached bool
|
||||||
HighReached bool
|
HighReached bool
|
||||||
}{
|
}{
|
||||||
|
Failsafe: failsafe,
|
||||||
|
HighPressure: highpressure,
|
||||||
Volts: formatVolts(volts),
|
Volts: formatVolts(volts),
|
||||||
Mbar: string(formatMbar(mbar)),
|
Mbar: string(formatMbar(mbar)),
|
||||||
MbarFloat: mbar,
|
MbarFloat: mbar,
|
||||||
|
|
|
@ -94,6 +94,14 @@ td > span {
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
<td id="status" colspan="4">OK</td>
|
<td id="status" colspan="4">OK</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Failsafe</th>
|
||||||
|
<td id="failsafe" colspan="4">OK</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Diffusion Pump Lockout</th>
|
||||||
|
<td id="highpressure" colspan="4">OK</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</p>
|
</p>
|
||||||
<p style="margin-top: 2em;">
|
<p style="margin-top: 2em;">
|
||||||
|
@ -240,6 +248,8 @@ window.addEventListener("load", (_) => {
|
||||||
console.log("s u c c");
|
console.log("s u c c");
|
||||||
|
|
||||||
let status = document.querySelector("#status");
|
let status = document.querySelector("#status");
|
||||||
|
let failsafe = document.querySelector("#failsafe");
|
||||||
|
let highpressure = document.querySelector("#highpressure");
|
||||||
let volts = document.querySelector("#volts");
|
let volts = document.querySelector("#volts");
|
||||||
let mbar = document.querySelector("#mbar");
|
let mbar = document.querySelector("#mbar");
|
||||||
let ping = document.querySelector("#ping");
|
let ping = document.querySelector("#ping");
|
||||||
|
@ -280,6 +290,21 @@ window.addEventListener("load", (_) => {
|
||||||
const data = JSON.parse(event.data);
|
const data = JSON.parse(event.data);
|
||||||
volts.innerHTML = data.Volts;
|
volts.innerHTML = data.Volts;
|
||||||
mbar.innerHTML = data.Mbar;
|
mbar.innerHTML = data.Mbar;
|
||||||
|
failsafe.innerHTML = data.failsafe ? "ON" : "OFF";
|
||||||
|
if data.failsafe {
|
||||||
|
failsafe.innerHTML = "ON"";
|
||||||
|
failsafe.style = "background-color: #f06060";
|
||||||
|
} else {
|
||||||
|
failsafe.innerHTML = "OFF";
|
||||||
|
failsafe.style = "background-color: #60f060";
|
||||||
|
}
|
||||||
|
if data.highpressure {
|
||||||
|
highpressure.innerHTML = "ON";
|
||||||
|
highpressure.style = "background-color: #f06060";
|
||||||
|
} else {
|
||||||
|
highpressure.innerHTML = "OFF";
|
||||||
|
highpressure.style = "background-color: #60f060";
|
||||||
|
}
|
||||||
rp.innerHTML = data.RPOn ? "ON" : "OFF";
|
rp.innerHTML = data.RPOn ? "ON" : "OFF";
|
||||||
if (data.RPOn) {
|
if (data.RPOn) {
|
||||||
rp.style = "background-color: #60f060";
|
rp.style = "background-color: #60f060";
|
||||||
|
|
|
@ -266,6 +266,14 @@ func (d *daemon) vacuumStatusGet() (rough, high bool) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *daemon) safetyStatusGet() (failsafe, highPressure bool) {
|
||||||
|
d.mu.RLock()
|
||||||
|
defer d.mu.RUnlock()
|
||||||
|
failsafe = d.failsafe
|
||||||
|
highPressure = d.highPressure
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// pumpDownPressed toggles the pump down relay for 500ms.
|
// pumpDownPressed toggles the pump down relay for 500ms.
|
||||||
func (d *daemon) pumpDownPress() {
|
func (d *daemon) pumpDownPress() {
|
||||||
d.mu.Lock()
|
d.mu.Lock()
|
||||||
|
|
Loading…
Reference in a new issue