Example #1
0
    def __init__(self,
                 name,
                 plan,
                 detectors_widget,
                 md_parameters=None,
                 **kwargs):
        super().__init__(**kwargs)
        self.name = name
        self.plan_function = plan
        self.md_parameters = md_parameters

        vlayout = QtWidgets.QVBoxLayout()
        hlayout = QtWidgets.QHBoxLayout()
        # num spinner
        self.num_spin = MISpin('num')
        self.num_spin.setRange(1, 2**16)  # 65k maximum, 18hr @ 1hz
        hlayout.addLayout(hstacked_label('num', self.num_spin))

        # float spinner
        self.delay_spin = MFSpin('delay')
        self.delay_spin.setRange(0, 60 * 60)  # maximum delay an hour
        self.delay_spin.setDecimals(1)  # only 0.1s precision from GUI
        self.delay_spin.setSuffix('s')
        hlayout.addLayout(label_layout('delay', False, self.delay_spin))
        hlayout.addStretch()
        vlayout.addLayout(hlayout)
        # set up the detector selector
        self.dets = detectors_widget
        vlayout.addWidget(self.dets)

        self.setLayout(vlayout)
Example #2
0
class Count(QtWidgets.QWidget):
    def __init__(self, name, plan, detectors_widget, md_parameters=None,
                 **kwargs):
        super().__init__(**kwargs)
        self.name = name
        self.plan_function = plan
        self.md_parameters = md_parameters

        vlayout = QtWidgets.QVBoxLayout()
        hlayout = QtWidgets.QHBoxLayout()
        # num spinner
        self.num_spin = MISpin('num')
        self.num_spin.setRange(1, 2**16)  # 65k maximum, 18hr @ 1hz
        hlayout.addLayout(hstacked_label('num', self.num_spin))

        # float spinner
        self.delay_spin = MFSpin('delay')
        self.delay_spin.setRange(0, 60*60)  # maximum delay an hour
        self.delay_spin.setDecimals(1)  # only 0.1s precision from GUI
        self.delay_spin.setSuffix('s')
        label_layout = QtWidgets.QHBoxLayout()
        inner_layout = QtWidgets.QHBoxLayout()
        cb = QtWidgets.QCheckBox()
        label_layout.addWidget(QtWidgets.QCheckBox())
        inner_layout.addWidget(QtWidgets.QLabel('delay'))
        inner_layout.addWidget(self.delay_spin)
        label_layout.addLayout(inner_layout)
        label_layout.addStretch()
        cb.setCheckable(True)
        cb.stateChanged.connect(self.delay_spin.setEnabled)
        cb.setChecked(False)
        self.delay_spin.setEnabled(False)
        hlayout.addLayout(label_layout)
        hlayout.addStretch()
        vlayout.addLayout(hlayout)
        # set up the detector selector
        self.dets = detectors_widget
        vlayout.addWidget(self.dets)

        self.setLayout(vlayout)

    def get_plan(self):
        d = self.delay_spin.value() if self.delay_spin.isEnabled() else None
        num = self.num_spin.value()
        md = (self.md_parameters.get_metadata()
              if self.md_parameters is not None
              else None)
        return self.plan_function(self.dets.get_detectors(),
                                  num=num,
                                  delay=d,
                                  md=md)
Example #3
0
    def __init__(self,
                 name,
                 mover=None,
                 *,
                 start_name='start',
                 stop_name='stop',
                 steps_name='steps',
                 steps=10,
                 **kwargs):
        super().__init__(**kwargs)
        self.name = name
        self.mover = None
        hlayout = QtWidgets.QHBoxLayout()
        label = self.label = QtWidgets.QLabel('')
        lower = self.lower = MFSpin(start_name)
        upper = self.upper = MFSpin(stop_name)
        stps = self.steps = MISpin(steps_name)
        stps.setValue(steps)
        stps.setMinimum(1)

        hlayout.addWidget(label)
        hlayout.addStretch()
        hlayout.addLayout(vstacked_label(start_name, lower))
        hlayout.addLayout(vstacked_label(stop_name, upper))
        hlayout.addLayout(vstacked_label(steps_name, stps))
        self.setLayout(hlayout)

        if mover is not None:
            self.set_mover(mover)
        def __init__(self, mdv, *args, **kwargs):
            super().__init__(*args, **kwargs)
            self.mdv = mdv

            w_layout = QtWidgets.QVBoxLayout()
            w_layout.addWidget(mdv)

            button_layout = QtWidgets.QHBoxLayout()
            w_layout.addLayout(button_layout)

            self.spinner = spinner = MISpin("run")
            w_layout.addWidget(spinner)
            spinner.setRange(0, 100)

            def on_change(n):
                self.mdv.show_row_n(n)

            spinner.valueChanged.connect(on_change)
            self.setLayout(w_layout)