Esempio n. 1
0
 def reset(self):
     """
     Reset the radio
     """
     self.logger.info("Resetting DAB Radio")
     if self.interface.hard_reset_radio() != True:
         self.logger.error("Failed to reset the DAB Radio")
         raise OperationFailedError("Reset failed")
Esempio n. 2
0
 def clear_database(self):
     """
     Clear the internal radio database. This probably clears the channel list and any presets...
     
     Raises OperationFailedError if the database couldn't be cleared
     """
     if self.interface.clear_database() == False:
         raise OperationFailedError("Clear database failed")
Esempio n. 3
0
 def next_stream(self):
     """
     Plays the next stream in the ensemble
     
     Raises OperationFailedError if the next stream can't be selected
     """
     if self.interface.next_stream != True:
         raise OperationFailedError("Could not select the next stream")
Esempio n. 4
0
    def stop(self):
        self.logger.info("Stopping channel " + str(self.index) + " " +
                         str(self.name))
        if self.interface.stop_stream() != True:
            self.logger.error("Could not stop stream: " + str(self.index) +
                              " " + str(self.name))
            raise OperationFailedError("Could not stop stream: " +
                                       str(self.index))

        self.radio.currently_playing = None
Esempio n. 5
0
    def play(self):
        self.logger.info("Playing channel " + str(self.index) + " " +
                         str(self.name))
        if self.interface.play_stream(self.mode, self.index) != True:
            self.logger.error("Could not play stream: " + str(self.index) +
                              " " + str(self.name))
            raise OperationFailedError("Could not play stream: " +
                                       str(self.index))

        self.radio.currently_playing = self
Esempio n. 6
0
    def next_stream(self):
        """
        Plays the next stream in the ensemble

        Raises OperationFailedError if the next stream can't be selected
        """
        self.logger.info("Changing to next stream/channel")
        if self.interface.next_stream != True:
            self.logger.error("Could not select next stream/channel")
            raise OperationFailedError("Could not select the next stream")
Esempio n. 7
0
    def dab_auto_search(self, start_index, end_index, clear=True):
        """
        Searches for radio programs

        Keyword arguments:

        start_index: DAB index to start searching from. 0 is probably a good start.
        end_index: DAB index to end searching to. 40 is a nice number
        clear: If True, the internal channel table will be cleared before the search starts. (default: True)
        
        Raises OperationFailedError if the previous stream can't be selected
        """
        if clear:
            if self.interface.dab_auto_search(start_index, end_index) == False:
                raise OperationFailedError("Auto-search failed")
        else:
            if self.interface.dab_auto_search_no_clear(start_index,
                                                       end_index) == False:
                raise OperationFailedError("Auto-search failed")
Esempio n. 8
0
    def volume(self, value):
        """
        Set the current volume.

        Range is 0-16

        Example:

        r.volume = 10

        Raises OperationFailedError if the volume can't be set
        """
        if value >= 0 and value <= 16:
            if self.interface.set_volume(value) == -1:
                raise OperationFailedError("Set volume failed")
Esempio n. 9
0
    def volume(self, value):
        """
        Set the current volume.

        Range is 0-16

        Example:

        r.volume = 10

        Raises OperationFailedError if the volume can't be set
        """
        self.logger.debug("Setting volume to: " + str(value))
        if value >= 0 and value <= 16:
            if self.interface.set_volume(value) == -1:
                self.logger.error("Set volume failed")
                raise OperationFailedError("Set volume failed")
            else:
                self.logger.info("Set volume to: " + str(value))
        else:
            self.logger.warning("Attempt to set volume outside allowable range of 0-16, ignoring request")
Esempio n. 10
0
 def reset(self):
     """
     Reset the radio
     """
     if self.interface.hard_reset_radio() != True:
         raise OperationFailedError("Reset failed")
Esempio n. 11
0
    def stop(self):
        if self.interface.stop_stream() != True:
            raise OperationFailedError("Could not stop stream: " +
                                       str(self.index))

        self.radio.currently_playing = None
Esempio n. 12
0
    def play(self):
        if self.interface.play_stream(self.mode, self.index) != True:
            raise OperationFailedError("Could not play stream: " +
                                       str(self.index))

        self.radio.currently_playing = self