Import LinuxCNC source tree
This commit is contained in:
1
tests/toolchanger/reload-tool/random/checkresult
Symbolic link
1
tests/toolchanger/reload-tool/random/checkresult
Symbolic link
@@ -0,0 +1 @@
|
||||
../checkresult
|
||||
1
tests/toolchanger/reload-tool/random/core_sim.hal
Symbolic link
1
tests/toolchanger/reload-tool/random/core_sim.hal
Symbolic link
@@ -0,0 +1 @@
|
||||
../core_sim.hal
|
||||
1
tests/toolchanger/reload-tool/random/postgui.hal
Symbolic link
1
tests/toolchanger/reload-tool/random/postgui.hal
Symbolic link
@@ -0,0 +1 @@
|
||||
../postgui.hal
|
||||
334
tests/toolchanger/reload-tool/random/test-ui.py
Executable file
334
tests/toolchanger/reload-tool/random/test-ui.py
Executable file
@@ -0,0 +1,334 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import linuxcnc
|
||||
import linuxcnc_util
|
||||
import hal
|
||||
|
||||
import math
|
||||
import time
|
||||
import sys
|
||||
import subprocess
|
||||
import os
|
||||
import signal
|
||||
import glob
|
||||
import re
|
||||
|
||||
xtool = 0.111 # [EMCIO]TOOL_CHANGE_POSITION x
|
||||
ytool = 0.222 # [EMCIO]TOOL_CHANGE_POSITION y
|
||||
ztool = 0.333 # [EMCIO]TOOL_CHANGE_POSITION z
|
||||
EPSILON = 1e-10
|
||||
|
||||
def wait_for_hal_pin(name, value, timeout=10):
|
||||
start_time = time.time()
|
||||
while (time.time() - start_time) < timeout:
|
||||
if h[name] == value:
|
||||
return
|
||||
time.sleep(0.1)
|
||||
raise RuntimeError("hal pin %s didn't get to %s after %.3f seconds" % (name, value, timeout))
|
||||
|
||||
|
||||
# After doing something that should change the stat buffer, wait this
|
||||
# long before polling to let the change propagate through.
|
||||
# FIXME: this is bogus
|
||||
stat_poll_wait = 0.100
|
||||
|
||||
|
||||
c = linuxcnc.command()
|
||||
s = linuxcnc.stat()
|
||||
e = linuxcnc.error_channel()
|
||||
|
||||
h = hal.component("test-ui")
|
||||
|
||||
h.newpin("tool-change", hal.HAL_BIT, hal.HAL_IN)
|
||||
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.newpin("tool-from-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.
|
||||
#
|
||||
|
||||
assert(h['tool-change'] == False)
|
||||
assert(h['tool-prepare'] == False)
|
||||
assert(h['tool-number'] == 3)
|
||||
assert(h['tool-prep-number'] == 0)
|
||||
assert(h['tool-prep-pocket'] == 0)
|
||||
assert(h['tool-from-pocket'] == 0)
|
||||
|
||||
s.poll()
|
||||
assert(s.tool_in_spindle == 3)
|
||||
assert(s.tool_from_pocket == 0)
|
||||
assert(s.pocket_prepped == -1)
|
||||
|
||||
|
||||
#
|
||||
# Prepare T2
|
||||
#
|
||||
|
||||
c.mdi('t2')
|
||||
wait_for_hal_pin('tool-prepare', True)
|
||||
|
||||
assert(h['tool-change'] == False)
|
||||
assert(h['tool-prepare'] == True)
|
||||
assert(h['tool-number'] == 3)
|
||||
assert(h['tool-prep-number'] == 2)
|
||||
assert(h['tool-prep-pocket'] == 46)
|
||||
assert(h['tool-from-pocket'] == 0)
|
||||
|
||||
s.poll()
|
||||
assert(s.tool_in_spindle == 3)
|
||||
assert(s.tool_from_pocket == 0)
|
||||
assert(s.pocket_prepped == -1)
|
||||
|
||||
h['tool-prepared'] = True
|
||||
wait_for_hal_pin('tool-prepare', False)
|
||||
h['tool-prepared'] = False
|
||||
|
||||
assert(h['tool-change'] == False)
|
||||
assert(h['tool-prepare'] == False)
|
||||
assert(h['tool-number'] == 3)
|
||||
assert(h['tool-prep-number'] == 2)
|
||||
assert(h['tool-prep-pocket'] == 46)
|
||||
assert(h['tool-from-pocket'] == 0)
|
||||
|
||||
time.sleep(stat_poll_wait)
|
||||
s.poll()
|
||||
assert(s.tool_in_spindle == 3)
|
||||
assert(s.tool_from_pocket == 0)
|
||||
assert(s.pocket_prepped == 46) # random tc gives you pocket, which is the same as tool-table-array index
|
||||
|
||||
|
||||
#
|
||||
# Change to T2
|
||||
#
|
||||
|
||||
c.mdi('m6')
|
||||
wait_for_hal_pin('tool-change', True)
|
||||
|
||||
assert(h['tool-change'] == True)
|
||||
assert(h['tool-prepare'] == False)
|
||||
assert(h['tool-number'] == 3)
|
||||
assert(h['tool-prep-number'] == 2)
|
||||
assert(h['tool-prep-pocket'] == 46)
|
||||
assert(h['tool-from-pocket'] == 0)
|
||||
|
||||
time.sleep(stat_poll_wait)
|
||||
s.poll()
|
||||
assert(s.tool_in_spindle == 3)
|
||||
assert(s.tool_from_pocket == 0)
|
||||
assert(s.pocket_prepped == 46)
|
||||
|
||||
assert(abs(s.joint_position[0] -xtool) < EPSILON)
|
||||
assert(abs(s.joint_position[1] -ytool) < EPSILON)
|
||||
assert(abs(s.joint_position[2] -ztool) < EPSILON)
|
||||
|
||||
h['tool-changed'] = True
|
||||
wait_for_hal_pin('tool-change', False)
|
||||
h['tool-changed'] = False
|
||||
|
||||
assert(h['tool-change'] == False)
|
||||
assert(h['tool-prepare'] == False)
|
||||
assert(h['tool-number'] == 2)
|
||||
assert(h['tool-prep-number'] == 0)
|
||||
assert(h['tool-prep-pocket'] == 0)
|
||||
assert(h['tool-from-pocket'] == 46)
|
||||
|
||||
time.sleep(stat_poll_wait)
|
||||
s.poll()
|
||||
assert(s.tool_in_spindle == 2)
|
||||
assert(s.tool_from_pocket == 46)
|
||||
assert(s.pocket_prepped == -1)
|
||||
|
||||
|
||||
#
|
||||
# Prepare T12
|
||||
#
|
||||
|
||||
c.mdi('t12')
|
||||
wait_for_hal_pin('tool-prepare', True)
|
||||
|
||||
assert(h['tool-change'] == False)
|
||||
assert(h['tool-prepare'] == True)
|
||||
assert(h['tool-number'] == 2)
|
||||
assert(h['tool-prep-number'] == 12)
|
||||
assert(h['tool-prep-pocket'] == 9)
|
||||
assert(h['tool-from-pocket'] == 46)
|
||||
|
||||
time.sleep(stat_poll_wait)
|
||||
s.poll()
|
||||
assert(s.tool_in_spindle == 2)
|
||||
assert(s.tool_from_pocket == 46)
|
||||
assert(s.pocket_prepped == -1)
|
||||
|
||||
h['tool-prepared'] = True
|
||||
wait_for_hal_pin('tool-prepare', False)
|
||||
h['tool-prepared'] = False
|
||||
|
||||
assert(h['tool-change'] == False)
|
||||
assert(h['tool-prepare'] == False)
|
||||
assert(h['tool-number'] == 2)
|
||||
assert(h['tool-prep-number'] == 12)
|
||||
assert(h['tool-prep-pocket'] == 9)
|
||||
assert(h['tool-from-pocket'] == 46)
|
||||
|
||||
time.sleep(stat_poll_wait)
|
||||
s.poll()
|
||||
assert(s.tool_in_spindle == 2)
|
||||
assert(s.tool_from_pocket == 46)
|
||||
assert(s.pocket_prepped == 9)
|
||||
|
||||
|
||||
#
|
||||
# Prepare T2
|
||||
# This tool is already in the spindle.
|
||||
#
|
||||
|
||||
c.mdi('t2')
|
||||
try:
|
||||
wait_for_hal_pin('tool-prepare', True, timeout=5)
|
||||
except RuntimeError:
|
||||
# It *should* time out, no tool prep should be performed since the
|
||||
# requested tool is already in the spindle.
|
||||
pass
|
||||
|
||||
assert(h['tool-change'] == False)
|
||||
assert(h['tool-prepare'] == False)
|
||||
assert(h['tool-number'] == 2)
|
||||
assert(h['tool-prep-number'] == 2)
|
||||
assert(h['tool-prep-pocket'] == 0)
|
||||
assert(h['tool-from-pocket'] == 46)
|
||||
|
||||
time.sleep(stat_poll_wait)
|
||||
s.poll()
|
||||
assert(s.tool_in_spindle == 2)
|
||||
assert(s.tool_from_pocket == 46)
|
||||
assert(s.pocket_prepped == 0)
|
||||
|
||||
|
||||
#
|
||||
# Change to prepared tool (T2)
|
||||
#
|
||||
|
||||
c.mdi('m6')
|
||||
try:
|
||||
wait_for_hal_pin('tool-change', True, timeout=5)
|
||||
except RuntimeError:
|
||||
# It *should* time out, no tool change should be performed since
|
||||
# the prepared tool is already in the spindle.
|
||||
pass
|
||||
|
||||
assert(h['tool-change'] == False)
|
||||
assert(h['tool-prepare'] == False)
|
||||
assert(h['tool-number'] == 2)
|
||||
assert(h['tool-prep-number'] == 2)
|
||||
assert(h['tool-prep-pocket'] == 0)
|
||||
assert(h['tool-from-pocket'] == 46)
|
||||
|
||||
time.sleep(stat_poll_wait)
|
||||
s.poll()
|
||||
assert(s.tool_in_spindle == 2)
|
||||
assert(s.tool_from_pocket == 46)
|
||||
assert(s.pocket_prepped == 0)
|
||||
|
||||
#
|
||||
# Prepare T0
|
||||
#
|
||||
|
||||
c.mdi('t0')
|
||||
wait_for_hal_pin('tool-prepare', True)
|
||||
|
||||
assert(h['tool-change'] == False)
|
||||
assert(h['tool-prepare'] == True)
|
||||
assert(h['tool-number'] == 2)
|
||||
assert(h['tool-prep-number'] == 0)
|
||||
assert(h['tool-prep-pocket'] == 2)
|
||||
assert(h['tool-from-pocket'] == 46)
|
||||
|
||||
s.poll()
|
||||
assert(s.tool_in_spindle == 2)
|
||||
assert(s.tool_from_pocket == 46)
|
||||
assert(s.pocket_prepped == 0)
|
||||
|
||||
h['tool-prepared'] = True
|
||||
wait_for_hal_pin('tool-prepare', False)
|
||||
h['tool-prepared'] = False
|
||||
|
||||
assert(h['tool-change'] == False)
|
||||
assert(h['tool-prepare'] == False)
|
||||
assert(h['tool-number'] == 2)
|
||||
assert(h['tool-prep-number'] == 0)
|
||||
assert(h['tool-prep-pocket'] == 2)
|
||||
assert(h['tool-from-pocket'] == 46)
|
||||
|
||||
time.sleep(stat_poll_wait)
|
||||
s.poll()
|
||||
assert(s.tool_in_spindle == 2)
|
||||
assert(s.tool_from_pocket == 46)
|
||||
assert(s.pocket_prepped == 2) # random tc gives you pocket, which is the same as tool-table-array index
|
||||
|
||||
|
||||
#
|
||||
# Change to T0
|
||||
#
|
||||
|
||||
c.mdi('m6')
|
||||
wait_for_hal_pin('tool-change', True)
|
||||
|
||||
assert(h['tool-change'] == True)
|
||||
assert(h['tool-prepare'] == False)
|
||||
assert(h['tool-number'] == 2)
|
||||
assert(h['tool-prep-number'] == 0)
|
||||
assert(h['tool-prep-pocket'] == 2)
|
||||
assert(h['tool-from-pocket'] == 46)
|
||||
|
||||
time.sleep(stat_poll_wait)
|
||||
s.poll()
|
||||
assert(s.tool_in_spindle == 2)
|
||||
assert(s.tool_from_pocket == 46)
|
||||
assert(s.pocket_prepped == 2)
|
||||
|
||||
h['tool-changed'] = True
|
||||
wait_for_hal_pin('tool-change', False)
|
||||
h['tool-changed'] = False
|
||||
|
||||
assert(h['tool-change'] == False)
|
||||
assert(h['tool-prepare'] == False)
|
||||
assert(h['tool-number'] == 0)
|
||||
assert(h['tool-prep-number'] == 0)
|
||||
assert(h['tool-prep-pocket'] == 0)
|
||||
assert(h['tool-from-pocket'] == 0)
|
||||
|
||||
time.sleep(stat_poll_wait)
|
||||
s.poll()
|
||||
assert(s.tool_in_spindle == 0)
|
||||
assert(s.tool_from_pocket == 0)
|
||||
assert(s.pocket_prepped == -1)
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
115
tests/toolchanger/reload-tool/random/test.ini
Normal file
115
tests/toolchanger/reload-tool/random/test.ini
Normal file
@@ -0,0 +1,115 @@
|
||||
[EMC]
|
||||
VERSION = 1.1
|
||||
|
||||
#DEBUG = 0x0
|
||||
DEBUG = 0xffffffff
|
||||
|
||||
[DISPLAY]
|
||||
DISPLAY = ./test-ui.py
|
||||
|
||||
[FILTER]
|
||||
#No Content
|
||||
|
||||
[RS274NGC]
|
||||
PARAMETER_FILE = sim.var
|
||||
USER_M_PATH = ./subs
|
||||
[EMCMOT]
|
||||
|
||||
EMCMOT = motmod
|
||||
COMM_TIMEOUT = 4.0
|
||||
BASE_PERIOD = 0
|
||||
SERVO_PERIOD = 1000000
|
||||
|
||||
[TASK]
|
||||
TASK = milltask
|
||||
CYCLE_TIME = 0.001
|
||||
|
||||
[HAL]
|
||||
HALFILE = core_sim.hal
|
||||
|
||||
[HALUI]
|
||||
#No Content
|
||||
|
||||
[TRAJ]
|
||||
|
||||
NO_FORCE_HOMING=1
|
||||
AXES = 3
|
||||
COORDINATES = X Y Z
|
||||
HOME = 0 0 0
|
||||
LINEAR_UNITS = inch
|
||||
ANGULAR_UNITS = degree
|
||||
DEFAULT_LINEAR_VELOCITY = 1.2
|
||||
MAX_LINEAR_ACCELERATION = 123.45
|
||||
MAX_LINEAR_VELOCITY = 45.67
|
||||
|
||||
[EMCIO]
|
||||
TOOL_TABLE = simpockets.tbl
|
||||
TOOL_CHANGE_QUILL_UP = 1
|
||||
RANDOM_TOOLCHANGER = 1
|
||||
TOOL_CHANGE_POSITION = .111 .222 .333
|
||||
|
||||
|
||||
[KINS]
|
||||
KINEMATICS = trivkins
|
||||
#This is a best-guess at the number of joints, it should be checked
|
||||
JOINTS = 3
|
||||
|
||||
[AXIS_X]
|
||||
MIN_LIMIT = -40.0
|
||||
MAX_LIMIT = 40.0
|
||||
MAX_VELOCITY = 4
|
||||
MAX_ACCELERATION = 1000.0
|
||||
|
||||
[JOINT_0]
|
||||
|
||||
TYPE = LINEAR
|
||||
HOME = 0.000
|
||||
MAX_VELOCITY = 4
|
||||
MAX_ACCELERATION = 1000.0
|
||||
BACKLASH = 0.000
|
||||
INPUT_SCALE = 4000
|
||||
OUTPUT_SCALE = 1.000
|
||||
MIN_LIMIT = -40.0
|
||||
MAX_LIMIT = 40.0
|
||||
FERROR = 0.050
|
||||
MIN_FERROR = 0.010
|
||||
|
||||
[AXIS_Y]
|
||||
MIN_LIMIT = -40.0
|
||||
MAX_LIMIT = 40.0
|
||||
MAX_VELOCITY = 4
|
||||
MAX_ACCELERATION = 1000.0
|
||||
|
||||
[JOINT_1]
|
||||
|
||||
TYPE = LINEAR
|
||||
HOME = 0.000
|
||||
MAX_VELOCITY = 4
|
||||
MAX_ACCELERATION = 1000.0
|
||||
BACKLASH = 0.000
|
||||
INPUT_SCALE = 4000
|
||||
OUTPUT_SCALE = 1.000
|
||||
MIN_LIMIT = -40.0
|
||||
MAX_LIMIT = 40.0
|
||||
FERROR = 0.050
|
||||
MIN_FERROR = 0.010
|
||||
|
||||
[AXIS_Z]
|
||||
MIN_LIMIT = -40.0
|
||||
MAX_LIMIT = 40.0
|
||||
MAX_VELOCITY = 4
|
||||
MAX_ACCELERATION = 1000.0
|
||||
|
||||
[JOINT_2]
|
||||
|
||||
TYPE = LINEAR
|
||||
HOME = 0.0
|
||||
MAX_VELOCITY = 4
|
||||
MAX_ACCELERATION = 1000.0
|
||||
BACKLASH = 0.000
|
||||
INPUT_SCALE = 4000
|
||||
OUTPUT_SCALE = 1.000
|
||||
MIN_LIMIT = -40.0
|
||||
MAX_LIMIT = 40.0
|
||||
FERROR = 0.050
|
||||
MIN_FERROR = 0.010
|
||||
1
tests/toolchanger/reload-tool/random/test.sh
Symbolic link
1
tests/toolchanger/reload-tool/random/test.sh
Symbolic link
@@ -0,0 +1 @@
|
||||
../shared-test.sh
|
||||
Reference in New Issue
Block a user