From 42c2b1bda1b59886c107e72b336ed22b034ee936 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Thu, 28 Jul 2022 12:10:52 -0400 Subject: [PATCH] coordinator use tcallbackdsp, #73 burn rate set button click effect, test blinks of lights --- coordinator/startup.lua | 10 ++++++++-- coordinator/ui/layout/unit_view.lua | 22 ++++++++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/coordinator/startup.lua b/coordinator/startup.lua index e685797..b817063 100644 --- a/coordinator/startup.lua +++ b/coordinator/startup.lua @@ -3,6 +3,7 @@ -- require("/initenv").init_env() +local tcallbackdsp = require("scada-common.tcallbackdsp") local log = require("scada-common.log") local ppm = require("scada-common.ppm") @@ -15,7 +16,7 @@ local config = require("coordinator.config") local coordinator = require("coordinator.coordinator") local renderer = require("coordinator.renderer") -local COORDINATOR_VERSION = "alpha-v0.3.7" +local COORDINATOR_VERSION = "alpha-v0.3.8" local print = util.print local println = util.println @@ -206,8 +207,13 @@ while ui_ok do println_ts(msg) log.warning(msg) else - -- a non-clock/main watchdog timer event, check API watchdogs + -- a non-clock/main watchdog timer event + + --check API watchdogs --apisessions.check_all_watchdogs(param1) + + -- notify timer callback dispatcher + tcallbackdsp.handle(param1) end elseif event == "modem_message" then -- got a packet diff --git a/coordinator/ui/layout/unit_view.lua b/coordinator/ui/layout/unit_view.lua index 6016128..839ef12 100644 --- a/coordinator/ui/layout/unit_view.lua +++ b/coordinator/ui/layout/unit_view.lua @@ -3,6 +3,7 @@ -- local core = require("graphics.core") +local tcallbackdsp = require("scada-common.tcallbackdsp") local style = require("coordinator.ui.style") @@ -47,7 +48,7 @@ local function init(monitor, id) local set_burn = function () print("set burn to " .. burn_rate.get_value()) end TextBox{parent=burn_control,x=9,y=2,text="mB/t"} - PushButton{parent=burn_control,x=14,y=2,text="SET",min_width=5,fg_bg=cpair(colors.black,colors.yellow),callback=set_burn} + PushButton{parent=burn_control,x=14,y=2,text="SET",min_width=5,fg_bg=cpair(colors.black,colors.yellow),active_fg_bg=cpair(colors.white,colors.gray),callback=set_burn} local annunciator = Div{parent=main,x=34,y=core_height+4} @@ -55,7 +56,7 @@ local function init(monitor, id) -- connectivity/basic state local plc_online = IndicatorLight{parent=annunciator,label="PLC Online",colors=cpair(colors.green,colors.red)} - local plc_hbeat = IndicatorLight{parent=annunciator,label="PLC Heartbeat",colors=cpair(colors.white,colors.red)} + local plc_hbeat = IndicatorLight{parent=annunciator,label="PLC Heartbeat",colors=cpair(colors.white,colors.gray)} local r_active = IndicatorLight{parent=annunciator,label="Active",colors=cpair(colors.green,colors.gray)} local r_auto = IndicatorLight{parent=annunciator,label="Auto Control",colors=cpair(colors.blue,colors.gray)} @@ -92,6 +93,23 @@ local function init(monitor, id) rps_trp.update(true) rps_nof.update(true) + local heartbeat = true + local function _test_toggle() + plc_hbeat.update(heartbeat) + heartbeat = not heartbeat + tcallbackdsp.dispatch(1, _test_toggle) + end + + local rps = true + local function _test_toggle1() + rps_nof.update(rps) + rps = not rps + tcallbackdsp.dispatch(0.25, _test_toggle1) + end + + tcallbackdsp.dispatch(1, _test_toggle) + tcallbackdsp.dispatch(0.25, _test_toggle1) + return main end