Import LinuxCNC source tree
This commit is contained in:
5
tests/remap/oword-pycall/README
Normal file
5
tests/remap/oword-pycall/README
Normal file
@@ -0,0 +1,5 @@
|
||||
Exercise a Python oword subroutine, including parameter passing and return values
|
||||
|
||||
not a remap, but it comes with the remapping code so test it here.
|
||||
|
||||
must properly return to top level
|
||||
26
tests/remap/oword-pycall/expected
Normal file
26
tests/remap/oword-pycall/expected
Normal file
@@ -0,0 +1,26 @@
|
||||
executing
|
||||
1 N..... USE_LENGTH_UNITS(CANON_UNITS_MM)
|
||||
2 N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
|
||||
3 N..... SET_G92_OFFSET(0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
|
||||
4 N..... SET_XY_ROTATION(0.0000)
|
||||
5 N..... SET_FEED_REFERENCE(CANON_XYZ)
|
||||
6 N..... ON_RESET()
|
||||
multiply: number of arguments= 2
|
||||
multiply: number of arguments= 3
|
||||
7 N..... USE_LENGTH_UNITS(CANON_UNITS_INCHES)
|
||||
8 N..... SELECT_TOOL(1)
|
||||
9 N..... STOP_SPINDLE_TURNING(0)
|
||||
10 N..... CHANGE_TOOL()
|
||||
11 N..... USE_TOOL_LENGTH_OFFSET(10.0000 0.0000 20.0000, 0.0000 0.0000 0.0000, 0.0000 0.0000 0.0000)
|
||||
12 N..... USE_TOOL_LENGTH_OFFSET(0.0000 0.0000 0.0000, 0.0000 0.0000 0.0000, 0.0000 0.0000 0.0000)
|
||||
13 N..... SET_TOOL_TABLE_ENTRY(1, 1, 20.0000 30.0000 40.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000, 0.0000, 0.0000, 0)
|
||||
14 N..... SET_TOOL_TABLE_ENTRY(0, 1, 20.0000 30.0000 40.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000, 0.0000, 0.0000, 0)
|
||||
15 N..... USE_TOOL_LENGTH_OFFSET(20.0000 30.0000 40.0000, 0.0000 0.0000 0.0000, 0.0000 0.0000 0.0000)
|
||||
16 N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
|
||||
17 N..... SET_XY_ROTATION(0.0000)
|
||||
18 N..... SET_FEED_MODE(0, 0)
|
||||
19 N..... SET_FEED_RATE(0.0000)
|
||||
20 N..... STOP_SPINDLE_TURNING(0)
|
||||
21 N..... SET_SPINDLE_MODE(0 0.0000)
|
||||
22 N..... PROGRAM_END()
|
||||
23 N..... ON_RESET()
|
||||
40
tests/remap/oword-pycall/oword.py
Normal file
40
tests/remap/oword-pycall/oword.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# This is a component of LinuxCNC
|
||||
# Copyright 2011 Michael Haberler <git@mah.priv.at>
|
||||
#
|
||||
# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Demo Python O-word subroutine - call as:
|
||||
# o<square> [5]
|
||||
# (debug, #<_value>)
|
||||
#
|
||||
# this function expects exactly one parameter from NGC and will throw an exception otherwise
|
||||
# which aint particularly bright
|
||||
def square(self,x):
|
||||
return x*x
|
||||
|
||||
# a function taking a variable number of arguments
|
||||
# o<multiply> [5] [7]
|
||||
# (debug, #<_value>)
|
||||
# o<multiply> [5] [7] [9] [16]
|
||||
# (debug, #<_value>)
|
||||
|
||||
import operator
|
||||
from functools import reduce
|
||||
|
||||
# you'd be better of doing it this way:
|
||||
def multiply(self, *args):
|
||||
print("multiply: number of arguments= {}".format(len(args)))
|
||||
return reduce(operator.mul, args)
|
||||
|
||||
18
tests/remap/oword-pycall/subs.py
Normal file
18
tests/remap/oword-pycall/subs.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# This is a component of LinuxCNC
|
||||
# Copyright 2011 Michael Haberler <git@mah.priv.at>
|
||||
#
|
||||
# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
import oword
|
||||
13
tests/remap/oword-pycall/test.ini
Normal file
13
tests/remap/oword-pycall/test.ini
Normal file
@@ -0,0 +1,13 @@
|
||||
[EMC]
|
||||
DEBUG=0
|
||||
LOG_LEVEL=0
|
||||
|
||||
[RS274NGC]
|
||||
SUBROUTINE_PATH = .
|
||||
|
||||
[PYTHON]
|
||||
PATH_PREPEND=.
|
||||
TOPLEVEL=subs.py
|
||||
|
||||
|
||||
|
||||
51
tests/remap/oword-pycall/test.ngc
Normal file
51
tests/remap/oword-pycall/test.ngc
Normal file
@@ -0,0 +1,51 @@
|
||||
; introspection acrobatics
|
||||
|
||||
;py,from interpreter import *
|
||||
;py,assert this.call_level == 0
|
||||
|
||||
o<square> call [25.0]
|
||||
;py,assert this.call_level == 0
|
||||
;py,assert this.params["_value"] == 625.0
|
||||
;py,assert this.return_value == 625.0
|
||||
|
||||
o<multiply> call [5] [6]
|
||||
;py,assert this.call_level == 0
|
||||
;py,assert this.return_value == 30.0
|
||||
;py,assert this.params["_value"] == 30.0
|
||||
|
||||
o<multiply> call [5] [6] [7]
|
||||
;py,assert this.call_level == 0
|
||||
;py,assert this.return_value == 210.0
|
||||
;py,assert this.params["_value"] == 210.0
|
||||
|
||||
|
||||
G20
|
||||
; t1 p1 x10 y0 z20
|
||||
T1M6
|
||||
G43
|
||||
;py,assert equal(this.params[5400],1.0),"loaded tool number not 1: %f" % (this.params[5400])
|
||||
;py,assert equal(this.params[5410],10.0) # diameter from tt
|
||||
|
||||
;py,assert this.params[5400] == this.tool_table[0].toolno
|
||||
;py,assert equal(this.tool_offset.x, 10.0)
|
||||
;py,assert equal(this.tool_offset.y, 0.0)
|
||||
;py,assert equal(this.tool_offset.z, 20.0)
|
||||
|
||||
;py,assert equal(this.tool_offset.x, this.tool_table[0].offset.x)
|
||||
;py,assert equal(this.tool_offset.y, this.tool_table[0].offset.y)
|
||||
;py,assert equal(this.tool_offset.z, this.tool_table[0].offset.z)
|
||||
|
||||
;py,assert equal(this.tool_offset.x, this.params[5401])
|
||||
;py,assert equal(this.tool_offset.y, this.params[5402])
|
||||
;py,assert equal(this.tool_offset.z, this.params[5403])
|
||||
|
||||
G49
|
||||
G10 L1 P1 R10 X20 Y30 Z40
|
||||
G43
|
||||
|
||||
;py,assert equal(this.tool_offset.x, 20.0)
|
||||
;py,assert equal(this.tool_offset.y, 30.0)
|
||||
;py,assert equal(this.tool_offset.z, 40.0)
|
||||
|
||||
M2
|
||||
|
||||
3
tests/remap/oword-pycall/test.sh
Executable file
3
tests/remap/oword-pycall/test.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
export PYTHONUNBUFFERED=1
|
||||
exec rs274 -t test.tbl -i test.ini -n 0 -g test.ngc 2>&1
|
||||
1
tests/remap/oword-pycall/test.tbl
Normal file
1
tests/remap/oword-pycall/test.tbl
Normal file
@@ -0,0 +1 @@
|
||||
T1 P1 D10 X10 Y0 Z20 ;
|
||||
Reference in New Issue
Block a user