added AUTO_GROUP enum
This commit is contained in:
parent
2e978db859
commit
402d8607b6
@ -182,7 +182,7 @@ function iocontrol.init(conf, comms, temp_scale, energy_scale)
|
|||||||
turbine_flow_stable = false,
|
turbine_flow_stable = false,
|
||||||
|
|
||||||
-- auto control group
|
-- auto control group
|
||||||
a_group = 0,
|
a_group = types.AUTO_GROUP.MANUAL,
|
||||||
|
|
||||||
start = function () io.process.start(i) end,
|
start = function () io.process.start(i) end,
|
||||||
scram = function () io.process.scram(i) end,
|
scram = function () io.process.scram(i) end,
|
||||||
@ -569,11 +569,10 @@ function iocontrol.update_facility_status(status)
|
|||||||
local group_map = ctl_status[14]
|
local group_map = ctl_status[14]
|
||||||
|
|
||||||
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" }
|
|
||||||
for i = 1, #group_map do
|
for i = 1, #group_map do
|
||||||
io.units[i].a_group = group_map[i]
|
io.units[i].a_group = group_map[i]
|
||||||
io.units[i].unit_ps.publish("auto_group_id", group_map[i])
|
io.units[i].unit_ps.publish("auto_group_id", group_map[i])
|
||||||
io.units[i].unit_ps.publish("auto_group", names[group_map[i] + 1])
|
io.units[i].unit_ps.publish("auto_group", types.AUTO_GROUP_NAMES[group_map[i] + 1])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -29,6 +29,8 @@ local PushButton = require("graphics.elements.controls.push_button")
|
|||||||
local RadioButton = require("graphics.elements.controls.radio_button")
|
local RadioButton = require("graphics.elements.controls.radio_button")
|
||||||
local SpinboxNumeric = require("graphics.elements.controls.spinbox_numeric")
|
local SpinboxNumeric = require("graphics.elements.controls.spinbox_numeric")
|
||||||
|
|
||||||
|
local AUTO_GROUP = types.AUTO_GROUP
|
||||||
|
|
||||||
local ALIGN = core.ALIGN
|
local ALIGN = core.ALIGN
|
||||||
|
|
||||||
local cpair = core.cpair
|
local cpair = core.cpair
|
||||||
@ -382,7 +384,7 @@ local function init(parent, id)
|
|||||||
if (unit.reactor_data ~= nil) and (unit.reactor_data.mek_status ~= nil) then
|
if (unit.reactor_data ~= nil) and (unit.reactor_data.mek_status ~= nil) then
|
||||||
local can_start = (not unit.reactor_data.mek_status.status) and
|
local can_start = (not unit.reactor_data.mek_status.status) and
|
||||||
(not unit.reactor_data.rps_tripped) and
|
(not unit.reactor_data.rps_tripped) and
|
||||||
(unit.a_group == 0)
|
(unit.a_group == AUTO_GROUP.MANUAL)
|
||||||
if can_start then start.enable() else start.disable() end
|
if can_start then start.enable() else start.disable() end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -486,9 +488,7 @@ local function init(parent, id)
|
|||||||
local auto_ctl = Rectangle{parent=main,border=border(1,colors.purple,true),thin=true,width=13,height=15,x=32,y=37}
|
local auto_ctl = Rectangle{parent=main,border=border(1,colors.purple,true),thin=true,width=13,height=15,x=32,y=37}
|
||||||
local auto_div = Div{parent=auto_ctl,width=13,height=15,x=1,y=1}
|
local auto_div = Div{parent=auto_ctl,width=13,height=15,x=1,y=1}
|
||||||
|
|
||||||
local ctl_opts = { "Manual", "Primary", "Secondary", "Tertiary", "Backup" }
|
local group = RadioButton{parent=auto_div,options=types.AUTO_GROUP_NAMES,callback=function()end,radio_colors=cpair(style.theme.accent_dark,style.theme.accent_light),select_color=colors.purple}
|
||||||
|
|
||||||
local group = RadioButton{parent=auto_div,options=ctl_opts,callback=function()end,radio_colors=cpair(style.theme.accent_dark,style.theme.accent_light),select_color=colors.purple}
|
|
||||||
|
|
||||||
group.register(u_ps, "auto_group_id", function (gid) group.set_value(gid + 1) end)
|
group.register(u_ps, "auto_group_id", function (gid) group.set_value(gid + 1) end)
|
||||||
|
|
||||||
@ -523,10 +523,10 @@ local function init(parent, id)
|
|||||||
|
|
||||||
-- enable/disable controls based on group assignment (start button is separate)
|
-- enable/disable controls based on group assignment (start button is separate)
|
||||||
burn_rate.register(u_ps, "auto_group_id", function (gid)
|
burn_rate.register(u_ps, "auto_group_id", function (gid)
|
||||||
if gid == 0 then burn_rate.enable() else burn_rate.disable() end
|
if gid == AUTO_GROUP.MANUAL then burn_rate.enable() else burn_rate.disable() end
|
||||||
end)
|
end)
|
||||||
set_burn_btn.register(u_ps, "auto_group_id", function (gid)
|
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
|
if gid == AUTO_GROUP.MANUAL then set_burn_btn.enable() else set_burn_btn.disable() end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- can't change group if auto is engaged regardless of if this unit is part of auto control
|
-- can't change group if auto is engaged regardless of if this unit is part of auto control
|
||||||
|
|||||||
@ -2,11 +2,10 @@
|
|||||||
-- I/O Control for Pocket Integration with Supervisor & Coordinator
|
-- I/O Control for Pocket Integration with Supervisor & Coordinator
|
||||||
--
|
--
|
||||||
|
|
||||||
local const = require("scada-common.constants")
|
local const = require("scada-common.constants")
|
||||||
-- local log = require("scada-common.log")
|
local psil = require("scada-common.psil")
|
||||||
local psil = require("scada-common.psil")
|
local types = require("scada-common.types")
|
||||||
local types = require("scada-common.types")
|
local util = require("scada-common.util")
|
||||||
local util = require("scada-common.util")
|
|
||||||
|
|
||||||
local process = require("pocket.process")
|
local process = require("pocket.process")
|
||||||
|
|
||||||
@ -22,8 +21,6 @@ local TEMP_UNITS = types.TEMP_SCALE_UNITS
|
|||||||
local WARN_TT = 40
|
local WARN_TT = 40
|
||||||
local HIGH_TT = 80
|
local HIGH_TT = 80
|
||||||
|
|
||||||
local GROUP_NAMES = { "Manual", "Primary", "Secondary", "Tertiary", "Backup" }
|
|
||||||
|
|
||||||
local iocontrol = {}
|
local iocontrol = {}
|
||||||
|
|
||||||
---@enum POCKET_LINK_STATE
|
---@enum POCKET_LINK_STATE
|
||||||
@ -318,7 +315,7 @@ function iocontrol.init_fac(conf)
|
|||||||
turbine_flow_stable = false,
|
turbine_flow_stable = false,
|
||||||
|
|
||||||
-- auto control group
|
-- auto control group
|
||||||
a_group = 0,
|
a_group = types.AUTO_GROUP.MANUAL,
|
||||||
|
|
||||||
start = function () process.start(i) end,
|
start = function () process.start(i) end,
|
||||||
scram = function () process.scram(i) end,
|
scram = function () process.scram(i) end,
|
||||||
@ -499,7 +496,7 @@ function iocontrol.record_unit_data(data)
|
|||||||
unit.alarms = data[5]
|
unit.alarms = data[5]
|
||||||
|
|
||||||
unit.unit_ps.publish("auto_group_id", unit.a_group)
|
unit.unit_ps.publish("auto_group_id", unit.a_group)
|
||||||
unit.unit_ps.publish("auto_group", GROUP_NAMES[unit.a_group + 1])
|
unit.unit_ps.publish("auto_group", types.AUTO_GROUP_NAMES[unit.a_group + 1])
|
||||||
|
|
||||||
--#region Annunciator
|
--#region Annunciator
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
-- Unit Control Page
|
-- Unit Control Page
|
||||||
--
|
--
|
||||||
|
|
||||||
|
local types = require("scada-common.types")
|
||||||
local util = require("scada-common.util")
|
local util = require("scada-common.util")
|
||||||
|
|
||||||
local iocontrol = require("pocket.iocontrol")
|
local iocontrol = require("pocket.iocontrol")
|
||||||
@ -26,6 +27,8 @@ local NumberField = require("graphics.elements.form.number_field")
|
|||||||
local DataIndicator = require("graphics.elements.indicators.data")
|
local DataIndicator = require("graphics.elements.indicators.data")
|
||||||
local IconIndicator = require("graphics.elements.indicators.icon")
|
local IconIndicator = require("graphics.elements.indicators.icon")
|
||||||
|
|
||||||
|
local AUTO_GROUP = types.AUTO_GROUP
|
||||||
|
|
||||||
local ALIGN = core.ALIGN
|
local ALIGN = core.ALIGN
|
||||||
local cpair = core.cpair
|
local cpair = core.cpair
|
||||||
|
|
||||||
@ -146,10 +149,10 @@ local function new_view(root)
|
|||||||
|
|
||||||
-- enable/disable controls based on group assignment (start button is separate)
|
-- enable/disable controls based on group assignment (start button is separate)
|
||||||
burn_cmd.register(u_ps, "auto_group_id", function (gid)
|
burn_cmd.register(u_ps, "auto_group_id", function (gid)
|
||||||
if gid == 0 then burn_cmd.enable() else burn_cmd.disable() end
|
if gid == AUTO_GROUP.MANUAL then burn_cmd.enable() else burn_cmd.disable() end
|
||||||
end)
|
end)
|
||||||
set_burn_btn.register(u_ps, "auto_group_id", function (gid)
|
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
|
if gid == AUTO_GROUP.MANUAL then set_burn_btn.enable() else set_burn_btn.disable() end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
burn_cmd.register(u_ps, "burn_rate", burn_cmd.set_value)
|
burn_cmd.register(u_ps, "burn_rate", burn_cmd.set_value)
|
||||||
@ -169,7 +172,7 @@ local function new_view(root)
|
|||||||
if (unit.reactor_data ~= nil) and (unit.reactor_data.mek_status ~= nil) then
|
if (unit.reactor_data ~= nil) and (unit.reactor_data.mek_status ~= nil) then
|
||||||
local can_start = (not unit.reactor_data.mek_status.status) and
|
local can_start = (not unit.reactor_data.mek_status.status) and
|
||||||
(not unit.reactor_data.rps_tripped) and
|
(not unit.reactor_data.rps_tripped) and
|
||||||
(unit.a_group == 0)
|
(unit.a_group == AUTO_GROUP.MANUAL)
|
||||||
if can_start then start.enable() else start.disable() end
|
if can_start then start.enable() else start.disable() end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -209,6 +209,23 @@ types.PROCESS_NAMES = {
|
|||||||
"GEN_RATE_FAULT_IDLE"
|
"GEN_RATE_FAULT_IDLE"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
---@enum AUTO_GROUP
|
||||||
|
types.AUTO_GROUP = {
|
||||||
|
MANUAL = 0,
|
||||||
|
PRIMARY = 1,
|
||||||
|
SECONDARY = 2,
|
||||||
|
TERTIARY = 3,
|
||||||
|
BACKUP = 4
|
||||||
|
}
|
||||||
|
|
||||||
|
types.AUTO_GROUP_NAMES = {
|
||||||
|
"Manual",
|
||||||
|
"Primary",
|
||||||
|
"Secondary",
|
||||||
|
"Tertiary",
|
||||||
|
"Backup"
|
||||||
|
}
|
||||||
|
|
||||||
---@enum WASTE_MODE
|
---@enum WASTE_MODE
|
||||||
types.WASTE_MODE = {
|
types.WASTE_MODE = {
|
||||||
AUTO = 1,
|
AUTO = 1,
|
||||||
|
|||||||
@ -8,6 +8,7 @@ local fac_update = require("supervisor.facility_update")
|
|||||||
local rsctl = require("supervisor.session.rsctl")
|
local rsctl = require("supervisor.session.rsctl")
|
||||||
local svsessions = require("supervisor.session.svsessions")
|
local svsessions = require("supervisor.session.svsessions")
|
||||||
|
|
||||||
|
local AUTO_GROUP = types.AUTO_GROUP
|
||||||
local PROCESS = types.PROCESS
|
local PROCESS = types.PROCESS
|
||||||
local RTU_ID_FAIL = types.RTU_ID_FAIL
|
local RTU_ID_FAIL = types.RTU_ID_FAIL
|
||||||
local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE
|
local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE
|
||||||
@ -73,7 +74,7 @@ function facility.new(config)
|
|||||||
burn_target = 0.1, -- burn rate target for aggregate burn mode
|
burn_target = 0.1, -- burn rate target for aggregate burn mode
|
||||||
charge_setpoint = 0, -- FE charge target setpoint
|
charge_setpoint = 0, -- FE charge target setpoint
|
||||||
gen_rate_setpoint = 0, -- FE/t charge rate target setpoint
|
gen_rate_setpoint = 0, -- FE/t charge rate target setpoint
|
||||||
group_map = {}, ---@type integer[] units -> group IDs
|
group_map = {}, ---@type AUTO_GROUP[] units -> group IDs
|
||||||
prio_defs = { {}, {}, {}, {} }, ---@type reactor_unit[][] priority definitions (each level is a table of units)
|
prio_defs = { {}, {}, {}, {} }, ---@type reactor_unit[][] priority definitions (each level is a table of units)
|
||||||
at_max_burn = false,
|
at_max_burn = false,
|
||||||
ascram = false,
|
ascram = false,
|
||||||
@ -130,7 +131,7 @@ function facility.new(config)
|
|||||||
for i = 1, config.UnitCount do
|
for i = 1, config.UnitCount do
|
||||||
table.insert(self.units,
|
table.insert(self.units,
|
||||||
unit.new(i, self.cooling_conf.r_cool[i].BoilerCount, self.cooling_conf.r_cool[i].TurbineCount, config.ExtChargeIdling))
|
unit.new(i, self.cooling_conf.r_cool[i].BoilerCount, self.cooling_conf.r_cool[i].TurbineCount, config.ExtChargeIdling))
|
||||||
table.insert(self.group_map, 0)
|
table.insert(self.group_map, AUTO_GROUP.MANUAL)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- list for RTU session management
|
-- list for RTU session management
|
||||||
@ -454,19 +455,19 @@ function facility.new(config)
|
|||||||
|
|
||||||
-- set the automatic control group of a unit
|
-- set the automatic control group of a unit
|
||||||
---@param unit_id integer unit ID
|
---@param unit_id integer unit ID
|
||||||
---@param group integer group ID or 0 for independent
|
---@param group AUTO_GROUP group ID or 0 for independent
|
||||||
function public.set_group(unit_id, group)
|
function public.set_group(unit_id, group)
|
||||||
if (group >= 0 and group <= 4) and (unit_id > 0 and unit_id <= config.UnitCount) and self.mode == PROCESS.INACTIVE then
|
if (group >= AUTO_GROUP.MANUAL and group <= AUTO_GROUP.BACKUP) and (unit_id > 0 and unit_id <= config.UnitCount) and self.mode == PROCESS.INACTIVE then
|
||||||
-- remove from old group if previously assigned
|
-- remove from old group if previously assigned
|
||||||
local old_group = self.group_map[unit_id]
|
local old_group = self.group_map[unit_id]
|
||||||
if old_group ~= 0 then
|
if old_group ~= AUTO_GROUP.MANUAL then
|
||||||
util.filter_table(self.prio_defs[old_group], function (u) return u.get_id() ~= unit_id end)
|
util.filter_table(self.prio_defs[old_group], function (u) return u.get_id() ~= unit_id end)
|
||||||
end
|
end
|
||||||
|
|
||||||
self.group_map[unit_id] = group
|
self.group_map[unit_id] = group
|
||||||
|
|
||||||
-- add to group if not independent
|
-- add to group if not independent
|
||||||
if group > 0 then
|
if group > AUTO_GROUP.MANUAL then
|
||||||
table.insert(self.prio_defs[group], self.units[unit_id])
|
table.insert(self.prio_defs[group], self.units[unit_id])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user