2022-05-12 19:36:27 +00:00
|
|
|
local rtu = require("rtu.rtu")
|
2022-05-03 14:45:35 +00:00
|
|
|
|
2022-05-04 17:37:01 +00:00
|
|
|
local energymachine_rtu = {}
|
|
|
|
|
2022-05-12 19:36:27 +00:00
|
|
|
-- create new energy machine device
|
|
|
|
---@param machine table
|
2022-05-04 17:37:01 +00:00
|
|
|
energymachine_rtu.new = function (machine)
|
2022-05-03 14:45:35 +00:00
|
|
|
local self = {
|
2022-05-04 17:37:01 +00:00
|
|
|
rtu = rtu.init_unit(),
|
2022-05-03 14:45:35 +00:00
|
|
|
machine = machine
|
|
|
|
}
|
|
|
|
|
2022-05-12 19:36:27 +00:00
|
|
|
---@class rtu_device
|
|
|
|
local public = {}
|
|
|
|
|
|
|
|
-- get the RTU interface
|
|
|
|
public.rtu_interface = function () return self.rtu end
|
2022-05-03 14:45:35 +00:00
|
|
|
|
|
|
|
-- discrete inputs --
|
|
|
|
-- none
|
|
|
|
|
|
|
|
-- coils --
|
|
|
|
-- none
|
|
|
|
|
|
|
|
-- input registers --
|
|
|
|
-- build properties
|
|
|
|
self.rtu.connect_input_reg(self.machine.getTotalMaxEnergy)
|
|
|
|
-- containers
|
|
|
|
self.rtu.connect_input_reg(self.machine.getTotalEnergy)
|
|
|
|
self.rtu.connect_input_reg(self.machine.getTotalEnergyNeeded)
|
|
|
|
self.rtu.connect_input_reg(self.machine.getTotalEnergyFilledPercentage)
|
|
|
|
|
|
|
|
-- holding registers --
|
|
|
|
-- none
|
|
|
|
|
2022-05-12 19:36:27 +00:00
|
|
|
return public
|
2022-05-03 14:45:35 +00:00
|
|
|
end
|
2022-05-04 17:37:01 +00:00
|
|
|
|
|
|
|
return energymachine_rtu
|