mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#268 better handling of wireless modem peripherals
This commit is contained in:
parent
a5214730ef
commit
8b136d78a8
@ -22,7 +22,7 @@ local sounder = require("coordinator.sounder")
|
|||||||
|
|
||||||
local apisessions = require("coordinator.session.apisessions")
|
local apisessions = require("coordinator.session.apisessions")
|
||||||
|
|
||||||
local COORDINATOR_VERSION = "v0.19.1"
|
local COORDINATOR_VERSION = "v0.19.2"
|
||||||
|
|
||||||
local println = util.println
|
local println = util.println
|
||||||
local println_ts = util.println_ts
|
local println_ts = util.println_ts
|
||||||
@ -234,6 +234,11 @@ local function main()
|
|||||||
nic.disconnect()
|
nic.disconnect()
|
||||||
log_sys("comms modem disconnected")
|
log_sys("comms modem disconnected")
|
||||||
|
|
||||||
|
local other_modem = ppm.get_wireless_modem()
|
||||||
|
if other_modem then
|
||||||
|
log_sys("found another wireless modem, using it for comms")
|
||||||
|
nic.connect(other_modem)
|
||||||
|
else
|
||||||
-- close out main UI
|
-- close out main UI
|
||||||
renderer.close_ui()
|
renderer.close_ui()
|
||||||
|
|
||||||
@ -241,6 +246,7 @@ local function main()
|
|||||||
log_sys("awaiting comms modem reconnect...")
|
log_sys("awaiting comms modem reconnect...")
|
||||||
|
|
||||||
iocontrol.fp_has_modem(false)
|
iocontrol.fp_has_modem(false)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
log_sys("non-comms modem disconnected")
|
log_sys("non-comms modem disconnected")
|
||||||
end
|
end
|
||||||
@ -263,7 +269,7 @@ local function main()
|
|||||||
|
|
||||||
if type ~= nil and device ~= nil then
|
if type ~= nil and device ~= nil then
|
||||||
if type == "modem" then
|
if type == "modem" then
|
||||||
if device.isWireless() then
|
if device.isWireless() and not nic.is_connected() then
|
||||||
-- reconnected modem
|
-- reconnected modem
|
||||||
log_sys("comms modem reconnected")
|
log_sys("comms modem reconnected")
|
||||||
nic.connect(device)
|
nic.connect(device)
|
||||||
@ -288,7 +294,7 @@ local function main()
|
|||||||
iocontrol.heartbeat()
|
iocontrol.heartbeat()
|
||||||
|
|
||||||
-- maintain connection
|
-- maintain connection
|
||||||
if nic.connected() then
|
if nic.is_connected() then
|
||||||
local ok, start_ui = coord_comms.try_connect()
|
local ok, start_ui = coord_comms.try_connect()
|
||||||
if not ok then
|
if not ok then
|
||||||
link_failed = true
|
link_failed = true
|
||||||
|
@ -19,7 +19,7 @@ local plc = require("reactor-plc.plc")
|
|||||||
local renderer = require("reactor-plc.renderer")
|
local renderer = require("reactor-plc.renderer")
|
||||||
local threads = require("reactor-plc.threads")
|
local threads = require("reactor-plc.threads")
|
||||||
|
|
||||||
local R_PLC_VERSION = "v1.5.2"
|
local R_PLC_VERSION = "v1.5.3"
|
||||||
|
|
||||||
local println = util.println
|
local println = util.println
|
||||||
local println_ts = util.println_ts
|
local println_ts = util.println_ts
|
||||||
|
@ -77,7 +77,7 @@ function threads.thread__main(smem, init)
|
|||||||
loop_clock.start()
|
loop_clock.start()
|
||||||
|
|
||||||
-- send updated data
|
-- send updated data
|
||||||
if nic.connected() then
|
if nic.is_connected() then
|
||||||
if plc_comms.is_linked() then
|
if plc_comms.is_linked() then
|
||||||
smem.q.mq_comms_tx.push_command(MQ__COMM_CMD.SEND_STATUS)
|
smem.q.mq_comms_tx.push_command(MQ__COMM_CMD.SEND_STATUS)
|
||||||
else
|
else
|
||||||
@ -116,7 +116,7 @@ function threads.thread__main(smem, init)
|
|||||||
smem.q.mq_rps.push_command(MQ__RPS_CMD.SCRAM)
|
smem.q.mq_rps.push_command(MQ__RPS_CMD.SCRAM)
|
||||||
|
|
||||||
-- determine if we are still in a degraded state
|
-- determine if we are still in a degraded state
|
||||||
if (not networked) or nic.connected() then
|
if (not networked) or nic.is_connected() then
|
||||||
plc_state.degraded = false
|
plc_state.degraded = false
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -146,7 +146,7 @@ function threads.thread__main(smem, init)
|
|||||||
|
|
||||||
-- update indicators
|
-- update indicators
|
||||||
databus.tx_hw_status(plc_state)
|
databus.tx_hw_status(plc_state)
|
||||||
elseif event == "modem_message" and networked and plc_state.init_ok and nic.connected() then
|
elseif event == "modem_message" and networked and plc_state.init_ok and nic.is_connected() then
|
||||||
-- got a packet
|
-- got a packet
|
||||||
local packet = plc_comms.parse_packet(param1, param2, param3, param4, param5)
|
local packet = plc_comms.parse_packet(param1, param2, param3, param4, param5)
|
||||||
if packet ~= nil then
|
if packet ~= nil then
|
||||||
@ -177,16 +177,21 @@ function threads.thread__main(smem, init)
|
|||||||
nic.disconnect()
|
nic.disconnect()
|
||||||
|
|
||||||
println_ts("comms modem disconnected!")
|
println_ts("comms modem disconnected!")
|
||||||
log.error("comms modem disconnected")
|
log.warning("comms modem disconnected")
|
||||||
|
|
||||||
|
local other_modem = ppm.get_wireless_modem()
|
||||||
|
if other_modem then
|
||||||
|
log.info("found another wireless modem, using it for comms")
|
||||||
|
nic.connect(other_modem)
|
||||||
|
else
|
||||||
plc_state.no_modem = true
|
plc_state.no_modem = true
|
||||||
|
plc_state.degraded = true
|
||||||
|
|
||||||
if plc_state.init_ok then
|
if plc_state.init_ok then
|
||||||
-- try to scram reactor if it is still connected
|
-- try to scram reactor if it is still connected
|
||||||
smem.q.mq_rps.push_command(MQ__RPS_CMD.DEGRADED_SCRAM)
|
smem.q.mq_rps.push_command(MQ__RPS_CMD.DEGRADED_SCRAM)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
plc_state.degraded = true
|
|
||||||
else
|
else
|
||||||
log.warning("non-comms modem disconnected")
|
log.warning("non-comms modem disconnected")
|
||||||
end
|
end
|
||||||
@ -230,7 +235,7 @@ function threads.thread__main(smem, init)
|
|||||||
rps.reset()
|
rps.reset()
|
||||||
end
|
end
|
||||||
elseif networked and type == "modem" then
|
elseif networked and type == "modem" then
|
||||||
if device.isWireless() then
|
if device.isWireless() and not nic.is_connected() then
|
||||||
-- reconnected modem
|
-- reconnected modem
|
||||||
plc_dev.modem = device
|
plc_dev.modem = device
|
||||||
plc_state.no_modem = false
|
plc_state.no_modem = false
|
||||||
|
@ -30,7 +30,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.5.0"
|
local RTU_VERSION = "v1.5.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
|
||||||
|
@ -98,9 +98,15 @@ function threads.thread__main(smem)
|
|||||||
nic.disconnect()
|
nic.disconnect()
|
||||||
|
|
||||||
println_ts("wireless modem disconnected!")
|
println_ts("wireless modem disconnected!")
|
||||||
log.warning("comms modem disconnected!")
|
log.warning("comms modem disconnected")
|
||||||
|
|
||||||
|
local other_modem = ppm.get_wireless_modem()
|
||||||
|
if other_modem then
|
||||||
|
log.info("found another wireless modem, using it for comms")
|
||||||
|
nic.connect(other_modem)
|
||||||
|
else
|
||||||
databus.tx_hw_modem(false)
|
databus.tx_hw_modem(false)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
log.warning("non-comms modem disconnected")
|
log.warning("non-comms modem disconnected")
|
||||||
end
|
end
|
||||||
@ -128,7 +134,7 @@ function threads.thread__main(smem)
|
|||||||
|
|
||||||
if type ~= nil and device ~= nil then
|
if type ~= nil and device ~= nil then
|
||||||
if type == "modem" then
|
if type == "modem" then
|
||||||
if device.isWireless() then
|
if device.isWireless() and not nic.is_connected() then
|
||||||
-- reconnected modem
|
-- reconnected modem
|
||||||
nic.connect(device)
|
nic.connect(device)
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ function network.nic(modem)
|
|||||||
|
|
||||||
-- check if this NIC has a connected modem
|
-- check if this NIC has a connected modem
|
||||||
---@nodiscard
|
---@nodiscard
|
||||||
function public.connected() return self.connected end
|
function public.is_connected() return self.connected end
|
||||||
|
|
||||||
-- connect to a modem peripheral
|
-- connect to a modem peripheral
|
||||||
---@param reconnected_modem table
|
---@param reconnected_modem table
|
||||||
|
@ -21,7 +21,7 @@ local supervisor = require("supervisor.supervisor")
|
|||||||
|
|
||||||
local svsessions = require("supervisor.session.svsessions")
|
local svsessions = require("supervisor.session.svsessions")
|
||||||
|
|
||||||
local SUPERVISOR_VERSION = "v0.19.2"
|
local SUPERVISOR_VERSION = "v0.19.3"
|
||||||
|
|
||||||
local println = util.println
|
local println = util.println
|
||||||
local println_ts = util.println_ts
|
local println_ts = util.println_ts
|
||||||
@ -153,7 +153,13 @@ local function main()
|
|||||||
println_ts("wireless modem disconnected!")
|
println_ts("wireless modem disconnected!")
|
||||||
log.warning("comms modem disconnected")
|
log.warning("comms modem disconnected")
|
||||||
|
|
||||||
|
local other_modem = ppm.get_wireless_modem()
|
||||||
|
if other_modem then
|
||||||
|
log.info("found another wireless modem, using it for comms")
|
||||||
|
nic.connect(other_modem)
|
||||||
|
else
|
||||||
databus.tx_hw_modem(false)
|
databus.tx_hw_modem(false)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
log.warning("non-comms modem disconnected")
|
log.warning("non-comms modem disconnected")
|
||||||
end
|
end
|
||||||
@ -164,7 +170,7 @@ local function main()
|
|||||||
|
|
||||||
if type ~= nil and device ~= nil then
|
if type ~= nil and device ~= nil then
|
||||||
if type == "modem" then
|
if type == "modem" then
|
||||||
if device.isWireless() and not nic.connected() then
|
if device.isWireless() and not nic.is_connected() then
|
||||||
-- reconnected modem
|
-- reconnected modem
|
||||||
nic.connect(device)
|
nic.connect(device)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user