def attach(self): m = Manager() m.openManager() time.sleep(1) # print 'There are', len(m.getAttachedDevices()), 'device(s) attached' try: d = m.getAttachedDevices()[0] self.ir = IR() self.ir.openPhidget(d.getSerialNum()) except IndexError as e: print 'No devices attached!' raise e
def _init(): global _log, _serial2phidgets, _manager, _encoderHistory, _encoderAsAxis, _lastPollDevices, _sync _log = logging.getLogger("phidgets") _serial2phidgets = dict() _encoderHistory = dict() _encoderAsAxis = dict() _lastPollDevices = 0 _sync = 0 try: _manager = Manager() _manager.openManager() except Exception as e: _manager = None _log.warning("Cannot initialize support for Phidgets (%s)", e) _log.debug(traceback.format_exc()) all()
def main(): createDB() try: manager = Manager() except RuntimeError as e: print("RuntimeException: %s" % e.details) print("Exiting...") exit(1) try: manager.setOnAttachHandler(managerDeviceAttached) manager.setOnDetachHandler(managerDeviceDetached) manager.setOnErrorHandler(managerErrorHandler) manager.setOnServerConnectHandler(managerServerConnect) manager.setOnServerDisconnectHandler(managerServerDisconnect) manager.openManager() except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) print("Exiting...") exit(1) try: manager.openManager() except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) print("Exiting...") exit(1) print("Press Enter to quit...") chr = sys.stdin.read(1) print("Closing...") try: manager.closeManager() except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) print("Exiting...") exit(1) print("Done.") exit(0)
manager = Manager() except RuntimeError as e: print("Runtime Error " + e.details + ", Exiting...\n") exit(1) try: manager.setOnAttachHandler(AttachHandler) manager.setOnDetachHandler(DetachHandler) manager.setOnErrorHandler(LibraryErrorHandler) except PhidgetException as e: LocalErrorCatcher(e) print("Opening....") try: # This would be openPhidget for a specific device object manager.openManager() except PhidgetException as e: LocalErrorCatcher(e) print("Phidget Simple Playground (plug and unplug devices)") print("Press Enter to end anytime...") character = str(raw_input()) print("Closing...") try: # This would be closePhidget() for a specific device object manager.closeManager() except PhidgetException as e: LocalErrorCatcher(e) exit(0)
exit(1) #Main Program Code try: mngr.setOnAttachHandler(ManagerDeviceAttached) mngr.setOnDetachHandler(ManagerDeviceDetached) mngr.setOnErrorHandler(ManagerError) except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) print("Exiting....") exit(1) print("Opening phidget manager....") try: mngr.openManager() except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) print("Exiting....") exit(1) attachedDevices = mngr.getAttachedDevices() print( "|------------|----------------------------------|--------------|------------|" ) print( "|- Attached -|- Type -|- Serial No. -|- Version -|" ) print( "|------------|----------------------------------|--------------|------------|"
exit(1) #Main Program Code try: mngr.setOnAttachHandler(ManagerDeviceAttached) mngr.setOnDetachHandler(ManagerDeviceDetached) mngr.setOnErrorHandler(ManagerError) except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) print("Exiting....") exit(1) print("Opening phidget manager....") try: mngr.openManager() except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) print("Exiting....") exit(1) attachedDevices = mngr.getAttachedDevices() print("|------------|----------------------------------|--------------|------------|") print("|- Attached -|- Type -|- Serial No. -|- Version -|") print("|------------|----------------------------------|--------------|------------|") for attachedDevice in attachedDevices: print("|- %8s -|- %30s -|- %10d -|- %8d -|" % (attachedDevice.isAttached(), attachedDevice.getDeviceName(), attachedDevice.getSerialNum(), attachedDevice.getDeviceVersion())) print("|------------|----------------------------------|--------------|------------|")
def setup_phidgets(): global interfaceKits interfaceKits = InterfaceKits() "Print Creating phidget manager" try: manager = Manager() except RuntimeError as e: output("Runtime Exception: %s" % e.details) output("Exiting....") exit(1) try: manager.setOnAttachHandler(ManagerDeviceAttached) manager.setOnDetachHandler(ManagerDeviceDetached) manager.setOnErrorHandler(ManagerError) except PhidgetException as e: output("Phidget Exception %i: %s" % (e.code, e.details)) output("Exiting....") exit(1) output("Opening phidget manager....") logging.info("Opening phidget manager....") try: manager.openManager() #manager.openRemote("hydropi","hydropi") except PhidgetException as e: output("Phidget Exception %i: %s" % (e.code, e.details)) logging.error("Phidget Exception %i: %s" % (e.code, e.details)) output("Exiting....") logging.error("Exiting....") exit(1) # Wait a moment for devices to attache...... output("\nWaiting one sec for devices to attach....\n\n") logging.info("Waiting one sec for devices to attach....") time.sleep(1) output("Phidget manager opened.") attachedDevices = manager.getAttachedDevices() for attachedDevice in attachedDevices: output("Found %30s - SN %10d" % (attachedDevice.getDeviceName(), attachedDevice.getSerialNum())) if attachedDevice.getDeviceClass() == PhidgetClass.INTERFACEKIT: output(" %s/%d is an InterfaceKit" % ( attachedDevice.getDeviceName(),attachedDevice.getSerialNum())) #Create an interfacekit object try: newInterfaceKit = InterfaceKit() except RuntimeError as e: output("Runtime Exception: %s" % e.details) output("Exiting....") exit(1) output(" Opening...") try: newInterfaceKit.openPhidget() except PhidgetException as e: output("Phidget Exception %i: %s" % (e.code, e.details)) output("Exiting....") output(" Setting handlers...") try: newInterfaceKit.setOnAttachHandler(interfaceKitAttached) newInterfaceKit.setOnDetachHandler(interfaceKitDetached) newInterfaceKit.setOnErrorhandler(interfaceKitError) except PhidgetException as e: output("Phidget Exception %i: %s" % (e.code, e.details)) output("Exiting....") exit(1) output(" Attaching...") try: newInterfaceKit.waitForAttach(5000) except PhidgetException as e: output("Phidget Exception %i: %s" % (e.code, e.details)) try: newInterfaceKit.closePhidget() except PhidgetException as e: output("Phidget Exception %i: %s" % (e.code, e.details)) output("Exiting....") exit(1) output("Exiting....") exit(1) output(" Setting the data rate for each sensor index to 1000ms....") for i in range(newInterfaceKit.getSensorCount()): try: newInterfaceKit.setDataRate(i, 1000) except PhidgetException as e: output("Phidget Exception %i: %s" % (e.code, e.details)) interfaceKits.kitList.append(newInterfaceKit) display_device_info(manager) return manager
i = 0 j = windowSize spatialList = [] #Create an accelerometer object # try: # spatial = Spatial() # except RuntimeError as e: # print("Runtime Exception: %s" % e.details) # print("Exiting....") # exit(1) try: manager = Manager() manager.openManager() except PhidgetException as e: print ("PhidgetException: %s" % e.details) print ("Exiting") exit(1) def animate(e, serialNum): global params param = params[serialNum] if len(param.getTimestamp()) < windowSize: return #mutex.acquire() # while len(dataBuffer[0]) < bufferSize or len(subBuffer[0]) < windowSize: # mutex.wait() # transferToBuffer(dataBuffer,subBuffer) # subBuffer = [[],[],[],[]]