#498 functioning pocket manual unit controls
This commit is contained in:
parent
66fae0695c
commit
ab11ff03b5
@ -316,14 +316,12 @@ function process.fac_ack(command, success)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- handle a unit command acknowledgement
|
-- handle a unit command acknowledgement
|
||||||
---@param unit any unit ID (invalid index protected)
|
---@param unit integer unit ID
|
||||||
---@param command UNIT_COMMAND command
|
---@param command UNIT_COMMAND command
|
||||||
---@param success boolean if the command was successful
|
---@param success boolean if the command was successful
|
||||||
function process.unit_ack(unit, command, success)
|
function process.unit_ack(unit, command, success)
|
||||||
if pctl.commands.unit[unit] then
|
|
||||||
cmd_ack(pctl.commands.unit[unit][command], success)
|
cmd_ack(pctl.commands.unit[unit][command], success)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
--#region One-Way Commands (no acknowledgements)
|
--#region One-Way Commands (no acknowledgements)
|
||||||
|
|
||||||
|
|||||||
@ -654,7 +654,36 @@ function pocket.comms(version, nic, sv_watchdog, api_watchdog, nav)
|
|||||||
if protocol == PROTOCOL.SCADA_CRDN then
|
if protocol == PROTOCOL.SCADA_CRDN then
|
||||||
---@cast packet crdn_frame
|
---@cast packet crdn_frame
|
||||||
if self.api.linked then
|
if self.api.linked then
|
||||||
if packet.type == CRDN_TYPE.API_GET_FAC then
|
if packet.type == CRDN_TYPE.UNIT_CMD then
|
||||||
|
-- unit command acknowledgement
|
||||||
|
if packet.length == 3 then
|
||||||
|
local cmd = packet.data[1]
|
||||||
|
local unit_id = packet.data[2]
|
||||||
|
local ack = packet.data[3] == true
|
||||||
|
|
||||||
|
local unit = iocontrol.get_db().units[unit_id] ---@type pioctl_unit
|
||||||
|
|
||||||
|
if unit ~= nil then
|
||||||
|
if cmd == UNIT_COMMAND.SCRAM then
|
||||||
|
unit.scram_ack(ack)
|
||||||
|
elseif cmd == UNIT_COMMAND.START then
|
||||||
|
unit.start_ack(ack)
|
||||||
|
elseif cmd == UNIT_COMMAND.RESET_RPS then
|
||||||
|
unit.reset_rps_ack(ack)
|
||||||
|
elseif cmd == UNIT_COMMAND.SET_BURN then
|
||||||
|
-- this also doesn't exist
|
||||||
|
elseif cmd == UNIT_COMMAND.SET_WASTE then
|
||||||
|
-- updated by unit updates
|
||||||
|
elseif cmd == UNIT_COMMAND.ACK_ALL_ALARMS then
|
||||||
|
unit.ack_alarms_ack(ack)
|
||||||
|
elseif cmd == UNIT_COMMAND.SET_GROUP then
|
||||||
|
-- updated by unit updates
|
||||||
|
else
|
||||||
|
log.debug(util.c("received unit command ack with unknown command ", cmd))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif packet.type == CRDN_TYPE.API_GET_FAC then
|
||||||
if _check_length(packet, 11) then
|
if _check_length(packet, 11) then
|
||||||
iocontrol.record_facility_data(packet.data)
|
iocontrol.record_facility_data(packet.data)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -154,6 +154,7 @@ local function new_view(root)
|
|||||||
local set_burn = function () unit.set_burn(burn_cmd.get_value()) end
|
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}
|
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}
|
||||||
|
|
||||||
|
burn_cmd.register(u_ps, "burn_rate", burn_cmd.set_value)
|
||||||
burn_cmd.register(u_ps, "max_burn", burn_cmd.set_max)
|
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 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}
|
||||||
@ -161,6 +162,27 @@ local function new_view(root)
|
|||||||
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 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 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}
|
||||||
|
|
||||||
|
unit.start_ack = start.on_response
|
||||||
|
unit.ack_alarms_ack = ack_a.on_response
|
||||||
|
unit.scram_ack = scram.on_response
|
||||||
|
unit.reset_rps_ack = reset.on_response
|
||||||
|
|
||||||
|
local function start_button_en_check()
|
||||||
|
if (unit.reactor_data ~= nil) and (unit.reactor_data.mek_status ~= nil) then
|
||||||
|
local can_start = (not unit.reactor_data.mek_status.status) and
|
||||||
|
(not unit.reactor_data.rps_tripped) and
|
||||||
|
(unit.a_group == 0)
|
||||||
|
if can_start then start.enable() else start.disable() end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
reset.register(u_ps, "rps_tripped", function (active) if active then reset.enable() else reset.disable() end end)
|
||||||
|
|
||||||
--#endregion
|
--#endregion
|
||||||
|
|
||||||
util.nop()
|
util.nop()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user