Skip to content

Commit f17e2ff

Browse files
authored
Merge pull request #2499 from rene-dev/cpp-enum
convert enums to enum class in task and interp
2 parents ba5ca74 + a358230 commit f17e2ff

47 files changed

Lines changed: 1096 additions & 1100 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/emc/canterp/canterp.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,15 +347,15 @@ int Canterp::execute(const char *line) {
347347

348348
if (!strcmp(the_command_name, "SELECT_PLANE")) {
349349
if (!strcmp(the_command_args, "CANON_PLANE_XY")) {
350-
SELECT_PLANE(CANON_PLANE_XY);
350+
SELECT_PLANE(CANON_PLANE::XY);
351351
return 0;
352352
}
353353
if (!strcmp(the_command_args, "CANON_PLANE_YZ")) {
354-
SELECT_PLANE(CANON_PLANE_YZ);
354+
SELECT_PLANE(CANON_PLANE::YZ);
355355
return 0;
356356
}
357357
if (!strcmp(the_command_args, "CANON_PLANE_XZ")) {
358-
SELECT_PLANE(CANON_PLANE_XZ);
358+
SELECT_PLANE(CANON_PLANE::XZ);
359359
return 0;
360360
}
361361
return INTERP_ERROR;

src/emc/iotask/ioControl.cc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ static int emcIoNmlGet()
165165
emcioStatus.heartbeat = 0;
166166
emcioStatus.command_type = 0;
167167
emcioStatus.echo_serial_number = 0;
168-
emcioStatus.status = RCS_DONE;
168+
emcioStatus.status = RCS_STATUS::DONE;
169169
emcioStatusBuffer->write(&emcioStatus);
170170
}
171171
}
@@ -562,7 +562,7 @@ void load_tool(int idx) {
562562
}
563563

564564
if (0 != tooldata_save(io_tool_table_file)) {
565-
emcioStatus.status = RCS_ERROR;
565+
emcioStatus.status = RCS_STATUS::ERROR;
566566
}
567567
} else if(idx == 0) {
568568
// on non-random tool-changers, asking for pocket 0 is the secret
@@ -622,7 +622,7 @@ static int read_tool_inputs(void)
622622
if (*iocontrol_data->tool_prepare && *iocontrol_data->tool_prepared) {
623623
emcioStatus.tool.pocketPrepped = *iocontrol_data->tool_prep_index; //check if tool has been (idx) prepared
624624
*(iocontrol_data->tool_prepare) = 0;
625-
emcioStatus.status = RCS_DONE; // we finally finished to do tool-changing, signal task with RCS_DONE
625+
emcioStatus.status = RCS_STATUS::DONE; // we finally finished to do tool-changing, signal task with RCS_DONE
626626
return 10; //prepped finished
627627
}
628628

@@ -649,7 +649,7 @@ static int read_tool_inputs(void)
649649
*(iocontrol_data->tool_prep_pocket) = 0; //likewise in HAL
650650
*(iocontrol_data->tool_prep_index) = 0; //likewise in HAL
651651
*(iocontrol_data->tool_change) = 0; //also reset the tool change signal
652-
emcioStatus.status = RCS_DONE; // we finally finished to do tool-changing, signal task with RCS_DONE
652+
emcioStatus.status = RCS_STATUS::DONE; // we finally finished to do tool-changing, signal task with RCS_DONE
653653
return 11; //change finished
654654
}
655655
return 0;
@@ -835,7 +835,7 @@ int main(int argc, char *argv[])
835835
}
836836

837837
type = emcioCommand->type;
838-
emcioStatus.status = RCS_DONE;
838+
emcioStatus.status = RCS_STATUS::DONE;
839839

