__author__ = 'Adam Stelmack' __version__ = '2.1.8' __date__ = 'July 14 2010' #Basic imports from ctypes import * import sys from time import sleep #Phidget specific imports from Phidgets.PhidgetException import PhidgetErrorCodes, PhidgetException from Phidgets.Events.Events import ErrorEventArgs, KeyChangeEventArgs, ServerConnectArgs, ServerDisconnectArgs from Phidgets.Dictionary import Dictionary, DictionaryKeyChangeReason, KeyListener #Create a Dictionary object and a key listener object try: dictionary = Dictionary() keyListener = KeyListener(dictionary, ".*") except RuntimeError as e: print("Runtime Exception: %s" % e.details) print("Exiting....") exit(1) #Event Handler Callback Functions def DictionaryError(e): print("Dictionary Error %i: %s" % (e.eCode, e.description)) return 0 def DictionaryServerConnected(e): print("Dictionary connected to server %s" % (e.device.getServerAddress())) try: keyListener.start()
#Basic imports import random import sys from ctypes import * from time import sleep #Phidget specific imports from Phidgets.PhidgetException import PhidgetErrorCodes, PhidgetException from Phidgets.Events.Events import ErrorEventArgs, KeyChangeEventArgs, \ ServerConnectArgs, ServerDisconnectArgs from Phidgets.Dictionary import Dictionary, DictionaryKeyChangeReason, \ KeyListener #Create a Dictionary object and a key listener object try: dictionary = Dictionary() keyListener = KeyListener(dictionary, ".*") except RuntimeError as e: print("Runtime Exception: %s" % e.details) print("Exiting....") exit(1) #Event Handler Callback Functions def DictionaryError(e): print("Dictionary Error %i: %s" % (e.eCode, e.description)) return 0 def DictionaryServerConnected(e): print("Dictionary connected to server %s" % (e.device.getServerAddress()))
# commander setup # ################### def capture_commands(e): key = e.key if '_on' in key or '_off' in key or 'LATCH' == key: cdict[key] = e.value ################## # Phidgets setup # ################## #Create a Dictionary object and a key listener object try: dictionary = Dictionary() keyListener = KeyListener(dictionary, "\/*") except RuntimeError as e: print("Runtime Exception: %s" % e.details) print("Exiting....") exit(1) #Event Handler Callback Functions def DictionaryError(e): print("Dictionary Error %i: %s" % (e.eCode, e.description)) return 0 def DictionaryServerConnected(e): print("Dictionary connected to server %s" % (e.device.getServerAddress())) try: keyListener.start()
#Basic imports import random import sys from ctypes import * from time import sleep #Phidget specific imports from Phidgets.PhidgetException import PhidgetErrorCodes, PhidgetException from Phidgets.Events.Events import ErrorEventArgs, KeyChangeEventArgs, \ ServerConnectArgs, ServerDisconnectArgs from Phidgets.Dictionary import Dictionary, DictionaryKeyChangeReason, \ KeyListener #Create a Dictionary object and a key listener object try: dictionary = Dictionary() keyListener = KeyListener(dictionary, ".*") except RuntimeError as e: print("Runtime Exception: %s" % e.details) print("Exiting....") exit(1) #Event Handler Callback Functions def DictionaryError(e): print("Dictionary Error %i: %s" % (e.eCode, e.description)) return 0 def DictionaryServerConnected(e): print("Dictionary connected to server %s" % (e.device.getServerAddress())) try: keyListener.start()
__version__ = '2.1.8' __date__ = 'July 14 2010' #Basic imports from ctypes import * import sys from time import sleep #Phidget specific imports from Phidgets.PhidgetException import PhidgetErrorCodes, PhidgetException from Phidgets.Events.Events import ErrorEventArgs, KeyChangeEventArgs, ServerConnectArgs, ServerDisconnectArgs from Phidgets.Dictionary import Dictionary, DictionaryKeyChangeReason, KeyListener from Phidgets.Phidget import PhidgetLogLevel #Create a Dictionary object and a key listener object try: dictionary = Dictionary() keyListener = KeyListener(dictionary, ".*") except RuntimeError as e: print("Runtime Exception: %s" % e.details) print("Exiting....") exit(1) #Event Handler Callback Functions def DictionaryError(e): print("Dictionary Error %i: %s" % (e.eCode, e.description)) return 0 def DictionaryServerConnected(e): print("Dictionary connected to server %s" % (e.device.getServerAddress()))
def setup_ph_dict(): #Create a Dictionary object and a key listener object try: dictionary = Dictionary() except RuntimeError as e: print("Runtime Exception: %s" % e.details) print("Exiting....") exit(1) try: dictionary.setErrorHandler(DictionaryError) dictionary.setServerConnectHandler(DictionaryServerConnected) dictionary.setServerDisconnectHandler(DictionaryServerDisconnected) except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) print("Exiting....") exit(1) print("Opening phidget object....") try: dictionary.openRemoteIP('localhost', port=5001) except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) print("Exiting....") exit(1) try: while dictionary.isAttachedToServer() == False: pass else: print("Connected: %s" % (dictionary.isAttachedToServer())) print("Server: %s:%s" % (dictionary.getServerAddress(), dictionary.getServerPort())) except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) print("Exiting....") exit(1) return dictionary
def setup_ph_dict(): #Create a Dictionary object and a key listener object try: dictionary = Dictionary() except RuntimeError as e: print("Runtime Exception: %s" % e.details) print("Exiting....") exit(1) try: dictionary.setErrorHandler(DictionaryError) dictionary.setServerConnectHandler(DictionaryServerConnected) dictionary.setServerDisconnectHandler(DictionaryServerDisconnected) except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) print("Exiting....") exit(1) print("Opening phidget object....") try: dictionary.openRemoteIP(LTCIP, port=5001) except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) print("Exiting....") exit(1) try: while dictionary.isAttachedToServer() == False: pass else: print("Connected: %s" % (dictionary.isAttachedToServer())) print("Server: %s:%s" % (dictionary.getServerAddress(), dictionary.getServerPort())) except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) print("Exiting....") exit(1) return dictionary
from time import sleep #Phidget specific imports from Phidgets.PhidgetException import PhidgetErrorCodes, PhidgetException from Phidgets.Events.Events import ErrorEventArgs, KeyChangeEventArgs, ServerConnectArgs, ServerDisconnectArgs from Phidgets.Dictionary import Dictionary, DictionaryKeyChangeReason, KeyListener IP = "localhost" ################## # Phidgets setup # ################## #Create a Dictionary object and a key listener object try: dictionary = Dictionary() keyListener = KeyListener(dictionary, "\/*") except RuntimeError as e: print("Runtime Exception: %s" % e.details) print("Exiting....") exit(1) #Event Handler Callback Functions def DictionaryError(e): print("Dictionary Error %i: %s" % (e.eCode, e.description)) return 0 def DictionaryServerConnected(e): print("Dictionary connected to server %s" % (e.device.getServerAddress())) try: keyListener.start()
################### def capture_commands(e): key = e.key if '_on' in key or '_off' in key or 'LATCH' == key: cdict[key] = e.value ################## # Phidgets setup # ################## #Create a Dictionary object and a key listener object try: dictionary = Dictionary() keyListener = KeyListener(dictionary, "\/*") except RuntimeError as e: print("Runtime Exception: %s" % e.details) print("Exiting....") exit(1) #Event Handler Callback Functions def DictionaryError(e): print("Dictionary Error %i: %s" % (e.eCode, e.description)) return 0 def DictionaryServerConnected(e): print("Dictionary connected to server %s" % (e.device.getServerAddress()))
from time import sleep #Phidget specific imports from Phidgets.PhidgetException import PhidgetErrorCodes, PhidgetException from Phidgets.Events.Events import ErrorEventArgs, KeyChangeEventArgs, ServerConnectArgs, ServerDisconnectArgs from Phidgets.Dictionary import Dictionary, DictionaryKeyChangeReason, KeyListener IP = "localhost" ################## # Phidgets setup # ################## #Create a Dictionary object and a key listener object try: dictionary = Dictionary() keyListener = KeyListener(dictionary, "\/*") except RuntimeError as e: print("Runtime Exception: %s" % e.details) print("Exiting....") exit(1) #Event Handler Callback Functions def DictionaryError(e): print("Dictionary Error %i: %s" % (e.eCode, e.description)) return 0 def DictionaryServerConnected(e): print("Dictionary connected to server %s" % (e.device.getServerAddress()))