Esempio n. 1
0
class PhidgetBridge():
    def __init__(self):
        self.bridge = Bridge()
        self.bridge.setOnAttachHandler(BridgeAttached)
        self.bridge.setOnDetachHandler(BridgeDetached)
        self.bridge.setOnErrorhandler(BridgeError)
        self.bridge.setOnBridgeDataHandler(BridgeData)
#         self.data_to_be_sent_bridge = []
#         self.times_to_be_sent_bridge = []
        
    def open(self,waitTimeMS):
        self.bridge.openPhidget()
        try:
            self.bridge.waitForAttach(waitTimeMS)
            time.sleep(0.2)
            self.bridge.setDataRate(8)
            time.sleep(0.2)
            self.bridge.setGain(0, BridgeGain.PHIDGET_BRIDGE_GAIN_8)
            time.sleep(0.2)
            self.bridge.setEnabled(0, True)
            time.sleep(0.2)
            return 1
        except:
            return -1
    
#     def BridgeData(self,e):
#         timeStamp = time.time()
#         self.data_to_be_sent_bridge.append(e.value)
#         self.times_to_be_sent_bridge.append(timeStamp)
        
    def getData(self):
        global data_to_be_sent_bridge
        global times_to_be_sent_bridge
        #return the data and times and update the lists
        data_to_return = [data_to_be_sent_bridge,times_to_be_sent_bridge]
        data_to_be_sent_bridge = []
        times_to_be_sent_bridge = []
        return data_to_return
    
    def close(self):
        self.bridge.setEnabled(0,False)
        time.sleep(2)
        self.bridge.closePhidget()
#Initialize data storage variables

startTime = getCurrentTime()
savedData = []

#each bridge is distinguished by a unique serial number
iBridgeSerials = [293138,293824,293749,293780,293743,293783]

#list of bridge objects.  Access serial by lBridges[0].getSerialNum()
lBridges = []

#loop through bridges creating bridge objects
for serial in iBridgeSerials:
    if options.verbose: print("---Opening %i...---"%serial)
    try:
        tempBridge = Bridge()
    except RuntimeError as e:
        print("Runtime Exception: %s" % e.details)
        print("Exiting....")
        exit(1)
    try:
        tempBridge.setOnAttachHandler(BridgeAttached)
        tempBridge.setOnDetachHandler(BridgeDetached)
        tempBridge.setOnErrorhandler(BridgeError)
        tempBridge.setOnBridgeDataHandler(BridgeData)
    except PhidgetException as e:
        print("Phidget Exception %i: %s" % (e.code, e.details))
        print("Exiting....")
        exit(1)

    try:
Esempio n. 3
0
    def __init__(self, master):
        frame = Frame(master)
        frame.pack()

        self.quitButton = Button(frame, text="Start", font=("Comic Sans", 500), command=root.destroy)
        self.quitButton.pack(side=LEFT)

root = Tk()
b = TheButtons(root)
root.mainloop()


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

# Creates bridge object
bridge = Bridge()

# Opens phidget
bridge.openPhidget()

# waits 10000 ms (10s) for bridge to connect
bridge.waitForAttach(10000)

displayDeviceInfo()


# defines initial parameters
def init():
    ax.set_ylim(0, 150)
    ax.set_xlim(0, 10)
    del xdata[:]
Esempio n. 4
0
#Basic imports
import sys
import time
#Phidget specific imports
from Phidgets.PhidgetException import PhidgetException
from Phidgets.Devices.Bridge import Bridge, BridgeGain
from Phidgets.Phidget import PhidgetLogLevel
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation


#Create a bridge object
try:
    bridge = Bridge()
except RuntimeError as e:	#error handling
    print("Runtime Exception: %s" % e.details)
    print("Exiting....")
    exit(1)


#Information Display Function
def displayDeviceInfo():
    print("|------------|----------------------------------|--------------|------------|")
    print("|- Attached -|-              Type              -|- Serial No. -|-  Version -|")
    print("|------------|----------------------------------|--------------|------------|")
    print("|- %8s -|- %30s -|- %10d -|- %8d -|" % (bridge.isAttached(), bridge.getDeviceName(), bridge.getSerialNum(), bridge.getDeviceVersion()))
    print("|------------|----------------------------------|--------------|------------|")
    print("Number of bridge inputs: %i" % (bridge.getInputCount()))
    print("Data Rate Max: %d" % (bridge.getDataRateMax()))
    print("Data Rate Min: %d" % (bridge.getDataRateMin()))
