#!/usr/bin/python """Usage: python teachin.py You must ". scripts/emc-environment" before running this script, if you use run-in-place. """ # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import hal import sys import linuxcnc s = linuxcnc.stat() def get_cart(): s.poll() position = " ".join(["%-8.4f"] * s.axes) return position % s.position[:s.axes] def get_joint(): s.poll() position = " ".join(["%-8.4f"] * s.axes) return position % s.joint_actual_position[:s.axes] h = hal.component("memorizador") h.newpin ("memorizar", hal.HAL_BIT, hal.HAL_IN) outfile = "Memorizado.txt" h.ready() try: while 1: if h["memorizar"] == 1: f = open(outfile, 'a') pos = get_cart() pos = pos + '\n' f.write(pos) f.close() except KeyboardIntrrupt: raise SystemExit