mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#363 check config
This commit is contained in:
parent
03bbf8a891
commit
3406d12681
@ -10,6 +10,8 @@ local rsio = require("scada-common.rsio")
|
||||
local tcd = require("scada-common.tcd")
|
||||
local util = require("scada-common.util")
|
||||
|
||||
local plc = require("reactor-plc.plc")
|
||||
|
||||
local core = require("graphics.core")
|
||||
local themes = require("graphics.themes")
|
||||
|
||||
@ -270,7 +272,7 @@ local function config_view(display)
|
||||
TextBox{parent=main_page,x=2,y=2,height=2,text="Welcome to the Reactor PLC configurator! Please select one of the following options."}
|
||||
|
||||
if tool_ctl.ask_config then
|
||||
TextBox{parent=main_page,x=2,y=y_start,height=4,width=49,text="Notice: This device has no valid config so the configurator has been automatically started. If you previously had a valid config, you may want to check the Change Log to see what changed.",fg_bg=cpair(colors.red,colors.lightGray)}
|
||||
TextBox{parent=main_page,x=2,y=y_start,height=4,width=49,text="Notice: This device had no valid config so the configurator has been automatically started. If you previously had a valid config, you may want to check the Change Log to see what changed.",fg_bg=cpair(colors.red,colors.lightGray)}
|
||||
y_start = y_start + 5
|
||||
end
|
||||
|
||||
@ -803,6 +805,7 @@ local function config_view(display)
|
||||
|
||||
local modem = ppm.get_wireless_modem()
|
||||
local reactor = ppm.get_fission_reactor()
|
||||
local valid_cfg = plc.validate_config(settings_cfg)
|
||||
|
||||
tool_ctl.self_check_msg("> check wireless/ender modem connected...", modem ~= nil, "you must connect an ender or wireless modem to the reactor PLC")
|
||||
tool_ctl.self_check_msg("> check fission reactor connected...", reactor ~= nil, "please connect the reactor PLC to the reactor's fission reactor logic adapter")
|
||||
@ -810,7 +813,9 @@ local function config_view(display)
|
||||
-- this consumes events, but that is fine here
|
||||
tool_ctl.self_check_msg(nil, reactor and reactor.isFormed(), "ensure the fission reactor multiblock is formed")
|
||||
|
||||
if modem then
|
||||
tool_ctl.self_check_msg("> check configuration...", valid_cfg, "go through Configure System again and apply settings to repair any corrupted or missing settings")
|
||||
|
||||
if valid_cfg and modem then
|
||||
tool_ctl.self_check_msg("> check supervisor connection...")
|
||||
|
||||
tool_ctl.nic = network.nic(modem)
|
||||
|
@ -57,41 +57,47 @@ function plc.load_config()
|
||||
config.FrontPanelTheme = settings.get("FrontPanelTheme")
|
||||
config.ColorMode = settings.get("ColorMode")
|
||||
|
||||
return plc.validate_config(config)
|
||||
end
|
||||
|
||||
-- validate a PLC configuration
|
||||
---@param cfg plc_config
|
||||
function plc.validate_config(cfg)
|
||||
local cfv = util.new_validator()
|
||||
|
||||
cfv.assert_type_bool(config.Networked)
|
||||
cfv.assert_type_int(config.UnitID)
|
||||
cfv.assert_type_bool(config.EmerCoolEnable)
|
||||
cfv.assert_type_bool(cfg.Networked)
|
||||
cfv.assert_type_int(cfg.UnitID)
|
||||
cfv.assert_type_bool(cfg.EmerCoolEnable)
|
||||
|
||||
if config.Networked == true then
|
||||
cfv.assert_channel(config.SVR_Channel)
|
||||
cfv.assert_channel(config.PLC_Channel)
|
||||
cfv.assert_type_num(config.ConnTimeout)
|
||||
cfv.assert_min(config.ConnTimeout, 2)
|
||||
cfv.assert_type_num(config.TrustedRange)
|
||||
cfv.assert_min(config.TrustedRange, 0)
|
||||
cfv.assert_type_str(config.AuthKey)
|
||||
if cfg.Networked == true then
|
||||
cfv.assert_channel(cfg.SVR_Channel)
|
||||
cfv.assert_channel(cfg.PLC_Channel)
|
||||
cfv.assert_type_num(cfg.ConnTimeout)
|
||||
cfv.assert_min(cfg.ConnTimeout, 2)
|
||||
cfv.assert_type_num(cfg.TrustedRange)
|
||||
cfv.assert_min(cfg.TrustedRange, 0)
|
||||
cfv.assert_type_str(cfg.AuthKey)
|
||||
|
||||
if type(config.AuthKey) == "string" then
|
||||
local len = string.len(config.AuthKey)
|
||||
if type(cfg.AuthKey) == "string" then
|
||||
local len = string.len(cfg.AuthKey)
|
||||
cfv.assert(len == 0 or len >= 8)
|
||||
end
|
||||
end
|
||||
|
||||
cfv.assert_type_int(config.LogMode)
|
||||
cfv.assert_range(config.LogMode, 0, 1)
|
||||
cfv.assert_type_str(config.LogPath)
|
||||
cfv.assert_type_bool(config.LogDebug)
|
||||
cfv.assert_type_int(cfg.LogMode)
|
||||
cfv.assert_range(cfg.LogMode, 0, 1)
|
||||
cfv.assert_type_str(cfg.LogPath)
|
||||
cfv.assert_type_bool(cfg.LogDebug)
|
||||
|
||||
cfv.assert_type_int(config.FrontPanelTheme)
|
||||
cfv.assert_range(config.FrontPanelTheme, 1, 2)
|
||||
cfv.assert_type_int(config.ColorMode)
|
||||
cfv.assert_range(config.ColorMode, 1, themes.COLOR_MODE.NUM_MODES)
|
||||
cfv.assert_type_int(cfg.FrontPanelTheme)
|
||||
cfv.assert_range(cfg.FrontPanelTheme, 1, 2)
|
||||
cfv.assert_type_int(cfg.ColorMode)
|
||||
cfv.assert_range(cfg.ColorMode, 1, themes.COLOR_MODE.NUM_MODES)
|
||||
|
||||
-- check emergency coolant configuration if enabled
|
||||
if config.EmerCoolEnable then
|
||||
cfv.assert_eq(rsio.is_valid_side(config.EmerCoolSide), true)
|
||||
cfv.assert_eq(config.EmerCoolColor == nil or rsio.is_color(config.EmerCoolColor), true)
|
||||
if cfg.EmerCoolEnable then
|
||||
cfv.assert_eq(rsio.is_valid_side(cfg.EmerCoolSide), true)
|
||||
cfv.assert_eq(cfg.EmerCoolColor == nil or rsio.is_color(cfg.EmerCoolColor), true)
|
||||
end
|
||||
|
||||
return cfv.valid()
|
||||
|
Loading…
Reference in New Issue
Block a user