succd: log pressures in error messages
This commit is contained in:
parent
451b44e31b
commit
590e93e43e
|
@ -36,24 +36,6 @@ func formatVolts(v float32) string {
|
|||
return fmt.Sprintf("%.4f V", v)
|
||||
}
|
||||
|
||||
// formatMbar formats a millibar value using scientific notation and returns a
|
||||
// HTML fragment (for superscript support).
|
||||
func formatMbar(v float32) template.HTML {
|
||||
exp := 0
|
||||
for v < 1 {
|
||||
v *= 10
|
||||
exp -= 1
|
||||
}
|
||||
for v >= 10 {
|
||||
v /= 10
|
||||
exp += 1
|
||||
}
|
||||
res := fmt.Sprintf("%.3f", v)
|
||||
res += fmt.Sprintf(" x 10<sup>%d</sup>", exp)
|
||||
res += " mbar"
|
||||
return template.HTML(res)
|
||||
}
|
||||
|
||||
// apiData is the data model served to the user via HTTP/WebSockets
|
||||
type apiData struct {
|
||||
// Safety interlocks.
|
||||
|
@ -125,7 +107,7 @@ func (s *webServer) apiData(skipSystem bool) *apiData {
|
|||
ad.Safety.Failsafe = state.safety.failsafe
|
||||
ad.Safety.HighPressure = state.safety.highPressure
|
||||
ad.Pirani.Volts = formatVolts(volts)
|
||||
ad.Pirani.Mbar = formatMbar(mbar)
|
||||
ad.Pirani.Mbar = formatMbarHTML(mbar)
|
||||
ad.Pirani.MbarFloat = mbar
|
||||
ad.Pumps.RPOn = state.rpOn
|
||||
ad.Pumps.DPOn = state.dpOn
|
||||
|
|
|
@ -78,11 +78,11 @@ func (d *daemon) processOnce(_ context.Context) error {
|
|||
d.safety.failsafe = true
|
||||
klog.Errorf("Pirani probe seems disconnected; enabling failsafe mode")
|
||||
}
|
||||
} else {
|
||||
} else if d.piraniDetection() == piraniDetectionConnected {
|
||||
if d.safety.failsafe {
|
||||
if mbar >= 1e2 {
|
||||
d.safety.failsafe = false
|
||||
klog.Infof("Values are plausible again; quitting failsafe mode")
|
||||
klog.Infof("Pirani probe value (%s) is plausible again; quitting failsafe mode", formatMbar(mbar))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -90,12 +90,12 @@ func (d *daemon) processOnce(_ context.Context) error {
|
|||
if mbar >= 1e-1 {
|
||||
if !d.safety.highPressure {
|
||||
d.safety.highPressure = true
|
||||
klog.Errorf("Pressure is too high; enabling diffusion pump lockout")
|
||||
klog.Errorf("Pressure is too high (%s mbar); enabling diffusion pump lockout", formatMbar(mbar))
|
||||
}
|
||||
} else if mbar < (1e-1)-(1e-2) {
|
||||
if d.safety.highPressure {
|
||||
d.safety.highPressure = false
|
||||
klog.Infof("Pressure is low enough for diffusion pump operation; quitting diffusion pump lockout")
|
||||
klog.Infof("Pressure is low enough (%s mbar) for diffusion pump operation; quitting diffusion pump lockout", formatMbar(mbar))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"html/template"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
|
@ -16,8 +17,25 @@ func (s *ScientificNotationValue) UnmarshalText(text []byte) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *ScientificNotationValue) MarshalText() ([]byte, error) {
|
||||
v := float64(*s)
|
||||
// formatMbarHTML formats a millibar value using scientific notation and returns
|
||||
// a HTML fragment (for superscript support).
|
||||
func formatMbarHTML(v float32) template.HTML {
|
||||
exp := 0
|
||||
for v < 1 {
|
||||
v *= 10
|
||||
exp -= 1
|
||||
}
|
||||
for v >= 10 {
|
||||
v /= 10
|
||||
exp += 1
|
||||
}
|
||||
res := fmt.Sprintf("%.3f", v)
|
||||
res += fmt.Sprintf(" x 10<sup>%d</sup>", exp)
|
||||
res += " mbar"
|
||||
return template.HTML(res)
|
||||
}
|
||||
|
||||
func formatMbar(v float32) string {
|
||||
exp := 0
|
||||
for v < 1 {
|
||||
v *= 10
|
||||
|
@ -29,5 +47,11 @@ func (s *ScientificNotationValue) MarshalText() ([]byte, error) {
|
|||
}
|
||||
res := fmt.Sprintf("%.3f", v)
|
||||
res += fmt.Sprintf("e%d", exp)
|
||||
return res
|
||||
}
|
||||
|
||||
func (s *ScientificNotationValue) MarshalText() ([]byte, error) {
|
||||
v := float32(*s)
|
||||
res := formatMbar(v)
|
||||
return []byte(res), nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue