diff --git a/src/emc/motion-logger/motion-logger.c b/src/emc/motion-logger/motion-logger.c index b61e1cf77a3..3c4adca96ce 100644 --- a/src/emc/motion-logger/motion-logger.c +++ b/src/emc/motion-logger/motion-logger.c @@ -464,7 +464,7 @@ int main(int argc, char* argv[]) { c->pos.tran.x, c->pos.tran.y, c->pos.tran.z, c->pos.a, c->pos.b, c->pos.c, c->pos.u, c->pos.v, c->pos.w, - c->id, c->motion_type, + c->id.line_number, c->motion_type, c->vel, c->ini_maxvel, c->acc, c->turn ); @@ -481,7 +481,7 @@ int main(int argc, char* argv[]) { log_print(" center: x=%.6g, y=%.6g, z=%.6g\n", c->center.x, c->center.y, c->center.z); log_print(" normal: x=%.6g, y=%.6g, z=%.6g\n", c->normal.x, c->normal.y, c->normal.z); log_print(" id=%d, motion_type=%d, vel=%.6g, ini_maxvel=%.6g, acc=%.6g, turn=%d\n", - c->id, c->motion_type, + c->id.line_number, c->motion_type, c->vel, c->ini_maxvel, c->acc, c->turn ); diff --git a/src/emc/motion/command.c b/src/emc/motion/command.c index 9d4d30367e2..7d38f189991 100644 --- a/src/emc/motion/command.c +++ b/src/emc/motion/command.c @@ -1003,7 +1003,7 @@ void emcmotCommandHandler_locked(void *arg, long servo_period) emcmotStatus->commandStatus = EMCMOT_COMMAND_INVALID_COMMAND; SET_MOTION_ERROR_FLAG(1); break; - } else if (!inRange(emcmotCommand->pos, emcmotCommand->id, "Linear")) { + } else if (!inRange(emcmotCommand->pos, emcmotCommand->id.line_number, "Linear")) { reportError(_("invalid params in linear command")); emcmotStatus->commandStatus = EMCMOT_COMMAND_INVALID_PARAMS; tpAbort(&emcmotInternal->coord_tp); @@ -1041,8 +1041,8 @@ void emcmotCommandHandler_locked(void *arg, long servo_period) emcmotCommand->tag); //KLUDGE ignore zero length line if (res_addline < 0) { - reportError(_("can't add linear move at line %d, error code %d"), - emcmotCommand->id, res_addline); + reportError(_("can't add linear move id %ld at %s line %d, error code %d"), + emcmotCommand->id.id, emcmotCommand->tag.filename, emcmotCommand->tag.fields[0], res_addline); emcmotStatus->commandStatus = EMCMOT_COMMAND_BAD_EXEC; tpAbort(&emcmotInternal->coord_tp); SET_MOTION_ERROR_FLAG(1); @@ -1072,7 +1072,7 @@ void emcmotCommandHandler_locked(void *arg, long servo_period) emcmotStatus->commandStatus = EMCMOT_COMMAND_INVALID_COMMAND; SET_MOTION_ERROR_FLAG(1); break; - } else if (!inRange(emcmotCommand->pos, emcmotCommand->id, "Circular")) { + } else if (!inRange(emcmotCommand->pos, emcmotCommand->id.line_number, "Circular")) { emcmotStatus->commandStatus = EMCMOT_COMMAND_INVALID_PARAMS; tpAbort(&emcmotInternal->coord_tp); SET_MOTION_ERROR_FLAG(1); @@ -1097,8 +1097,8 @@ void emcmotCommandHandler_locked(void *arg, long servo_period) emcmotCommand->acc, emcmotCommand->ini_maxjerk, emcmotStatus->enables_new, issue_atspeed, emcmotCommand->tag); if (res_addcircle < 0) { - reportError(_("can't add circular move at line %d, error code %d"), - emcmotCommand->id, res_addcircle); + reportError(_("can't add circular move id %ld at %s line %d, error code %d"), + emcmotCommand->id.id, emcmotCommand->tag.filename, emcmotCommand->tag.fields[0], res_addcircle); emcmotStatus->commandStatus = EMCMOT_COMMAND_BAD_EXEC; tpAbort(&emcmotInternal->coord_tp); SET_MOTION_ERROR_FLAG(1); @@ -1449,7 +1449,7 @@ void emcmotCommandHandler_locked(void *arg, long servo_period) emcmotStatus->commandStatus = EMCMOT_COMMAND_INVALID_COMMAND; SET_MOTION_ERROR_FLAG(1); break; - } else if (!inRange(emcmotCommand->pos, emcmotCommand->id, "Probe")) { + } else if (!inRange(emcmotCommand->pos, emcmotCommand->id.line_number, "Probe")) { emcmotStatus->commandStatus = EMCMOT_COMMAND_INVALID_PARAMS; tpAbort(&emcmotInternal->coord_tp); SET_MOTION_ERROR_FLAG(1); @@ -1519,7 +1519,7 @@ void emcmotCommandHandler_locked(void *arg, long servo_period) emcmotStatus->commandStatus = EMCMOT_COMMAND_INVALID_COMMAND; SET_MOTION_ERROR_FLAG(1); break; - } else if (!inRange(emcmotCommand->pos, emcmotCommand->id, "Rigid tap")) { + } else if (!inRange(emcmotCommand->pos, emcmotCommand->id.line_number, "Rigid tap")) { emcmotStatus->commandStatus = EMCMOT_COMMAND_INVALID_PARAMS; tpAbort(&emcmotInternal->coord_tp); SET_MOTION_ERROR_FLAG(1); @@ -1545,8 +1545,8 @@ void emcmotCommandHandler_locked(void *arg, long servo_period) emcmotCommand->tag); if (res_addtap < 0) { emcmotStatus->atspeed_next_feed = 0; /* rigid tap always waits for spindle to be at-speed */ - reportError(_("can't add rigid tap move at line %d, error code %d"), - emcmotCommand->id, res_addtap); + reportError(_("can't add rigid tap move id %ld at %s line %d, error code %d"), + emcmotCommand->id.id, emcmotCommand->tag.filename, emcmotCommand->tag.fields[0], res_addtap); tpAbort(&emcmotInternal->coord_tp); SET_MOTION_ERROR_FLAG(1); break; diff --git a/src/emc/motion/control.c b/src/emc/motion/control.c index a17f2981ac5..6607ec5e456 100644 --- a/src/emc/motion/control.c +++ b/src/emc/motion/control.c @@ -1947,7 +1947,7 @@ static void output_to_hal(void) emcmotStatus->spindle_status[spindle_num].speed / 60.; } - *(emcmot_hal_data->program_line) = emcmotStatus->id; + *(emcmot_hal_data->program_line) = emcmotStatus->id.line_number; *(emcmot_hal_data->tp_reverse) = emcmotStatus->reverse_run; *(emcmot_hal_data->motion_type) = emcmotStatus->motionType; *(emcmot_hal_data->distance_to_go) = emcmotStatus->distance_to_go; @@ -2179,7 +2179,7 @@ static void update_status(void) /* check to see if we should pause in order to implement single emcmotStatus->stepping */ - if (emcmotStatus->stepping && emcmotInternal->idForStep != emcmotStatus->id) { + if (emcmotStatus->stepping && emcmotInternal->idForStep.id != emcmotStatus->id.id) { tpPause(&emcmotInternal->coord_tp); emcmotStatus->stepping = 0; emcmotStatus->paused = 1; diff --git a/src/emc/motion/emcmotcfg.h b/src/emc/motion/emcmotcfg.h index c0288a48e6f..8a3867f90a1 100644 --- a/src/emc/motion/emcmotcfg.h +++ b/src/emc/motion/emcmotcfg.h @@ -13,6 +13,8 @@ #ifndef EMCMOTCFG_H #define EMCMOTCFG_H +#include + /* default name of EMCMOT INI file */ #define DEFAULT_EMCMOT_INIFILE "emc.ini" /* same as for EMC-- we're in touch */ @@ -72,4 +74,20 @@ /* max following error */ #define DEFAULT_MAX_FERROR 100 +#ifdef __cplusplus +extern "C" { +#endif +typedef union { + // note: CMS can't deal with 64bit values nor with bitfields + int64_t id; + struct { + int line_number; + unsigned filename_hash; + }; +} emcmot_motion_id_t; + +#ifdef __cplusplus +} +#endif + #endif diff --git a/src/emc/motion/motion.c b/src/emc/motion/motion.c index d27b42d4f60..caba7a14e09 100644 --- a/src/emc/motion/motion.c +++ b/src/emc/motion/motion.c @@ -890,7 +890,7 @@ static int init_comm_buffers(void) override, and feed hold are on */ emcmotStatus->enables_new = FS_ENABLED | SS_ENABLED | FH_ENABLED; emcmotStatus->enables_queued = emcmotStatus->enables_new; - emcmotStatus->id = 0; + emcmotStatus->id.id = 0; emcmotStatus->depth = 0; emcmotStatus->activeDepth = 0; emcmotStatus->paused = 0; diff --git a/src/emc/motion/motion.h b/src/emc/motion/motion.h index 4477e9286b1..5ace1089b1d 100644 --- a/src/emc/motion/motion.h +++ b/src/emc/motion/motion.h @@ -68,6 +68,7 @@ to another. #include "simple_tp.h" #include "rtapi_limits.h" #include +#include #include "rtapi_bool.h" #include "state_tag.h" #include "tp_types.h" @@ -77,7 +78,7 @@ to another. // this should be really be tested for in command.c #define MOTION_INVALID_ID INT_MIN -#define MOTION_ID_VALID(x) ((x) != MOTION_INVALID_ID) +#define MOTION_ID_VALID(x) ((x.line_number) != MOTION_INVALID_ID) #ifdef __cplusplus extern "C" { @@ -222,7 +223,7 @@ extern "C" { double ini_maxjerk; int planner_type; /* planner type: 0 = trapezoidal, 1 = S-curve */ double backlash; /* amount of backlash */ - int id; /* id for motion */ + emcmot_motion_id_t id; /* id for motion */ int termCond; /* termination condition */ double tolerance; /* tolerance for path deviation in CONTINUOUS mode */ 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.. unsigned int heartbeat; int config_num; /* incremented whenever configuration changed. */ - int id; /* id for executing motion */ + emcmot_motion_id_t id; /* id for executing motion */ int depth; /* motion queue depth */ int activeDepth; /* depth of active blend elements */ int queueFull; /* Flag to indicate the tc queue is full */ @@ -751,7 +752,7 @@ typedef struct emcmot_internal_t { int overriding; /* non-zero means we've initiated an joint move while overriding limits */ TP_STRUCT coord_tp; /* coordinated mode planner */ - int idForStep; /* status id while stepping */ + emcmot_motion_id_t idForStep; /* status id while stepping */ } emcmot_internal_t; /* error ring buffer access functions */ diff --git a/src/emc/motion/usrmotintf.cc b/src/emc/motion/usrmotintf.cc index 80ef69a14a2..864a110eb9f 100644 --- a/src/emc/motion/usrmotintf.cc +++ b/src/emc/motion/usrmotintf.cc @@ -78,7 +78,7 @@ int usrmotWriteEmcmotCommand(emcmot_command_t * c) double end; if (!MOTION_ID_VALID(c->id)) { - rcs_print("USRMOT: ERROR: invalid motion id: %d\n",c->id); + rcs_print("USRMOT: ERROR: invalid motion id: %d %u\n", c->id.line_number, c->id.filename_hash); return EMCMOT_COMM_INVALID_MOTION_ID; } @@ -256,8 +256,8 @@ void printTPstruct(TP_STRUCT * tp) printf("vLimit=%f\n", tp->vLimit); printf("wMax=%f\n", tp->wMax); printf("wDotMax=%f\n", tp->wDotMax); - printf("nextId=%d\n", tp->nextId); - printf("execId=%d\n", tp->execId); + printf("nextId=%ld\n", tp->nextId.id); + printf("execId=%ld\n", tp->execId.id); printf("termCond=%d\n", tp->termCond); printf("currentPos :"); printEmcPose(&tp->currentPos); @@ -425,7 +425,7 @@ void usrmotPrintEmcmotStatus(emcmot_status_t *s, int which) #endif printf("velocity: \t%f\n", s->vel); printf("accel: \t%f\n", s->acc); - printf("id: \t%d\n", s->id); + printf("id: \t%ld\n", s->id.id); printf("depth: \t%d\n", s->depth); printf("active depth: \t%d\n", s->activeDepth); printf("inpos: \t%d\n", diff --git a/src/emc/nml_intf/emc.cc b/src/emc/nml_intf/emc.cc index df1e3bae789..88b3263f478 100644 --- a/src/emc/nml_intf/emc.cc +++ b/src/emc/nml_intf/emc.cc @@ -1702,7 +1702,8 @@ void EMC_TRAJ_STAT::update(CMS * cms) cms->update(queue); cms->update(activeQueue); cms->update(queueFull); - cms->update(id); + cms->update(id.line_number); + cms->update(id.filename_hash); cms->update(paused); cms->update(single_stepping); cms->update(scale); diff --git a/src/emc/nml_intf/emc.hh b/src/emc/nml_intf/emc.hh index 3eba83a9c1d..be111a06a1e 100644 --- a/src/emc/nml_intf/emc.hh +++ b/src/emc/nml_intf/emc.hh @@ -354,7 +354,7 @@ extern int emcTrajSetFHEnable(unsigned char mode); //feed hold enable extern int emcTrajSetSpindleScale(int spindle, double scale); extern int emcTrajSetSOEnable(unsigned char mode); //spindle speed override enable extern int emcTrajSetAFEnable(unsigned char enable); //adaptive feed enable -extern int emcTrajSetMotionId(int id); +extern int emcTrajSetMotionId(emcmot_motion_id_t id); extern double emcTrajGetLinearUnits(); extern double emcTrajGetAngularUnits(); diff --git a/src/emc/nml_intf/emc_nml.hh b/src/emc/nml_intf/emc_nml.hh index a4717a33b76..38fab39cded 100644 --- a/src/emc/nml_intf/emc_nml.hh +++ b/src/emc/nml_intf/emc_nml.hh @@ -982,7 +982,7 @@ class EMC_TRAJ_STAT:public EMC_TRAJ_STAT_MSG { // current int activeQueue; // number of motions blending bool queueFull; // non-zero means can't accept another motion - int id; // id of the currently executing motion + emcmot_motion_id_t id; // id of the currently executing motion bool paused; // non-zero means motion paused bool single_stepping; // non-zero means motion stepping single block double scale; // velocity scale factor diff --git a/src/emc/nml_intf/emcglb.h b/src/emc/nml_intf/emcglb.h index 1ec4d2d83ef..6fc311f8421 100644 --- a/src/emc/nml_intf/emcglb.h +++ b/src/emc/nml_intf/emcglb.h @@ -98,7 +98,7 @@ typedef struct TrajConfig_t { int AxisMask; double LinearUnits; double AngularUnits; - int MotionId; + emcmot_motion_id_t MotionId; } TrajConfig_t; #ifdef __cplusplus diff --git a/src/emc/nml_intf/interpl.cc b/src/emc/nml_intf/interpl.cc index 8258d4355c1..a727a590aba 100644 --- a/src/emc/nml_intf/interpl.cc +++ b/src/emc/nml_intf/interpl.cc @@ -114,7 +114,17 @@ int NML_INTERP_LIST::len() return ((int)linked_list.size()); } -int NML_INTERP_LIST::get_line_number() +int NML_INTERP_LIST::get_line_number() const { return line_number; } + +void NML_INTERP_LIST::set_filename(const std::string& s) +{ + filename = s; +} + +const std::string& NML_INTERP_LIST::get_filename() const +{ + return filename; +} diff --git a/src/emc/nml_intf/interpl.hh b/src/emc/nml_intf/interpl.hh index b5ef1652a60..19f5da2e19a 100644 --- a/src/emc/nml_intf/interpl.hh +++ b/src/emc/nml_intf/interpl.hh @@ -19,6 +19,7 @@ #include #include +#include class NMLmsg; @@ -35,7 +36,9 @@ class NML_INTERP_LIST { public: void set_line_number(int line); - int get_line_number(); + int get_line_number() const; + void set_filename(const std::string& s); + const std::string& get_filename() const; int append(std::unique_ptr&& command); std::unique_ptr get(); void clear(); @@ -47,6 +50,7 @@ private: int next_line_number = 0; // line number used to fill temp_node int line_number = 0; // line number of node from get() // NML_INTERP_LIST_NODE node; // pointer returned by get + std::string filename; }; extern NML_INTERP_LIST interp_list; /* NML Union, for interpreter */ diff --git a/src/emc/task/emccanon.cc b/src/emc/task/emccanon.cc index f8c6cfb69ed..a65e09869b0 100644 --- a/src/emc/task/emccanon.cc +++ b/src/emc/task/emccanon.cc @@ -1042,7 +1042,7 @@ static VelData getStraightVelocity(const CANON_POSITION& pos) #include struct pt { double x, y, z, a, b, c, u, v, w; - int line_no; + //int line_no; StateTag tag; }; @@ -1061,7 +1061,7 @@ static void flush_segments(void) { double a = pos.a, b = pos.b, c = pos.c; double u = pos.u, v = pos.v, w = pos.w; - int line_no = pos.line_no; + //int line_no = pos.line_no; #ifdef SHOW_JOINED_SEGMENTS for(unsigned int i=0; i != chained_points.size(); i++) { printf("."); } @@ -1114,7 +1114,8 @@ static void flush_segments(void) { linearMoveMsg->type = EMC_MOTION_TYPE_FEED; linearMoveMsg->indexer_jnum = -1; if ((vel && acc) || canon.spindle[canon.spindle_num].synched) { - interp_list.set_line_number(line_no); + interp_list.set_line_number(pos.tag.fields[GM_FIELD_LINE_NUMBER]); + interp_list.set_filename(pos.tag.filename); tag_and_send(std::move(linearMoveMsg), pos.tag); } canonUpdateEndPoint(x, y, z, a, b, c, u, v, w); @@ -1188,7 +1189,7 @@ see_segment(int line_number, if(!chained_points.empty() && !linkable(x, y, z, a, b, c, u, v, w)) { flush_segments(); } - pt pos = {x, y, z, a, b, c, u, v, w, line_number, tag}; + pt pos = {x, y, z, a, b, c, u, v, w, tag}; chained_points.push_back(pos); if(changed_abc || changed_uvw) { flush_segments(); @@ -1317,7 +1318,8 @@ void STRAIGHT_TRAVERSE(int line_number, STOP_SPEED_FEED_SYNCH(); if(vel && acc) { - interp_list.set_line_number(line_number); + interp_list.set_line_number(_tag.fields[GM_FIELD_LINE_NUMBER]); + interp_list.set_filename(_tag.filename); tag_and_send(std::move(linearMoveMsg), _tag); } @@ -1373,8 +1375,9 @@ void RIGID_TAP(int line_number, double x, double y, double z, double scale) flush_segments(); if(ini_maxvel && acc) { - interp_list.set_line_number(line_number); - interp_list.append(std::move(rigidTapMsg)); + interp_list.set_line_number(_tag.fields[GM_FIELD_LINE_NUMBER]); + interp_list.set_filename(_tag.filename); + tag_and_send(std::move(rigidTapMsg), _tag); } // don't move the endpoint because after this move, we are back where we started @@ -1432,7 +1435,9 @@ void STRAIGHT_PROBE(int line_number, probeMsg->pos = to_ext_pose(x,y,z,a,b,c,u,v,w); if(vel && acc) { - interp_list.set_line_number(line_number); + interp_list.set_line_number(_tag.fields[GM_FIELD_LINE_NUMBER]); + interp_list.set_filename(_tag.filename); + //interp_list.set_line_number(line_number); interp_list.append(std::move(probeMsg)); } canonUpdateEndPoint(x, y, z, a, b, c, u, v, w); @@ -2909,7 +2914,9 @@ void ARC_FEED(int line_number, linearMoveMsg->acc = toExtAcc(a_max); linearMoveMsg->indexer_jnum = -1; if(vel && a_max){ - interp_list.set_line_number(line_number); + interp_list.set_line_number(_tag.fields[GM_FIELD_LINE_NUMBER]); + interp_list.set_filename(_tag.filename); + //interp_list.set_line_number(line_number); tag_and_send(std::move(linearMoveMsg), _tag); } } else { @@ -2936,7 +2943,9 @@ void ARC_FEED(int line_number, // The end point is still updated, but nothing is added to the interp list // seems to be a crude way to indicate a zero length segment? if(vel && a_max) { - interp_list.set_line_number(line_number); + interp_list.set_line_number(_tag.fields[GM_FIELD_LINE_NUMBER]); + interp_list.set_filename(_tag.filename); + //interp_list.set_line_number(line_number); tag_and_send(std::move(circularMoveMsg), _tag); } } @@ -4343,7 +4352,10 @@ int UNLOCK_ROTARY(int line_number, int joint_num) int old_feed_mode = canon.feed_mode; if(canon.feed_mode) STOP_SPEED_FEED_SYNCH(); - interp_list.set_line_number(line_number); + //interp_list.set_line_number(line_number); + interp_list.set_line_number(_tag.fields[GM_FIELD_LINE_NUMBER]); + interp_list.set_filename(_tag.filename); + // tag and send? interp_list.append(std::move(m)); // no need to update endpoint diff --git a/src/emc/task/emctask.cc b/src/emc/task/emctask.cc index a96f264e3d8..8221dc2f2ca 100644 --- a/src/emc/task/emctask.cc +++ b/src/emc/task/emctask.cc @@ -698,8 +698,9 @@ int emcTaskUpdate(EMC_TASK_STAT * stat) // execState set in main // interpState set in main - if (emcStatus->motion.traj.id > 0) { - stat->motionLine = emcStatus->motion.traj.id; + if (emcStatus->motion.traj.id.line_number > 0) { + //stat->motionLine = emcStatus->motion.traj.tag.fields[GM_FIELD_LINE_NUMBER]; + stat->motionLine = emcStatus->motion.traj.id.line_number; } // currentLine set in main // readLine set in main diff --git a/src/emc/task/emctaskmain.cc b/src/emc/task/emctaskmain.cc index 36d6b38a951..0837d0a94cd 100644 --- a/src/emc/task/emctaskmain.cc +++ b/src/emc/task/emctaskmain.cc @@ -662,6 +662,8 @@ static void mdi_execute_hook(void) && (interp_list.len() == 0) && (emcTaskCommand == NULL) ) { + interp_list.set_line_number(-mdi_execute_queue.len()); + interp_list.set_filename(":MDI:"); interp_list.append(mdi_execute_queue.get()); emcStatus->task.queuedMDIcommands = mdi_execute_queue.len(); return; @@ -2623,7 +2625,13 @@ static int emcTaskExecute(void) emcStatus->task.currentLine = interp_list.get_line_number(); emcStatus->task.callLevel = emcTaskPlanLevel(); // and set it for all subsystems which use queued ids - emcTrajSetMotionId(emcStatus->task.currentLine); + + std::string s_id = emcStatus->task.file; + emcmot_motion_id_t id = { + .line_number = emcStatus->task.currentLine, + .filename_hash = static_cast(std::hash{}(s_id) % UINT_MAX) + }; + emcTrajSetMotionId(id); if (emcStatus->motion.traj.queueFull) { emcStatus->task.execState = EMC_TASK_EXEC::WAITING_FOR_MOTION_QUEUE; diff --git a/src/emc/task/taskintf.cc b/src/emc/task/taskintf.cc index 486747b66d3..d26c6502406 100644 --- a/src/emc/task/taskintf.cc +++ b/src/emc/task/taskintf.cc @@ -1335,12 +1335,11 @@ int emcTrajSetAFEnable(unsigned char enable) return usrmotWriteEmcmotCommand(&emcmotCommand); } -int emcTrajSetMotionId(int id) +int emcTrajSetMotionId(emcmot_motion_id_t id) { - if (EMC_DEBUG_MOTION_TIME & emc_debug) { - if (id != TrajConfig.MotionId) { - rcs_print("Outgoing motion id is %d.\n", id); + if (id.id != TrajConfig.MotionId.id) { + rcs_print("Outgoing motion id is %d %u.\n", id.line_number, id.filename_hash); } } @@ -1359,7 +1358,7 @@ int emcTrajInit() TrajConfig.AxisMask = 0; TrajConfig.LinearUnits = 1.0; TrajConfig.AngularUnits = 1.0; - TrajConfig.MotionId = 0; + TrajConfig.MotionId = { .id=0 } ; TrajConfig.MaxVel = DEFAULT_TRAJ_MAX_VELOCITY; // init emcmot interface @@ -1609,8 +1608,8 @@ int emcTrajRigidTap(const EmcPose& pos, double vel, double ini_maxvel, double ac } -static int last_id = 0; -static int last_id_printed = 0; +static emcmot_motion_id_t last_id = {.id=0}; +static emcmot_motion_id_t last_id_printed = {.id=0}; static RCS_STATUS last_status = RCS_STATUS::UNINITIALIZED; static double last_id_time; @@ -1659,9 +1658,9 @@ int emcTrajUpdate(EMC_TRAJ_STAT * stat) stat->dtg = emcmotStatus.dtg; stat->current_vel = emcmotStatus.current_vel; if (EMC_DEBUG_MOTION_TIME & emc_debug) { - if (stat->id != last_id) { - if (last_id != last_id_printed) { - rcs_print("Motion id %d took %f seconds.\n", last_id, + if (stat->id.id != last_id.id) { + if (last_id.id != last_id_printed.id) { + rcs_print("Motion id %d %u took %f seconds.\n", last_id.line_number, last_id.filename_hash, etime() - last_id_time); last_id_printed = last_id; } @@ -1692,10 +1691,10 @@ int emcTrajUpdate(EMC_TRAJ_STAT * stat) if (EMC_DEBUG_MOTION_TIME & emc_debug) { if (stat->status == RCS_STATUS::DONE && last_status != RCS_STATUS::DONE - && stat->id != last_id_printed) { - rcs_print("Motion id %d took %f seconds.\n", last_id, + && stat->id.id != last_id_printed.id) { + rcs_print("Motion id %d %u took %f seconds.\n", last_id.line_number, last_id.filename_hash, etime() - last_id_time); - last_id_printed = last_id = stat->id; + last_id_printed.id = last_id.id = stat->id.id; last_id_time = etime(); } } @@ -2086,7 +2085,7 @@ int emcMotionUpdate(EMC_MOTION_STAT * stat) r3 = emcTrajUpdate(&stat->traj); r1 = emcJointUpdate(&stat->joint[0], stat->traj.joints); r2 = emcAxisUpdate(&stat->axis[0], stat->traj.axis_mask); - r3 = emcTrajUpdate(&stat->traj); + //r3 = emcTrajUpdate(&stat->traj); r4 = emcSpindleUpdate(&stat->spindle[0], stat->traj.spindles); stat->command_type = localMotionCommandType; stat->echo_serial_number = localMotionEchoSerialNumber; diff --git a/src/emc/tp/tc.c b/src/emc/tp/tc.c index 84a334ba6e1..25a06158fa0 100644 --- a/src/emc/tp/tc.c +++ b/src/emc/tp/tc.c @@ -465,7 +465,7 @@ int tcSetTermCond(TC_STRUCT *prev_tc, TC_STRUCT *tc, int term_cond) { } if (prev_tc) { - tp_debug_print("setting term condition %d on tc id %d, type %d\n", term_cond, prev_tc->id, prev_tc->motion_type); + tp_debug_print("setting term condition %d on tc id %ld, type %d\n", term_cond, prev_tc->id.id, prev_tc->motion_type); prev_tc->term_cond = term_cond; } return 0; @@ -635,7 +635,7 @@ int tcInit(TC_STRUCT * const tc, tc->enables = enables; tc->cycle_time = cycle_time; - tc->id = -1; //ID to be set when added to queue (may change before due to blend arcs) + tc->id.id = -1; //ID to be set when added to queue (may change before due to blend arcs) /** Segment settings (given values later during setup / optimization) */ tc->indexer_jnum = -1; diff --git a/src/emc/tp/tc_types.h b/src/emc/tp/tc_types.h index 492cf253b70..0bcd436ced1 100644 --- a/src/emc/tp/tc_types.h +++ b/src/emc/tp/tc_types.h @@ -146,7 +146,7 @@ typedef struct { double elapsed_time; // time elapsed since segment activation double last_move_length; // length of last move step for S-curve - int id; // segment's serial number + emcmot_motion_id_t id; // segment's serial number struct state_tag_t tag; // state tag corresponding to running motion union { // describes the segment's start and end positions diff --git a/src/emc/tp/tp.c b/src/emc/tp/tp.c index d326ef77f8a..88da1992dde 100644 --- a/src/emc/tp/tp.c +++ b/src/emc/tp/tp.c @@ -502,8 +502,8 @@ int tpClear(TP_STRUCT * const tp) tp->queueSize = 0; tp->goalPos = tp->currentPos; // Clear out status ID's - tp->nextId = 0; - tp->execId = 0; + tp->nextId.id = 0; + tp->execId.id = 0; struct state_tag_t tag = {}; tp->execTag = tag; tp->motionType = 0; @@ -553,8 +553,8 @@ int tpInit(TP_STRUCT * const tp) tp->spindle.offset = 0.0; tp->spindle.revs = 0.0; - tp->spindle.waiting_for_index = MOTION_INVALID_ID; - tp->spindle.waiting_for_atspeed = MOTION_INVALID_ID; + tp->spindle.waiting_for_index.id = MOTION_INVALID_ID; + tp->spindle.waiting_for_atspeed.id = MOTION_INVALID_ID; tp->reverse_run = TC_DIR_FORWARD; tp->termCond = TC_TERM_COND_PARABOLIC; @@ -640,11 +640,11 @@ int tpSetAmax(TP_STRUCT * const tp, double aMax) * ids for each motion, call this before each motion you append and stick what * you want in here. */ -int tpSetId(TP_STRUCT * const tp, int id) +int tpSetId(TP_STRUCT * const tp, emcmot_motion_id_t id) { if (!MOTION_ID_VALID(id)) { - rtapi_print_msg(RTAPI_MSG_ERR, "tpSetId: invalid motion id %d\n", id); + rtapi_print_msg(RTAPI_MSG_ERR, "tpSetId: invalid motion id %ld\n", id.id); return TP_ERR_FAIL; } @@ -659,10 +659,12 @@ int tpSetId(TP_STRUCT * const tp, int id) /** Returns the id of the last motion that is currently executing.*/ -int tpGetExecId(TP_STRUCT * const tp) +emcmot_motion_id_t tpGetExecId(TP_STRUCT * const tp) { if (0 == tp) { - return TP_ERR_FAIL; + // FIXME return invalid motion id + emcmot_motion_id_t ret = {.id = TP_ERR_FAIL}; + return ret; } return tp->execId; @@ -744,9 +746,9 @@ int tpSetCurrentPos(TP_STRUCT * const tp, EmcPose const * const pos) tp->currentPos = *pos; return TP_ERR_OK; } else { - rtapi_print_msg(RTAPI_MSG_ERR, "Tried to set invalid pose in tpSetCurrentPos on id %d!" + rtapi_print_msg(RTAPI_MSG_ERR, "Tried to set invalid pose in tpSetCurrentPos on id %ld!" "pos is %.12g, %.12g, %.12g\n", - tp->execId, + tp->execId.id, pos->tran.x, pos->tran.y, pos->tran.z); @@ -765,9 +767,9 @@ int tpAddCurrentPos(TP_STRUCT * const tp, EmcPose const * const disp) emcPoseSelfAdd(&tp->currentPos, disp); return TP_ERR_OK; } else { - rtapi_print_msg(RTAPI_MSG_ERR, "Tried to set invalid pose in tpAddCurrentPos on id %d!" + rtapi_print_msg(RTAPI_MSG_ERR, "Tried to set invalid pose in tpAddCurrentPos on id %ld!" "disp is %.12g, %.12g, %.12g\n", - tp->execId, + tp->execId.id, disp->tran.x, disp->tran.y, disp->tran.z); @@ -1588,7 +1590,8 @@ STATIC inline int tpAddSegmentToQueue(TP_STRUCT * const tp, TC_STRUCT * const tc return TP_ERR_FAIL; } if (inc_id) { - tp->nextId++; + // FIXME + tp->nextId.line_number++; } // Store end of current move as new final goal of TP @@ -2171,7 +2174,7 @@ int tpAddLine(TP_STRUCT * const tp, EmcPose end, int canon_motion_type, &end); tc.target = pmLine9Target(&tc.coords.line); if (tc.target < TP_POS_EPSILON) { - rtapi_print_msg(RTAPI_MSG_DBG,"failed to create line id %d, zero-length segment\n",tp->nextId); + rtapi_print_msg(RTAPI_MSG_DBG,"failed to create line id %ld, zero-length segment\n", tp->nextId.id); return TP_ERR_ZERO_LENGTH; } tc.nominal_length = tc.target; @@ -2984,8 +2987,8 @@ STATIC int tpUpdateMovementStatus(TP_STRUCT * const tp, TC_STRUCT const * const EmcPose tc_pos; tcGetEndpoint(tc, &tc_pos); - tc_debug_print("tc id = %u canon_type = %u motion_type = %u\n", - tc->id, tc->canon_motion_type, tc->motion_type); + tc_debug_print("tc id = %ld canon_type = %u motion_type = %u\n", + tc->id.id, tc->canon_motion_type, tc->motion_type); tp->motionType = tc->canon_motion_type; tp->activeDepth = tc->active_depth; emcmotStatus->distance_to_go = tc->target - tc->progress; @@ -3054,7 +3057,7 @@ STATIC void tpHandleEmptyQueue(TP_STRUCT * const tp) tp->done = 1; tp->depth = tp->activeDepth = 0; tp->aborting = 0; - tp->execId = 0; + tp->execId.id = 0; tp->motionType = 0; tpUpdateMovementStatus(tp, NULL); @@ -3082,7 +3085,7 @@ STATIC int tpGetRotaryIsUnlocked(int axis) { STATIC int tpCompleteSegment(TP_STRUCT * const tp, TC_STRUCT * const tc) { - if (tp->spindle.waiting_for_atspeed == tc->id) { + if (tp->spindle.waiting_for_atspeed.id == tc->id.id) { return TP_ERR_FAIL; } @@ -3150,12 +3153,12 @@ STATIC tp_err_t tpHandleAbort(TP_STRUCT * const tp, TC_STRUCT * const tc, tp->done = 1; tp->depth = tp->activeDepth = 0; tp->aborting = 0; - tp->execId = 0; + tp->execId.id = 0; tp->motionType = 0; tp->synchronized = 0; tp->reverse_run = 0; - tp->spindle.waiting_for_index = MOTION_INVALID_ID; - tp->spindle.waiting_for_atspeed = MOTION_INVALID_ID; + tp->spindle.waiting_for_index.id = MOTION_INVALID_ID; + tp->spindle.waiting_for_atspeed.id = MOTION_INVALID_ID; tpResume(tp); return TP_ERR_STOPPED; } //FIXME consistent error codes @@ -3173,21 +3176,21 @@ STATIC tp_err_t tpCheckAtSpeed(TP_STRUCT * const tp, TC_STRUCT * const tc) { int s; // this is no longer the segment we were waiting_for_index for - if (MOTION_ID_VALID(tp->spindle.waiting_for_index) && tp->spindle.waiting_for_index != tc->id) + if (MOTION_ID_VALID(tp->spindle.waiting_for_index) && tp->spindle.waiting_for_index.id != tc->id.id) { rtapi_print_msg(RTAPI_MSG_ERR, - "Was waiting for index on motion id %d, but reached id %d\n", - tp->spindle.waiting_for_index, tc->id); - tp->spindle.waiting_for_index = MOTION_INVALID_ID; + "Was waiting for index on motion id %ld, but reached id %ld\n", + tp->spindle.waiting_for_index.id, tc->id.id); + tp->spindle.waiting_for_index.id = MOTION_INVALID_ID; } - if (MOTION_ID_VALID(tp->spindle.waiting_for_atspeed) && tp->spindle.waiting_for_atspeed != tc->id) + if (MOTION_ID_VALID(tp->spindle.waiting_for_atspeed) && tp->spindle.waiting_for_atspeed.id != tc->id.id) { rtapi_print_msg(RTAPI_MSG_ERR, - "Was waiting for atspeed on motion id %d, but reached id %d\n", - tp->spindle.waiting_for_atspeed, tc->id); - tp->spindle.waiting_for_atspeed = MOTION_INVALID_ID; + "Was waiting for atspeed on motion id %ld, but reached id %ld\n", + tp->spindle.waiting_for_atspeed.id, tc->id.id); + tp->spindle.waiting_for_atspeed.id = MOTION_INVALID_ID; } if (MOTION_ID_VALID(tp->spindle.waiting_for_atspeed)) { @@ -3198,7 +3201,7 @@ STATIC tp_err_t tpCheckAtSpeed(TP_STRUCT * const tp, TC_STRUCT * const tc) } } // not waiting any more - tp->spindle.waiting_for_atspeed = MOTION_INVALID_ID; + tp->spindle.waiting_for_atspeed.id = MOTION_INVALID_ID; } if (MOTION_ID_VALID(tp->spindle.waiting_for_index)) { @@ -3209,7 +3212,7 @@ STATIC tp_err_t tpCheckAtSpeed(TP_STRUCT * const tp, TC_STRUCT * const tc) rtapi_print_msg(RTAPI_MSG_DBG, "Index seen on spindle %d\n", tp->spindle.spindle_num); /* passed index, start the move */ emcmotStatus->spindleSync = 1; - tp->spindle.waiting_for_index = MOTION_INVALID_ID; + tp->spindle.waiting_for_index.id = MOTION_INVALID_ID; tc->sync_accel = 1; tp->spindle.revs = 0; } @@ -3572,8 +3575,8 @@ STATIC inline int tcSetSplitCycle(TC_STRUCT * const tc, double split_time, { tp_debug_print("split time for id %d is %.16g\n", tc->id, split_time); if (tc->splitting != 0 && split_time > 0.0) { - rtapi_print_msg(RTAPI_MSG_ERR,"already splitting on id %d with cycle time %.16g, dx = %.16g, split time %.12g\n", - tc->id, + rtapi_print_msg(RTAPI_MSG_ERR,"already splitting on id %ld with cycle time %.16g, dx = %.16g, split time %.12g\n", + tc->id.id, tc->cycle_time, tc->target-tc->progress, split_time); @@ -3749,9 +3752,9 @@ STATIC int tpHandleSplitCycle(TP_STRUCT * const tp, TC_STRUCT * const tc, case TC_TERM_COND_EXACT: break; default: - rtapi_print_msg(RTAPI_MSG_ERR,"unknown term cond %d in segment %d\n", + rtapi_print_msg(RTAPI_MSG_ERR,"unknown term cond %d in segment %ld\n", tc->term_cond, - tc->id); + tc->id.id); } // Run split cycle update with remaining time in nexttc @@ -4085,7 +4088,7 @@ int tpIsMoving(TP_STRUCT const * const tp) if (emcmotStatus->current_vel >= TP_VEL_EPSILON ) { tp_debug_print("TP moving, current_vel = %.16g\n", emcmotStatus->current_vel); return true; - } else if (tp->spindle.waiting_for_index != MOTION_INVALID_ID || tp->spindle.waiting_for_atspeed != MOTION_INVALID_ID) { + } else if (tp->spindle.waiting_for_index.id != MOTION_INVALID_ID || tp->spindle.waiting_for_atspeed.id != MOTION_INVALID_ID) { tp_debug_print("TP moving, waiting for index or atspeed\n"); return true; } diff --git a/src/emc/tp/tp.h b/src/emc/tp/tp.h index c8867bf45eb..13d80997eda 100644 --- a/src/emc/tp/tp.h +++ b/src/emc/tp/tp.h @@ -36,8 +36,8 @@ int tpSetCycleTime(TP_STRUCT * tp, double secs); int tpSetVmax(TP_STRUCT * tp, double vmax, double ini_maxvel); int tpSetVlimit(TP_STRUCT * tp, double limit); int tpSetAmax(TP_STRUCT * tp, double amax); -int tpSetId(TP_STRUCT * tp, int id); -int tpGetExecId(TP_STRUCT * tp); +int tpSetId(TP_STRUCT * tp, emcmot_motion_id_t id); +emcmot_motion_id_t tpGetExecId(TP_STRUCT * tp); struct state_tag_t tpGetExecTag(TP_STRUCT * const tp); int tpSetTermCond(TP_STRUCT * tp, int cond, double tolerance); int tpSetPos(TP_STRUCT * tp, EmcPose const * const pos); diff --git a/src/emc/tp/tp_types.h b/src/emc/tp/tp_types.h index 89dd0849055..6470e2adf4f 100644 --- a/src/emc/tp/tp_types.h +++ b/src/emc/tp/tp_types.h @@ -81,8 +81,8 @@ typedef struct { int spindle_num; double offset; double revs; - int waiting_for_index; - int waiting_for_atspeed; + emcmot_motion_id_t waiting_for_index; + emcmot_motion_id_t waiting_for_atspeed; } tp_spindle_t; /** @@ -114,8 +114,8 @@ typedef struct { double wMax; /* rotational velocity max */ double wDotMax; /* rotational acceleration max */ - int nextId; - int execId; + emcmot_motion_id_t nextId; + emcmot_motion_id_t execId; struct state_tag_t execTag; /* state tag corresponding to running motion */ int termCond; int done;