Skip to content

Commit 46de036

Browse files
authored
Merge pull request #3732 from rmu75/rs-amend-3560
Add Stepping Status to emcmodule
2 parents 8502ed4 + 5ac53b4 commit 46de036

5 files changed

Lines changed: 45 additions & 30 deletions

File tree

docs/src/config/python-interface.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,9 @@ see <<python:reading-ini-values,ReadingINI file values>> for an example.
278278
*paused*:: '(returns boolean)' -
279279
`motion paused` flag.
280280

281+
*single_stepping*:: '(returns boolean)' -
282+
`motion single_stepping` flag.
283+
281284
*pocket_prepped*:: '(returns integer)' -
282285
A Tx command completed, and this pocket is prepared. -1 if no
283286
prepared pocket.

src/emc/nml_intf/emc.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,6 +1704,7 @@ void EMC_TRAJ_STAT::update(CMS * cms)
17041704
cms->update(queueFull);
17051705
cms->update(id);
17061706
cms->update(paused);
1707+
cms->update(single_stepping);
17071708
cms->update(scale);
17081709
cms->update(rapid_scale);
17091710
EmcPose_update(cms, &position);

src/emc/nml_intf/emc_nml.hh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -794,8 +794,8 @@ class EMC_TRAJ_SET_TERM_COND:public EMC_TRAJ_CMD_MSG {
794794
void update(CMS * cms);
795795

796796
int cond;
797-
double tolerance; // used to set the precision/tolerance of path deviation
798-
// during CONTINUOUS motion mode.
797+
double tolerance; // used to set the precision/tolerance of path deviation
798+
// during CONTINUOUS motion mode.
799799
};
800800

