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

57 lines
1.8 KiB
Lua
Raw Normal View History

2022-05-12 19:36:27 +00:00
local rtu = require("rtu.rtu")
2022-05-04 15:23:45 +00:00
local turbinev_rtu = {}
2023-07-11 21:27:03 +00:00
-- create new turbine device
2023-02-22 04:50:43 +00:00
---@nodiscard
2022-05-12 19:36:27 +00:00
---@param turbine table
---@return rtu_device interface, boolean faulted
function turbinev_rtu.new(turbine)
local unit = rtu.init_unit(turbine)
2022-05-04 15:23:45 +00:00
-- discrete inputs --
unit.connect_di("isFormed")
2022-05-04 15:23:45 +00:00
-- coils --
unit.connect_coil(function () turbine.incrementDumpingMode() end, function () end)
unit.connect_coil(function () turbine.decrementDumpingMode() end, function () end)
2022-05-04 15:23:45 +00:00
-- 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")
2022-05-04 15:23:45 +00:00
-- build properties
unit.connect_input_reg("getBlades")
unit.connect_input_reg("getCoils")
unit.connect_input_reg("getVents")
unit.connect_input_reg("getDispersers")
unit.connect_input_reg("getCondensers")
unit.connect_input_reg("getSteamCapacity")
unit.connect_input_reg("getMaxEnergy")
unit.connect_input_reg("getMaxFlowRate")
unit.connect_input_reg("getMaxProduction")
unit.connect_input_reg("getMaxWaterOutput")
2022-05-04 15:23:45 +00:00
-- current state
unit.connect_input_reg("getFlowRate")
unit.connect_input_reg("getProductionRate")
unit.connect_input_reg("getLastSteamInputRate")
unit.connect_input_reg("getDumpingMode")
2022-05-04 15:23:45 +00:00
-- tanks/containers
unit.connect_input_reg("getSteam")
unit.connect_input_reg("getSteamNeeded")
unit.connect_input_reg("getSteamFilledPercentage")
unit.connect_input_reg("getEnergy")
unit.connect_input_reg("getEnergyNeeded")
unit.connect_input_reg("getEnergyFilledPercentage")
2022-05-04 15:23:45 +00:00
-- holding registers --
unit.connect_holding_reg("getDumpingMode", "setDumpingMode")
return unit.interface(), false
2022-05-04 15:23:45 +00:00
end
return turbinev_rtu