当前位置: 首页>>代码示例>>Python>>正文


Python InterfaceKit.InterfaceKit类代码示例

本文整理汇总了Python中Phidgets.Devices.InterfaceKit.InterfaceKit的典型用法代码示例。如果您正苦于以下问题:Python InterfaceKit类的具体用法?Python InterfaceKit怎么用?Python InterfaceKit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了InterfaceKit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: cycleForever

class cycleForever(threading.Thread):
    def __init__(
        self,
        behavior_setup_name,
        interfaceKitIPAddress,
        pumpIPAddress,
        interfaceKitPort=5001,
        pumpPort=100,
        pump_channels=["01", "02"]
        ):
        threading.Thread.__init__(self)
        self.setup_name = behavior_setup_name
        self.interfaceKitIPAddress = interfaceKitIPAddress
        self.interfaceKitPort = interfaceKitPort
        self.controller = InterfaceKit()
        self.controller.openRemoteIP(self.interfaceKitIPAddress, self.interfaceKitPort)
        self.pumpIPAddress = pumpIPAddress
        self.pumpPort = pumpPort
        self.pumpsConn = newPumpConnection(self.pumpIPAddress, self.pumpPort)
        self.pump_channels = pump_channels

    def run(self):
        while True:
            infuse = infuseFully(self.setup_name, self.controller, self.pumpsConn, pump_channels=self.pump_channels)
            infuse.start()
            infuse.join()
            withdraw = withdrawFully(self.setup_name, self.controller, self.pumpsConn, pump_channels=self.pump_channels)
            withdraw.start()
            withdraw.join()
开发者ID:coxlab,项目名称:Pumpr,代码行数:29,代码来源:pumpr.py

示例2: InterfaceSource

class InterfaceSource(Source):
    def __init__(self):
        Source.__init__(self)
        
        try:
            self._device = InterfaceKit()
        except RuntimeError as e:
            print("Runtime Error: %s" % e.message)
            
        try:
            self._device.openPhidget()
        except PhidgetException as e:
            print("Phidget Exception %i: %s" % (e.code, e.detail))
        
        self._device.setOnSensorChangeHandler(self.sensor_changed)
        
        print("Phidget: Waiting for Connection")
        self._device.waitForAttach(10000)
        
        self._device.setSensorChangeTrigger(0, 0)
        self._device.setDataRate(0, 1)
        
        print("Phidget: Connected")
    
    def sensor_changed(self, e):
        if self.sink is not None:
            self.sink([e.value])
开发者ID:intrinseca,项目名称:pidaq,代码行数:27,代码来源:phidget.py

示例3: _try_init

 def _try_init(self):
     if all([self._data_rate, self._attach_timeout, self._sensors]):
         try:
             from Phidgets.Devices.InterfaceKit import InterfaceKit
             from Phidgets.PhidgetException import PhidgetException
             self.interface_kit = InterfaceKit()
             self.interface_kit.setOnAttachHandler(lambda e: self._attach(e))
             self.interface_kit.setOnDetachHandler(lambda e: self._detach(e))
             self.interface_kit.setOnErrorhandler(lambda e: self._error(e))
             self.interface_kit.setOnSensorChangeHandler(lambda e: self._sensor_change(e))
             self.interface_kit.openPhidget()
             self.interface_kit.waitForAttach(self._attach_timeout)
             for i in range(self.interface_kit.getSensorCount()):
                 self.interface_kit.setDataRate(i, self._data_rate)
             logging.info("Phidget Sensor Handler Initalized")
             for s in self._sensors:
                 if s.port_num is not None:
                     s.current_data = self.interface_kit.getSensorValue(s.port_num)
                     logging.debug("Setting Initial Value for Sensor {} to {}".format(s.port_num, s.current_data))
                 else:
                     logging.warn("Cannot set Initial Value for Sensor {}".format(s.port_num))
         except ImportError:
             self.interface_kit = None
             logging.error('Phidget Python Module not found. Did you install python-phidget?')
         except PhidgetException as e:
             self.interface_kit = None
             logging.error("Could not Initalize Phidget Kit: {}".format(e.details))
