當前位置: 首頁>>代碼示例>>Python>>正文


Python InterfaceKit.setDataRate方法代碼示例

本文整理匯總了Python中Phidgets.Devices.InterfaceKit.InterfaceKit.setDataRate方法的典型用法代碼示例。如果您正苦於以下問題:Python InterfaceKit.setDataRate方法的具體用法?Python InterfaceKit.setDataRate怎麽用?Python InterfaceKit.setDataRate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Phidgets.Devices.InterfaceKit.InterfaceKit的用法示例。


在下文中一共展示了InterfaceKit.setDataRate方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: InterfaceSource

# 需要導入模塊: from Phidgets.Devices.InterfaceKit import InterfaceKit [as 別名]
# 或者: from Phidgets.Devices.InterfaceKit.InterfaceKit import setDataRate [as 別名]
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,代碼行數:29,代碼來源:phidget.py

示例2: __init__

# 需要導入模塊: from Phidgets.Devices.InterfaceKit import InterfaceKit [as 別名]
# 或者: from Phidgets.Devices.InterfaceKit.InterfaceKit import setDataRate [as 別名]
class Phidgets:
    
    def __init__(self):
        self.V1 = 0.0
        self.V2list = [0,0,0,0,0,0,0] #lista dei valori associati alle porte analogiche, corrispondenza porta analogica posizione nella lista
        self.running = True
        
    def ponteDiWheatstone(self):
        R1 = 1000.0#1KOhm
        R2 = 1000.0#1KOhm
        R3 = 1000.0#1KOhm
        Vs = 5.0
        
        for pos, v in enumerate(self.V2list):
            if v==0:
                continue
            
            Vm = v-self.V1 #ingresso differenziale
            print Vm
            #formula per il calcolo della resistenza
            p1 = R3/(R1+R3) + (Vm/Vs)
            p2 = 1 - p1
            Rx = R2*(p1/p2);
            
            #
            date = datetime.now().strftime('%Y-%m-%d')
            time = datetime.now().strftime('%H:%M:%S')
            self.monitoring.insertValue(Rx, pos+1, date,time)
            #
            print ("la resistenza sull'input %d vale %f: " % (pos+1, Rx))

    def partitoreDiTensione(self, val):
        if val != 1:
            r1 = 1000
            Vref = 12 #5V tensione applicata al partitore
            V2 = (5.0/1023.0)*val #tensione letta ai capi della resistenza
            r2 =  r1*V2/(Vref-V2)
            print ("la resistenza vale %f: " % r2)
        
    def interfaceKitSensorChanged(self, e):
        source = e.device
        if e.value == 1:#1 indica che non sta nulla collegato e resetto anche il suo valore nella lista
            if e.index==0:
                self.V1=0
            else:
                self.V2list[e.index-1]=0
            return
        
        if e.index == 0:#V1 va collegato sempre sul pin 0
            self.V1 = (5.0/1023.0)*e.value 
            print self.V1
        else:
            val = (5.0/1023.0)*e.value
            self.V2list[e.index-1]=val #corrispondenza porta analogica posizione nella lista
            print str(self.V2list)
        
        self.ponteDiWheatstone()
            
        #if e.value != 1:
        #    self.monitoring.insertPos(e.index)
        #print("InterfaceKit %i: Sensor %i: %i" % (source.getSerialNum(), e.index, e.value))
    
    def run(self):
            try:
                self.interfaceKit = InterfaceKit() #instanzio la classe per interfacciarmi con la scheda di acquisizione
                self.monitoring = sm.SensorMonitoring() #tabella dove sono memorizzati i valori dei sensori collegati
                self.monitoring.open()
                self.monitoring.create()
            except RuntimeError as e:
                print("Runtime Exception: %s" % e.details)
                print("Exiting....")
                exit(1)
            
            try:
                self.interfaceKit.setOnSensorChangeHandler(self.interfaceKitSensorChanged)
            except PhidgetException as e:
                print("Exiting....")
                exit(1)
                
            try:
                self.interfaceKit.openPhidget()
            except PhidgetException as e:
                print("Exiting....")
                exit(1)
                
            try:
                self.interfaceKit.waitForAttach(10000)
            except PhidgetException as e:
                try:
                    self.interfaceKit.closePhidget()
                except PhidgetException as e:
                    exit(1)
                print("Assicurarsi di aver collegato la scheda di acquisizione Phidget 1019 al PC. Exiting....")
                exit(1)
            else:
                print "Scheda di acquisizione rilevata."
                
            for i in range(self.interfaceKit.getSensorCount()):
                try:
                    self.interfaceKit.setDataRate(i, 4)
