succd: add safety status to web frontend

This commit is contained in:
zdmx 2024-09-27 23:49:24 +02:00
parent eb7707f1a0
commit 908727608a
3 changed files with 65 additions and 24 deletions

View file

@ -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()