Esempio n. 5
0
    def __init__(self):

        # Information Display Function
        def displayDeviceInfo():
            print("|------------|----------------------------------|--------------|------------|")
            print("|- Attached -|-              Type              -|- Serial No. -|-  Version -|")
            print("|------------|----------------------------------|--------------|------------|")
            print("|- %8s -|- %30s -|- %10d -|- %8d -|" % (
            bridge.isAttached(), bridge.getDeviceName(), bridge.getSerialNum(), bridge.getDeviceVersion()))
            print("|------------|----------------------------------|--------------|------------|")

            # sets data rate (number of ms between data collection)
            # must be a multiple of 8 ms (125 Hz to 1 Hz)
            bridge.setDataRate(24)
            time.sleep(.2)
            print("Data rate set to: ", bridge.getDataRate(), "ms    ", 1 / (bridge.getDataRate() * 0.001), " Hz")

            # Gain	Resoluion	Range
            #  1	119 nV/V 	1000 mV/V
            #  8	14.9 nV/V	125 mV/V
            # 16	7.45 nV/V	62.5 mV/V
            # 32	3.72 nV/V	31.25 mV/V
            # 64	1.86 nV/V	15.625 mV/V
            # 128	0.92 nV/V   7.8125 mV/V

            # Force sensor maxes out around 4 mV/V so set gain to 128
            bridge.setGain(1, BridgeGain.PHIDGET_BRIDGE_GAIN_128)
            time.sleep(.2)
            print("Gain set to: ", bridge.getGain(1))

            # Sensor hooked up to input 1 on the PhidgetBridge
            print("Enabling  Bridge input 1 for reading data...")
            bridge.setEnabled(1, True)
            time.sleep(.2)

        # defines initial parameters
        def init():
            ax.set_ylim(0, 150)
            ax.set_xlim(0, 10)
            del xdata[:]
            del ydata[:]
            line.set_data(xdata, ydata)

            force_text.set_text('')
            return line, force_text

        # update the data
        def run(maxForce):
            # calculates seconds since program started running
            t = time.time() - startTime
            # converts bridge voltage output to lbs
            y = (bridge.getBridgeValue(1) + 0.007) * 74.3  # lbs/mV

            # adds this data onto the xdata and y data
            xdata.append(t)
            ydata.append(y)

            if len(ydata) > 30:
                ydata[len(ydata)-1] = (np.mean(ydata[(len(ydata) - 5):]))

            # updates plot title with current force* in lbs
            plt.title("%.1f" % np.mean(ydata[(len(ydata) - 10):]))
            # "%.1f" %" -- formats following number as a float with 1 value after the decimal
            # np.mean() -- takes the mean
            # len(ydata) -- computes the length of ydata
            # ydata[(len(ydata)-10):] -- takes the last ten values of ydata (similar to MATLAB colon notation)
            # So really avergaing the last 10 values (0.24s) worth of data


            currentForce = np.mean(ydata[(len(ydata) - 10):])
            force_text.set_text("Current Force: %.1f" % currentForce + " lbs")
            force_text.set_size(30)

            if currentForce > maxForce:
                maxForce = currentForce

            max_text.set_text("Max Force: %.1f" % np.max(ydata) + " lbs")
            max_text.set_size(30)

            a, b = force_text.get_position()
            c, d = max_text.get_position()

            # calculates current bounds on the x-axis
            xmin, xmax = ax.get_xlim()

            # if the data is within 2 second of the end of the graph
            if t >= xmax - 2:
                ax.set_xlim(t-8, t+2)  # increment the x-axis
                force_text.set_position((t-7.5, b))
                max_text.set_position((t-7.5, d))
                ax.figure.canvas.draw()  # redraw the graph
            line.set_data(xdata, ydata)  # update x and y values

            return line

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

        # Creates bridge object
        bridge = Bridge()

        # Opens phidget
        bridge.openPhidget()

        # waits 10000 ms (10s) for bridge to connect
        bridge.waitForAttach(10000)

        displayDeviceInfo()

        # sets up plot
        fig, ax = plt.subplots()
        line, = ax.plot([], [], lw=2)
        ax.grid()
        xdata, ydata = [], []
        startTime = time.time()

        time_template = 'time = %.1fs'
        force_text = plt.text(0.5, 125, "0")
        max_text = plt.text(0.5, 110, "0")

        # animates the graph
        ani = animation.FuncAnimation(fig, run, blit=False, interval=10, repeat=False, init_func=init)
        plt.show()
