本文整理匯總了Python中utilities.DispatchDgt.fire方法的典型用法代碼示例。如果您正苦於以下問題:Python DispatchDgt.fire方法的具體用法?Python DispatchDgt.fire怎麽用?Python DispatchDgt.fire使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類utilities.DispatchDgt
的用法示例。
在下文中一共展示了DispatchDgt.fire方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _process_user_move_done
# 需要導入模塊: from utilities import DispatchDgt [as 別名]
# 或者: from utilities.DispatchDgt import fire [as 別名]
def _process_user_move_done(self, message):
self.force_leds_off(log=True) # can happen in case of a sliding move
##logging.debug('molli players mode %s', str(self.play_mode))
##logging.debug('molli message.turn %s', str(message.turn))
##logging.debug('molli play.turn %s', str(self.play_turn))
##logging.debug('molli last.turn %s', str(self.last_turn))
if message.turn == False:
self.c_last_player = 'C' ##molli
else:
self.c_last_player = 'U' ##molli
self.c_time_counter = 0 ##molli
self.last_move = message.move
self.last_fen = message.fen
self.last_turn = message.turn
self.play_move = chess.Move.null()
self.play_fen = None
self.play_turn = None
self._exit_menu()
if self.dgtmenu.get_mode() == Mode.TRAINING: ##molli
self._display_confirm('K05_okmove')
text = self._combine_depth_and_score()
text.wait = True
DispatchDgt.fire(text)
else:
self._display_confirm('K05_okuser')
示例2: _process_computer_move
# 需要導入模塊: from utilities import DispatchDgt [as 別名]
# 或者: from utilities.DispatchDgt import fire [as 別名]
def _process_computer_move(self, message):
self.force_leds_off(log=True) # can happen in case of a book move
move = message.move
ponder = message.ponder
self.play_move = move
self.play_fen = message.game.fen()
self.play_turn = message.game.turn
if ponder:
game_copy = message.game.copy()
game_copy.push(move)
self.hint_move = ponder
self.hint_fen = game_copy.fen()
self.hint_turn = game_copy.turn
else:
self.hint_move = chess.Move.null()
self.hint_fen = None
self.hint_turn = None
# Display the move
side = self._get_clock_side(message.game.turn)
beep = self.dgttranslate.bl(BeepLevel.CONFIG)
disp = Dgt.DISPLAY_MOVE(move=move, fen=message.game.fen(), side=side, wait=message.wait, maxtime=0,
beep=beep, devs={'ser', 'i2c', 'web'}, uci960=self.uci960,
lang=self.dgttranslate.language, capital=self.dgttranslate.capital)
DispatchDgt.fire(disp)
DispatchDgt.fire(Dgt.LIGHT_SQUARES(uci_move=move.uci(), devs={'ser', 'web'}))
self.leds_are_on = True
示例3: force_leds_off
# 需要導入模塊: from utilities import DispatchDgt [as 別名]
# 或者: from utilities.DispatchDgt import fire [as 別名]
def force_leds_off(self, log=False):
"""Clear the rev2 lights if they still on."""
if self.leds_are_on:
if log:
logging.warning('(rev) leds still on')
DispatchDgt.fire(Dgt.LIGHT_CLEAR(devs={'ser', 'web'}))
self.leds_are_on = False
示例4: _process_engine_ready
# 需要導入模塊: from utilities import DispatchDgt [as 別名]
# 或者: from utilities.DispatchDgt import fire [as 別名]
def _process_engine_ready(self, message):
for index in range(0, len(self.dgtmenu.installed_engines)):
if self.dgtmenu.installed_engines[index]['file'] == message.eng['file']:
self.dgtmenu.set_engine_index(index)
self.dgtmenu.set_engine_has_960(message.has_960)
self.dgtmenu.set_engine_has_ponder(message.has_ponder)
if not self.dgtmenu.get_confirm() or not message.show_ok:
DispatchDgt.fire(message.eng_text)
self.dgtmenu.set_engine_restart(False)
示例5: _process_start_new_game
# 需要導入模塊: from utilities import DispatchDgt [as 別名]
# 或者: from utilities.DispatchDgt import fire [as 別名]
def _process_start_new_game(self, message):
self.force_leds_off()
self._reset_moves_and_score()
self.time_control.reset()
if message.newgame:
pos960 = message.game.chess960_pos()
self.uci960 = pos960 is not None and pos960 != 518
DispatchDgt.fire(self.dgttranslate.text('C10_ucigame' if self.uci960 else 'C10_newgame', str(pos960)))
if self.dgtmenu.get_mode() in (Mode.NORMAL, Mode.BRAIN, Mode.OBSERVE, Mode.REMOTE):
self._set_clock()
示例6: _process_button4
# 需要導入模塊: from utilities import DispatchDgt [as 別名]
# 或者: from utilities.DispatchDgt import fire [as 別名]
def _process_button4(self, dev):
logging.debug('(%s) clock handle button 4 press', dev)
if self._inside_updt_menu():
tag = self.dgtmenu.updt_down(dev)
Observable.fire(Event.UPDATE_PICO(tag=tag))
else:
text = self.dgtmenu.main_down() # button4 can exit the menu, so check
if text:
DispatchDgt.fire(text)
else:
Observable.fire(Event.EXIT_MENU())
示例7: _process_new_score
# 需要導入模塊: from utilities import DispatchDgt [as 別名]
# 或者: from utilities.DispatchDgt import fire [as 別名]
def _process_new_score(self, message):
if message.mate is None:
score = int(message.score)
if message.turn == chess.BLACK:
score *= -1
text = self.dgttranslate.text('N10_score', score)
else:
text = self.dgttranslate.text('N10_mate', str(message.mate))
self.score = text
if message.mode == Mode.KIBITZ and not self._inside_main_menu():
DispatchDgt.fire(self._combine_depth_and_score())
示例8: _process_new_pv
# 需要導入模塊: from utilities import DispatchDgt [as 別名]
# 或者: from utilities.DispatchDgt import fire [as 別名]
def _process_new_pv(self, message):
self.hint_move = message.pv[0]
self.hint_fen = message.game.fen()
self.hint_turn = message.game.turn
if message.mode == Mode.ANALYSIS and not self._inside_main_menu():
side = self._get_clock_side(self.hint_turn)
beep = self.dgttranslate.bl(BeepLevel.NO)
disp = Dgt.DISPLAY_MOVE(move=self.hint_move, fen=self.hint_fen, side=side, wait=True, maxtime=0,
beep=beep, devs={'ser', 'i2c', 'web'}, uci960=self.uci960,
lang=self.dgttranslate.language, capital=self.dgttranslate.capital)
DispatchDgt.fire(disp)
示例9: _process_new_score
# 需要導入模塊: from utilities import DispatchDgt [as 別名]
# 或者: from utilities.DispatchDgt import fire [as 別名]
def _process_new_score(self, message):
if message.mate is None:
score = int(message.score)
if message.turn == chess.BLACK:
score *= -1
text = self.dgttranslate.text('N10_score', score)
else:
if message.turn == chess.BLACK: # WD Fehlerbereiningung
message.mate *= -1 # WD Fehlerbereinigung
text = self.dgttranslate.text('N10_mate', str(message.mate))
self.score = text
if message.mode in (Mode.KIBITZ, Mode.TRAINING) and not self._inside_main_menu(): # WD
text = self._combine_depth_and_score()
text.wait = True
DispatchDgt.fire(text)
示例10: _exit_display
# 需要導入模塊: from utilities import DispatchDgt [as 別名]
# 或者: from utilities.DispatchDgt import fire [as 別名]
def _exit_display(self):
if self.play_move and self.dgtmenu.get_mode() in (Mode.NORMAL, Mode.BRAIN, Mode.REMOTE):
side = self._get_clock_side(self.play_turn)
beep = self.dgttranslate.bl(BeepLevel.BUTTON)
text = Dgt.DISPLAY_MOVE(move=self.play_move, fen=self.play_fen, side=side, wait=True, maxtime=1,
beep=beep, devs={'ser', 'i2c', 'web'}, uci960=self.uci960,
lang=self.dgttranslate.language, capital=self.dgttranslate.capital)
else:
text = None
if self._inside_main_menu():
text = self.dgtmenu.get_current_text()
if text:
text.wait = True # in case of "bad pos" message send before
else:
text = Dgt.DISPLAY_TIME(force=True, wait=True, devs={'ser', 'i2c', 'web'})
DispatchDgt.fire(text)
示例11: _process_dgt_serial_nr
# 需要導入模塊: from utilities import DispatchDgt [as 別名]
# 或者: from utilities.DispatchDgt import fire [as 別名]
def _process_dgt_serial_nr(self):
# logging.debug('Serial number {}'.format(message.number)) # actually used for watchdog (once a second)
if self.dgtmenu.get_mode() == Mode.PONDER and not self._inside_main_menu():
if self.show_move_or_value >= self.dgtmenu.get_ponderinterval():
if self.hint_move:
side = self._get_clock_side(self.hint_turn)
beep = self.dgttranslate.bl(BeepLevel.NO)
text = Dgt.DISPLAY_MOVE(move=self.hint_move, fen=self.hint_fen, side=side, wait=True, maxtime=1,
beep=beep, devs={'ser', 'i2c', 'web'}, uci960=self.uci960,
lang=self.dgttranslate.language, capital=self.dgttranslate.capital)
else:
text = self.dgttranslate.text('N10_nomove')
else:
text = self._combine_depth_and_score()
text.wait = True
DispatchDgt.fire(text)
self.show_move_or_value = (self.show_move_or_value + 1) % (self.dgtmenu.get_ponderinterval() * 2)
示例12: _process_button2
# 需要導入模塊: from utilities import DispatchDgt [as 別名]
# 或者: from utilities.DispatchDgt import fire [as 別名]
def _process_button2(self, dev):
logging.debug('(%s) clock handle button 2 press', dev)
if self._inside_main_menu() or self.dgtmenu.inside_picochess_time(dev):
text = self.dgtmenu.main_middle(dev) # button2 can exit the menu (if in "position"), so check
if text:
DispatchDgt.fire(text)
else:
Observable.fire(Event.EXIT_MENU())
else:
if self.dgtmenu.get_mode() in (Mode.ANALYSIS, Mode.KIBITZ, Mode.PONDER):
DispatchDgt.fire(self.dgttranslate.text('B00_nofunction'))
else:
if self.play_move:
self.play_move = chess.Move.null()
self.play_fen = None
self.play_turn = None
Observable.fire(Event.ALTERNATIVE_MOVE())
else:
Observable.fire(Event.PAUSE_RESUME())
示例13: _process_button0
# 需要導入模塊: from utilities import DispatchDgt [as 別名]
# 或者: from utilities.DispatchDgt import fire [as 別名]
def _process_button0(self, dev):
logging.debug('(%s) clock handle button 0 press', dev)
if self._inside_main_menu():
text = self.dgtmenu.main_up() # button0 can exit the menu, so check
if text:
DispatchDgt.fire(text)
else:
self._exit_display()
elif self._inside_updt_menu():
self.dgtmenu.updt_up(dev)
self._exit_display() # button0 always exit the menu
else:
if self.last_move:
side = self._get_clock_side(self.last_turn)
beep = self.dgttranslate.bl(BeepLevel.BUTTON)
text = Dgt.DISPLAY_MOVE(move=self.last_move, fen=self.last_fen, side=side, wait=False, maxtime=1,
beep=beep, devs={'ser', 'i2c', 'web'}, uci960=self.uci960,
lang=self.dgttranslate.language, capital=self.dgttranslate.capital)
else:
text = self.dgttranslate.text('B10_nomove')
DispatchDgt.fire(text)
self._exit_display()
示例14: _exit_display
# 需要導入模塊: from utilities import DispatchDgt [as 別名]
# 或者: from utilities.DispatchDgt import fire [as 別名]
def _exit_display(self, devs=None):
if devs is None: # prevent W0102 error
devs = {'ser', 'i2c', 'web'}
if self.play_move and self.dgtmenu.get_mode() in (Mode.NORMAL, Mode.BRAIN, Mode.REMOTE, Mode.TRAINING): # WD
side = self._get_clock_side(self.play_turn)
beep = self.dgttranslate.bl(BeepLevel.BUTTON)
text = Dgt.DISPLAY_MOVE(move=self.play_move, fen=self.play_fen, side=side, wait=True, maxtime=1,
beep=beep, devs=devs, uci960=self.uci960, lang=self.dgttranslate.language,
capital=self.dgttranslate.capital, long=self.dgttranslate.notation)
else:
text = None
if self._inside_main_menu():
text = self.dgtmenu.get_current_text()
if text:
text.wait = True # in case of "bad pos" message send before
else:
if self.dgtmenu.get_mode() == Mode.TRAINING: # WD 01.2019
text = self._combine_depth_and_score() # WD 01.2019
text.wait = True # WD 01.2019
else: # WD 01.2019
text = Dgt.DISPLAY_TIME(force=True, wait=True, devs=devs)
DispatchDgt.fire(text)
示例15: _process_computer_move_done
# 需要導入模塊: from utilities import DispatchDgt [as 別名]
# 或者: from utilities.DispatchDgt import fire [as 別名]
def _process_computer_move_done(self):
self.c_last_player = 'C' ##molli
self.c_time_counter = 0 ##molli
self.force_leds_off()
self.last_move = self.play_move
self.last_fen = self.play_fen
self.last_turn = self.play_turn
self.play_move = chess.Move.null()
self.play_fen = None
self.play_turn = None
self._exit_menu()
if self.dgtmenu.get_time_mode() == TimeMode.FIXED: # go back to a stopped time display and reset times
self.time_control.reset()
self._set_clock()
if self.dgtmenu.get_mode() == Mode.TRAINING: ##molli
self._display_confirm('K05_okmove')
text = self._combine_depth_and_score()
text.wait = True
DispatchDgt.fire(text)
else:
self._display_confirm('K05_okpico')