Example #1
0
    def run(self, integ_time):
        if self.mnt_grp is None:
            self.error('ActiveMntGrp is not defined or has invalid value')
            return
        # integration time has to be accessible from with in the hooks
        # so declare it also instance attribute
        self.integ_time = integ_time
        self.debug("Counting for %s sec", integ_time)
        self.outputDate()
        self.output('')
        self.flushOutput()

        for preAcqHook in self.getHooks('pre-acq'):
            preAcqHook()

        state, data = self.mnt_grp.count(integ_time)

        for postAcqHook in self.getHooks('post-acq'):
            postAcqHook()

        names, counts = [], []
        for ch_info in self.mnt_grp.getChannelsEnabledInfo():
            names.append('  %s' % ch_info.label)
            ch_data = data.get(ch_info.full_name)
            if ch_data is None:
                counts.append("<nodata>")
            elif ch_info.shape > [1]:
                counts.append(list(ch_data.shape))
            else:
                counts.append(ch_data)
        self.setData(Record(data))
        table = Table([counts], row_head_str=names, row_head_fmt='%*s',
                      col_sep='  =  ')
        for line in table.genOutput():
            self.output(line)
Example #2
0
    def run(self, integ_time, countable_elem):
        if self.countable_elem is None:
            msg = ('Unknown countable {0} element. Use macro parameter or'
                   'ActiveMntGrp environment variable'.format(
                       self.countable_elem_name))
            self.error(msg)
            return

        self.print_value = True
        try:
            state, data = self.countable_elem.count(integ_time)
        except Exception:
            if self.countable_elem.type == Type.MeasurementGroup:
                names = self.countable_elem.ElementList
                elements = [self.getObj(name) for name in names]
                self.dump_information(elements)
            raise
        finally:
            self.finish()
        if state != DevState.ON:
            if self.countable_elem.type == Type.MeasurementGroup:
                names = self.countable_elem.ElementList
                elements = [self.getObj(name) for name in names]
                self.dump_information(elements)
                raise ValueError("Acquisition ended with {}".format(
                    state.name.capitalize()))
        self.setData(Record(data))
        self.printAllValues()
Example #3
0
    def run(self, integ_time):
        if self.mnt_grp is None:
            self.error('ActiveMntGrp is not defined or has invalid value')
            return

        self.debug("Counting for %s sec", integ_time)
        self.outputDate()
        self.output('')
        self.flushOutput()

        state, data = self.mnt_grp.count(integ_time)
        names, counts = [], []
        for ch_info in self.mnt_grp.getChannelsEnabledInfo():
            names.append('  %s' % ch_info.label)
            ch_data = data.get(ch_info.full_name)
            if ch_data is None:
                counts.append("<nodata>")
            elif ch_info.shape > [1]:
                counts.append(list(ch_data.shape))
            else:
                counts.append(ch_data)
        self.setData(Record(data))
        table = Table([counts],
                      row_head_str=names,
                      row_head_fmt='%*s',
                      col_sep='  =  ')
        for line in table.genOutput():
            self.output(line)
Example #4
0
    def run(self, integ_time, countable_elem):
        if self.countable_elem is None:
            msg = ('Unknown countable {0} element. Use macro parameter or'
                   'ActiveMntGrp environment variable'.format(
                       self.countable_elem_name))
            self.error(msg)
            return
        # integration time has to be accessible from with in the hooks
        # so declare it also instance attribute
        self.integ_time = integ_time
        self.debug("Counting for %s sec", integ_time)
        self.outputDate()
        self.output('')
        self.flushOutput()

        for preAcqHook in self.getHooks('pre-acq'):
            preAcqHook()

        try:
            state, data = self.countable_elem.count(integ_time)
        except Exception:
            if self.countable_elem.type == Type.MeasurementGroup:
                names = self.countable_elem.ElementList
                elements = [self.getObj(name) for name in names]
                self.dump_information(elements)
            raise
        if state != DevState.ON:
            if self.countable_elem.type == Type.MeasurementGroup:
                names = self.countable_elem.ElementList
                elements = [self.getObj(name) for name in names]
                self.dump_information(elements)
                raise ValueError("Acquisition ended with {}".format(
                    state.name.capitalize()))

        for postAcqHook in self.getHooks('post-acq'):
            postAcqHook()

        names, counts = [], []
        if self.countable_elem.type == Type.MeasurementGroup:
            meas_grp = self.countable_elem
            for ch_info in meas_grp.getChannelsEnabledInfo():
                names.append('  %s' % ch_info.label)
                ch_data = data.get(ch_info.full_name)
                counts.append(_value_to_repr(ch_data))
        else:
            channel = self.countable_elem
            names.append("  %s" % channel.name)
            counts.append(_value_to_repr(data))
            # to be compatible with measurement group count
            data = {channel.full_name: data}
        self.setData(Record(data))
        table = Table([counts],
                      row_head_str=names,
                      row_head_fmt='%*s',
                      col_sep='  =  ')
        for line in table.genOutput():
            self.output(line)
Example #5
0
    def run(self, integ_time):
        if self.mnt_grp is None:
            self.error('ActiveMntGrp is not defined or has invalid value')
            return

        self.print_value = True
        try:
            _, data = self.mnt_grp.count(integ_time)
            self.setData(Record(data))
        finally:
            self.finish()
Example #6
0
    def run(self, integ_time, mnt_grp):
        if self.mnt_grp is None:
            self.error('The MntGrp {} is not defined or has invalid '
                       'value'.format(self.mnt_grp_name))
            return

        self.print_value = True
        try:
            _, data = self.mnt_grp.count(integ_time)
            self.setData(Record(data))
        finally:
            self.finish()
Example #7
0
    def run(self, integ_time, countable_elem):
        if self.countable_elem is None:
            msg = ('Unknown countable {0} element. Use macro parameter or'
                   'ActiveMntGrp environment variable'.format(
                       self.countable_elem_name))
            self.error(msg)
            return

        self.print_value = True
        try:
            _, data = self.countable_elem.count(integ_time)
            self.setData(Record(data))
        finally:
            self.finish()