#100 work in progress on command acks for reactive buttons

This commit is contained in:
Mikayla Fischler
2022-10-20 12:22:03 -04:00
parent bfa87815fa
commit ab757e14a7
8 changed files with 118 additions and 52 deletions

View File

@@ -18,6 +18,7 @@ local println_ts = util.println_ts
local PROTOCOLS = comms.PROTOCOLS
local SCADA_MGMT_TYPES = comms.SCADA_MGMT_TYPES
local SCADA_CRDN_TYPES = comms.SCADA_CRDN_TYPES
local CRDN_COMMANDS = comms.CRDN_COMMANDS
-- request the user to select a monitor
---@param names table available monitors
@@ -306,11 +307,11 @@ function coordinator.comms(version, modem, sv_port, sv_listen, api_listen, sv_wa
end
-- send a unit command
---@param unit integer unit ID
---@param cmd CRDN_COMMANDS command
---@param unit integer unit ID
---@param option any? optional options (like burn rate)
function public.send_command(unit, cmd, option)
_send_sv(PROTOCOLS.SCADA_CRDN, SCADA_CRDN_TYPES.COMMAND_UNIT, { unit, cmd, option })
function public.send_command(cmd, unit, option)
_send_sv(PROTOCOLS.SCADA_CRDN, SCADA_CRDN_TYPES.COMMAND_UNIT, { cmd, unit, option })
end
-- parse a packet
@@ -425,6 +426,22 @@ function coordinator.comms(version, modem, sv_port, sv_listen, api_listen, sv_wa
log.error("received invalid unit statuses packet")
end
elseif packet.type == SCADA_CRDN_TYPES.COMMAND_UNIT then
-- unit command acknowledgement
if packet.length == 3 then
local cmd = packet.data[1]
local unit = packet.data[2]
local ack = packet.data[3]
if cmd == CRDN_COMMANDS.SCRAM then
elseif cmd == CRDN_COMMANDS.START then
elseif cmd == CRDN_COMMANDS.RESET_RPS then
elseif cmd == CRDN_COMMANDS.SET_BURN then
elseif cmd == CRDN_COMMANDS.SET_WASTE then
else
end
else
log.debug("unit command ack packet length mismatch")
end
elseif packet.type == SCADA_CRDN_TYPES.ALARM then
else
log.warning("received unknown SCADA_CRDN packet type " .. packet.type)

View File

@@ -34,25 +34,10 @@ function iocontrol.init(conf, comms)
burn_rate_cmd = 0.0,
waste_control = 0,
start = function ()
comms.send_command(i, CRDN_COMMANDS.START)
log.debug(util.c("sent unit ", i, ": START"))
end,
scram = function ()
comms.send_command(i, CRDN_COMMANDS.SCRAM)
log.debug(util.c("sent unit ", i, ": SCRAM"))
end,
reset_rps = function ()
comms.send_command(i, CRDN_COMMANDS.RESET_RPS)
log.debug(util.c("sent unit ", i, ": RESET_RPS"))
end,
set_burn = function (rate)
comms.send_command(i, CRDN_COMMANDS.SET_BURN, rate)
log.debug(util.c("sent unit ", i, ": SET_BURN = ", rate))
end,
start = function () end,
scram = function () end,
reset_rps = function () end,
set_burn = function (rate) end,
reactor_ps = psil.create(),
reactor_data = {}, ---@type reactor_db
@@ -64,12 +49,36 @@ function iocontrol.init(conf, comms)
turbine_data_tbl = {}
}
function entry.start()
entry.control_state = true
comms.send_command(CRDN_COMMANDS.START, i)
log.debug(util.c("UNIT[", i, "]: START"))
end
function entry.scram()
entry.control_state = false
comms.send_command(CRDN_COMMANDS.SCRAM, i)
log.debug(util.c("UNIT[", i, "]: SCRAM"))
end
function entry.reset_rps()
comms.send_command(CRDN_COMMANDS.RESET_RPS, i)
log.debug(util.c("UNIT[", i, "]: RESET_RPS"))
end
function entry.set_burn(rate)
comms.send_command(CRDN_COMMANDS.SET_BURN, i, rate)
log.debug(util.c("UNIT[", i, "]: SET_BURN = ", rate))
end
-- create boiler tables
for _ = 1, conf.defs[(i * 2) - 1] do
local data = {} ---@type boilerv_session_db
table.insert(entry.boiler_ps_tbl, psil.create())
table.insert(entry.boiler_data_tbl, data)
end
-- create turbine tables
for _ = 1, conf.defs[i * 2] do
local data = {} ---@type turbinev_session_db
table.insert(entry.turbine_ps_tbl, psil.create())

View File

@@ -16,7 +16,7 @@ local config = require("coordinator.config")
local coordinator = require("coordinator.coordinator")
local renderer = require("coordinator.renderer")
local COORDINATOR_VERSION = "alpha-v0.5.4"
local COORDINATOR_VERSION = "alpha-v0.5.5"
local print = util.print
local println = util.println