Commit 236ffd64 authored by Eric S. Raymond's avatar Eric S. Raymond

Implement HostDrainThreshold

parent d30dc0f6
......@@ -166,7 +166,7 @@ events = {
"EventBadAC": "Poll of mains reports bad AC voltage",
"EventBatteryWarn": "Poll of BMS reports Time ToEmpty <= ShutdownTime + WarningTime",
"EventBatteryLow": "Poll of BMS reports TimeToEmpty <= ShutdownTime",
"EventHostOff": "Poll of host load sensor shows no current draw",
"EventHostOff": "Poll of host load sensor shows current draw less than threshold",
"EventUnreachable": "Code cannot reach this event",
}
......
......@@ -110,6 +110,7 @@ These policy parameters control the state transitions:
| Parameter | Default | Meaning
| ShutdownTime | 30 sec | Time required for host shutdown
| WarningTime | 60 sec | Desired warning margin before shutdown
| HostDrainThreshold | 10V | Lowest expected draw of shut down host.
|========================================================================
In the following state diagram, ovals are are possible values of a
......
......@@ -28,6 +28,7 @@ type policyConfig struct {
WarningTime time.Duration
QuietTime time.Duration
VoltageThreshold float32
HostDrainThreshold int
HostPair int
MasterSlaves [][]string
PowerButton uint
......@@ -116,6 +117,7 @@ func init() {
PolicyConfiguration = policyConfig{
ShutdownTime: 30 * time.Second, // Time required for host shutdown
WarningTime: 60 * time.Second, // Desired warning margin before shutdown
HostDrainThreshold: 10,
QuietTime: 10 * time.Millisecond,
VoltageThreshold: 0.90,
HostPair: 1,
......@@ -309,7 +311,7 @@ func fireEvents(prev *Observables, ob *Observables) {
hostSensor := PolicyConfiguration.HostSensor()
nv := ob.LoadMap[hostSensor]
ov := prev.LoadMap[hostSensor]
if ov != 0 && nv == 0 {
if ov >= PolicyConfiguration.HostDrainThreshold && nv < PolicyConfiguration.HostDrainThreshold {
Transition(EventHostOff)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment