mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
catch terminations that are caught by PPM
This commit is contained in:
parent
91079eeb78
commit
6a5e0243be
@ -10,7 +10,7 @@ os.loadAPI("scada-common/comms.lua")
|
|||||||
os.loadAPI("config.lua")
|
os.loadAPI("config.lua")
|
||||||
os.loadAPI("plc.lua")
|
os.loadAPI("plc.lua")
|
||||||
|
|
||||||
local R_PLC_VERSION = "alpha-v0.1.5"
|
local R_PLC_VERSION = "alpha-v0.1.6"
|
||||||
|
|
||||||
local print = util.print
|
local print = util.print
|
||||||
local println = util.println
|
local println = util.println
|
||||||
@ -271,7 +271,12 @@ while true do
|
|||||||
iss.trip_timeout()
|
iss.trip_timeout()
|
||||||
println_ts("server timeout, reactor disabled")
|
println_ts("server timeout, reactor disabled")
|
||||||
log._warning("server timeout, reactor disabled")
|
log._warning("server timeout, reactor disabled")
|
||||||
elseif event == "terminate" then
|
end
|
||||||
|
|
||||||
|
-- check for termination request
|
||||||
|
if event == "terminate" or ppm.should_terminate() then
|
||||||
|
log._warning("terminate requested, exiting...")
|
||||||
|
|
||||||
-- safe exit
|
-- safe exit
|
||||||
if plc_state.init_ok then
|
if plc_state.init_ok then
|
||||||
plc_state.scram = true
|
plc_state.scram = true
|
||||||
@ -282,9 +287,11 @@ while true do
|
|||||||
println_ts("exiting, reactor failed to disable")
|
println_ts("exiting, reactor failed to disable")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- send an alarm: plc_comms.send_alarm(ALARMS.PLC_SHUTDOWN) ?
|
|
||||||
println_ts("exited")
|
break
|
||||||
log._info("terminate requested, exiting")
|
|
||||||
return
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- send an alarm: plc_comms.send_alarm(ALARMS.PLC_SHUTDOWN) ?
|
||||||
|
println_ts("exited")
|
||||||
|
log._info("exited")
|
||||||
|
@ -17,7 +17,7 @@ os.loadAPI("dev/boiler_rtu.lua")
|
|||||||
os.loadAPI("dev/imatrix_rtu.lua")
|
os.loadAPI("dev/imatrix_rtu.lua")
|
||||||
os.loadAPI("dev/turbine_rtu.lua")
|
os.loadAPI("dev/turbine_rtu.lua")
|
||||||
|
|
||||||
local RTU_VERSION = "alpha-v0.1.4"
|
local RTU_VERSION = "alpha-v0.1.5"
|
||||||
|
|
||||||
local print = util.print
|
local print = util.print
|
||||||
local println = util.println
|
local println = util.println
|
||||||
@ -237,7 +237,10 @@ while true do
|
|||||||
|
|
||||||
-- if linked, stop sending advertisements
|
-- if linked, stop sending advertisements
|
||||||
linked = link_ref.linked
|
linked = link_ref.linked
|
||||||
elseif event == "terminate" then
|
end
|
||||||
|
|
||||||
|
-- check for termination request
|
||||||
|
if event == "terminate" or ppm.should_terminate() then
|
||||||
log._warning("terminate requested, exiting...")
|
log._warning("terminate requested, exiting...")
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
@ -15,6 +15,7 @@ local self = {
|
|||||||
mounts = {},
|
mounts = {},
|
||||||
auto_cf = false,
|
auto_cf = false,
|
||||||
faulted = false,
|
faulted = false,
|
||||||
|
terminate = false,
|
||||||
mute = false
|
mute = false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,9 +39,15 @@ local peri_init = function (device)
|
|||||||
else
|
else
|
||||||
-- function failed
|
-- function failed
|
||||||
self.faulted = true
|
self.faulted = true
|
||||||
|
|
||||||
if not mute then
|
if not mute then
|
||||||
log._error("PPM: protected " .. key .. "() -> " .. result)
|
log._error("PPM: protected " .. key .. "() -> " .. result)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if result == "Terminated" then
|
||||||
|
self.terminate = true
|
||||||
|
end
|
||||||
|
|
||||||
return ACCESS_FAULT
|
return ACCESS_FAULT
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -85,6 +92,13 @@ function clear_fault()
|
|||||||
self.faulted = false
|
self.faulted = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- TERMINATION --
|
||||||
|
|
||||||
|
-- if a caught error was a termination request
|
||||||
|
function should_terminate()
|
||||||
|
return self.terminate
|
||||||
|
end
|
||||||
|
|
||||||
-- MOUNTING --
|
-- MOUNTING --
|
||||||
|
|
||||||
-- mount all available peripherals (clears mounts first)
|
-- mount all available peripherals (clears mounts first)
|
||||||
|
Loading…
Reference in New Issue
Block a user