801801
class EMC_TRAJ_SET_SPINDLESYNC:public EMC_TRAJ_CMD_MSG {
@@ -984,6 +984,7 @@ class EMC_TRAJ_STAT:public EMC_TRAJ_STAT_MSG {
984984
bool queueFull; // non-zero means can't accept another motion
985985
int id; // id of the currently executing motion
986986
bool paused; // non-zero means motion paused
987+
bool single_stepping; // non-zero means motion stepping single block
987988
double scale; // velocity scale factor
988989
double rapid_scale; // rapid scale factor
989990
//double spindle_scale; // moved to EMC_SPINDLE_STAT
@@ -1379,7 +1380,7 @@ class EMC_TASK_PLAN_SET_OPTIONAL_STOP:public EMC_TASK_CMD_MSG {
13791380
// Sub-class update() calls base-class update()
13801381
// cppcheck-suppress duplInheritedMember
13811382
void update(CMS * cms);
1382-
1383+
13831384
bool state; //state == ON, optional stop is on (e.g. we stop on any stops)
13841385
};
13851386

@@ -1394,7 +1395,7 @@ class EMC_TASK_PLAN_SET_BLOCK_DELETE:public EMC_TASK_CMD_MSG {
13941395
// Sub-class update() calls base-class update()
13951396
// cppcheck-suppress duplInheritedMember
13961397
void update(CMS * cms);
1397-
1398+
13981399
bool state; //state == ON, block delete is on, we ignore lines starting with "/"
13991400
};
14001401

@@ -1408,7 +1409,7 @@ class EMC_TASK_PLAN_OPTIONAL_STOP:public EMC_TASK_CMD_MSG {
14081409
// Sub-class update() calls base-class update()
14091410
// cppcheck-suppress duplInheritedMember
14101411
void update(CMS * cms);
1411-
1412+
14121413
};
14131414

14141415

@@ -1460,7 +1461,7 @@ class EMC_TASK_STAT:public EMC_TASK_STAT_MSG {
14601461
double activeSettings[ACTIVE_SETTINGS];
14611462
CANON_UNITS programUnits; // CANON_UNITS_INCHES, MM, CM
14621463

1463-
int interpreter_errcode; // return value from rs274ngc function
1464+
int interpreter_errcode; // return value from rs274ngc function
14641465
// (only useful for new interpreter.)
14651466
int task_paused; // non-zero means task is paused
14661467
double delayLeft; // delay time left of G4, M66..
@@ -1747,7 +1748,7 @@ class EMC_SPINDLE_ORIENT:public EMC_SPINDLE_CMD_MSG {
17471748

17481749
int spindle;
17491750
double orientation; // desired spindle position
1750-
int mode;
1751+
int mode;
17511752
};
17521753

17531754
class EMC_SPINDLE_WAIT_ORIENT_COMPLETE:public EMC_SPINDLE_CMD_MSG {

src/emc/task/emctaskmain.cc

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Author:
88
* License: GPL Version 2
99
* System: Linux
10-
*
10+
*
1111
* Copyright (c) 2004 All rights reserved.
1212
*
1313
********************************************************************/
@@ -217,7 +217,7 @@ int emcOperatorError(const char *fmt, ...)
217217
error_msg.error[0] = 0;
218218
// append error string
219219
va_start(ap, fmt);
220-
vsnprintf(&error_msg.error[strlen(error_msg.error)],
220+
vsnprintf(&error_msg.error[strlen(error_msg.error)],
221221
sizeof(error_msg.error) - strlen(error_msg.error), fmt, ap);
222222
va_end(ap);
223223

@@ -466,7 +466,7 @@ static int checkInterpList(NML_INTERP_LIST * il, EMC_STAT * /*stat*/)
466466
emcOperatorError("%s", error_msg->error);
467467
break;
468468
}
469-
469+
470470
//FIXME: there was limit checking tests below, see if they were needed
471471
case EMC_TRAJ_LINEAR_MOVE_TYPE:
472472
break;
@@ -535,7 +535,7 @@ void readahead_reading(void)
535535
EMC_TASK_INTERP::WAITING;
536536
interp_list.clear();
537537
emcAbortCleanup(EMC_ABORT::INTERPRETER_ERROR,
538-
"interpreter error");
538+
"interpreter error");
539539
} else if (execRetval == -1
540540
|| execRetval == INTERP_EXIT ) {
541541
emcStatus->task.interpState =
@@ -585,7 +585,7 @@ void readahead_reading(void)
585585

586586
if (emcStatus->task.readLine < programStartLine &&
587587
emcTaskPlanLevel() == 0) {
588-
588+
589589
//update the position with our current position, as the other positions are only skipped through
590590
CANON_UPDATE_END_POINT(emcStatus->motion.traj.actualPosition.tran.x,
591591
emcStatus->motion.traj.actualPosition.tran.y,
@@ -648,7 +648,7 @@ static void mdi_execute_hook(void)
648648
emcTaskCommand == 0 &&
649649
emcStatus->task.execState ==
650650
EMC_TASK_EXEC::DONE) {
651-
emcTaskPlanClearWait();
651+
emcTaskPlanClearWait();
652652
mdi_execute_wait = 0;
653653
mdi_execute_hook();
654654
}
@@ -670,11 +670,11 @@ static void mdi_execute_hook(void)
670670
// determine when a MDI command actually finishes normally.
671671
if (interp_list.len() == 0 &&
672672
emcTaskCommand == 0 &&
673-
emcStatus->task.execState == EMC_TASK_EXEC::DONE &&
674-
emcStatus->task.interpState != EMC_TASK_INTERP::IDLE &&
673+
emcStatus->task.execState == EMC_TASK_EXEC::DONE &&
674+
emcStatus->task.interpState != EMC_TASK_INTERP::IDLE &&
675675
emcStatus->motion.traj.queue == 0 &&
676-
emcStatus->io.status == RCS_STATUS::DONE &&
677-
!mdi_execute_wait &&
676+
emcStatus->io.status == RCS_STATUS::DONE &&
677+
!mdi_execute_wait &&
678678
!mdi_execute_next) {
679679

680680
// finished. Check for dequeuing of queued MDI command is done in emcTaskPlan().
@@ -1076,7 +1076,7 @@ static int emcTaskPlan(void)
10761076
case EMC_TASK_PLAN_STEP_TYPE:
10771077
// handles case where first action is to step the program
10781078
taskPlanRunCmd.line = 0; // run from start
1079-
/*! \todo FIXME-- can have GUI set this; send a run instead of a
1079+
/*! \todo FIXME-- can have GUI set this; send a run instead of a
10801080
step */
10811081
retval = emcTaskIssueCommand(&taskPlanRunCmd);
10821082
if(retval != 0) break;
@@ -1174,6 +1174,7 @@ static int emcTaskPlan(void)
11741174
break;
11751175

11761176
case EMC_TASK_PLAN_STEP_TYPE:
1177+
emcStatus->motion.traj.single_stepping = 1;
11771178
stepping = 1; // set stepping mode in case it's not
11781179
steppingWait = 0; // clear the wait
11791180
break;
@@ -1188,7 +1189,7 @@ static int emcTaskPlan(void)
11881189

11891190
// handle interp readahead logic
11901191
readahead_reading();
1191-
1192+
11921193
break; // EMC_TASK_INTERP::READING
11931194

11941195
case EMC_TASK_INTERP::PAUSED: // ON, AUTO, PAUSED
@@ -1249,6 +1250,7 @@ static int emcTaskPlan(void)
12491250
break;
12501251

12511252
case EMC_TASK_PLAN_STEP_TYPE:
1253+
emcStatus->motion.traj.single_stepping = 1;
12521254
stepping = 1;
12531255
steppingWait = 0;
12541256
if (emcStatus->motion.traj.paused &&
@@ -1324,6 +1326,7 @@ static int emcTaskPlan(void)
13241326
break;
13251327

13261328
case EMC_TASK_PLAN_STEP_TYPE:
1329+
emcStatus->motion.traj.single_stepping = 1;
13271330
stepping = 1; // set stepping mode in case it's not
13281331
steppingWait = 0; // clear the wait
13291332
break;
@@ -1892,10 +1895,10 @@ static int emcTaskIssueCommand(NMLmsg * cmd)
18921895

18931896
case EMC_TRAJ_PROBE_TYPE:
18941897
retval = emcTrajProbe(
1895-
((EMC_TRAJ_PROBE *) cmd)->pos,
1898+
((EMC_TRAJ_PROBE *) cmd)->pos,
18961899
((EMC_TRAJ_PROBE *) cmd)->type,
18971900
((EMC_TRAJ_PROBE *) cmd)->vel,
1898-
((EMC_TRAJ_PROBE *) cmd)->ini_maxvel,
1901+
((EMC_TRAJ_PROBE *) cmd)->ini_maxvel,
18991902
((EMC_TRAJ_PROBE *) cmd)->acc,
19001903
((EMC_TRAJ_PROBE *) cmd)->ini_maxjerk,
19011904
((EMC_TRAJ_PROBE *) cmd)->probe_type);
@@ -1908,7 +1911,7 @@ static int emcTaskIssueCommand(NMLmsg * cmd)
19081911
emcAuxInputWaitIndex = -1;
19091912
taskExecDelayTimeout = 0.0;
19101913
} else {
1911-
emcAuxInputWaitType = emcAuxInputWaitMsg->wait_type; // remember what we are waiting for
1914+
emcAuxInputWaitType = emcAuxInputWaitMsg->wait_type; // remember what we are waiting for
19121915
emcAuxInputWaitIndex = emcAuxInputWaitMsg->index; // remember the input to look at
19131916
emcStatus->task.input_timeout = 2; // set timeout flag, gets cleared if input changes before timeout happens
19141917
// set the timeout clock to expire at 'now' + delay time
@@ -1925,7 +1928,7 @@ static int emcTaskIssueCommand(NMLmsg * cmd)
19251928
emcTrajUpdateTag(((EMC_TRAJ_LINEAR_MOVE *) cmd)->tag);
19261929
retval = emcTrajRigidTap(((EMC_TRAJ_RIGID_TAP *) cmd)->pos,
19271930
((EMC_TRAJ_RIGID_TAP *) cmd)->vel,
1928-
((EMC_TRAJ_RIGID_TAP *) cmd)->ini_maxvel,
1931+
((EMC_TRAJ_RIGID_TAP *) cmd)->ini_maxvel,
19291932
((EMC_TRAJ_RIGID_TAP *) cmd)->acc,
19301933
((EMC_TRAJ_RIGID_TAP *) cmd)->ini_maxjerk,
19311934
((EMC_TRAJ_RIGID_TAP *) cmd)->scale);
@@ -2125,6 +2128,7 @@ static int emcTaskIssueCommand(NMLmsg * cmd)
21252128
// clear out the interpreter state
21262129
emcStatus->task.interpState = EMC_TASK_INTERP::IDLE;
21272130
emcStatus->task.execState = EMC_TASK_EXEC::DONE;
2131+
emcStatus->motion.traj.single_stepping = 0;
21282132
stepping = 0;
21292133
steppingWait = 0;
21302134

@@ -2219,6 +2223,7 @@ static int emcTaskIssueCommand(NMLmsg * cmd)
22192223
break;
22202224

22212225
case EMC_TASK_PLAN_EXECUTE_TYPE:
2226+
emcStatus->motion.traj.single_stepping = 0;
22222227
stepping = 0;
22232228
steppingWait = 0;
22242229
execute_msg = (EMC_TASK_PLAN_EXECUTE *) cmd;
@@ -2314,6 +2319,7 @@ static int emcTaskIssueCommand(NMLmsg * cmd)
23142319
retval = -1;
23152320
break;
23162321
}
2322+
emcStatus->motion.traj.single_stepping = 0;
23172323
stepping = 0;
23182324
steppingWait = 0;
23192325
if (!taskplanopen && emcStatus->task.file[0] != 0) {
@@ -2362,6 +2368,7 @@ static int emcTaskIssueCommand(NMLmsg * cmd)
23622368
emcTrajResume();
23632369
emcStatus->task.interpState = interpResumeState;
23642370
emcStatus->task.task_paused = 0;
2371+
emcStatus->motion.traj.single_stepping = 0;
23652372
stepping = 0;
23662373
steppingWait = 0;
23672374
retval = 0;
@@ -2592,6 +2599,7 @@ static int emcTaskExecute(void)
25922599
// clear out the interpreter state
25932600
emcStatus->task.interpState = EMC_TASK_INTERP::IDLE;
25942601
emcStatus->task.execState = EMC_TASK_EXEC::DONE;
2602+
emcStatus->motion.traj.single_stepping = 0;
25952603
stepping = 0;
25962604
steppingWait = 0;
25972605

@@ -2740,7 +2748,7 @@ static int emcTaskExecute(void)
27402748
}
27412749
// delay can be also be because we wait for an input
27422750
// if the index is set (not -1)
2743-
if (emcAuxInputWaitIndex >= 0) {
2751+
if (emcAuxInputWaitIndex >= 0) {
27442752
switch (emcAuxInputWaitType) {
27452753
case WAIT_MODE_HIGH:
27462754
if (emcStatus->motion.synch_di[emcAuxInputWaitIndex] != 0) {
@@ -2751,12 +2759,12 @@ static int emcTaskExecute(void)
27512759
}
27522760
break;
27532761

2754-
case WAIT_MODE_RISE:
2762+
case WAIT_MODE_RISE:
27552763
if (emcStatus->motion.synch_di[emcAuxInputWaitIndex] == 0) {
27562764
emcAuxInputWaitType = WAIT_MODE_HIGH;
27572765
}
27582766
break;
2759-
2767+
27602768
case WAIT_MODE_LOW:
27612769
if (emcStatus->motion.synch_di[emcAuxInputWaitIndex] == 0) {
27622770
emcStatus->task.input_timeout = 0; // clear timeout flag
@@ -2778,7 +2786,7 @@ static int emcTaskExecute(void)
27782786
emcStatus->task.execState = EMC_TASK_EXEC::DONE;
27792787
emcStatus->task.delayLeft = 0;
27802788
break;
2781-
2789+
27822790
default:
27832791
emcOperatorError("Unknown Wait Mode");
27842792
}
@@ -3437,7 +3445,7 @@ int main(int argc, char *argv[])
34373445

34383446
// check for subordinate errors, and halt task if so
34393447
if ( emcStatus->motion.status == RCS_STATUS::ERROR
3440-
&& emcStatus->motion.on_soft_limit) {
3448+
&& emcStatus->motion.on_soft_limit) {
34413449
if (!gave_soft_limit_message) {
34423450
emcOperatorError("On Soft Limit");
34433451
// if gui does not provide a means to switch to joint mode
@@ -3466,7 +3474,7 @@ int main(int argc, char *argv[])
34663474
}
34673475
// motion already should have reported this condition (and set RCS_STATUS::ERROR?)
34683476
// an M19 orient failed to complete within timeout
3469-
// if ((emcStatus->motion.status == RCS_STATUS::ERROR) &&
3477+
// if ((emcStatus->motion.status == RCS_STATUS::ERROR) &&
34703478
// (emcStatus->motion.spindle.orient_state == EMCMOT_ORIENT_FAULTED) &&
34713479
// (emcStatus->motion.spindle.orient_fault != 0)) {
34723480
// emcOperatorError("wait for orient complete timed out");
@@ -3499,6 +3507,7 @@ int main(int argc, char *argv[])
34993507
// clear out the interpreter state
35003508
emcStatus->task.interpState = EMC_TASK_INTERP::IDLE;
35013509
emcStatus->task.execState = EMC_TASK_EXEC::DONE;
3510+
emcStatus->motion.traj.single_stepping = 0;
35023511
stepping = 0;
35033512
steppingWait = 0;
35043513

src/emc/usr_intf/axis/extensions/emcmodule.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ static PyMemberDef Stat_members[] = {
466466
{(char*)"queue_full", T_BOOL, O(motion.traj.queueFull), READONLY, NULL},
467467
{(char*)"motion_id", T_INT, O(motion.traj.id), READONLY, NULL},
468468
{(char*)"paused", T_BOOL, O(motion.traj.paused), READONLY, NULL},
469+
{(char*)"single_stepping", T_BOOL, O(motion.traj.single_stepping), READONLY, NULL},
469470
{(char*)"feedrate", T_DOUBLE, O(motion.traj.scale), READONLY, NULL},
470471
{(char*)"rapidrate", T_DOUBLE, O(motion.traj.rapid_scale), READONLY, NULL},
471472
{(char*)"velocity", T_DOUBLE, O(motion.traj.velocity), READONLY, NULL},
@@ -2596,7 +2597,7 @@ static struct PyModuleDef linuxcnc_moduledef = {
25962597
PyMODINIT_FUNC PyInit_linuxcnc(void);
25972598
PyMODINIT_FUNC PyInit_linuxcnc(void)
25982599
{
2599-
2600+
26002601
verbose_nml_error_messages = 0;
26012602
clear_rcs_print_flag(~0);
26022603

0 commit comments

Comments
 (0)