#232 completed display of flow/dynamic tank/sps, dynamically sized
This commit is contained in:
@@ -10,27 +10,39 @@ config.RTU_CHANNEL = 16242
|
||||
config.CRD_CHANNEL = 16243
|
||||
-- pocket comms channel
|
||||
config.PKT_CHANNEL = 16244
|
||||
-- max trusted modem message distance (0 to disable check)
|
||||
-- max trusted modem message distance
|
||||
-- (0 to disable check)
|
||||
config.TRUSTED_RANGE = 0
|
||||
-- time in seconds (>= 2) before assuming a remote device is no longer active
|
||||
-- time in seconds (>= 2) before assuming a remote
|
||||
-- device is no longer active
|
||||
config.PLC_TIMEOUT = 5
|
||||
config.RTU_TIMEOUT = 5
|
||||
config.CRD_TIMEOUT = 5
|
||||
config.PKT_TIMEOUT = 5
|
||||
-- facility authentication key (do NOT use one of your passwords)
|
||||
-- facility authentication key
|
||||
-- (do NOT use one of your passwords)
|
||||
-- this enables verifying that messages are authentic
|
||||
-- all devices on the same network must use the same key
|
||||
-- all devices on this network must use this key
|
||||
-- config.AUTH_KEY = "SCADAfacility123"
|
||||
|
||||
-- expected number of reactors
|
||||
config.NUM_REACTORS = 4
|
||||
-- expected number of boilers/turbines for each reactor
|
||||
-- expected number of devices for each unit
|
||||
config.REACTOR_COOLING = {
|
||||
{ BOILERS = 1, TURBINES = 1 }, -- reactor unit 1
|
||||
{ BOILERS = 1, TURBINES = 1 }, -- reactor unit 2
|
||||
{ BOILERS = 1, TURBINES = 1 }, -- reactor unit 3
|
||||
{ BOILERS = 1, TURBINES = 1 } -- reactor unit 4
|
||||
-- reactor unit 1
|
||||
{ BOILERS = 1, TURBINES = 1, TANK = false },
|
||||
-- reactor unit 2
|
||||
{ BOILERS = 1, TURBINES = 1, TANK = false },
|
||||
-- reactor unit 3
|
||||
{ BOILERS = 1, TURBINES = 1, TANK = false },
|
||||
-- reactor unit 4
|
||||
{ BOILERS = 1, TURBINES = 1, TANK = false }
|
||||
}
|
||||
-- advanced facility dynamic tank configuration
|
||||
-- (see wiki for details)
|
||||
-- by default, dynamic tanks are for each unit
|
||||
config.FAC_TANK_MODE = 0
|
||||
config.FAC_TANK_LIST = { 0, 0, 0, 0 }
|
||||
|
||||
-- log path
|
||||
config.LOG_PATH = "/log.txt"
|
||||
|
||||
@@ -54,7 +54,7 @@ local facility = {}
|
||||
-- create a new facility management object
|
||||
---@nodiscard
|
||||
---@param num_reactors integer number of reactor units
|
||||
---@param cooling_conf table cooling configurations of reactor units
|
||||
---@param cooling_conf sv_cooling_conf cooling configurations of reactor units
|
||||
function facility.new(num_reactors, cooling_conf)
|
||||
local self = {
|
||||
units = {},
|
||||
@@ -118,7 +118,7 @@ function facility.new(num_reactors, cooling_conf)
|
||||
|
||||
-- create units
|
||||
for i = 1, num_reactors do
|
||||
table.insert(self.units, unit.new(i, cooling_conf[i].BOILERS, cooling_conf[i].TURBINES))
|
||||
table.insert(self.units, unit.new(i, cooling_conf.r_cool[i].BOILERS, cooling_conf.r_cool[i].TURBINES))
|
||||
table.insert(self.group_map, 0)
|
||||
end
|
||||
|
||||
|
||||
@@ -198,7 +198,7 @@ end
|
||||
---@param nic nic network interface device
|
||||
---@param fp_ok boolean front panel active
|
||||
---@param num_reactors integer number of reactors
|
||||
---@param cooling_conf table cooling configuration definition
|
||||
---@param cooling_conf sv_cooling_conf cooling configuration definition
|
||||
function svsessions.init(nic, fp_ok, num_reactors, cooling_conf)
|
||||
self.nic = nic
|
||||
self.fp_ok = fp_ok
|
||||
|
||||
@@ -21,7 +21,7 @@ local supervisor = require("supervisor.supervisor")
|
||||
|
||||
local svsessions = require("supervisor.session.svsessions")
|
||||
|
||||
local SUPERVISOR_VERSION = "v0.20.5"
|
||||
local SUPERVISOR_VERSION = "v1.0.0"
|
||||
|
||||
local println = util.println
|
||||
local println_ts = util.println_ts
|
||||
@@ -48,11 +48,16 @@ cfv.assert_type_num(config.PKT_TIMEOUT)
|
||||
cfv.assert_min(config.PKT_TIMEOUT, 2)
|
||||
cfv.assert_type_int(config.NUM_REACTORS)
|
||||
cfv.assert_type_table(config.REACTOR_COOLING)
|
||||
cfv.assert_type_int(config.FAC_TANK_MODE)
|
||||
cfv.assert_type_table(config.FAC_TANK_LIST)
|
||||
cfv.assert_type_str(config.LOG_PATH)
|
||||
cfv.assert_type_int(config.LOG_MODE)
|
||||
|
||||
assert(cfv.valid(), "bad config file: missing/invalid fields")
|
||||
|
||||
assert((config.FAC_TANK_MODE ~= 0) and (config.NUM_REACTORS == #config.FAC_TANK_LIST),
|
||||
"bad config file: FAC_TANK_LIST length not equal to NUM_REACTORS")
|
||||
|
||||
cfv.assert_eq(#config.REACTOR_COOLING, config.NUM_REACTORS)
|
||||
assert(cfv.valid(), "config: number of cooling configs different than number of units")
|
||||
|
||||
@@ -61,6 +66,7 @@ for i = 1, config.NUM_REACTORS do
|
||||
assert(cfv.valid(), "config: missing cooling entry for reactor " .. i)
|
||||
cfv.assert_type_int(config.REACTOR_COOLING[i].BOILERS)
|
||||
cfv.assert_type_int(config.REACTOR_COOLING[i].TURBINES)
|
||||
cfv.assert_type_bool(config.REACTOR_COOLING[i].TANK)
|
||||
assert(cfv.valid(), "config: missing boilers/turbines for reactor " .. i)
|
||||
cfv.assert_min(config.REACTOR_COOLING[i].BOILERS, 0)
|
||||
cfv.assert_min(config.REACTOR_COOLING[i].TURBINES, 1)
|
||||
|
||||
@@ -32,7 +32,8 @@ function supervisor.comms(_version, nic, fp_ok)
|
||||
|
||||
-- configuration data
|
||||
local num_reactors = config.NUM_REACTORS
|
||||
local cooling_conf = config.REACTOR_COOLING
|
||||
---@class sv_cooling_conf
|
||||
local cooling_conf = { r_cool = config.REACTOR_COOLING, fac_tank_mode = config.FAC_TANK_MODE, fac_tank_list = config.FAC_TANK_LIST }
|
||||
|
||||
local self = {
|
||||
last_est_acks = {}
|
||||
@@ -295,16 +296,10 @@ function supervisor.comms(_version, nic, fp_ok)
|
||||
local s_id = svsessions.establish_crd_session(src_addr, firmware_v)
|
||||
|
||||
if s_id ~= false then
|
||||
local cfg = { num_reactors }
|
||||
for i = 1, #cooling_conf do
|
||||
table.insert(cfg, cooling_conf[i].BOILERS)
|
||||
table.insert(cfg, cooling_conf[i].TURBINES)
|
||||
end
|
||||
|
||||
println(util.c("CRD (", firmware_v, ") [@", src_addr, "] \xbb connected"))
|
||||
log.info(util.c("CRD_ESTABLISH: coordinator (", firmware_v, ") [@", src_addr, "] connected with session ID ", s_id))
|
||||
|
||||
_send_establish(packet.scada_frame, ESTABLISH_ACK.ALLOW, cfg)
|
||||
_send_establish(packet.scada_frame, ESTABLISH_ACK.ALLOW, { num_reactors, cooling_conf })
|
||||
else
|
||||
if last_ack ~= ESTABLISH_ACK.COLLISION then
|
||||
log.info("CRD_ESTABLISH: denied new coordinator [@" .. src_addr .. "] due to already being connected to another coordinator")
|
||||
|
||||
Reference in New Issue
Block a user