__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() except PhidgetException as e:
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() pass
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:
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: