Esempio n. 1
0
 def __render_pregame(self, scoreboard):
     debug.info("Showing Main Event")
     self.matrix.clear()
     ScoreboardRenderer(self.data, self.matrix, scoreboard).render()
     sleep(self.refresh_rate)
     self.boards._scheduled(self.data, self.matrix)
     self.data.needs_refresh = True
Esempio n. 2
0
    def render(self):
        self.index = 0
        self.games = self.data.games
        self.num_games = len(self.games)
        try:
            while not self.sleepEvent.is_set():
                self.matrix.clear()
                if self.index >= (len(self.games)):
                    return
                    
                ScoreboardRenderer(self.data, self.matrix, Scoreboard(self.games[self.index], self.data)).render()
                self.show_indicator()
                self.matrix.render()

                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()

                #sleep(self.rotation_rate)
                self.sleepEvent.wait(self.rotation_rate)

                self.index += 1

        except IndexError:
            print("no game to display, you set preferred teams only or NHL OFF DAY today")
            return
Esempio n. 3
0
    def render(self):
        if self.data.config.testing_mode:
            debug.info("Rendering in Testing Mode")
            while True:
                self._draw_goal_animation()
                ScoreboardRenderer(self.data, self.matrix,
                                   Scoreboard(self.data.games[0],
                                              self.data)).render()
                self.matrix.render()
                data.refresh.daily(self.data)
                sleep(15)
                debug.info("Testing Mode Refresh")

        if self.data.config.test_goal_animation:
            debug.info("Rendering in Testing Mode")
            while True:
                self._draw_goal_animation()
                self.matrix.render()
                sleep(1)

        while self.data.network_issues:
            Clock(self.data, self.matrix, self.sleepEvent, duration=60)
            self.data.refresh_data()

        while True:
            try:
                debug.info('Rendering...')

                if self.status.is_offseason(self.data.date()):
                    # Offseason (Show offseason related stuff)
                    debug.info("It's offseason")
                    self.__render_offday()
                elif self.data.config.testScChampions:
                    self.test_stanley_cup_champion(
                        self.data.config.testScChampions)

                else:
                    # Season.
                    if not self.data.config.live_mode:
                        debug.info(
                            "Live mode is off. Going through the boards")
                        self.__render_offday()
                    elif self.data.is_pref_team_offday():
                        debug.info("Your preferred teams are Off today")
                        self.__render_offday()
                    elif self.data.is_nhl_offday():
                        debug.info("There is no game in the NHL today")
                        self.__render_offday()
                    else:
                        debug.info("Game Day Wooooo")
                        self.__render_game_day()

                self.data.refresh_data()

            except AttributeError as e:
                debug.log(f"ERROR WHILE RENDERING: {e}")
                debug.log("Refreshing data in a minute")
                self.boards.fallback(self.data, self.matrix, self.sleepEvent)
                self.data.refresh_data()
Esempio n. 4
0
 def __render_postgame(self, scoreboard):
     debug.info("Showing Post-Game")
     self.matrix.clear()
     ScoreboardRenderer(self.data, self.matrix, scoreboard).render()
     self.draw_end_of_game_indicator()
     sleep(self.refresh_rate)
     self.boards._post_game(self.data, self.matrix)
     self.data.needs_refresh = True
Esempio n. 5
0
 def __render_live(self, scoreboard):
     debug.info("Showing Main Event")
     self.matrix.clear()
     show_SOG = False
     if self.alternate_data_counter % self.sog_display_frequency == 0:
         show_SOG = True
     ScoreboardRenderer(self.data, self.matrix, scoreboard, show_SOG).render()
     self.alternate_data_counter += 1
Esempio n. 6
0
 def __render_live(self, scoreboard):
     debug.info("Showing Main Event")
     self.matrix.clear()
     ScoreboardRenderer(self.data, self.matrix, scoreboard).render()
     if scoreboard.intermission:
         debug.info("Main event is in Intermission")
         # Show Boards for Intermission
         self.draw_end_period_indicator()
         sleep(self.refresh_rate)
         self.boards._intermission(self.data, self.matrix)
     else:
         sleep(self.refresh_rate)
     self.data.needs_refresh = True
Esempio n. 7
0
    def render(self):
        if self.data.config.testing_mode:
            debug.info("Rendering in Testing Mode")
            while True:
                ScoreboardRenderer(self.data, self.matrix,
                                   Scoreboard(self.data.games[0],
                                              self.data)).render()
                self.data.refresh_overview()
                #self.scoreboard = Scoreboard(self.data.overview, self.data)
                #self._draw_event_animation("penalty", self.scoreboard.home_team.id, self.scoreboard.home_team.name)
                #PenaltyRenderer(self.data, self.matrix, self.sleepEvent, self.scoreboard.away_team).render()
                #TeamSummary(self.data, self.matrix, self.sleepEvent).render()
                sleep(1)
                debug.info("Testing Mode Refresh")

        if self.data.config.test_goal_animation:
            debug.info("Rendering in Testing Mode")
            while True:
                self._draw_event_animation("goal", id=9)

        while self.data.network_issues:
            Clock(self.data, self.matrix, self.sleepEvent, duration=60)
            self.data.refresh_data()

        while True:
            debug.info('Rendering...')

            if self.status.is_offseason(self.data.date()):
                # Offseason (Show offseason related stuff)
                debug.info("It's offseason")
                self.__render_offday()
            elif self.data.config.testScChampions:
                self.test_stanley_cup_champion(
                    self.data.config.testScChampions)

            else:
                # Season.
                if not self.data.config.live_mode:
                    debug.info("Live mode is off. Going through the boards")
                    self.__render_offday()
                elif self.data.is_pref_team_offday():
                    debug.info("Your preferred teams are Off today")
                    self.__render_offday()
                elif self.data.is_nhl_offday():
                    debug.info("There is no game in the NHL today")
                    self.__render_offday()
                else:
                    debug.info("Game Day Wooooo")
                    self.__render_game_day()

            self.data.refresh_data()
    def render(self):
        self.index = 0
        self.games = self.data.games
        self.num_games = len(self.games)
        try:
            while True:
                self.matrix.clear()
                if self.index >= (len(self.games)):
                    return

                ScoreboardRenderer(self.data, self.matrix, Scoreboard(self.games[self.index], self.data.teams_info, self.data.config)).render()
                self.show_indicator()
                self.matrix.render()

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

                sleep(self.rotation_rate)
                self.index += 1

        except IndexError:
            print("NHL OFF DAY today")
            return
Esempio n. 9
0
 def __render_irregular(self, scoreboard):
     debug.info("Showing Irregular")
     self.matrix.clear()
     ScoreboardRenderer(self.data, self.matrix, scoreboard).render()
Esempio n. 10
0
 def __render_postgame(self, scoreboard):
     debug.info("Showing Post-Game")
     self.matrix.clear()
     ScoreboardRenderer(self.data, self.matrix, scoreboard).render()
     self.draw_end_of_game_indicator()
Esempio n. 11
0
 def __render_pregame(self, scoreboard):
     debug.info("Showing Pre-Game")
     self.matrix.clear()
     ScoreboardRenderer(self.data, self.matrix, scoreboard).render()
Esempio n. 12
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
        # 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):
                print(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()
                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)

            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()
Esempio n. 13
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()