本文整理汇总了Python中utilities.DispatchDgt类的典型用法代码示例。如果您正苦于以下问题:Python DispatchDgt类的具体用法?Python DispatchDgt怎么用?Python DispatchDgt使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DispatchDgt类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _process_user_move_done
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')
开发者ID:djdekker,项目名称:picochess,代码行数:30,代码来源:display.py
示例2: _process_computer_move
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
开发者ID:antmp27,项目名称:Picochess_NonDGT_LCD_0.9j,代码行数:26,代码来源:display.py
示例3: force_leds_off
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
开发者ID:antmp27,项目名称:Picochess_NonDGT_LCD_0.9j,代码行数:7,代码来源:display.py
示例4: _process_engine_ready
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)
开发者ID:antmp27,项目名称:Picochess_NonDGT_LCD_0.9j,代码行数:9,代码来源:display.py
示例5: _process_start_new_game
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()
开发者ID:antmp27,项目名称:Picochess_NonDGT_LCD_0.9j,代码行数:10,代码来源:display.py
示例6: _process_button4
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())
开发者ID:antmp27,项目名称:Picochess_NonDGT_LCD_0.9j,代码行数:11,代码来源:display.py
示例7: _process_new_score
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())
开发者ID:antmp27,项目名称:Picochess_NonDGT_LCD_0.9j,代码行数:11,代码来源:display.py
示例8: _process_new_pv
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)
开发者ID:antmp27,项目名称:Picochess_NonDGT_LCD_0.9j,代码行数:11,代码来源:display.py
示例9: _process_new_score
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)
开发者ID:djdekker,项目名称:picochess,代码行数:15,代码来源:display.py
示例10: _exit_display
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)
开发者ID:antmp27,项目名称:Picochess_NonDGT_LCD_0.9j,代码行数:16,代码来源:display.py
示例11: _process_dgt_serial_nr
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)
开发者ID:antmp27,项目名称:Picochess_NonDGT_LCD_0.9j,代码行数:17,代码来源:display.py
示例12: _process_button2
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())
开发者ID:antmp27,项目名称:Picochess_NonDGT_LCD_0.9j,代码行数:19,代码来源:display.py
示例13: _process_button0
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()
开发者ID:antmp27,项目名称:Picochess_NonDGT_LCD_0.9j,代码行数:22,代码来源:display.py
示例14: _exit_display
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)
开发者ID:djdekker,项目名称:picochess,代码行数:23,代码来源:display.py
示例15: _process_computer_move_done
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')
开发者ID:djdekker,项目名称:picochess,代码行数:24,代码来源:display.py
示例16: _process_button1
def _process_button1(self, dev):
logging.debug('(%s) clock handle button 1 press', dev)
if self._inside_main_menu():
DispatchDgt.fire(self.dgtmenu.main_left()) # button1 cant exit the menu
elif self._inside_updt_menu():
DispatchDgt.fire(self.dgtmenu.updt_left()) # button1 cant exit the menu
else:
text = self._combine_depth_and_score()
text.beep = self.dgttranslate.bl(BeepLevel.BUTTON)
# text.maxtime = 0
DispatchDgt.fire(text)
self._exit_display()
开发者ID:antmp27,项目名称:Picochess_NonDGT_LCD_0.9j,代码行数:12,代码来源:display.py
示例17: _process_dgt_serial_nr
def _process_dgt_serial_nr(self):
# logging.debug('Serial number {}'.format(message.number)) # actually used for watchdog (once a second)
# molli: rolling display
if not self._inside_main_menu():
if self.dgtmenu.get_mode() == Mode.PONDER:
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,
long=self.dgttranslate.notation)
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)
elif (self.dgtmenu.get_mode() == Mode.BRAIN and self.dgtmenu.get_rolldispbrain()) or (self.dgtmenu.get_mode() == Mode.NORMAL and self.dgtmenu.get_rolldispnorm()):
#molli: allow rolling information display (time/score/hint_move) in BRAIN mode according to
## ponder interval
if self.play_move == chess.Move.null() and self.c_last_player == 'U':
if self.c_time_counter > 2 * self.dgtmenu.get_ponderinterval():
text = self._combine_depth_and_score()
text.wait = True
DispatchDgt.fire(text)
self.c_time_counter = (self.c_time_counter + 1) % (self.dgtmenu.get_ponderinterval() * 3)
elif self.c_time_counter > 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,
long=self.dgttranslate.notation)
else:
text = self.dgttranslate.text('N10_nomove')
text.wait = True
self.c_time_counter = (self.c_time_counter + 1) % (self.dgtmenu.get_ponderinterval() * 3)
DispatchDgt.fire(text)
if self.c_time_counter == 2 * self.dgtmenu.get_ponderinterval():
time.sleep(0.3)
else:
## molli: standard clock display
if self.c_time_counter == 0:
time.sleep(0.3)
self.c_time_counter = (self.c_time_counter + 1) % (self.dgtmenu.get_ponderinterval() * 3)
self._exit_display()
if self.c_time_counter == self.dgtmenu.get_ponderinterval():
time.sleep(0.3)
开发者ID:djdekker,项目名称:picochess,代码行数:52,代码来源:display.py
示例18: _process_button3
def _process_button3(self, dev):
logging.debug('(%s) clock handle button 3 press', dev)
if self._inside_main_menu():
DispatchDgt.fire(self.dgtmenu.main_right()) # button3 cant exit the menu
elif self._inside_updt_menu():
DispatchDgt.fire(self.dgtmenu.updt_right()) # button3 cant exit the menu
else:
if self.hint_move:
side = self._get_clock_side(self.hint_turn)
beep = self.dgttranslate.bl(BeepLevel.BUTTON)
text = Dgt.DISPLAY_MOVE(move=self.hint_move, fen=self.hint_fen, side=side, wait=False, maxtime=1,
beep=beep, devs={'ser', 'i2c', 'web'}, uci960=self.uci960,
lang=self.dgttranslate.language, capital=self.dgttranslate.capital,
long=self.dgttranslate.notation)
else:
text = self.dgttranslate.text('B10_nomove')
DispatchDgt.fire(text)
self._exit_display()
开发者ID:Ernisius,项目名称:Picochess-nonDGT,代码行数:18,代码来源:display.py
示例19: _reboot
def _reboot(self, dev='web'):
DispatchDgt.fire(self.dgttranslate.text('Y15_pleasewait'))
self.dgtmenu.set_engine_restart(True)
Observable.fire(Event.REBOOT(dev=dev))
开发者ID:antmp27,项目名称:Picochess_NonDGT_LCD_0.9j,代码行数:4,代码来源:display.py
示例20: _process_message
def _process_message(self, message):
if False: # switch-case
pass
elif isinstance(message, Message.ENGINE_READY):
self._process_engine_ready(message)
elif isinstance(message, Message.ENGINE_STARTUP):
self._process_engine_startup(message)
elif isinstance(message, Message.ENGINE_FAIL):
DispatchDgt.fire(self.dgttranslate.text('Y10_erroreng'))
self.dgtmenu.set_engine_restart(False)
elif isinstance(message, Message.COMPUTER_MOVE):
self._process_computer_move(message)
elif isinstance(message, Message.START_NEW_GAME):
self._process_start_new_game(message)
elif isinstance(message, Message.COMPUTER_MOVE_DONE):
self._process_computer_move_done()
elif isinstance(message, Message.USER_MOVE_DONE):
self._process_user_move_done(message)
elif isinstance(message, Message.REVIEW_MOVE_DONE):
self._process_review_move_done(message)
elif isinstance(message, Message.ALTERNATIVE_MOVE):
self.force_leds_off()
self.play_mode = message.play_mode
DispatchDgt.fire(self.dgttranslate.text('B05_altmove'))
elif isinstance(message, Message.LEVEL):
if not self.dgtmenu.get_engine_restart():
DispatchDgt.fire(message.level_text)
elif isinstance(message, Message.TIME_CONTROL):
self._process_time_control(message)
elif isinstance(message, Message.OPENING_BOOK):
if not self.dgtmenu.get_confirm() or not message.show_ok:
DispatchDgt.fire(message.book_text)
elif isinstance(message, Message.TAKE_BACK):
self.force_leds_off()
self._reset_moves_and_score()
DispatchDgt.fire(self.dgttranslate.text('C10_takeback'))
DispatchDgt.fire(Dgt.DISPLAY_TIME(force=True, wait=True, devs={'ser', 'i2c', 'web'}))
elif isinstance(message, Message.GAME_ENDS):
if not self.dgtmenu.get_engine_restart(): # filter out the shutdown/reboot process
text = self.dgttranslate.text(message.result.value)
text.beep = self.dgttranslate.bl(BeepLevel.CONFIG)
text.maxtime = 0.5
DispatchDgt.fire(text)
elif isinstance(message, Message.INTERACTION_MODE):
if not self.dgtmenu.get_confirm() or not message.show_ok:
DispatchDgt.fire(message.mode_text)
elif isinstance(message, Message.PLAY_MODE):
self.play_mode = message.play_mode
DispatchDgt.fire(message.play_mode_text)
elif isinstance(message, Message.NEW_SCORE):
self._process_new_score(message)
elif isinstance(message, Message.BOOK_MOVE):
self.score = self.dgttranslate.text('N10_score', None)
DispatchDgt.fire(self.dgttranslate.text('N10_bookmove'))
elif isinstance(message, Message.NEW_PV):
self._process_new_pv(message)
elif isinstance(message, Message.NEW_DEPTH):
self.depth = message.depth
elif isinstance(message, Message.IP_INFO):
self.dgtmenu.int_ip = message.info['int_ip']
self.dgtmenu.ext_ip = message.info['ext_ip']
elif isinstance(message, Message.STARTUP_INFO):
self._process_startup_info(message)
elif isinstance(message, Message.SEARCH_STARTED):
logging.debug('search started')
elif isinstance(message, Message.SEARCH_STOPPED):
logging.debug('search stopped')
elif isinstance(message, Message.CLOCK_START):
self._process_clock_start(message)
elif isinstance(message, Message.CLOCK_STOP):
DispatchDgt.fire(Dgt.CLOCK_STOP(devs=message.devs, wait=True))
elif isinstance(message, Message.DGT_BUTTON):
self._process_button(message)
#.........这里部分代码省略.........
开发者ID:antmp27,项目名称:Picochess_NonDGT_LCD_0.9j,代码行数:101,代码来源:display.py
注:本文中的utilities.DispatchDgt类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论