mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#53 RTU redstone parse checks
This commit is contained in:
parent
790571b6fc
commit
62d5490dc8
@ -103,6 +103,19 @@ for entry_idx = 1, #rtu_redstone do
|
||||
|
||||
log.debug("init> starting redstone RTU I/O linking for reactor " .. io_reactor .. "...")
|
||||
|
||||
local continue = true
|
||||
|
||||
for i = 1, #units do
|
||||
local unit = units[i] ---@type rtu_unit_registry_entry
|
||||
if unit.reactor == io_reactor and unit.type == rtu_t.redstone then
|
||||
-- duplicate entry
|
||||
log.warning("init> skipping definition block #" .. entry_idx .. " for reactor " .. io_reactor .. " with already defined redstone I/O")
|
||||
continue = false
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if continue then
|
||||
for i = 1, #io_table do
|
||||
local valid = false
|
||||
local conf = io_table[i]
|
||||
@ -125,11 +138,21 @@ for entry_idx = 1, #rtu_redstone do
|
||||
-- link redstone in RTU
|
||||
local mode = rsio.get_io_mode(conf.channel)
|
||||
if mode == rsio.IO_MODE.DIGITAL_IN then
|
||||
-- can't have duplicate inputs
|
||||
if util.table_contains(capabilities, conf.channel) then
|
||||
log.warning("init> skipping duplicate input for channel " .. rsio.to_string(conf.channel) .. " on side " .. conf.side)
|
||||
else
|
||||
rs_rtu.link_di(conf.side, conf.bundled_color)
|
||||
end
|
||||
elseif mode == rsio.IO_MODE.DIGITAL_OUT then
|
||||
rs_rtu.link_do(conf.channel, conf.side, conf.bundled_color)
|
||||
elseif mode == rsio.IO_MODE.ANALOG_IN then
|
||||
-- can't have duplicate inputs
|
||||
if util.table_contains(capabilities, conf.channel) then
|
||||
log.warning("init> skipping duplicate input for channel " .. rsio.to_string(conf.channel) .. " on side " .. conf.side)
|
||||
else
|
||||
rs_rtu.link_ai(conf.side)
|
||||
end
|
||||
elseif mode == rsio.IO_MODE.ANALOG_OUT then
|
||||
rs_rtu.link_ao(conf.side)
|
||||
else
|
||||
@ -162,6 +185,7 @@ for entry_idx = 1, #rtu_redstone do
|
||||
|
||||
log.debug("init> initialized RTU unit #" .. #units .. ": redstone_io (redstone) [1] for reactor " .. io_reactor)
|
||||
end
|
||||
end
|
||||
|
||||
-- mounted peripherals
|
||||
for i = 1, #rtu_devices do
|
||||
|
@ -107,6 +107,17 @@ util.filter_table = function (t, f, on_delete)
|
||||
end
|
||||
end
|
||||
|
||||
-- check if a table contains the provided element
|
||||
---@param t table table to check
|
||||
---@param element any element to check for
|
||||
util.table_contains = function (t, element)
|
||||
for i = 1, #t do
|
||||
if t[i] == element then return true end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
-- MEKANISM POWER --
|
||||
|
||||
-- function kFE(fe) return fe / 1000 end
|
||||
|
Loading…
Reference in New Issue
Block a user