Skip to content

Commit a0d619c

Browse files
committed
task: change c enums to class enums
1 parent eb5b603 commit a0d619c

15 files changed

Lines changed: 380 additions & 387 deletions

File tree

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

src/emc/nml_intf/emcops.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ EMC_TRAJ_STAT_MSG(EMC_TRAJ_STAT_TYPE, sizeof(EMC_TRAJ_STAT)),
6060
cycleTime = 0.0;
6161
joints = 1;
6262
axis_mask = 1;
63-
mode = EMC_TRAJ_MODE_FREE;
63+
mode = EMC_TRAJ_MODE::FREE;
6464
enabled = OFF;
6565
inpos = ON;
6666
queue = 0;
@@ -117,10 +117,10 @@ EMC_TASK_STAT_MSG(EMC_TASK_STAT_TYPE, sizeof(EMC_TASK_STAT))
117117
{
118118
int t;
119119

120-
mode = EMC_TASK_MODE_MANUAL;
121-
state = EMC_TASK_STATE_ESTOP;
122-
execState = EMC_TASK_EXEC_DONE;
123-
interpState = EMC_TASK_INTERP_IDLE;
120+
mode = EMC_TASK_MODE::MANUAL;
121+
state = EMC_TASK_STATE::ESTOP;
122+
execState = EMC_TASK_EXEC::DONE;
123+
interpState = EMC_TASK_INTERP::IDLE;
124124
callLevel = 0;
125125
motionLine = 0;
126126
currentLine = 0;

src/emc/task/emctask.cc

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
//note:the +1 is for the PROGRAM_PREFIX or default directory==nc_files
4242

4343
/* flag for how we want to interpret traj coord mode, as mdi or auto */
44-
static int mdiOrAuto = EMC_TASK_MODE_AUTO;
44+
static EMC_TASK_MODE mdiOrAuto = EMC_TASK_MODE::AUTO;
4545

4646
InterpBase *pinterp=0;
4747
#define interp (*pinterp)
@@ -219,7 +219,7 @@ int emcTaskStateRestore()
219219
{
220220
int res = 0;
221221
// Do NOT restore on MDI command
222-
if (emcStatus->task.mode == EMC_TASK_MODE_AUTO) {
222+
if (emcStatus->task.mode == EMC_TASK_MODE::AUTO) {
223223
// Validity of state tag checked within restore function
224224
res = pinterp->restore_from_tag(emcStatus->motion.traj.tag);
225225
}
@@ -235,8 +235,8 @@ int emcTaskAbort()
235235
interp_list.clear();
236236

237237
// clear out the interpreter state
238-
emcStatus->task.interpState = EMC_TASK_INTERP_IDLE;
239-
emcStatus->task.execState = EMC_TASK_EXEC_DONE;
238+
emcStatus->task.interpState = EMC_TASK_INTERP::IDLE;
239+
emcStatus->task.execState = EMC_TASK_EXEC::DONE;
240240
emcStatus->task.task_paused = 0;
241241
emcStatus->task.motionLine = 0;
242242
emcStatus->task.readLine = 0;
@@ -265,7 +265,7 @@ int emcTaskAbort()
265265
return 0;
266266
}
267267

268-
int emcTaskSetMode(int mode)
268+
int emcTaskSetMode(EMC_TASK_MODE mode)
269269
{
270270
int retval = 0;
271271

@@ -275,30 +275,30 @@ int emcTaskSetMode(int mode)
275275
}
276276

277277
switch (mode) {
278-
case EMC_TASK_MODE_MANUAL:
278+
case EMC_TASK_MODE::MANUAL:
279279
// go to manual mode
280280
if (all_homed()) {
281-
emcTrajSetMode(EMC_TRAJ_MODE_TELEOP);
281+
emcTrajSetMode(EMC_TRAJ_MODE::TELEOP);
282282
} else {
283-
emcTrajSetMode(EMC_TRAJ_MODE_FREE);
283+
emcTrajSetMode(EMC_TRAJ_MODE::FREE);
284284
}
285-
mdiOrAuto = EMC_TASK_MODE_AUTO; // we'll default back to here
285+
mdiOrAuto = EMC_TASK_MODE::AUTO; // we'll default back to here
286286
break;
287287

288-
case EMC_TASK_MODE_MDI:
288+
case EMC_TASK_MODE::MDI:
289289
// go to mdi mode
290-
emcTrajSetMode(EMC_TRAJ_MODE_COORD);
290+
emcTrajSetMode(EMC_TRAJ_MODE::COORD);
291291
emcTaskAbort();
292292
emcTaskPlanSynch();
293-
mdiOrAuto = EMC_TASK_MODE_MDI;
293+
mdiOrAuto = EMC_TASK_MODE::MDI;
294294
break;
295295

296-
case EMC_TASK_MODE_AUTO:
296+
case EMC_TASK_MODE::AUTO:
297297
// go to auto mode
298-
emcTrajSetMode(EMC_TRAJ_MODE_COORD);
298+
emcTrajSetMode(EMC_TRAJ_MODE::COORD);
299299
emcTaskAbort();
300300
emcTaskPlanSynch();
301-
mdiOrAuto = EMC_TASK_MODE_AUTO;
301+
mdiOrAuto = EMC_TASK_MODE::AUTO;
302302
break;
303303

304304
default:
@@ -309,13 +309,13 @@ int emcTaskSetMode(int mode)
309309
return retval;
310310
}
311311

312-
int emcTaskSetState(int state)
312+
int emcTaskSetState(EMC_TASK_STATE state)
313313
{
314314
int t;
315315
int retval = 0;
316316

317317
switch (state) {
318-
case EMC_TASK_STATE_OFF:
318+
case EMC_TASK_STATE::OFF:
319319
emcMotionAbort();
320320
// turn the machine servos off-- go into READY state
321321
for (t = 0; t < emcStatus->motion.traj.spindles; t++) emcSpindleAbort(t);
@@ -331,7 +331,7 @@ int emcTaskSetState(int state)
331331
emcTaskPlanSynch();
332332
break;
333333

334-
case EMC_TASK_STATE_ON:
334+
case EMC_TASK_STATE::ON:
335335
// turn the machine servos on
336336
emcTrajEnable();
337337
for (t = 0; t < emcStatus->motion.traj.joints; t++){
@@ -340,7 +340,7 @@ int emcTaskSetState(int state)
340340
emcLubeOn();
341341
break;
342342

343-
case EMC_TASK_STATE_ESTOP_RESET:
343+
case EMC_TASK_STATE::ESTOP_RESET:
344344
// reset the estop
345345
emcAuxEstopOff();
346346
emcLubeOff();
@@ -351,7 +351,7 @@ int emcTaskSetState(int state)
351351
emcTaskPlanSynch();
352352
break;
353353

354-
case EMC_TASK_STATE_ESTOP:
354+
case EMC_TASK_STATE::ESTOP:
355355
emcMotionAbort();
356356
for (t = 0; t < emcStatus->motion.traj.spindles; t++) emcSpindleAbort(t);
357357
// go into estop-- do both IO estop and machine servos off
@@ -393,15 +393,15 @@ int emcTaskSetState(int state)
393393
COORD MDI MDI
394394
COORD AUTO AUTO
395395
*/
396-
static int determineMode()
396+
EMC_TASK_MODE determineMode()
397397
{
398-
if (emcStatus->motion.traj.mode == EMC_TRAJ_MODE_FREE) {
399-
return EMC_TASK_MODE_MANUAL;
398+
if (emcStatus->motion.traj.mode == EMC_TRAJ_MODE::FREE) {
399+
return EMC_TASK_MODE::MANUAL;
400400
}
401-
if (emcStatus->motion.traj.mode == EMC_TRAJ_MODE_TELEOP) {
402-
return EMC_TASK_MODE_MANUAL;
401+
if (emcStatus->motion.traj.mode == EMC_TRAJ_MODE::TELEOP) {
402+
return EMC_TASK_MODE::MANUAL;
403403
}
404-
// for EMC_TRAJ_MODE_COORD
404+
// for EMC_TRAJ_MODE::COORD
405405
return mdiOrAuto;
406406
}
407407

@@ -419,17 +419,17 @@ static int determineMode()
419419
DISABLED OUT OF ESTOP ESTOP_RESET
420420
ENABLED OUT OF ESTOP ON
421421
*/
422-
static int determineState()
422+
static EMC_TASK_STATE determineState()
423423
{
424424
if (emcStatus->io.aux.estop) {
425-
return EMC_TASK_STATE_ESTOP;
425+
return EMC_TASK_STATE::ESTOP;
426426
}
427427

428428
if (!emcStatus->motion.traj.enabled) {
429-
return EMC_TASK_STATE_ESTOP_RESET;
429+
return EMC_TASK_STATE::ESTOP_RESET;
430430
}
431431

432-
return EMC_TASK_STATE_ON;
432+
return EMC_TASK_STATE::ON;
433433
}
434434

435435
static int waitFlag = 0;
@@ -692,11 +692,11 @@ int emcTaskPlanCommand(char *cmd)
692692

693693
int emcTaskUpdate(EMC_TASK_STAT * stat)
694694
{
695-
stat->mode = (enum EMC_TASK_MODE_ENUM) determineMode();
696-
int oldstate = stat->state;
697-
stat->state = (enum EMC_TASK_STATE_ENUM) determineState();
695+
stat->mode = determineMode();
696+
EMC_TASK_STATE oldstate = stat->state;
697+
stat->state = determineState();
698698

699-
if(oldstate == EMC_TASK_STATE_ON && oldstate != stat->state) {
699+
if(oldstate == EMC_TASK_STATE::ON && oldstate != stat->state) {
700700
emcTaskAbort();
701701
for (int s = 0; s < emcStatus->motion.traj.spindles; s++) emcSpindleAbort(s);
702702
emcIoAbort(EMC_ABORT_TASK_STATE_NOT_ON);
@@ -718,15 +718,15 @@ int emcTaskUpdate(EMC_TASK_STAT * stat)
718718
// update active G and M codes
719719
// Start by assuming that we can't unpack a state tag from motion
720720
int res_state = INTERP_ERROR;
721-
if (emcStatus->task.interpState != EMC_TASK_INTERP_IDLE) {
721+
if (emcStatus->task.interpState != EMC_TASK_INTERP::IDLE) {
722722
res_state = interp.active_modes(&stat->activeGCodes[0],
723723
&stat->activeMCodes[0],
724724
&stat->activeSettings[0],
725725
emcStatus->motion.traj.tag);
726726
}
727727
// If we get an error from trying to unpack from the motion state, always
728728
// use interp's internal state, so the active state is never out of date
729-
if (emcStatus->task.mode != EMC_TASK_MODE_AUTO ||
729+
if (emcStatus->task.mode != EMC_TASK_MODE::AUTO ||
730730
res_state == INTERP_ERROR) {
731731
interp.active_g_codes(&stat->activeGCodes[0]);
732732
interp.active_m_codes(&stat->activeMCodes[0]);

0 commit comments

Comments
 (0)