#57 updates per safety pass, fixed plc_sys fields staying nil on degraded start, fixed repeated SCRAM messages when unlinked

This commit is contained in:
Mikayla Fischler
2022-05-22 17:57:24 -04:00
parent 26c6010ce0
commit a93f0a4452
6 changed files with 47 additions and 31 deletions

View File

@@ -137,6 +137,7 @@ end
---@param msg string message
---@param show_term? boolean whether or not to show on terminal output
log.dmesg = function (msg, show_term)
if msg == nil then return end
local message = string.format("[%10.3f] ", os.clock()) .. msg
if show_term then _write(message) end
_log(message)
@@ -146,6 +147,7 @@ end
---@param msg string message
---@param trace? boolean include file trace
log.debug = function (msg, trace)
if msg == nil then return end
if LOG_DEBUG then
local dbg_info = ""
@@ -167,12 +169,14 @@ end
-- log info messages
---@param msg string message
log.info = function (msg)
if msg == nil then return end
_log("[INF] " .. msg)
end
-- log warning messages
---@param msg string message
log.warning = function (msg)
if msg == nil then return end
_log("[WRN] " .. msg)
end
@@ -180,6 +184,7 @@ end
---@param msg string message
---@param trace? boolean include file trace
log.error = function (msg, trace)
if msg == nil then return end
local dbg_info = ""
if trace then
@@ -199,6 +204,7 @@ end
-- log fatal errors
---@param msg string message
log.fatal = function (msg)
if msg == nil then return end
_log("[FTL] " .. msg)
end

View File

@@ -189,12 +189,12 @@ ppm.mount = function (iface)
for i = 1, #ifaces do
if iface == ifaces[i] then
log.info("PPM: mount(" .. iface .. ") -> found a " .. peripheral.getType(iface))
_ppm_sys.mounts[iface] = peri_init(iface)
pm_type = _ppm_sys.mounts[iface].type
pm_dev = _ppm_sys.mounts[iface].dev
log.info("PPM: mount(" .. iface .. ") -> found a " .. pm_type)
break
end
end
@@ -262,7 +262,7 @@ end
ppm.get_all_devices = function (name)
local devices = {}
for side, data in pairs(_ppm_sys.mounts) do
for _, data in pairs(_ppm_sys.mounts) do
if data.type == name then
table.insert(devices, data.dev)
end
@@ -300,7 +300,7 @@ end
ppm.get_wireless_modem = function ()
local w_modem = nil
for side, device in pairs(_ppm_sys.mounts) do
for _, device in pairs(_ppm_sys.mounts) do
if device.type == "modem" and device.dev.isWireless() then
w_modem = device.dev
break

View File

@@ -19,11 +19,13 @@ end
-- timestamped print
util.print_ts = function (message)
if message == nil then return end
term.write(os.date("[%H:%M:%S] ") .. message)
end
-- timestamped print line
util.println_ts = function (message)
if message == nil then return end
print(os.date("[%H:%M:%S] ") .. message)
end
@@ -37,10 +39,10 @@ util.time_ms = function ()
end
-- current time
---@return integer seconds
---@return number seconds
util.time_s = function ()
---@diagnostic disable-next-line: undefined-field
return os.epoch('local') / 1000
return os.epoch('local') / 1000.0
end
-- current time