840840
switch (type) {
841841
case 0:
@@ -921,7 +921,7 @@ int main(int argc, char *argv[])
921921
// the feedback logic is done inside read_hal_inputs()
922922
// we only need to set RCS_EXEC if RCS_DONE is not already set by the above logic
923923
if (tool_status != 10) //set above to 10 in case PREP already finished (HAL loopback machine)
924-
emcioStatus.status = RCS_EXEC;
924+
emcioStatus.status = RCS_STATUS::EXEC;
925925
}
926926
break;
927927
case EMC_TOOL_LOAD_TYPE:
@@ -952,7 +952,7 @@ int main(int argc, char *argv[])
952952
if (tool_status != 11)
953953
// set above to 11 in case LOAD already finished (HAL
954954
// loopback machine)
955-
emcioStatus.status = RCS_EXEC;
955+
emcioStatus.status = RCS_STATUS::EXEC;
956956
}
957957
break;
958958
}
@@ -968,7 +968,7 @@ int main(int argc, char *argv[])
968968
if(!strlen(filename)) filename = io_tool_table_file;
969969
rtapi_print_msg(RTAPI_MSG_DBG, "EMC_TOOL_LOAD_TOOL_TABLE\n");
970970
if (0 != tooldata_load(filename)) {
971-
emcioStatus.status = RCS_ERROR;
971+
emcioStatus.status = RCS_STATUS::ERROR;
972972
} else {
973973
reload_tool_number(emcioStatus.tool.toolInSpindle);
974974
}
@@ -1007,7 +1007,7 @@ int main(int argc, char *argv[])
10071007
UNEXPECTED_MSG;
10081008
}
10091009
if (0 != tooldata_save(io_tool_table_file)) {
1010-
emcioStatus.status = RCS_ERROR;
1010+
emcioStatus.status = RCS_STATUS::ERROR;
10111011
}
10121012
if (io_db_mode == DB_ACTIVE) {
10131013
int pno = idx; // for random_toolchanger

src/emc/iotask/ioControl_v2.cc

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ static int emcIoNmlGet()
253253
emcioStatus.heartbeat = 0;
254254
emcioStatus.command_type = 0;
255255
emcioStatus.echo_serial_number = 0;
256-
emcioStatus.status = RCS_DONE;
256+
emcioStatus.status = RCS_STATUS::DONE;
257257
emcioStatusBuffer->write(&emcioStatus);
258258
}
259259
}
@@ -515,7 +515,7 @@ void load_tool(int idx) {
515515
}
516516

517517
if (0 != tooldata_save(io_tool_table_file)) {
518-
emcioStatus.status = RCS_ERROR;
518+
emcioStatus.status = RCS_STATUS::ERROR;
519519
}
520520
} else if(idx == 0) {
521521
// magic T0 = pocket 0 = no tool
@@ -736,14 +736,14 @@ static void do_hal_exit(void) {
736736
}
737737

738738

739-
static void update_status(int status, int serial)
739+
static void update_status(RCS_STATUS status, int serial)
740740
{
741-
static int status_reported = -1;
741+
static RCS_STATUS status_reported = RCS_STATUS::UNINITIALIZED;
742742

743743
emcioStatus.status = status;
744744
if (status_reported != status) {
745745
rtapi_print_msg(RTAPI_MSG_DBG, "%s: updating status=%s state=%s fault=%d reason=%d\n",
746-
progname,strcs[emcioStatus.status],strstate[*(iocontrol_data->state)],
746+
progname,strcs[(int)emcioStatus.status],strstate[*(iocontrol_data->state)],//BUG: array accessed at -1 when status is RCS_STATUS::UNINITIALIZED
747747
emcioStatus.fault, emcioStatus.reason
748748
);
749749
status_reported = emcioStatus.status; // just print this once
@@ -919,11 +919,11 @@ int main(int argc, char *argv[])
919919
rtapi_print_msg(RTAPI_MSG_DBG, "%s:lube_level changed to %d\n",progname,emcioStatus.lube.level);
920920

921921
// need for different serial number, because we are pushing a new message
922-
update_status(RCS_DONE, emcioCommand->serial_number + 1);
922+
update_status(RCS_STATUS::DONE, emcioCommand->serial_number + 1);
923923
}
924924

925925
if (input_status & (TI_PREPARING)) {
926-
update_status(RCS_EXEC, emcioCommand->serial_number);
926+
update_status(RCS_STATUS::EXEC, emcioCommand->serial_number);
927927
}
928928

929929
if (input_status & (TI_START_CHANGE|TI_CHANGING)) {
@@ -934,15 +934,15 @@ int main(int argc, char *argv[])
934934
strstate[*(iocontrol_data->state)],
935935
str_input(input_status)
936936
);
937-
update_status(RCS_ERROR, emcioCommand->serial_number);
937+
update_status(RCS_STATUS::ERROR, emcioCommand->serial_number);
938938
} else {
939-
update_status(RCS_EXEC, emcioCommand->serial_number);
939+
update_status(RCS_STATUS::EXEC, emcioCommand->serial_number);
940940
}
941941
}
942942

