mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
RTU bugfixes, adjusted comms sleep timer
This commit is contained in:
parent
533d398f9d
commit
bc6453de2b
@ -45,7 +45,7 @@ rtu.init_unit = function ()
|
|||||||
-- return IO count
|
-- return IO count
|
||||||
---@return integer discrete_inputs, integer coils, integer input_regs, integer holding_regs
|
---@return integer discrete_inputs, integer coils, integer input_regs, integer holding_regs
|
||||||
public.io_count = function ()
|
public.io_count = function ()
|
||||||
return self.io_count_cache[0], self.io_count_cache[1], self.io_count_cache[2], self.io_count_cache[3]
|
return self.io_count_cache[1], self.io_count_cache[2], self.io_count_cache[3], self.io_count_cache[4]
|
||||||
end
|
end
|
||||||
|
|
||||||
-- discrete inputs: single bit read-only
|
-- discrete inputs: single bit read-only
|
||||||
|
@ -24,7 +24,7 @@ local imatrix_rtu = require("rtu.dev.imatrix_rtu")
|
|||||||
local turbine_rtu = require("rtu.dev.turbine_rtu")
|
local turbine_rtu = require("rtu.dev.turbine_rtu")
|
||||||
local turbinev_rtu = require("rtu.dev.turbinev_rtu")
|
local turbinev_rtu = require("rtu.dev.turbinev_rtu")
|
||||||
|
|
||||||
local RTU_VERSION = "alpha-v0.6.4"
|
local RTU_VERSION = "alpha-v0.6.5"
|
||||||
|
|
||||||
local rtu_t = types.rtu_t
|
local rtu_t = types.rtu_t
|
||||||
|
|
||||||
@ -94,13 +94,14 @@ local rtu_redstone = config.RTU_REDSTONE
|
|||||||
local rtu_devices = config.RTU_DEVICES
|
local rtu_devices = config.RTU_DEVICES
|
||||||
|
|
||||||
-- redstone interfaces
|
-- redstone interfaces
|
||||||
for reactor_idx = 1, #rtu_redstone do
|
for entry_idx = 1, #rtu_redstone do
|
||||||
local rs_rtu = redstone_rtu.new()
|
local rs_rtu = redstone_rtu.new()
|
||||||
local io_table = rtu_redstone[reactor_idx].io
|
local io_table = rtu_redstone[entry_idx].io
|
||||||
|
local io_reactor = rtu_redstone[entry_idx].for_reactor
|
||||||
|
|
||||||
local capabilities = {}
|
local capabilities = {}
|
||||||
|
|
||||||
log.debug("init> starting redstone RTU I/O linking for reactor " .. rtu_redstone[reactor_idx].for_reactor .. "...")
|
log.debug("init> starting redstone RTU I/O linking for reactor " .. io_reactor .. "...")
|
||||||
|
|
||||||
for i = 1, #io_table do
|
for i = 1, #io_table do
|
||||||
local valid = false
|
local valid = false
|
||||||
@ -116,8 +117,8 @@ for reactor_idx = 1, #rtu_redstone do
|
|||||||
end
|
end
|
||||||
|
|
||||||
if not valid then
|
if not valid then
|
||||||
local message = "init> invalid redstone definition at index " .. i .. " in definition block #" .. reactor_idx ..
|
local message = "init> invalid redstone definition at index " .. i .. " in definition block #" .. entry_idx ..
|
||||||
" (for reactor " .. rtu_redstone[reactor_idx].for_reactor .. ")"
|
" (for reactor " .. io_reactor .. ")"
|
||||||
println_ts(message)
|
println_ts(message)
|
||||||
log.warning(message)
|
log.warning(message)
|
||||||
else
|
else
|
||||||
@ -140,7 +141,7 @@ for reactor_idx = 1, #rtu_redstone do
|
|||||||
table.insert(capabilities, conf.channel)
|
table.insert(capabilities, conf.channel)
|
||||||
|
|
||||||
log.debug("init> linked redstone " .. #capabilities .. ": " .. rsio.to_string(conf.channel) .. " (" .. conf.side ..
|
log.debug("init> linked redstone " .. #capabilities .. ": " .. rsio.to_string(conf.channel) .. " (" .. conf.side ..
|
||||||
") for reactor " .. rtu_redstone[reactor_idx].for_reactor)
|
") for reactor " .. io_reactor)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -148,8 +149,8 @@ for reactor_idx = 1, #rtu_redstone do
|
|||||||
local unit = {
|
local unit = {
|
||||||
name = "redstone_io",
|
name = "redstone_io",
|
||||||
type = rtu_t.redstone,
|
type = rtu_t.redstone,
|
||||||
index = 1,
|
index = entry_idx,
|
||||||
reactor = rtu_redstone[reactor_idx].for_reactor,
|
reactor = io_reactor,
|
||||||
device = capabilities, -- use device field for redstone channels
|
device = capabilities, -- use device field for redstone channels
|
||||||
rtu = rs_rtu,
|
rtu = rs_rtu,
|
||||||
modbus_io = modbus.new(rs_rtu, false),
|
modbus_io = modbus.new(rs_rtu, false),
|
||||||
@ -160,7 +161,7 @@ for reactor_idx = 1, #rtu_redstone do
|
|||||||
|
|
||||||
table.insert(units, unit)
|
table.insert(units, unit)
|
||||||
|
|
||||||
log.debug("init> initialized RTU unit #" .. #units .. ": redstone_io (redstone) [1] for reactor " .. rtu_redstone[reactor_idx].for_reactor)
|
log.debug("init> initialized RTU unit #" .. #units .. ": redstone_io (redstone) [1] for reactor " .. io_reactor)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- mounted peripherals
|
-- mounted peripherals
|
||||||
|
@ -23,7 +23,7 @@ local print_ts = util.print_ts
|
|||||||
local println_ts = util.println_ts
|
local println_ts = util.println_ts
|
||||||
|
|
||||||
local MAIN_CLOCK = 2 -- (2Hz, 40 ticks)
|
local MAIN_CLOCK = 2 -- (2Hz, 40 ticks)
|
||||||
local COMMS_SLEEP = 150 -- (150ms, 3 ticks)
|
local COMMS_SLEEP = 100 -- (100ms, 2 ticks)
|
||||||
|
|
||||||
-- main thread
|
-- main thread
|
||||||
---@param smem rtu_shared_memory
|
---@param smem rtu_shared_memory
|
||||||
|
Loading…
Reference in New Issue
Block a user