Skip to content

Commit 81f105b

Browse files
committed
task: track interpState during MDI execution
the halui.program.is-running pin now makes sense during MDI execution. The current MDI command is reflected in emcstatus->task.command during MDI execution.
1 parent 2be62bf commit 81f105b

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

src/emc/task/emctask.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ int emcTaskAbort()
187187
emcStatus->task.task_paused = 0;
188188
emcStatus->task.motionLine = 0;
189189
emcStatus->task.readLine = 0;
190+
emcStatus->task.command[0] = 0;
191+
190192
stepping = 0;
191193
steppingWait = 0;
192194

src/emc/task/emctaskmain.cc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,7 @@ static void mdi_execute_abort(void)
679679
mdi_execute_next = 0;
680680

681681
mdi_execute_queue.clear();
682+
emcStatus->task.interpState = EMC_TASK_INTERP_IDLE;
682683
}
683684

684685
static void mdi_execute_hook(void)
@@ -701,6 +702,22 @@ static void mdi_execute_hook(void)
701702
return;
702703
}
703704

705+
// determine when a MDI command actually finishes normally.
706+
if (interp_list.len() == 0 &&
707+
emcTaskCommand == 0 &&
708+
emcStatus->task.execState == EMC_TASK_EXEC_DONE &&
709+
emcStatus->task.interpState != EMC_TASK_INTERP_IDLE &&
710+
emcStatus->motion.traj.queue == 0 &&
711+
emcStatus->io.status == RCS_DONE &&
712+
!mdi_execute_wait &&
713+
!mdi_execute_next) {
714+
715+
if (emc_debug & EMC_DEBUG_INTERP)
716+
rcs_print("mdi_execute_hook: MDI command '%s' done\n", emcStatus->task.command);
717+
emcStatus->task.command[0] = 0;
718+
emcStatus->task.interpState = EMC_TASK_INTERP_IDLE;
719+
}
720+
704721
if (!mdi_execute_next) return;
705722

706723
if (interp_list.len() > emc_task_interp_max_len) return;
@@ -2086,11 +2103,17 @@ static int emcTaskIssueCommand(NMLmsg * cmd)
20862103
retval = -1;
20872104
break;
20882105
}
2106+
// track interpState also during MDI - it might be an oword sub call
2107+
emcStatus->task.interpState = EMC_TASK_INTERP_READING;
2108+
20892109
if (execute_msg->command[0] != 0) {
20902110
char * command = execute_msg->command;
20912111
if (command[0] == (char) 0xff) {
20922112
// Empty command recieved. Consider it is NULL
20932113
command = NULL;
2114+
} else {
2115+
// record initial MDI command
2116+
strcpy(emcStatus->task.command, execute_msg->command);
20942117
}
20952118

20962119
if ((mdi_execute_level >= 0 || mdi_execute_wait) && command) {

0 commit comments

Comments
 (0)