Esempio n. 6
0
#Phidget specific imports
from Phidgets.PhidgetException import PhidgetException
from Phidgets.Devices.Bridge import Bridge, BridgeGain
from Phidgets.Phidget import PhidgetLogLevel

measure_DATA = False
measure_MEAS = -1
DATA = [[], [], [], []]
MEAS = [[],[],[],[]]
offsets = []
K = []
printing = False

#Create an accelerometer object
try:
    bridge = Bridge()
except RuntimeError as e:
    print("Runtime Exception: %s" % e.details)
    print("Exiting....")
    exit(1)

#Information Display Function
def displayDeviceInfo():
    print("|------------|----------------------------------|--------------|------------|")
    print("|- Attached -|-              Type              -|- Serial No. -|-  Version -|")
    print("|------------|----------------------------------|--------------|------------|")
    print("|- %8s -|- %30s -|- %10d -|- %8d -|" % (bridge.isAttached(), bridge.getDeviceName(), bridge.getSerialNum(), bridge.getDeviceVersion()))
    print("|------------|----------------------------------|--------------|------------|")
    print("Number of bridge inputs: %i" % (bridge.getInputCount()))
    print("Data Rate Max: %d" % (bridge.getDataRateMax()))
    print("Data Rate Min: %d" % (bridge.getDataRateMin()))
Esempio n. 7
0
def AttachBridge(databasepath, serialNumber):
    def onAttachHandler(event):
        logString = "Bridge Attached " + str(event.device.getSerialNum())
        #print(logString)
        DisplayAttachedDeviceInfo(event.device)

    def onDetachHandler(event):
        logString = "Bridge Detached " + str(event.device.getSerialNum())
        #print(logString)
        DisplayDetachedDeviceInfo(event.device)

        event.device.closePhidget()

    def onErrorHandler(event):
        logString = "Bridge Error " + str(
            event.device.getSerialNum()) + ", Error: " + event.description
        print(logString)

        DisplayErrorDeviceInfo(event)

    def onServerConnectHandler(event):
        logString = "Bridge Server Connect " + str(event.device.getSerialNum())
        #print(logString)

    def onServerDisconnectHandler(event):
        logString = "Bridge Server Disconnect " + str(
            event.device.getSerialNum())
        #print(logString)

    def bridgeDataHandler(event):
        logString = "Bridge Data " + str(event.device.getSerialNum())
        #print(logString)

        try:
            conn = sqlite3.connect(databasepath)

            conn.execute(
                "INSERT INTO BRIDGE_DATA VALUES(NULL, DateTime('now'), ?, ?, ?)",
                (event.device.getSerialNum(), event.index, event.value))

            conn.commit()
            conn.close()
        except sqlite3.Error as e:
            print "An error occurred:", e.args[0]

    try:
        p = Bridge()

        p.setOnAttachHandler(onAttachHandler)
        p.setOnDetachHandler(onDetachHandler)
        p.setOnErrorhandler(onErrorHandler)
        p.setOnServerConnectHandler(onServerConnectHandler)
        p.setOnServerDisconnectHandler(onServerDisconnectHandler)

        p.setOnBridgeDataHandler(bridgeDataHandler)

        p.openPhidget(serialNumber)

    except PhidgetException as e:
        print("Phidget Exception %i: %s" % (e.code, e.details))
        print("Exiting...")
        exit(1)
Esempio n. 8
0
 def __init__(self):
     self.bridge = Bridge()
     self.bridge.setOnAttachHandler(BridgeAttached)
     self.bridge.setOnDetachHandler(BridgeDetached)
     self.bridge.setOnErrorhandler(BridgeError)
     self.bridge.setOnBridgeDataHandler(BridgeData)
