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-04 17:37:01 +00:00
|
|
|
imatrix_rtu.new = function (imatrix)
|
2022-01-25 19:51:33 +00:00
|
|
|
local self = {
|
2022-05-04 17:37:01 +00:00
|
|
|
rtu = rtu.init_unit(),
|
2022-01-25 19:51:33 +00:00
|
|
|
imatrix = imatrix
|
|
|
|
}
|
|
|
|
|
|
|
|
-- discrete inputs --
|
2022-05-12 19:36:27 +00:00
|
|
|
self.rtu.connect_di(self.boiler.isFormed)
|
2022-01-25 19:51:33 +00:00
|
|
|
|
|
|
|
-- coils --
|
|
|
|
-- none
|
|
|
|
|
|
|
|
-- input registers --
|
2022-05-04 15:23:45 +00:00
|
|
|
-- multiblock properties
|
|
|
|
self.rtu.connect_input_reg(self.boiler.getLength)
|
|
|
|
self.rtu.connect_input_reg(self.boiler.getWidth)
|
|
|
|
self.rtu.connect_input_reg(self.boiler.getHeight)
|
2022-05-12 19:36:27 +00:00
|
|
|
self.rtu.connect_input_reg(self.boiler.getMinPos)
|
|
|
|
self.rtu.connect_input_reg(self.boiler.getMaxPos)
|
2022-01-25 19:51:33 +00:00
|
|
|
-- build properties
|
2022-05-04 15:23:45 +00:00
|
|
|
self.rtu.connect_input_reg(self.imatrix.getMaxEnergy)
|
2022-05-03 14:45:35 +00:00
|
|
|
self.rtu.connect_input_reg(self.imatrix.getTransferCap)
|
|
|
|
self.rtu.connect_input_reg(self.imatrix.getInstalledCells)
|
|
|
|
self.rtu.connect_input_reg(self.imatrix.getInstalledProviders)
|
2022-01-25 19:51:33 +00:00
|
|
|
-- containers
|
2022-05-04 15:23:45 +00:00
|
|
|
self.rtu.connect_input_reg(self.imatrix.getEnergy)
|
|
|
|
self.rtu.connect_input_reg(self.imatrix.getEnergyNeeded)
|
|
|
|
self.rtu.connect_input_reg(self.imatrix.getEnergyFilledPercentage)
|
|
|
|
-- I/O rates
|
2022-05-03 14:45:35 +00:00
|
|
|
self.rtu.connect_input_reg(self.imatrix.getLastInput)
|
|
|
|
self.rtu.connect_input_reg(self.imatrix.getLastOutput)
|
2022-01-25 19:51:33 +00:00
|
|
|
|
|
|
|
-- holding registers --
|
|
|
|
-- none
|
|
|
|
|
2022-05-12 19:36:27 +00:00
|
|
|
return self.rtu.interface()
|
2022-01-25 19:51:33 +00:00
|
|
|
end
|
2022-05-04 17:37:01 +00:00
|
|
|
|
|
|
|
return imatrix_rtu
|