diff --git a/rtu/config/check.lua b/rtu/config/check.lua index 6818ba6..bc3f6d5 100644 --- a/rtu/config/check.lua +++ b/rtu/config/check.lua @@ -136,22 +136,45 @@ local function self_check() self.self_check_msg("> check gateway configuration...", valid_cfg, "go through Configure Gateway and apply settings to set any missing settings and repair any corrupted ones") -- check redstone configurations - local ifaces = {} - local bundled_sides = {} + + local phys = {} ---@type rtu_rs_definition[][] + local inputs = { [0] = {}, {}, {}, {}, {} } + for i = 1, #cfg.Redstone do local entry = cfg.Redstone[i] - local ident = entry.side .. tri(entry.color, ":" .. rsio.color_name(entry.color), "") - local dupe = util.table_contains(ifaces, ident) - local mixed = (bundled_sides[entry.side] and (entry.color == nil)) or (bundled_sides[entry.side] == false and (entry.color ~= nil)) + local name = entry.relay or "local" - local mixed_msg = util.trinary(bundled_sides[entry.side], "bundled entry(s) but this entry is not", "non-bundled entry(s) but this entry is") + if phys[name] == nil then phys[name] = {} end + table.insert(phys[entry.relay or "local"], entry) + end - self.self_check_msg("> check redstone " .. ident .. " unique...", not dupe, "only one port should be set to a side/color combination") - self.self_check_msg("> check redstone " .. ident .. " bundle...", not mixed, "this side has " .. mixed_msg .. " bundled, which will not work") - self.self_check_msg("> check redstone " .. ident .. " valid...", redstone.validate(entry), "configuration invalid, please re-configure redstone entry") + for name, entries in pairs(phys) do + TextBox{parent=self.sc_log,text="> checking redstone @ "..name.."...",fg_bg=cpair(colors.blue,colors.white)} - bundled_sides[entry.side] = bundled_sides[entry.side] or entry.color ~= nil - table.insert(ifaces, ident) + local ifaces = {} + local bundled_sides = {} + + for i = 1, #entries do + local entry = entries[i] + local ident = entry.side .. tri(entry.color, ":" .. rsio.color_name(entry.color), "") + + local sc_dupe = util.table_contains(ifaces, ident) + local mixed = (bundled_sides[entry.side] and (entry.color == nil)) or (bundled_sides[entry.side] == false and (entry.color ~= nil)) + + local mixed_msg = util.trinary(bundled_sides[entry.side], "bundled entry(s) but this entry is not", "non-bundled entry(s) but this entry is") + + self.self_check_msg("> check redstone " .. ident .. " unique...", not sc_dupe, "only one port should be set to a side/color combination") + self.self_check_msg("> check redstone " .. ident .. " bundle...", not mixed, "this side has " .. mixed_msg .. " bundled, which will not work") + self.self_check_msg("> check redstone " .. ident .. " valid...", redstone.validate(entry), "configuration invalid, please re-configure redstone entry") + + if rsio.get_io_dir(entry.port) == rsio.IO_DIR.IN then + local in_dupe = util.table_contains(inputs[entry.unit or 0], entry.port) + self.self_check_msg("> check redstone " .. ident .. " input...", not in_dupe, "you cannot have multiple of the same input for a given unit or the facility ("..rsio.to_string(entry.port)..")") + end + + bundled_sides[entry.side] = bundled_sides[entry.side] or entry.color ~= nil + table.insert(ifaces, ident) + end end -- check peripheral configurations @@ -245,7 +268,7 @@ function check.create(main_pane, settings_cfg, check_sys, style) TextBox{parent=check_sys,x=1,y=2,text=" RTU Gateway Self-Check",fg_bg=bw_fg_bg} - self.sc_log = ListBox{parent=sc,x=1,y=1,height=12,width=49,scroll_height=500,fg_bg=bw_fg_bg,nav_fg_bg=g_lg_fg_bg,nav_active=cpair(colors.black,colors.gray)} + self.sc_log = ListBox{parent=sc,x=1,y=1,height=12,width=49,scroll_height=1000,fg_bg=bw_fg_bg,nav_fg_bg=g_lg_fg_bg,nav_active=cpair(colors.black,colors.gray)} local last_check = { nil, nil } diff --git a/rtu/configure.lua b/rtu/configure.lua index 380f4ca..eea6072 100644 --- a/rtu/configure.lua +++ b/rtu/configure.lua @@ -36,7 +36,8 @@ local changes = { { "v1.7.15", { "Added front panel UI theme", "Added color accessibility modes" } }, { "v1.9.2", { "Added standard with black off state color mode", "Added blue indicator color modes" } }, { "v1.10.2", { "Re-organized peripheral configuration UI, resulting in some input fields being re-ordered" } }, - { "v1.11.8", { "Added advanced option to invert digital redstone signals" } } + { "v1.11.8", { "Added advanced option to invert digital redstone signals" } }, + { "v1.12.0", { "Added support for redstone relays" } } } ---@class rtu_configurator diff --git a/rtu/startup.lua b/rtu/startup.lua index 8ac188c..314c2c7 100644 --- a/rtu/startup.lua +++ b/rtu/startup.lua @@ -31,7 +31,7 @@ local sna_rtu = require("rtu.dev.sna_rtu") local sps_rtu = require("rtu.dev.sps_rtu") local turbinev_rtu = require("rtu.dev.turbinev_rtu") -local RTU_VERSION = "v1.11.8" +local RTU_VERSION = "v1.12.0" local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE local RTU_HW_STATE = databus.RTU_HW_STATE @@ -152,7 +152,7 @@ local function main() --#region Redstone Interfaces local rs_rtus = {} ---@type { name: string, rtu: rtu_rs_device, phy: table, banks: rtu_rs_definition[][] }[] - local all_conns = {} + local all_conns = { [0] = {}, {}, {}, {}, {} } -- go through redstone definitions list for entry_idx = 1, #rtu_redstone do @@ -197,11 +197,11 @@ local function main() log.warning(util.c("sys_config> redstone relay ", entry.relay, " is not a redstone relay")) end - rs_rtus[entry.relay] = { name = entry.relay, rtu = redstone_rtu.new(relay), phy = relay, banks = {} } + rs_rtus[entry.relay] = { name = entry.relay, rtu = redstone_rtu.new(relay), phy = relay, banks = { [0] = {}, {}, {}, {}, {} } } end elseif rs_rtus[0] == nil then log.debug(util.c("sys_config> allocated local redstone RTU")) - rs_rtus[0] = { name = "redstone_local", rtu = redstone_rtu.new(), phy = rs, banks = {} } + rs_rtus[0] = { name = "redstone_local", rtu = redstone_rtu.new(), phy = rs, banks = { [0] = {}, {}, {}, {}, {} } } end -- verify configuration