Import LinuxCNC source tree
This commit is contained in:
16
tests/remap/remap-io/README
Normal file
16
tests/remap/remap-io/README
Normal file
@@ -0,0 +1,16 @@
|
||||
This test verifies that M62-M68 can be remapped through both python
|
||||
and NGC, and that calling the original M-codes is supported in the
|
||||
remap subroutine.
|
||||
|
||||
It also serves as an example of how to do this, since esp. the M66
|
||||
python function is not trivial and must be a generator yielding
|
||||
`INTERP_EXECUTE_FINISH`.
|
||||
|
||||
The recursive call to the original functions needs supporting code for
|
||||
mode 5 M-codes in `interp_convert.cc` `convert_m()`, and for M62-M68
|
||||
in `rs274ngc_pre.cc`, `find_remappings()`.
|
||||
|
||||
The peculiar M66 needs special handling in the interpreter for
|
||||
`input_flag`, and to ensure that its result (in param `#5399`) is
|
||||
available within the remap, `Interp::pycall()` runs `read_inputs()`
|
||||
before returning control back to the python generator.
|
||||
60
tests/remap/remap-io/core_sim.hal
Normal file
60
tests/remap/remap-io/core_sim.hal
Normal file
@@ -0,0 +1,60 @@
|
||||
# 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
|
||||
123
tests/remap/remap-io/expected
Normal file
123
tests/remap/remap-io/expected
Normal file
@@ -0,0 +1,123 @@
|
||||
********** Testing python remaps
|
||||
----Testing M62/M63 digital output w/motion----
|
||||
cmd: "M62 P1"
|
||||
M62 remapping pre: motion dout0=0; hal d_out=0
|
||||
M62 remapping post: motion dout0=1; hal d_out=1
|
||||
cmd: "M63 P1"
|
||||
M63 remapping pre: motion dout0=1; hal d_out=1
|
||||
M63 remapping post: motion dout0=0; hal d_out=0
|
||||
cmd: "M62 P1"
|
||||
M62 remapping pre: motion dout0=0; hal d_out=0
|
||||
M62 remapping post: motion dout0=1; hal d_out=1
|
||||
cmd: "M63 P1"
|
||||
M63 remapping pre: motion dout0=1; hal d_out=1
|
||||
M63 remapping post: motion dout0=0; hal d_out=0
|
||||
----Testing M64/M65 digital output, immediate----
|
||||
cmd: "M64 P1"
|
||||
M64 remapping pre: motion dout0=0; hal d_out=0
|
||||
M64 remapping post: motion dout0=1; hal d_out=1
|
||||
cmd: "M65 P1"
|
||||
M65 remapping pre: motion dout0=1; hal d_out=1
|
||||
M65 remapping post: motion dout0=0; hal d_out=0
|
||||
cmd: "M64 P1"
|
||||
M64 remapping pre: motion dout0=0; hal d_out=0
|
||||
M64 remapping post: motion dout0=1; hal d_out=1
|
||||
cmd: "M65 P1"
|
||||
M65 remapping pre: motion dout0=1; hal d_out=1
|
||||
M65 remapping post: motion dout0=0; hal d_out=0
|
||||
----Testing M66 digital input----
|
||||
cmd: "M66 P1"; input: 1.0000
|
||||
M66 remapping pre: 5399=0.000000; 100=0.000000; ain0=0.00; din0=0
|
||||
M66 remapping post: 5399=1.000000; 100=1.000000; ain0=0.00; din0=1
|
||||
cmd: "M66 P1"; input: 0.0000
|
||||
M66 remapping pre: 5399=1.000000; 100=1.000000; ain0=0.00; din0=1
|
||||
M66 remapping post: 5399=0.000000; 100=0.000000; ain0=0.00; din0=0
|
||||
----Testing M66 analog input----
|
||||
cmd: "M66 E1 L0"; input: 42.1300
|
||||
M66 remapping pre: 5399=0.000000; 100=0.000000; ain0=0.00; din0=0
|
||||
M66 remapping post: 5399=42.130000; 100=42.130000; ain0=42.13; din0=0
|
||||
cmd: "M66 E1 L0"; input: -13.4200
|
||||
M66 remapping pre: 5399=42.130000; 100=42.130000; ain0=42.13; din0=0
|
||||
M66 remapping post: 5399=-13.420000; 100=-13.420000; ain0=-13.42; din0=0
|
||||
----Testing M67 analog output w/motion----
|
||||
cmd: "M67 E1 Q42.13"
|
||||
M67 remapping pre: motion aout0=0.00; hal a_out=0.00
|
||||
M67 remapping post: motion aout0=42.13; hal a_out=42.13
|
||||
cmd: "M67 E1 Q-13.42"
|
||||
M67 remapping pre: motion aout0=42.13; hal a_out=42.13
|
||||
M67 remapping post: motion aout0=-13.42; hal a_out=-13.42
|
||||
cmd: "M67 E1 Q0.00"
|
||||
M67 remapping pre: motion aout0=-13.42; hal a_out=-13.42
|
||||
M67 remapping post: motion aout0=0.00; hal a_out=0.00
|
||||
----Testing M68 analog output, immediate----
|
||||
cmd: "M68 E1 Q42.13"
|
||||
M68 remapping pre: motion aout0=0.00; hal a_out=0.00
|
||||
M68 remapping post: motion aout0=42.13; hal a_out=42.13
|
||||
cmd: "M68 E1 Q-13.42"
|
||||
M68 remapping pre: motion aout0=42.13; hal a_out=42.13
|
||||
M68 remapping post: motion aout0=-13.42; hal a_out=-13.42
|
||||
cmd: "M68 E1 Q0.00"
|
||||
M68 remapping pre: motion aout0=-13.42; hal a_out=-13.42
|
||||
M68 remapping post: motion aout0=0.00; hal a_out=0.00
|
||||
|
||||
********** Testing ngc remaps
|
||||
----Testing M62/M63 digital output w/motion----
|
||||
cmd: "M62 P1"
|
||||
M62 remapping pre: motion dout0=0; hal d_out=0
|
||||
M62 remapping post: motion dout0=1; hal d_out=1
|
||||
cmd: "M63 P1"
|
||||
M63 remapping pre: motion dout0=1; hal d_out=1
|
||||
M63 remapping post: motion dout0=0; hal d_out=0
|
||||
cmd: "M62 P1"
|
||||
M62 remapping pre: motion dout0=0; hal d_out=0
|
||||
M62 remapping post: motion dout0=1; hal d_out=1
|
||||
cmd: "M63 P1"
|
||||
M63 remapping pre: motion dout0=1; hal d_out=1
|
||||
M63 remapping post: motion dout0=0; hal d_out=0
|
||||
----Testing M64/M65 digital output, immediate----
|
||||
cmd: "M64 P1"
|
||||
M64 remapping pre: motion dout0=0; hal d_out=0
|
||||
M64 remapping post: motion dout0=1; hal d_out=1
|
||||
cmd: "M65 P1"
|
||||
M65 remapping pre: motion dout0=1; hal d_out=1
|
||||
M65 remapping post: motion dout0=0; hal d_out=0
|
||||
cmd: "M64 P1"
|
||||
M64 remapping pre: motion dout0=0; hal d_out=0
|
||||
M64 remapping post: motion dout0=1; hal d_out=1
|
||||
cmd: "M65 P1"
|
||||
M65 remapping pre: motion dout0=1; hal d_out=1
|
||||
M65 remapping post: motion dout0=0; hal d_out=0
|
||||
----Testing M66 digital input----
|
||||
cmd: "M66 P1"; input: 1.0000
|
||||
M66 remapping pre: 5399=0.000000; 100=0.000000; ain0=0.00; din0=0
|
||||
M66 remapping post: 5399=1.000000; 100=1.000000; ain0=0.00; din0=1
|
||||
cmd: "M66 P1"; input: 0.0000
|
||||
M66 remapping pre: 5399=1.000000; 100=1.000000; ain0=0.00; din0=1
|
||||
M66 remapping post: 5399=0.000000; 100=0.000000; ain0=0.00; din0=0
|
||||
----Testing M66 analog input----
|
||||
cmd: "M66 E1 L0"; input: 42.1300
|
||||
M66 remapping pre: 5399=0.000000; 100=0.000000; ain0=0.00; din0=0
|
||||
M66 remapping post: 5399=42.130000; 100=42.130000; ain0=42.13; din0=0
|
||||
cmd: "M66 E1 L0"; input: -13.4200
|
||||
M66 remapping pre: 5399=42.130000; 100=42.130000; ain0=42.13; din0=0
|
||||
M66 remapping post: 5399=-13.420000; 100=-13.420000; ain0=-13.42; din0=0
|
||||
----Testing M67 analog output w/motion----
|
||||
cmd: "M67 E1 Q42.13"
|
||||
M67 remapping pre: motion aout0=0.00; hal a_out=0.00
|
||||
M67 remapping post: motion aout0=42.13; hal a_out=42.13
|
||||
cmd: "M67 E1 Q-13.42"
|
||||
M67 remapping pre: motion aout0=42.13; hal a_out=42.13
|
||||
M67 remapping post: motion aout0=-13.42; hal a_out=-13.42
|
||||
cmd: "M67 E1 Q0.00"
|
||||
M67 remapping pre: motion aout0=-13.42; hal a_out=-13.42
|
||||
M67 remapping post: motion aout0=0.00; hal a_out=0.00
|
||||
----Testing M68 analog output, immediate----
|
||||
cmd: "M68 E1 Q42.13"
|
||||
M68 remapping pre: motion aout0=0.00; hal a_out=0.00
|
||||
M68 remapping post: motion aout0=42.13; hal a_out=42.13
|
||||
cmd: "M68 E1 Q-13.42"
|
||||
M68 remapping pre: motion aout0=42.13; hal a_out=42.13
|
||||
M68 remapping post: motion aout0=-13.42; hal a_out=-13.42
|
||||
cmd: "M68 E1 Q0.00"
|
||||
M68 remapping pre: motion aout0=-13.42; hal a_out=-13.42
|
||||
M68 remapping post: motion aout0=0.00; hal a_out=0.00
|
||||
13
tests/remap/remap-io/io_input_m66.ngc
Normal file
13
tests/remap/remap-io/io_input_m66.ngc
Normal file
@@ -0,0 +1,13 @@
|
||||
o<io_input_M66> sub
|
||||
(debug,X io_input_M66 remapping pre: 5399=#5399)
|
||||
o<analog_or_digital> if [EXISTS[#<e>]]
|
||||
; analog input
|
||||
M66 E0 L0
|
||||
o<analog_or_digital> else
|
||||
; digital input
|
||||
M66 P0 L0
|
||||
o<analog_or_digital> endif
|
||||
; Result should be available here after M66; save it for test to check
|
||||
#100 = #5399
|
||||
(debug,X io_input_M66 remapping post: 5399=#5399)
|
||||
o<io_input_M66> endsub
|
||||
5
tests/remap/remap-io/io_output_m62.ngc
Normal file
5
tests/remap/remap-io/io_output_m62.ngc
Normal file
@@ -0,0 +1,5 @@
|
||||
o<io_output_M62> sub
|
||||
(debug,X io_output_M62 remapping pre: 5399=#5399)
|
||||
M62 P0
|
||||
(debug,X io_output_M62 remapping post: 5399=#5399)
|
||||
o<io_output_M62> endsub
|
||||
3
tests/remap/remap-io/io_output_m63.ngc
Normal file
3
tests/remap/remap-io/io_output_m63.ngc
Normal file
@@ -0,0 +1,3 @@
|
||||
o<io_output_M63> sub
|
||||
M63 P0
|
||||
o<io_output_M63> endsub
|
||||
3
tests/remap/remap-io/io_output_m64.ngc
Normal file
3
tests/remap/remap-io/io_output_m64.ngc
Normal file
@@ -0,0 +1,3 @@
|
||||
o<io_output_M64> sub
|
||||
M64 P0
|
||||
o<io_output_M64> endsub
|
||||
3
tests/remap/remap-io/io_output_m65.ngc
Normal file
3
tests/remap/remap-io/io_output_m65.ngc
Normal file
@@ -0,0 +1,3 @@
|
||||
o<io_output_M65> sub
|
||||
M65 P0
|
||||
o<io_output_M65> endsub
|
||||
3
tests/remap/remap-io/io_output_m67.ngc
Normal file
3
tests/remap/remap-io/io_output_m67.ngc
Normal file
@@ -0,0 +1,3 @@
|
||||
o<io_output_M67> sub
|
||||
M67 E0 Q#<Q>
|
||||
o<io_output_M67> endsub
|
||||
3
tests/remap/remap-io/io_output_m68.ngc
Normal file
3
tests/remap/remap-io/io_output_m68.ngc
Normal file
@@ -0,0 +1,3 @@
|
||||
o<io_output_M68> sub
|
||||
M68 E0 Q#<Q>
|
||||
o<io_output_M68> endsub
|
||||
9
tests/remap/remap-io/postgui.hal
Normal file
9
tests/remap/remap-io/postgui.hal
Normal file
@@ -0,0 +1,9 @@
|
||||
# net analog and digital in signals to test-ui pin for m66
|
||||
net a_in-0 test-ui.a_in => motion.analog-in-00
|
||||
net d_in-0 test-ui.d_in => motion.digital-in-00
|
||||
|
||||
# net digital out to test-ui pin for m62-m65
|
||||
net d_out-0 motion.digital-out-00 => test-ui.d_out
|
||||
|
||||
# net analog out to test-ui pin for m67, m68
|
||||
net a_out-0 motion.analog-out-00 => test-ui.a_out
|
||||
50
tests/remap/remap-io/remap.py
Normal file
50
tests/remap/remap-io/remap.py
Normal file
@@ -0,0 +1,50 @@
|
||||
import linuxcnc
|
||||
import emccanon
|
||||
import interpreter
|
||||
|
||||
def init_stdglue(self):
|
||||
pass
|
||||
|
||||
def io_output_M62(self,**words):
|
||||
|
||||
self.execute("M62 P0")
|
||||
return interpreter.INTERP_OK
|
||||
|
||||
def io_output_M63(self,**words):
|
||||
|
||||
self.execute("M63 P0")
|
||||
return interpreter.INTERP_OK
|
||||
|
||||
def io_output_M64(self,**words):
|
||||
|
||||
self.execute("M64 P0")
|
||||
return interpreter.INTERP_OK
|
||||
|
||||
def io_output_M65(self,**words):
|
||||
|
||||
self.execute("M65 P0")
|
||||
return interpreter.INTERP_OK
|
||||
|
||||
def io_input_M66(self,**words):
|
||||
|
||||
self.execute("M66 %(inp)s%(wait_mode)s" % dict(
|
||||
inp = ("P0" if 'p' in words else "E0"),
|
||||
wait_mode = (" L%d" % words['l'] if 'l' in words else ""),
|
||||
))
|
||||
yield interpreter.INTERP_EXECUTE_FINISH
|
||||
|
||||
# Result should be available after yield; save it for test to check
|
||||
self.params[100] = self.params[5399]
|
||||
yield interpreter.INTERP_OK
|
||||
|
||||
|
||||
def io_output_M67(self,**words):
|
||||
|
||||
self.execute("M67 E0 Q%.2f" % words['q'])
|
||||
return interpreter.INTERP_OK
|
||||
|
||||
def io_output_M68(self,**words):
|
||||
|
||||
self.execute("M68 E0 Q%.2f" % words['q'])
|
||||
return interpreter.INTERP_OK
|
||||
|
||||
3
tests/remap/remap-io/simpockets.tbl
Normal file
3
tests/remap/remap-io/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 ;
|
||||
129
tests/remap/remap-io/test-ngc.ini
Normal file
129
tests/remap/remap-io/test-ngc.ini
Normal file
@@ -0,0 +1,129 @@
|
||||
# This config file was created 2017-05-10 09:59:22.679734 by the update_ini script
|
||||
# The original config files may be found in the /home/jepler/src/linuxcnc/master/tests/remap/remap-io/test-ngc.old directory
|
||||
|
||||
[EMC]
|
||||
# The version string for this INI file.
|
||||
VERSION = 1.1
|
||||
|
||||
DEBUG = 0x0
|
||||
|
||||
[DISPLAY]
|
||||
DISPLAY = ./test-ui.py
|
||||
|
||||
[FILTER]
|
||||
#No Content
|
||||
|
||||
[RS274NGC]
|
||||
PARAMETER_FILE = sim.var
|
||||
SUBROUTINE_PATH = .
|
||||
REMAP= M62 modalgroup=5 argspec=P ngc=io_output_m62
|
||||
REMAP= M63 modalgroup=5 argspec=P ngc=io_output_m63
|
||||
REMAP= M64 modalgroup=5 argspec=P ngc=io_output_m64
|
||||
REMAP= M65 modalgroup=5 argspec=P ngc=io_output_m65
|
||||
REMAP= M66 modalgroup=5 argspec=pelq ngc=io_input_m66
|
||||
REMAP= M67 modalgroup=5 argspec=EQ ngc=io_output_m67
|
||||
REMAP= M68 modalgroup=5 argspec=EQ ngc=io_output_m68
|
||||
|
||||
[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
|
||||
AXES = 3
|
||||
COORDINATES = X Y Z
|
||||
HOME = 0 0 0
|
||||
LINEAR_UNITS = inch
|
||||
ANGULAR_UNITS = degree
|
||||
DEFAULT_LINEAR_VELOCITY = 1.2
|
||||
MAX_LINEAR_VELOCITY = 4
|
||||
|
||||
[EMCIO]
|
||||
TOOL_TABLE = simpockets.tbl
|
||||
TOOL_CHANGE_QUILL_UP = 1
|
||||
RANDOM_TOOLCHANGER = 0
|
||||
|
||||
|
||||
|
||||
[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
|
||||
|
||||
[PYTHON]
|
||||
|
||||
TOPLEVEL= toplevel.py
|
||||
PATH_PREPEND= .
|
||||
129
tests/remap/remap-io/test-py.ini
Normal file
129
tests/remap/remap-io/test-py.ini
Normal file
@@ -0,0 +1,129 @@
|
||||
# This config file was created 2017-05-10 09:59:11.447475 by the update_ini script
|
||||
# The original config files may be found in the /home/jepler/src/linuxcnc/master/tests/remap/remap-io/test-py.old directory
|
||||
|
||||
[EMC]
|
||||
# The version string for this INI file.
|
||||
VERSION = 1.1
|
||||
|
||||
DEBUG = 0x0
|
||||
|
||||
[DISPLAY]
|
||||
DISPLAY = ./test-ui.py
|
||||
|
||||
[FILTER]
|
||||
#No Content
|
||||
|
||||
[RS274NGC]
|
||||
PARAMETER_FILE = sim.var
|
||||
SUBROUTINE_PATH = .
|
||||
REMAP= M62 modalgroup=5 argspec=P py=io_output_M62
|
||||
REMAP= M63 modalgroup=5 argspec=P py=io_output_M63
|
||||
REMAP= M64 modalgroup=5 argspec=P py=io_output_M64
|
||||
REMAP= M65 modalgroup=5 argspec=P py=io_output_M65
|
||||
REMAP= M66 modalgroup=5 argspec=pelq py=io_input_M66
|
||||
REMAP= M67 modalgroup=5 argspec=EQ py=io_output_M67
|
||||
REMAP= M68 modalgroup=5 argspec=EQ py=io_output_M68
|
||||
|
||||
[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
|
||||
AXES = 3
|
||||
COORDINATES = X Y Z
|
||||
HOME = 0 0 0
|
||||
LINEAR_UNITS = inch
|
||||
ANGULAR_UNITS = degree
|
||||
DEFAULT_LINEAR_VELOCITY = 1.2
|
||||
MAX_LINEAR_VELOCITY = 4
|
||||
|
||||
[EMCIO]
|
||||
TOOL_TABLE = simpockets.tbl
|
||||
TOOL_CHANGE_QUILL_UP = 1
|
||||
RANDOM_TOOLCHANGER = 0
|
||||
|
||||
|
||||
|
||||
[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
|
||||
|
||||
[PYTHON]
|
||||
|
||||
TOPLEVEL= toplevel.py
|
||||
PATH_PREPEND= .
|
||||
154
tests/remap/remap-io/test-ui.py
Executable file
154
tests/remap/remap-io/test-ui.py
Executable file
@@ -0,0 +1,154 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import linuxcnc, hal
|
||||
import sys, os
|
||||
|
||||
# Set up pins
|
||||
h = hal.component("test-ui")
|
||||
h.newpin('d_out', hal.HAL_BIT, hal.HAL_IN) # pin for reading digital out
|
||||
h.newpin('a_out', hal.HAL_FLOAT, hal.HAL_IN) # pin for reading analog out
|
||||
h.newpin('d_in', hal.HAL_BIT, hal.HAL_OUT) # pin for setting digital in
|
||||
h.newpin('a_in', hal.HAL_FLOAT, hal.HAL_OUT) # pin for setting analog in
|
||||
h.ready() # mark the component as 'ready'
|
||||
os.system('halcmd source postgui.hal') # Net above pins to motion I/O pins
|
||||
|
||||
# Initialization
|
||||
c = linuxcnc.command()
|
||||
s = linuxcnc.stat()
|
||||
c.state(linuxcnc.STATE_ESTOP_RESET)
|
||||
c.state(linuxcnc.STATE_ON)
|
||||
c.mode(linuxcnc.MODE_MDI)
|
||||
|
||||
|
||||
###################################################
|
||||
# M62-M65 digital out
|
||||
|
||||
def do_dout(on=True, mpos=None):
|
||||
# Set up command
|
||||
#
|
||||
# for sanity, specify output 1, changed to 0 in remap
|
||||
code = 64 + int(not on) - 2*int(mpos is not None)
|
||||
cmd = 'M%d P1' % code
|
||||
|
||||
# Print pre-test values
|
||||
s.poll() # Update status channel
|
||||
c.mdi('(print,cmd: "%s")' % cmd)
|
||||
c.mdi('(print, M%d remapping pre: motion dout0=%d; hal d_out=%d)' %
|
||||
(code, s.dout[0], h['d_out']))
|
||||
|
||||
# Run test command
|
||||
c.mdi(cmd)
|
||||
if mpos is not None:
|
||||
c.mdi('G0 X%.2f' % mpos)
|
||||
c.wait_complete()
|
||||
|
||||
# Print post-test values
|
||||
s.poll() # Update status channel
|
||||
c.mdi('(print, M%d remapping post: motion dout0=%d; hal d_out=%d)' %
|
||||
(code, s.dout[0], h['d_out']))
|
||||
|
||||
# M62/M63 test: toggle DIO w/motion & verify
|
||||
c.mdi('(print,----Testing M62/M63 digital output w/motion----)')
|
||||
do_dout(on=True, mpos=1.0) # M62
|
||||
do_dout(on=False, mpos=2.0) # M63
|
||||
do_dout(on=True, mpos=3.0) # M62
|
||||
do_dout(on=False, mpos=4.0) # M63
|
||||
|
||||
# M64/M65 test: toggle DIO & verify
|
||||
c.mdi('(print,----Testing M64/M65 digital output, immediate----)')
|
||||
do_dout(on=True) # M64
|
||||
do_dout(on=False) # M65
|
||||
do_dout(on=True) # M64
|
||||
do_dout(on=False) # M65
|
||||
|
||||
###################################################
|
||||
# M66 wait on input
|
||||
|
||||
# These tests don't exercise the L- and Q-words, despite partial
|
||||
# plumbing being there
|
||||
|
||||
def do_in(inp, d_in=True, wait_mode=None, timeout=None):
|
||||
# Set up M66 command
|
||||
cmd = 'M66 %(ad_in)s%(wait_mode)s%(timeout)s' % dict(
|
||||
# for sanity, specify input 1, changed to 0 in remap
|
||||
ad_in = ('P1' if d_in else 'E1'),
|
||||
wait_mode = (' L%d' % wait_mode if wait_mode is not None else ''),
|
||||
timeout = (' Q%d' % timeout if timeout is not None else ''),
|
||||
)
|
||||
|
||||
# Set input pin
|
||||
if d_in:
|
||||
h['d_in'] = inp
|
||||
else:
|
||||
h['a_in'] = inp
|
||||
|
||||
# Print pre-test values
|
||||
s.poll() # Update status channel
|
||||
c.mdi('(print,cmd: "%s"; input: %.4f)' % (cmd, inp))
|
||||
c.mdi('(print, M66 remapping pre: 5399=#5399; 100=#100; '
|
||||
'ain0=%.2f; din0=%d)' % (s.ain[0], s.din[0]))
|
||||
|
||||
# Run test command and wait for it
|
||||
c.mdi(cmd)
|
||||
c.wait_complete()
|
||||
|
||||
# Print post-test values
|
||||
s.poll() # Update status channel
|
||||
c.mdi('(print, M66 remapping post: 5399=#5399; 100=#100; '
|
||||
'ain0=%.2f; din0=%d)' % (s.ain[0], s.din[0]))
|
||||
|
||||
# Run test cases
|
||||
#
|
||||
# Digital input
|
||||
c.mdi('(print,----Testing M66 digital input----)')
|
||||
do_in(1, d_in=True)
|
||||
do_in(0, d_in=True)
|
||||
# Analog input
|
||||
c.mdi('(print,----Testing M66 analog input----)')
|
||||
do_in(42.13, d_in=False, wait_mode=0)
|
||||
do_in(-13.42, d_in=False, wait_mode=0)
|
||||
|
||||
###################################################
|
||||
# M67-M68 analog out
|
||||
|
||||
def do_aout(out_val, mpos=None):
|
||||
# Set up command
|
||||
#
|
||||
# for sanity, specify output 1, changed to 0 in remap
|
||||
code = 67 + int(mpos is None)
|
||||
cmd = 'M%d E1 Q%.2f' % (code, out_val)
|
||||
|
||||
# Print pre-test values
|
||||
s.poll() # Update status channel
|
||||
c.mdi('(print,cmd: "%s")' % cmd)
|
||||
c.mdi('(print, M%d remapping pre: motion aout0=%.2f; hal a_out=%.2f)' %
|
||||
(code, s.aout[0], h['a_out']))
|
||||
|
||||
# Run test command
|
||||
c.mdi(cmd)
|
||||
if mpos is not None:
|
||||
c.mdi('G0 X%.2f' % mpos)
|
||||
c.wait_complete()
|
||||
|
||||
# Print post-test values
|
||||
s.poll() # Update status channel
|
||||
c.mdi('(print, M%d remapping post: motion aout0=%.2f; hal a_out=%.2f)' %
|
||||
(code, s.aout[0], h['a_out']))
|
||||
|
||||
# M67 test: set AIO w/motion & verify
|
||||
c.mdi('(print,----Testing M67 analog output w/motion----)')
|
||||
do_aout(42.13, mpos=-1.0)
|
||||
do_aout(-13.42, mpos=-2.0)
|
||||
do_aout(0.0, mpos=-3.0)
|
||||
|
||||
# M68 test: set AIO (immed.) & verify
|
||||
c.mdi('(print,----Testing M68 analog output, immediate----)')
|
||||
do_aout(42.13)
|
||||
do_aout(-13.42)
|
||||
do_aout(0.0)
|
||||
|
||||
###################################################
|
||||
# Shutdown
|
||||
c.wait_complete()
|
||||
sys.exit(0)
|
||||
|
||||
13
tests/remap/remap-io/test.sh
Executable file
13
tests/remap/remap-io/test.sh
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash -e
|
||||
export PYTHONUNBUFFERED=1
|
||||
do_test() {
|
||||
INI="$1"
|
||||
linuxcnc -r "$INI" | grep -i m6
|
||||
}
|
||||
|
||||
echo "********** Testing python remaps"
|
||||
do_test test-py.ini
|
||||
echo
|
||||
echo "********** Testing ngc remaps"
|
||||
do_test test-ngc.ini
|
||||
|
||||
5
tests/remap/remap-io/toplevel.py
Executable file
5
tests/remap/remap-io/toplevel.py
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
import remap
|
||||
|
||||
def __init__(self):
|
||||
remap.init_stdglue(self)
|
||||
Reference in New Issue
Block a user