#118 coordinator code cleanup

This commit is contained in:
Mikayla Fischler
2023-02-22 23:09:47 -05:00
parent 79494f0587
commit 4340518ecf
18 changed files with 484 additions and 435 deletions

View File

@@ -13,6 +13,7 @@ local cpair = core.graphics.cpair
local border = core.graphics.border
-- new boiler view
---@nodiscard
---@param root graphics_element parent
---@param x integer top left x
---@param y integer top left y

View File

@@ -19,6 +19,7 @@ local border = core.graphics.border
local TEXT_ALIGN = core.graphics.TEXT_ALIGN
-- new induction matrix view
---@nodiscard
---@param root graphics_element parent
---@param x integer top left x
---@param y integer top left y

View File

@@ -16,11 +16,8 @@ local DataIndicator = require("graphics.elements.indicators.data")
local IndicatorLight = require("graphics.elements.indicators.light")
local RadIndicator = require("graphics.elements.indicators.rad")
local TriIndicatorLight = require("graphics.elements.indicators.trilight")
local VerticalBar = require("graphics.elements.indicators.vbar")
local HazardButton = require("graphics.elements.controls.hazard_button")
local MultiButton = require("graphics.elements.controls.multi_button")
local PushButton = require("graphics.elements.controls.push_button")
local RadioButton = require("graphics.elements.controls.radio_button")
local SpinboxNumeric = require("graphics.elements.controls.spinbox_numeric")
@@ -32,6 +29,7 @@ local border = core.graphics.border
local period = core.flasher.PERIOD
-- new process control view
---@nodiscard
---@param root graphics_element parent
---@param x integer top left x
---@param y integer top left y

View File

