2022-06-04 14:49:36 +00:00
|
|
|
local rtu = require("rtu.rtu")
|
|
|
|
|
|
|
|
local envd_rtu = {}
|
|
|
|
|
|
|
|
-- create new environment detector device
|
2023-02-22 04:50:43 +00:00
|
|
|
---@nodiscard
|
2022-06-04 14:49:36 +00:00
|
|
|
---@param envd table
|
2023-04-06 16:52:25 +00:00
|
|
|
---@return rtu_device interface, boolean faulted
|
2022-06-04 14:49:36 +00:00
|
|
|
function envd_rtu.new(envd)
|
2024-03-09 18:24:06 +00:00
|
|
|
local unit = rtu.init_unit(envd)
|
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
|
|
|
envd.__p_clear_fault()
|
2023-04-06 16:52:25 +00:00
|
|
|
envd.__p_disable_afc()
|
|
|
|
|
2022-06-04 14:49:36 +00:00
|
|
|
-- discrete inputs --
|
|
|
|
-- none
|
|
|
|
|
|
|
|
-- coils --
|
|
|
|
-- none
|
|
|
|
|
|
|
|
-- input registers --
|
|
|
|
unit.connect_input_reg(envd.getRadiation)
|
|
|
|
unit.connect_input_reg(envd.getRadiationRaw)
|
|
|
|
|
|
|
|
-- holding registers --
|
|
|
|
-- none
|
|
|
|
|
2023-04-06 16:52:25 +00:00
|
|
|
-- check if any calls faulted
|
|
|
|
local faulted = envd.__p_is_faulted()
|
|
|
|
envd.__p_clear_fault()
|
|
|
|
envd.__p_enable_afc()
|
|
|
|
|
|
|
|
return unit.interface(), faulted
|
2022-06-04 14:49:36 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return envd_rtu
|