mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
refactored RTU devices
This commit is contained in:
parent
377cf8e6fc
commit
2278469a8b
@ -1,6 +1,6 @@
|
|||||||
-- #REQUIRES rtu.lua
|
-- #REQUIRES rtu.lua
|
||||||
|
|
||||||
function boiler_rtu(boiler)
|
function new(boiler)
|
||||||
local self = {
|
local self = {
|
||||||
rtu = rtu.rtu_init(),
|
rtu = rtu.rtu_init(),
|
||||||
boiler = boiler
|
boiler = boiler
|
@ -1,6 +1,6 @@
|
|||||||
-- #REQUIRES rtu.lua
|
-- #REQUIRES rtu.lua
|
||||||
|
|
||||||
function imatrix_rtu(imatrix)
|
function new(imatrix)
|
||||||
local self = {
|
local self = {
|
||||||
rtu = rtu.rtu_init(),
|
rtu = rtu.rtu_init(),
|
||||||
imatrix = imatrix
|
imatrix = imatrix
|
@ -5,7 +5,7 @@
|
|||||||
local digital_read = rsio.digital_read
|
local digital_read = rsio.digital_read
|
||||||
local digital_is_active = rsio.digital_is_active
|
local digital_is_active = rsio.digital_is_active
|
||||||
|
|
||||||
function redstone_rtu()
|
function new()
|
||||||
local self = {
|
local self = {
|
||||||
rtu = rtu.rtu_init()
|
rtu = rtu.rtu_init()
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
-- #REQUIRES rtu.lua
|
-- #REQUIRES rtu.lua
|
||||||
|
|
||||||
function turbine_rtu(turbine)
|
function new(turbine)
|
||||||
local self = {
|
local self = {
|
||||||
rtu = rtu.rtu_init(),
|
rtu = rtu.rtu_init(),
|
||||||
turbine = turbine
|
turbine = turbine
|
@ -12,23 +12,18 @@ os.loadAPI("scada-common/rsio.lua")
|
|||||||
os.loadAPI("config.lua")
|
os.loadAPI("config.lua")
|
||||||
os.loadAPI("rtu.lua")
|
os.loadAPI("rtu.lua")
|
||||||
|
|
||||||
os.loadAPI("dev/redstone.lua")
|
os.loadAPI("dev/redstone_rtu.lua")
|
||||||
os.loadAPI("dev/boiler.lua")
|
os.loadAPI("dev/boiler_rtu.lua")
|
||||||
os.loadAPI("dev/imatrix.lua")
|
os.loadAPI("dev/imatrix_rtu.lua")
|
||||||
os.loadAPI("dev/turbine.lua")
|
os.loadAPI("dev/turbine_rtu.lua")
|
||||||
|
|
||||||
local RTU_VERSION = "alpha-v0.1.2"
|
local RTU_VERSION = "alpha-v0.1.3"
|
||||||
|
|
||||||
local print = util.print
|
local print = util.print
|
||||||
local println = util.println
|
local println = util.println
|
||||||
local print_ts = util.print_ts
|
local print_ts = util.print_ts
|
||||||
local println_ts = util.println_ts
|
local println_ts = util.println_ts
|
||||||
|
|
||||||
local redstone_rtu = redstone.redstone_rtu
|
|
||||||
local boiler_rtu = boiler.boiler_rtu
|
|
||||||
local turbine_rtu = turbine.turbine_rtu
|
|
||||||
local imatrix_rtu = imatrix.imatrix_rtu
|
|
||||||
|
|
||||||
log._info("========================================")
|
log._info("========================================")
|
||||||
log._info("BOOTING rtu.startup " .. RTU_VERSION)
|
log._info("BOOTING rtu.startup " .. RTU_VERSION)
|
||||||
log._info("========================================")
|
log._info("========================================")
|
||||||
@ -63,7 +58,7 @@ local rtu_devices = config.RTU_DEVICES
|
|||||||
|
|
||||||
-- redstone interfaces
|
-- redstone interfaces
|
||||||
for reactor_idx = 1, #rtu_redstone do
|
for reactor_idx = 1, #rtu_redstone do
|
||||||
local rs_rtu = redstone_rtu()
|
local rs_rtu = redstone_rtu.new()
|
||||||
local io_table = rtu_redstone[reactor_idx].io
|
local io_table = rtu_redstone[reactor_idx].io
|
||||||
|
|
||||||
local capabilities = {}
|
local capabilities = {}
|
||||||
@ -141,15 +136,15 @@ for i = 1, #rtu_devices do
|
|||||||
if type == "boiler" then
|
if type == "boiler" then
|
||||||
-- boiler multiblock
|
-- boiler multiblock
|
||||||
rtu_type = "boiler"
|
rtu_type = "boiler"
|
||||||
rtu_iface = boiler_rtu(device)
|
rtu_iface = boiler_rtu.new(device)
|
||||||
elseif type == "turbine" then
|
elseif type == "turbine" then
|
||||||
-- turbine multiblock
|
-- turbine multiblock
|
||||||
rtu_type = "turbine"
|
rtu_type = "turbine"
|
||||||
rtu_iface = turbine_rtu(device)
|
rtu_iface = turbine_rtu.new(device)
|
||||||
elseif type == "mekanismMachine" then
|
elseif type == "mekanismMachine" then
|
||||||
-- assumed to be an induction matrix multiblock
|
-- assumed to be an induction matrix multiblock
|
||||||
rtu_type = "imatrix"
|
rtu_type = "imatrix"
|
||||||
rtu_iface = imatrix_rtu(device)
|
rtu_iface = imatrix_rtu.new(device)
|
||||||
else
|
else
|
||||||
local message = "init> device '" .. rtu_devices[i].name .. "' is not a known type (" .. type .. ")"
|
local message = "init> device '" .. rtu_devices[i].name .. "' is not a known type (" .. type .. ")"
|
||||||
println_ts(message)
|
println_ts(message)
|
||||||
@ -210,11 +205,11 @@ while true do
|
|||||||
unit.device = device
|
unit.device = device
|
||||||
|
|
||||||
if unit.type == "boiler" then
|
if unit.type == "boiler" then
|
||||||
unit.rtu = boiler_rtu(device)
|
unit.rtu = boiler_rtu.new(device)
|
||||||
elseif unit.type == "turbine" then
|
elseif unit.type == "turbine" then
|
||||||
unit.rtu = turbine_rtu(device)
|
unit.rtu = turbine_rtu.new(device)
|
||||||
elseif unit.type == "imatrix" then
|
elseif unit.type == "imatrix" then
|
||||||
unit.rtu = imatrix_rtu(device)
|
unit.rtu = imatrix_rtu.new(device)
|
||||||
end
|
end
|
||||||
|
|
||||||
unit.modbus_io = modbus.new(unit.rtu)
|
unit.modbus_io = modbus.new(unit.rtu)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user