@@ -1,3 +1,5 @@
local types = require("scada-common.types")
local style = require("coordinator.ui.style")
local core = require("graphics.core")
@@ -13,6 +15,7 @@ local cpair = core.graphics.cpair
local border = core.graphics.border
-- create new reactor view
---@nodiscard
---@param root graphics_element parent
---@param x integer top left x
---@param y integer top left y
@@ -47,7 +50,7 @@ local function new_view(root, x, y, data, ps)
local waste = HorizontalBar{parent=reactor_fills,x=8,y=5,show_percent=true,bar_fg_bg=cpair(colors.brown,colors.gray),height=1,width=14}
ps.subscribe("ccool_type", function (type)
if type == "mekanism:sodium" then
if type == types.FLUID.SODIUM then
ccool.recolor(cpair(colors.lightBlue, colors.gray))
else
ccool.recolor(cpair(colors.blue, colors.gray))
@@ -55,7 +58,7 @@ local function new_view(root, x, y, data, ps)
end)
ps.subscribe("hcool_type", function (type)
if type == "mekanism:superheated_sodium" then
if type == types.FLUID.SUPERHEATED_SODIUM then
hcool.recolor(cpair(colors.orange, colors.gray))
else
hcool.recolor(cpair(colors.white, colors.gray))

View File

@@ -15,6 +15,7 @@ local cpair = core.graphics.cpair
local border = core.graphics.border
-- new turbine view
---@nodiscard
---@param root graphics_element parent
---@param x integer top left x
---@param y integer top left y

View File

@@ -57,6 +57,7 @@ local waste_opts = {
}
-- create a unit view
---@nodiscard
---@param parent graphics_element parent
---@param id integer
local function init(parent, id)
@@ -237,13 +238,13 @@ local function init(parent, id)
local rcs_annunc = Div{parent=rcs,width=27,height=22,x=2,y=1}
local rcs_tags = Div{parent=rcs,width=2,height=13,x=29,y=9}
local c_flt = IndicatorLight{parent=rcs_annunc,label="RCS Hardware Fault",colors=cpair(colors.yellow,colors.gray)}
local c_emg = TriIndicatorLight{parent=rcs_annunc,label="Emergency Coolant",c1=colors.gray,c2=colors.white,c3=colors.yellow}
local c_cfm = IndicatorLight{parent=rcs_annunc,label="Coolant Feed Mismatch",colors=cpair(colors.yellow,colors.gray)}
local c_brm = IndicatorLight{parent=rcs_annunc,label="Boil Rate Mismatch",colors=cpair(colors.yellow,colors.gray)}
local c_sfm = IndicatorLight{parent=rcs_annunc,label="Steam Feed Mismatch",colors=cpair(colors.yellow,colors.gray)}
local c_mwrf = IndicatorLight{parent=rcs_annunc,label="Max Water Return Feed",colors=cpair(colors.yellow,colors.gray)}
local c_tbnt = IndicatorLight{parent=rcs_annunc,label="Turbine Trip",colors=cpair(colors.red,colors.gray),flash=true,period=period.BLINK_250_MS}
local c_flt = IndicatorLight{parent=rcs_annunc,label="RCS Hardware Fault",colors=cpair(colors.yellow,colors.gray)}
local c_emg = TriIndicatorLight{parent=rcs_annunc,label="Emergency Coolant",c1=colors.gray,c2=colors.white,c3=colors.yellow}
local c_cfm = IndicatorLight{parent=rcs_annunc,label="Coolant Feed Mismatch",colors=cpair(colors.yellow,colors.gray)}
local c_brm = IndicatorLight{parent=rcs_annunc,label="Boil Rate Mismatch",colors=cpair(colors.yellow,colors.gray)}
local c_sfm = IndicatorLight{parent=rcs_annunc,label="Steam Feed Mismatch",colors=cpair(colors.yellow,colors.gray)}
local c_mwrf = IndicatorLight{parent=rcs_annunc,label="Max Water Return Feed",colors=cpair(colors.yellow,colors.gray)}
local c_tbnt = IndicatorLight{parent=rcs_annunc,label="Turbine Trip",colors=cpair(colors.red,colors.gray),flash=true,period=period.BLINK_250_MS}
u_ps.subscribe("RCSFault", c_flt.update)
u_ps.subscribe("EmergencyCoolant", c_emg.update)

View File

@@ -19,6 +19,7 @@ local TEXT_ALIGN = core.graphics.TEXT_ALIGN
local pipe = core.graphics.pipe
-- make a new unit overview window
---@nodiscard
---@param parent graphics_element parent
---@param x integer top left x
---@param y integer top left y
@@ -51,7 +52,7 @@ local function make(parent, x, y, unit)
-- REACTOR --
-------------
reactor_view(root, 1, 3, unit.reactor_data, unit.unit_ps)
local _ = reactor_view(root, 1, 3, unit.reactor_data, unit.unit_ps)
if num_boilers > 0 then
local coolant_pipes = {}
@@ -101,16 +102,16 @@ local function make(parent, x, y, unit)
local steam_pipes_b = {}
if no_boilers then
table.insert(steam_pipes_b, pipe(0, 1, 3, 1, colors.white)) -- steam to turbine 1
table.insert(steam_pipes_b, pipe(0, 2, 3, 2, colors.blue)) -- water to turbine 1
table.insert(steam_pipes_b, pipe(0, 1, 3, 1, colors.white)) -- steam to turbine 1
table.insert(steam_pipes_b, pipe(0, 2, 3, 2, colors.blue)) -- water to turbine 1
if num_turbines >= 2 then
table.insert(steam_pipes_b, pipe(1, 2, 3, 9, colors.white)) -- steam to turbine 2
table.insert(steam_pipes_b, pipe(2, 3, 3, 10, colors.blue)) -- water to turbine 2
table.insert(steam_pipes_b, pipe(1, 2, 3, 9, colors.white)) -- steam to turbine 2
table.insert(steam_pipes_b, pipe(2, 3, 3, 10, colors.blue)) -- water to turbine 2
end
if num_turbines >= 3 then
table.insert(steam_pipes_b, pipe(1, 9, 3, 17, colors.white)) -- steam boiler 1 to turbine 1 junction end
table.insert(steam_pipes_b, pipe(1, 9, 3, 17, colors.white)) -- steam boiler 1 to turbine 1 junction end
table.insert(steam_pipes_b, pipe(2, 10, 3, 18, colors.blue)) -- water boiler 1 to turbine 1 junction start
end
else

View File

@@ -1,5 +1,5 @@
--
-- Reactor Unit SCADA Coordinator GUI
-- Reactor Unit Waiting Spinner
--
local style = require("coordinator.ui.style")
@@ -16,6 +16,7 @@ local TEXT_ALIGN = core.graphics.TEXT_ALIGN
local cpair = core.graphics.cpair
-- create a unit waiting view
---@nodiscard
---@param parent graphics_element parent
---@param y integer y offset
local function init(parent, y)

View File

@@ -3,13 +3,11 @@ local completion = require("cc.completion")
local util = require("scada-common.util")
local print = util.print
local println = util.println
local print_ts = util.print_ts
local println_ts = util.println_ts
local dialog = {}
-- ask the user yes or no
---@nodiscard
---@param question string
---@param default boolean
---@return boolean|nil
@@ -36,6 +34,7 @@ function dialog.ask_y_n(question, default)
end
-- ask the user for an input within a set of options
---@nodiscard
---@param options table
---@param cancel string
---@return boolean|string|nil

View File

@@ -30,6 +30,7 @@ local TEXT_ALIGN = core.graphics.TEXT_ALIGN
local cpair = core.graphics.cpair
-- create new main view
---@nodiscard
---@param monitor table main viewscreen
local function init(monitor)
local facility = iocontrol.get_db().facility
@@ -77,7 +78,7 @@ local function init(monitor)
end
end
-- command & control
-- command & control
cnc_y_start = cnc_y_start
@@ -90,7 +91,7 @@ local function init(monitor)
cnc_bottom_align_start = cnc_bottom_align_start + 2
local process = process_ctl(main, 2, cnc_bottom_align_start)
local _ = process_ctl(main, 2, cnc_bottom_align_start)
-- testing
---@fixme remove test code
@@ -123,7 +124,7 @@ local function init(monitor)
SwitchButton{parent=audio,x=1,text="RCS TRANSIENT",min_width=23,fg_bg=cpair(colors.black,colors.yellow),active_fg_bg=cpair(colors.white,colors.gray),callback=sounder.test_rcs}
SwitchButton{parent=audio,x=1,text="TURBINE TRIP",min_width=23,fg_bg=cpair(colors.black,colors.yellow),active_fg_bg=cpair(colors.white,colors.gray),callback=sounder.test_turbinet}
local imatrix_1 = imatrix(main, 131, cnc_bottom_align_start, facility.induction_data_tbl[1], facility.induction_ps_tbl[1])
local _ = imatrix(main, 131, cnc_bottom_align_start, facility.induction_data_tbl[1], facility.induction_ps_tbl[1])
return main
end

View File

@@ -9,12 +9,13 @@ local unit_detail = require("coordinator.ui.components.unit_detail")
local DisplayBox = require("graphics.elements.displaybox")
-- create a unit view
---@nodiscard
---@param monitor table
---@param id integer
local function init(monitor, id)
local main = DisplayBox{window=monitor,fg_bg=style.root}
unit_detail(main, id)
local _ = unit_detail(main, id)
return main
end