mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#371 fixed RTU configurator bug with empty peripherals or redstone, re-ordered settings load, added type checks
This commit is contained in:
parent
1fdf012f65
commit
a048b0aa4a
@ -463,8 +463,8 @@ local function config_view(display)
|
|||||||
for k, v in pairs(tmp_cfg) do settings.set(k, v) end
|
for k, v in pairs(tmp_cfg) do settings.set(k, v) end
|
||||||
|
|
||||||
if settings.save("reactor-plc.settings") then
|
if settings.save("reactor-plc.settings") then
|
||||||
load_settings(ini_cfg)
|
|
||||||
load_settings(settings_cfg, true)
|
load_settings(settings_cfg, true)
|
||||||
|
load_settings(ini_cfg)
|
||||||
|
|
||||||
try_set(networked, ini_cfg.Networked)
|
try_set(networked, ini_cfg.Networked)
|
||||||
try_set(u_id, ini_cfg.UnitID)
|
try_set(u_id, ini_cfg.UnitID)
|
||||||
@ -648,8 +648,9 @@ end
|
|||||||
---@param ask_config? boolean indicate if this is being called by the PLC startup app due to an invalid configuration
|
---@param ask_config? boolean indicate if this is being called by the PLC startup app due to an invalid configuration
|
||||||
function configurator.configure(ask_config)
|
function configurator.configure(ask_config)
|
||||||
tool_ctl.ask_config = ask_config == true
|
tool_ctl.ask_config = ask_config == true
|
||||||
tool_ctl.has_config = load_settings(ini_cfg)
|
|
||||||
load_settings(settings_cfg, true)
|
load_settings(settings_cfg, true)
|
||||||
|
tool_ctl.has_config = load_settings(ini_cfg)
|
||||||
|
|
||||||
reset_term()
|
reset_term()
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ local plc = require("reactor-plc.plc")
|
|||||||
local renderer = require("reactor-plc.renderer")
|
local renderer = require("reactor-plc.renderer")
|
||||||
local threads = require("reactor-plc.threads")
|
local threads = require("reactor-plc.threads")
|
||||||
|
|
||||||
local R_PLC_VERSION = "v1.6.4"
|
local R_PLC_VERSION = "v1.6.5"
|
||||||
|
|
||||||
local println = util.println
|
local println = util.println
|
||||||
local println_ts = util.println_ts
|
local println_ts = util.println_ts
|
||||||
|
@ -531,9 +531,13 @@ local function config_view(display)
|
|||||||
if not (exclude_conns and (k == "Peripherals" or k == "Redstone")) then settings.set(k, v) end
|
if not (exclude_conns and (k == "Peripherals" or k == "Redstone")) then settings.set(k, v) end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- always set these if missing
|
||||||
|
if settings.get("Peripherals") == nil then settings.set("Peripherals", {}) end
|
||||||
|
if settings.get("Redstone") == nil then settings.set("Redstone", {}) end
|
||||||
|
|
||||||
if settings.save("rtu.settings") then
|
if settings.save("rtu.settings") then
|
||||||
load_settings(ini_cfg)
|
|
||||||
load_settings(settings_cfg, true)
|
load_settings(settings_cfg, true)
|
||||||
|
load_settings(ini_cfg)
|
||||||
|
|
||||||
try_set(s_vol, ini_cfg.SpeakerVolume)
|
try_set(s_vol, ini_cfg.SpeakerVolume)
|
||||||
try_set(svr_chan, ini_cfg.SVR_Channel)
|
try_set(svr_chan, ini_cfg.SVR_Channel)
|
||||||
@ -582,8 +586,8 @@ local function config_view(display)
|
|||||||
PushButton{parent=sum_c_3,x=43,y=14,min_width=7,text="Apply",callback=save_and_continue,fg_bg=cpair(colors.black,colors.green),active_fg_bg=btn_act_fg_bg}
|
PushButton{parent=sum_c_3,x=43,y=14,min_width=7,text="Apply",callback=save_and_continue,fg_bg=cpair(colors.black,colors.green),active_fg_bg=btn_act_fg_bg}
|
||||||
|
|
||||||
TextBox{parent=sum_c_4,x=1,y=1,height=1,text="Settings saved!"}
|
TextBox{parent=sum_c_4,x=1,y=1,height=1,text="Settings saved!"}
|
||||||
PushButton{parent=sum_c_4,x=1,y=14,min_width=6,text="Home",callback=function()tool_ctl.go_home()end,fg_bg=nav_fg_bg,active_fg_bg=btn_act_fg_bg}
|
PushButton{parent=sum_c_4,x=1,y=14,min_width=6,text="Exit",callback=exit,fg_bg=cpair(colors.black,colors.red),active_fg_bg=cpair(colors.white,colors.gray)}
|
||||||
PushButton{parent=sum_c_4,x=44,y=14,min_width=6,text="Exit",callback=exit,fg_bg=cpair(colors.black,colors.red),active_fg_bg=cpair(colors.white,colors.gray)}
|
PushButton{parent=sum_c_4,x=44,y=14,min_width=6,text="Home",callback=function()tool_ctl.go_home()end,fg_bg=nav_fg_bg,active_fg_bg=btn_act_fg_bg}
|
||||||
|
|
||||||
TextBox{parent=sum_c_5,x=1,y=1,height=2,text="The old config.lua file will now be deleted, then the configurator will exit."}
|
TextBox{parent=sum_c_5,x=1,y=1,height=2,text="The old config.lua file will now be deleted, then the configurator will exit."}
|
||||||
|
|
||||||
@ -652,8 +656,8 @@ local function config_view(display)
|
|||||||
settings.set("Peripherals", tmp_cfg.Peripherals)
|
settings.set("Peripherals", tmp_cfg.Peripherals)
|
||||||
|
|
||||||
if settings.save("rtu.settings") then
|
if settings.save("rtu.settings") then
|
||||||
load_settings(ini_cfg)
|
|
||||||
load_settings(settings_cfg, true)
|
load_settings(settings_cfg, true)
|
||||||
|
load_settings(ini_cfg)
|
||||||
peri_pane.set_value(5)
|
peri_pane.set_value(5)
|
||||||
else
|
else
|
||||||
peri_pane.set_value(6)
|
peri_pane.set_value(6)
|
||||||
@ -958,8 +962,8 @@ local function config_view(display)
|
|||||||
settings.set("Redstone", tmp_cfg.Redstone)
|
settings.set("Redstone", tmp_cfg.Redstone)
|
||||||
|
|
||||||
if settings.save("rtu.settings") then
|
if settings.save("rtu.settings") then
|
||||||
load_settings(ini_cfg)
|
|
||||||
load_settings(settings_cfg, true)
|
load_settings(settings_cfg, true)
|
||||||
|
load_settings(ini_cfg)
|
||||||
rs_pane.set_value(4)
|
rs_pane.set_value(4)
|
||||||
else
|
else
|
||||||
rs_pane.set_value(5)
|
rs_pane.set_value(5)
|
||||||
@ -1445,9 +1449,9 @@ end
|
|||||||
---@param ask_config? boolean indicate if this is being called by the RTU startup app due to an invalid configuration
|
---@param ask_config? boolean indicate if this is being called by the RTU startup app due to an invalid configuration
|
||||||
function configurator.configure(ask_config)
|
function configurator.configure(ask_config)
|
||||||
tool_ctl.ask_config = ask_config == true
|
tool_ctl.ask_config = ask_config == true
|
||||||
tool_ctl.has_config = load_settings(ini_cfg)
|
|
||||||
load_settings(settings_cfg, true)
|
|
||||||
|
|
||||||
|
load_settings(settings_cfg, true)
|
||||||
|
tool_ctl.has_config = load_settings(ini_cfg)
|
||||||
tmp_cfg.Peripherals = deep_copy_peri(ini_cfg.Peripherals)
|
tmp_cfg.Peripherals = deep_copy_peri(ini_cfg.Peripherals)
|
||||||
tmp_cfg.Redstone = deep_copy_rs(ini_cfg.Redstone)
|
tmp_cfg.Redstone = deep_copy_rs(ini_cfg.Redstone)
|
||||||
|
|
||||||
|
@ -58,6 +58,9 @@ function rtu.load_config()
|
|||||||
cfv.assert_type_str(config.LogPath)
|
cfv.assert_type_str(config.LogPath)
|
||||||
cfv.assert_type_bool(config.LogDebug)
|
cfv.assert_type_bool(config.LogDebug)
|
||||||
|
|
||||||
|
cfv.assert_type_table(config.Peripherals)
|
||||||
|
cfv.assert_type_table(config.Redstone)
|
||||||
|
|
||||||
return cfv.valid()
|
return cfv.valid()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ local sna_rtu = require("rtu.dev.sna_rtu")
|
|||||||
local sps_rtu = require("rtu.dev.sps_rtu")
|
local sps_rtu = require("rtu.dev.sps_rtu")
|
||||||
local turbinev_rtu = require("rtu.dev.turbinev_rtu")
|
local turbinev_rtu = require("rtu.dev.turbinev_rtu")
|
||||||
|
|
||||||
local RTU_VERSION = "v1.7.2"
|
local RTU_VERSION = "v1.7.3"
|
||||||
|
|
||||||
local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE
|
local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE
|
||||||
local RTU_UNIT_HW_STATE = databus.RTU_UNIT_HW_STATE
|
local RTU_UNIT_HW_STATE = databus.RTU_UNIT_HW_STATE
|
||||||
|
Loading…
Reference in New Issue
Block a user