Exemplo n.º 1
0
 def stanley_cup_champions(self, data, matrix, sleepEvent):
     StanleyCupChampions(data, matrix, sleepEvent).render()
Exemplo n.º 2
0
 def test_stanley_cup_champion(self, team_id):
     StanleyCupChampions(self.data, team_id, self.matrix,
                         self.sleepEvent).render()
Exemplo n.º 3
0
    def __render_game_day(self):
        debug.info("Showing Game")
        # Initialize the scoreboard. get the current status at startup
        self.data.refresh_overview()
        self.scoreboard = Scoreboard(self.data.overview, self.data)
        self.away_score = self.scoreboard.away_team.goals
        self.home_score = self.scoreboard.home_team.goals
        # Cache to save goals and allow all the details to be collected on the API.
        self.goal_team_cache = []
        self.sleepEvent.clear()

        while not self.sleepEvent.is_set():

            if self.data._is_new_day():
                debug.log('This is a new day')
                return

            # Display the pushbutton board
            if self.data.pb_trigger:
                debug.info(
                    'PushButton triggered in game day loop....will display ' +
                    self.data.config.pushbutton_state_triggered1 + ' board')
                if not self.data.screensaver:
                    self.data.pb_trigger = False
                #Display the board from the config
                self.boards._pb_board(self.data, self.matrix, self.sleepEvent)

            # Display the Weather Alert board
            if self.data.wx_alert_interrupt:
                debug.info(
                    'Weather Alert triggered in game day loop....will display weather alert board'
                )
                self.data.wx_alert_interrupt = False
                #Display the board from the config
                self.boards._wx_alert(self.data, self.matrix, self.sleepEvent)

            # Display the screensaver board
            if self.data.screensaver:
                if not self.data.pb_trigger:
                    debug.info('Screensaver triggered in game day loop....')
                    #self.data.wx_alert_interrupt = False
                    #Display the board from the config
                    self.boards._screensaver(self.data, self.matrix,
                                             self.sleepEvent)
                else:
                    self.data.pb_trigger = False

            if self.status.is_live(self.data.overview.status):
                """ Live Game state """
                #blocks the screensaver from running if game is live
                self.data.screensaver_livegame = True
                debug.info("Game is Live")
                self.scoreboard = Scoreboard(self.data.overview, self.data)
                self.check_new_goals()
                self.__render_live(self.scoreboard)
                if self.scoreboard.intermission:
                    debug.info("Main event is in Intermission")
                    # Show Boards for Intermission
                    self.draw_end_period_indicator()
                    self.sleepEvent.wait(self.refresh_rate)
                    self.check_new_goals()
                    self.boards._intermission(self.data, self.matrix,
                                              self.sleepEvent)
                else:
                    self.sleepEvent.wait(self.refresh_rate)

            elif self.status.is_game_over(self.data.overview.status):
                print(self.data.overview.status)
                debug.info("Game Over")
                self.scoreboard = Scoreboard(self.data.overview, self.data)
                self.check_new_goals()
                if self.data.isPlayoff and self.stanleycup_round:
                    self.check_stanley_cup_champion()
                    if self.data.ScChampions_id:
                        StanleyCupChampions(self.data,
                                            self.data.ScChampions_id,
                                            self.matrix,
                                            self.sleepEvent).render()

                self.__render_postgame(self.scoreboard)

                self.sleepEvent.wait(self.refresh_rate)

            elif self.status.is_final(self.data.overview.status):
                """ Post Game state """
                debug.info("FINAL")
                self.scoreboard = Scoreboard(self.data.overview, self.data)
                self.check_new_goals()
                if self.data.isPlayoff and self.stanleycup_round:
                    self.check_stanley_cup_champion()
                    if self.data.ScChampions_id:
                        StanleyCupChampions(self.data, self.matrix,
                                            self.sleepEvent).render()
                self.__render_postgame(self.scoreboard)

                self.sleepEvent.wait(self.refresh_rate)
                if self.data._next_game():
                    debug.info("moving to the next preferred game")
                    return
                if not self.goal_team_cache:
                    self.boards._post_game(self.data, self.matrix,
                                           self.sleepEvent)

            elif self.status.is_scheduled(self.data.overview.status):
                """ Pre-game state """
                debug.info("Game is Scheduled")
                self.scoreboard = Scoreboard(self.data.overview, self.data)
                self.__render_pregame(self.scoreboard)
                #sleep(self.refresh_rate)
                self.sleepEvent.wait(self.refresh_rate)
                self.boards._scheduled(self.data, self.matrix, self.sleepEvent)

            elif self.status.is_irregular(self.data.overview.status):
                """ Pre-game state """
                debug.info("Game is irregular")
                self.scoreboard = Scoreboard(self.data.overview, self.data)
                self.__render_irregular(self.scoreboard)
                #sleep(self.refresh_rate)
                self.sleepEvent.wait(self.refresh_rate)
                self.boards._scheduled(self.data, self.matrix, self.sleepEvent)

            self.data.refresh_data()
            self.data.refresh_overview()
            if self.data.network_issues:
                self.matrix.network_issue_indicator()

            if self.data.newUpdate and not self.data.config.clock_hide_indicators:
                self.matrix.update_indicator()
Exemplo n.º 4
0
    def __render_game_day(self):
        debug.info("Showing Game")
        # Initialize the scoreboard. get the current status at startup
        self.data.refresh_overview()
        self.scoreboard = Scoreboard(self.data.overview, self.data)
        self.away_score = self.scoreboard.away_team.goals
        self.home_score = self.scoreboard.home_team.goals
        self.away_penalties = self.scoreboard.away_team.penalties
        self.home_penalties = self.scoreboard.home_team.penalties

        # Announce a game today to /dev/shm/getNHL.txt.1
        home_name = self.scoreboard.home_team.name
        away_name = self.scoreboard.away_team.name
        stime = self.scoreboard.start_time
        f = open('/dev/shm/getNHL.txt.1', 'w')
        #f.write('Blues game today!')
        f.write('NHL: %s vs %s, %spm\n' % (home_name, away_name, stime))
        f.close()
        subprocess_cmd = 'sudo -H -u pi bash -c "rsync /dev/shm/getNHL.txt.1 [email protected]:/dev/shm/"'
        subprocess.run([subprocess_cmd], shell=True)

        # Cache to save goals and penalties and allow all the details to be collected on the API.
        self.goal_team_cache = []
        self.penalties_team_cache = []
        self.sleepEvent.clear()

        while not self.sleepEvent.is_set():

            if self.data._is_new_day():
                debug.log('This is a new day')
                return

            # Display the pushbutton board
            if self.data.pb_trigger:
                debug.info(
                    'PushButton triggered in game day loop....will display ' +
                    self.data.config.pushbutton_state_triggered1 + ' board')
                if not self.data.screensaver:
                    self.data.pb_trigger = False
                #Display the board from the config
                self.boards._pb_board(self.data, self.matrix, self.sleepEvent)

            # Display the Weather Alert board
            if self.data.wx_alert_interrupt:
                debug.info(
                    'Weather Alert triggered in game day loop....will display weather alert board'
                )
                self.data.wx_alert_interrupt = False
                #Display the board from the config
                self.boards._wx_alert(self.data, self.matrix, self.sleepEvent)

            # Display the screensaver board
            if self.data.screensaver:
                if not self.data.pb_trigger:
                    debug.info('Screensaver triggered in game day loop....')
                    #self.data.wx_alert_interrupt = False
                    #Display the board from the config
                    self.boards._screensaver(self.data, self.matrix,
                                             self.sleepEvent)
                else:
                    self.data.pb_trigger = False

            if self.status.is_live(self.data.overview.status):
                """ Live Game state """
                #blocks the screensaver from running if game is live
                self.data.screensaver_livegame = True
                debug.info("Game is Live")
                sbrenderer = ScoreboardRenderer(self.data, self.matrix,
                                                self.scoreboard)

                self.check_new_penalty()
                self.check_new_goals()
                self.__render_live(sbrenderer)
                if self.scoreboard.intermission:
                    debug.info("Main event is in Intermission")
                    # Show Boards for Intermission
                    self.draw_end_period_indicator()
                    self.sleepEvent.wait(self.refresh_rate)

                    self.check_new_penalty()
                    self.check_new_goals()
                    self.boards._intermission(self.data, self.matrix,
                                              self.sleepEvent)

                else:
                    self.sleepEvent.wait(self.refresh_rate)

            elif self.status.is_game_over(self.data.overview.status):
                debug.info("Game Over")
                sbrenderer = ScoreboardRenderer(self.data, self.matrix,
                                                self.scoreboard)
                self.check_new_goals()
                if self.data.isPlayoff and self.data.stanleycup_round:
                    self.check_stanley_cup_champion()
                    if self.data.ScChampions_id:
                        StanleyCupChampions(self.data, self.matrix,
                                            self.sleepEvent).render()

                self.__render_postgame(sbrenderer)

                self.sleepEvent.wait(self.refresh_rate)

            elif self.status.is_final(self.data.overview.status):
                """ Post Game state """
                debug.info("FINAL")
                sbrenderer = ScoreboardRenderer(self.data, self.matrix,
                                                self.scoreboard)
                self.check_new_goals()

                # Announce a game today to /dev/shm/getNHL.txt.1
                home_name = self.scoreboard.home_team.name
                away_name = self.scoreboard.away_team.name
                home_goals = self.scoreboard.home_team.goals
                away_goals = self.scoreboard.away_team.goals
                f = open('/dev/shm/getNHL.txt.1', 'w')
                #f.write('Blues game today!')
                f.write('%s %d, %s %d FINAL\n' %
                        (home_name, home_goals, away_name, away_goals))
                f.close()
                subprocess_cmd = 'sudo -H -u pi bash -c "rsync /dev/shm/getNHL.txt.1 [email protected]:/dev/shm/"'
                subprocess.run([subprocess_cmd], shell=True)

                if self.data.isPlayoff and self.data.stanleycup_round:
                    self.check_stanley_cup_champion()
                    if self.data.ScChampions_id:
                        StanleyCupChampions(self.data, self.matrix,
                                            self.sleepEvent).render()
                self.__render_postgame(sbrenderer)

                self.sleepEvent.wait(self.refresh_rate)
                if not self.goal_team_cache:
                    self.boards._post_game(self.data, self.matrix,
                                           self.sleepEvent)

            elif self.status.is_scheduled(self.data.overview.status):
                """ Pre-game state """
                debug.info("Game is Scheduled")
                sbrenderer = ScoreboardRenderer(self.data, self.matrix,
                                                self.scoreboard)
                self.__render_pregame(sbrenderer)
                #sleep(self.refresh_rate)
                self.sleepEvent.wait(self.refresh_rate)
                self.boards._scheduled(self.data, self.matrix, self.sleepEvent)
                #announce upcoming game
                home_name = self.scoreboard.home_team.name
                away_name = self.scoreboard.away_team.name
                stime = self.scoreboard.start_time
                f = open('/dev/shm/getNHL.txt.1', 'w')
                f.write('NHL: %s vs %s, %spm\n' %
                        (home_name, away_name, stime))
                f.close()
                subprocess_cmd = 'sudo -H -u pi bash -c "rsync /dev/shm/getNHL.txt.1 [email protected]:/dev/shm/"'
                subprocess.run([subprocess_cmd], shell=True)

            elif self.status.is_irregular(self.data.overview.status):
                """ Pre-game state """
                debug.info("Game is irregular")
                sbrenderer = ScoreboardRenderer(self.data, self.matrix,
                                                self.scoreboard)
                self.__render_irregular(sbrenderer)
                #sleep(self.refresh_rate)
                self.sleepEvent.wait(self.refresh_rate)
                self.boards._scheduled(self.data, self.matrix, self.sleepEvent)

            self.data.refresh_data()
            self.data.refresh_overview()
            self.scoreboard = Scoreboard(self.data.overview, self.data)
            if self.data.network_issues:
                self.matrix.network_issue_indicator()

            if self.data.newUpdate and not self.data.config.clock_hide_indicators:
                self.matrix.update_indicator()