#621 support environment_detector peripheral type

This commit is contained in:
Mikayla 2025-06-16 15:07:56 +00:00
parent 264edc0030
commit 6d3b35a41d
5 changed files with 11 additions and 11 deletions

View File

@ -195,7 +195,7 @@ local function self_check()
valid = is_int_min_max(entry.unit, 1, 4) valid = is_int_min_max(entry.unit, 1, 4)
elseif p_type == "dynamicValve" then elseif p_type == "dynamicValve" then
valid = (entry.unit == nil and is_int_min_max(entry.index, 1, 4)) or is_int_min_max(entry.unit, 1, 4) valid = (entry.unit == nil and is_int_min_max(entry.index, 1, 4)) or is_int_min_max(entry.unit, 1, 4)
elseif p_type == "environmentDetector" then elseif p_type == "environmentDetector" or p_type == "environment_detector" then
valid = (entry.unit == nil or is_int_min_max(entry.unit, 1, 4)) and util.is_int(entry.index) valid = (entry.unit == nil or is_int_min_max(entry.unit, 1, 4)) and util.is_int(entry.index)
else else
valid = true valid = true

View File

@ -43,8 +43,8 @@ local self = {
local peripherals = {} local peripherals = {}
local RTU_DEV_TYPES = { "boilerValve", "turbineValve", "dynamicValve", "inductionPort", "spsPort", "solarNeutronActivator", "environmentDetector" } local RTU_DEV_TYPES = { "boilerValve", "turbineValve", "dynamicValve", "inductionPort", "spsPort", "solarNeutronActivator", "environmentDetector", "environment_detector" }
local NEEDS_UNIT = { "boilerValve", "turbineValve", "dynamicValve", "solarNeutronActivator", "environmentDetector" } local NEEDS_UNIT = { "boilerValve", "turbineValve", "dynamicValve", "solarNeutronActivator", "environmentDetector", "environment_detector" }
-- create the peripherals configuration view -- create the peripherals configuration view
---@param tool_ctl _rtu_cfg_tool_ctl ---@param tool_ctl _rtu_cfg_tool_ctl
@ -165,7 +165,7 @@ function peripherals.create(tool_ctl, main_pane, cfg_sys, peri_cfg, style)
end end
self.p_desc.set_value("Each reactor unit can have at most 1 tank and the facility can have at most 4. Each facility tank must have a unique # 1 through 4, regardless of where it is connected. Only a total of 4 tanks can be displayed on the flow monitor.") self.p_desc.set_value("Each reactor unit can have at most 1 tank and the facility can have at most 4. Each facility tank must have a unique # 1 through 4, regardless of where it is connected. Only a total of 4 tanks can be displayed on the flow monitor.")
elseif type == "environmentDetector" then elseif type == "environmentDetector" or type == "environment_detector" then
reposition("This is the below system's # env. detector.", 29, 99, 17, 6, 8) reposition("This is the below system's # env. detector.", 29, 99, 17, 6, 8)
self.p_assign_btn.show() self.p_assign_btn.show()
self.p_assign_btn.redraw() self.p_assign_btn.redraw()
@ -281,7 +281,7 @@ function peripherals.create(tool_ctl, main_pane, cfg_sys, peri_cfg, style)
local idx = tonumber(self.p_idx.get_value()) local idx = tonumber(self.p_idx.get_value())
if util.table_contains(NEEDS_UNIT, peri_type) then if util.table_contains(NEEDS_UNIT, peri_type) then
if (peri_type == "dynamicValve" or peri_type == "environmentDetector") and for_facility then if (peri_type == "dynamicValve" or peri_type == "environmentDetector" or peri_type == "environment_detector") and for_facility then
-- skip -- skip
elseif not (util.is_int(u) and u > 0 and u < 5) then elseif not (util.is_int(u) and u > 0 and u < 5) then
self.p_err.set_value("Unit ID must be within 1 to 4.") self.p_err.set_value("Unit ID must be within 1 to 4.")
@ -310,7 +310,7 @@ function peripherals.create(tool_ctl, main_pane, cfg_sys, peri_cfg, style)
else index = idx end else index = idx end
elseif peri_type == "dynamicValve" then elseif peri_type == "dynamicValve" then
index = 1 index = 1
elseif peri_type == "environmentDetector" then elseif peri_type == "environmentDetector" or peri_type == "environment_detector" then
if not (util.is_int(idx) and idx > 0) then if not (util.is_int(idx) and idx > 0) then
self.p_err.set_value("Index must be greater than 0.") self.p_err.set_value("Index must be greater than 0.")
self.p_err.show() self.p_err.show()

View File

@ -506,7 +506,7 @@ function system.create(tool_ctl, main_pane, cfg_sys, divs, ext, style)
local u, idx = def.unit, def.index local u, idx = def.unit, def.index
if util.table_contains(NEEDS_UNIT, mount.type) then if util.table_contains(NEEDS_UNIT, mount.type) then
if (mount.type == "dynamicValve" or mount.type == "environmentDetector") and for_facility then if (mount.type == "dynamicValve" or mount.type == "environmentDetector" or mount.type == "environment_detector") and for_facility then
-- skip -- skip
elseif not (util.is_int(u) and u > 0 and u < 5) then elseif not (util.is_int(u) and u > 0 and u < 5) then
err = true err = true
@ -527,7 +527,7 @@ function system.create(tool_ctl, main_pane, cfg_sys, divs, ext, style)
else index = idx end else index = idx end
elseif mount.type == "dynamicValve" then elseif mount.type == "dynamicValve" then
index = 1 index = 1
elseif mount.type == "environmentDetector" then elseif mount.type == "environmentDetector" or mount.type == "environment_detector" then
if not (util.is_int(idx) and idx > 0) then if not (util.is_int(idx) and idx > 0) then
err = true err = true
else index = idx end else index = idx end

View File

@ -31,7 +31,7 @@ local sna_rtu = require("rtu.dev.sna_rtu")
local sps_rtu = require("rtu.dev.sps_rtu") local sps_rtu = require("rtu.dev.sps_rtu")
local turbinev_rtu = require("rtu.dev.turbinev_rtu") local turbinev_rtu = require("rtu.dev.turbinev_rtu")
local RTU_VERSION = "v1.12.1" local RTU_VERSION = "v1.12.2"
local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE
local RTU_HW_STATE = databus.RTU_HW_STATE local RTU_HW_STATE = databus.RTU_HW_STATE
@ -472,7 +472,7 @@ local function main()
rtu_type = RTU_UNIT_TYPE.SNA rtu_type = RTU_UNIT_TYPE.SNA
rtu_iface, faulted = sna_rtu.new(device) rtu_iface, faulted = sna_rtu.new(device)
elseif type == "environmentDetector" then elseif type == "environmentDetector" or type == "environment_detector" then
-- advanced peripherals environment detector -- advanced peripherals environment detector
if not validate_index(1) then return false end if not validate_index(1) then return false end
if not validate_assign(entry.unit == nil) then return false end if not validate_assign(entry.unit == nil) then return false end

View File

@ -89,7 +89,7 @@ local function handle_unit_mount(smem, println_ts, iface, type, device, unit)
if unit.reactor < 1 or unit.reactor > 4 then fail(util.c("SNA '", unit.name, "' cannot init, not assigned to a valid unit")) end if unit.reactor < 1 or unit.reactor > 4 then fail(util.c("SNA '", unit.name, "' cannot init, not assigned to a valid unit")) end
unit.type = RTU_UNIT_TYPE.SNA unit.type = RTU_UNIT_TYPE.SNA
elseif type == "environmentDetector" then elseif type == "environmentDetector" or type == "environment_detector" then
-- advanced peripherals environment detector -- advanced peripherals environment detector
if unit.reactor < 0 or unit.reactor > 4 then fail(util.c("environment detector '", unit.name, "' cannot init, no valid assignment provided")) end if unit.reactor < 0 or unit.reactor > 4 then fail(util.c("environment detector '", unit.name, "' cannot init, no valid assignment provided")) end
if (unit.index == false) or unit.index < 1 then fail(util.c("environment detector '", unit.name, "' cannot init, invalid index provided")) end if (unit.index == false) or unit.index < 1 then fail(util.c("environment detector '", unit.name, "' cannot init, invalid index provided")) end