diff --git a/succbone/succd/http.go b/succbone/succd/http.go
index 506236b..0d1ce02 100644
--- a/succbone/succd/http.go
+++ b/succbone/succd/http.go
@@ -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%d", 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
diff --git a/succbone/succd/process.go b/succbone/succd/process.go
index a62c261..f19dc5e 100644
--- a/succbone/succd/process.go
+++ b/succbone/succd/process.go
@@ -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))
}
}
diff --git a/succbone/succd/scientific.go b/succbone/succd/scientific.go
index d2df8d8..a15f273 100644
--- a/succbone/succd/scientific.go
+++ b/succbone/succd/scientific.go
@@ -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%d", 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
}