cc-mek-scada/rtu/dev/dynamicv_rtu.lua

40 lines
1.2 KiB
Lua
Raw Normal View History

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)
local unit = rtu.init_unit(dynamic_tank)
2023-07-11 21:27:03 +00:00
-- discrete inputs --
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
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
unit.connect_input_reg("getTankCapacity")
unit.connect_input_reg("getChemicalTankCapacity")
2023-07-11 21:27:03 +00:00
-- tanks/containers
unit.connect_input_reg("getStored")
unit.connect_input_reg("getFilledPercentage")
2023-07-11 21:27:03 +00:00
-- holding registers --
unit.connect_holding_reg("getContainerEditMode", "setContainerEditMode")
2023-07-11 21:27:03 +00:00
return unit.interface(), false
2023-07-11 21:27:03 +00:00
end
return dynamicv_rtu