开发者ID:BigSense,项目名称:LtSense,代码行数:27,代码来源:handlers.py

示例4: __init__

    def __init__(self):
        print ("Initiating pumps")
        try:
            self.interfaceKit = InterfaceKit()
        except RuntimeError as e:
            print ("Runtime Exception a: %s" % e.details)
            print ("Exiting....")
            exit(1)
        try:
            self.interfaceKit.openPhidget()
        except PhidgetException as e:
            print ("Phidget Exception b %i: %s" % (e.code, e.details))
            print ("Exiting....")
            exit(1)

        try:
            self.interfaceKit.waitForAttach(1000)
        except PhidgetException as e:
            print ("Phidget Exception c %i: %s" % (e.code, e.details))
            raise Exception("Timeout")
            try:
                self.interfaceKit.closePhidget()
            except PhidgetException as e:
                print ("Phidget Exception d %i: %s" % (e.code, e.details))
                print ("Exiting....")
                exit(1)
        self.pumplist = []
        for i in range(0, 4):
            self.pumplist.append(onePump(self.interfaceKit, i))
        print ("Pumps ready")
开发者ID:cloudymike,项目名称:hopitty,代码行数:30,代码来源:pumpUSB.py

示例5: __init__

    def __init__(self):     
        try:
            self.interfaceKit = InterfaceKit()
        except RuntimeError as e:
            print("Runtime Exception: %s" % e.details)
            exit(1)

        print("Connecting to Phidget.")

        try:
            self.interfaceKit.openPhidget()
        except PhidgetException as e:
            print("Phidget Exception %i: %s" % (e.code, e.details))
            exit(1)

        print("Connection opened.")

        try:
            self.interfaceKit.waitForAttach(10000)
        except PhidgetException as e:
            try:
                self.interfaceKit.closePhidget()
            except PhidgetException as e:
                exit(1)
            exit(1)
        print("Attached to phidget interface.")
开发者ID:veiset,项目名称:home-pie,代码行数:26,代码来源:read_sensor_data.py

示例6: __init__

 def __init__(self, name, *args, **kwargs):
     self.name = name
     self.initializing = True
     if LIVE: self.interface_kit = InterfaceKit()
     self.manager = PubSub(self, pub_port=settings.NODE_PUB, sub_port=settings.NODE_SUB, sub_filter=self.name)
     self.logger = util.get_logger("%s.%s" % (self.__module__, self.__class__.__name__))
     self.initialize()    
     self.run()
开发者ID:entone,项目名称:Automaton,代码行数:8,代码来源:__init__.py

示例7: __init__

 def __init__(self, **kwargs):
     log.debug("Acquiring InterfaceKit")
     self.ik = InterfaceKit()
     log.debug("Registering Handlers")
     self.ik.setOnAttachHandler(self._onAttach)
     self.ik.setOnDetachHandler(self._onDetach)
     self.ik.setOnErrorhandler(self._onError)
     self.ik.setOnOutputChangeHandler(self._onOutput)
     self.ik.setOnInputChangeHandler(self._onInput)
     self.ik.setOnSensorChangeHandler(self._onSensor)
开发者ID:psas,项目名称:launch-tower-comm,代码行数:10,代码来源:ltcbackend.py

示例8: instanciarIK

 def instanciarIK (self, nroSerie):
     """
     Método utilizado para instanciar un objeto de tipo InterfaceKit de la API de Phidgets, que permite interactuar con la placa controladora y sus puertos"""
     try:
         ik= InterfaceKit()
         ik.openRemoteIP(self.__ipWS, self.__puertoWS, nroSerie)
         ik.waitForAttach(5000)
         return ik
     except :
         ik.closePhidget()
         return None
开发者ID:dbayure,项目名称:SGIA,代码行数:11,代码来源:Herramientas.py

示例9: cycleFor

