Beispiel #1
0
 def run(self):
     ump = UMP.get_ump()
     devices = Sensapex.devices
     while True:
         try:
             with self.lock:
                 if self.stopped:
                     break
                 
             # read all updates waiting in queue
             devids = ump.recv_all()
             
             if len(devids) == 0:
                 # no packets in queue; just wait for the next one.
                 try:
                     devids = [ump.recv()]
                 except UMPError as err:
                     if err.errno == -3:
                         # ignore timeouts
                         continue
             for devid in devids:
                 dev = devices.get(devid, None)
                 if dev is not None:
                     # received an update packet for this device; ask it to update its position
                     dev._getPosition()
                     
             time.sleep(0.03)  # rate-limit updates to 30 Hz 
         except:
             debug.printExc('Error in Sensapex monitor thread:')
             time.sleep(1)
Beispiel #2
0
    def run(self):
        minInterval = 100e-3
        interval = minInterval
        lastPos = None
        while True:
            try:
                with self.lock:
                    if self.stopped:
                        break
                    maxInterval = self.interval

                pos = self.dev._getPosition()  # this causes sigPositionChanged to be emitted
                if pos != lastPos:
                    # if there was a change, then loop more rapidly for a short time.
                    interval = minInterval
                    lastPos = pos
                else:
                    interval = min(maxInterval, interval*2)

                if self.monitorObj is True:
                    self.dev._checkObjective()

                time.sleep(interval)
            except:
                debug.printExc('Error in Scientifica monitor thread:')
                time.sleep(maxInterval)
Beispiel #3
0
def printExc(msg='', indent=4, prefix='|', msgType='error'):
    """Print an error message followed by an indented exception backtrace
    (This function is intended to be called within except: blocks)"""
    pgdebug.printExc(msg, indent, prefix)
    try:
        import acq4.Manager
        if hasattr(acq4, 'Manager'):
            acq4.Manager.logExc(msg=msg, msgType=msgType)
    except Exception:
        pgdebug.printExc("[failed to log this error to manager]")
Beispiel #4
0
    def processClicked(self):
        output = []

        table = self.getElement('Results')
        for fh in self.fileLoader.loadedFiles():
            try:
                output.append(self.flowchart.process(Input=fh))
            except:
                debug.printExc('Error processing %s' % fh)
        table.setData(output)
Beispiel #5
0
 def processClicked(self):
     output = []
     
     table = self.getElement('Results')
     for fh in self.fileLoader.loadedFiles():
         try:
             output.append(self.flowchart.process(Input=fh))
         except:
             debug.printExc('Error processing %s' % fh)
     table.setData(output)
Beispiel #6
0
def printExc(msg="", indent=4, prefix="|", msgType="error"):
    """Print an error message followed by an indented exception backtrace
    (This function is intended to be called within except: blocks)"""
    try:
        import acq4.Manager

        acq4.Manager.logExc(msg=msg, msgType=msgType)
    except ImportError:
        print "[import acq4 failed; not logging this error to manager]"
    pgdebug.printExc(msg, indent, prefix)
Beispiel #7
0
    def run(self):
        minInterval = 100e-3
        interval = minInterval

        while True:
            try:
                with self.lock:
                    if self.stopped:
                        break
                    maxInterval = self.interval
                    moveRequest = self.moveRequest
                    self.moveRequest = None

                if moveRequest is None:
                    # just check for position update
                    if self.dev._checkPositionChange() is not False:
                        interval = minInterval
                    else:
                        interval = min(maxInterval, interval * 2)
                else:
                    # move the drive
                    mid, drive, pos, speed = moveRequest
                    try:
                        with self.dev.dev.lock:
                            # record the move starting time only after locking the device
                            start = ptime.time()
                            with self.lock:
                                self._moveStatus[mid] = (start, False)
                            pos = self.dev.dev.moveTo(drive, pos, speed)
                            self.dev._checkPositionChange(drive, pos)
                    except Exception as err:
                        debug.printExc('Move error:')
                        try:
                            if hasattr(err, 'lastPosition'):
                                self.dev._checkPositionChange(
                                    drive, err.lastPosition)
                        finally:
                            with self.lock:
                                self._moveStatus[mid] = (start, err)
                    else:
                        with self.lock:
                            self._moveStatus[mid] = (start, True)

                time.sleep(interval)
            except:
                debug.printExc('Error in MPC200 monitor thread:')
                time.sleep(maxInterval)
Beispiel #8
0
	def run(self):
		minInterval = 100e-6
		interval = minInterval
		while True:
			try:
				with self.lock:
					if self.stopped:
						break
					maxInterval = self.interval

				if self.dev.checkPositionChange() is not False:
					interval = minInterval
				else:
					interval = min(maxInterval, interval*2)

				time.sleep(interval)
			except:
				debug.printExc('Error in MPC200 monirot thread:')
				time.sleep(maxInterval)
Beispiel #9
0
    def run(self):
        minInterval = 100e-3
        interval = minInterval
        lastPos = None
        while True:
            try:
                with self.lock:
                    if self.stopped:
                        break
                    maxInterval = self.interval
                pos = self.dev._getPosition()[2]
                if pos != lastPos:
                    # stage is moving; request more frequent updates
                    interval = minInterval
                else:
                    interval = min(maxInterval, interval * 2)
                lastPos = pos

                time.sleep(interval)
            except:
                debug.printExc('Error in MFC1 monitor thread:')
                time.sleep(maxInterval)