diff --git a/succbone/succd/http.go b/succbone/succd/http.go index 0be9c76..43bee92 100644 --- a/succbone/succd/http.go +++ b/succbone/succd/http.go @@ -60,6 +60,7 @@ func (d *daemon) httpIndex(w http.ResponseWriter, r *http.Request) { volts, mbar := d.pirani() rp := d.rpGet() dp := d.dpGet() + failsafe, highpressure := d.safetyStatusGet() loadB, err := os.ReadFile("/proc/loadavg") load := "unknown" @@ -74,12 +75,14 @@ func (d *daemon) httpIndex(w http.ResponseWriter, r *http.Request) { } templateIndex.Execute(w, map[string]any{ - "volts": formatVolts(volts), - "mbar": formatMbar(mbar), - "rp": rp, - "dp": dp, - "hostname": hostname, - "load": load, + "failsafe": failsafe, + "highpressure": highpressure, + "volts": formatVolts(volts), + "mbar": formatMbar(mbar), + "rp": rp, + "dp": dp, + "hostname": hostname, + "load": load, }) } @@ -107,7 +110,10 @@ func (d *daemon) httpStream(w http.ResponseWriter, r *http.Request) { rp := d.rpGet() dp := d.dpGet() rough, high := d.vacuumStatusGet() + failsafe, highpressure := d.safetyStatusGet() v := struct { + Failsafe bool + HighPressure bool Volts string Mbar string MbarFloat float32 @@ -116,6 +122,8 @@ func (d *daemon) httpStream(w http.ResponseWriter, r *http.Request) { RoughReached bool HighReached bool }{ + Failsafe: failsafe, + HighPressure: highpressure, Volts: formatVolts(volts), Mbar: string(formatMbar(mbar)), MbarFloat: mbar, diff --git a/succbone/succd/index.html b/succbone/succd/index.html index fe87fba..7ed97c4 100644 --- a/succbone/succd/index.html +++ b/succbone/succd/index.html @@ -94,6 +94,14 @@ td > span {
@@ -240,6 +248,8 @@ window.addEventListener("load", (_) => { console.log("s u c c"); let status = document.querySelector("#status"); + let failsafe = document.querySelector("#failsafe"); + let highpressure = document.querySelector("#highpressure"); let volts = document.querySelector("#volts"); let mbar = document.querySelector("#mbar"); let ping = document.querySelector("#ping"); @@ -280,6 +290,21 @@ window.addEventListener("load", (_) => { const data = JSON.parse(event.data); volts.innerHTML = data.Volts; 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"; if (data.RPOn) { rp.style = "background-color: #60f060"; diff --git a/succbone/succd/process.go b/succbone/succd/process.go index 21a4f5e..5fb8a7f 100644 --- a/succbone/succd/process.go +++ b/succbone/succd/process.go @@ -123,7 +123,7 @@ func (d *daemon) processOnce(_ context.Context) error { d.aboveRough.process(float64(mbar)) d.aboveHigh.process(float64(mbar)) - if d.piraniWireBreakDetection() { + if d.piraniWireBreakDetection() { // Unrealistic result, Pirani probe probably disconnected. Failsafe mode. if !d.failsafe { d.failsafe = true @@ -131,10 +131,10 @@ func (d *daemon) processOnce(_ context.Context) error { } } else { if d.failsafe { - if mbar >= 1e2 { - d.failsafe = false - klog.Infof("Values are plausible again; quitting failsafe mode") - } + if mbar >= 1e2 { + d.failsafe = false + klog.Infof("Values are plausible again; quitting failsafe mode") + } } } @@ -146,14 +146,14 @@ func (d *daemon) processOnce(_ context.Context) error { } else { if d.highPressure { 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 { d.aboveRough.output = true d.aboveHigh.output = true - d.dpOn = false + d.dpOn = false } if d.highPressure { @@ -192,19 +192,19 @@ func (d *daemon) processOnce(_ context.Context) error { } func (d *daemon) piraniWireBreakDetection() bool { - if len(d.adcPiraniVolts) < 3 { - return true - } - volts := float32(0.0) - for _, v := range d.adcPiraniVolts[len(d.adcPiraniVolts)-3:] { - volts += v - } - volts /= 3.0 + if len(d.adcPiraniVolts) < 3 { + return true + } + volts := float32(0.0) + for _, v := range d.adcPiraniVolts[len(d.adcPiraniVolts)-3:] { + volts += v + } + volts /= 3.0 - bar := math.Pow(10.0, float64(volts)-8.5) - mbar := float32(bar * 1000.0) + bar := math.Pow(10.0, float64(volts)-8.5) + mbar := float32(bar * 1000.0) - return mbar < 4e-6 + return mbar < 4e-6 } // pirani returns the Pirani gauge voltage and pressure. @@ -266,6 +266,14 @@ func (d *daemon) vacuumStatusGet() (rough, high bool) { 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. func (d *daemon) pumpDownPress() { d.mu.Lock()