additional config validations

This commit is contained in:
Mikayla Fischler 2024-02-18 15:25:30 -05:00
parent 36b12d5dea
commit 1984b63837
5 changed files with 12 additions and 2 deletions

View File

@ -37,14 +37,17 @@ function plc.load_config()
config.Networked = settings.get("Networked")
config.UnitID = settings.get("UnitID")
config.EmerCoolEnable = settings.get("EmerCoolEnable")
config.EmerCoolSide = settings.get("EmerCoolSide")
config.EmerCoolColor = settings.get("EmerCoolColor")
config.SVR_Channel = settings.get("SVR_Channel")
config.PLC_Channel = settings.get("PLC_Channel")
config.ConnTimeout = settings.get("ConnTimeout")
config.TrustedRange = settings.get("TrustedRange")
config.AuthKey = settings.get("AuthKey")
config.LogMode = settings.get("LogMode")
config.LogPath = settings.get("LogPath")
config.LogDebug = settings.get("LogDebug")
@ -71,6 +74,7 @@ function plc.load_config()
end
cfv.assert_type_int(config.LogMode)
cfv.assert_range(config.LogMode, 0, 1)
cfv.assert_type_str(config.LogPath)
cfv.assert_type_bool(config.LogDebug)

View File

@ -18,7 +18,7 @@ local plc = require("reactor-plc.plc")
local renderer = require("reactor-plc.renderer")
local threads = require("reactor-plc.threads")
local R_PLC_VERSION = "v1.6.9"
local R_PLC_VERSION = "v1.6.10"
local println = util.println
local println_ts = util.println_ts

View File

@ -41,6 +41,9 @@ function rtu.load_config()
local cfv = util.new_validator()
cfv.assert_type_num(config.SpeakerVolume)
cfv.assert_min(config.SpeakerVolume, 0.0)
cfv.assert_max(config.SpeakerVolume, 3.0)
cfv.assert_channel(config.SVR_Channel)
cfv.assert_channel(config.RTU_Channel)
cfv.assert_type_num(config.ConnTimeout)
@ -55,6 +58,7 @@ function rtu.load_config()
end
cfv.assert_type_int(config.LogMode)
cfv.assert_range(config.LogMode, 0, 1)
cfv.assert_type_str(config.LogPath)
cfv.assert_type_bool(config.LogDebug)

View File

@ -31,7 +31,7 @@ local sna_rtu = require("rtu.dev.sna_rtu")
local sps_rtu = require("rtu.dev.sps_rtu")
local turbinev_rtu = require("rtu.dev.turbinev_rtu")
local RTU_VERSION = "v1.7.11"
local RTU_VERSION = "v1.7.12"
local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE
local RTU_UNIT_HW_STATE = databus.RTU_UNIT_HW_STATE

View File

@ -69,6 +69,7 @@ function supervisor.load_config()
cfv.assert_min(config.PKT_Timeout, 2)
cfv.assert_type_num(config.TrustedRange)
cfv.assert_min(config.TrustedRange, 0)
if type(config.AuthKey) == "string" then
local len = string.len(config.AuthKey)
@ -76,6 +77,7 @@ function supervisor.load_config()
end
cfv.assert_type_int(config.LogMode)
cfv.assert_range(config.LogMode, 0, 1)
cfv.assert_type_str(config.LogPath)
cfv.assert_type_bool(config.LogDebug)