mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#137 save/recall waste configuration with config file
This commit is contained in:
parent
8abac3fdcb
commit
e808ee2be0
@ -70,7 +70,9 @@ function coordinator.configure_monitors(num_units)
|
||||
end
|
||||
|
||||
-- attempt to load settings
|
||||
settings.load("/coord.settings")
|
||||
if not settings.load("/coord.settings") then
|
||||
log.warning("configure_monitors(): failed to load coordinator settings file (may not exist yet)")
|
||||
end
|
||||
|
||||
---------------------
|
||||
-- PRIMARY DISPLAY --
|
||||
@ -143,7 +145,9 @@ function coordinator.configure_monitors(num_units)
|
||||
end
|
||||
|
||||
settings.set("UNIT_DISPLAYS", unit_displays)
|
||||
settings.save("/coord.settings")
|
||||
if not settings.save("/coord.settings") then
|
||||
log.warning("configure_monitors(): failed to save coordinator settings file")
|
||||
end
|
||||
|
||||
for i = 1, #unit_displays do
|
||||
monitors.unit_displays[i] = ppm.get_periph(unit_displays[i])
|
||||
|
@ -23,6 +23,21 @@ local self = {
|
||||
function process.init(iocontrol, comms)
|
||||
self.io = iocontrol
|
||||
self.comms = comms
|
||||
|
||||
-- load settings
|
||||
if not settings.load("/coord.settings") then
|
||||
log.error("process.init(): failed to load coordinator settings file")
|
||||
end
|
||||
|
||||
local waste_mode = settings.get("WASTE_MODES") ---@type table|nil
|
||||
|
||||
if type(waste_mode) == "table" then
|
||||
for id = 1, math.min(#waste_mode, self.io.facility.num_units) do
|
||||
self.comms.send_unit_command(UNIT_COMMANDS.SET_WASTE, id, waste_mode[id])
|
||||
end
|
||||
|
||||
log.info("PROCESS: loaded waste mode settings from coord.settings")
|
||||
end
|
||||
end
|
||||
|
||||
-- start reactor
|
||||
@ -62,6 +77,20 @@ end
|
||||
function process.set_waste(id, mode)
|
||||
self.comms.send_command(UNIT_COMMANDS.SET_WASTE, id, mode)
|
||||
log.debug(util.c("UNIT[", id, "]: SET WASTE = ", mode))
|
||||
|
||||
local waste_mode = settings.get("WASTE_MODES") ---@type table|nil
|
||||
|
||||
if type(waste_mode) ~= "table" then
|
||||
waste_mode = {}
|
||||
end
|
||||
|
||||
waste_mode[id] = mode
|
||||
|
||||
settings.set("WASTE_MODES", waste_mode)
|
||||
|
||||
if not settings.save("/coord.settings") then
|
||||
log.error("process.set_waste(): failed to save coordinator settings file")
|
||||
end
|
||||
end
|
||||
|
||||
-- acknowledge all alarms
|
||||
|
@ -19,7 +19,7 @@ local iocontrol = require("coordinator.iocontrol")
|
||||
local renderer = require("coordinator.renderer")
|
||||
local sounder = require("coordinator.sounder")
|
||||
|
||||
local COORDINATOR_VERSION = "beta-v0.8.9"
|
||||
local COORDINATOR_VERSION = "beta-v0.8.10"
|
||||
|
||||
local print = util.print
|
||||
local println = util.println
|
||||
|
@ -322,6 +322,9 @@ function unit.new(for_reactor, num_boilers, num_turbines)
|
||||
---@param rs_unit unit_session
|
||||
function public.add_redstone(rs_unit)
|
||||
table.insert(self.redstone, rs_unit)
|
||||
|
||||
-- send or re-send waste settings
|
||||
public.set_waste(self.waste_mode)
|
||||
end
|
||||
|
||||
-- link a turbine RTU session
|
||||
|
@ -14,7 +14,7 @@ local svsessions = require("supervisor.session.svsessions")
|
||||
local config = require("supervisor.config")
|
||||
local supervisor = require("supervisor.supervisor")
|
||||
|
||||
local SUPERVISOR_VERSION = "beta-v0.9.5"
|
||||
local SUPERVISOR_VERSION = "beta-v0.9.6"
|
||||
|
||||
local print = util.print
|
||||
local println = util.println
|
||||
|
Loading…
Reference in New Issue
Block a user