Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configs/sim/axis/remap/getting-started/python/remap.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def involute(self, **words):
self.set_errormsg("feedrate > 0 required")
return INTERP_ERROR

if equal(self.speed,0.0):
if equal(self.speed[0], 0.0):
self.set_errormsg("spindle speed > 0 required")
return INTERP_ERROR

Expand Down
2 changes: 1 addition & 1 deletion docs/src/remap/remap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ def involute(self, **words):
if equal(self.feed_rate,0.0):
return "feedrate > 0 required"

if equal(self.speed,0.0):
if equal(self.speed[0],0.0):
return "spindle speed > 0 required"

plunge = 0.1 # if Z word was given, plunge - with reduced feed
Expand Down
4 changes: 2 additions & 2 deletions nc_files/remap_lib/python-stdglue/stdglue.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ def setspeed_epilog(self,**words):
pass
#print "---------- S builtin recursion, nothing to do"
else:
self.speed = self.params["speed"]
emccanon.enqueue_SET_SPINDLE_SPEED(self.speed)
self.speed[0] = self.params["speed"]
emccanon.enqueue_SET_SPINDLE_SPEED(self.speed[0])
return INTERP_OK
except Exception,e:
self.set_errormsg("S/setspeed_epilog: %s)" % (e))
Expand Down
1 change: 1 addition & 0 deletions src/emc/rs274ngc/interp_array_types.hh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

namespace pp = pyplusplus::containers::static_sized;

typedef pp::array_1_t<double, EMCMOT_MAX_SPINDLES> spindle_speed_array, (*spindle_speed_w)(Interp &);
typedef pp::array_1_t< int, ACTIVE_G_CODES> active_g_codes_array, (*active_g_codes_w)( Interp & );
typedef pp::array_1_t< int, ACTIVE_M_CODES> active_m_codes_array, (*active_m_codes_w)( Interp & );
typedef pp::array_1_t< double, ACTIVE_SETTINGS> active_settings_array, (*active_settings_w)( Interp & );
Expand Down
28 changes: 21 additions & 7 deletions src/emc/rs274ngc/interpmodule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ namespace pp = pyplusplus::containers::static_sized;
#define IS_STRING(x) (PyObject_IsInstance(x.ptr(), (PyObject*)&PyString_Type))
#define IS_INT(x) (PyObject_IsInstance(x.ptr(), (PyObject*)&PyInt_Type))

static spindle_speed_array spindle_speed_wrapper (Interp & inst) {
return spindle_speed_array(inst._setup.speed);
}

