Skip to content

Commit 779753c

Browse files
author
Robert Schöftner
committed
change emcmot motion id to struct containing hash of filename
1 parent a743d12 commit 779753c

22 files changed

Lines changed: 159 additions & 102 deletions

src/emc/motion-logger/motion-logger.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ int main(int argc, char* argv[]) {
464464
c->pos.tran.x, c->pos.tran.y, c->pos.tran.z,
465465
c->pos.a, c->pos.b, c->pos.c,
466466
c->pos.u, c->pos.v, c->pos.w,
467-
c->id, c->motion_type,
467+
c->id.line_number, c->motion_type,
468468
c->vel, c->ini_maxvel,
469469
c->acc, c->turn
470470
);
@@ -481,7 +481,7 @@ int main(int argc, char* argv[]) {
481481
log_print(" center: x=%.6g, y=%.6g, z=%.6g\n", c->center.x, c->center.y, c->center.z);
482482
log_print(" normal: x=%.6g, y=%.6g, z=%.6g\n", c->normal.x, c->normal.y, c->normal.z);
483483
log_print(" id=%d, motion_type=%d, vel=%.6g, ini_maxvel=%.6g, acc=%.6g, turn=%d\n",
484-
c->id, c->motion_type,
484+
c->id.line_number, c->motion_type,
485485
c->vel, c->ini_maxvel,
486486
c->acc, c->turn
487487
);

src/emc/motion/command.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ void emcmotCommandHandler_locked(void *arg, long servo_period)
10031003
emcmotStatus->commandStatus = EMCMOT_COMMAND_INVALID_COMMAND;
10041004
SET_MOTION_ERROR_FLAG(1);
10051005
break;
1006-
} else if (!inRange(emcmotCommand->pos, emcmotCommand->id, "Linear")) {
1006+
} else if (!inRange(emcmotCommand->pos, emcmotCommand->id.line_number, "Linear")) {
10071007
reportError(_("invalid params in linear command"));
10081008
emcmotStatus->commandStatus = EMCMOT_COMMAND_INVALID_PARAMS;
10091009
tpAbort(&emcmotInternal->coord_tp);
@@ -1041,8 +1041,8 @@ void emcmotCommandHandler_locked(void *arg, long servo_period)
10411041
emcmotCommand->tag);
10421042
//KLUDGE ignore zero length line
10431043
if (res_addline < 0) {
1044-
reportError(_("can't add linear move at line %d, error code %d"),
1045-
emcmotCommand->id, res_addline);
1044+
reportError(_("can't add linear move id %ld at %s line %d, error code %d"),
1045+
emcmotCommand->id.id, emcmotCommand->tag.filename, emcmotCommand->tag.fields[0], res_addline);
10461046
emcmotStatus->commandStatus = EMCMOT_COMMAND_BAD_EXEC;
10471047
tpAbort(&emcmotInternal->coord_tp);
10481048
SET_MOTION_ERROR_FLAG(1);
@@ -1072,7 +1072,7 @@ void emcmotCommandHandler_locked(void *arg, long servo_period)
10721072
emcmotStatus->commandStatus = EMCMOT_COMMAND_INVALID_COMMAND;
10731073
SET_MOTION_ERROR_FLAG(1);
10741074
break;
1075-
} else if (!inRange(emcmotCommand->pos, emcmotCommand->id, "Circular")) {
1075+
} else if (!inRange(emcmotCommand->pos, emcmotCommand->id.line_number, "Circular")) {
10761076
emcmotStatus->commandStatus = EMCMOT_COMMAND_INVALID_PARAMS;
10771077
tpAbort(&emcmotInternal->coord_tp);
10781078
SET_MOTION_ERROR_FLAG(1);
@@ -1097,8 +1097,8 @@ void emcmotCommandHandler_locked(void *arg, long servo_period)
10971097
emcmotCommand->acc, emcmotCommand->ini_maxjerk, emcmotStatus->enables_new,
10981098
issue_atspeed, emcmotCommand->tag);
10991099
if (res_addcircle < 0) {
1100-
reportError(_("can't add circular move at line %d, error code %d"),
1101-
emcmotCommand->id, res_addcircle);
1100+
reportError(_("can't add circular move id %ld at %s line %d, error code %d"),
1101+
emcmotCommand->id.id, emcmotCommand->tag.filename, emcmotCommand->tag.fields[0], res_addcircle);
11021102
emcmotStatus->commandStatus = EMCMOT_COMMAND_BAD_EXEC;
11031103
tpAbort(&emcmotInternal->coord_tp);
11041104
SET_MOTION_ERROR_FLAG(1);
@@ -1449,7 +1449,7 @@ void emcmotCommandHandler_locked(void *arg, long servo_period)
14491449
emcmotStatus->commandStatus = EMCMOT_COMMAND_INVALID_COMMAND;
14501450
SET_MOTION_ERROR_FLAG(1);
14511451
break;
1452-
} else if (!inRange(emcmotCommand->pos, emcmotCommand->id, "Probe")) {
1452+
} else if (!inRange(emcmotCommand->pos, emcmotCommand->id.line_number, "Probe")) {
14531453
emcmotStatus->commandStatus = EMCMOT_COMMAND_INVALID_PARAMS;
14541454
tpAbort(&emcmotInternal->coord_tp);
14551455
SET_MOTION_ERROR_FLAG(1);
@@ -1519,7 +1519,7 @@ void emcmotCommandHandler_locked(void *arg, long servo_period)
15191519
emcmotStatus->commandStatus = EMCMOT_COMMAND_INVALID_COMMAND;
15201520
SET_MOTION_ERROR_FLAG(1);
15211521
break;
1522-
} else if (!inRange(emcmotCommand->pos, emcmotCommand->id, "Rigid tap")) {
1522+
} else if (!inRange(emcmotCommand->pos, emcmotCommand->id.line_number, "Rigid tap")) {
15231523
emcmotStatus->commandStatus = EMCMOT_COMMAND_INVALID_PARAMS;
15241524
tpAbort(&emcmotInternal->coord_tp);
15251525
SET_MOTION_ERROR_FLAG(1);
@@ -1545,8 +1545,8 @@ void emcmotCommandHandler_locked(void *arg, long servo_period)
15451545
emcmotCommand->tag);
15461546
if (res_addtap < 0) {
15471547
emcmotStatus->atspeed_next_feed = 0; /* rigid tap always waits for spindle to be at-speed */
1548-
reportError(_("can't add rigid tap move at line %d, error code %d"),
1549-
emcmotCommand->id, res_addtap);
1548+
reportError(_("can't add rigid tap move id %ld at %s line %d, error code %d"),
1549+
emcmotCommand->id.id, emcmotCommand->tag.filename, emcmotCommand->tag.fields[0], res_addtap);
15501550
tpAbort(&emcmotInternal->coord_tp);
15511551
SET_MOTION_ERROR_FLAG(1);
15521552
break;

src/emc/motion/control.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1947,7 +1947,7 @@ static void output_to_hal(void)
19471947
emcmotStatus->spindle_status[spindle_num].speed / 60.;
19481948
}
19491949

