Fix clock, I guess ?
This commit is contained in:
@@ -48,11 +48,8 @@ class GameController:
|
||||
if auth_token != "Bearer " + self._auth_token:
|
||||
return jsonify({"status": "error", "message": "Invalid authorization token"}), 401
|
||||
|
||||
img, fen = self._game_service.make_move()
|
||||
|
||||
threading.Thread(
|
||||
target=self.__send_detection_result,
|
||||
args=("https://192.168.15.125:1880/party/image", img, fen),
|
||||
target=self._analyze_move(),
|
||||
daemon=True
|
||||
).start()
|
||||
|
||||
@@ -61,7 +58,11 @@ class GameController:
|
||||
print(ex)
|
||||
return jsonify({"status": "error", "message": f"An error occurred : {ex}"}), 500
|
||||
|
||||
def __send_detection_result(self, url, img, fen):
|
||||
def _analyze_move(self):
|
||||
img, fen = self._game_service.make_move()
|
||||
self._send_detection_result("https://192.168.15.125:1880/party/image", img, fen)
|
||||
|
||||
def _send_detection_result(self, url, img, fen):
|
||||
try:
|
||||
headers = {'Content-Type': 'image/jpeg'}
|
||||
body = {'frame': img, 'fen': fen}
|
||||
|
||||
@@ -45,10 +45,7 @@ class ClockService:
|
||||
return clock
|
||||
|
||||
def __tick(self, formatted_time : str) -> None:
|
||||
if self.white_clock.is_running() :
|
||||
self.__update_screen(f"W {formatted_time} \n B {self.black_clock.clock_to_str()}")
|
||||
elif self.black_clock.is_running() :
|
||||
self.__update_screen(f"W {self.white_clock.clock_to_str()} \n B {formatted_time}")
|
||||
self.__update_screen(f"W {self.white_clock.clock_to_str()} \n B {self.black_clock.clock_to_str()}")
|
||||
|
||||
def __terminate(self) -> None:
|
||||
self.__update_screen("Time is over !")
|
||||
|
||||
@@ -21,6 +21,7 @@ class GameService:
|
||||
|
||||
def make_move(self) -> tuple[bytes, str] | None:
|
||||
try :
|
||||
self.clock_service.switch()
|
||||
return self.detection_service.analyze_single_frame()
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
Reference in New Issue
Block a user