diff --git a/doc/devices_classes_branch.txt b/doc/devices_classes_branch.txt index 835d0d9..16d6d36 100644 --- a/doc/devices_classes_branch.txt +++ b/doc/devices_classes_branch.txt @@ -212,7 +212,7 @@ KVS implementation completed and all tests pass Registry tests all complete receive sequence counter tested -setup_tool implemented ready for testing to start +setup_tool implemented and tested in simulation -------------------------------------------------------------------------------- @@ -220,10 +220,8 @@ ---- DEMO APPS PHASE 1 -write: setup_tool.py - -fix or deprecate, depending on what setup_tool does, -also depending on what we want to show as a standalone app +For each of these, rewrite it in the assumption that you use setup_tool +to configure the system. fix: control_legacy.py fix: control_mihome.py @@ -241,15 +239,19 @@ * add back in the loop() call in the monitor_mihome.py program + ---- DEMO APPS PHASE 2 -setup_tool.py +(might do these after merge to master) + mihome_energy_monitor.py games_console_minder.py ---- EVENT HANDLERS ON DEVICES (later) +(might do this as an improvement branch after merge to master) + (add this as an issue of 'ideas for devices') Need to get the core code out there, and improve it later diff --git a/src/energenie/Devices.py b/src/energenie/Devices.py index da66813..ca457a7 100644 --- a/src/energenie/Devices.py +++ b/src/energenie/Devices.py @@ -69,7 +69,7 @@ #TODO: This might be deprecated now, and replaced with the DeviceFactory? #Still used in deprecated methods in Registry.py -@deprecated +@unimplemented # no longer supported def getDescription(mfrid, productid): if mfrid == MFRID_ENERGENIE: mfr = "Energenie" @@ -94,7 +94,7 @@ #e.g. if there is a turn_on method or get_switch method, it has a switch. #still used in switch.py demo (will be until device classes deployed into tests) -@deprecated +@unimplemented # no longer supported def hasSwitch(mfrid, productid): if mfrid != MFRID: return False if productid == PRODUCTID_MIHO005: return True @@ -354,18 +354,35 @@ """An estimate of the next time we expect a message from this device""" pass - @unimplemented def get_readings_summary(self): """Try to get a terse summary of all present readings""" - # if self.readings does not exist - # return "no readings" - # + + try: + r = self.readings + except AttributeError: + return "(no readings)" + + def shortname(name): + parts = name.split('_') + sn = "" + for p in parts: + sn += p[0].upper() + return sn + + + line = "" + for rname in dir(self.readings): + if not rname.startswith("__"): + value = getattr(self.readings, rname) + line += "%s:%s " % (shortname(rname), str(value)) + + return line + # for each reading # call get_x to get the reading # think of a very short name, perhaps first letter of reading name? # add it to a terse string # return the string - return "no readings (yet - TODO)" def get_receive_count(self): return self.rxseq diff --git a/src/energenie/OpenThings.py b/src/energenie/OpenThings.py index 5b27efe..8311433 100644 --- a/src/energenie/OpenThings.py +++ b/src/energenie/OpenThings.py @@ -689,7 +689,6 @@ value["paramid"] = key self.pydict["recs"].append(value) - @untested def copyof(self): # -> Message """Clone, to create a new message that is a completely independent copy""" import copy diff --git a/src/energenie/Registry.py b/src/energenie/Registry.py index 6bbeda4..138d57f 100644 --- a/src/energenie/Registry.py +++ b/src/energenie/Registry.py @@ -21,7 +21,7 @@ directory = {} -@deprecated +@unimplemented # no longer supported def allkeys(d): result = "" for k in d: @@ -31,7 +31,7 @@ return result -@deprecated +@unimplemented # no longer supported def update(message): """Update the local directory with information about this device""" now = time.time() @@ -50,17 +50,17 @@ #not as a list index, else merging will be hard. -@deprecated +@unimplemented # no longer supported def size(): return len(directory) -@deprecated +@unimplemented # no longer supported def get_sensorids(): return directory.keys() -@deprecated +@unimplemented # no longer supported def get_info(sensor_id): return directory[sensor_id] @@ -88,17 +88,6 @@ self.store = KVS(filename) #TODO: later we might make it possible to load_from multiple files self.store.load(filename, Devices.DeviceFactory.get_device_from_name) - @unimplemented - def reload(self): - pass #TODO: reload from the persisted version - #TODO: need to know what file it was previously loaded from - #TODO: What about existing receive routes?? - - @untested - def rewrite(self): - """Rewrite the persisted version from the in memory version""" - self.store.rewrite() - def load_into(self, context): """auto-create variables in the provided context, for all persisted registry entries""" if context == None: @@ -124,7 +113,6 @@ fsk_router.add(address, c) return c - @untested def rename(self, old_name, new_name): """Rename a device in the registry""" c = self.store[old_name] # get the class instance @@ -423,7 +411,7 @@ def ask(address, message): - MSG = "Do you want to register to device: %s" % str(address) + MSG = "Do you want to register to device: %s? " % str(address) try: y = raw_input(MSG) except AttributeError: diff --git a/src/energenie/lifecycle.py b/src/energenie/lifecycle.py index a3d032a..bb6564f 100644 --- a/src/energenie/lifecycle.py +++ b/src/energenie/lifecycle.py @@ -3,7 +3,7 @@ # Coding lifecycle method decorators. def unimplemented(m): - print("warning: unimplemented method %s" % str(m)) + ##print("warning: unimplemented method %s" % str(m)) def inner(*args, **kwargs): raise RuntimeError("Method is unimplemented: %s" % str(m)) return inner diff --git a/src/setup_tool.py b/src/setup_tool.py index 3dd1bb3..4ad18b0 100644 --- a/src/setup_tool.py +++ b/src/setup_tool.py @@ -10,7 +10,7 @@ import time import energenie -from energenie.lifecycle import * +##from energenie.lifecycle import * #===== GLOBALS ===== @@ -31,7 +31,7 @@ while True: try: - hc = readin("House code? (ENTER for default) ") + hc = readin("House code (ENTER for default)? ") if hc == "": return None except KeyboardInterrupt: @@ -50,7 +50,7 @@ while True: try: - di = readin("Device index 1..4? (ENTER for all)") + di = readin("Device index 1..4 (ENTER for all)? ") except KeyboardInterrupt: return None # user abort @@ -81,7 +81,7 @@ try: while True: - i = readin("Which device %s to %s" % (1,len(names))) + i = readin("Which device %s to %s? " % (1,len(names))) try: device_index = int(i) break # got it @@ -108,6 +108,7 @@ device = energenie.Devices.ENER002((house_code, device_index)) # in a loop until Ctrl-C + print("Legacy learn broadcasting, Ctrl-C to stop") try: while True: print("ON") @@ -139,6 +140,7 @@ def do_list_registry(): """List the entries in the registry""" + print("REGISTRY:") show_registry() @@ -175,7 +177,6 @@ quit = False -@untested def do_show_device_status(): """Show the readings associated with a device""" @@ -186,13 +187,14 @@ print(readings) -@untested def do_watch_devices(): """Repeatedly show readings for all devices""" + print("Watching devices, Ctrl-C to stop") try: while True: energenie.loop() # allow receive processing + print('-' * 80) names = energenie.registry.names() for name in names: @@ -206,28 +208,33 @@ pass # user exit -@untested def do_rename_device(): """Rename a device in the registry to a different name""" # This is useful when turning auto discovered names into your own names old_name = get_device_name() - new_name = readin("New name?") + if old_name == None: return # user abort + + try: + new_name = readin("New name? ") + except KeyboardInterrupt: + return # user abort energenie.registry.rename(old_name, new_name) + print("Renamed OK") -@untested def do_delete_device(): """Delete a device from the registry so it is no longer recognised""" name = get_device_name() + if name == None: return #user abort energenie.registry.delete(name) + print("Deleted OK") -@untested def do_logging(): """Enter a mode where all communications are logged to screen and a file""" @@ -240,6 +247,7 @@ Logger.logMessage(message) energenie.fsk_router.when_incoming(incoming) + print("Logging enabled, Ctrl-C to stop") try: while True: energenie.loop() @@ -276,7 +284,7 @@ last = choices[1] try: while True: - choice = readin("Choose %d to %d?" % (first, last)) + choice = readin("Choose %d to %d? " % (first, last)) try: choice = int(choice) if choice < first or choice > last: @@ -315,10 +323,11 @@ """The main program loop""" while not quit: - print("MAIN MENU") + print("\nMAIN MENU") show_menu(MAIN_MENU) choice = get_choice((1,len(MAIN_MENU))) if not quit: + print("\n") handle_choice(MAIN_MENU, choice)