#.........這裏部分代碼省略.........
開發者ID:Gigi91,項目名稱:WMeasuresClient,代碼行數:103,代碼來源:phidgets.py

示例3: print

# 需要導入模塊: from Phidgets.Devices.InterfaceKit import InterfaceKit [as 別名]
# 或者: from Phidgets.Devices.InterfaceKit.InterfaceKit import setDataRate [as 別名]
    try:
        interfaceKit.closePhidget()
    except PhidgetException as e:
        print("Phidget Exception %i: %s" % (e.code, e.details))
        print("Exiting....")
        exit(1)
    print("Exiting....")
    exit(1)
else:
    displayDeviceInfo()


print("Setting the data rate for each sensor index to 4ms....")
for i in range(interfaceKit.getSensorCount()):
    try:        
        interfaceKit.setDataRate(i, 4)
    except PhidgetException as e:
        print("Phidget Exception %i: %s" % (e.code, e.details))
        

HOST = ''                                             
PORT = 20000       
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind((HOST, PORT))                            
s.listen(1)


print("Press Enter to quit....")
    
開發者ID:seven8nine,項目名稱:Push_and_record,代碼行數:31,代碼來源:InterfaceKitServer.py

示例4: setup_phidgets

# 需要導入模塊: from Phidgets.Devices.InterfaceKit import InterfaceKit [as 別名]
# 或者: from Phidgets.Devices.InterfaceKit.InterfaceKit import setDataRate [as 別名]
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 
開發者ID:mrPaq,項目名稱:autoHP,代碼行數:100,代碼來源:autoHP.py

示例5: PhidgetSensorHandler

# 需要導入模塊: from Phidgets.Devices.InterfaceKit import InterfaceKit [as 別名]
# 或者: from Phidgets.Devices.InterfaceKit.InterfaceKit import setDataRate [as 別名]
class PhidgetSensorHandler(AbstractSensorHandler):

    def __init__(self):
        self.device = None
        self._attach_timeout = None
        self._data_rate = None
        self._sensors = None

    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))

    def _read_sensors(self):
        ready_sensors = []
        for s in self._sensors:
            if s.data is not None:
                ready_sensors.append(s)
        return ready_sensors

    def _set_sensors(self, v):
        logging.debug('Adding Phidget Sensors :: {}'.format(v))
        self._sensors = v
        self._try_init()

    sensors = property(_read_sensors, _set_sensors)

    attach_timeout = property(lambda self: self._attach_timeout,
                              lambda self, v: self._set_config('attach_timeout', v))

    data_rate = property(lambda self: self._data_rate,
                         lambda self, v: self._set_config('data_rate', v))

    def _set_config(self, prop, value):
        if prop == 'data_rate':
            self._data_rate = value
        elif prop == 'attach_timeout':
            self._attach_timeout = value
        self._try_init()

    def _attach(self, e):
        self.device = e.device
        logging.info("Phidget InterfaceKit {} Attached".format(self.device.getSerialNum()))

    def _detach(self, e):
        logging.warn("Phidget InterfaceKit {} Removed".format(e.device.getSerialNum()))
        self.device = None

    def _error(self, e):
        logging.error("Phidget Error {} :: {}".format(e.eCode, e.description))

    def _sensor_change(self, e):
        # logging.debug("Phidget Analog Sensor Change :: Port: {} / Data: {}".format(e.index, e.value))
        for s in self._sensors:
            if s.port_type == 'analog' and s.port_num == e.index:

                # Set a default ID if none given in config file
                if s.id is None:
                    # Default ID is kit serial number::port
                    s.id = '{}:{}:{}'.format(self.device.getSerialNum(),
                                             s.port_type, s.port_num)

                s.current_data = e.value
開發者ID:BigSense,項目名稱:LtSense,代碼行數:88,代碼來源:handlers.py

示例6: print

# 需要導入模塊: from Phidgets.Devices.InterfaceKit import InterfaceKit [as 別名]
# 或者: from Phidgets.Devices.InterfaceKit.InterfaceKit import setDataRate [as 別名]
        interfaceKitHUB.closePhidget()
        #interfaceKitLCD.closePhidget()
        
    except PhidgetException as e:
        print("Phidget Exception %i: %s" % (e.code, e.details))
        print("Exiting....")
        exit(1)
    print("Exiting....")
    exit(1)
else:
    displayDeviceInfo()

#print("Setting the data rate for each sensor index to 4ms....")
for i in range(interfaceKitHUB.getSensorCount()):
    try:
        interfaceKitHUB.setDataRate(i, 2)
    except PhidgetException as e:
        print("Phidget Exception %i: %s" % (e.code, e.details))

