import time import sys import os # Time increment and timeout, seconds TIME_INCR = 0.1 TIMEOUT = 10.0 # # connect to LinuxCNC # c = linuxcnc.command() s = linuxcnc.stat() e = linuxcnc.error_channel() l = linuxcnc_util.LinuxCNC(command=c, status=s, error=e) # # Create and connect test feedback comp # h = hal.component("test-ui") h.newpin("Xpos", hal.HAL_FLOAT, hal.HAL_IN) h.newpin("Ypos", hal.HAL_FLOAT, hal.HAL_IN) h.ready() os.system("halcmd source ./postgui.hal") # # Come out of E-stop, turn the machine on, home #
h.newpin("tool-changed", hal.HAL_BIT, hal.HAL_OUT) h["tool-changed"] = False h.newpin("tool-prepare", hal.HAL_BIT, hal.HAL_IN) h.newpin("tool-prepared", hal.HAL_BIT, hal.HAL_OUT) h["tool-prepared"] = False h.newpin("tool-number", hal.HAL_S32, hal.HAL_IN) h.newpin("tool-prep-number", hal.HAL_S32, hal.HAL_IN) h.newpin("tool-prep-pocket", hal.HAL_S32, hal.HAL_IN) h.ready() os.system("halcmd source ./postgui.hal") l = linuxcnc_util.LinuxCNC() # Wait for LinuxCNC to initialize itself so the Status buffer stabilizes. l.wait_for_linuxcnc_startup() c.state(linuxcnc.STATE_ESTOP_RESET) c.state(linuxcnc.STATE_ON) c.home(-1) c.wait_complete() c.mode(linuxcnc.MODE_MDI) # # At startup tool 3 is in the spindle and no tool prep or change is # being requested. #