#498 auto control mode based UI disabling and increased timeouts
This commit is contained in:
parent
13bb6cb026
commit
6ff096fd31
@ -224,6 +224,7 @@ function pocket.new_session(id, s_addr, i_seq_num, in_queue, out_queue, timeout)
|
||||
u.unit_id,
|
||||
u.connected,
|
||||
u.rtu_hw,
|
||||
u.a_group,
|
||||
u.alarms,
|
||||
u.annunciator,
|
||||
u.reactor_data,
|
||||
|
||||
@ -10,6 +10,7 @@ local element = require("graphics.element")
|
||||
---@field accent color accent color for hazard border
|
||||
---@field dis_colors? cpair text color and border color when disabled
|
||||
---@field callback function function to call on touch
|
||||
---@field timeout? integer override for the default 1.5 second timeout, in seconds
|
||||
---@field parent graphics_element
|
||||
---@field id? string element id
|
||||
---@field x? integer 1 if omitted
|
||||
@ -28,6 +29,8 @@ local function hazard_button(args)
|
||||
args.height = 3
|
||||
args.width = string.len(args.text) + 4
|
||||
|
||||
local timeout = args.timeout or 1.5
|
||||
|
||||
-- create new graphics element base object
|
||||
local e = element.new(args)
|
||||
|
||||
@ -149,8 +152,8 @@ local function hazard_button(args)
|
||||
tcd.abort(on_success)
|
||||
tcd.abort(on_failure)
|
||||
|
||||
-- 1.5 second timeout
|
||||
tcd.dispatch(1.5, on_timeout)
|
||||
-- operation timeout handling
|
||||
tcd.dispatch(timeout, on_timeout)
|
||||
|
||||
args.callback()
|
||||
end
|
||||
|
||||
@ -22,6 +22,8 @@ local TEMP_UNITS = types.TEMP_SCALE_UNITS
|
||||
local WARN_TT = 40
|
||||
local HIGH_TT = 80
|
||||
|
||||
local GROUP_NAMES = { "Manual", "Primary", "Secondary", "Tertiary", "Backup" }
|
||||
|
||||
local iocontrol = {}
|
||||
|
||||
---@enum POCKET_LINK_STATE
|
||||
@ -493,11 +495,15 @@ function iocontrol.record_unit_data(data)
|
||||
|
||||
unit.connected = data[2]
|
||||
unit.rtu_hw = data[3]
|
||||
unit.alarms = data[4]
|
||||
unit.a_group = data[4]
|
||||
unit.alarms = data[5]
|
||||
|
||||
unit.unit_ps.publish("auto_group_id", unit.a_group)
|
||||
unit.unit_ps.publish("auto_group", GROUP_NAMES[unit.a_group + 1])
|
||||
|
||||
--#region Annunciator
|
||||
|
||||
unit.annunciator = data[5]
|
||||
unit.annunciator = data[6]
|
||||
|
||||
local rcs_disconn, rcs_warn, rcs_hazard = false, false, false
|
||||
|
||||
@ -575,7 +581,7 @@ function iocontrol.record_unit_data(data)
|
||||
|
||||
--#region Reactor Data
|
||||
|
||||
unit.reactor_data = data[6]
|
||||
unit.reactor_data = data[7]
|
||||
|
||||
local control_status = 1
|
||||
local reactor_status = 1
|
||||
@ -647,7 +653,7 @@ function iocontrol.record_unit_data(data)
|
||||
|
||||
--#region RTU Devices
|
||||
|
||||
unit.boiler_data_tbl = data[7]
|
||||
unit.boiler_data_tbl = data[8]
|
||||
|
||||
for id = 1, #unit.boiler_data_tbl do
|
||||
local boiler = unit.boiler_data_tbl[id] ---@type boilerv_session_db
|
||||
@ -680,7 +686,7 @@ function iocontrol.record_unit_data(data)
|
||||
ps.publish("BoilerStateStatus", computed_status)
|
||||
end
|
||||
|
||||
unit.turbine_data_tbl = data[8]
|
||||
unit.turbine_data_tbl = data[9]
|
||||
|
||||
for id = 1, #unit.turbine_data_tbl do
|
||||
local turbine = unit.turbine_data_tbl[id] ---@type turbinev_session_db
|
||||
@ -715,10 +721,10 @@ function iocontrol.record_unit_data(data)
|
||||
ps.publish("TurbineStateStatus", computed_status)
|
||||
end
|
||||
|
||||
unit.tank_data_tbl = data[9]
|
||||
unit.tank_data_tbl = data[10]
|
||||
|
||||
unit.last_rate_change_ms = data[10]
|
||||
unit.turbine_flow_stable = data[11]
|
||||
unit.last_rate_change_ms = data[11]
|
||||
unit.turbine_flow_stable = data[12]
|
||||
|
||||
--#endregion
|
||||
|
||||
|
||||
@ -609,7 +609,7 @@ function pocket.comms(version, nic, sv_watchdog, api_watchdog, nav)
|
||||
local ok = util.trinary(max == nil, packet.length == length, packet.length >= length and packet.length <= (max or 0))
|
||||
if not ok then
|
||||
local fmt = "[comms] RX_PACKET{r_chan=%d,proto=%d,type=%d}: packet length mismatch -> expect %d != actual %d"
|
||||
log.debug(util.sprintf(fmt, packet.scada_frame.remote_channel(), packet.scada_frame.protocol(), packet.type, length, packet.scada_frame.length()))
|
||||
log.debug(util.sprintf(fmt, packet.scada_frame.remote_channel(), packet.scada_frame.protocol(), packet.type, length, packet.length))
|
||||
end
|
||||
return ok
|
||||
end
|
||||
@ -703,7 +703,7 @@ function pocket.comms(version, nic, sv_watchdog, api_watchdog, nav)
|
||||
iocontrol.record_facility_data(packet.data)
|
||||
end
|
||||
elseif packet.type == CRDN_TYPE.API_GET_UNIT then
|
||||
if _check_length(packet, 11) and type(packet.data[1]) == "number" and iocontrol.get_db().units[packet.data[1]] then
|
||||
if _check_length(packet, 12) and type(packet.data[1]) == "number" and iocontrol.get_db().units[packet.data[1]] then
|
||||
iocontrol.record_unit_data(packet.data)
|
||||
end
|
||||
else _fail_type(packet) end
|
||||
|
||||
@ -150,18 +150,26 @@ local function new_view(root)
|
||||
|
||||
TextBox{parent=u_div,y=8,text="CMD",width=4,fg_bg=cpair(colors.lightGray,colors.black)}
|
||||
TextBox{parent=u_div,x=14,y=8,text="mB/t",width=4,fg_bg=cpair(colors.lightGray,colors.black)}
|
||||
local burn_cmd = NumberField{parent=u_div,x=5,y=8,width=8,default=0.01,min=0.01,max_frac_digits=2,max_chars=8,allow_decimal=true,align_right=true,fg_bg=cpair(colors.white,colors.gray)}
|
||||
local burn_cmd = NumberField{parent=u_div,x=5,y=8,width=8,default=0.01,min=0.01,max_frac_digits=2,max_chars=8,allow_decimal=true,align_right=true,fg_bg=cpair(colors.white,colors.gray),dis_fg_bg=cpair(colors.gray,colors.lightGray)}
|
||||
|
||||
local set_burn = function () unit.set_burn(burn_cmd.get_value()) end
|
||||
local set_burn_btn = PushButton{parent=u_div,x=19,y=8,text="SET",min_width=5,fg_bg=cpair(colors.green,colors.black),active_fg_bg=cpair(colors.white,colors.black),dis_fg_bg=cpair(colors.gray,colors.black),callback=set_burn}
|
||||
|
||||
-- enable/disable controls based on group assignment (start button is separate)
|
||||
burn_cmd.register(u_ps, "auto_group_id", function (gid)
|
||||
if gid == 0 then burn_cmd.enable() else burn_cmd.disable() end
|
||||
end)
|
||||
set_burn_btn.register(u_ps, "auto_group_id", function (gid)
|
||||
if gid == 0 then set_burn_btn.enable() else set_burn_btn.disable() end
|
||||
end)
|
||||
|
||||
burn_cmd.register(u_ps, "burn_rate", burn_cmd.set_value)
|
||||
burn_cmd.register(u_ps, "max_burn", burn_cmd.set_max)
|
||||
|
||||
local start = HazardButton{parent=u_div,x=2,y=11,text="START",accent=colors.lightBlue,dis_colors=dis_colors,callback=unit.start,fg_bg=hzd_fg_bg}
|
||||
local ack_a = HazardButton{parent=u_div,x=12,y=11,text="ACK \x13",accent=colors.orange,dis_colors=dis_colors,callback=unit.ack_alarms,fg_bg=hzd_fg_bg}
|
||||
local scram = HazardButton{parent=u_div,x=2,y=15,text="SCRAM",accent=colors.yellow,dis_colors=dis_colors,callback=unit.scram,fg_bg=hzd_fg_bg}
|
||||
local reset = HazardButton{parent=u_div,x=12,y=15,text="RESET",accent=colors.red,dis_colors=dis_colors,callback=unit.reset_rps,fg_bg=hzd_fg_bg}
|
||||
local start = HazardButton{parent=u_div,x=2,y=11,text="START",accent=colors.lightBlue,dis_colors=dis_colors,callback=unit.start,timeout=3,fg_bg=hzd_fg_bg}
|
||||
local ack_a = HazardButton{parent=u_div,x=12,y=11,text="ACK \x13",accent=colors.orange,dis_colors=dis_colors,callback=unit.ack_alarms,timeout=3,fg_bg=hzd_fg_bg}
|
||||
local scram = HazardButton{parent=u_div,x=2,y=15,text="SCRAM",accent=colors.yellow,dis_colors=dis_colors,callback=unit.scram,timeout=3,fg_bg=hzd_fg_bg}
|
||||
local reset = HazardButton{parent=u_div,x=12,y=15,text="RESET",accent=colors.red,dis_colors=dis_colors,callback=unit.reset_rps,timeout=3,fg_bg=hzd_fg_bg}
|
||||
|
||||
unit.start_ack = start.on_response
|
||||
unit.ack_alarms_ack = ack_a.on_response
|
||||
@ -179,8 +187,8 @@ local function new_view(root)
|
||||
|
||||
start.register(u_ps, "status", start_button_en_check)
|
||||
start.register(u_ps, "rps_tripped", start_button_en_check)
|
||||
-- start.register(u_ps, "auto_group_id", start_button_en_check)
|
||||
-- start.register(u_ps, "AutoControl", start_button_en_check)
|
||||
start.register(u_ps, "auto_group_id", start_button_en_check)
|
||||
start.register(u_ps, "AutoControl", start_button_en_check)
|
||||
|
||||
reset.register(u_ps, "rps_tripped", function (active) if active then reset.enable() else reset.disable() end end)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user