Esempio n. 9
0
def AttachBridge(databasepath, serialNumber):
	def onAttachHandler(event):
		logString = "Bridge Attached " + str(event.device.getSerialNum())
		#print(logString)
		DisplayAttachedDeviceInfo(event.device)

	def onDetachHandler(event):
		logString = "Bridge Detached " + str(event.device.getSerialNum())
		#print(logString)
		DisplayDetachedDeviceInfo(event.device)

		event.device.closePhidget()

	def onErrorHandler(event):
		logString = "Bridge Error " + str(event.device.getSerialNum()) + ", Error: " + event.description
		print(logString)

		DisplayErrorDeviceInfo(event)
		
	def onServerConnectHandler(event):
		logString = "Bridge Server Connect " + str(event.device.getSerialNum())
		#print(logString)

	def onServerDisconnectHandler(event):
		logString = "Bridge Server Disconnect " + str(event.device.getSerialNum())
		#print(logString)

	def bridgeDataHandler(event):
		logString = "Bridge Data " + str(event.device.getSerialNum())
		#print(logString)

		try:
			conn = sqlite3.connect(databasepath)

			conn.execute("INSERT INTO BRIDGE_DATA VALUES(NULL, DateTime('now'), ?, ?, ?)", 
					(event.device.getSerialNum(), event.index, event.value))

			conn.commit()
			conn.close()
		except sqlite3.Error as e:
			print "An error occurred:", e.args[0]
	try:
		p = Bridge()

		p.setOnAttachHandler(onAttachHandler)
		p.setOnDetachHandler(onDetachHandler)
		p.setOnErrorhandler(onErrorHandler)
		p.setOnServerConnectHandler(onServerConnectHandler)
		p.setOnServerDisconnectHandler(onServerDisconnectHandler)

		p.setOnBridgeDataHandler(bridgeDataHandler)

		p.openPhidget(serialNumber)

	except PhidgetException as e:
		print("Phidget Exception %i: %s" % (e.code, e.details))
		print("Exiting...")
		exit(1)
Esempio n. 10
0
def openBridge(serialNum):
    #Create a bridge object
    try:
        bridge = Bridge()
    except RuntimeError as e:
        print("Runtime Exception: %s" % e.details)
        print("Exiting....")
        exit(1)

    try:
        bridge.setOnAttachHandler(BridgeAttached)
        bridge.setOnDetachHandler(BridgeDetached)
        bridge.setOnErrorhandler(BridgeError)
        bridge.setOnBridgeDataHandler(BridgeData)
    except PhidgetException as e:
        print("Phidget Exception %i: %s" % (e.code, e.details))
        print("Exiting....")
        exit(1)

    print("Calibration Script.\nOpening phidget object....")

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

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

    try:
        bridge.waitForAttach(20000)
        
        print("Set data rate to %i ms ..." % (rate))
        bridge.setDataRate(rate)
        sleep(1)

        print("Set Gain to %s..." % str(gainTable[gain]))
        setGainAllChanels(bridge,gain)
        sleep(1)

    except PhidgetException as e:
        print("Phidget Exception %i: %s" % (e.code, e.details))
        try:
            bridge.closePhidget()
        except PhidgetException as e:
            print("Phidget Exception %i: %s" % (e.code, e.details))
            print("Exiting....")
            exit(1)
        print("Exiting....")
        exit(1)
    else:
        displayDeviceInfo(bridge)
    return bridge
Esempio n. 11
0
class PhidgetBridge():
    def __init__(self):
        self.bridge = Bridge()
        self.bridge.setOnAttachHandler(BridgeAttached)
        self.bridge.setOnDetachHandler(BridgeDetached)
        self.bridge.setOnErrorhandler(BridgeError)
        self.bridge.setOnBridgeDataHandler(BridgeData)
#         self.data_to_be_sent_bridge = []
#         self.times_to_be_sent_bridge = []

    def open(self, waitTimeMS):
        self.bridge.openPhidget()
        try:
            self.bridge.waitForAttach(waitTimeMS)
            time.sleep(0.2)
            self.bridge.setDataRate(8)
            time.sleep(0.2)
            self.bridge.setGain(0, BridgeGain.PHIDGET_BRIDGE_GAIN_8)
            time.sleep(0.2)
            self.bridge.setEnabled(0, True)
            time.sleep(0.2)
            return 1
        except:
            return -1

#     def BridgeData(self,e):
#         timeStamp = time.time()
#         self.data_to_be_sent_bridge.append(e.value)
#         self.times_to_be_sent_bridge.append(timeStamp)

    def getData(self):
        global data_to_be_sent_bridge
        global times_to_be_sent_bridge
        #return the data and times and update the lists
        data_to_return = [data_to_be_sent_bridge, times_to_be_sent_bridge]
        data_to_be_sent_bridge = []
        times_to_be_sent_bridge = []
        return data_to_return

    def close(self):
        self.bridge.setEnabled(0, False)
        time.sleep(2)
        self.bridge.closePhidget()
