Example #1
0
 def terminateValveControl(self, msg="NO_MSG"):
     endTest(msg)
     print(msg)
     if (self.stepper is not None):
         self.stepper.setVelocityLimit(0)
         self.stepper.setEngaged(0)
         self.stepper.close()
	def onEncoderDetached(self, e):
		try:
			print("\nDetach event on Port %d Channel %d" % (detached.getHubPort(), detached.getChannel()))
		except PhidgetException as e:
			terminateValveControl("encoder detached! Phidget Exception " + str(e.code) + " " + e.details)
		try:
			tempVelocity = self.velocitySetting
			self.MEVStepper.setVelocity(0)
			tempPosition = self.encoder.getPosition()
			self.encoder.close()
			self.initEncoder(tempPosition)
			self.MEVStepper.setVelocity(tempVelocity)
		except Exception as e:
			endTest("Encoder detached error")
Example #3
0
 def onEncoderAttached(self, e):
     try:
         attached = e
         print("\nAttach Event Detected (Information Below)")
         print("===========================================")
         print("Library Version: %s" % attached.getLibraryVersion())
         print("Serial Number: %d" % attached.getDeviceSerialNumber())
         print("Channel: %d" % attached.getChannel())
         print("Channel Class: %s" % attached.getChannelClass())
         print("Channel Name: %s" % attached.getChannelName())
         print("Device ID: %d" % attached.getDeviceID())
         print("Device Version: %d" % attached.getDeviceVersion())
         print("Device Name: %s" % attached.getDeviceName())
         print("Device Class: %d" % attached.getDeviceClass())
         print("\n")
     except Exception as e:
         endTest("Encoder attached error")
Example #4
0
    def initEncoder(self, serialNum, initPosition=0):
        self.encoder = Encoder()
        try:
            self.encoder.setDeviceSerialNumber(serialNum)
            self.encoder.setChannel(0)

            self.encoder.setOnAttachHandler(self.onEncoderAttached)
            self.encoder.setOnDetachHandler(self.onEncoderDetached)
            self.encoder.setOnErrorHandler(self.onErrorEvent)

            #self.encoder.setOnPositionChangeHandler(self.onPositionChanged)

            self.encoder.openWaitForAttachment(5000)
            self.encoder.setPosition(initPosition)
            self.encoder.setDataInterval(10)
            if (not self.encoder.getEnabled()):
                self.encoder.setEnabled(1)
        except PhidgetException as e:
            print("Phidget Exception %i: %s" % (e.code, e.details))
            endTest("Encoder init error")
Example #5
0
 def onErrorEvent(self, e, eCode, description):
     print("Error event #%i : %s" % (eCode, description))
     endTest("Encoder error")