2020-06-01 12:58:18 +00:00
|
|
|
import logging
|
2020-10-18 00:43:59 +00:00
|
|
|
import time
|
|
|
|
|
2022-02-02 21:10:22 +00:00
|
|
|
from fishy.helper import auto_update
|
|
|
|
|
2020-06-01 12:58:18 +00:00
|
|
|
from fishy.engine import SemiFisherEngine
|
|
|
|
from fishy.engine.fullautofisher.engine import FullAuto
|
|
|
|
|
|
|
|
|
2022-02-01 11:51:58 +00:00
|
|
|
# to test only gui without engine code interfering
|
2021-05-01 09:28:09 +00:00
|
|
|
class IEngineHandler:
|
|
|
|
def __init__(self):
|
|
|
|
...
|
|
|
|
|
|
|
|
def start_event_handler(self):
|
|
|
|
...
|
|
|
|
|
|
|
|
def toggle_semifisher(self):
|
|
|
|
...
|
|
|
|
|
|
|
|
def toggle_fullfisher(self):
|
|
|
|
...
|
|
|
|
|
|
|
|
def check_pixel_val(self):
|
|
|
|
...
|
|
|
|
|
2022-02-02 21:10:22 +00:00
|
|
|
def set_update(self, version):
|
|
|
|
...
|
|
|
|
|
|
|
|
def quit_me(self):
|
2021-05-01 09:28:09 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
|
|
|
|
class EngineEventHandler(IEngineHandler):
|
2020-10-17 19:06:07 +00:00
|
|
|
def __init__(self, gui_ref):
|
2021-05-01 09:28:09 +00:00
|
|
|
super().__init__()
|
2020-06-01 12:58:18 +00:00
|
|
|
self.event_handler_running = True
|
|
|
|
self.event = []
|
|
|
|
|
2022-02-02 21:10:22 +00:00
|
|
|
self.update_flag = False
|
|
|
|
self.to_version = ""
|
|
|
|
|
2020-10-17 19:06:07 +00:00
|
|
|
self.semi_fisher_engine = SemiFisherEngine(gui_ref)
|
|
|
|
self.full_fisher_engine = FullAuto(gui_ref)
|
2020-06-01 12:58:18 +00:00
|
|
|
|
|
|
|
def start_event_handler(self):
|
|
|
|
while self.event_handler_running:
|
|
|
|
while len(self.event) > 0:
|
|
|
|
event = self.event.pop(0)
|
|
|
|
event()
|
2020-10-18 00:43:59 +00:00
|
|
|
time.sleep(0.1)
|
2020-06-01 12:58:18 +00:00
|
|
|
|
|
|
|
def toggle_semifisher(self):
|
|
|
|
self.event.append(self.semi_fisher_engine.toggle_start)
|
|
|
|
|
|
|
|
def toggle_fullfisher(self):
|
|
|
|
self.event.append(self.full_fisher_engine.toggle_start)
|
|
|
|
|
|
|
|
def check_pixel_val(self):
|
|
|
|
def func():
|
|
|
|
if self.semi_fisher_engine.start:
|
|
|
|
self.semi_fisher_engine.show_pixel_vals()
|
|
|
|
else:
|
|
|
|
logging.debug("Start the engine first before running this command")
|
|
|
|
|
|
|
|
self.event.append(func)
|
|
|
|
|
2022-02-02 21:10:22 +00:00
|
|
|
def set_update(self, version):
|
|
|
|
self.to_version = version
|
|
|
|
self.update_flag = True
|
|
|
|
self.quit_me()
|
|
|
|
|
|
|
|
def stop(self):
|
2022-02-02 23:20:36 +00:00
|
|
|
self.semi_fisher_engine.join()
|
|
|
|
self.full_fisher_engine.join()
|
2022-02-02 21:10:22 +00:00
|
|
|
if self.update_flag:
|
|
|
|
auto_update.update_now(self.to_version)
|
|
|
|
|
|
|
|
def quit_me(self):
|
2020-06-01 12:58:18 +00:00
|
|
|
def func():
|
2022-02-01 11:51:58 +00:00
|
|
|
if self.semi_fisher_engine.start:
|
|
|
|
self.semi_fisher_engine.turn_off()
|
|
|
|
if self.full_fisher_engine.start:
|
|
|
|
self.semi_fisher_engine.turn_off()
|
|
|
|
|
2020-06-01 12:58:18 +00:00
|
|
|
self.event_handler_running = False
|
|
|
|
|
|
|
|
self.event.append(func)
|