Esempio n. 12
0
                self.file_data_3 = None
                
        if self.file_log is not None:
            try:
                self.file_log.close()
            except:
                print("log file close wrong")
            finally:
                self.file_log = None
                
        print("close_file: finished")

f = FileController()

try:
    bridge = Bridge()
except RuntimeError as e:
    f.print_log("Runtime Exception: %s" % e.details)
    f.print_log("Exiting.... ")
    #exit(1)

def displayDeviceInfo():

    f.print_log('Start: '+datetime.datetime.utcnow().ctime())
    f.print_log("|------------|----------------------------------|--------------|------------|")
    f.print_log("|- Attached -|-              Type              -|- Serial No. -|-  Version -|")
    f.print_log("|------------|----------------------------------|--------------|------------|")
    f.print_log("|- %8s -|- %30s -|- %10d -|- %8d -|" % (bridge.isAttached(), bridge.getDeviceName(), bridge.getSerialNum(), bridge.getDeviceVersion()))
    f.print_log("|------------|----------------------------------|--------------|------------|")
    f.print_log("Number of bridge inputs: %i" % (bridge.getInputCount()))
    f.print_log("Data Rate Max: %d" % (bridge.getDataRateMax()))
Esempio n. 13
0
#Phidget specific imports
from Phidgets.PhidgetException import PhidgetException
from Phidgets.Devices.Bridge import Bridge, BridgeGain
from Phidgets.Phidget import PhidgetLogLevel

measure_DATA = False
measure_MEAS = -1
DATA = [[], [], [], []]
MEAS = [[], [], [], []]
offsets = []
K = []
printing = False

#Create an accelerometer object
try:
    bridge = Bridge()
except RuntimeError as e:
    print("Runtime Exception: %s" % e.details)
    print("Exiting....")
    exit(1)


