Merge remote-tracking branch 'origin/2.8' into 2.9

* origin/2.8:
  interpmodule: add interpreter.active_spindle property
  add a test that uses remap to introspect about interpreter spindle state
  fixup remap stdglue, interpreter.speed is an array now
  fixup remap docs, interpreter.speed is an array now
  fix remap/gettings-started config: speed is a tuple, not a float
  interpmodule: fix `speed` property
This commit is contained in:
Sebastian Kuzminsky 2023-01-09 09:52:01 -07:00
commit 3eb1c9c5e9
13 changed files with 102 additions and 11 deletions

View file

@ -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

View file

@ -567,7 +567,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

View file

@ -69,8 +69,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 as e:
self.set_errormsg("S/setspeed_epilog: %s)" % (e))

View file

@ -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 & );

View file

@ -61,6 +61,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);
}
@ -378,6 +382,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;
}
@ -522,12 +534,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;
}
@ -926,6 +932,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)
@ -950,7 +957,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)
@ -1008,6 +1014,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 >()))

View file

@ -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");

View file

@ -0,0 +1 @@
Test remap's ability to introspect about spindles.

View file

@ -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()

View file

@ -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("}")

View file

@ -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

View file

@ -0,0 +1,13 @@
M500 P0
S1000
M3
M500 P1
S2000 $1
M4 $1
M500 P2
M2

3
tests/remap/spindle/test.sh Executable file
View file

@ -0,0 +1,3 @@
#!/bin/bash
rs274 -i test.ini -n 0 -g test.ngc 2>&1
exit $?

View file

@ -0,0 +1,2 @@
import interpreter
import remap