2022-06-04 14:49:36 +00:00
|
|
|
local rtu = require("rtu.rtu")
|
|
|
|
|
|
|
|
local sna_rtu = {}
|
|
|
|
|
2023-02-22 04:50:43 +00:00
|
|
|
-- create new solar neutron activator (SNA) device
|
|
|
|
---@nodiscard
|
2022-06-04 14:49:36 +00:00
|
|
|
---@param sna table
|
2023-04-06 16:52:25 +00:00
|
|
|
---@return rtu_device interface, boolean faulted
|
2022-06-04 14:49:36 +00:00
|
|
|
function sna_rtu.new(sna)
|
2024-03-09 18:24:06 +00:00
|
|
|
local unit = rtu.init_unit(sna)
|
2022-06-04 14:49:36 +00:00
|
|
|
|
2023-04-06 16:52:25 +00:00
|
|
|
-- disable auto fault clearing
|
2023-06-22 19:46:17 +00:00
|
|
|
sna.__p_clear_fault()
|
2023-04-06 16:52:25 +00:00
|
|
|
sna.__p_disable_afc()
|
|
|
|
|
2022-06-04 14:49:36 +00:00
|
|
|
-- discrete inputs --
|
|
|
|
-- none
|
|
|
|
|
|
|
|
-- coils --
|
|
|
|
-- none
|
|
|
|
|
|
|
|
-- input registers --
|
|
|
|
-- build properties
|
|
|
|
unit.connect_input_reg(sna.getInputCapacity)
|
|
|
|
unit.connect_input_reg(sna.getOutputCapacity)
|
|
|
|
-- current state
|
|
|
|
unit.connect_input_reg(sna.getProductionRate)
|
|
|
|
unit.connect_input_reg(sna.getPeakProductionRate)
|
|
|
|
-- tanks
|
|
|
|
unit.connect_input_reg(sna.getInput)
|
|
|
|
unit.connect_input_reg(sna.getInputNeeded)
|
|
|
|
unit.connect_input_reg(sna.getInputFilledPercentage)
|
|
|
|
unit.connect_input_reg(sna.getOutput)
|
|
|
|
unit.connect_input_reg(sna.getOutputNeeded)
|
|
|
|
unit.connect_input_reg(sna.getOutputFilledPercentage)
|
|
|
|
|
|
|
|
-- holding registers --
|
|
|
|
-- none
|
|
|
|
|
2023-04-06 16:52:25 +00:00
|
|
|
-- check if any calls faulted
|
|
|
|
local faulted = sna.__p_is_faulted()
|
|
|
|
sna.__p_clear_fault()
|
|
|
|
sna.__p_enable_afc()
|
|
|
|
|
|
|
|
return unit.interface(), faulted
|
2022-06-04 14:49:36 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return sna_rtu
|