From 92f16f4042175efa642ee8499acb797d410afc76 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Sat, 20 Apr 2013 12:27:49 +0200 Subject: digital/io-hub/tools: add graphs --- digital/io-hub/tools/io_hub/io_hub.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'digital/io-hub/tools/io_hub') diff --git a/digital/io-hub/tools/io_hub/io_hub.py b/digital/io-hub/tools/io_hub/io_hub.py index cd954648..04df1440 100644 --- a/digital/io-hub/tools/io_hub/io_hub.py +++ b/digital/io-hub/tools/io_hub/io_hub.py @@ -27,12 +27,32 @@ __all__ = [ 'Proto', 'ProtoRobospierre', 'ProtoGuybrush' ] class Proto: + stats_items = { + 'pressure': ('F', 'H'), + 'us': ('U', 'hhhh'), + 'cake': ('G', 'hh'), + } + def __init__ (self, file, time = time.time, **param): self.proto = proto.Proto (file, time, 0.1) self.async = False self.param = param + self.stats_callback = None + def make_handler (stat): + def handler (*values): + if self.stats_callback: + self.stats_callback (stat, *values) + return handler + for stat, cmd in self.stats_items.iteritems (): + self.proto.register (cmd[0], cmd[1], make_handler (stat)) self.send_param () + def register_stats (self, stats_callback): + self.stats_callback = stats_callback + + def stats (self, stat, interval): + self.proto.send (self.stats_items[stat][0], 'B', interval) + def send_param (self): pass -- cgit v1.2.3