コード例 #1
0
ファイル: acquisition.py プロジェクト: ihebdelmic/odemis
    def _on_auto_center(self, event):
        """
        Called when the "Auto centering" button is clicked
        """
        # Force spot mode: not needed by the code, but makes sense for the user
        self._tab_data_model.tool.value = guimod.TOOL_SPOT
        self._pause()

        main_data = self._main_data_model
        main_data.is_acquiring.value = True

        logging.debug("Starting auto centering procedure")
        f = align.AlignSpot(main_data.ccd,
                            self._aligner_xy,
                            main_data.ebeam,
                            main_data.focus,
                            type=OBJECTIVE_MOVE)
        logging.debug("Auto centering is running...")
        self._acq_future = f
        # Transform auto centering button into cancel
        self._tab_panel.btn_auto_center.Bind(wx.EVT_BUTTON, self._on_cancel)
        self._tab_panel.btn_auto_center.Label = "Cancel"

        # Set up progress bar
        self._tab_panel.lbl_auto_center.Hide()
        self._tab_panel.gauge_auto_center.Show()
        self._sizer.Layout()
        self._acf_connector = ProgressiveFutureConnector(
            f, self._tab_panel.gauge_auto_center)

        f.add_done_callback(self._on_ac_done)
コード例 #2
0
    def test_spot_alignment(self):
        """
        Test AlignSpot
        """
        escan = self.ebeam
        ccd = self.ccd
        focus = self.focus

        f = align.AlignSpot(ccd, self.aligner_xy, escan, focus)
        dist, vector = f.result()
        self.assertAlmostEqual(dist, 2.41e-05)
コード例 #3
0
    def test_spot_alignment(self):
        """
        Test AlignSpot
        """
        escan = self.ebeam
        stage = self.align
        ccd = self.ccd
        focus = self.focus

        f = align.AlignSpot(ccd, stage, escan, focus)
        with self.assertRaises(IOError):
            f.result()
コード例 #4
0
    def test_spot_alignment_cancelled(self):
        """
        Test AlignSpot cancellation
        """
        escan = self.ebeam
        ccd = self.ccd
        focus = self.focus

        f = align.AlignSpot(ccd, self.aligner_xy, escan, focus)
        time.sleep(0.01)  # Cancel almost after the half grid is scanned

        f.cancel()
        self.assertTrue(f.cancelled())
        self.assertTrue(f.done())
        with self.assertRaises(futures.CancelledError):
            f.result()
コード例 #5
0
def main(args):
    """
    Handles the command line arguments
    args is the list of arguments passed
    return (int): value to return to the OS as program exit code
    """

    # arguments handling
    parser = argparse.ArgumentParser(
        description="Automated spot alignment procedure")

    try:
        escan = None
        ccd = None
        focus = None
        stage = None

        # find components by their role
        for c in model.getComponents():
            if c.role == "e-beam":
                escan = c
            elif c.role == "ccd":
                ccd = c
            elif c.role == "focus":
                focus = c
            elif c.role == "align":
                stage = c
        if not all([escan, ccd, focus, stage]):
            logging.error("Failed to find all the components")
            raise KeyError("Not all components found")

        # Apply spot alignment
        future_spot = align.AlignSpot(ccd, stage, escan, focus)
        t = future_spot.result()
        logging.debug("Final distance to the center (in meters): %f", t)

    except:
        logging.exception("Unexpected error while performing action.")
        return 127

    return 0