mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#145 configure bootstrap command and size reduction of startup/initenv
This commit is contained in:
parent
f7766d8cba
commit
e4f49e9949
16
configure.lua
Normal file
16
configure.lua
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
print("CONFIGURE> SCANNING FOR CONFIGURATOR...")
|
||||||
|
|
||||||
|
if fs.exists("reactor-plc/configure.lua") then
|
||||||
|
require("reactor-plc/configure.lua").configure()
|
||||||
|
elseif fs.exists("rtu/startup.lua") then
|
||||||
|
print("CONFIGURE> RTU CONFIGURATOR NOT YET IMPLEMENTED IN BETA")
|
||||||
|
elseif fs.exists("supervisor/startup.lua") then
|
||||||
|
print("CONFIGURE> SUPERVISOR CONFIGURATOR NOT YET IMPLEMENTED IN BETA")
|
||||||
|
elseif fs.exists("coordinator/startup.lua") then
|
||||||
|
print("CONFIGURE> COORDINATOR CONFIGURATOR NOT YET IMPLEMENTED IN BETA")
|
||||||
|
elseif fs.exists("pocket/startup.lua") then
|
||||||
|
print("CONFIGURE> POCKET CONFIGURATOR NOT YET IMPLEMENTED IN BETA")
|
||||||
|
else
|
||||||
|
print("CONFIGURE> NO CONFIGURATOR FOUND")
|
||||||
|
print("CONFIGURE> EXIT")
|
||||||
|
end
|
4
imgen.py
4
imgen.py
@ -60,7 +60,7 @@ def make_manifest(size):
|
|||||||
},
|
},
|
||||||
"files" : {
|
"files" : {
|
||||||
# common files
|
# common files
|
||||||
"system" : [ "initenv.lua", "startup.lua" ],
|
"system" : [ "initenv.lua", "startup.lua", "configure.lua" ],
|
||||||
"common" : list_files("./scada-common"),
|
"common" : list_files("./scada-common"),
|
||||||
"graphics" : list_files("./graphics"),
|
"graphics" : list_files("./graphics"),
|
||||||
"lockbox" : list_files("./lockbox"),
|
"lockbox" : list_files("./lockbox"),
|
||||||
@ -82,7 +82,7 @@ def make_manifest(size):
|
|||||||
# manifest file estimate
|
# manifest file estimate
|
||||||
"manifest" : size,
|
"manifest" : size,
|
||||||
# common files
|
# common files
|
||||||
"system" : os.path.getsize("initenv.lua") + os.path.getsize("startup.lua"),
|
"system" : os.path.getsize("initenv.lua") + os.path.getsize("startup.lua") + os.path.getsize("configure.lua"),
|
||||||
"common" : dir_size("./scada-common"),
|
"common" : dir_size("./scada-common"),
|
||||||
"graphics" : dir_size("./graphics"),
|
"graphics" : dir_size("./graphics"),
|
||||||
"lockbox" : dir_size("./lockbox"),
|
"lockbox" : dir_size("./lockbox"),
|
||||||
|
12
initenv.lua
12
initenv.lua
@ -1,18 +1,10 @@
|
|||||||
--
|
|
||||||
-- Initialize the Post-Boot Module Environment
|
|
||||||
--
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
-- initialize booted environment
|
-- initialize booted environment
|
||||||
init_env = function ()
|
init_env = function ()
|
||||||
local _require = require("cc.require")
|
local _require, _env = require("cc.require"), setmetatable({}, { __index = _ENV })
|
||||||
local _env = setmetatable({}, { __index = _ENV })
|
|
||||||
|
|
||||||
-- overwrite require/package globals
|
-- overwrite require/package globals
|
||||||
require, package = _require.make(_env, "/")
|
require, package = _require.make(_env, "/")
|
||||||
|
|
||||||
-- reset terminal
|
-- reset terminal
|
||||||
term.clear()
|
term.clear(); term.setCursorPos(1, 1)
|
||||||
term.setCursorPos(1, 1)
|
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
29
startup.lua
29
startup.lua
@ -1,6 +1,6 @@
|
|||||||
local util = require("scada-common.util")
|
local util = require("scada-common.util")
|
||||||
|
|
||||||
local BOOTLOADER_VERSION = "0.2"
|
local BOOTLOADER_VERSION = "0.3"
|
||||||
|
|
||||||
local println = util.println
|
local println = util.println
|
||||||
local println_ts = util.println_ts
|
local println_ts = util.println_ts
|
||||||
@ -12,39 +12,26 @@ local exit_code ---@type boolean
|
|||||||
println_ts("BOOT> SCANNING FOR APPLICATIONS...")
|
println_ts("BOOT> SCANNING FOR APPLICATIONS...")
|
||||||
|
|
||||||
if fs.exists("reactor-plc/startup.lua") then
|
if fs.exists("reactor-plc/startup.lua") then
|
||||||
-- found reactor-plc application
|
println("BOOT> FOUND REACTOR PLC CODE: EXEC STARTUP")
|
||||||
println("BOOT> FOUND REACTOR PLC APPLICATION")
|
|
||||||
println("BOOT> EXEC STARTUP")
|
|
||||||
exit_code = shell.execute("reactor-plc/startup")
|
exit_code = shell.execute("reactor-plc/startup")
|
||||||
elseif fs.exists("rtu/startup.lua") then
|
elseif fs.exists("rtu/startup.lua") then
|
||||||
-- found rtu application
|
println("BOOT> FOUND RTU CODE: EXEC STARTUP")
|
||||||
println("BOOT> FOUND RTU APPLICATION")
|
|
||||||
println("BOOT> EXEC STARTUP")
|
|
||||||
exit_code = shell.execute("rtu/startup")
|
exit_code = shell.execute("rtu/startup")
|
||||||
elseif fs.exists("supervisor/startup.lua") then
|
elseif fs.exists("supervisor/startup.lua") then
|
||||||
-- found supervisor application
|
println("BOOT> FOUND SUPERVISOR CODE: EXEC STARTUP")
|
||||||
println("BOOT> FOUND SUPERVISOR APPLICATION")
|
|
||||||
println("BOOT> EXEC STARTUP")
|
|
||||||
exit_code = shell.execute("supervisor/startup")
|
exit_code = shell.execute("supervisor/startup")
|
||||||
elseif fs.exists("coordinator/startup.lua") then
|
elseif fs.exists("coordinator/startup.lua") then
|
||||||
-- found coordinator application
|
println("BOOT> FOUND COORDINATOR CODE: EXEC STARTUP")
|
||||||
println("BOOT> FOUND COORDINATOR APPLICATION")
|
|
||||||
println("BOOT> EXEC STARTUP")
|
|
||||||
exit_code = shell.execute("coordinator/startup")
|
exit_code = shell.execute("coordinator/startup")
|
||||||
elseif fs.exists("pocket/startup.lua") then
|
elseif fs.exists("pocket/startup.lua") then
|
||||||
-- found pocket application
|
println("BOOT> FOUND POCKET CODE: EXEC STARTUP")
|
||||||
println("BOOT> FOUND POCKET APPLICATION")
|
|
||||||
println("BOOT> EXEC STARTUP")
|
|
||||||
exit_code = shell.execute("pocket/startup")
|
exit_code = shell.execute("pocket/startup")
|
||||||
else
|
else
|
||||||
-- no known applications found
|
println("BOOT> NO SCADA STARTUP FOUND")
|
||||||
println("BOOT> NO SCADA STARTUP APPLICATION FOUND")
|
|
||||||
println("BOOT> EXIT")
|
println("BOOT> EXIT")
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
if not exit_code then
|
if not exit_code then println_ts("BOOT> APPLICATION CRASHED") end
|
||||||
println_ts("BOOT> APPLICATION CRASHED")
|
|
||||||
end
|
|
||||||
|
|
||||||
return exit_code
|
return exit_code
|
||||||
|
Loading…
Reference in New Issue
Block a user