class cycleFor(threading.Thread):
    def __init__(
        self,
        numCycles,
        behavior_setup_name,
        interfaceKitIPAddress,
        pumpIPAddress,
        interfaceKitPort=5001,
        primeForBehavior=True,
        pumpPort=100,
        pump_channels=["01", "02"]
        ):
        threading.Thread.__init__(self)
        self.controller = InterfaceKit()
        self.controller.openRemoteIP(interfaceKitIPAddress, interfaceKitPort)
        self.pumpsConn = newPumpConnection(pumpIPAddress, pumpPort)
        self.numCycles = numCycles
        self.behavior_setup_name = behavior_setup_name
        self.interfaceKitIPAddress = interfaceKitIPAddress
        self.pumpIPAddress = pumpIPAddress
        self.interfaceKitPort = interfaceKitPort
        self.primeForBehavior = primeForBehavior
        self.pumpPort = pumpPort
        self.pump_channels = pump_channels
    def run(self):
        #infuse fully then withdraw fully for numCycles
        for i in xrange(self.numCycles):
            infuse = infuseFully(self.behavior_setup_name, self.controller, self.pumpsConn, pump_channels=self.pump_channels)
            infuse.start()
            infuse.join()
            withdraw = withdrawFully(self.behavior_setup_name, self.controller, self.pumpsConn, pump_channels=self.pump_channels)
            withdraw.start()
            withdraw.join()
        if self.primeForBehavior:
            prime = primeForBehaviorSession(self.behavior_setup_name, self.controller, self.pumpsConn, pump_channels=self.pump_channels)
            prime.start()
            prime.join()
        self.pumpsConn.close()
开发者ID:coxlab,项目名称:Pumpr,代码行数:38,代码来源:pumpr.py

示例10: set_bbias

def set_bbias(state):
    """Set back bias to state"""

    state_dict = {"On" : True,
                  "Off" : False}
    setting = state_dict[state]

    ## Attach to Phidget controller
    relay = InterfaceKit()
    relay.openPhidget()
    relay.waitForAttach(10000)

    ## Check if successful
    if relay.isAttached():
        print "Done!"
    else:
        print "Failed to connect to Phidget controller"

    ## Set output to 0 and close
    relay.setOutputState(0, setting)
    print "BSS is now {0}".format(state)
    relay.closePhidget()

    return
开发者ID:Snyder005,项目名称:ccdcontroller,代码行数:24,代码来源:ccdsetup.py

示例11: run

def run():  
    kit = InterfaceKit()
    try:
        try:
            kit.openPhidget()
            kit.setOnAttachHandler(attached)
            kit.setOnDetachHandler(detached)
            if not kit.isAttached():
                print "Please attach the interface kit!"
            raw_input()
        except PhidgetException as e:
            print ("Phidget exception %i: %s" % (e.code,e.detail))
    except RuntimeError as e:
        print ("Runtime error: %s" % e.message)
    except Exception as e:
        print ("Unknown error: %s" % (e.message))
        
    stop(kit)
开发者ID:tfaris,项目名称:phidgetvol,代码行数:18,代码来源:main.py

示例12: __init__

    def __init__(self, serialNumber=None, waitForAttach=1000, **kargs):

        self.interfaceKit = InterfaceKit()

        if 'remoteHost' in kargs:
            self.interfaceKit.openRemote(kargs['remoteHost'], serialNumber)
        else:
            self.interfaceKit.openPhidget(serialNumber)
    
        self.ratiometric = 1
        if 'ratiometric' in kargs:
            self.ratiometric = kargs['ratiometric'] 

        h = [
            'onAttachHandler',
            'onDetachHandler',
            'onErrorhandler',
            'onInputChangeHandler',
            'onOutputChangeHandler',
            'onSensorChangeHandler'
            ]

        for event in h:
            self.__dict__[event] = None
            if event in kargs:
                self.__dict__[event] = kargs[event]

        self.interfaceKit.setOnAttachHandler(self.attached)
        self.interfaceKit.setOnDetachHandler(self.detached)
        self.interfaceKit.setOnErrorhandler(self.error)
        self.interfaceKit.setOnInputChangeHandler(self.inputChanged)
        self.interfaceKit.setOnOutputChangeHandler(self.outputChanged)
        self.interfaceKit.setOnSensorChangeHandler(self.sensorChanged)


        if waitForAttach > 0:
            try:
                self.interfaceKit.waitForAttach(waitForAttach)
            except PhidgetException as e:
                #print("Phidget Exception %i: %s" % (e.code, e.details))
                try:
                    self.interfaceKit.closePhidget()
                except PhidgetException as e2:
                    pass
                raise e
