Skip to content

Commit

Permalink
remap m2 work
Browse files Browse the repository at this point in the history
The remap works but having the remap call the builtin doesn't yet.
  • Loading branch information
c-morley committed Sep 1, 2020
1 parent c207d3c commit 74d7ac6
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[EMC]
VERSION = 1.1
MACHINE = LinuxCNC-HAL-SIM-AXIS
DEBUG = 0

#DEBUG = 0x7FFFFFFF
DEBUG = 0x00004000
[DISPLAY]
DISPLAY = qtvcp -d qtlathe
PREFERENCE_FILE_PATH = WORKINGFOLDER/qtlathe.pref
Expand Down Expand Up @@ -38,6 +38,7 @@ PROGRAM_EXTENSION = .py Python Script
SUBROUTINE_PATH = ./:../:~/linuxcnc/nc_files/macros/lathe:~/linuxcnc/nc_files/examples/macros/lathe
REMAP=T python=index_lathe_tool_with_wear
REMAP=M6 python=ignore_m6
REMAP=M2 python=m2_remap modalgroup=4
PARAMETER_FILE = sim.var

[PYTHON]
Expand All @@ -51,7 +52,7 @@ PATH_APPEND=../../nc_files/remap_lib/python-stdglue/
TOPLEVEL=toplevel.py

# the higher the more verbose tracing of the Python plugin
LOG_LEVEL = 0
LOG_LEVEL = 100

[EMCMOT]
EMCMOT = motmod
Expand Down
19 changes: 19 additions & 0 deletions configs/sim/qtvcp_screens/industrial_lathe_wear/remap.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,23 @@
# ignore_m6()

from stdglue import *
from emccanon import MESSAGE
COUNT = 0

def ignore_m6(self,**words):
MESSAGE("remapped m6")
try:
return INTERP_OK
except Exception, e:
return "Ignore M6 failed: %s" % (e)

def m2_remap(self, **words): # in remap module
print self.remap_level
global COUNT
COUNT +=1
print 'run count:{}'.format(COUNT)

#MESSAGE("remapped m2")
self.execute("m2")
#emccanon.PROGRAM_END()
return INTERP_OK
1 change: 1 addition & 0 deletions nc_files/lathe_pawn.ngc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
G21
G64
G18 G8
t201
G00 X13.5 Z1.0 S1000 M3
Z0.488
G94 G01 X-1.0 F50.0
Expand Down
7 changes: 7 additions & 0 deletions nc_files/lathe_test.ngc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
G21
G64
G18 G8
G0 X 2
G1 x0 f10
m2

19 changes: 18 additions & 1 deletion src/emc/rs274ngc/interp_convert.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4256,6 +4256,8 @@ int Interp::convert_stop(block_pointer block, //!< pointer to a block of RS27
// convert_control_functions()
CHKS((block->m_modes[4] == 99 && settings->call_level > 0),
(_("Bug: Reached convert_stop() from M99 as subprogram return")));


if (block->m_modes[4] == 0) {
PROGRAM_STOP();
} else if (block->m_modes[4] == 60) {
Expand All @@ -4271,9 +4273,24 @@ int Interp::convert_stop(block_pointer block, //!< pointer to a block of RS27
loop_to_beginning(settings); // return control to beginning of file
FINISH(); // Output any final linked segments
return INTERP_EXECUTE_FINISH; // tell task to issue any queued commands




} else if ((block->m_modes[4] == 2) || (block->m_modes[4] == 30) ||
(block->m_modes[4] == 99 && !_setup.loop_on_main_m99)
) { /* reset stuff here */
) {


if (IS_USER_MCODE(block,settings,4) &&
STEP_REMAPPED_IN_BLOCK(block, STEP_MGROUP4) &&
ONCE_M4) {
printf("*remap conversion-%d*\n",block->m_modes[4]);
return convert_remapped_code(block, settings, STEP_MGROUP4, 'm',
block->m_modes[4]);}

printf("*no remap conversion-%d*\n",block->m_modes[4]);
/* reset stuff here */

/*1*/
settings->current_x += settings->origin_offset_x;
Expand Down
2 changes: 2 additions & 0 deletions src/emc/rs274ngc/interp_execute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,10 @@ int Interp::execute_block(block_pointer block, //!< pointer to a block of RS27
/* convert m0, m1, m2, m30, m60, or (when main program loops disabled) m99 */
if ((block->m_modes[4] != -1) && ONCE(STEP_MGROUP4)) {
if (STEP_REMAPPED_IN_BLOCK(block, STEP_MGROUP4)) {
printf("*-----------------------------------------%d*\n",block->m_modes[4]);
status = convert_remapped_code(block,settings,STEP_MGROUP4,'M',block->m_modes[4]);
} else {
printf("*Nope----------------------------------------%d*\n",block->m_modes[4]);
status = convert_stop(block, settings);
}
if (status == INTERP_EXIT) {
Expand Down
2 changes: 1 addition & 1 deletion src/emc/rs274ngc/interp_internal.hh
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ struct block_struct
#define TODO(step) (block->breadcrumbs[step] == 0)
#define ONCE(step) (TODO(step) ? TICKOFF(step),1 : 0)
#define ONCE_M(step) (TODO(STEP_M_ ## step) ? TICKOFF(STEP_M_ ## step),1 : 0)

#define ONCE_M4 (TODO(STEP_MGROUP4) ? TICKOFF(STEP_MGROUP4),1 : 0)

// there might be several remapped items in a block, but at any point
// in time there's only one excuting
Expand Down
1 change: 1 addition & 0 deletions src/emc/rs274ngc/rs274ngc_interp.hh
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ int read_inputs(setup_pointer settings);
(m == 61) || \
(m == 0) || \
(m == 1) || \
(m == 2) || \
(m == 60) || \
(m == 62) || \
(m == 63) || \
Expand Down
5 changes: 4 additions & 1 deletion src/emc/rs274ngc/rs274ngc_pre.cc
Original file line number Diff line number Diff line change
Expand Up @@ -731,13 +731,16 @@ int Interp::find_remappings(block_pointer block, setup_pointer settings)

if (remap_in_progress("M0") ||
remap_in_progress("M1") ||
remap_in_progress("M2") ||
remap_in_progress("M60")) { // detect recursion case

// these require real work.
// remap_in_progress("M2") ||
//remap_in_progress("M2") ||
// remap_in_progress("M60")
printf("*---builtin -------%d*\n",block->m_modes[4]);
CONTROLLING_BLOCK(*settings).builtin_used = true;
} else {
printf("*---remappped -------%d*\n",block->m_modes[4]);
block->remappings.insert(STEP_MGROUP4);
}
}
Expand Down

0 comments on commit 74d7ac6

Please sign in to comment.