summaryrefslogtreecommitdiffhomepage
path: root/digital/io/tools
diff options
context:
space:
mode:
Diffstat (limited to 'digital/io/tools')
-rw-r--r--digital/io/tools/io/init.py8
-rw-r--r--digital/io/tools/io/io.py40
-rw-r--r--digital/io/tools/test_simu.py76
3 files changed, 62 insertions, 62 deletions
diff --git a/digital/io/tools/io/init.py b/digital/io/tools/io/init.py
index 12c6bb9a..7b8d2b8a 100644
--- a/digital/io/tools/io/init.py
+++ b/digital/io/tools/io/init.py
@@ -1,6 +1,6 @@
"""Default parameters for io."""
host = dict (
- trap = ((1, 255), (1, 255), (1, 255), (1, 255), (1, 255), (1, 255)),
- sharp_threshold = ((0x7f, 0x90), (0x7f, 0x90), (0x7f, 0x90),
- (0x7f, 0x90), (0x7f, 0x90)),
- )
+ trap = ((1, 255), (1, 255), (1, 255), (1, 255), (1, 255), (1, 255)),
+ sharp_threshold = ((0x7f, 0x90), (0x7f, 0x90), (0x7f, 0x90),
+ (0x7f, 0x90), (0x7f, 0x90)),
+ )
diff --git a/digital/io/tools/io/io.py b/digital/io/tools/io/io.py
index 8b78a8cc..5d2826a1 100644
--- a/digital/io/tools/io/io.py
+++ b/digital/io/tools/io/io.py
@@ -3,34 +3,34 @@ import proto, time
class Io:
def __init__ (self, file, time = time.time, **param):
- self.proto = proto.Proto (file, time, 0.1)
- self.async = False
- self.param = param
- self.send_param ()
+ self.proto = proto.Proto (file, time, 0.1)
+ self.async = False
+ self.param = param
+ self.send_param ()
def send_param (self):
- p = self.param
- for i, t in enumerate (p['trap']):
- self.proto.send ('t', 'BBB', i, t[0], t[1])
- for i, t in enumerate (p['sharp_threshold']):
- self.proto.send ('h', 'BHH', i, t[0], t[1])
+ p = self.param
+ for i, t in enumerate (p['trap']):
+ self.proto.send ('t', 'BBB', i, t[0], t[1])
+ for i, t in enumerate (p['sharp_threshold']):
+ self.proto.send ('h', 'BHH', i, t[0], t[1])
def write_eeprom (self):
- self.proto.send ('p', 'BB', ord ('E'), ord ('s'))
- time.sleep (1)
- self.proto.wait (lambda: True)
+ self.proto.send ('p', 'BB', ord ('E'), ord ('s'))
+ time.sleep (1)
+ self.proto.wait (lambda: True)
def reset (self):
- self.proto.send ('w')
- self.proto.send ('w', 'H', 0)
- self.proto.send ('z')
- self.proto.send ('z')
+ self.proto.send ('w')
+ self.proto.send ('w', 'H', 0)
+ self.proto.send ('z')
+ self.proto.send ('z')
def close (self):
- self.reset ()
- self.wait (lambda: True)
- self.proto.file.close ()
+ self.reset ()
+ self.wait (lambda: True)
+ self.proto.file.close ()
def fileno (self):
- return self.proto.fileno ()
+ return self.proto.fileno ()
diff --git a/digital/io/tools/test_simu.py b/digital/io/tools/test_simu.py
index 7f208911..1d7175a7 100644
--- a/digital/io/tools/test_simu.py
+++ b/digital/io/tools/test_simu.py
@@ -18,58 +18,58 @@ class TestSimu (InterNode):
"""Inter, with simulated programs."""
robot_start_pos = ((200, 2100 - 70, -90),
- (3000 - 200, 2100 - 70, -90))
+ (3000 - 200, 2100 - 70, -90))
def __init__ (self, asserv_cmd, io_cmd):
- # Hub.
- self.hub = mex.hub.Hub (min_clients = 2)
- self.forked_hub = utils.forked.Forked (self.hub.wait)
- # InterNode.
- InterNode.__init__ (self)
- def time ():
- return self.node.date / self.TICK
- # Asserv.
- self.asserv = Asserv (PopenIO (asserv_cmd), time, **asserv.init.host)
- self.asserv.async = True
- self.tk.createfilehandler (self.asserv, READABLE, self.asserv_read)
- # Io.
- self.io = Io (PopenIO (io_cmd), time, **io.init.host)
- self.io.async = True
- self.tk.createfilehandler (self.io, READABLE, self.io_read)
- # Color switch.
- self.change_color ()
- self.colorVar.trace_variable ('w', self.change_color)
+ # Hub.
+ self.hub = mex.hub.Hub (min_clients = 2)
+ self.forked_hub = utils.forked.Forked (self.hub.wait)
+ # InterNode.
+ InterNode.__init__ (self)
+ def time ():
+ return self.node.date / self.TICK
+ # Asserv.
+ self.asserv = Asserv (PopenIO (asserv_cmd), time, **asserv.init.host)
+ self.asserv.async = True
+ self.tk.createfilehandler (self.asserv, READABLE, self.asserv_read)
+ # Io.
+ self.io = Io (PopenIO (io_cmd), time, **io.init.host)
+ self.io.async = True
+ self.tk.createfilehandler (self.io, READABLE, self.io_read)
+ # Color switch.
+ self.change_color ()
+ self.colorVar.trace_variable ('w', self.change_color)
def close (self):
- self.forked_hub.kill ()
- import time
- time.sleep (1)
- self.asserv.close ()
- self.io.close ()
+ self.forked_hub.kill ()
+ import time
+ time.sleep (1)
+ self.asserv.close ()
+ self.io.close ()
def asserv_read (self, file, mask):
- self.asserv.proto.read ()
- self.asserv.proto.sync ()
+ self.asserv.proto.read ()
+ self.asserv.proto.sync ()
def io_read (self, file, mask):
- self.io.proto.read ()
- self.io.proto.sync ()
+ self.io.proto.read ()
+ self.io.proto.sync ()
def step (self):
- """Overide step to handle retransmissions, could be made cleaner using
- simulated time."""
- InterNode.step (self)
- self.asserv.proto.sync ()
- self.io.proto.sync ()
+ """Overide step to handle retransmissions, could be made cleaner using
+ simulated time."""
+ InterNode.step (self)
+ self.asserv.proto.sync ()
+ self.io.proto.sync ()
def change_color (self, *dummy):
- i = self.colorVar.get ()
- self.asserv.set_simu_pos (*self.robot_start_pos[i]);
+ i = self.colorVar.get ()
+ self.asserv.set_simu_pos (*self.robot_start_pos[i]);
if __name__ == '__main__':
app = TestSimu (('../../asserv/src/asserv/asserv.host', '-m', 'giboulee'),
- ('../src/io.host'))
+ ('../src/io.host'))
try:
- app.mainloop ()
+ app.mainloop ()
finally:
- app.close ()
+ app.close ()