mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
This commit is contained in:
parent
c620310e51
commit
1828920873
@ -16,7 +16,7 @@ local config = require("coordinator.config")
|
||||
local coordinator = require("coordinator.coordinator")
|
||||
local renderer = require("coordinator.renderer")
|
||||
|
||||
local COORDINATOR_VERSION = "alpha-v0.6.1"
|
||||
local COORDINATOR_VERSION = "alpha-v0.6.2"
|
||||
|
||||
local print = util.print
|
||||
local println = util.println
|
||||
@ -298,9 +298,6 @@ while ui_ok do
|
||||
renderer.handle_touch(core.events.touch(param1, param2, param3))
|
||||
end
|
||||
|
||||
-- call unserviced TCD callbacks
|
||||
tcallbackdsp.call_unserviced()
|
||||
|
||||
-- check for termination request
|
||||
if event == "terminate" or ppm.should_terminate() then
|
||||
println_ts("terminate requested, closing connections...")
|
||||
|
@ -9,11 +9,6 @@ local tcallbackdsp = {}
|
||||
|
||||
local registry = {}
|
||||
|
||||
---@todo possibly move this to a config file?
|
||||
-- maximum 5 ticks late (0.25 seconds)<br/>
|
||||
-- heavily modded servers and large multiplayer servers tend to significantly slow tick times, so nominal 0.05s ticks are unlikely
|
||||
local UNSERVICED_CALL_DELAY = util.TICK_TIME_S * 5
|
||||
|
||||
-- request a function to be called after the specified time
|
||||
---@param time number seconds
|
||||
---@param f function callback function
|
||||
@ -65,33 +60,6 @@ function tcallbackdsp.handle(event)
|
||||
end
|
||||
end
|
||||
|
||||
-- execute any callbacks that are overdo their time and have not been serviced
|
||||
--
|
||||
-- this can be called periodically to prevent loss of any callbacks do to timer events that are lost (see github issue #110)
|
||||
function tcallbackdsp.call_unserviced()
|
||||
local found_unserviced = true
|
||||
|
||||
while found_unserviced do
|
||||
found_unserviced = false
|
||||
|
||||
-- go through registry, restart if unserviced entries were found due to mutating registry table
|
||||
for timer, entry in pairs(registry) do
|
||||
found_unserviced = util.time_s() > (entry.expiry + UNSERVICED_CALL_DELAY)
|
||||
if found_unserviced then
|
||||
local overtime = util.time_s() - entry.expiry
|
||||
local callback = entry.callback
|
||||
|
||||
log.warning(util.c("TCD: executing unserviced callback ", entry.callback, " (", overtime, "s late) [timer: ", timer, "]"))
|
||||
|
||||
-- clear first so that dispatch_unique call from inside callback won't see it as a conflict
|
||||
registry[timer] = nil
|
||||
callback()
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- identify any overdo callbacks
|
||||
--
|
||||
-- prints to log debug output
|
||||
|
@ -353,12 +353,12 @@ end
|
||||
-- convert Joules to FE
|
||||
---@param J number Joules
|
||||
---@return number FE Forge Energy
|
||||
function util.joules_to_fe(J) return mekanismEnergyHelper.joulesToFE(J) end
|
||||
function util.joules_to_fe(J) return (J * 0.4) end
|
||||
|
||||
-- convert FE to Joules
|
||||
---@param FE number Forge Energy
|
||||
---@return number J Joules
|
||||
function util.fe_to_joules(FE) return mekanismEnergyHelper.feToJoules(FE) end
|
||||
function util.fe_to_joules(FE) return (FE * 2.5) end
|
||||
|
||||
local function kFE(fe) return fe / 1000.0 end
|
||||
local function MFE(fe) return fe / 1000000.0 end
|
||||
|
Loading…
Reference in New Issue
Block a user