943943
// if (input_status & (TI_PREPARE_COMPLETE|TI_CHANGE_COMPLETE|TI_START_CHANGE_ACKED|TI_EMC_ABORT_ACKED))
944944
if (input_status & (TI_PREPARE_COMPLETE|TI_CHANGE_COMPLETE|TI_START_CHANGE_ACKED)) {
945-
update_status(RCS_DONE, emcioCommand->serial_number);
945+
update_status(RCS_STATUS::DONE, emcioCommand->serial_number);
946946
}
947947

948948
/* read NML, run commands */
@@ -970,7 +970,7 @@ int main(int argc, char *argv[])
970970
* to cause an abort, set emcioStatus.reason and
971971
* emcioStatus.status to RCS_ERROR.
972972
*/
973-
emcioStatus.status = RCS_DONE;
973+
emcioStatus.status = RCS_STATUS::DONE;
974974
type = emcioCommand->type;
975975

976976
switch (type) {
@@ -1061,7 +1061,7 @@ int main(int argc, char *argv[])
10611061

10621062
// delay fetching the next message until prepare done
10631063
if (!(input_status & TI_PREPARE_COMPLETE)) {
1064-
emcioStatus.status = RCS_EXEC;
1064+
emcioStatus.status = RCS_STATUS::EXEC;
10651065
}
10661066
}
10671067
}
@@ -1093,7 +1093,7 @@ int main(int argc, char *argv[])
10931093

