diff --git a/libs/wrapper/power.py b/libs/wrapper/power.py index 8e666ed..9af1bf9 100644 --- a/libs/wrapper/power.py +++ b/libs/wrapper/power.py @@ -177,6 +177,7 @@ class SteamTurbineWrapper: """wrapper class wor `SteamTurbine`""" default_threshold = 25 notify_threshold = 10 + notify_timeout = 100 def __init__(self, turbine: SteamTurbine, threshold: int = 25, storages: list[GasTank] = None): """init wrapper for `SteamTurbine` @@ -191,6 +192,7 @@ class SteamTurbineWrapper: self.storages = storages self.pcontrol = get_component("power_control") self.steam_in = turbine.steam_in + self.__notify_timeout = 0 def run(self): """run loop for `SteamTurbine`""" @@ -201,11 +203,19 @@ class SteamTurbineWrapper: def check_health(self): """check own function and notify if not in expected parameters""" - if self.steam_in.level() < self.notify_threshold: - notify(f"{self.turbine.id}: steam level under {self.notify_threshold}", "warn", 30) + if self.__notify_timeout: + self.__notify_timeout -= 1 + return if self.turbine.is_stalled() or self.steam_in.level() == 0: notify(f"{self.turbine.id}: stopped working or has low efficency ({self.turbine.efficiency()*100}%)", "error", 30) - sleep(30) + return + if self.turbine.power_output() == 108 and get_component("power_control").grid(self.turbine.id).net < self.notify_threshold * -1: + notify(f"{self.turbine.id}: insufficient energy supply", "error", 30) + return + if self.steam_in.level() < self.notify_threshold: + notify(f"{self.turbine.id}: steam level under {self.notify_threshold}", "warn", 30) + return + self.notify_timeout = 100 def fill_steam(self): """fills steam if own steam under threshold"""