From 2e95e3a33bcb34aeec66551503c692c1cb80ab61 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Mon, 9 Feb 2009 20:05:30 +0100 Subject: * all python: - changed tabs to spaces. --- digital/asserv/tools/inter_asserv.py | 126 +++++++++++++++++------------------ 1 file changed, 63 insertions(+), 63 deletions(-) (limited to 'digital/asserv/tools/inter_asserv.py') diff --git a/digital/asserv/tools/inter_asserv.py b/digital/asserv/tools/inter_asserv.py index 44fb8492..1dd47fc3 100644 --- a/digital/asserv/tools/inter_asserv.py +++ b/digital/asserv/tools/inter_asserv.py @@ -40,86 +40,86 @@ class InterAsserv (Inter): """Inter, communicating with the asserv board.""" def __init__ (self, argv): - # Asserv. - if argv[0] == '!': - io = proto.popen_io.PopenIO (argv[1:]) - i = asserv.init.host - else: - io = serial.Serial (argv[0]) - i = asserv.init.target - self.a = Asserv (io, **i) - self.a.async = True - self.a.register_pos (self.pos) - # Inter. - Inter.__init__ (self) - self.tk.createfilehandler (self.a, READABLE, self.read) - self.timeout () + # Asserv. + if argv[0] == '!': + io = proto.popen_io.PopenIO (argv[1:]) + i = asserv.init.host + else: + io = serial.Serial (argv[0]) + i = asserv.init.target + self.a = Asserv (io, **i) + self.a.async = True + self.a.register_pos (self.pos) + # Inter. + Inter.__init__ (self) + self.tk.createfilehandler (self.a, READABLE, self.read) + self.timeout () def createWidgets (self): - Inter.createWidgets (self) - self.ArggButton = Button (self.rightFrame, text = 'Argggg!', - command = self.emergency_stop) - self.ArggButton.pack () - self.actionVar = StringVar () - self.actionVar.set ('goto') - self.actionSetPosButton = Radiobutton (self.rightFrame, - text = 'set pos', value = 'set_pos', - variable = self.actionVar) - self.actionSetPosButton.pack () - self.actionGotoButton = Radiobutton (self.rightFrame, - text = 'goto', value = 'goto', - variable = self.actionVar) - self.actionGotoButton.pack () - self.backwardOkVar = IntVar () - self.backwardOkButton = Checkbutton (self.rightFrame, - text = 'backward ok', variable = self.backwardOkVar) - self.backwardOkButton.pack () + Inter.createWidgets (self) + self.ArggButton = Button (self.rightFrame, text = 'Argggg!', + command = self.emergency_stop) + self.ArggButton.pack () + self.actionVar = StringVar () + self.actionVar.set ('goto') + self.actionSetPosButton = Radiobutton (self.rightFrame, + text = 'set pos', value = 'set_pos', + variable = self.actionVar) + self.actionSetPosButton.pack () + self.actionGotoButton = Radiobutton (self.rightFrame, + text = 'goto', value = 'goto', + variable = self.actionVar) + self.actionGotoButton.pack () + self.backwardOkVar = IntVar () + self.backwardOkButton = Checkbutton (self.rightFrame, + text = 'backward ok', variable = self.backwardOkVar) + self.backwardOkButton.pack () - self.tableview.configure (cursor = 'crosshair') - self.tableview.bind ('<1>', self.button1) - self.tableview.bind ('<3>', self.button3) + self.tableview.configure (cursor = 'crosshair') + self.tableview.bind ('<1>', self.button1) + self.tableview.bind ('<3>', self.button3) def read (self, file, mask): - """Handle asserv events.""" - self.a.proto.read () - self.a.proto.sync () + """Handle asserv events.""" + self.a.proto.read () + self.a.proto.sync () def timeout (self): - self.a.proto.sync () - self.after (100, self.timeout) + self.a.proto.sync () + self.after (100, self.timeout) def pos (self, x, y, a): - self.tableview.robot.pos = (x, y) - self.tableview.robot.angle = float (a) / 180 * math.pi - self.update (self.tableview.robot) - self.update () + self.tableview.robot.pos = (x, y) + self.tableview.robot.angle = float (a) / 180 * math.pi + self.update (self.tableview.robot) + self.update () def button1 (self, ev): - x, y = self.tableview.screen_coord ((ev.x, ev.y)) - action = self.actionVar.get () - if action == 'set_pos': - self.a.set_pos (x, y) - elif action == 'goto': - self.a.goto (x, y, self.backwardOkVar.get ()) - else: - assert 0 + x, y = self.tableview.screen_coord ((ev.x, ev.y)) + action = self.actionVar.get () + if action == 'set_pos': + self.a.set_pos (x, y) + elif action == 'goto': + self.a.goto (x, y, self.backwardOkVar.get ()) + else: + assert 0 def button3 (self, ev): - x, y = self.tableview.screen_coord ((ev.x, ev.y)) - a = math.degrees (math.atan2 (y - self.tableview.robot.pos[1], - x - self.tableview.robot.pos[0])) - action = self.actionVar.get () - if action == 'set_pos': - self.a.set_pos (a = a) - elif action == 'goto': - self.a.goto_angle (a) + x, y = self.tableview.screen_coord ((ev.x, ev.y)) + a = math.degrees (math.atan2 (y - self.tableview.robot.pos[1], + x - self.tableview.robot.pos[0])) + action = self.actionVar.get () + if action == 'set_pos': + self.a.set_pos (a = a) + elif action == 'goto': + self.a.goto_angle (a) def emergency_stop (self): - self.a.free () + self.a.free () if __name__ == '__main__': app = InterAsserv (sys.argv[1:]) try: - app.mainloop () + app.mainloop () finally: - app.a.close () + app.a.close () -- cgit v1.2.3