10941094
// delay fetching the next message until change done
10951095
if (! (input_status & TI_CHANGE_COMPLETE)) {
1096-
emcioStatus.status = RCS_EXEC;
1096+
emcioStatus.status = RCS_STATUS::EXEC;
10971097
}
10981098
}
10991099
break;
@@ -1106,7 +1106,7 @@ int main(int argc, char *argv[])
11061106
*(iocontrol_data->state) = ST_START_CHANGE;
11071107
// delay fetching the next message until ack line seen
11081108
if (! (input_status & TI_START_CHANGE_ACKED)) {
1109-
emcioStatus.status = RCS_EXEC;
1109+
emcioStatus.status = RCS_STATUS::EXEC;
11101110
}
11111111
}
11121112
break;
@@ -1123,7 +1123,7 @@ int main(int argc, char *argv[])
11231123
if(!strlen(filename)) filename = io_tool_table_file;
11241124
rtapi_print_msg(RTAPI_MSG_DBG, "EMC_TOOL_LOAD_TOOL_TABLE\n");
11251125
if (0 != tooldata_load(filename)) {
1126-
emcioStatus.status = RCS_ERROR;
1126+
emcioStatus.status = RCS_STATUS::ERROR;
11271127
} else {
11281128
reload_tool_number(emcioStatus.tool.toolInSpindle);
11291129
}
@@ -1163,7 +1163,7 @@ int main(int argc, char *argv[])
11631163
UNEXPECTED_MSG;
11641164
}
11651165
if (0 != tooldata_save(io_tool_table_file)) {
1166-
emcioStatus.status = RCS_ERROR;
1166+
emcioStatus.status = RCS_STATUS::ERROR;
11671167
}
11681168
if (io_db_mode == DB_ACTIVE) {
11691169
int pno = idx; // for random_toolchanger

src/emc/nml_intf/canon.hh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ struct NURBS_G6_DPLANE_POINT {
7171
}; //è impiegata per salvare le derivate x'(u) y'(u).
7272

7373

74-
enum CANON_PLANE {
75-
CANON_PLANE_XY = 1,
76-
CANON_PLANE_YZ,
77-
CANON_PLANE_XZ,
78-
CANON_PLANE_UV,
79-
CANON_PLANE_VW,
80-
CANON_PLANE_UW,
74+
enum class CANON_PLANE {
75+
XY = 1,
76+
YZ,
77+
XZ,
78+
UV,
79+
VW,
80+
UW,
8181
};
8282

8383
enum CANON_UNITS
@@ -552,12 +552,12 @@ extern std::vector<double> nurbs_G6_knot_vector_new_creator_sgment(unsigned int
552552

553553
/* Canon calls */
554554

555-
extern void NURBS_G5_FEED(int lineno, std::vector<NURBS_CONTROL_POINT> nurbs_control_points, unsigned int nurbs_order, int plane);
555+
extern void NURBS_G5_FEED(int lineno, std::vector<NURBS_CONTROL_POINT> nurbs_control_points, unsigned int nurbs_order, CANON_PLANE plane);
556556
/* Move at the feed rate along an approximation of a NURBS with a variable number
557557
* of control points
558558
*/
559559

560-
extern void NURBS_G6_FEED(int lineno, std::vector<NURBS_G6_CONTROL_POINT> nurbs_control_points, unsigned int k, double feedrate, int l, int plane);
560+
extern void NURBS_G6_FEED(int lineno, std::vector<NURBS_G6_CONTROL_POINT> nurbs_control_points, unsigned int k, double feedrate, int l, CANON_PLANE plane);
561561
// this is for G6xx
562562

563563
extern double alpha_finder(double dx, double dy);

src/emc/nml_intf/emc.hh

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -246,46 +246,46 @@ struct PM_CARTESIAN;
246246
#define EMC_STAT_TYPE ((NMLTYPE) 1999)
247247

248248
// types for EMC_TASK mode
249-
enum EMC_TASK_MODE_ENUM {
250-
EMC_TASK_MODE_MANUAL = 1,
251-
EMC_TASK_MODE_AUTO = 2,
252-
EMC_TASK_MODE_MDI = 3
249+
enum class EMC_TASK_MODE {
250+
MANUAL = 1,
251+
AUTO = 2,
252+
MDI = 3
253253
};
254254

255255
// types for EMC_TASK state
256-
enum EMC_TASK_STATE_ENUM {
257-
EMC_TASK_STATE_ESTOP = 1,
258-
EMC_TASK_STATE_ESTOP_RESET = 2,
259-
EMC_TASK_STATE_OFF = 3,
260-
EMC_TASK_STATE_ON = 4
256+
enum class EMC_TASK_STATE {
257+
ESTOP = 1,
258+
ESTOP_RESET = 2,
259+
OFF = 3,
260+
ON = 4
261261
};
262262

263263
// types for EMC_TASK execState
264-
enum EMC_TASK_EXEC_ENUM {
265-
EMC_TASK_EXEC_ERROR = 1,
266-
EMC_TASK_EXEC_DONE = 2,
267-
EMC_TASK_EXEC_WAITING_FOR_MOTION = 3,
268-
EMC_TASK_EXEC_WAITING_FOR_MOTION_QUEUE = 4,
269-
EMC_TASK_EXEC_WAITING_FOR_IO = 5,
270-
EMC_TASK_EXEC_WAITING_FOR_MOTION_AND_IO = 7,
271-
EMC_TASK_EXEC_WAITING_FOR_DELAY = 8,
272-
EMC_TASK_EXEC_WAITING_FOR_SYSTEM_CMD = 9,
273-
EMC_TASK_EXEC_WAITING_FOR_SPINDLE_ORIENTED = 10
264+
enum class EMC_TASK_EXEC {
265+
ERROR = 1,
266+
DONE = 2,
267+
WAITING_FOR_MOTION = 3,
268+
WAITING_FOR_MOTION_QUEUE = 4,
269+
WAITING_FOR_IO = 5,
270+
WAITING_FOR_MOTION_AND_IO = 7,
271+
WAITING_FOR_DELAY = 8,
272+
WAITING_FOR_SYSTEM_CMD = 9,
273+
WAITING_FOR_SPINDLE_ORIENTED = 10
274274
};
275275

276276
// types for EMC_TASK interpState
277-
enum EMC_TASK_INTERP_ENUM {
278-
EMC_TASK_INTERP_IDLE = 1,
279-
EMC_TASK_INTERP_READING = 2,
280-
EMC_TASK_INTERP_PAUSED = 3,
281-
EMC_TASK_INTERP_WAITING = 4
277+
enum class EMC_TASK_INTERP {
278+
IDLE = 1,
279+
READING = 2,
280+
PAUSED = 3,
281+
WAITING = 4
282282
};
283283

284284
// types for motion control
285-
enum EMC_TRAJ_MODE_ENUM {
286-
EMC_TRAJ_MODE_FREE = 1, // independent-axis motion,
287-
EMC_TRAJ_MODE_COORD = 2, // coordinated-axis motion,
288-
EMC_TRAJ_MODE_TELEOP = 3 // velocity based world coordinates motion,
285+
enum class EMC_TRAJ_MODE {
286+
FREE = 1, // independent-axis motion,
287+
COORD = 2, // coordinated-axis motion,
288+
TELEOP = 3 // velocity based world coordinates motion,
289289
};
290290

291291
// types for emcIoAbort() reasons
@@ -398,7 +398,7 @@ extern int emcTrajSetAxes(int axismask);
398398
extern int emcTrajSetSpindles(int spindles);
399399
extern int emcTrajSetUnits(double linearUnits, double angularUnits);
400400
extern int emcTrajSetCycleTime(double cycleTime);
401-
extern int emcTrajSetMode(int traj_mode);
401+
extern int emcTrajSetMode(EMC_TRAJ_MODE traj_mode);
402402
extern int emcTrajSetVelocity(double vel, double ini_maxvel);
403403
extern int emcTrajSetAcceleration(double acc);
404404
extern int emcTrajSetMaxVelocity(double vel);

src/emc/nml_intf/emc_nml.hh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ class EMC_TRAJ_SET_MODE:public EMC_TRAJ_CMD_MSG {
602602
// For internal NML/CMS use only.
603603
void update(CMS * cms);
604604

605-
enum EMC_TRAJ_MODE_ENUM mode;
605+
EMC_TRAJ_MODE mode;
606606
};
607607

608608
class EMC_TRAJ_SET_VELOCITY:public EMC_TRAJ_CMD_MSG {
@@ -1034,8 +1034,8 @@ class EMC_TRAJ_STAT:public EMC_TRAJ_STAT_MSG {
10341034
int joints; // maximum joint number
10351035
int spindles; // maximum spindle number
10361036
int axis_mask; // mask of axes actually present
1037-
enum EMC_TRAJ_MODE_ENUM mode; // EMC_TRAJ_MODE_FREE,
1038-
// EMC_TRAJ_MODE_COORD
1037+
EMC_TRAJ_MODE mode; // EMC_TRAJ_MODE::FREE,
1038+
// EMC_TRAJ_MODE::COORD
10391039
bool enabled; // non-zero means enabled
10401040

10411041
bool inpos; // non-zero means in position
@@ -1282,7 +1282,7 @@ class EMC_TASK_SET_MODE:public EMC_TASK_CMD_MSG {
12821282
// For internal NML/CMS use only.
12831283
void update(CMS * cms);
12841284

1285-
enum EMC_TASK_MODE_ENUM mode;
1285+
EMC_TASK_MODE mode;
12861286
};
12871287

12881288
class EMC_TASK_SET_STATE:public EMC_TASK_CMD_MSG {
@@ -1294,7 +1294,7 @@ class EMC_TASK_SET_STATE:public EMC_TASK_CMD_MSG {
12941294
// For internal NML/CMS use only.
12951295
void update(CMS * cms);
12961296

1297-
enum EMC_TASK_STATE_ENUM state;
1297+
EMC_TASK_STATE state;
12981298
};
12991299

13001300
class EMC_TASK_PLAN_OPEN:public EMC_TASK_CMD_MSG {
@@ -1488,11 +1488,11 @@ class EMC_TASK_STAT:public EMC_TASK_STAT_MSG {
14881488
// For internal NML/CMS use only.
14891489
void update(CMS * cms);
14901490

1491-
enum EMC_TASK_MODE_ENUM mode; // EMC_TASK_MODE_MANUAL, etc.
1492-
enum EMC_TASK_STATE_ENUM state; // EMC_TASK_STATE_ESTOP, etc.
1491+
EMC_TASK_MODE mode; // EMC_TASK_MODE::MANUAL, etc.
1492+
EMC_TASK_STATE state; // EMC_TASK_STATE::ESTOP, etc.
14931493

1494-
enum EMC_TASK_EXEC_ENUM execState; // EMC_DONE,WAITING_FOR_MOTION, etc.
1495-
enum EMC_TASK_INTERP_ENUM interpState; // EMC_IDLE,READING,PAUSED,WAITING
1494+
EMC_TASK_EXEC execState; // EMC_DONE,WAITING_FOR_MOTION, etc.
1495+
EMC_TASK_INTERP interpState; // EMC_IDLE,READING,PAUSED,WAITING
14961496
int callLevel; // current subroutine level - 0 if not in a subroutine, > 0 otherwise
14971497
int motionLine; // line motion is executing-- may lag
14981498
int currentLine; // line currently executing

0 commit comments

Comments
 (0)