print "\n"

#Make sure the ratiometric setting is set (required by sonar)
if not interfaceKitHUB.getRatiometric:
    interfaceKitHUB.setRatiometric(True)

#Register interupt callback
signal.signal(signal.SIGINT, signal_handler)

#Setup zmq sockets
context = zmq.Context()
distance_socket = context.socket(zmq.PUB)
開發者ID:AustralianSynchrotron,項目名稱:Australian-Synchrotron-Surveyor-Tunnel-Exploration-And-Fault-Detection-Robot,代碼行數:33,代碼來源:srv_irdist.py

示例7: print

# 需要導入模塊: from Phidgets.Devices.InterfaceKit import InterfaceKit [as 別名]
# 或者: from Phidgets.Devices.InterfaceKit.InterfaceKit import setDataRate [as 別名]
    except PhidgetException as e:
        print("InterfaceKit Close: Phidget Exception %i: %s" % (e.code, e.details))
    try:
        textLCD.closePhidget()
    except PhidgetException as e:
        print("LCD Close: Phidget Exception %i: %s" % (e.code, e.details))
    print("Exiting....")
    exit(1)
else:
    DisplayInterfaceKitDeviceInfo()


print("Setting the data rate for each sensor index to 128ms....")
for i in range(interfaceKit.getSensorCount()):
    try:
        interfaceKit.setDataRate(i, 128)
    except PhidgetException as e:
        print("InterfaceKit SetDataRate: Phidget Exception %i: %s" % (e.code, e.details))

while (1):
    try:
        if textLCD.getDeviceID()==PhidgetID.PHIDID_TEXTLCD_ADAPTER:
            textLCD.setScreenIndex(0)
            textLCD.setScreenSize(TextLCD_ScreenSize.PHIDGET_TEXTLCD_SCREEN_2x8)
            
        textLCD.setBacklight(True)
            
#         print("Writing to first row....")
#         textLCD.setDisplayString(0, "  Cisco Live 2014   ")
#        sleep(2)
開發者ID:Brett-Kugler,項目名稱:CiscoLiveHackathon,代碼行數:32,代碼來源:SensorSend.py

示例8: sleep

# 需要導入模塊: from Phidgets.Devices.InterfaceKit import InterfaceKit [as 別名]
# 或者: from Phidgets.Devices.InterfaceKit.InterfaceKit import setDataRate [as 別名]
       print iii+1
       interfaceKit.setOutputState (7, True)
       interfaceKit.setOutputState (0, True)
       sleep(0.38)

       interfaceKit.setOutputState (7, False)
       interfaceKit.setOutputState (0, False)
       sleep(0.38)

except PhidgetException as e:
        print("Phidget Exception %i: %s" % (e.code, e.details))

print("Setting the data rate for each sensor index to 16ms....")
for i in range(interfaceKit.getSensorCount()):
    try:
        interfaceKit.setDataRate(0, 16)
    except PhidgetException as e:
        print("Phidget Exception %i: %s" % (e.code, e.details))

print("Closing program")

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

print("Done.")
exit(0)
開發者ID:borevitzlab,項目名稱:plantspin,代碼行數:32,代碼來源:Camera_repeat_script.py

示例9: Node

# 需要導入模塊: from Phidgets.Devices.InterfaceKit import InterfaceKit [as 別名]
# 或者: from Phidgets.Devices.InterfaceKit.InterfaceKit import setDataRate [as 別名]

