예제 #1
0
    def __init__(self, config=None):
        """
        A class to record audio from a USB Soundcard microphone.

        Args:
            config: A dictionary loaded from a config JSON file used to replace
            the default settings of the sensor.
        """

        # Initialise the sensor config, double checking the types of values. This
        # code uses the variables named and described in the config static to set
        # defaults and override with any passed in the config file.
        opts = self.options()
        opts = {var['name']: var for var in opts}

        self.record_length = sensors.set_option('record_length', config, opts)
        self.compress_data = sensors.set_option('compress_data', config, opts)
        self.capture_delay = sensors.set_option('capture_delay', config, opts)

        # set internal variables and required class variables
        self.working_file = 'currentlyRecording.wav'
        self.current_file = None
        self.working_dir = None
        self.upload_dir = None
        self.server_sync_interval = self.record_length + self.capture_delay
    def __init__(self, config=None):
        """
        Init method for the sensor class, taking the contents of the config
        options and using that to populate the Sensor specific settings. This
        method should just handle setting config options and any checking of
        resources needed to capture data should be in the setup() method.

        Args:
            config: A dictionary loaded from a config JSON file used to replace
             the default settings of the sensor.
        """

        # Initialise the sensor config, double checking the types of values. This
        # code uses the variables named and described in the config static to set
        # defaults and override with any passed in the config file.
        opts = self.options()
        opts = {var['name']: var for var in opts}

        # config options
        self.device = sensors.set_option('device', config, opts)
        self.sample_size = sensors.set_option('sample_size', config, opts)
        self.sample_rate = sensors.set_option('sample_rate', config, opts)
        self.total_samples = sensors.set_option('total_samples', config, opts)
        self.capture_delay = sensors.set_option('capture_delay', config, opts)

        # starting values for other class variables
        self.start_time = None
        self.uncompressed_file = None
        self.working_dir = None
        self.upload_dir = None
        self.server_sync_interval = 20
    def __init__(self, config=None):
        """
        A class to take photos from a still camera

        Args:
            config: A dictionary loaded from a config JSON file used to replace
             the default settings of the sensor.
        """

        # Initialise the sensor config, double checking the types of values. This
        # code uses the variables named and described in the config static to set
        # defaults and override with any passed in the config file.
        opts = self.options()
        opts = {var['name']: var for var in opts}

        # config options
        self.device = sensors.set_option('device', config, opts)
        self.capture_delay = sensors.set_option('capture_delay', config, opts)

        # set internal variables and required class variables
        self.current_file = None
        self.working_dir = None
        self.upload_dir = None
        self.server_sync_interval = self.capture_delay
예제 #4
0
    def __init__(self, config=None):
        """
        A base class definition to set the methods for Sensor classes.

        Args:
            config: A dictionary loaded from a config JSON file used to update
            the default settings of the sensor.
        """

        # Initialise the sensor config, double checking the types of values. This
        # code uses the variables named and described in the config static to set
        # defaults and override with any passed in the config file.
        opts = self.options()
        opts = {var['name']: var for var in opts}

        # config options
        self.capture_delay = sensors.set_option('capture_delay', config, opts)

        # set internal variables and required class variables
        #TODO add pre_upload into here
        self.current_file = None
        self.working_dir = None
        self.upload_dir = None
        self.server_sync_interval = self.capture_delay