mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
RTU modem init consistency and cleanup
This commit is contained in:
parent
3cc6781844
commit
a4add9370c
@ -19,7 +19,7 @@ local renderer = require("coordinator.renderer")
|
|||||||
local sounder = require("coordinator.sounder")
|
local sounder = require("coordinator.sounder")
|
||||||
local threads = require("coordinator.threads")
|
local threads = require("coordinator.threads")
|
||||||
|
|
||||||
local COORDINATOR_VERSION = "v1.5.0"
|
local COORDINATOR_VERSION = "v1.5.1"
|
||||||
|
|
||||||
local CHUNK_LOAD_DELAY_S = 30.0
|
local CHUNK_LOAD_DELAY_S = 30.0
|
||||||
|
|
||||||
@ -151,8 +151,8 @@ local function main()
|
|||||||
|
|
||||||
-- core coordinator devices
|
-- core coordinator devices
|
||||||
crd_dev = {
|
crd_dev = {
|
||||||
speaker = ppm.get_device("speaker"),
|
modem = ppm.get_wireless_modem(),
|
||||||
modem = ppm.get_wireless_modem()
|
speaker = ppm.get_device("speaker")
|
||||||
},
|
},
|
||||||
|
|
||||||
-- system objects
|
-- system objects
|
||||||
|
@ -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.10.0"
|
local RTU_VERSION = "v1.10.1"
|
||||||
|
|
||||||
local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE
|
local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE
|
||||||
local RTU_UNIT_HW_STATE = databus.RTU_UNIT_HW_STATE
|
local RTU_UNIT_HW_STATE = databus.RTU_UNIT_HW_STATE
|
||||||
@ -93,14 +93,6 @@ local function main()
|
|||||||
network.init_mac(config.AuthKey)
|
network.init_mac(config.AuthKey)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- get modem
|
|
||||||
local modem = ppm.get_wireless_modem()
|
|
||||||
if modem == nil then
|
|
||||||
println("boot> wireless modem not found")
|
|
||||||
log.fatal("no wireless modem on startup")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- generate alarm tones
|
-- generate alarm tones
|
||||||
audio.generate_tones()
|
audio.generate_tones()
|
||||||
|
|
||||||
@ -116,14 +108,15 @@ local function main()
|
|||||||
|
|
||||||
-- RTU gateway devices (not RTU units)
|
-- RTU gateway devices (not RTU units)
|
||||||
rtu_dev = {
|
rtu_dev = {
|
||||||
|
modem = ppm.get_wireless_modem(),
|
||||||
sounders = {}
|
sounders = {}
|
||||||
},
|
},
|
||||||
|
|
||||||
-- system objects
|
-- system objects
|
||||||
rtu_sys = {
|
rtu_sys = {
|
||||||
nic = network.nic(modem),
|
nic = nil, ---@type nic
|
||||||
rtu_comms = nil, ---@type rtu_comms
|
rtu_comms = nil, ---@type rtu_comms
|
||||||
conn_watchdog = nil, ---@type watchdog
|
conn_watchdog = nil, ---@type watchdog
|
||||||
units = {}
|
units = {}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -134,8 +127,9 @@ local function main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
local smem_sys = __shared_memory.rtu_sys
|
local smem_sys = __shared_memory.rtu_sys
|
||||||
|
local smem_dev = __shared_memory.rtu_dev
|
||||||
|
|
||||||
databus.tx_hw_modem(true)
|
local rtu_state = __shared_memory.rtu_state
|
||||||
|
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
-- interpret config and init units
|
-- interpret config and init units
|
||||||
@ -501,8 +495,6 @@ local function main()
|
|||||||
-- start system
|
-- start system
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
|
|
||||||
local rtu_state = __shared_memory.rtu_state
|
|
||||||
|
|
||||||
log.debug("boot> running sys_config()")
|
log.debug("boot> running sys_config()")
|
||||||
|
|
||||||
if sys_config() then
|
if sys_config() then
|
||||||
@ -517,23 +509,33 @@ local function main()
|
|||||||
log.info("startup> running in headless mode without front panel")
|
log.info("startup> running in headless mode without front panel")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- check modem
|
||||||
|
if smem_dev.modem == nil then
|
||||||
|
println("startup> wireless modem not found")
|
||||||
|
log.fatal("no wireless modem on startup")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
databus.tx_hw_modem(true)
|
||||||
|
|
||||||
-- 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
|
||||||
local sounder = rtu.init_sounder(s)
|
local sounder = rtu.init_sounder(s)
|
||||||
|
|
||||||
table.insert(__shared_memory.rtu_dev.sounders, sounder)
|
table.insert(smem_dev.sounders, sounder)
|
||||||
|
|
||||||
log.debug(util.c("startup> added speaker, attached as ", sounder.name))
|
log.debug(util.c("startup> added speaker, attached as ", sounder.name))
|
||||||
end
|
end
|
||||||
|
|
||||||
databus.tx_hw_spkr_count(#__shared_memory.rtu_dev.sounders)
|
databus.tx_hw_spkr_count(#smem_dev.sounders)
|
||||||
|
|
||||||
-- start connection watchdog
|
-- start connection watchdog
|
||||||
smem_sys.conn_watchdog = util.new_watchdog(config.ConnTimeout)
|
smem_sys.conn_watchdog = util.new_watchdog(config.ConnTimeout)
|
||||||
log.debug("startup> conn watchdog started")
|
log.debug("startup> conn watchdog started")
|
||||||
|
|
||||||
-- setup comms
|
-- setup comms
|
||||||
|
smem_sys.nic = network.nic(smem_dev.modem)
|
||||||
smem_sys.rtu_comms = rtu.comms(RTU_VERSION, smem_sys.nic, smem_sys.conn_watchdog)
|
smem_sys.rtu_comms = rtu.comms(RTU_VERSION, smem_sys.nic, smem_sys.conn_watchdog)
|
||||||
log.debug("startup> comms init")
|
log.debug("startup> comms init")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user