#.........這裏部分代碼省略.........
            cls=self.__class__.__name__
        )

    def __conform__(self, protocol):
        return json.dumps(self.json(), cls=ComplexEncoder)

    def displayDeviceInfo(self):pass
        
    #Event Handler Callback Functions
    def inferfaceKitAttached(self, e):
        attached = e.device
        self.logger.info("InterfaceKit %i Attached!" % (attached.getSerialNum()))

    def interfaceKitDetached(self, e):
        detached = e.device
        self.logger.info("InterfaceKit %i Detached!" % (detached.getSerialNum()))

    def interfaceKitError(self, e):
        try:
            if e.eCode not in (36866,):
                source = e.device
                self.logger.info("InterfaceKit %i: Phidget Error %i: %s" % (source.getSerialNum(), e.eCode, e.description))
        except PhidgetException as e:
            self.logger.exception(e)

    def interfaceKitInputChanged(self, e):
        input = self.get_input(e.index)
        if not input: return
        val = input.do_conversion(e.value)
        ob = input.json()
        self.publish(ob)
        self.logger.info("%s Input: %s" % (input.display, val))

    def interfaceKitSensorChanged(self, e):
        sensor = self.get_sensor(e.index)
        if not sensor: return
        val = sensor.do_conversion(float(e.value)) if sensor else 0
        ob = sensor.json()
        self.publish(ob)
        self.logger.info("%s Sensor: %s" % (sensor.display, val))

    def interfaceKitOutputChanged(self, e):
        output = self.get_output(e.index)
        if not output: return
        output.current_state = e.state
        ob = output.json()
        self.publish(ob)
        self.logger.info("%s Output: %s" % (output.display, output.current_state))


    def run(self):
        if LIVE: self.init_kit()
        while True: gevent.sleep(.1)

    def init_kit(self):
        try:
            self.interface_kit.setOnAttachHandler(self.inferfaceKitAttached)
            self.interface_kit.setOnDetachHandler(self.interfaceKitDetached)
            self.interface_kit.setOnErrorhandler(self.interfaceKitError)
            self.interface_kit.setOnInputChangeHandler(self.interfaceKitInputChanged)
            self.interface_kit.setOnOutputChangeHandler(self.interfaceKitOutputChanged)
            self.interface_kit.setOnSensorChangeHandler(self.interfaceKitSensorChanged)
        except PhidgetException as e:
            self.logger.exception(e)
            
        self.logger.info("Opening phidget object....")

        try:
            self.interface_kit.openPhidget()
        except PhidgetException as e:
            self.logger.exception(e)
            
        self.logger.info("Waiting for attach....")

        try:
            self.interface_kit.waitForAttach(10000)
        except PhidgetException as e:
            self.logger.exception(e)
            try:
                self.interface_kit.closePhidget()
            except PhidgetException as e:
                self.logger.exception(e)
                self.logger.info("Exiting....")
                exit(1)
            self.logger.info("Exiting....")
        else:
            self.displayDeviceInfo()

        self.logger.info("Initializing Sensors")
        for i in range(self.interface_kit.getSensorCount()):
            try:
                sensor = self.get_sensor(i)
                if sensor:
                    self.logger.info("Setting Up: %s" % sensor.display)
                    self.logger.info("Change: %s" % sensor.change)
                    self.logger.info("Data Rate: %s" % sensor.data_rate)
                    self.interface_kit.setSensorChangeTrigger(i, sensor.change)
                    self.interface_kit.setDataRate(i, sensor.data_rate)
            except PhidgetException as e:
                self.logger.exception(e)
開發者ID:entone,項目名稱:Automaton,代碼行數:104,代碼來源:__init__.py

示例10: __init__

# 需要導入模塊: from Phidgets.Devices.InterfaceKit import InterfaceKit [as 別名]
# 或者: from Phidgets.Devices.InterfaceKit.InterfaceKit import setDataRate [as 別名]
class Pot:

    __sensorPort = 1
    __sampleRate = 4 # Maybe too high?

    __potMin = 242
    __potZero = 490
    __potMax = 668


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

        try:
            self.interfaceKit.openPhidget()
            self.interfaceKit.waitForAttach(10000)
            self.interfaceKit.setDataRate(self.__sensorPort, self.__sampleRate)
        except PhidgetException as e:
            print("Phidget Exception %i: %s" % (e.code, e.details))
            try:
                self.interfaceKit.closePhidget()
            except PhidgetException as e:
                print("Phidget Exception %i: %s" % (e.code, e.details))
                print("Exiting....")
                exit(1)


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

    def getRawPot(self):
        try:
            resp = self.interfaceKit.getSensorValue(self.__sensorPort)
        except PhidgetException as e:
            # suppress print (makes testing harder) #TODO restore!!
            resp = float('nan')
            #print("Skipping reading - phidget Exception %i: %s" % (e.code, e.details))
        return resp

    #def recconect(self):


    def getPot(self):
        rawSensor = self.getRawPot()
        value = 0.0

        if rawSensor > self.__potMax:
            #warnings.warn("Pot measuremens out of bounds.") 
            return 1.0
        if rawSensor < self.__potMin: 
            #warnings.warn("Pot measuremens out of bounds.")
            return -1.0

        if rawSensor >= self.__potZero:
            value = float(rawSensor - self.__potZero) / (self.__potMax - self.__potZero)
        else:
            value = float(rawSensor - self.__potZero) / (self.__potZero - self.__potMin)

        return value
開發者ID:71ananab,項目名稱:Software,代碼行數:72,代碼來源:pot.py

示例11: SitwPhidgetsKey