#Information Display Function
def displayDeviceInfo():
    print(
        "|------------|----------------------------------|--------------|------------|"
    )
    print(
        "|- Attached -|-              Type              -|- Serial No. -|-  Version -|"
    )
    print(
Esempio n. 14
0
from Phidgets.Phidget import PhidgetLogLevel

#---------------------------Init List--------------------------
#Titre = ["List1", "List2"]
Titre = ["List1"]
nbval = 10
List10 = [0] * nbval
#List20 = [0] * nbval
List1 = []
#List2 = []
iter = 0


#Create an accelerometer object
try:
    bridge = Bridge()
except RuntimeError as e:
    print("Runtime Exception: %s" % e.details)
    print("Exiting....")
    exit(1)

#Event Handler Callback Functions
def BridgeError(e):
    try:
        source = e.device
        print("Bridge %i: Phidget Error %i: %s" % (source.getSerialNum(), e.eCode, e.description))
    except PhidgetException as e:
        print("Phidget Exception %i: %s" % (e.code, e.details))

#---------------------------Add DATA--------------------------
def Moyenne(List):
Esempio n. 15
0
 def __init__(self):
     self.bridge = Bridge()
     self.bridge.setOnAttachHandler(BridgeAttached)
     self.bridge.setOnDetachHandler(BridgeDetached)
     self.bridge.setOnErrorhandler(BridgeError)
     self.bridge.setOnBridgeDataHandler(BridgeData)
Esempio n. 16
0
#Phidget specific imports
from Phidgets.Devices.Bridge import Bridge, BridgeGain
from Phidgets.PhidgetException import PhidgetException
from Phidgets.Phidget import PhidgetLogLevel

# declare and initialize some variables
# debug   0=suppress output messages   1=display messages
# loop    0=run once                   1=continuously loop
global debug, loop
debug=0
loop=0

#Create a bridge object
try:
    bridge = Bridge()
except RuntimeError as e:
    print("Runtime Exception: %s" % e.details)
    print("Exiting....")
    exit(1)

#Information Display Function
def displayDeviceInfo():
    global debug
    if debug:
       print("|------------|----------------------------------|--------------|------------|")
       print("|- Attached -|-              Type              -|- Serial No. -|-  Version -|")
       print("|------------|----------------------------------|--------------|------------|")
       print("|- %8s -|- %30s -|- %10d -|- %8d -|" % (bridge.isAttached(), bridge.getDeviceName(), bridge.getSerialNum(), bridge.getDeviceVersion()))
       print("|------------|----------------------------------|--------------|------------|")
       print("Number of bridge inputs: %i" % (bridge.getInputCount()))
Esempio n. 17
0
fig = Figure()   # creates the graph figure
axis1 = fig.add_subplot(111)            # axis 1 is in the first slot of the 1 by 1 subplot
axis1.set_title("Force over Time")
yellowLevel = 60
redLevel = 80

yellowLine = axis1.axhline(yellowLevel, color='y', linestyle='-')     # sets yellow horizontal line
redLine = axis1.axhline(redLevel, color='r', linestyle='-')        # sets red horizontal line
axis1.grid(color='gray', linestyle='-', linewidth=.25)      # sets up the grid
axis1.set_ylabel("Force (lbs)")
axis1.set_xlabel("Time (s)")
line1, = axis1.plot([], [], 'k', lw=3)       # creates a line on the axis with no datapoints and width of 2


print("Opening phidget object....")
bridge = Bridge()            # Creates PhidgetBridge object
bridge.openPhidget()         # Opens Phidgetbridge
bridge.waitForAttach(10000)  # waits 10000 ms (10s) for bridge to connect


# variable initializations
xData = []
yData = []
startTime = time.time()
maxForce = 0
imagePos = 0
pause = True
force_text = axis1.text(0.5, 125, "0", fontsize=25)
max_text = axis1.text(0.5, 110, "0", fontsize=25)

time.sleep(1)
Esempio n. 18
0
def openBridge(serialNum):
    # Create a bridge object
    try:
        bridge = Bridge()
    except RuntimeError as e:
        print("Runtime Exception: %s" % e.details)
        print("Exiting....")
        exit(1)

    try:
        bridge.setOnAttachHandler(BridgeAttached)
        bridge.setOnDetachHandler(BridgeDetached)
        bridge.setOnErrorhandler(BridgeError)
        bridge.setOnBridgeDataHandler(BridgeData)
    except PhidgetException as e:
        print("Phidget Exception %i: %s" % (e.code, e.details))
        print("Exiting....")
        exit(1)

    print("Calibration Script.\nOpening phidget object....")

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

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

    try:
        bridge.waitForAttach(20000)

        print("Set data rate to %i ms ..." % (rate))
        bridge.setDataRate(rate)
        sleep(1)

        print("Set Gain to %s..." % str(gainTable[gain]))
        setGainAllChanels(bridge, gain)
        sleep(1)

    except PhidgetException as e:
        print("Phidget Exception %i: %s" % (e.code, e.details))
        try:
            bridge.closePhidget()
        except PhidgetException as e:
            print("Phidget Exception %i: %s" % (e.code, e.details))
            print("Exiting....")
            exit(1)
        print("Exiting....")
        exit(1)
    else:
        displayDeviceInfo(bridge)
    return bridge
Esempio n. 19
0
"""

__author__ = "Adam Stelmack"
__version__ = "2.1.8"
__date__ = "14-Jan-2011 2:29:14 PM"

#Basic imports
import sys
from time import sleep
#Phidget specific imports
from Phidgets.PhidgetException import PhidgetException
from Phidgets.Devices.Bridge import Bridge, BridgeGain

#Create an accelerometer object
try:
    bridge = Bridge()
except RuntimeError as e:
    print("Runtime Exception: %s" % e.details)
    print("Exiting....")
    exit(1)


#Information Display Function
def displayDeviceInfo():
    print(
        "|------------|----------------------------------|--------------|------------|"
    )
    print(
        "|- Attached -|-              Type              -|- Serial No. -|-  Version -|"
    )
    print(
Esempio n. 20
0
#Initialize data storage variables

startTime = getCurrentTime()
savedData = []

#each bridge is distinguished by a unique serial number
iBridgeSerials = [293138, 293824, 293749, 293780, 293743, 293783]

#list of bridge objects.  Access serial by lBridges[0].getSerialNum()
lBridges = []

#loop through bridges creating bridge objects
for serial in iBridgeSerials:
    if options.verbose: print("---Opening %i...---" % serial)
    try:
        tempBridge = Bridge()
    except RuntimeError as e:
        print("Runtime Exception: %s" % e.details)
        print("Exiting....")
        exit(1)
    try:
        tempBridge.setOnAttachHandler(BridgeAttached)
        tempBridge.setOnDetachHandler(BridgeDetached)
        tempBridge.setOnErrorhandler(BridgeError)
        tempBridge.setOnBridgeDataHandler(BridgeData)
    except PhidgetException as e:
        print("Phidget Exception %i: %s" % (e.code, e.details))
        print("Exiting....")
        exit(1)

    try: