From 313569e1dcff4fd16ab112c3d3e257cc704515de Mon Sep 17 00:00:00 2001 From: Rahix Date: Fri, 4 Oct 2024 23:08:29 +0200 Subject: [PATCH 1/5] succd: Use grid layout to show all info on a single screen Use CSS grids to all information on a single screen if possible. There is a breakpoint for smaller screens. --- succbone/succd/index.html | 49 ++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/succbone/succd/index.html b/succbone/succd/index.html index a26db5d..a8eaf00 100644 --- a/succbone/succd/index.html +++ b/succbone/succd/index.html @@ -5,12 +5,11 @@ @@ -59,19 +68,7 @@ td > span {

succd

nothing more permanent than a temporary solution

-

- - - - - - - - - - -
Pirani GaugeVoltage{{ .Pirani.Volts }}
Pressure{{ .Pirani.Mbar }}
- +

@@ -96,6 +93,19 @@ td > span {
Thresholds
+ + + + + + + + + + +
Pirani GaugeVoltage{{ .Pirani.Volts }}
Pressure{{ .Pirani.Mbar }}
+ + @@ -125,10 +135,11 @@ td > span {
Control...
-

-

- -

+ +

+ +

+

{{ .System.Hostname }} | load: {{ .System.Load }} | pprof | metrics | ws ping: -- 2.45.2 From ed8adad6113c0fc000680a13eb33105d60e60955 Mon Sep 17 00:00:00 2001 From: Rahix Date: Fri, 4 Oct 2024 23:17:17 +0200 Subject: [PATCH 2/5] succd: Fix table jiggle Make sure the table size doesn't dynamically jiggle with movement of width changes of the load-average value. --- succbone/succd/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/succbone/succd/index.html b/succbone/succd/index.html index a8eaf00..6be0c1d 100644 --- a/succbone/succd/index.html +++ b/succbone/succd/index.html @@ -132,7 +132,7 @@ td > span { Status OK Load - ... + ... -- 2.45.2 From 86457187486dd9f2b94cbf1678e8073c6d056309 Mon Sep 17 00:00:00 2001 From: Rahix Date: Fri, 4 Oct 2024 22:33:22 +0200 Subject: [PATCH 3/5] succd: Add hysteresis feature to thresholdOutput blocks Add a hysteresis value that can be optionally configured for thresholdOutput blocks. This will hopefully help to prevent jumping outputs from feedback that is caused by the thresholdOutput itself. --- succbone/succd/process_blocks.go | 9 ++++++++- succbone/succd/process_blocks_test.go | 25 +++++++++++++++++++++---- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/succbone/succd/process_blocks.go b/succbone/succd/process_blocks.go index 0b37193..ae1294d 100644 --- a/succbone/succd/process_blocks.go +++ b/succbone/succd/process_blocks.go @@ -30,13 +30,20 @@ type thresholdOutput struct { debounce time.Time // threshold is the setpoint of the block. threshold float64 + // hysteresis around the process setpoint (min/max is threshold +- hysteresis) + hysteresis float64 } func (t *thresholdOutput) process(value float64) { if time.Now().Before(t.debounce) { return } - new := value > t.threshold + new := t.output + if t.output { + new = value > (t.threshold - t.hysteresis) + } else { + new = value > (t.threshold + t.hysteresis) + } if new != t.output { t.output = new t.debounce = time.Now().Add(time.Second * 5) diff --git a/succbone/succd/process_blocks_test.go b/succbone/succd/process_blocks_test.go index 4dd028c..24b75f6 100644 --- a/succbone/succd/process_blocks_test.go +++ b/succbone/succd/process_blocks_test.go @@ -26,20 +26,37 @@ func TestMomentaryOutput(t *testing.T) { func TestThresholdOutput(t *testing.T) { to := thresholdOutput{ - threshold: 1, + threshold: 1, + hysteresis: 0.2, } - to.process(0) + to.process(0.7) if to.output { t.Fatalf("output shouldn't have triggered") } - to.process(2) + to.process(1) + if to.output { + t.Fatalf("output shouldn't have triggered") + } + to.process(1.3) if !to.output { t.Fatalf("output should have triggered") } - to.process(0) + to.process(1) + if !to.output { + t.Fatalf("output should have triggered") + } + to.process(0.7) if !to.output { t.Fatalf("output should have triggered (in debounce)") } + + // let debounce timeout pass + time.Sleep(time.Second * 6) + + to.process(0.7) + if to.output { + t.Fatalf("output shouldn't have triggered") + } } func TestRingbufferInput(t *testing.T) { -- 2.45.2 From ef959f4be3226dadbb59275157c6e2ecec4489a2 Mon Sep 17 00:00:00 2001 From: Rahix Date: Fri, 4 Oct 2024 23:13:43 +0200 Subject: [PATCH 4/5] succd: Configure hysteresis for rough and high thresholds Add CLI flags for rough and high hysteresis and configure default values based on experiments. --- succbone/succd/main.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/succbone/succd/main.go b/succbone/succd/main.go index 23427b6..a8ae0f8 100644 --- a/succbone/succd/main.go +++ b/succbone/succd/main.go @@ -11,17 +11,21 @@ import ( ) var ( - flagFake bool - flagListenHTTP string - flagPressureThresholdRough = ScientificNotationValue(1e-1) - flagPressureThresholdHigh = ScientificNotationValue(1e-4) + flagFake bool + flagListenHTTP string + flagPressureThresholdRough = ScientificNotationValue(1e-1) + flagPressureThresholdRoughHysteresis = ScientificNotationValue(5e-2) + flagPressureThresholdHigh = ScientificNotationValue(1e-4) + flagPressureThresholdHighHysteresis = ScientificNotationValue(5e-5) ) func main() { flag.BoolVar(&flagFake, "fake", false, "Enable fake mode which allows to run succd for tests outside the succbone") flag.StringVar(&flagListenHTTP, "listen_http", ":8080", "Address at which to listen for HTTP requests") flag.TextVar(&flagPressureThresholdRough, "pressure_threshold_rough", &flagPressureThresholdRough, "Threshold for opening up diffusion pump (mbar)") + flag.TextVar(&flagPressureThresholdRoughHysteresis, "pressure_threshold_rough_hysteresis", &flagPressureThresholdRoughHysteresis, "+-Hysteresis for rough threshold (mbar)") flag.TextVar(&flagPressureThresholdHigh, "pressure_threshold_high", &flagPressureThresholdHigh, "Threshold for enabling high voltage circuits (mbar)") + flag.TextVar(&flagPressureThresholdHighHysteresis, "pressure_threshold_high_hysteresis", &flagPressureThresholdHighHysteresis, "+-Hysteresis for high threshold (mbar)") flag.Parse() ctx, _ := signal.NotifyContext(context.Background(), os.Interrupt) @@ -32,7 +36,9 @@ func main() { d.daemonState.piraniVolts100.limit = 100 d.aboveRough.threshold = float64(flagPressureThresholdRough) + d.aboveRough.hysteresis = float64(flagPressureThresholdRoughHysteresis) d.aboveHigh.threshold = float64(flagPressureThresholdHigh) + d.aboveHigh.hysteresis = float64(flagPressureThresholdHighHysteresis) if flagFake { klog.Infof("Starting with fake peripherals") d.adcPirani = &fakeADC{} -- 2.45.2 From e2fc15ed9ba6cf512cbbd23663682fbb3bf1bb5a Mon Sep 17 00:00:00 2001 From: Rahix Date: Fri, 4 Oct 2024 23:24:21 +0200 Subject: [PATCH 5/5] succd: Use tigher hysteresis values It seems we can get away with less hysteresis still. Make the values a bit smaller. --- succbone/succd/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/succbone/succd/main.go b/succbone/succd/main.go index a8ae0f8..4a39d11 100644 --- a/succbone/succd/main.go +++ b/succbone/succd/main.go @@ -14,9 +14,9 @@ var ( flagFake bool flagListenHTTP string flagPressureThresholdRough = ScientificNotationValue(1e-1) - flagPressureThresholdRoughHysteresis = ScientificNotationValue(5e-2) + flagPressureThresholdRoughHysteresis = ScientificNotationValue(2e-2) flagPressureThresholdHigh = ScientificNotationValue(1e-4) - flagPressureThresholdHighHysteresis = ScientificNotationValue(5e-5) + flagPressureThresholdHighHysteresis = ScientificNotationValue(2e-5) ) func main() { -- 2.45.2