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
print("Opening Dictionary object....") try: dictionary.openRemoteIP("adam.local", 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) try: print("Now we'll add some keys...") sleep(1) dictionary.addKey("test1", "ok") dictionary.addKey("test2", "ok", True) dictionary.addKey("test3", "ok", False) dictionary.addKey("test4", "ok", True) sleep(2)
print("Opening Dictionary object....") try: dictionary.openRemoteIP("localhost", 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) # Set revolving values try: print("Now we'll add some keys...") sleep(1) ai1, ai2, ai3, dev_state = 0, 0, 0, True dictionary.addKey("ai1", str(ai1)) dictionary.addKey("ai2", str(ai2)) dictionary.addKey("ai3", str(ai3)) dictionary.addKey("dev_state", str(dev_state)) print("got here")