optmise notifications
This commit is contained in:
+13
-3
@@ -177,6 +177,7 @@ class SteamTurbineWrapper:
|
|||||||
"""wrapper class wor `SteamTurbine`"""
|
"""wrapper class wor `SteamTurbine`"""
|
||||||
default_threshold = 25
|
default_threshold = 25
|
||||||
notify_threshold = 10
|
notify_threshold = 10
|
||||||
|
notify_timeout = 100
|
||||||
|
|
||||||
def __init__(self, turbine: SteamTurbine, threshold: int = 25, storages: list[GasTank] = None):
|
def __init__(self, turbine: SteamTurbine, threshold: int = 25, storages: list[GasTank] = None):
|
||||||
"""init wrapper for `SteamTurbine`
|
"""init wrapper for `SteamTurbine`
|
||||||
@@ -191,6 +192,7 @@ class SteamTurbineWrapper:
|
|||||||
self.storages = storages
|
self.storages = storages
|
||||||
self.pcontrol = get_component("power_control")
|
self.pcontrol = get_component("power_control")
|
||||||
self.steam_in = turbine.steam_in
|
self.steam_in = turbine.steam_in
|
||||||
|
self.__notify_timeout = 0
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""run loop for `SteamTurbine`"""
|
"""run loop for `SteamTurbine`"""
|
||||||
@@ -201,11 +203,19 @@ class SteamTurbineWrapper:
|
|||||||
|
|
||||||
def check_health(self):
|
def check_health(self):
|
||||||
"""check own function and notify if not in expected parameters"""
|
"""check own function and notify if not in expected parameters"""
|
||||||
if self.steam_in.level() < self.notify_threshold:
|
if self.__notify_timeout:
|
||||||
notify(f"{self.turbine.id}: steam level under {self.notify_threshold}", "warn", 30)
|
self.__notify_timeout -= 1
|
||||||
|
return
|
||||||
if self.turbine.is_stalled() or self.steam_in.level() == 0:
|
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)
|
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):
|
def fill_steam(self):
|
||||||
"""fills steam if own steam under threshold"""
|
"""fills steam if own steam under threshold"""
|
||||||
|
|||||||
Reference in New Issue
Block a user