Skip to content

Commit f82c475

Browse files
committed
emcmodule.cc: add taskbeat (task) and heartbeat (motion) to Python stat interface
Piggy backs off of commit 2001815 (some discussion at Pull Request #3809)
1 parent bcfa300 commit f82c475

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

docs/src/config/python-interface.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,10 @@ see <<python:reading-ini-values,ReadingINI file values>> for an example.
190190
Active G-codes for each modal group. +
191191
The integer values reflect the nominal G-code numbers multiplied by 10. (Examples: 10 = 'G1', 430 = 'G43', 923 = 'G92.3')
192192

193+
*heartbeat*:: '(returns integer)' -
194+
motion controller heartbeat counter. Increments every servo cycle.
195+
Rate is determined by `[EMCMOT]SERVO_PERIOD` in the INI file.
196+
193197
*homed*:: '(returns tuple of integers)' -
194198
currently homed joints, with 0 = not homed, 1 = homed.
195199

@@ -351,6 +355,10 @@ see <<python:reading-ini-values,ReadingINI file values>> for an example.
351355
*tool_in_spindle*:: '(returns integer)' -
352356
current tool number.
353357

358+
*taskbeat*:: '(returns integer)' -
359+
task main loop heartbeat counter. Increments every task cycle.
360+
Rate is determined by `[TASK]CYCLE_TIME` in the INI file.
361+
354362
*tool_from_pocket*:: '(returns integer)' -
355363
pocket number for the currently loaded tool (0 if no tool loaded).
356364

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,22 @@ static PyObject *Stat_tool_table(pyStatChannel * /*s*/, void *) {
805805
return res;
806806
}
807807

808+
static PyObject *Stat_heartbeat(pyStatChannel *s, void *) {
809+
#if PY_VERSION_HEX >= 0x030e00f0 // 3.14
810+
return PyLong_FromUInt64(s->status.motion.heartbeat);
811+
#else
812+
return PyLong_FromUnsignedLongLong(s->status.motion.heartbeat);
813+
#endif
814+
}
815+
816+
static PyObject *Stat_taskbeat(pyStatChannel *s, void *) {
817+
#if PY_VERSION_HEX >= 0x030e00f0 // 3.14
818+
return PyLong_FromUInt64(s->status.task.taskbeat);
819+
#else
820+
return PyLong_FromUnsignedLongLong(s->status.task.taskbeat);
821+
#endif
822+
}
823+
808824
static PyGetSetDef Stat_getsetlist[] = {
809825
{(char*)"actual_position", (getter)Stat_actual, NULL, NULL, NULL},
810826
{(char*)"ain", (getter)Stat_ain, NULL, NULL, NULL},
@@ -838,6 +854,12 @@ static PyGetSetDef Stat_getsetlist[] = {
838854
(char*)"The tooltable, expressed as a list of tools. Each tool is a dict with the\n"
839855
"tool id (tool number), diameter, offsets, etc.", NULL
840856
},
857+
{(char*)"heartbeat", (getter)Stat_heartbeat, NULL,
858+
(char*)"Motion controller heartbeat counter. Increments every servo cycle.", NULL
859+
},
860+
{(char*)"taskbeat", (getter)Stat_taskbeat, NULL,
861+
(char*)"Task main loop heartbeat counter. Increments every task cycle.", NULL
862+
},
841863
{}
842864
};
843865

0 commit comments

Comments
 (0)