mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#150 save and automatically set priority groups, added checks to set waste and set group commands, restore waste mode control if operation failed
This commit is contained in:
parent
72791d042b
commit
a117d5ee97
@ -292,6 +292,7 @@ function iocontrol.update_facility_status(status)
|
|||||||
if (type(group_map) == "table") and (#group_map == fac.num_units) then
|
if (type(group_map) == "table") and (#group_map == fac.num_units) then
|
||||||
local names = { "Manual", "Primary", "Secondary", "Tertiary", "Backup" }
|
local names = { "Manual", "Primary", "Secondary", "Tertiary", "Backup" }
|
||||||
for i = 1, #group_map do
|
for i = 1, #group_map do
|
||||||
|
io.units[i].unit_ps.publish("auto_group_id", group_map[i] + 1)
|
||||||
io.units[i].unit_ps.publish("auto_group", names[group_map[i] + 1])
|
io.units[i].unit_ps.publish("auto_group", names[group_map[i] + 1])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -70,12 +70,22 @@ function process.init(iocontrol, comms)
|
|||||||
local waste_mode = settings.get("WASTE_MODES") ---@type table|nil
|
local waste_mode = settings.get("WASTE_MODES") ---@type table|nil
|
||||||
|
|
||||||
if type(waste_mode) == "table" then
|
if type(waste_mode) == "table" then
|
||||||
for id = 1, math.min(#waste_mode, self.io.facility.num_units) do
|
for id, mode in pairs(waste_mode) do
|
||||||
self.comms.send_unit_command(UNIT_COMMANDS.SET_WASTE, id, waste_mode[id])
|
self.comms.send_unit_command(UNIT_COMMANDS.SET_WASTE, id, mode)
|
||||||
end
|
end
|
||||||
|
|
||||||
log.info("PROCESS: loaded waste mode settings from coord.settings")
|
log.info("PROCESS: loaded waste mode settings from coord.settings")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local prio_groups = settings.get("PRIORITY_GROUPS") ---@type table|nil
|
||||||
|
|
||||||
|
if type(prio_groups) == "table" then
|
||||||
|
for id, group in pairs(prio_groups) do
|
||||||
|
self.comms.send_unit_command(UNIT_COMMANDS.SET_GROUP, id, group)
|
||||||
|
end
|
||||||
|
|
||||||
|
log.info("PROCESS: loaded priority groups settings from coord.settings")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- start reactor
|
-- start reactor
|
||||||
@ -113,6 +123,9 @@ end
|
|||||||
---@param id integer unit ID
|
---@param id integer unit ID
|
||||||
---@param mode integer waste mode
|
---@param mode integer waste mode
|
||||||
function process.set_waste(id, mode)
|
function process.set_waste(id, mode)
|
||||||
|
-- publish so that if it fails then it gets reset
|
||||||
|
self.io.units[id].unit_ps.publish("U_WasteMode", mode)
|
||||||
|
|
||||||
self.comms.send_unit_command(UNIT_COMMANDS.SET_WASTE, id, mode)
|
self.comms.send_unit_command(UNIT_COMMANDS.SET_WASTE, id, mode)
|
||||||
log.debug(util.c("UNIT[", id, "]: SET WASTE = ", mode))
|
log.debug(util.c("UNIT[", id, "]: SET WASTE = ", mode))
|
||||||
|
|
||||||
@ -160,6 +173,20 @@ end
|
|||||||
function process.set_group(unit_id, group_id)
|
function process.set_group(unit_id, group_id)
|
||||||
self.comms.send_unit_command(UNIT_COMMANDS.SET_GROUP, unit_id, group_id)
|
self.comms.send_unit_command(UNIT_COMMANDS.SET_GROUP, unit_id, group_id)
|
||||||
log.debug(util.c("UNIT[", unit_id, "]: SET GROUP ", group_id))
|
log.debug(util.c("UNIT[", unit_id, "]: SET GROUP ", group_id))
|
||||||
|
|
||||||
|
local prio_groups = settings.get("PRIORITY_GROUPS") ---@type table|nil
|
||||||
|
|
||||||
|
if type(prio_groups) ~= "table" then
|
||||||
|
prio_groups = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
prio_groups[unit_id] = group_id
|
||||||
|
|
||||||
|
settings.set("PRIORITY_GROUPS", prio_groups)
|
||||||
|
|
||||||
|
if not settings.save("/coord.settings") then
|
||||||
|
log.error("process.set_group(): failed to save coordinator settings file")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------
|
--------------------------
|
||||||
|
@ -19,7 +19,7 @@ local iocontrol = require("coordinator.iocontrol")
|
|||||||
local renderer = require("coordinator.renderer")
|
local renderer = require("coordinator.renderer")
|
||||||
local sounder = require("coordinator.sounder")
|
local sounder = require("coordinator.sounder")
|
||||||
|
|
||||||
local COORDINATOR_VERSION = "beta-v0.8.14"
|
local COORDINATOR_VERSION = "beta-v0.8.15"
|
||||||
|
|
||||||
local print = util.print
|
local print = util.print
|
||||||
local println = util.println
|
local println = util.println
|
||||||
|
@ -459,10 +459,11 @@ local function init(parent, id)
|
|||||||
|
|
||||||
local group = RadioButton{parent=auto_div,options=ctl_opts,callback=function()end,radio_colors=cpair(colors.blue,colors.white),radio_bg=colors.gray}
|
local group = RadioButton{parent=auto_div,options=ctl_opts,callback=function()end,radio_colors=cpair(colors.blue,colors.white),radio_bg=colors.gray}
|
||||||
|
|
||||||
|
u_ps.subscribe("auto_group_id", group.set_value)
|
||||||
|
|
||||||
auto_div.line_break()
|
auto_div.line_break()
|
||||||
|
|
||||||
local function set_group() unit.set_group(group.get_value() - 1) end
|
local function set_group() unit.set_group(group.get_value() - 1) end
|
||||||
|
|
||||||
local set_grp_btn = PushButton{parent=auto_div,text="SET",x=4,min_width=5,fg_bg=cpair(colors.black,colors.yellow),active_fg_bg=cpair(colors.white,colors.gray),dis_fg_bg=cpair(colors.gray,colors.white),callback=set_group}
|
local set_grp_btn = PushButton{parent=auto_div,text="SET",x=4,min_width=5,fg_bg=cpair(colors.black,colors.yellow),active_fg_bg=cpair(colors.white,colors.gray),dis_fg_bg=cpair(colors.gray,colors.white),callback=set_group}
|
||||||
|
|
||||||
auto_div.line_break()
|
auto_div.line_break()
|
||||||
|
@ -268,7 +268,7 @@ function coordinator.new_session(id, in_queue, out_queue, facility)
|
|||||||
log.debug(log_header .. "CRDN unit command burn rate missing option")
|
log.debug(log_header .. "CRDN unit command burn rate missing option")
|
||||||
end
|
end
|
||||||
elseif cmd == UNIT_COMMANDS.SET_WASTE then
|
elseif cmd == UNIT_COMMANDS.SET_WASTE then
|
||||||
if pkt.length == 3 then
|
if (pkt.length == 3) and (type(pkt.data[3]) == "number") and (pkt.data[3] > 0) and (pkt.data[3] <= 4) then
|
||||||
unit.set_waste(pkt.data[3])
|
unit.set_waste(pkt.data[3])
|
||||||
else
|
else
|
||||||
log.debug(log_header .. "CRDN unit command set waste missing option")
|
log.debug(log_header .. "CRDN unit command set waste missing option")
|
||||||
@ -289,7 +289,7 @@ function coordinator.new_session(id, in_queue, out_queue, facility)
|
|||||||
log.debug(log_header .. "CRDN unit command reset alarm missing alarm id")
|
log.debug(log_header .. "CRDN unit command reset alarm missing alarm id")
|
||||||
end
|
end
|
||||||
elseif cmd == UNIT_COMMANDS.SET_GROUP then
|
elseif cmd == UNIT_COMMANDS.SET_GROUP then
|
||||||
if pkt.length == 3 then
|
if (pkt.length == 3) and (type(pkt.data[3]) == "number") and (pkt.data[3] >= 0) and (pkt.data[3] <= 4) then
|
||||||
facility.set_group(unit.get_id(), pkt.data[3])
|
facility.set_group(unit.get_id(), pkt.data[3])
|
||||||
_send(SCADA_CRDN_TYPES.UNIT_CMD, { cmd, uid, pkt.data[3] })
|
_send(SCADA_CRDN_TYPES.UNIT_CMD, { cmd, uid, pkt.data[3] })
|
||||||
else
|
else
|
||||||
|
@ -14,7 +14,7 @@ local svsessions = require("supervisor.session.svsessions")
|
|||||||
local config = require("supervisor.config")
|
local config = require("supervisor.config")
|
||||||
local supervisor = require("supervisor.supervisor")
|
local supervisor = require("supervisor.supervisor")
|
||||||
|
|
||||||
local SUPERVISOR_VERSION = "beta-v0.9.9"
|
local SUPERVISOR_VERSION = "beta-v0.9.10"
|
||||||
|
|
||||||
local print = util.print
|
local print = util.print
|
||||||
local println = util.println
|
local println = util.println
|
||||||
|
Loading…
x
Reference in New Issue
Block a user