def setStagePosition(self, value):
                for axis in self.stage_axes:
                        if axis == 'b':
                                pass
                        else:
                                try:
                                        if value[axis] < self.stage_range[axis][0]:
                                                raise ValueError('Stage position %s out of range' % axis)
                                        if value[axis] > self.stage_range[axis][1]:
                                                m = 'invalid stage position for %s axis'
                                                raise ValueError(m % axis)
                                except KeyError:
                                        pass

                for axis in value.keys():
                        if axis == 'b' and value['b'] is not None:
                                try:
                                        nidaq.setBeta(value['b'])
                                except:
                                        print 'exception, beta not set'
                        else:
                                try:
                                        self.stage_position[axis] = value[axis]
                                except KeyError:
                                        pass
Esempio n. 2
0
	def _setStagePosition(self, position, relative = 'absolute'):
#		tolerance = 1.0e-4
#		polltime = 0.01

		if relative == 'relative':
			for key in position:
				position[key] += getattr(self.tecnai.Stage.Position, key.upper())
		elif relative != 'absolute':
			raise ValueError
		
		pos = self.tecnai.Stage.Position

		axes = 0
		for key, value in position.items():
			if use_nidaq and key == 'b':
				deg = value / 3.14159 * 180.0
				nidaq.setBeta(deg)
				continue
			setattr(pos, key.upper(), value)
			axes |= getattr(self.tem_constants, 'axis' + key.upper())

		if axes == 0:
			return
		try:
			self.tecnai.Stage.Goto(pos, axes)
		except com_module.COMError, (hr, msg, exc, arg):
			#print 'Stage.Goto failed with error %d: %s' % (hr, msg)
			if exc is None:
				raise ValueError('no extended error information, assuming stage limit was hit')
			else:
				wcode, source, text, helpFile, helpId, scode = exc
				if winerror.SUCCEEDED(wcode) and text is None:
					raise ValueError('no extended error information, assuming stage limit was hit')
				else:
					raise RuntimeError(text)