Import LinuxCNC source tree
This commit is contained in:
10
tests/tool-info/README
Normal file
10
tests/tool-info/README
Normal file
@@ -0,0 +1,10 @@
|
||||
This test runs LinuxCNC and verifies that all three sources of tool info
|
||||
are correct. The three sources are:
|
||||
|
||||
* the Status buffer
|
||||
|
||||
* IO's HAL pins
|
||||
|
||||
* Interp's system variables (like #<_current_pocket>)
|
||||
|
||||
In 2.7.8 this test replicates Github Issue #239.
|
||||
2
tests/tool-info/checkresult
Executable file
2
tests/tool-info/checkresult
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
exit 0 # test failure is indicated by test.sh exit value
|
||||
61
tests/tool-info/core_sim.hal
Normal file
61
tests/tool-info/core_sim.hal
Normal file
@@ -0,0 +1,61 @@
|
||||
# core HAL config file for simulation
|
||||
|
||||
# first load all the RT modules that will be needed
|
||||
# kinematics
|
||||
loadrt [KINS]KINEMATICS
|
||||
#autoconverted trivkins
|
||||
# motion controller, get name and thread periods from INI file
|
||||
loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS
|
||||
# load 6 differentiators (for velocity and accel signals
|
||||
loadrt ddt count=6
|
||||
# load additional blocks
|
||||
loadrt hypot count=2
|
||||
loadrt comp count=3
|
||||
loadrt or2 count=1
|
||||
|
||||
# add motion controller functions to servo thread
|
||||
addf motion-command-handler servo-thread
|
||||
addf motion-controller servo-thread
|
||||
# link the differentiator functions into the code
|
||||
addf ddt.0 servo-thread
|
||||
addf ddt.1 servo-thread
|
||||
addf ddt.2 servo-thread
|
||||
addf ddt.3 servo-thread
|
||||
addf ddt.4 servo-thread
|
||||
addf ddt.5 servo-thread
|
||||
addf hypot.0 servo-thread
|
||||
addf hypot.1 servo-thread
|
||||
|
||||
# create HAL signals for position commands from motion module
|
||||
# loop position commands back to motion module feedback
|
||||
net Xpos joint.0.motor-pos-cmd => joint.0.motor-pos-fb ddt.0.in
|
||||
net Ypos joint.1.motor-pos-cmd => joint.1.motor-pos-fb ddt.2.in
|
||||
net Zpos joint.2.motor-pos-cmd => joint.2.motor-pos-fb ddt.4.in
|
||||
|
||||
# send the position commands thru differentiators to
|
||||
# generate velocity and accel signals
|
||||
net Xvel ddt.0.out => ddt.1.in hypot.0.in0
|
||||
net Xacc <= ddt.1.out
|
||||
net Yvel ddt.2.out => ddt.3.in hypot.0.in1
|
||||
net Yacc <= ddt.3.out
|
||||
net Zvel ddt.4.out => ddt.5.in hypot.1.in0
|
||||
net Zacc <= ddt.5.out
|
||||
|
||||
# Cartesian 2- and 3-axis velocities
|
||||
net XYvel hypot.0.out => hypot.1.in1
|
||||
net XYZvel <= hypot.1.out
|
||||
|
||||
# estop loopback
|
||||
net estop-loop iocontrol.0.user-enable-out iocontrol.0.emc-enable-in
|
||||
|
||||
# create signals for tool loading loopback
|
||||
net tool-prepare <= iocontrol.0.tool-prepare
|
||||
net tool-prepared => iocontrol.0.tool-prepared
|
||||
|
||||
net tool-change <= iocontrol.0.tool-change
|
||||
net tool-changed => iocontrol.0.tool-changed
|
||||
|
||||
net tool-number <= iocontrol.0.tool-number
|
||||
net tool-prep-number <= iocontrol.0.tool-prep-number
|
||||
net tool-prep-pocket <= iocontrol.0.tool-prep-pocket
|
||||
|
||||
2
tests/tool-info/non-random/.gitignore
vendored
Normal file
2
tests/tool-info/non-random/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
sim.var*
|
||||
simpockets.tbl
|
||||
1
tests/tool-info/non-random/checkresult
Symbolic link
1
tests/tool-info/non-random/checkresult
Symbolic link
@@ -0,0 +1 @@
|
||||
../checkresult
|
||||
1
tests/tool-info/non-random/core_sim.hal
Symbolic link
1
tests/tool-info/non-random/core_sim.hal
Symbolic link
@@ -0,0 +1 @@
|
||||
../core_sim.hal
|
||||
262
tests/tool-info/non-random/test-ui.py
Executable file
262
tests/tool-info/non-random/test-ui.py
Executable file
@@ -0,0 +1,262 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import linuxcnc
|
||||
import hal
|
||||
|
||||
import math
|
||||
import time
|
||||
import sys
|
||||
import subprocess
|
||||
import os
|
||||
import signal
|
||||
import glob
|
||||
import re
|
||||
|
||||
|
||||
def wait_for_linuxcnc_startup(status, timeout=10.0):
|
||||
|
||||
"""Poll the Status buffer waiting for it to look initialized,
|
||||
rather than just allocated (all-zero). Returns on success, throws
|
||||
RuntimeError on failure."""
|
||||
|
||||
start_time = time.time()
|
||||
while time.time() - start_time < timeout:
|
||||
status.poll()
|
||||
if (status.angular_units == 0.0) \
|
||||
or (status.axis_mask == 0) \
|
||||
or (status.cycle_time == 0.0) \
|
||||
or (status.exec_state != linuxcnc.EXEC_DONE) \
|
||||
or (status.interp_state != linuxcnc.INTERP_IDLE) \
|
||||
or (status.inpos == False) \
|
||||
or (status.linear_units == 0.0) \
|
||||
or (status.max_acceleration == 0.0) \
|
||||
or (status.max_velocity == 0.0) \
|
||||
or (status.program_units == 0.0) \
|
||||
or (status.rapidrate == 0.0) \
|
||||
or (status.state != linuxcnc.RCS_DONE) \
|
||||
or (status.task_state != linuxcnc.STATE_ESTOP):
|
||||
time.sleep(0.1)
|
||||
else:
|
||||
# looks good
|
||||
return
|
||||
|
||||
# timeout, throw an exception
|
||||
raise RuntimeError
|
||||
|
||||
|
||||
def verify_interp_vars(state, current_tool, current_pocket, selected_tool, selected_pocket):
|
||||
c.mdi('(debug,current_tool=#<_current_tool> current_pocket=#<_current_pocket> selected_tool=#<_selected_tool> selected_pocket=#<_selected_pocket>)')
|
||||
c.wait_complete()
|
||||
|
||||
expected = "current_tool=%.6f current_pocket=%.6f selected_tool=%.6f selected_pocket=%.6f" % (current_tool, current_pocket, selected_tool, selected_pocket)
|
||||
|
||||
while True:
|
||||
result = e.poll()
|
||||
if result == None:
|
||||
print("nothing from polling error channel")
|
||||
sys.exit(1)
|
||||
|
||||
(type, msg) = result
|
||||
if type == linuxcnc.OPERATOR_DISPLAY:
|
||||
if msg == expected:
|
||||
# success!
|
||||
break
|
||||
print("state='%s', unexpected interp variables" % state)
|
||||
print("result: {}".format(msg))
|
||||
print("expected: {}".format(expected))
|
||||
sys.exit(1)
|
||||
else:
|
||||
print("state='%s', ignoring unexpected error type %d: %s" % (state, type, msg))
|
||||
|
||||
print("state='%s', got expected interp variables:" % state)
|
||||
print(" current_tool=%.6f" % current_tool)
|
||||
print(" current_pocket=%.6f" % current_pocket)
|
||||
print(" selected_tool=%.6f" % selected_tool)
|
||||
print(" selected_pocket=%.6f" % selected_pocket)
|
||||
|
||||
|
||||
def verify_io_pins(state, tool_number, tool_prep_number, tool_prep_pocket):
|
||||
if h['tool-number'] != tool_number:
|
||||
print("state=%s, expected io.tool-number=%d, got %d" % (state, tool_number, h['tool-number']))
|
||||
sys.exit(1)
|
||||
|
||||
if h['tool-prep-number'] != tool_prep_number:
|
||||
print("state=%s, expected io.tool-prep-number=%d, got %d" % (state, tool_prep_number, h['tool-prep-number']))
|
||||
sys.exit(1)
|
||||
|
||||
if h['tool-prep-pocket'] != tool_prep_pocket:
|
||||
print("state=%s, expected io.tool-prep-pocket=%d, got %d" % (state, tool_prep_pocket, h['tool-prep-pocket']))
|
||||
sys.exit(1)
|
||||
|
||||
print("state='%s', got expected io pins:" % state)
|
||||
print(" tool-number=%d" % tool_number)
|
||||
print(" tool-prep-number=%d" % tool_prep_number)
|
||||
print(" tool-prep-pocket=%d" % tool_prep_pocket)
|
||||
|
||||
|
||||
def verify_status_buffer(state, tool_in_spindle):
|
||||
deadline = time.time() + 1
|
||||
while time.time() < deadline:
|
||||
s.poll()
|
||||
if s.tool_in_spindle == tool_in_spindle:
|
||||
break
|
||||
time.sleep(.05)
|
||||
|
||||
if s.tool_in_spindle != tool_in_spindle:
|
||||
print("state=%s, expected status.tool_in_spindle=%d, got %d" % (state, tool_in_spindle, s.tool_in_spindle))
|
||||
sys.exit(1)
|
||||
|
||||
print("state='%s', got expected status buffer fields:" % state)
|
||||
print(" tool_in_spindle=%d" % tool_in_spindle)
|
||||
|
||||
|
||||
def wait_for_hal_pin(pin_name, value, timeout=10):
|
||||
start = time.time()
|
||||
while time.time() < (start + timeout):
|
||||
if h[pin_name] == value:
|
||||
return
|
||||
time.sleep(0.1)
|
||||
print("timeout waiting for hal pin %s to go to %s!" % (pin_name, value))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
|
||||
c = linuxcnc.command()
|
||||
s = linuxcnc.stat()
|
||||
e = linuxcnc.error_channel()
|
||||
|
||||
|
||||
h = hal.component("test-ui")
|
||||
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-prepare", hal.HAL_BIT, hal.HAL_IN)
|
||||
h.newpin("tool-prepared", hal.HAL_BIT, hal.HAL_OUT)
|
||||
h.newpin("tool-change", hal.HAL_BIT, hal.HAL_IN)
|
||||
h.newpin("tool-changed", hal.HAL_BIT, hal.HAL_OUT)
|
||||
h['tool-prepared'] = False
|
||||
h['tool-changed'] = False
|
||||
h.ready()
|
||||
|
||||
hal.connect('test-ui.tool-number', 'tool-number')
|
||||
hal.connect('test-ui.tool-prep-number', 'tool-prep-number')
|
||||
hal.connect('test-ui.tool-prep-pocket', 'tool-prep-pocket')
|
||||
|
||||
hal.connect('test-ui.tool-prepare', 'tool-prepare')
|
||||
hal.connect('test-ui.tool-prepared', 'tool-prepared')
|
||||
hal.connect('test-ui.tool-change', 'tool-change')
|
||||
hal.connect('test-ui.tool-changed', 'tool-changed')
|
||||
|
||||
|
||||
# Wait for LinuxCNC to initialize itself so the Status buffer stabilizes.
|
||||
wait_for_linuxcnc_startup(s)
|
||||
|
||||
c.state(linuxcnc.STATE_ESTOP_RESET)
|
||||
c.state(linuxcnc.STATE_ON)
|
||||
c.home(-1)
|
||||
c.wait_complete()
|
||||
|
||||
c.mode(linuxcnc.MODE_MDI)
|
||||
|
||||
|
||||
#
|
||||
# Starting state should be sane.
|
||||
#
|
||||
|
||||
verify_status_buffer(state='init', tool_in_spindle=0)
|
||||
verify_io_pins(state='init', tool_number=0, tool_prep_number=0, tool_prep_pocket=0)
|
||||
verify_interp_vars(state='init', current_tool=0, current_pocket=-1, selected_tool=0, selected_pocket=-1)
|
||||
|
||||
|
||||
#
|
||||
# After "T1" prepares the tool.
|
||||
#
|
||||
|
||||
c.mdi('T1')
|
||||
wait_for_hal_pin('tool-prepare', True)
|
||||
h['tool-prepared'] = True
|
||||
wait_for_hal_pin('tool-prepare', False)
|
||||
h['tool-prepared'] = False
|
||||
|
||||
verify_status_buffer(state='after T1', tool_in_spindle=0)
|
||||
verify_io_pins(state='after T1', tool_number=0, tool_prep_number=1, tool_prep_pocket=1)
|
||||
verify_interp_vars(state='after T1', current_tool=0, current_pocket=-1, selected_tool=1, selected_pocket=1)
|
||||
|
||||
|
||||
#
|
||||
# After "M6" changes to the prepared tool.
|
||||
#
|
||||
|
||||
c.mdi('M6')
|
||||
wait_for_hal_pin('tool-change', True)
|
||||
h['tool-changed'] = True
|
||||
wait_for_hal_pin('tool-change', False)
|
||||
h['tool-changed'] = False
|
||||
|
||||
verify_status_buffer(state='after T1 M6', tool_in_spindle=1)
|
||||
verify_io_pins(state='after T1 M6', tool_number=1, tool_prep_number=0, tool_prep_pocket=0)
|
||||
verify_interp_vars(state='after T1 M6', current_tool=1, current_pocket=1, selected_tool=1, selected_pocket=-1)
|
||||
|
||||
|
||||
#
|
||||
# After "T10" prepares the tool.
|
||||
#
|
||||
|
||||
c.mdi('T10')
|
||||
wait_for_hal_pin('tool-prepare', True)
|
||||
h['tool-prepared'] = True
|
||||
wait_for_hal_pin('tool-prepare', False)
|
||||
h['tool-prepared'] = False
|
||||
|
||||
verify_status_buffer(state='after T10', tool_in_spindle=1)
|
||||
verify_io_pins(state='after T10', tool_number=1, tool_prep_number=10, tool_prep_pocket=3)
|
||||
verify_interp_vars(state='after T10', current_tool=1, current_pocket=1, selected_tool=10, selected_pocket=3)
|
||||
|
||||
|
||||
#
|
||||
# After "M6" changes to the prepared tool.
|
||||
#
|
||||
|
||||
c.mdi('M6')
|
||||
wait_for_hal_pin('tool-change', True)
|
||||
h['tool-changed'] = True
|
||||
wait_for_hal_pin('tool-change', False)
|
||||
h['tool-changed'] = False
|
||||
|
||||
verify_status_buffer(state='after T10 M6', tool_in_spindle=10)
|
||||
verify_io_pins(state='after T10 M6', tool_number=10, tool_prep_number=0, tool_prep_pocket=0)
|
||||
verify_interp_vars(state='after T10 M6', current_tool=10, current_pocket=3, selected_tool=10, selected_pocket=-1)
|
||||
|
||||
|
||||
#
|
||||
# After "T99999" prepares a tool.
|
||||
#
|
||||
|
||||
c.mdi('T99999')
|
||||
wait_for_hal_pin('tool-prepare', True)
|
||||
h['tool-prepared'] = True
|
||||
wait_for_hal_pin('tool-prepare', False)
|
||||
h['tool-prepared'] = False
|
||||
|
||||
verify_status_buffer(state='after T99999', tool_in_spindle=10)
|
||||
verify_io_pins(state='after T99999', tool_number=10, tool_prep_number=99999, tool_prep_pocket=50)
|
||||
verify_interp_vars(state='after T99999', current_tool=10, current_pocket=3, selected_tool=99999, selected_pocket=50)
|
||||
|
||||
|
||||
#
|
||||
# After "M6" changes to the prepared tool.
|
||||
#
|
||||
|
||||
c.mdi('M6')
|
||||
wait_for_hal_pin('tool-change', True)
|
||||
h['tool-changed'] = True
|
||||
wait_for_hal_pin('tool-change', False)
|
||||
h['tool-changed'] = False
|
||||
|
||||
verify_status_buffer(state='after T99999 M6', tool_in_spindle=99999)
|
||||
verify_io_pins(state='after T99999 M6', tool_number=99999, tool_prep_number=0, tool_prep_pocket=0)
|
||||
verify_interp_vars(state='after T99999 M6', current_tool=99999, current_pocket=50, selected_tool=99999, selected_pocket=-1)
|
||||
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
111
tests/tool-info/non-random/test.ini
Normal file
111
tests/tool-info/non-random/test.ini
Normal file
@@ -0,0 +1,111 @@
|
||||
[EMC]
|
||||
# The version string for this INI file.
|
||||
VERSION = 1.1
|
||||
|
||||
DEBUG = 0x0
|
||||
#DEBUG = 0xffffffff
|
||||
|
||||
[DISPLAY]
|
||||
DISPLAY = ./test-ui.py
|
||||
|
||||
|
||||
[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]
|
||||
HALUI = halui
|
||||
HALFILE = core_sim.hal
|
||||
|
||||
[HALUI]
|
||||
#No Content
|
||||
|
||||
[TRAJ]
|
||||
|
||||
NO_FORCE_HOMING=1
|
||||
COORDINATES = XYZ
|
||||
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 = 0
|
||||
|
||||
|
||||
|
||||
[KINS]
|
||||
KINEMATICS = trivkins coordinates=XYZ
|
||||
#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/tool-info/non-random/test.sh
Symbolic link
1
tests/tool-info/non-random/test.sh
Symbolic link
@@ -0,0 +1 @@
|
||||
../shared-test.sh
|
||||
2
tests/tool-info/random-no-startup-tool/.gitignore
vendored
Normal file
2
tests/tool-info/random-no-startup-tool/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
sim.var*
|
||||
simpockets.tbl
|
||||
1
tests/tool-info/random-no-startup-tool/checkresult
Symbolic link
1
tests/tool-info/random-no-startup-tool/checkresult
Symbolic link
@@ -0,0 +1 @@
|
||||
../checkresult
|
||||
1
tests/tool-info/random-no-startup-tool/core_sim.hal
Symbolic link
1
tests/tool-info/random-no-startup-tool/core_sim.hal
Symbolic link
@@ -0,0 +1 @@
|
||||
../core_sim.hal
|
||||
262
tests/tool-info/random-no-startup-tool/test-ui.py
Executable file
262
tests/tool-info/random-no-startup-tool/test-ui.py
Executable file
@@ -0,0 +1,262 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import linuxcnc
|
||||
import hal
|
||||
|
||||
import math
|
||||
import time
|
||||
import sys
|
||||
import subprocess
|
||||
import os
|
||||
import signal
|
||||
import glob
|
||||
import re
|
||||
|
||||
|
||||
def wait_for_linuxcnc_startup(status, timeout=10.0):
|
||||
|
||||
"""Poll the Status buffer waiting for it to look initialized,
|
||||
rather than just allocated (all-zero). Returns on success, throws
|
||||
RuntimeError on failure."""
|
||||
|
||||
start_time = time.time()
|
||||
while time.time() - start_time < timeout:
|
||||
status.poll()
|
||||
if (status.angular_units == 0.0) \
|
||||
or (status.axis_mask == 0) \
|
||||
or (status.cycle_time == 0.0) \
|
||||
or (status.exec_state != linuxcnc.EXEC_DONE) \
|
||||
or (status.interp_state != linuxcnc.INTERP_IDLE) \
|
||||
or (status.inpos == False) \
|
||||
or (status.linear_units == 0.0) \
|
||||
or (status.max_acceleration == 0.0) \
|
||||
or (status.max_velocity == 0.0) \
|
||||
or (status.program_units == 0.0) \
|
||||
or (status.rapidrate == 0.0) \
|
||||
or (status.state != linuxcnc.RCS_DONE) \
|
||||
or (status.task_state != linuxcnc.STATE_ESTOP):
|
||||
time.sleep(0.1)
|
||||
else:
|
||||
# looks good
|
||||
return
|
||||
|
||||
# timeout, throw an exception
|
||||
raise RuntimeError
|
||||
|
||||
|
||||
def verify_interp_vars(state, current_tool, current_pocket, selected_tool, selected_pocket):
|
||||
c.mdi('(debug,current_tool=#<_current_tool> current_pocket=#<_current_pocket> selected_tool=#<_selected_tool> selected_pocket=#<_selected_pocket>)')
|
||||
c.wait_complete()
|
||||
|
||||
expected = "current_tool=%.6f current_pocket=%.6f selected_tool=%.6f selected_pocket=%.6f" % (current_tool, current_pocket, selected_tool, selected_pocket)
|
||||
|
||||
while True:
|
||||
result = e.poll()
|
||||
if result == None:
|
||||
print("nothing from polling error channel")
|
||||
sys.exit(1)
|
||||
|
||||
(type, msg) = result
|
||||
if type == linuxcnc.OPERATOR_DISPLAY:
|
||||
if msg == expected:
|
||||
# success!
|
||||
break
|
||||
print("state='%s', unexpected interp variables" % state)
|
||||
print("result: {}".format(msg))
|
||||
print("expected: {}".format(expected))
|
||||
sys.exit(1)
|
||||
else:
|
||||
print("state='%s', ignoring unexpected error type %d: %s" % (state, type, msg))
|
||||
|
||||
print("state='%s', got expected interp variables:" % state)
|
||||
print(" current_tool=%.6f" % current_tool)
|
||||
print(" current_pocket=%.6f" % current_pocket)
|
||||
print(" selected_tool=%.6f" % selected_tool)
|
||||
print(" selected_pocket=%.6f" % selected_pocket)
|
||||
|
||||
|
||||
def verify_io_pins(state, tool_number, tool_prep_number, tool_prep_pocket):
|
||||
if h['tool-number'] != tool_number:
|
||||
print("state=%s, expected io.tool-number=%d, got %d" % (state, tool_number, h['tool-number']))
|
||||
sys.exit(1)
|
||||
|
||||
if h['tool-prep-number'] != tool_prep_number:
|
||||
print("state=%s, expected io.tool-prep-number=%d, got %d" % (state, tool_prep_number, h['tool-prep-number']))
|
||||
sys.exit(1)
|
||||
|
||||
if h['tool-prep-pocket'] != tool_prep_pocket:
|
||||
print("state=%s, expected io.tool-prep-pocket=%d, got %d" % (state, tool_prep_pocket, h['tool-prep-pocket']))
|
||||
sys.exit(1)
|
||||
|
||||
print("state='%s', got expected io pins:" % state)
|
||||
print(" tool-number=%d" % tool_number)
|
||||
print(" tool-prep-number=%d" % tool_prep_number)
|
||||
print(" tool-prep-pocket=%d" % tool_prep_pocket)
|
||||
|
||||
|
||||
def verify_status_buffer(state, tool_in_spindle):
|
||||
deadline = time.time() + 1
|
||||
while time.time() < deadline:
|
||||
s.poll()
|
||||
if s.tool_in_spindle == tool_in_spindle:
|
||||
break
|
||||
time.sleep(.05)
|
||||
|
||||
if s.tool_in_spindle != tool_in_spindle:
|
||||
print("state=%s, expected status.tool_in_spindle=%d, got %d" % (state, tool_in_spindle, s.tool_in_spindle))
|
||||
sys.exit(1)
|
||||
|
||||
print("state='%s', got expected status buffer fields:" % state)
|
||||
print(" tool_in_spindle=%d" % tool_in_spindle)
|
||||
|
||||
|
||||
def wait_for_hal_pin(pin_name, value, timeout=10):
|
||||
start = time.time()
|
||||
while time.time() < (start + timeout):
|
||||
if h[pin_name] == value:
|
||||
return
|
||||
time.sleep(0.1)
|
||||
print("timeout waiting for hal pin %s to go to %s!" % (pin_name, value))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
|
||||
c = linuxcnc.command()
|
||||
s = linuxcnc.stat()
|
||||
e = linuxcnc.error_channel()
|
||||
|
||||
|
||||
h = hal.component("test-ui")
|
||||
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-prepare", hal.HAL_BIT, hal.HAL_IN)
|
||||
h.newpin("tool-prepared", hal.HAL_BIT, hal.HAL_OUT)
|
||||
h.newpin("tool-change", hal.HAL_BIT, hal.HAL_IN)
|
||||
h.newpin("tool-changed", hal.HAL_BIT, hal.HAL_OUT)
|
||||
h['tool-prepared'] = False
|
||||
h['tool-changed'] = False
|
||||
h.ready()
|
||||
|
||||
hal.connect('test-ui.tool-number', 'tool-number')
|
||||
hal.connect('test-ui.tool-prep-number', 'tool-prep-number')
|
||||
hal.connect('test-ui.tool-prep-pocket', 'tool-prep-pocket')
|
||||
|
||||
hal.connect('test-ui.tool-prepare', 'tool-prepare')
|
||||
hal.connect('test-ui.tool-prepared', 'tool-prepared')
|
||||
hal.connect('test-ui.tool-change', 'tool-change')
|
||||
hal.connect('test-ui.tool-changed', 'tool-changed')
|
||||
|
||||
|
||||
# Wait for LinuxCNC to initialize itself so the Status buffer stabilizes.
|
||||
wait_for_linuxcnc_startup(s)
|
||||
|
||||
c.state(linuxcnc.STATE_ESTOP_RESET)
|
||||
c.state(linuxcnc.STATE_ON)
|
||||
c.home(-1)
|
||||
c.wait_complete()
|
||||
|
||||
c.mode(linuxcnc.MODE_MDI)
|
||||
|
||||
|
||||
#
|
||||
# Starting state should be sane.
|
||||
#
|
||||
|
||||
verify_status_buffer(state='init', tool_in_spindle=-1)
|
||||
verify_io_pins(state='init', tool_number=-1, tool_prep_number=0, tool_prep_pocket=0)
|
||||
verify_interp_vars(state='init', current_tool=-1, current_pocket=-1, selected_tool=0, selected_pocket=-1)
|
||||
|
||||
|
||||
#
|
||||
# After "T1" prepares the tool.
|
||||
#
|
||||
|
||||
c.mdi('T1')
|
||||
wait_for_hal_pin('tool-prepare', True)
|
||||
h['tool-prepared'] = True
|
||||
wait_for_hal_pin('tool-prepare', False)
|
||||
h['tool-prepared'] = False
|
||||
|
||||
verify_status_buffer(state='after T1', tool_in_spindle=-1)
|
||||
verify_io_pins(state='after T1', tool_number=-1, tool_prep_number=1, tool_prep_pocket=1)
|
||||
verify_interp_vars(state='after T1', current_tool=-1, current_pocket=-1, selected_tool=1, selected_pocket=1)
|
||||
|
||||
|
||||
#
|
||||
# After "M6" changes to the prepared tool.
|
||||
#
|
||||
|
||||
c.mdi('M6')
|
||||
wait_for_hal_pin('tool-change', True)
|
||||
h['tool-changed'] = True
|
||||
wait_for_hal_pin('tool-change', False)
|
||||
h['tool-changed'] = False
|
||||
|
||||
verify_status_buffer(state='after T1 M6', tool_in_spindle=1)
|
||||
verify_io_pins(state='after T1 M6', tool_number=1, tool_prep_number=0, tool_prep_pocket=0)
|
||||
verify_interp_vars(state='after T1 M6', current_tool=1, current_pocket=0, selected_tool=1, selected_pocket=-1)
|
||||
|
||||
|
||||
#
|
||||
# After "T10" prepares the tool.
|
||||
#
|
||||
|
||||
c.mdi('T10')
|
||||
wait_for_hal_pin('tool-prepare', True)
|
||||
h['tool-prepared'] = True
|
||||
wait_for_hal_pin('tool-prepare', False)
|
||||
h['tool-prepared'] = False
|
||||
|
||||
verify_status_buffer(state='after T10', tool_in_spindle=1)
|
||||
verify_io_pins(state='after T10', tool_number=1, tool_prep_number=10, tool_prep_pocket=3)
|
||||
verify_interp_vars(state='after T10', current_tool=1, current_pocket=0, selected_tool=10, selected_pocket=3)
|
||||
|
||||
|
||||
#
|
||||
# After "M6" changes to the prepared tool.
|
||||
#
|
||||
|
||||
c.mdi('M6')
|
||||
wait_for_hal_pin('tool-change', True)
|
||||
h['tool-changed'] = True
|
||||
wait_for_hal_pin('tool-change', False)
|
||||
h['tool-changed'] = False
|
||||
|
||||
verify_status_buffer(state='after T10 M6', tool_in_spindle=10)
|
||||
verify_io_pins(state='after T10 M6', tool_number=10, tool_prep_number=0, tool_prep_pocket=0)
|
||||
verify_interp_vars(state='after T10 M6', current_tool=10, current_pocket=0, selected_tool=10, selected_pocket=-1)
|
||||
|
||||
|
||||
#
|
||||
# After "T99999" prepares a tool.
|
||||
#
|
||||
|
||||
c.mdi('T99999')
|
||||
wait_for_hal_pin('tool-prepare', True)
|
||||
h['tool-prepared'] = True
|
||||
wait_for_hal_pin('tool-prepare', False)
|
||||
h['tool-prepared'] = False
|
||||
|
||||
verify_status_buffer(state='after T99999', tool_in_spindle=10)
|
||||
verify_io_pins(state='after T99999', tool_number=10, tool_prep_number=99999, tool_prep_pocket=50)
|
||||
verify_interp_vars(state='after T99999', current_tool=10, current_pocket=0, selected_tool=99999, selected_pocket=50)
|
||||
|
||||
|
||||
#
|
||||
# After "M6" changes to the prepared tool.
|
||||
#
|
||||
|
||||
c.mdi('M6')
|
||||
wait_for_hal_pin('tool-change', True)
|
||||
h['tool-changed'] = True
|
||||
wait_for_hal_pin('tool-change', False)
|
||||
h['tool-changed'] = False
|
||||
|
||||
verify_status_buffer(state='after T99999 M6', tool_in_spindle=99999)
|
||||
verify_io_pins(state='after T99999 M6', tool_number=99999, tool_prep_number=0, tool_prep_pocket=0)
|
||||
verify_interp_vars(state='after T99999 M6', current_tool=99999, current_pocket=0, selected_tool=99999, selected_pocket=-1)
|
||||
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
111
tests/tool-info/random-no-startup-tool/test.ini
Normal file
111
tests/tool-info/random-no-startup-tool/test.ini
Normal file
@@ -0,0 +1,111 @@
|
||||
[EMC]
|
||||
# The version string for this INI file.
|
||||
VERSION = 1.1
|
||||
|
||||
DEBUG = 0x0
|
||||
#DEBUG = 0xffffffff
|
||||
|
||||
[DISPLAY]
|
||||
DISPLAY = ./test-ui.py
|
||||
|
||||
|
||||
[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]
|
||||
HALUI = halui
|
||||
HALFILE = core_sim.hal
|
||||
|
||||
[HALUI]
|
||||
#No Content
|
||||
|
||||
[TRAJ]
|
||||
|
||||
NO_FORCE_HOMING=1
|
||||
COORDINATES = XYZ
|
||||
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
|
||||
|
||||
|
||||
|
||||
[KINS]
|
||||
KINEMATICS = trivkins coordinates=XYZ
|
||||
#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/tool-info/random-no-startup-tool/test.sh
Symbolic link
1
tests/tool-info/random-no-startup-tool/test.sh
Symbolic link
@@ -0,0 +1 @@
|
||||
../shared-test.sh
|
||||
2
tests/tool-info/random-with-startup-tool/.gitignore
vendored
Normal file
2
tests/tool-info/random-with-startup-tool/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
sim.var*
|
||||
simpockets.tbl
|
||||
1
tests/tool-info/random-with-startup-tool/checkresult
Symbolic link
1
tests/tool-info/random-with-startup-tool/checkresult
Symbolic link
@@ -0,0 +1 @@
|
||||
../checkresult
|
||||
1
tests/tool-info/random-with-startup-tool/core_sim.hal
Symbolic link
1
tests/tool-info/random-with-startup-tool/core_sim.hal
Symbolic link
@@ -0,0 +1 @@
|
||||
../core_sim.hal
|
||||
@@ -0,0 +1,3 @@
|
||||
T99999 P0 Z+2.000000 ;
|
||||
T1 P3 D0.125000 Z+1.000000 ;
|
||||
T10 P50 D0.500000 Z+3.000000 ;
|
||||
262
tests/tool-info/random-with-startup-tool/test-ui.py
Executable file
262
tests/tool-info/random-with-startup-tool/test-ui.py
Executable file
@@ -0,0 +1,262 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import linuxcnc
|
||||
import hal
|
||||
|
||||
import math
|
||||
import time
|
||||
import sys
|
||||
import subprocess
|
||||
import os
|
||||
import signal
|
||||
import glob
|
||||
import re
|
||||
|
||||
|
||||
def wait_for_linuxcnc_startup(status, timeout=10.0):
|
||||
|
||||
"""Poll the Status buffer waiting for it to look initialized,
|
||||
rather than just allocated (all-zero). Returns on success, throws
|
||||
RuntimeError on failure."""
|
||||
|
||||
start_time = time.time()
|
||||
while time.time() - start_time < timeout:
|
||||
status.poll()
|
||||
if (status.angular_units == 0.0) \
|
||||
or (status.axis_mask == 0) \
|
||||
or (status.cycle_time == 0.0) \
|
||||
or (status.exec_state != linuxcnc.EXEC_DONE) \
|
||||
or (status.interp_state != linuxcnc.INTERP_IDLE) \
|
||||
or (status.inpos == False) \
|
||||
or (status.linear_units == 0.0) \
|
||||
or (status.max_acceleration == 0.0) \
|
||||
or (status.max_velocity == 0.0) \
|
||||
or (status.program_units == 0.0) \
|
||||
or (status.rapidrate == 0.0) \
|
||||
or (status.state != linuxcnc.RCS_DONE) \
|
||||
or (status.task_state != linuxcnc.STATE_ESTOP):
|
||||
time.sleep(0.1)
|
||||
else:
|
||||
# looks good
|
||||
return
|
||||
|
||||
# timeout, throw an exception
|
||||
raise RuntimeError
|
||||
|
||||
|
||||
def verify_interp_vars(state, current_tool, current_pocket, selected_tool, selected_pocket):
|
||||
c.mdi('(debug,current_tool=#<_current_tool> current_pocket=#<_current_pocket> selected_tool=#<_selected_tool> selected_pocket=#<_selected_pocket>)')
|
||||
c.wait_complete()
|
||||
|
||||
expected = "current_tool=%.6f current_pocket=%.6f selected_tool=%.6f selected_pocket=%.6f" % (current_tool, current_pocket, selected_tool, selected_pocket)
|
||||
|
||||
while True:
|
||||
result = e.poll()
|
||||
if result == None:
|
||||
print("nothing from polling error channel")
|
||||
sys.exit(1)
|
||||
|
||||
(type, msg) = result
|
||||
if type == linuxcnc.OPERATOR_DISPLAY:
|
||||
if msg == expected:
|
||||
# success!
|
||||
break
|
||||
print("state='%s', unexpected interp variables" % state)
|
||||
print("result: {}".format(msg))
|
||||
print("expected: {}".format(expected))
|
||||
sys.exit(1)
|
||||
else:
|
||||
print("state='%s', ignoring unexpected error type %d: %s" % (state, type, msg))
|
||||
|
||||
print("state='%s', got expected interp variables:" % state)
|
||||
print(" current_tool=%.6f" % current_tool)
|
||||
print(" current_pocket=%.6f" % current_pocket)
|
||||
print(" selected_tool=%.6f" % selected_tool)
|
||||
print(" selected_pocket=%.6f" % selected_pocket)
|
||||
|
||||
|
||||
def verify_io_pins(state, tool_number, tool_prep_number, tool_prep_pocket):
|
||||
if h['tool-number'] != tool_number:
|
||||
print("state=%s, expected io.tool-number=%d, got %d" % (state, tool_number, h['tool-number']))
|
||||
sys.exit(1)
|
||||
|
||||
if h['tool-prep-number'] != tool_prep_number:
|
||||
print("state=%s, expected io.tool-prep-number=%d, got %d" % (state, tool_prep_number, h['tool-prep-number']))
|
||||
sys.exit(1)
|
||||
|
||||
if h['tool-prep-pocket'] != tool_prep_pocket:
|
||||
print("state=%s, expected io.tool-prep-pocket=%d, got %d" % (state, tool_prep_pocket, h['tool-prep-pocket']))
|
||||
sys.exit(1)
|
||||
|
||||
print("state='%s', got expected io pins:" % state)
|
||||
print(" tool-number=%d" % tool_number)
|
||||
print(" tool-prep-number=%d" % tool_prep_number)
|
||||
print(" tool-prep-pocket=%d" % tool_prep_pocket)
|
||||
|
||||
|
||||
def verify_status_buffer(state, tool_in_spindle):
|
||||
deadline = time.time() + 1
|
||||
while time.time() < deadline:
|
||||
s.poll()
|
||||
if s.tool_in_spindle == tool_in_spindle:
|
||||
break
|
||||
time.sleep(.05)
|
||||
|
||||
if s.tool_in_spindle != tool_in_spindle:
|
||||
print("state=%s, expected status.tool_in_spindle=%d, got %d" % (state, tool_in_spindle, s.tool_in_spindle))
|
||||
sys.exit(1)
|
||||
|
||||
print("state='%s', got expected status buffer fields:" % state)
|
||||
print(" tool_in_spindle=%d" % tool_in_spindle)
|
||||
|
||||
|
||||
def wait_for_hal_pin(pin_name, value, timeout=10):
|
||||
start = time.time()
|
||||
while time.time() < (start + timeout):
|
||||
if h[pin_name] == value:
|
||||
return
|
||||
time.sleep(0.1)
|
||||
print("timeout waiting for hal pin %s to go to %s!" % (pin_name, value))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
|
||||
c = linuxcnc.command()
|
||||
s = linuxcnc.stat()
|
||||
e = linuxcnc.error_channel()
|
||||
|
||||
|
||||
h = hal.component("test-ui")
|
||||
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-prepare", hal.HAL_BIT, hal.HAL_IN)
|
||||
h.newpin("tool-prepared", hal.HAL_BIT, hal.HAL_OUT)
|
||||
h.newpin("tool-change", hal.HAL_BIT, hal.HAL_IN)
|
||||
h.newpin("tool-changed", hal.HAL_BIT, hal.HAL_OUT)
|
||||
h['tool-prepared'] = False
|
||||
h['tool-changed'] = False
|
||||
h.ready()
|
||||
|
||||
hal.connect('test-ui.tool-number', 'tool-number')
|
||||
hal.connect('test-ui.tool-prep-number', 'tool-prep-number')
|
||||
hal.connect('test-ui.tool-prep-pocket', 'tool-prep-pocket')
|
||||
|
||||
hal.connect('test-ui.tool-prepare', 'tool-prepare')
|
||||
hal.connect('test-ui.tool-prepared', 'tool-prepared')
|
||||
hal.connect('test-ui.tool-change', 'tool-change')
|
||||
hal.connect('test-ui.tool-changed', 'tool-changed')
|
||||
|
||||
|
||||
# Wait for LinuxCNC to initialize itself so the Status buffer stabilizes.
|
||||
wait_for_linuxcnc_startup(s)
|
||||
|
||||
c.state(linuxcnc.STATE_ESTOP_RESET)
|
||||
c.state(linuxcnc.STATE_ON)
|
||||
c.home(-1)
|
||||
c.wait_complete()
|
||||
|
||||
c.mode(linuxcnc.MODE_MDI)
|
||||
|
||||
|
||||
#
|
||||
# Starting state should be sane.
|
||||
#
|
||||
|
||||
verify_status_buffer(state='init', tool_in_spindle=99999)
|
||||
verify_io_pins(state='init', tool_number=99999, tool_prep_number=0, tool_prep_pocket=0)
|
||||
verify_interp_vars(state='init', current_tool=99999, current_pocket=0, selected_tool=0, selected_pocket=-1)
|
||||
|
||||
|
||||
#
|
||||
# After "T1" prepares the tool.
|
||||
#
|
||||
|
||||
c.mdi('T1')
|
||||
wait_for_hal_pin('tool-prepare', True)
|
||||
h['tool-prepared'] = True
|
||||
wait_for_hal_pin('tool-prepare', False)
|
||||
h['tool-prepared'] = False
|
||||
|
||||
verify_status_buffer(state='after T1', tool_in_spindle=99999)
|
||||
verify_io_pins(state='after T1', tool_number=99999, tool_prep_number=1, tool_prep_pocket=3)
|
||||
verify_interp_vars(state='after T1', current_tool=99999, current_pocket=0, selected_tool=1, selected_pocket=3)
|
||||
|
||||
|
||||
#
|
||||
# After "M6" changes to the prepared tool.
|
||||
#
|
||||
|
||||
c.mdi('M6')
|
||||
wait_for_hal_pin('tool-change', True)
|
||||
h['tool-changed'] = True
|
||||
wait_for_hal_pin('tool-change', False)
|
||||
h['tool-changed'] = False
|
||||
|
||||
verify_status_buffer(state='after T1 M6', tool_in_spindle=1)
|
||||
verify_io_pins(state='after T1 M6', tool_number=1, tool_prep_number=0, tool_prep_pocket=0)
|
||||
verify_interp_vars(state='after T1 M6', current_tool=1, current_pocket=0, selected_tool=1, selected_pocket=-1)
|
||||
|
||||
|
||||
#
|
||||
# After "T10" prepares the tool.
|
||||
#
|
||||
|
||||
c.mdi('T10')
|
||||
wait_for_hal_pin('tool-prepare', True)
|
||||
h['tool-prepared'] = True
|
||||
wait_for_hal_pin('tool-prepare', False)
|
||||
h['tool-prepared'] = False
|
||||
|
||||
verify_status_buffer(state='after T10', tool_in_spindle=1)
|
||||
verify_io_pins(state='after T10', tool_number=1, tool_prep_number=10, tool_prep_pocket=50)
|
||||
verify_interp_vars(state='after T10', current_tool=1, current_pocket=0, selected_tool=10, selected_pocket=50)
|
||||
|
||||
|
||||
#
|
||||
# After "M6" changes to the prepared tool.
|
||||
#
|
||||
|
||||
c.mdi('M6')
|
||||
wait_for_hal_pin('tool-change', True)
|
||||
h['tool-changed'] = True
|
||||
wait_for_hal_pin('tool-change', False)
|
||||
h['tool-changed'] = False
|
||||
|
||||
verify_status_buffer(state='after T10 M6', tool_in_spindle=10)
|
||||
verify_io_pins(state='after T10 M6', tool_number=10, tool_prep_number=0, tool_prep_pocket=0)
|
||||
verify_interp_vars(state='after T10 M6', current_tool=10, current_pocket=0, selected_tool=10, selected_pocket=-1)
|
||||
|
||||
|
||||
#
|
||||
# After "T99999" prepares a tool.
|
||||
#
|
||||
|
||||
c.mdi('T99999')
|
||||
wait_for_hal_pin('tool-prepare', True)
|
||||
h['tool-prepared'] = True
|
||||
wait_for_hal_pin('tool-prepare', False)
|
||||
h['tool-prepared'] = False
|
||||
|
||||
verify_status_buffer(state='after T99999', tool_in_spindle=10)
|
||||
verify_io_pins(state='after T99999', tool_number=10, tool_prep_number=99999, tool_prep_pocket=3)
|
||||
verify_interp_vars(state='after T99999', current_tool=10, current_pocket=0, selected_tool=99999, selected_pocket=3)
|
||||
|
||||
|
||||
#
|
||||
# After "M6" changes to the prepared tool.
|
||||
#
|
||||
|
||||
c.mdi('M6')
|
||||
wait_for_hal_pin('tool-change', True)
|
||||
h['tool-changed'] = True
|
||||
wait_for_hal_pin('tool-change', False)
|
||||
h['tool-changed'] = False
|
||||
|
||||
verify_status_buffer(state='after T99999 M6', tool_in_spindle=99999)
|
||||
verify_io_pins(state='after T99999 M6', tool_number=99999, tool_prep_number=0, tool_prep_pocket=0)
|
||||
verify_interp_vars(state='after T99999 M6', current_tool=99999, current_pocket=0, selected_tool=99999, selected_pocket=-1)
|
||||
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
111
tests/tool-info/random-with-startup-tool/test.ini
Normal file
111
tests/tool-info/random-with-startup-tool/test.ini
Normal file
@@ -0,0 +1,111 @@
|
||||
[EMC]
|
||||
# The version string for this INI file.
|
||||
VERSION = 1.1
|
||||
|
||||
DEBUG = 0x0
|
||||
#DEBUG = 0xffffffff
|
||||
|
||||
[DISPLAY]
|
||||
DISPLAY = ./test-ui.py
|
||||
|
||||
|
||||
[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]
|
||||
HALUI = halui
|
||||
HALFILE = core_sim.hal
|
||||
|
||||
[HALUI]
|
||||
#No Content
|
||||
|
||||
[TRAJ]
|
||||
|
||||
NO_FORCE_HOMING=1
|
||||
COORDINATES = XYZ
|
||||
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
|
||||
|
||||
|
||||
|
||||
[KINS]
|
||||
KINEMATICS = trivkins coordinates=XYZ
|
||||
#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
|
||||
9
tests/tool-info/random-with-startup-tool/test.sh
Executable file
9
tests/tool-info/random-with-startup-tool/test.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
set -x
|
||||
|
||||
rm -f sim.var*
|
||||
rm -f simpockets.tbl
|
||||
cp simpockets.tbl.original simpockets.tbl
|
||||
|
||||
linuxcnc -r test.ini
|
||||
|
||||
9
tests/tool-info/shared-test.sh
Executable file
9
tests/tool-info/shared-test.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
set -x
|
||||
|
||||
rm -f sim.var*
|
||||
rm -f simpockets.tbl
|
||||
cp ../simpockets.tbl .
|
||||
|
||||
linuxcnc -r test.ini
|
||||
|
||||
3
tests/tool-info/simpockets.tbl
Normal file
3
tests/tool-info/simpockets.tbl
Normal file
@@ -0,0 +1,3 @@
|
||||
T1 P1 D0.125000 Z+1.000000 ;
|
||||
T10 P3 D0.500000 Z+3.000000 ;
|
||||
T99999 P50 Z+2.000000 ;
|
||||
Reference in New Issue
Block a user