开发者ID:asphotographics,项目名称:WeatherStation,代码行数:45,代码来源:lphidget.py

示例13: open_phidget

    def open_phidget(self):
        self.log.debug("Attempting to open phidget")

        self.interface = InterfaceKit()

        if self._serial != None:
            self.log.debug("Attempt to open serial: %s" % self._serial)
            self.interface.openPhidget(self._serial)
        else:
            self.log.debug("Attempt to open first found")
            self.interface.openPhidget()

        wait_interval = 10300
        self.log.debug("Wait for attach %sms" % wait_interval)           
        self.interface.waitForAttach(wait_interval)
  
        self.log.info("Opened phidget") 
        return 1
开发者ID:WasatchPhotonics,项目名称:Phidgeter,代码行数:18,代码来源:relay.py

示例14: __init__

    def __init__(self):

        rospy.loginfo("Initializing PhidgetInterface")

        self.batteryVoltage = 0
        self.forwardRange = 1
        self.aftRange = 2

        self.interfaceKit = InterfaceKit()
        
        self.forwardRangeMessage = Range()
        self.forwardRangeMessage.header.frame_id = 'infrared_forward'
        self.forwardRangeMessage.radiation_type = Range.INFRARED
        self.forwardRangeMessage.field_of_view = 0.018
        self.forwardRangeMessage.min_range = 0.2
        self.forwardRangeMessage.max_range = 0.8
        self.forwardRangeMessage.range = 0.0

        self.aftRangeMessage = Range()
        self.aftRangeMessage.header.frame_id = 'infrared_aft'
        self.aftRangeMessage.radiation_type = Range.INFRARED
        self.aftRangeMessage.field_of_view = 0.018
        self.aftRangeMessage.min_range = 0.2
        self.aftRangeMessage.max_range = 0.8
        self.aftRangeMessage.range = 0.0

        self.sensorPublisher = rospy.Publisher('bogies', Range)

        self.interfaceKit.setOnAttachHandler(self.interfaceKitAttached)
        self.interfaceKit.setOnDetachHandler(self.interfaceKitDetached)
        self.interfaceKit.setOnErrorhandler(self.interfaceKitError)
        self.interfaceKit.setOnInputChangeHandler(self.interfaceKitInputChanged)
        self.interfaceKit.setOnOutputChangeHandler(self.interfaceKitOutputChanged)
        self.interfaceKit.setOnSensorChangeHandler(self.interfaceKitSensorChanged)

        try:
            self.interfaceKit.openPhidget()

        except PhidgetException, e:
            rospy.logerror("openPhidget() failed")
            rospy.logerror("code: %d" % e.code)
            rospy.logerror("message", e.message)

            raise
开发者ID:billmania,项目名称:nomad,代码行数:44,代码来源:short_range_and_battery.py

示例15: __init__

 def __init__(
     self,
     behavior_setup_name,
     interfaceKitIPAddress,
     pumpIPAddress,
     interfaceKitPort=5001,
     pumpPort=100,
     pump_channels=["01", "02"]
     ):
     threading.Thread.__init__(self)
     self.setup_name = behavior_setup_name
     self.interfaceKitIPAddress = interfaceKitIPAddress
     self.interfaceKitPort = interfaceKitPort
     self.controller = InterfaceKit()
     self.controller.openRemoteIP(self.interfaceKitIPAddress, self.interfaceKitPort)
     self.pumpIPAddress = pumpIPAddress
     self.pumpPort = pumpPort
     self.pumpsConn = newPumpConnection(self.pumpIPAddress, self.pumpPort)
     self.pump_channels = pump_channels
开发者ID:coxlab,项目名称:Pumpr,代码行数:19,代码来源:pumpr.py


注:本文中的Phidgets.Devices.InterfaceKit.InterfaceKit类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。