2022-05-12 19:36:27 +00:00
|
|
|
local rtu = require("rtu.rtu")
|
2022-05-04 15:23:45 +00:00
|
|
|
|
2022-05-04 17:37:01 +00:00
|
|
|
local boilerv_rtu = {}
|
|
|
|
|
2023-07-11 21:27:03 +00:00
|
|
|
-- create new boiler device
|
2023-02-22 04:50:43 +00:00
|
|
|
---@nodiscard
|
2022-05-12 19:36:27 +00:00
|
|
|
---@param boiler table
|
2023-04-06 16:52:25 +00:00
|
|
|
---@return rtu_device interface, boolean faulted
|
2022-05-31 18:54:55 +00:00
|
|
|
function boilerv_rtu.new(boiler)
|
2024-03-09 18:24:06 +00:00
|
|
|
local unit = rtu.init_unit(boiler)
|
2022-05-04 15:23:45 +00:00
|
|
|
|
2023-04-06 16:52:25 +00:00
|
|
|
-- disable auto fault clearing
|
2023-06-22 19:46:17 +00:00
|
|
|
boiler.__p_clear_fault()
|
2023-04-06 16:52:25 +00:00
|
|
|
boiler.__p_disable_afc()
|
|
|
|
|
2022-05-04 15:23:45 +00:00
|
|
|
-- discrete inputs --
|
2022-05-31 18:54:55 +00:00
|
|
|
unit.connect_di(boiler.isFormed)
|
2022-05-04 15:23:45 +00:00
|
|
|
|
|
|
|
-- coils --
|
|
|
|
-- none
|
|
|
|
|
|
|
|
-- input registers --
|
|
|
|
-- multiblock properties
|
2022-05-31 18:54:55 +00:00
|
|
|
unit.connect_input_reg(boiler.getLength)
|
|
|
|
unit.connect_input_reg(boiler.getWidth)
|
|
|
|
unit.connect_input_reg(boiler.getHeight)
|
|
|
|
unit.connect_input_reg(boiler.getMinPos)
|
|
|
|
unit.connect_input_reg(boiler.getMaxPos)
|
2022-05-04 15:23:45 +00:00
|
|
|
-- build properties
|
2022-05-31 18:54:55 +00:00
|
|
|
unit.connect_input_reg(boiler.getBoilCapacity)
|
|
|
|
unit.connect_input_reg(boiler.getSteamCapacity)
|
|
|
|
unit.connect_input_reg(boiler.getWaterCapacity)
|
|
|
|
unit.connect_input_reg(boiler.getHeatedCoolantCapacity)
|
|
|
|
unit.connect_input_reg(boiler.getCooledCoolantCapacity)
|
|
|
|
unit.connect_input_reg(boiler.getSuperheaters)
|
|
|
|
unit.connect_input_reg(boiler.getMaxBoilRate)
|
2022-05-04 15:23:45 +00:00
|
|
|
-- current state
|
2022-05-31 18:54:55 +00:00
|
|
|
unit.connect_input_reg(boiler.getTemperature)
|
|
|
|
unit.connect_input_reg(boiler.getBoilRate)
|
2022-11-15 02:50:32 +00:00
|
|
|
unit.connect_input_reg(boiler.getEnvironmentalLoss)
|
2022-05-04 15:23:45 +00:00
|
|
|
-- tanks
|
2022-05-31 18:54:55 +00:00
|
|
|
unit.connect_input_reg(boiler.getSteam)
|
|
|
|
unit.connect_input_reg(boiler.getSteamNeeded)
|
|
|
|
unit.connect_input_reg(boiler.getSteamFilledPercentage)
|
|
|
|
unit.connect_input_reg(boiler.getWater)
|
|
|
|
unit.connect_input_reg(boiler.getWaterNeeded)
|
|
|
|
unit.connect_input_reg(boiler.getWaterFilledPercentage)
|
|
|
|
unit.connect_input_reg(boiler.getHeatedCoolant)
|
|
|
|
unit.connect_input_reg(boiler.getHeatedCoolantNeeded)
|
|
|
|
unit.connect_input_reg(boiler.getHeatedCoolantFilledPercentage)
|
|
|
|
unit.connect_input_reg(boiler.getCooledCoolant)
|
|
|
|
unit.connect_input_reg(boiler.getCooledCoolantNeeded)
|
|
|
|
unit.connect_input_reg(boiler.getCooledCoolantFilledPercentage)
|
2022-05-04 15:23:45 +00:00
|
|
|
|
|
|
|
-- holding registers --
|
|
|
|
-- none
|
|
|
|
|
2023-04-06 16:52:25 +00:00
|
|
|
-- check if any calls faulted
|
|
|
|
local faulted = boiler.__p_is_faulted()
|
|
|
|
boiler.__p_clear_fault()
|
|
|
|
boiler.__p_enable_afc()
|
|
|
|
|
|
|
|
return unit.interface(), faulted
|
2022-05-04 15:23:45 +00:00
|
|
|
end
|
2022-05-04 17:37:01 +00:00
|
|
|
|
|
|
|
return boilerv_rtu
|