{"id":7954,"date":"2018-04-23T06:48:13","date_gmt":"2018-04-23T10:48:13","guid":{"rendered":"http:\/\/esr.ibiblio.org\/?p=7954"},"modified":"2018-04-23T06:51:57","modified_gmt":"2018-04-23T10:51:57","slug":"the-upside-state-diagram","status":"publish","type":"post","link":"http:\/\/esr.ibiblio.org\/?p=7954","title":{"rendered":"The UPSide state diagram"},"content":{"rendered":"<p>I think this diagram is now stable enough to put on the record.<\/p>\n<figure id=\"attachment_7953\" aria-describedby=\"caption-attachment-7953\" style=\"width: 960px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/esr.ibiblio.org\/wp-content\/uploads\/2018\/04\/flow.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-7953\" src=\"http:\/\/esr.ibiblio.org\/wp-content\/uploads\/2018\/04\/flow.png\" alt=\"UPSide state diagram\" width=\"960\" height=\"1454\" srcset=\"http:\/\/esr.ibiblio.org\/wp-content\/uploads\/2018\/04\/flow.png 960w, http:\/\/esr.ibiblio.org\/wp-content\/uploads\/2018\/04\/flow-198x300.png 198w, http:\/\/esr.ibiblio.org\/wp-content\/uploads\/2018\/04\/flow-768x1163.png 768w, http:\/\/esr.ibiblio.org\/wp-content\/uploads\/2018\/04\/flow-676x1024.png 676w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" \/><\/a><figcaption id=\"caption-attachment-7953\" class=\"wp-caption-text\">UPSide state diagram<\/figcaption><\/figure>\n<p>Both this diagram and the Go code for the policy logic are generated from this pseudocode:<\/p>\n<pre><code>\r\n    render.state(\"DaemonUp\", \"Daemon running\") \r\n    render.action(\"DaemonUp\", \"ChargeWait\", CHARGING)\r\n    render.state(\"ChargeWait\", \"Charge wait\")\r\n    render.action(\"ChargeWait\", \"MainsUp\", CHARGED)\r\n    render.action(\"ChargeWait\", \"OnBattery\", MAINSDROP)\r\n    render.state(\"MainsUp\", \"On mains power\")\r\n    render.action(\"DaemonUp\", \"OnBattery\", MAINSOFF)\r\n    render.state(\"OnBattery\", \"On battery power\")\r\n    render.action(\"MainsUp\", \"OnBattery\", MAINSDROP)\r\n    render.action(\"OnBattery\", \"Overtime\", DWELLWARNING)\r\n    render.state(\"Overtime\", \"User warned of shutdown\")\r\n    render.action(\"Overtime\", \"PreShutdown\", DWELLTIMEOUT)\r\n    render.state(\"PreShutdown\", \"Awaiting power drop\")\r\n    render.action(\"PreShutdown\", \"ChargeWait\", RESTORED)\r\n    render.state(\"UPSCrash\", \"UPS goes dark\")\r\n    render.state(\"HostDown\", \"Host has shut down\")\r\n    render.action(\"PreShutdown\", \"HostDown\", HOSTDOWN)\r\n    render.action(\"PreShutdown\", \"UPSCrash\", BATTERYDRAIN, unreachable=True)\r\n    render.action(\"OnBattery\", \"ChargeWait\", RESTORED)\r\n    render.action(\"Overtime\", \"ChargeWait\", RESTORED)\r\n    render.action(\"HostDown\", \"MainsUp\", RESTORED_LATE)\r\n    render.action(\"HostDown\", \"UPSCrash\", BATTERYDRAIN, unreachable=True)\r\n<\/code><\/pre>\n<p>To see the full context of this, clone git@gitlab.com:esr\/upside.git and explore the docs\/ directory.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I think this diagram is now stable enough to put on the record. Both this diagram and the Go code for the policy logic are generated from this pseudocode: render.state(&#8220;DaemonUp&#8221;, &#8220;Daemon running&#8221;) render.action(&#8220;DaemonUp&#8221;, &#8220;ChargeWait&#8221;, CHARGING) render.state(&#8220;ChargeWait&#8221;, &#8220;Charge wait&#8221;) render.action(&#8220;ChargeWait&#8221;, &#8220;MainsUp&#8221;, CHARGED) render.action(&#8220;ChargeWait&#8221;, &#8220;OnBattery&#8221;, MAINSDROP) render.state(&#8220;MainsUp&#8221;, &#8220;On mains power&#8221;) render.action(&#8220;DaemonUp&#8221;, &#8220;OnBattery&#8221;, MAINSOFF) render.state(&#8220;OnBattery&#8221;, &#8220;On battery power&#8221;)&hellip; <a class=\"more-link\" href=\"http:\/\/esr.ibiblio.org\/?p=7954\">Continue reading <span class=\"screen-reader-text\">The UPSide state diagram<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[56],"class_list":["post-7954","post","type-post","status-publish","format-standard","hentry","category-software","tag-upside","entry"],"_links":{"self":[{"href":"http:\/\/esr.ibiblio.org\/index.php?rest_route=\/wp\/v2\/posts\/7954","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/esr.ibiblio.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/esr.ibiblio.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/esr.ibiblio.org\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/esr.ibiblio.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7954"}],"version-history":[{"count":2,"href":"http:\/\/esr.ibiblio.org\/index.php?rest_route=\/wp\/v2\/posts\/7954\/revisions"}],"predecessor-version":[{"id":7956,"href":"http:\/\/esr.ibiblio.org\/index.php?rest_route=\/wp\/v2\/posts\/7954\/revisions\/7956"}],"wp:attachment":[{"href":"http:\/\/esr.ibiblio.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7954"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/esr.ibiblio.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7954"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/esr.ibiblio.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7954"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}