# 需要導入模塊: from Phidgets.Devices.InterfaceKit import InterfaceKit [as 別名]
# 或者: from Phidgets.Devices.InterfaceKit.InterfaceKit import setDataRate [as 別名]

#.........這裏部分代碼省略.........
        print("Opening phidget object....")
        
        try:
            self.interfaceKit.openPhidget()
        except PhidgetException as e:
            print("Phidget Exception %i: %s" % (e.code, e.details))
            print("Exiting....")
            exit(1)
        
        print("Waiting for attach....")
        
        try:
            self.interfaceKit.waitForAttach(10000)
        except PhidgetException as e:
            print("Phidget Exception %i: %s" % (e.code, e.details))
            self.closePhidgets()
        else:
            self.displayDeviceInfo()
        
        
        #get sensor count
        try:
            self.ChannelCount = self.interfaceKit.getSensorCount()
        except PhidgetException as e:
            print("Phidget Exception %i: %s" % (e.code, e.details))
            self.closePhidgets()
            sitwPara.KeyCount = 0 #no sensor has been detected
            self.prtMsg('   ****** No sensor has been detected !!!\n')
        
        
        print("Setting the data rate for each sensor index to 4ms....")
        for i in range(sitwPara.KeyCount):
            try:
                self.interfaceKit.setDataRate(i, 4)
            except PhidgetException as e:
                print("Phidget Exception %i: %s" % (e.code, e.details))
        
        
        ### depends on the low light performance of the sensor
        print("Setting the sensitivity for each sensor index to ???....")
        for i in range(sitwPara.KeyCount):
            try:
                self.interfaceKit.setSensorChangeTrigger(i, 2)              #~~~~*YL*~~~~
            except PhidgetException as e:
                print("Phidget Exception %i: %s" % (e.code, e.details))
        
        

    def closePhidgets(self):
        #print("Press Enter to quit....")
        #chr = sys.stdin.read(1)
        #print("Closing...")
        
        try:
            self.interfaceKit.closePhidget()
        except PhidgetException as e:
            print("Phidget Exception %i: %s" % (e.code, e.details))
            print("Exiting....")
            exit(1)
        
        #print("Done.")
        #exit(1)



    def initKeys(self):
開發者ID:screensinthewild,項目名稱:Phidgets-Light-Keypad,代碼行數:70,代碼來源:SitwPhidgetsKey.py

示例12: main

# 需要導入模塊: from Phidgets.Devices.InterfaceKit import InterfaceKit [as 別名]
# 或者: from Phidgets.Devices.InterfaceKit.InterfaceKit import setDataRate [as 別名]
def main():
    
    
    
    try:
        interfaceKit = InterfaceKit()
    except RuntimeError as e:
        print("Runtime Exception: %s" % e.details)
        print("Exiting....")
        exit(1)

    try:
        interfaceKit.setOnAttachHandler(inferfaceKitAttached)
        interfaceKit.setOnDetachHandler(interfaceKitDetached)
        interfaceKit.setOnErrorhandler(interfaceKitError)
        interfaceKit.setOnInputChangeHandler(interfaceKitInputChanged)
        interfaceKit.setOnOutputChangeHandler(interfaceKitOutputChanged)
        interfaceKit.setOnSensorChangeHandler(interfaceKitSensorChanged)
    except PhidgetException as e:
        print("Phidget Exception %i: %s" % (e.code, e.details))
        print("Exiting....")
        exit(1)

    print("Opening phidget object....")

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

    print("Waiting for attach....")

    try:
        interfaceKit.waitForAttach(10000)
    except PhidgetException as e:
        print("Phidget Exception %i: %s" % (e.code, e.details))
        try:
            interfaceKit.closePhidget()
        except PhidgetException as e:
            print("Phidget Exception %i: %s" % (e.code, e.details))
            print("Exiting....")
            exit(1)
        print("Exiting....")
        exit(1)

    print("Setting the data rate for each sensor index to 4ms....")
    for i in range(interfaceKit.getSensorCount()):
        try:
            interfaceKit.setDataRate(i, 4)
        except PhidgetException as e:
            print("Phidget Exception %i: %s" % (e.code, e.details))

    sys.exit(app.exec_())
    try:
        interfaceKit.closePhidget()
    except PhidgetException as e:
        print("Phidget Exception %i: %s" % (e.code, e.details))
        print("Exiting....")
        exit(1)
開發者ID:Dillon-Benson,項目名稱:Phidgets-InterfaceKit-Gui,代碼行數:63,代碼來源:interfaceKit.py


注:本文中的Phidgets.Devices.InterfaceKit.InterfaceKit.setDataRate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。