diff --git a/coordinator/startup.lua b/coordinator/startup.lua index ab90f72..aa65be4 100644 --- a/coordinator/startup.lua +++ b/coordinator/startup.lua @@ -2,6 +2,8 @@ -- Nuclear Generation Facility SCADA Coordinator -- +require("/initenv").init_env() + local log = require("scada-common.log") local ppm = require("scada-common.ppm") local util = require("scada-common.util") diff --git a/initenv.lua b/initenv.lua new file mode 100644 index 0000000..257af39 --- /dev/null +++ b/initenv.lua @@ -0,0 +1,18 @@ +-- +-- Initialize the Boot Environment +-- + +-- initialize booted environment +local init_env = function () + local _require = require("cc.require") + local _env = setmetatable({}, { __index = _ENV }) + + -- overwrite require/package globals + require, package = _require.make(_env, "/") + + -- reset terminal + term.clear() + term.setCursorPos(1, 1) +end + +return { init_env = init_env } diff --git a/pocket/startup.lua b/pocket/startup.lua index aeeaef4..40a0777 100644 --- a/pocket/startup.lua +++ b/pocket/startup.lua @@ -1,3 +1,5 @@ -- -- SCADA Coordinator Access on a Pocket Computer --- \ No newline at end of file +-- + +require("/initenv").init_env() diff --git a/reactor-plc/startup.lua b/reactor-plc/startup.lua index 0aaaeba..aad57f7 100644 --- a/reactor-plc/startup.lua +++ b/reactor-plc/startup.lua @@ -2,6 +2,8 @@ -- Reactor Programmable Logic Controller -- +require("/initenv").init_env() + local log = require("scada-common.log") local mqueue = require("scada-common.mqueue") local ppm = require("scada-common.ppm") diff --git a/rtu/startup.lua b/rtu/startup.lua index b37e3fd..94ae506 100644 --- a/rtu/startup.lua +++ b/rtu/startup.lua @@ -2,6 +2,8 @@ -- RTU: Remote Terminal Unit -- +require("/initenv").init_env() + local log = require("scada-common.log") local mqueue = require("scada-common.mqueue") local ppm = require("scada-common.ppm") diff --git a/startup.lua b/startup.lua index 0a5cffb..482c919 100644 --- a/startup.lua +++ b/startup.lua @@ -1,6 +1,6 @@ local util = require("scada-common.util") -local BOOTLOADER_VERSION = "0.1" +local BOOTLOADER_VERSION = "0.2" local println = util.println local println_ts = util.println_ts @@ -43,9 +43,7 @@ else return false end -if exit_code then - println_ts("BOOT> APPLICATION EXITED OK") -else +if not exit_code then println_ts("BOOT> APPLICATION CRASHED") end diff --git a/supervisor/startup.lua b/supervisor/startup.lua index 16725b6..53f3e1a 100644 --- a/supervisor/startup.lua +++ b/supervisor/startup.lua @@ -2,6 +2,8 @@ -- Nuclear Generation Facility SCADA Supervisor -- +require("/initenv").init_env() + local log = require("scada-common.log") local ppm = require("scada-common.ppm") local util = require("scada-common.util")