示例#1
0
    def setup_waveform(self):

        waveform = Waveform()

        preamble = self.query('ACQ1:MEM?').strip().split(';')
        wave_header = {}
        for entry in preamble:
            entry_parts = entry.split(',')
            if len(entry_parts) == 2:
                wave_header[entry_parts[0]] = entry_parts[1]

        waveform.capture_time = waveform.capture_time = datetime.datetime.utcnow()
        waveform.data_channel = wave_header['Source']
        waveform.number_of_points = int(wave_header['Memory Length'])
        waveform.x_unit = wave_header['Horizontal Units']
        if waveform.x_unit.lower() == 's':
            waveform.x_unit = 'Seconds'
        waveform.x_scale = float(wave_header['Horizontal Scale'])
        waveform.y_unit = wave_header['Vertical Units']
        if waveform.y_unit.lower() == 'V':
            waveform.y_unit = 'Volts'
        waveform.y_scale = float(wave_header['Vertical Scale'])

        return waveform
示例#2
0
    def setup_waveform(self):
        """
        Fetch all the parameters needed to parse the wave data.
        will be passed the waveform object.
        :return: the waveform object if setup fails.
        """

        waveform = Waveform()
        waveform.data_channel = self.getDataChannel()  # get active channel
        waveform.capture_time = datetime.datetime.utcnow()

        try:
            preamble = self.query("WFMP?").split(';')  # get waveform preamble and parse it

            if len(preamble) > 5:  # normal operation
                waveform.number_of_points = int(preamble[5])
                waveform.x_increment = float(preamble[8])
                waveform.x_offset = float(preamble[9])
                waveform.x_zero = float(preamble[10])
                waveform.x_unit = preamble[11].strip('"')
                if waveform.x_unit == 's':
                    waveform.x_unit = 'Seconds'
                waveform.y_multiplier = float(preamble[12])
                waveform.y_zero = float(preamble[13])
                waveform.y_offset = float(preamble[14])
                waveform.y_unit = preamble[15].strip('"')

            else:  # Selected channel is not active
                waveform.error = waveform.data_channel \
                                 + ' is not active. Please select an active channel.'

            return waveform

        except Exception as e:
            self.logger.error(e)