Ejemplo n.º 1
0
        ]
        return all(valid)

    def generate(self, mode):
        cmd = 'RefineMatrix'
        kwargs = []
        for (p, box) in zip(
                'a b c alpha beta gamma wavelength '
                'delta_gamma delta_nu'.split(), self._boxes):
            text = box.currentText()
            if text == '= a':
                kwargs.append((p, '\'a\''))
            elif text == '= alpha':
                kwargs.append((p, '\'alpha\''))
            elif text != 'free':
                kwargs.append((p, '%.4f' % float(text)))
        if mode == 'simple':
            code = cmd + ' ' + ' '.join('%s %s' % i for i in kwargs)
            if self.acceptBox.isChecked():
                code += '\nAcceptRefinement'
        else:
            code = cmd + '(' + ', '.join('%s=%s' % i for i in kwargs) + ')'
            if self.acceptBox.isChecked():
                code += '; AcceptRefinement()'
        return code


register(Lubrication)
register(CenterPeak)
register(RefineMatrix)
Ejemplo n.º 2
0
            count_time = 0
            devices_args = []
            is_trans = False
            for (k, v) in entry.items():
                if isinstance(v, Sample):
                    sample = v.getValue()
                    count_time = v.extra[1]
                elif isinstance(v, Device):
                    devices_args.append(k)
                    devices_args.append(repr(v.getValue()))
                elif isinstance(v, Mode):
                    is_trans = v.getValue() == Mode.VALUES[0]

            items.append(f"\n##### Measurement {len(out) + 1}")
            if sample:
                items.append(f'# SelectSample("{sample}")')
            if devices_args:
                args = ", ".join(devices_args)
                items.append(f"maw({args})")
            if is_trans:
                items.append("# enable_trans()")
            else:
                items.append("# enable_sans()")

            items.append(f"# loki_count(t={count_time})")
            out.append('\n'.join(items))
        return '\n'.join(out)


register(MeasureTable)
Ejemplo n.º 3
0
            full_name = 'sample_slit' if slittype == 'ap_sam' else 'pol_slit'
            cmds.append('maw({}, ({}, {}, {}, {}))'.format(
                full_name, x_center, y_center, x_max, y_max))
        for slit in self.slits:
            if values[slit]:
                limits = self._getSlitLimits(slittype, slit)
                cmds.append('scan({}_{}, {:g}, {:g}, {:g}, {:g})'.format(
                    slittype, slit, values[slit + '_from'],
                    values[slit + '_stepsize'],
                    values[slit + '_number_of_steps'], values['time']))
                cmds.append('maw({}_{}, {})'.format(slittype, slit, limits[2]))
        return '\n'.join(cmds)

    def isValid(self):
        values = self.getValues()
        slittype = values['slittype']
        valid = 1
        for slit in self.slits:
            limits = self._getSlitLimits(slittype, slit)
            slit_obj = getattr(self, 'lE_{}_to'.format(slit))
            valid *= self.markValid(
                slit_obj, limits[0] <= float(slit_obj.text()) <= limits[1])
        return valid


register(Shutter)
register(SetTemperature)
register(PowderScan)
register(SingleCrystalScan)
register(SlitScan)
Ejemplo n.º 4
0
            self.start.setText(values['scanstart'])
        if 'scanstep' in values:
            self.step.setText(values['scanstep'])
        if 'scanpoints' in values:
            self.numpoints.setValue(values['scanpoints'])
        if 'devspeed' in values:
            self.speed.setText(values['devspeed'])

    def isValid(self):
        valid = [
            self.markValid(self.start, isFloat(self.start)),
            self.markValid(self.step, isFloat(self.step)),
            self.markValid(self.speed, isFloat(self.speed, 0.00001)),
            self.markValid(self.numpoints,
                           self.numpoints.value() >= 2),
        ]
        return all(valid)

    def generate(self, mode):
        values = self.getValues()
        if mode == 'simple':
            return 'kscan %(dev)s %(scanstart)s %(scanstep)s %(scanpoints)s ' \
                   '%(devspeed)s' % values
        values['dev'] = self._getDeviceRepr(values['dev'])
        return 'kscan(%(dev)s, %(scanstart)s, %(scanstep)s, %(scanpoints)s, ' \
               '%(devspeed)s)' % values


register(KScan)
register(SScan)
Ejemplo n.º 5
0
            elements.append(('chopper', Chopper))
            elements.append(('time', MeasTime))
        return elements


class MeasureTable(KWS1MeasureTable):

    meas_def_class = MeasDef

    def __init__(self, parent, client):
        KWS1MeasureTable.__init__(self, parent, client)
        self.rtBox.hide()
        self.rtConfBtn.hide()


register(MeasureTable)


class RestoreState(Cmdlet):

    name = 'Device state as script'
    category = 'Other'

    def __init__(self, parent, client):
        Cmdlet.__init__(self, parent, client,
                        findResource('nicos_mlz/kws3/gui/restore.ui'))
        for devname in self._getDeviceList():
            item = QListWidgetItem(devname, self.devList)
            item.setCheckState(Qt.Unchecked)
        # self.devList.