static active_g_codes_array active_g_codes_wrapper ( Interp & inst) {
return active_g_codes_array(inst._setup.active_g_codes);
}
Expand Down Expand Up @@ -366,6 +370,14 @@ static inline double get_CC_origin_offset (Interp &interp) {
static inline void set_CC_origin_offset(Interp &interp, double value) {
interp._setup.CC_origin_offset = value;
}

static inline int get_active_spindle (Interp const & interp) {
return interp._setup.active_spindle;
}
static inline void set_active_spindle(Interp & interp, int value) {
interp._setup.active_spindle = value;
}

static inline double get_axis_offset_x (Interp &interp) {
return interp._setup.axis_offset_x;
}
Expand Down Expand Up @@ -510,12 +522,6 @@ static inline double get_rotation_xy (Interp &interp) {
static inline void set_rotation_xy(Interp &interp, double value) {
interp._setup.rotation_xy = value;
}
static inline double get_speed (Interp &interp, int spindle) {
return interp._setup.speed[spindle];
}
static inline void set_speed(Interp &interp, int spindle, double value) {
interp._setup.speed[spindle] = value;
}
static inline double get_traverse_rate (Interp &interp) {
return interp._setup.traverse_rate;
}
Expand Down Expand Up @@ -896,6 +902,7 @@ BOOST_PYTHON_MODULE(interpreter) {
.add_property("CC_axis_offset", &get_CC_axis_offset, &set_CC_axis_offset)
.add_property("CC_current", &get_CC_current, &set_CC_current)
.add_property("CC_origin_offset", &get_CC_origin_offset, &set_CC_origin_offset)
.add_property("active_spindle", &get_active_spindle, &set_active_spindle)
.add_property("axis_offset_x", &get_axis_offset_x, &set_axis_offset_x)
.add_property("axis_offset_y", &get_axis_offset_y, &set_axis_offset_y)
.add_property("axis_offset_z", &get_axis_offset_z, &set_axis_offset_z)
Expand All @@ -920,7 +927,6 @@ BOOST_PYTHON_MODULE(interpreter) {
.add_property("program_z", &get_program_z, &set_program_z)
.add_property("return_value", &get_return_value, &set_return_value)
.add_property("rotation_xy", &get_rotation_xy, &set_rotation_xy)
.add_property("speed", &get_speed, &set_speed)
.add_property("traverse_rate", &get_traverse_rate, &set_traverse_rate)
.add_property("u_axis_offset", &get_u_axis_offset, &set_u_axis_offset)
.add_property("u_origin_offset", &get_u_origin_offset, &set_u_origin_offset)
Expand Down Expand Up @@ -974,6 +980,14 @@ BOOST_PYTHON_MODULE(interpreter) {


// _setup arrays
.add_property(
"speed",
bp::make_function(
spindle_speed_w(&spindle_speed_wrapper),
bp::with_custodian_and_ward_postcall<0, 1>()
)
)

.add_property( "active_g_codes",
bp::make_function( active_g_codes_w(&active_g_codes_wrapper),
bp::with_custodian_and_ward_postcall< 0, 1 >()))
Expand Down
1 change: 1 addition & 0 deletions src/emc/rs274ngc/pyarrays.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ void export_Arrays()
using namespace boost::python;
using namespace boost;

pp::register_array_1<double, EMCMOT_MAX_SPINDLES>("SpindleSpeedArray");
pp::register_array_1< int, ACTIVE_G_CODES> ("ActiveGcodesArray" );
pp::register_array_1< int, ACTIVE_M_CODES> ("ActiveMcodesArray" );
pp::register_array_1< double, ACTIVE_SETTINGS> ("ActiveSettingsArray");
Expand Down
1 change: 1 addition & 0 deletions tests/remap/spindle/README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Test remap's ability to introspect about spindles.
35 changes: 35 additions & 0 deletions tests/remap/spindle/expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
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()
M500 P0 {
active spindle: 0
spindle speeds: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
}
7 N..... SET_SPINDLE_SPEED(0, 1000.0000)
8 N..... START_SPINDLE_CLOCKWISE(0)
M500 P1 {
active spindle: 0
spindle speeds: [1000.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
}
9 N..... SET_SPINDLE_SPEED(1, 2000.0000)
10 N..... START_SPINDLE_COUNTERCLOCKWISE(1)
M500 P2 {
active spindle: 0
spindle speeds: [1000.0, 2000.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
}
11 N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
12 N..... SET_XY_ROTATION(0.0000)
13 N..... SET_FEED_MODE(0, 0)
14 N..... SET_FEED_RATE(0.0000)
15 N..... STOP_SPINDLE_TURNING(0)
16 N..... SET_SPINDLE_MODE(0 0.0000)
17 N..... STOP_SPINDLE_TURNING(1)
18 N..... SET_SPINDLE_MODE(1 0.0000)
19 N..... STOP_SPINDLE_TURNING(2)
20 N..... SET_SPINDLE_MODE(2 0.0000)
21 N..... PROGRAM_END()
22 N..... ON_RESET()
7 changes: 7 additions & 0 deletions tests/remap/spindle/remap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from __future__ import print_function

def m500(self, **words):
print("M500 P{} {{".format(int(words['p'])))
print(" active spindle: ", self.active_spindle)
print(" spindle speeds: ", list(self.speed))
print("}")
14 changes: 14 additions & 0 deletions tests/remap/spindle/test.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[EMC]
DEBUG=0

[RS274NGC]
SUBROUTINE_PATH = .
LOG_LEVEL=0
REMAP= M500 py=m500 modalgroup=10 argspec=P

[TRAJ]
SPINDLES=3

[PYTHON]
PATH_PREPEND=.
TOPLEVEL=toplevel.py
13 changes: 13 additions & 0 deletions tests/remap/spindle/test.ngc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
M500 P0

S1000
M3

M500 P1

S2000 $1
M4 $1

M500 P2

M2
3 changes: 3 additions & 0 deletions tests/remap/spindle/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
rs274 -i test.ini -n 0 -g test.ngc 2>&1
exit $?
2 changes: 2 additions & 0 deletions tests/remap/spindle/toplevel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import interpreter
import remap