1950-
*(emcmot_hal_data->program_line) = emcmotStatus->id;
1950+
*(emcmot_hal_data->program_line) = emcmotStatus->id.line_number;
19511951
*(emcmot_hal_data->tp_reverse) = emcmotStatus->reverse_run;
19521952
*(emcmot_hal_data->motion_type) = emcmotStatus->motionType;
19531953
*(emcmot_hal_data->distance_to_go) = emcmotStatus->distance_to_go;
@@ -2179,7 +2179,7 @@ static void update_status(void)
21792179
/* check to see if we should pause in order to implement
21802180
single emcmotStatus->stepping */
21812181

2182-
if (emcmotStatus->stepping && emcmotInternal->idForStep != emcmotStatus->id) {
2182+
if (emcmotStatus->stepping && emcmotInternal->idForStep.id != emcmotStatus->id.id) {
21832183
tpPause(&emcmotInternal->coord_tp);
21842184
emcmotStatus->stepping = 0;
21852185
emcmotStatus->paused = 1;

src/emc/motion/emcmotcfg.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#ifndef EMCMOTCFG_H
1414
#define EMCMOTCFG_H
1515

16+
#include <stdint.h>
17+
1618
/* default name of EMCMOT INI file */
1719
#define DEFAULT_EMCMOT_INIFILE "emc.ini" /* same as for EMC-- we're in
1820
touch */
@@ -72,4 +74,20 @@
7274
/* max following error */
7375
#define DEFAULT_MAX_FERROR 100
7476

77+
#ifdef __cplusplus
78+
extern "C" {
79+
#endif
80+
typedef union {
81+
// note: CMS can't deal with 64bit values nor with bitfields
82+
int64_t id;
83+
struct {
84+
int line_number;
85+
unsigned filename_hash;
86+
};
87+
} emcmot_motion_id_t;
88+
89+
#ifdef __cplusplus
90+
}
91+
#endif
92+
7593
#endif

src/emc/motion/motion.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ static int init_comm_buffers(void)
890890
override, and feed hold are on */
891891
emcmotStatus->enables_new = FS_ENABLED | SS_ENABLED | FH_ENABLED;
892892
emcmotStatus->enables_queued = emcmotStatus->enables_new;
893-
emcmotStatus->id = 0;
893+
emcmotStatus->id.id = 0;
894894
emcmotStatus->depth = 0;
895895
emcmotStatus->activeDepth = 0;
896896
emcmotStatus->paused = 0;

src/emc/motion/motion.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ to another.
6868
#include "simple_tp.h"
6969
#include "rtapi_limits.h"
7070
#include <stdarg.h>
71+
#include <stdint.h>
7172
#include "rtapi_bool.h"
7273
#include "state_tag.h"
7374
#include "tp_types.h"
@@ -77,7 +78,7 @@ to another.
7778
// this should be really be tested for in command.c
7879

7980
#define MOTION_INVALID_ID INT_MIN
80-
#define MOTION_ID_VALID(x) ((x) != MOTION_INVALID_ID)
81+
#define MOTION_ID_VALID(x) ((x.line_number) != MOTION_INVALID_ID)
8182

8283
#ifdef __cplusplus
8384
extern "C" {
@@ -222,7 +223,7 @@ extern "C" {
222223
double ini_maxjerk;
223224
int planner_type; /* planner type: 0 = trapezoidal, 1 = S-curve */
224225
double backlash; /* amount of backlash */
225-
int id; /* id for motion */
226+
emcmot_motion_id_t id; /* id for motion */
226227
int termCond; /* termination condition */
227228
double tolerance; /* tolerance for path deviation in CONTINUOUS mode */
228229
int joint; /* which joint index to use for below */
@@ -626,7 +627,7 @@ Suggestion: Split this in to an Error and a Status flag register..
626627
unsigned int heartbeat;
627628
int config_num; /* incremented whenever configuration
628629
changed. */
629-
int id; /* id for executing motion */
630+
emcmot_motion_id_t id; /* id for executing motion */
630631
int depth; /* motion queue depth */
631632
int activeDepth; /* depth of active blend elements */
632633
int queueFull; /* Flag to indicate the tc queue is full */
@@ -751,7 +752,7 @@ typedef struct emcmot_internal_t {
751752
int overriding; /* non-zero means we've initiated an joint
752753
move while overriding limits */
753754
TP_STRUCT coord_tp; /* coordinated mode planner */
754-
int idForStep; /* status id while stepping */
755+
emcmot_motion_id_t idForStep; /* status id while stepping */
755756
} emcmot_internal_t;
756757

757758
/* error ring buffer access functions */

src/emc/motion/usrmotintf.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ int usrmotWriteEmcmotCommand(emcmot_command_t * c)
7878
double end;
7979

8080
if (!MOTION_ID_VALID(c->id)) {
81-
rcs_print("USRMOT: ERROR: invalid motion id: %d\n",c->id);
81+
rcs_print("USRMOT: ERROR: invalid motion id: %d %u\n", c->id.line_number, c->id.filename_hash);
8282
return EMCMOT_COMM_INVALID_MOTION_ID;
8383
}
8484

@@ -256,8 +256,8 @@ void printTPstruct(TP_STRUCT * tp)
256256
printf("vLimit=%f\n", tp->vLimit);
257257
printf("wMax=%f\n", tp->wMax);
258258
printf("wDotMax=%f\n", tp->wDotMax);
259-
printf("nextId=%d\n", tp->nextId);
260-
printf("execId=%d\n", tp->execId);
259+
printf("nextId=%ld\n", tp->nextId.id);
260+
printf("execId=%ld\n", tp->execId.id);
261261
printf("termCond=%d\n", tp->termCond);
262262
printf("currentPos :");
263263
printEmcPose(&tp->currentPos);
@@ -425,7 +425,7 @@ void usrmotPrintEmcmotStatus(emcmot_status_t *s, int which)
425425
#endif
426426
printf("velocity: \t%f\n", s->vel);
427427
printf("accel: \t%f\n", s->acc);
428-
printf("id: \t%d\n", s->id);
428+
printf("id: \t%ld\n", s->id.id);
429429
printf("depth: \t%d\n", s->depth);
430430
printf("active depth: \t%d\n", s->activeDepth);
431431
printf("inpos: \t%d\n",

src/emc/nml_intf/emc.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1702,7 +1702,8 @@ void EMC_TRAJ_STAT::update(CMS * cms)
17021702
cms->update(queue);
17031703
cms->update(activeQueue);
17041704
cms->update(queueFull);
1705-
cms->update(id);
1705+
cms->update(id.line_number);
1706+
cms->update(id.filename_hash);
17061707
cms->update(paused);
17071708
cms->update(single_stepping);
17081709
cms->update(scale);

src/emc/nml_intf/emc.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ extern int emcTrajSetFHEnable(unsigned char mode); //feed hold enable
354354
extern int emcTrajSetSpindleScale(int spindle, double scale);
355355
extern int emcTrajSetSOEnable(unsigned char mode); //spindle speed override enable
356356
extern int emcTrajSetAFEnable(unsigned char enable); //adaptive feed enable
357-
extern int emcTrajSetMotionId(int id);
357+
extern int emcTrajSetMotionId(emcmot_motion_id_t id);
358358
extern double emcTrajGetLinearUnits();
359359
extern double emcTrajGetAngularUnits();
360360

src/emc/nml_intf/emc_nml.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ class EMC_TRAJ_STAT:public EMC_TRAJ_STAT_MSG {
982982
// current
983983
int activeQueue; // number of motions blending
984984
bool queueFull; // non-zero means can't accept another motion
985-
int id; // id of the currently executing motion
985+
emcmot_motion_id_t id; // id of the currently executing motion
986986
bool paused; // non-zero means motion paused
987987
bool single_stepping; // non-zero means motion stepping single block
988988
double scale; // velocity scale factor

0 commit comments

Comments
 (0)