2022-05-12 19:36:27 +00:00
|
|
|
local rtu = require("rtu.rtu")
|
2022-01-25 19:51:33 +00:00
|
|
|
|
2022-05-04 17:37:01 +00:00
|
|
|
local imatrix_rtu = {}
|
|
|
|
|
2022-05-12 19:36:27 +00:00
|
|
|
-- create new induction matrix (mek 10.1+) device
|
|
|
|
---@param imatrix table
|
2022-05-31 18:54:55 +00:00
|
|
|
function imatrix_rtu.new(imatrix)
|
|
|
|
local unit = rtu.init_unit()
|
2022-01-25 19:51:33 +00:00
|
|
|
|
|
|
|
-- discrete inputs --
|
2022-05-31 18:54:55 +00:00
|
|
|
unit.connect_di(imatrix.isFormed)
|
2022-01-25 19:51:33 +00:00
|
|
|
|
|
|
|
-- coils --
|
|
|
|
-- none
|
|
|
|
|
|
|
|
-- input registers --
|
2022-05-04 15:23:45 +00:00
|
|
|
-- multiblock properties
|
2022-05-31 18:54:55 +00:00
|
|
|
unit.connect_input_reg(imatrix.getLength)
|
|
|
|
unit.connect_input_reg(imatrix.getWidth)
|
|
|
|
unit.connect_input_reg(imatrix.getHeight)
|
|
|
|
unit.connect_input_reg(imatrix.getMinPos)
|
|
|
|
unit.connect_input_reg(imatrix.getMaxPos)
|
2022-01-25 19:51:33 +00:00
|
|
|
-- build properties
|
2022-05-31 18:54:55 +00:00
|
|
|
unit.connect_input_reg(imatrix.getMaxEnergy)
|
|
|
|
unit.connect_input_reg(imatrix.getTransferCap)
|
|
|
|
unit.connect_input_reg(imatrix.getInstalledCells)
|
|
|
|
unit.connect_input_reg(imatrix.getInstalledProviders)
|
2022-01-25 19:51:33 +00:00
|
|
|
-- containers
|
2022-05-31 18:54:55 +00:00
|
|
|
unit.connect_input_reg(imatrix.getEnergy)
|
|
|
|
unit.connect_input_reg(imatrix.getEnergyNeeded)
|
|
|
|
unit.connect_input_reg(imatrix.getEnergyFilledPercentage)
|
2022-05-04 15:23:45 +00:00
|
|
|
-- I/O rates
|
2022-05-31 18:54:55 +00:00
|
|
|
unit.connect_input_reg(imatrix.getLastInput)
|
|
|
|
unit.connect_input_reg(imatrix.getLastOutput)
|
2022-01-25 19:51:33 +00:00
|
|
|
|
|
|
|
-- holding registers --
|
|
|
|
-- none
|
|
|
|
|
2022-05-31 18:54:55 +00:00
|
|
|
return unit.interface()
|
2022-01-25 19:51:33 +00:00
|
|
|
end
|
2022-05-04 17:37:01 +00:00
|
|
|
|
|
|
|
return imatrix_rtu
|