From 0443ae6a587e083db400c25e52c9a2fff3d1a582 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Mon, 26 Mar 2012 00:56:16 +0200 Subject: digital/io-hub: add support for several robots --- digital/io-hub/tools/io_hub/io_hub.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'digital/io-hub/tools/io_hub/io_hub.py') diff --git a/digital/io-hub/tools/io_hub/io_hub.py b/digital/io-hub/tools/io_hub/io_hub.py index 06d237e9..bf038cf2 100644 --- a/digital/io-hub/tools/io_hub/io_hub.py +++ b/digital/io-hub/tools/io_hub/io_hub.py @@ -23,6 +23,8 @@ # }}} import proto, time +__all__ = [ 'Proto', 'ProtoRobospierre' ] + class Proto: def __init__ (self, file, time = time.time, **param): @@ -47,6 +49,16 @@ class Proto: def goto (self, x, y, backward): self.proto.send ('m', 'hhB', x, y, backward) + def close (self): + self.reset () + self.proto.wait (lambda: True) + self.proto.file.close () + + def fileno (self): + return self.proto.fileno () + +class ProtoRobospierre (Proto): + def clamp_move (self, pos): self.proto.send ('c', 'B', pos) @@ -69,11 +81,4 @@ class Proto: def clamp_openclose (self, open_): self.proto.send ('d', 'BB', 0xff, (0, 1)[open_]) - def close (self): - self.reset () - self.proto.wait (lambda: True) - self.proto.file.close () - - def fileno (self): - return self.proto.fileno () -- cgit v1.2.3