Exemplo n.º 1
0
    def read_bank(self, bank=0, nbits=8, verbose=True):
        """
            return voltages (V) measured on channels in "bank"
            nbits= 8 or 12 resolution of measurement
        """
        self._check_nbits(nbits)

        if nbits == 8:
            nbytes = 16
            bank_idxs = EIGHT_BIT_BANKS
        else:
            nbytes = 32
            bank_idxs = TWELVE_BIT_BANKS

        idx = bank_idxs[bank]
        cmdstr = self._make_cmdstr(254, idx)
        resp = self.ask(cmdstr,
                        nchars=nbytes,
                        verbose=verbose,
                        remove_eol=False)
        vs = self._map_to_voltage(resp, nbits, nbytes)
        if verbose:
            self.debug('bank={} nbits={} values={}'.format(
                bank, nbits, to_csv_str(vs)))
        return vs
Exemplo n.º 2
0
 def to_string(self):
     attrs = ['labnumber', 'aliquot', 'step',
              'extract_value', 'extract_units', 'ramp_duration',
              'position', 'duration', 'cleanup', 'beam_diameter',
              'mass_spectrometer', 'extract_device',
              'extraction_script', 'measurement_script',
              'post_equilibration_script', 'post_measurement_script']
     return to_csv_str(self.to_string_attrs(attrs))
Exemplo n.º 3
0
 def to_string(self):
     attrs = ['labnumber', 'aliquot', 'step',
              'extract_value', 'extract_units', 'ramp_duration',
              'position', 'duration', 'cleanup', 'beam_diameter',
              'mass_spectrometer', 'extract_device',
              'extraction_script', 'measurement_script',
              'post_equilibration_script', 'post_measurement_script']
     return to_csv_str(self.to_string_attrs(attrs))
Exemplo n.º 4
0
    def load_extraction(self, jd):
        for attr in EXTRACTION_ATTRS:
            tag = attr
            if attr == 'cleanup_duration':
                if attr not in jd:
                    tag = 'cleanup'
            elif attr == 'extract_duration':
                if attr not in jd:
                    tag = 'duration'

            v = jd.get(tag)
            if v is not None:
                setattr(self, attr, v)

        rs = jd.get('measured_response')
        if rs is None:
            rs = jd.get('request')
        self.measured_response_stream = rs

        rs = jd.get('requested_output')
        if rs is None:
            rs = jd.get('response')
        self.requested_output_stream = rs

        rs = jd.get('setpoint_stream')
        if rs is None:
            rs = jd.get('sblob')
        self.setpoint_stream = rs

        pd = jd.get('positions')
        if pd:
            ps = sorted(pd, key=itemgetter('position'))
            self.position = to_csv_str([pp['position'] for pp in ps])
            self.xyz_position = to_csv_str(['{},{},{}'.format(pp['x'], pp['y'], pp['z'])
                                            for pp in ps if pp['x'] is not None], delimiter=';')
        if not self.extract_units:
            self.extract_units = 'W'
Exemplo n.º 5
0
    def load_extraction(self, jd):
        for attr in EXTRACTION_ATTRS:
            tag = attr
            if attr == 'cleanup_duration':
                if attr not in jd:
                    tag = 'cleanup'
            elif attr == 'extract_duration':
                if attr not in jd:
                    tag = 'duration'

            v = jd.get(tag)
            if v is not None:
                setattr(self, attr, v)

        rs = jd.get('measured_response')
        if rs is None:
            rs = jd.get('request')
        self.measured_response_stream = rs

        rs = jd.get('requested_output')
        if rs is None:
            rs = jd.get('response')
        self.requested_output_stream = rs

        rs = jd.get('setpoint_stream')
        if rs is None:
            rs = jd.get('sblob')
        self.setpoint_stream = rs

        pd = jd.get('positions')
        if pd:
            ps = sorted(pd, key=itemgetter('position'))
            self.position = to_csv_str([pp['position'] for pp in ps])
            self.xyz_position = to_csv_str(['{},{},{}'.format(pp['x'], pp['y'], pp['z'])
                                            for pp in ps if pp['x'] is not None], delimiter=';')
        if not self.extract_units:
            self.extract_units = 'W'
    def _build_command(self, command, xx=None, nn=None):
        """
        """
        if isinstance(nn, list):
            nn = to_csv_str(nn)

        cmd = '{}'
        args = (command, )
        if xx is not None:
            cmd += '{}'
            args = (xx, command)
        if nn is not None:
            cmd += '{}'
            args = (xx, command, nn)

        return cmd.format(*args)
Exemplo n.º 7
0
Arquivo: adc.py Projeto: NMGRL/pychron
    def read_bank(self, bank=0, nbits=8, verbose=True):
        """
            return voltages (V) measured on channels in "bank"
            nbits= 8 or 12 resolution of measurement
        """
        self._check_nbits(nbits)

        if nbits == 8:
            nbytes = 16
            bank_idxs = EIGHT_BIT_BANKS
        else:
            nbytes = 32
            bank_idxs = TWELVE_BIT_BANKS

        idx = bank_idxs[bank]
        cmdstr = self._make_cmdstr(254, idx)
        resp = self.ask(cmdstr, nchars=nbytes, verbose=verbose, remove_eol=False)
        vs = self._map_to_voltage(resp, nbits, nbytes)
        if verbose:
            self.debug('bank={} nbits={} values={}'.format(bank, nbits, to_csv_str(vs)))
        return vs
Exemplo n.º 8
0
 def to_string(self):
     attrs = [getattr(self, attr) for attr in ('name', 'kind', 'username', 'host',
                                               'dbname', 'password', 'enabled', 'default', 'path')]
     return to_csv_str(attrs)
Exemplo n.º 9
0
 def dump_coeffs(self):
     return to_csv_str(self.coefficients)
Exemplo n.º 10
0
def write_txt_file(p, out):
    with open(p, 'w') as wfile:
        for line in out:
            wfile.write('{}\n'.format(to_csv_str(line)))
Exemplo n.º 11
0
 def dump_coeffs(self):
     return to_csv_str(self.coefficients)
Exemplo n.º 12
0
 def to_string(self):
     return to_csv_str(self.make_row())
Exemplo n.º 13
0
 def to_string(self):
     return to_csv_str(self.make_row())
Exemplo n.º 14
0
 def to_string(self):
     attrs = [getattr(self, attr) for attr in self.attributes]
     return to_csv_str(attrs)
Exemplo n.º 15
0
 def to_string(self):
     attrs = [getattr(self, attr) for attr in ('name', 'kind', 'username', 'host',
                                               'dbname', 'password', 'enabled', 'default', 'path',
                                               'organization', 'meta_repo_name', 'meta_repo_dir')]
     return to_csv_str(attrs)