def getDevice(cls, port): """ Return a SutterMPC200 instance for the specified serial port. Only one instance will be created for each port. """ port = SerialDevice.normalizePortName(port) if port not in cls.DEVICES: cls.DEVICES[port] = SutterMPC200(port=port) return cls.DEVICES[port]
def __init__(self, port): port = SerialDevice.normalizePortName(port) if port in SutterMPC200.DEVICES: raise Exception("The port %s is already accessed by another instance of this class. Use getDevice(port) instead.") SutterMPC200.DEVICES[port] = self self.lock = RLock() self.port = port SerialDevice.__init__(self, port=self.port, baudrate=128000) self.scale = [0.0625e-6]*3 # default is 16 usteps per micron self._moving = False
def getDevice(cls, port): """ Return a SutterMPC200 instance for the specified serial port. Only one instance will be created for each port. *port* must be a serial COM port (eg. COM3 or /dev/ttyACM0) """ port = SerialDevice.normalizePortName(port) if port in cls.DEVICES: return cls.DEVICES[port] else: return SutterMPC200(port=port)