2023-07-11 21:27:03 +00:00
|
|
|
local rtu = require("rtu.rtu")
|
|
|
|
|
|
|
|
local dynamicv_rtu = {}
|
|
|
|
|
|
|
|
-- create new dynamic tank device
|
|
|
|
---@nodiscard
|
|
|
|
---@param dynamic_tank table
|
|
|
|
---@return rtu_device interface, boolean faulted
|
|
|
|
function dynamicv_rtu.new(dynamic_tank)
|
2024-03-09 18:24:06 +00:00
|
|
|
local unit = rtu.init_unit(dynamic_tank)
|
2023-07-11 21:27:03 +00:00
|
|
|
|
|
|
|
-- discrete inputs --
|
2024-03-23 04:26:58 +00:00
|
|
|
unit.connect_di("isFormed")
|
2023-07-11 21:27:03 +00:00
|
|
|
|
|
|
|
-- coils --
|
|
|
|
unit.connect_coil(function () dynamic_tank.incrementContainerEditMode() end, function () end)
|
|
|
|
unit.connect_coil(function () dynamic_tank.decrementContainerEditMode() end, function () end)
|
|
|
|
|
|
|
|
-- input registers --
|
|
|
|
-- multiblock properties
|
2024-03-23 04:26:58 +00:00
|
|
|
unit.connect_input_reg("getLength")
|
|
|
|
unit.connect_input_reg("getWidth")
|
|
|
|
unit.connect_input_reg("getHeight")
|
|
|
|
unit.connect_input_reg("getMinPos")
|
|
|
|
unit.connect_input_reg("getMaxPos")
|
2023-07-11 21:27:03 +00:00
|
|
|
-- build properties
|
2024-03-23 04:26:58 +00:00
|
|
|
unit.connect_input_reg("getTankCapacity")
|
|
|
|
unit.connect_input_reg("getChemicalTankCapacity")
|
2023-07-11 21:27:03 +00:00
|
|
|
-- tanks/containers
|
2024-03-23 04:26:58 +00:00
|
|
|
unit.connect_input_reg("getStored")
|
|
|
|
unit.connect_input_reg("getFilledPercentage")
|
2023-07-11 21:27:03 +00:00
|
|
|
|
|
|
|
-- holding registers --
|
2024-03-23 04:26:58 +00:00
|
|
|
unit.connect_holding_reg("getContainerEditMode", "setContainerEditMode")
|
2023-07-11 21:27:03 +00:00
|
|
|
|
2024-03-23 04:26:58 +00:00
|
|
|
return unit.interface(), false
|
2023-07-11 21:27:03 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return dynamicv_rtu
|