mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
added time functions to util, also task_wait
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
-- #REQUIRES util.lua
|
||||
|
||||
SEVERITY = {
|
||||
INFO = 0, -- basic info message
|
||||
WARNING = 1, -- warning about some abnormal state
|
||||
@ -9,7 +11,7 @@ SEVERITY = {
|
||||
|
||||
function scada_alarm(severity, device, message)
|
||||
local self = {
|
||||
time = os.epoch(),
|
||||
time = util.time(),
|
||||
ts_string = os.date("[%H:%M:%S]"),
|
||||
severity = severity,
|
||||
device = device,
|
||||
|
@ -1,3 +1,5 @@
|
||||
-- PRINT --
|
||||
|
||||
-- we are overwriting 'print' so save it first
|
||||
local _print = print
|
||||
|
||||
@ -21,6 +23,28 @@ function println_ts(message)
|
||||
_print(os.date("[%H:%M:%S] ") .. message)
|
||||
end
|
||||
|
||||
-- TIME --
|
||||
|
||||
function time_ms()
|
||||
return os.epoch('local')
|
||||
end
|
||||
|
||||
function time_s()
|
||||
return os.epoch('local') / 1000
|
||||
end
|
||||
|
||||
function time()
|
||||
return time_ms()
|
||||
end
|
||||
|
||||
-- PARALLELIZATION --
|
||||
|
||||
-- block waiting for parallel call
|
||||
function task_wait(f)
|
||||
parallel.waitForAll(f)
|
||||
end
|
||||
|
||||
-- WATCHDOG --
|
||||
|
||||
-- ComputerCraft OS Timer based Watchdog
|
||||
-- triggers a timer event if not fed within 'timeout' seconds
|
||||
|
Reference in New Issue
Block a user