#580 review changes/fixes
This commit is contained in:
@@ -158,16 +158,18 @@ function backplane.init(config, __shared_memory)
|
|||||||
-- Modem Init
|
-- Modem Init
|
||||||
|
|
||||||
-- init wired NIC
|
-- init wired NIC
|
||||||
if type(config.WiredModem) == "string" then
|
if type(_bp.lan_iface) == "string" then
|
||||||
local modem = ppm.get_modem(_bp.lan_iface)
|
local modem = ppm.get_modem(_bp.lan_iface)
|
||||||
local wd_nic = network.nic(modem)
|
local wd_nic = network.nic(modem)
|
||||||
|
|
||||||
log.info("BKPLN: WIRED PHY_" .. util.trinary(modem, "UP ", "DOWN ") .. _bp.lan_iface)
|
log.info("BKPLN: WIRED PHY_" .. util.trinary(modem, "UP ", "DOWN ") .. _bp.lan_iface)
|
||||||
log_comms("wired comms modem " .. util.trinary(modem, "connected", "not found"))
|
log_comms("wired comms modem " .. util.trinary(modem, "connected", "not found"))
|
||||||
|
|
||||||
-- set this as active for now
|
|
||||||
_bp.act_nic = wd_nic
|
|
||||||
_bp.wd_nic = wd_nic
|
_bp.wd_nic = wd_nic
|
||||||
|
_bp.act_nic = wd_nic -- set this as active for now
|
||||||
|
|
||||||
|
wd_nic.closeAll()
|
||||||
|
wd_nic.open(config.CRD_Channel)
|
||||||
|
|
||||||
iocontrol.fp_has_wd_modem(modem ~= nil)
|
iocontrol.fp_has_wd_modem(modem ~= nil)
|
||||||
end
|
end
|
||||||
@@ -339,11 +341,13 @@ function backplane.attach(type, device, iface)
|
|||||||
end
|
end
|
||||||
elseif type == "speaker" then
|
elseif type == "speaker" then
|
||||||
---@cast device Speaker
|
---@cast device Speaker
|
||||||
log_sys("alarm sounder speaker reconnected")
|
|
||||||
log.info("BKPLN: SPEAKER LINK_UP " .. iface)
|
log.info("BKPLN: SPEAKER LINK_UP " .. iface)
|
||||||
|
|
||||||
sounder.reconnect(device)
|
sounder.reconnect(device)
|
||||||
|
|
||||||
|
log_sys("alarm sounder speaker reconnected")
|
||||||
|
|
||||||
iocontrol.fp_has_speaker(true)
|
iocontrol.fp_has_speaker(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -465,10 +469,11 @@ function backplane.detach(type, device, iface)
|
|||||||
end
|
end
|
||||||
elseif type == "speaker" then
|
elseif type == "speaker" then
|
||||||
---@cast device Speaker
|
---@cast device Speaker
|
||||||
log_sys("lost alarm sounder speaker")
|
|
||||||
|
|
||||||
log.info("BKPLN: SPEAKER LINK_DOWN " .. iface)
|
log.info("BKPLN: SPEAKER LINK_DOWN " .. iface)
|
||||||
|
|
||||||
|
log_sys("alarm sounder speaker disconnected")
|
||||||
|
|
||||||
iocontrol.fp_has_speaker(false)
|
iocontrol.fp_has_speaker(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -184,10 +184,6 @@ function coordinator.comms(version, nic, wl_nic, sv_watchdog)
|
|||||||
comms.set_trusted_range(config.TrustedRange)
|
comms.set_trusted_range(config.TrustedRange)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- configure network channels
|
|
||||||
nic.closeAll()
|
|
||||||
nic.open(config.CRD_Channel)
|
|
||||||
|
|
||||||
-- pass config to apisessions
|
-- pass config to apisessions
|
||||||
if config.API_Enabled and wl_nic then
|
if config.API_Enabled and wl_nic then
|
||||||
apisessions.init(wl_nic, config)
|
apisessions.init(wl_nic, config)
|
||||||
@@ -254,15 +250,7 @@ function coordinator.comms(version, nic, wl_nic, sv_watchdog)
|
|||||||
|
|
||||||
-- switch the current active NIC
|
-- switch the current active NIC
|
||||||
---@param act_nic nic
|
---@param act_nic nic
|
||||||
function public.switch_nic(act_nic)
|
function public.switch_nic(act_nic) nic = act_nic end
|
||||||
nic.closeAll()
|
|
||||||
|
|
||||||
-- configure receive channels
|
|
||||||
act_nic.closeAll()
|
|
||||||
act_nic.open(config.CRD_Channel)
|
|
||||||
|
|
||||||
nic = act_nic
|
|
||||||
end
|
|
||||||
|
|
||||||
-- try to connect to the supervisor if not already linked
|
-- try to connect to the supervisor if not already linked
|
||||||
---@param abort boolean? true to print out cancel info if not linked (use on program terminate)
|
---@param abort boolean? true to print out cancel info if not linked (use on program terminate)
|
||||||
|
|||||||
@@ -71,7 +71,6 @@ local function init(panel, config)
|
|||||||
wl_modem.register(ps, "has_wl_modem", wl_modem.update)
|
wl_modem.register(ps, "has_wl_modem", wl_modem.update)
|
||||||
else
|
else
|
||||||
local modem = LED{parent=system,label="MODEM",colors=led_grn}
|
local modem = LED{parent=system,label="MODEM",colors=led_grn}
|
||||||
modem.register(ps, "has_modem", modem.update)
|
|
||||||
modem.register(ps, util.trinary(config.WirelessModem, "has_wl_modem", "has_wd_modem"), modem.update)
|
modem.register(ps, util.trinary(config.WirelessModem, "has_wl_modem", "has_wd_modem"), modem.update)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -39,17 +39,19 @@ function backplane.init(config, __shared_memory)
|
|||||||
|
|
||||||
if _bp.smem.networked then
|
if _bp.smem.networked then
|
||||||
-- init wired NIC
|
-- init wired NIC
|
||||||
if type(config.WiredModem) == "string" then
|
if type(_bp.lan_iface) == "string" then
|
||||||
local modem = ppm.get_modem(_bp.lan_iface)
|
local modem = ppm.get_modem(_bp.lan_iface)
|
||||||
local wd_nic = network.nic(modem)
|
local wd_nic = network.nic(modem)
|
||||||
|
|
||||||
log.info("BKPLN: WIRED PHY_" .. util.trinary(modem, "UP ", "DOWN ") .. _bp.lan_iface)
|
log.info("BKPLN: WIRED PHY_" .. util.trinary(modem, "UP ", "DOWN ") .. _bp.lan_iface)
|
||||||
|
|
||||||
plc_state.wd_modem = wd_nic.is_connected()
|
|
||||||
|
|
||||||
-- set this as active for now
|
|
||||||
_bp.act_nic = wd_nic
|
|
||||||
_bp.wd_nic = wd_nic
|
_bp.wd_nic = wd_nic
|
||||||
|
_bp.act_nic = wd_nic -- set this as active for now
|
||||||
|
|
||||||
|
wd_nic.closeAll()
|
||||||
|
wd_nic.open(config.PLC_Channel)
|
||||||
|
|
||||||
|
plc_state.wd_modem = wd_nic.is_connected()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- init wireless NIC(s)
|
-- init wireless NIC(s)
|
||||||
@@ -59,14 +61,17 @@ function backplane.init(config, __shared_memory)
|
|||||||
|
|
||||||
log.info("BKPLN: WIRELESS PHY_" .. util.trinary(modem, "UP ", "DOWN ") .. iface)
|
log.info("BKPLN: WIRELESS PHY_" .. util.trinary(modem, "UP ", "DOWN ") .. iface)
|
||||||
|
|
||||||
plc_state.wl_modem = wl_nic.is_connected()
|
|
||||||
|
|
||||||
-- set this as active if connected or if both modems are disconnected and this is preferred
|
-- set this as active if connected or if both modems are disconnected and this is preferred
|
||||||
if (modem and _bp.wlan_pref) or not (_bp.act_nic and _bp.act_nic.is_connected()) then
|
if (modem and _bp.wlan_pref) or not (_bp.act_nic and _bp.act_nic.is_connected()) then
|
||||||
_bp.act_nic = wl_nic
|
_bp.act_nic = wl_nic
|
||||||
end
|
end
|
||||||
|
|
||||||
_bp.wl_nic = wl_nic
|
_bp.wl_nic = wl_nic
|
||||||
|
|
||||||
|
wl_nic.closeAll()
|
||||||
|
wl_nic.open(config.PLC_Channel)
|
||||||
|
|
||||||
|
plc_state.wl_modem = wl_nic.is_connected()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- comms modem is required if networked
|
-- comms modem is required if networked
|
||||||
@@ -86,6 +91,8 @@ function backplane.init(config, __shared_memory)
|
|||||||
|
|
||||||
-- we need a reactor, can at least do some things even if it isn't formed though
|
-- we need a reactor, can at least do some things even if it isn't formed though
|
||||||
if plc_state.no_reactor then
|
if plc_state.no_reactor then
|
||||||
|
log.info("BKPLN: REACTOR LINK_DOWN")
|
||||||
|
|
||||||
println("startup> fission reactor not found")
|
println("startup> fission reactor not found")
|
||||||
log.warning("BKPLN: no reactor on startup")
|
log.warning("BKPLN: no reactor on startup")
|
||||||
|
|
||||||
@@ -97,14 +104,16 @@ function backplane.init(config, __shared_memory)
|
|||||||
plc_dev.reactor = dev
|
plc_dev.reactor = dev
|
||||||
|
|
||||||
log.info("BKPLN: mounted virtual device as reactor")
|
log.info("BKPLN: mounted virtual device as reactor")
|
||||||
elseif not plc_dev.reactor.isFormed() then
|
else
|
||||||
|
log.info("BKPLN: REACTOR LINK_UP " .. ppm.get_iface(plc_dev.reactor))
|
||||||
|
|
||||||
|
if not plc_dev.reactor.isFormed() then
|
||||||
println("startup> fission reactor is not formed")
|
println("startup> fission reactor is not formed")
|
||||||
log.warning("BKPLN: reactor logic adapter present, but reactor is not formed")
|
log.warning("BKPLN: reactor logic adapter detected, but reactor is not formed")
|
||||||
|
|
||||||
plc_state.degraded = true
|
plc_state.degraded = true
|
||||||
plc_state.reactor_formed = false
|
plc_state.reactor_formed = false
|
||||||
else
|
end
|
||||||
log.info("BKPLN: reactor detected")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -129,6 +138,8 @@ function backplane.attach(iface, type, device, print_no_fp)
|
|||||||
if type ~= nil and device ~= nil then
|
if type ~= nil and device ~= nil then
|
||||||
if state.no_reactor and (type == "fissionReactorLogicAdapter") then
|
if state.no_reactor and (type == "fissionReactorLogicAdapter") then
|
||||||
-- reconnected reactor
|
-- reconnected reactor
|
||||||
|
log.info("BKPLN: REACTOR LINK_UP " .. iface)
|
||||||
|
|
||||||
dev.reactor = device
|
dev.reactor = device
|
||||||
state.no_reactor = false
|
state.no_reactor = false
|
||||||
|
|
||||||
@@ -225,6 +236,8 @@ function backplane.detach(iface, type, device, print_no_fp)
|
|||||||
local sys = _bp.smem.plc_sys
|
local sys = _bp.smem.plc_sys
|
||||||
|
|
||||||
if device == dev.reactor then
|
if device == dev.reactor then
|
||||||
|
log.info("BKPLN: REACTOR LINK_DOWN " .. iface)
|
||||||
|
|
||||||
print_no_fp("reactor disconnected")
|
print_no_fp("reactor disconnected")
|
||||||
log.warning("BKPLN: reactor disconnected")
|
log.warning("BKPLN: reactor disconnected")
|
||||||
|
|
||||||
|
|||||||
@@ -563,10 +563,6 @@ function plc.comms(version, nic, reactor, rps, conn_watchdog)
|
|||||||
comms.set_trusted_range(config.TrustedRange)
|
comms.set_trusted_range(config.TrustedRange)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- configure network channels
|
|
||||||
nic.closeAll()
|
|
||||||
nic.open(config.PLC_Channel)
|
|
||||||
|
|
||||||
--#region PRIVATE FUNCTIONS --
|
--#region PRIVATE FUNCTIONS --
|
||||||
|
|
||||||
-- send an RPLC packet
|
-- send an RPLC packet
|
||||||
@@ -834,15 +830,7 @@ function plc.comms(version, nic, reactor, rps, conn_watchdog)
|
|||||||
|
|
||||||
-- switch the current active NIC
|
-- switch the current active NIC
|
||||||
---@param act_nic nic
|
---@param act_nic nic
|
||||||
function public.switch_nic(act_nic)
|
function public.switch_nic(act_nic) nic = act_nic end
|
||||||
nic.closeAll()
|
|
||||||
|
|
||||||
-- configure receive channels
|
|
||||||
act_nic.closeAll()
|
|
||||||
act_nic.open(config.PLC_Channel)
|
|
||||||
|
|
||||||
nic = act_nic
|
|
||||||
end
|
|
||||||
|
|
||||||
-- reconnect a newly connected reactor
|
-- reconnect a newly connected reactor
|
||||||
---@param new_reactor table
|
---@param new_reactor table
|
||||||
|
|||||||
@@ -40,15 +40,17 @@ function backplane.init(config, __shared_memory)
|
|||||||
-- Modem Init
|
-- Modem Init
|
||||||
|
|
||||||
-- init wired NIC
|
-- init wired NIC
|
||||||
if type(config.WiredModem) == "string" then
|
if type(_bp.lan_iface) == "string" then
|
||||||
local modem = ppm.get_modem(_bp.lan_iface)
|
local modem = ppm.get_modem(_bp.lan_iface)
|
||||||
local wd_nic = network.nic(modem)
|
local wd_nic = network.nic(modem)
|
||||||
|
|
||||||
log.info("BKPLN: WIRED PHY_" .. util.trinary(modem, "UP ", "DOWN ") .. _bp.lan_iface)
|
log.info("BKPLN: WIRED PHY_" .. util.trinary(modem, "UP ", "DOWN ") .. _bp.lan_iface)
|
||||||
|
|
||||||
-- set this as active for now
|
|
||||||
_bp.act_nic = wd_nic
|
|
||||||
_bp.wd_nic = wd_nic
|
_bp.wd_nic = wd_nic
|
||||||
|
_bp.act_nic = wd_nic -- set this as active for now
|
||||||
|
|
||||||
|
wd_nic.closeAll()
|
||||||
|
wd_nic.open(config.RTU_Channel)
|
||||||
|
|
||||||
databus.tx_hw_wd_modem(modem ~= nil)
|
databus.tx_hw_wd_modem(modem ~= nil)
|
||||||
end
|
end
|
||||||
@@ -67,6 +69,9 @@ function backplane.init(config, __shared_memory)
|
|||||||
|
|
||||||
_bp.wl_nic = wl_nic
|
_bp.wl_nic = wl_nic
|
||||||
|
|
||||||
|
wl_nic.closeAll()
|
||||||
|
wl_nic.open(config.RTU_Channel)
|
||||||
|
|
||||||
databus.tx_hw_wl_modem(modem ~= nil)
|
databus.tx_hw_wl_modem(modem ~= nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -82,10 +87,9 @@ function backplane.init(config, __shared_memory)
|
|||||||
-- find and setup all speakers
|
-- find and setup all speakers
|
||||||
local speakers = ppm.get_all_devices("speaker")
|
local speakers = ppm.get_all_devices("speaker")
|
||||||
for _, s in pairs(speakers) do
|
for _, s in pairs(speakers) do
|
||||||
|
log.info("BKPLN: SPEAKER LINK_UP " .. ppm.get_iface(s))
|
||||||
|
|
||||||
local sounder = rtu.init_sounder(s)
|
local sounder = rtu.init_sounder(s)
|
||||||
|
|
||||||
log.info("BKPLN: SPEAKER LINK_UP " .. sounder.name)
|
|
||||||
|
|
||||||
table.insert(_bp.sounders, sounder)
|
table.insert(_bp.sounders, sounder)
|
||||||
|
|
||||||
log.debug(util.c("BKPLN: added speaker sounder, attached as ", sounder.name))
|
log.debug(util.c("BKPLN: added speaker sounder, attached as ", sounder.name))
|
||||||
|
|||||||
14
rtu/rtu.lua
14
rtu/rtu.lua
@@ -310,10 +310,6 @@ function rtu.comms(version, nic, conn_watchdog)
|
|||||||
comms.set_trusted_range(config.TrustedRange)
|
comms.set_trusted_range(config.TrustedRange)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- configure network channels
|
|
||||||
nic.closeAll()
|
|
||||||
nic.open(config.RTU_Channel)
|
|
||||||
|
|
||||||
--#region PRIVATE FUNCTIONS --
|
--#region PRIVATE FUNCTIONS --
|
||||||
|
|
||||||
-- send a scada management packet
|
-- send a scada management packet
|
||||||
@@ -363,15 +359,7 @@ function rtu.comms(version, nic, conn_watchdog)
|
|||||||
|
|
||||||
-- switch the current active NIC
|
-- switch the current active NIC
|
||||||
---@param act_nic nic
|
---@param act_nic nic
|
||||||
function public.switch_nic(act_nic)
|
function public.switch_nic(act_nic) nic = act_nic end
|
||||||
nic.closeAll()
|
|
||||||
|
|
||||||
-- configure receive channels
|
|
||||||
act_nic.closeAll()
|
|
||||||
act_nic.open(config.RTU_Channel)
|
|
||||||
|
|
||||||
nic = act_nic
|
|
||||||
end
|
|
||||||
|
|
||||||
-- unlink from the server
|
-- unlink from the server
|
||||||
---@param rtu_state rtu_state
|
---@param rtu_state rtu_state
|
||||||
|
|||||||
@@ -23,31 +23,33 @@ local _bp = {
|
|||||||
nic_map = {} ---@type nic[] connected nics
|
nic_map = {} ---@type nic[] connected nics
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- network interfaces indexed by peripheral names
|
||||||
backplane.nics = _bp.nic_map
|
backplane.nics = _bp.nic_map
|
||||||
|
|
||||||
-- initialize the system peripheral backplane
|
-- initialize the system peripheral backplane
|
||||||
---@param config svr_config
|
---@param config svr_config
|
||||||
---@return boolean success
|
---@return boolean success
|
||||||
function backplane.init(config)
|
function backplane.init(config)
|
||||||
-- setup the wired modem, if configured
|
|
||||||
if type(config.WiredModem) == "string" then
|
|
||||||
_bp.lan_iface = config.WiredModem
|
_bp.lan_iface = config.WiredModem
|
||||||
|
|
||||||
|
-- setup the wired modem, if configured
|
||||||
|
if type(_bp.lan_iface) == "string" then
|
||||||
local modem = ppm.get_modem(_bp.lan_iface)
|
local modem = ppm.get_modem(_bp.lan_iface)
|
||||||
|
local wd_nic = network.nic(modem)
|
||||||
|
|
||||||
|
log.info("BKPLN: WIRED PHY_" .. util.trinary(modem, "UP ", "DOWN ") .. _bp.lan_iface)
|
||||||
|
|
||||||
if not (modem and _bp.lan_iface) then
|
if not (modem and _bp.lan_iface) then
|
||||||
println("startup> wired comms modem not found")
|
println("startup> wired comms modem not found")
|
||||||
log.fatal("BKPLN: no wired comms modem on startup")
|
log.fatal("BKPLN: no wired comms modem on startup")
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local nic = network.nic(modem)
|
_bp.wd_nic = wd_nic
|
||||||
_bp.wd_nic = nic
|
_bp.nic_map[_bp.lan_iface] = wd_nic
|
||||||
_bp.nic_map[_bp.lan_iface] = nic
|
|
||||||
|
|
||||||
log.info("BKPLN: WIRED PHY_UP " .. _bp.lan_iface)
|
wd_nic.closeAll()
|
||||||
|
wd_nic.open(config.SVR_Channel)
|
||||||
nic.closeAll()
|
|
||||||
nic.open(config.SVR_Channel)
|
|
||||||
|
|
||||||
databus.tx_hw_wd_modem(true)
|
databus.tx_hw_wd_modem(true)
|
||||||
end
|
end
|
||||||
@@ -55,20 +57,21 @@ function backplane.init(config)
|
|||||||
-- setup the wireless modem, if configured
|
-- setup the wireless modem, if configured
|
||||||
if config.WirelessModem then
|
if config.WirelessModem then
|
||||||
local modem, iface = ppm.get_wireless_modem()
|
local modem, iface = ppm.get_wireless_modem()
|
||||||
|
local wl_nic = network.nic(modem)
|
||||||
|
|
||||||
|
log.info("BKPLN: WIRELESS PHY_" .. util.trinary(modem, "UP ", "DOWN ") .. iface)
|
||||||
|
|
||||||
if not (modem and iface) then
|
if not (modem and iface) then
|
||||||
println("startup> wireless comms modem not found")
|
println("startup> wireless comms modem not found")
|
||||||
log.fatal("BKPLN: no wireless comms modem on startup")
|
log.fatal("BKPLN: no wireless comms modem on startup")
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local nic = network.nic(modem)
|
_bp.wl_nic = wl_nic
|
||||||
_bp.wl_nic = nic
|
_bp.nic_map[iface] = wl_nic
|
||||||
_bp.nic_map[iface] = nic
|
|
||||||
|
|
||||||
log.info("BKPLN: WIRELESS PHY_UP " .. iface)
|
wl_nic.closeAll()
|
||||||
|
wl_nic.open(config.SVR_Channel)
|
||||||
nic.closeAll()
|
|
||||||
nic.open(config.SVR_Channel)
|
|
||||||
|
|
||||||
databus.tx_hw_wl_modem(true)
|
databus.tx_hw_wl_modem(true)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user