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,12 +75,14 @@ func (d *daemon) httpIndex(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
templateIndex.Execute(w, map[string]any{
|
templateIndex.Execute(w, map[string]any{
|
||||||
"volts": formatVolts(volts),
|
"failsafe": failsafe,
|
||||||
"mbar": formatMbar(mbar),
|
"highpressure": highpressure,
|
||||||
"rp": rp,
|
"volts": formatVolts(volts),
|
||||||
"dp": dp,
|
"mbar": formatMbar(mbar),
|
||||||
"hostname": hostname,
|
"rp": rp,
|
||||||
"load": load,
|
"dp": dp,
|
||||||
|
"hostname": hostname,
|
||||||
|
"load": load,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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";
|
||||||
|
|
|
@ -123,7 +123,7 @@ func (d *daemon) processOnce(_ context.Context) error {
|
||||||
d.aboveRough.process(float64(mbar))
|
d.aboveRough.process(float64(mbar))
|
||||||
d.aboveHigh.process(float64(mbar))
|
d.aboveHigh.process(float64(mbar))
|
||||||
|
|
||||||
if d.piraniWireBreakDetection() {
|
if d.piraniWireBreakDetection() {
|
||||||
// Unrealistic result, Pirani probe probably disconnected. Failsafe mode.
|
// Unrealistic result, Pirani probe probably disconnected. Failsafe mode.
|
||||||
if !d.failsafe {
|
if !d.failsafe {
|
||||||
d.failsafe = true
|
d.failsafe = true
|
||||||
|
@ -131,10 +131,10 @@ func (d *daemon) processOnce(_ context.Context) error {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if d.failsafe {
|
if d.failsafe {
|
||||||
if mbar >= 1e2 {
|
if mbar >= 1e2 {
|
||||||
d.failsafe = false
|
d.failsafe = false
|
||||||
klog.Infof("Values are plausible again; quitting failsafe mode")
|
klog.Infof("Values are plausible again; quitting failsafe mode")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,14 +146,14 @@ func (d *daemon) processOnce(_ context.Context) error {
|
||||||
} else {
|
} else {
|
||||||
if d.highPressure {
|
if d.highPressure {
|
||||||
d.highPressure = false
|
d.highPressure = false
|
||||||
klog.Infof("Pressure is low enough for diffusion pump operation; quitting diffusion pump lockout")
|
klog.Infof("Pressure is low enough for diffusion pump operation; quitting diffusion pump lockout")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.failsafe {
|
if d.failsafe {
|
||||||
d.aboveRough.output = true
|
d.aboveRough.output = true
|
||||||
d.aboveHigh.output = true
|
d.aboveHigh.output = true
|
||||||
d.dpOn = false
|
d.dpOn = false
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.highPressure {
|
if d.highPressure {
|
||||||
|
@ -192,19 +192,19 @@ func (d *daemon) processOnce(_ context.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *daemon) piraniWireBreakDetection() bool {
|
func (d *daemon) piraniWireBreakDetection() bool {
|
||||||
if len(d.adcPiraniVolts) < 3 {
|
if len(d.adcPiraniVolts) < 3 {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
volts := float32(0.0)
|
volts := float32(0.0)
|
||||||
for _, v := range d.adcPiraniVolts[len(d.adcPiraniVolts)-3:] {
|
for _, v := range d.adcPiraniVolts[len(d.adcPiraniVolts)-3:] {
|
||||||
volts += v
|
volts += v
|
||||||
}
|
}
|
||||||
volts /= 3.0
|
volts /= 3.0
|
||||||
|
|
||||||
bar := math.Pow(10.0, float64(volts)-8.5)
|
bar := math.Pow(10.0, float64(volts)-8.5)
|
||||||
mbar := float32(bar * 1000.0)
|
mbar := float32(bar * 1000.0)
|
||||||
|
|
||||||
return mbar < 4e-6
|
return mbar < 4e-6
|
||||||
}
|
}
|
||||||
|
|
||||||
// pirani returns the Pirani gauge voltage and pressure.
|
// pirani returns the Pirani gauge voltage and pressure.
|
||||||
|
@ -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