mirror of
https://github.com/fishyboteso/fishyboteso.git
synced 2024-08-30 18:32:13 +00:00
added few debug logs for engine
This commit is contained in:
parent
d4a5297a97
commit
fd7237161b
@ -21,6 +21,7 @@ class IEngine:
|
|||||||
self.state = 0
|
self.state = 0
|
||||||
self.window = None
|
self.window = None
|
||||||
self.thread = None
|
self.thread = None
|
||||||
|
self.name = "default"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def gui(self):
|
def gui(self):
|
||||||
@ -46,6 +47,7 @@ class IEngine:
|
|||||||
|
|
||||||
def join(self):
|
def join(self):
|
||||||
if self.thread:
|
if self.thread:
|
||||||
|
logging.debug(f"waiting for {self.name} engine")
|
||||||
self.thread.join()
|
self.thread.join()
|
||||||
|
|
||||||
def turn_off(self):
|
def turn_off(self):
|
||||||
@ -54,23 +56,26 @@ class IEngine:
|
|||||||
its the responsibility of the thread to shut turn itself off
|
its the responsibility of the thread to shut turn itself off
|
||||||
"""
|
"""
|
||||||
if self.state == 1:
|
if self.state == 1:
|
||||||
logging.info("turning off...")
|
logging.debug(f"sending turn off signal to {self.name} engine")
|
||||||
self.state = 2
|
self.state = 2
|
||||||
else:
|
else:
|
||||||
logging.error("engine already signaled to turn off")
|
logging.debug(f"{self.name} engine already signaled to turn off ")
|
||||||
# todo: implement force turn off on repeated calls
|
# todo: implement force turn off on repeated calls
|
||||||
|
|
||||||
# noinspection PyBroadException
|
# noinspection PyBroadException
|
||||||
def _crash_safe(self):
|
def _crash_safe(self):
|
||||||
self.window = WindowClient(color=cv2.COLOR_RGB2GRAY, show_name="fishy debug")
|
logging.debug(f"starting {self.name} engine thread")
|
||||||
|
self.window = WindowClient(color=cv2.COLOR_RGB2GRAY, show_name=f"{self.name} debug")
|
||||||
self.gui.bot_started(True)
|
self.gui.bot_started(True)
|
||||||
try:
|
try:
|
||||||
self.run()
|
self.run()
|
||||||
except Exception:
|
except Exception:
|
||||||
|
logging.error(f"Unhandled exception occurred while running {self.name} engine")
|
||||||
print_exc()
|
print_exc()
|
||||||
self.state = 0
|
self.state = 0
|
||||||
self.gui.bot_started(False)
|
self.gui.bot_started(False)
|
||||||
self.window.destroy()
|
self.window.destroy()
|
||||||
|
logging.debug(f"{self.name} engine thread safely exiting")
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
@ -30,6 +30,7 @@ class FullAuto(IEngine):
|
|||||||
from fishy.engine.fullautofisher.test import Test
|
from fishy.engine.fullautofisher.test import Test
|
||||||
|
|
||||||
super().__init__(gui_ref)
|
super().__init__(gui_ref)
|
||||||
|
self.name = "FullAuto"
|
||||||
self._curr_rotate_y = 0
|
self._curr_rotate_y = 0
|
||||||
|
|
||||||
self.fisher = SemiFisherEngine(None)
|
self.fisher = SemiFisherEngine(None)
|
||||||
|
@ -21,6 +21,7 @@ class SemiFisherEngine(IEngine):
|
|||||||
def __init__(self, gui_ref: Optional['Callable[[], GUI]']):
|
def __init__(self, gui_ref: Optional['Callable[[], GUI]']):
|
||||||
super().__init__(gui_ref)
|
super().__init__(gui_ref)
|
||||||
self.window = None
|
self.window = None
|
||||||
|
self.name = "SemiFisher"
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user