<commit_before># -*- coding: utf-8 -*-
from __future__ import print_function
import time
from acq4.util import Qt
from ..Stage import Stage, MoveFuture
from acq4.drivers.SutterMPC200 import SutterMPC200 as MPC200_Driver
from acq4.util.Mutex import Mutex
from acq4.util.Thread import Thread
from pyqtgraph import debug, ptime
from six.moves import range


def __reload__(old):
    # copy some globals if the module is reloaded
    SutterMPC200._monitor = old['SutterMPC200']._monitor


class ChangeNotifier(Qt.QObject):
    """Used to send raw (unscaled) stage position updates to other devices. 
    In particular, focus motors may use this to hijack unused ROE axes.
    """
    sigPosChanged = Qt.Signal(object, object, object)


class SutterMPC200(Stage):
    """
    This Device class represents a single drive of a Sutter MPC-200 stage/manipulator driver.
    Config options are: 

        port: <serial port>  # eg. 'COM1' or '/dev/ttyACM0'
        drive: <drive>       # int 1-4
    """

    _pos_cache = [None] * 4
    _notifier = ChangeNotifier()
    _monitor = None
    _drives = [None] * 4
    slowSpeed = 4  # speed to move when user requests 'slow' movement

    def __init__(self, man, config, name):
        self.port = config.pop('port')
        self.drive = config.pop('drive')
        self.scale = config.pop('scale', (1, 1, 1))
        if self._drives[self.drive-1] is not None:
            raise RuntimeError("Already created MPC200 device for drive %d!" % self.drive)
        self._drives[self.drive-1] = self
        self.dev = MPC200_Driver.getDevice(self.port)
        # self._notifier.sigPosChanged.connect(self._mpc200PosChanged)
        man.sigAbortAll.connect(self.stop)

        self._lastMove = None

        Stage.__init__(self, man, config, name)

        # clear cached position for this device and re-read to generate an initial position update
        self._pos_cache[self.drive-1] = None
        self.getPosition(refresh=True)

        ## May have multiple SutterMPC200 instances (one per drive), but 
        ## we only need one monitor.
        if SutterMPC200._monitor is None:
            SutterMPC200._monitor = MonitorThread(self)
            SutterMPC200._monitor.start()

    def capabilities(self):
        """Return a structure describing the capabilities of this device"""<commit_msg>add missing axes method for SutterMPC200<commit_after># -*- coding: utf-8 -*-
from __future__ import print_function
import time
from acq4.util import Qt
from ..Stage import Stage, MoveFuture
from acq4.drivers.SutterMPC200 import SutterMPC200 as MPC200_Driver
from acq4.util.Mutex import Mutex
from acq4.util.Thread import Thread
from pyqtgraph import debug, ptime
from six.moves import range


def __reload__(old):
    # copy some globals if the module is reloaded
    SutterMPC200._monitor = old['SutterMPC200']._monitor


class ChangeNotifier(Qt.QObject):
    """Used to send raw (unscaled) stage position updates to other devices. 
    In particular, focus motors may use this to hijack unused ROE axes.
    """
    sigPosChanged = Qt.Signal(object, object, object)


class SutterMPC200(Stage):
    """
    This Device class represents a single drive of a Sutter MPC-200 stage/manipulator driver.
    Config options are: 

        port: <serial port>  # eg. 'COM1' or '/dev/ttyACM0'
        drive: <drive>       # int 1-4
    """

    _pos_cache = [None] * 4
    _notifier = ChangeNotifier()
    _monitor = None
    _drives = [None] * 4
    slowSpeed = 4  # speed to move when user requests 'slow' movement

    def __init__(self, man, config, name):
        self.port = config.pop('port')
        self.drive = config.pop('drive')
        self.scale = config.pop('scale', (1, 1, 1))
        if self._drives[self.drive-1] is not None:
            raise RuntimeError("Already created MPC200 device for drive %d!" % self.drive)
        self._drives[self.drive-1] = self
        self.dev = MPC200_Driver.getDevice(self.port)
        # self._notifier.sigPosChanged.connect(self._mpc200PosChanged)
        man.sigAbortAll.connect(self.stop)

        self._lastMove = None

        Stage.__init__(self, man, config, name)

        # clear cached position for this device and re-read to generate an initial position update
        self._pos_cache[self.drive-1] = None
        self.getPosition(refresh=True)

        ## May have multiple SutterMPC200 instances (one per drive), but 
        ## we only need one monitor.
        if SutterMPC200._monitor is None:
            SutterMPC200._monitor = MonitorThread(self)
            SutterMPC200._monitor.start()

    def axes(self):
        if 'axes' in self.config:
            return self.config['axes']
        else:
            return ('x', 'y')

    def capabilities(self):
        """Return a structure describing the capabilities of this device"""
{'fraction_non_alphanumeric': 0.0944686140459913, 'fraction_numerical': 0.0254816656308266, 'mean_word_length': 2.853152434158021, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6332544', 'n_tokens_mistral': 1543, 'n_tokens_neox': 1425, 'n_words': 456}