protected sleep call

This commit is contained in:
Mikayla Fischler 2022-04-27 15:56:55 -04:00
parent 67a93016c0
commit 146e0bf569
4 changed files with 12 additions and 8 deletions

View File

@ -12,7 +12,7 @@ os.loadAPI("config.lua")
os.loadAPI("plc.lua") os.loadAPI("plc.lua")
os.loadAPI("threads.lua") os.loadAPI("threads.lua")
local R_PLC_VERSION = "alpha-v0.4.1" local R_PLC_VERSION = "alpha-v0.4.2"
local print = util.print local print = util.print
local println = util.println local println = util.println

View File

@ -8,6 +8,8 @@ local println = util.println
local print_ts = util.print_ts local print_ts = util.print_ts
local println_ts = util.println_ts local println_ts = util.println_ts
local psleep = util.psleep
local MAIN_CLOCK = 1 -- (1Hz, 20 ticks) local MAIN_CLOCK = 1 -- (1Hz, 20 ticks)
local ISS_CLOCK = 0.5 -- (2Hz, 10 ticks) local ISS_CLOCK = 0.5 -- (2Hz, 10 ticks)
local COMMS_CLOCK = 0.25 -- (4Hz, 5 ticks) local COMMS_CLOCK = 0.25 -- (4Hz, 5 ticks)
@ -302,9 +304,9 @@ function thread__iss(smem)
local sleep_for = ISS_CLOCK - (util.time() - last_update) local sleep_for = ISS_CLOCK - (util.time() - last_update)
last_update = util.time() last_update = util.time()
if sleep_for > 0 then if sleep_for > 0 then
sleep(sleep_for) psleep(sleep_for)
else else
sleep(0.05) psleep(0.05)
end end
end end
end end
@ -361,9 +363,9 @@ function thread__comms(smem)
local sleep_for = COMMS_CLOCK - (util.time() - last_update) local sleep_for = COMMS_CLOCK - (util.time() - last_update)
last_update = util.time() last_update = util.time()
if sleep_for > 0 then if sleep_for > 0 then
sleep(sleep_for) psleep(sleep_for)
else else
sleep(0.05) psleep(0.05)
end end
end end
end end

View File

@ -19,7 +19,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.4.1" local RTU_VERSION = "alpha-v0.4.2"
local print = util.print local print = util.print
local println = util.println local println = util.println

View File

@ -8,6 +8,8 @@ local println = util.println
local print_ts = util.print_ts local print_ts = util.print_ts
local println_ts = util.println_ts local println_ts = util.println_ts
local psleep = util.psleep
local MAIN_CLOCK = 2 -- (2Hz, 40 ticks) local MAIN_CLOCK = 2 -- (2Hz, 40 ticks)
local COMMS_CLOCK = 0.25 -- (4Hz, 5 ticks) local COMMS_CLOCK = 0.25 -- (4Hz, 5 ticks)
@ -146,9 +148,9 @@ function thread__comms(smem)
local sleep_for = COMMS_CLOCK - (util.time() - last_update) local sleep_for = COMMS_CLOCK - (util.time() - last_update)
last_update = util.time() last_update = util.time()
if sleep_for > 0 then if sleep_for > 0 then
sleep(sleep_for) psleep(sleep_for)
else else
sleep(0.05) psleep(0.05)
end end
end end
end end