diff --git a/configs/sim/qtvcp_screens/industrial_lathe_wear/industrial_lathe_wear.ini b/configs/sim/qtvcp_screens/industrial_lathe_wear/industrial_lathe_wear.ini index 877fdcb04cd..7f68bdeb8ca 100644 --- a/configs/sim/qtvcp_screens/industrial_lathe_wear/industrial_lathe_wear.ini +++ b/configs/sim/qtvcp_screens/industrial_lathe_wear/industrial_lathe_wear.ini @@ -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 @@ -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] @@ -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 diff --git a/configs/sim/qtvcp_screens/industrial_lathe_wear/remap.py b/configs/sim/qtvcp_screens/industrial_lathe_wear/remap.py index 4eb1f4a32dd..b500f0151fa 100644 --- a/configs/sim/qtvcp_screens/industrial_lathe_wear/remap.py +++ b/configs/sim/qtvcp_screens/industrial_lathe_wear/remap.py @@ -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 diff --git a/nc_files/lathe_pawn.ngc b/nc_files/lathe_pawn.ngc index a6fadf14770..57f4dad74fe 100644 --- a/nc_files/lathe_pawn.ngc +++ b/nc_files/lathe_pawn.ngc @@ -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 diff --git a/nc_files/lathe_test.ngc b/nc_files/lathe_test.ngc new file mode 100644 index 00000000000..2e2d18d5dd7 --- /dev/null +++ b/nc_files/lathe_test.ngc @@ -0,0 +1,7 @@ +G21 +G64 +G18 G8 +G0 X 2 +G1 x0 f10 +m2 + diff --git a/src/emc/rs274ngc/interp_convert.cc b/src/emc/rs274ngc/interp_convert.cc index b4a424a7590..44451f2a2a8 100644 --- a/src/emc/rs274ngc/interp_convert.cc +++ b/src/emc/rs274ngc/interp_convert.cc @@ -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) { @@ -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; diff --git a/src/emc/rs274ngc/interp_execute.cc b/src/emc/rs274ngc/interp_execute.cc index c3e9a1f3b70..11d74b21b13 100644 --- a/src/emc/rs274ngc/interp_execute.cc +++ b/src/emc/rs274ngc/interp_execute.cc @@ -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) { diff --git a/src/emc/rs274ngc/interp_internal.hh b/src/emc/rs274ngc/interp_internal.hh index dd9a8376a27..87cae3df733 100644 --- a/src/emc/rs274ngc/interp_internal.hh +++ b/src/emc/rs274ngc/interp_internal.hh @@ -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 diff --git a/src/emc/rs274ngc/rs274ngc_interp.hh b/src/emc/rs274ngc/rs274ngc_interp.hh index 3e5cd4da2e9..9eb9c9665e7 100644 --- a/src/emc/rs274ngc/rs274ngc_interp.hh +++ b/src/emc/rs274ngc/rs274ngc_interp.hh @@ -603,6 +603,7 @@ int read_inputs(setup_pointer settings); (m == 61) || \ (m == 0) || \ (m == 1) || \ + (m == 2) || \ (m == 60) || \ (m == 62) || \ (m == 63) || \ diff --git a/src/emc/rs274ngc/rs274ngc_pre.cc b/src/emc/rs274ngc/rs274ngc_pre.cc index f6b2a973086..6da28c2ed86 100644 --- a/src/emc/rs274ngc/rs274ngc_pre.cc +++ b/src/emc/rs274ngc/rs274ngc_pre.cc @@ -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); } }