From 18289208733c6d32fb995f37d72b85c0ac93a250 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Wed, 2 Nov 2022 17:00:33 -0400 Subject: [PATCH] #110, #114 no longer use mekanism energy helper functions as those are event consuming --- coordinator/startup.lua | 5 +---- scada-common/tcallbackdsp.lua | 32 -------------------------------- scada-common/util.lua | 4 ++-- 3 files changed, 3 insertions(+), 38 deletions(-) diff --git a/coordinator/startup.lua b/coordinator/startup.lua index 1ba171b..0d2a81d 100644 --- a/coordinator/startup.lua +++ b/coordinator/startup.lua @@ -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...") diff --git a/scada-common/tcallbackdsp.lua b/scada-common/tcallbackdsp.lua index 98d9b6f..d4926c0 100644 --- a/scada-common/tcallbackdsp.lua +++ b/scada-common/tcallbackdsp.lua @@ -9,11 +9,6 @@ local tcallbackdsp = {} local registry = {} ----@todo possibly move this to a config file? --- maximum 5 ticks late (0.25 seconds)
--- 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 diff --git a/scada-common/util.lua b/scada-common/util.lua index 1153c6b..867a77e 100644 --- a/scada-common/util.lua +++ b/scada-common/util.lua @@ -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