Skip to content

Commit 64d27a3

Browse files
committed
rs274: changed enums to class enums
1 parent a0d619c commit 64d27a3

16 files changed

Lines changed: 236 additions & 234 deletions

src/emc/rs274ngc/interp_arc.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ tool radius from the arc.
7777

7878
int Interp::arc_data_comp_ijk(int move, //!<either G_2 (cw arc) or G_3 (ccw arc)
7979
int plane, //!<active plane
80-
int side, //!<either RIGHT or LEFT
80+
CUTTER_COMP side, //!<either RIGHT or LEFT
8181
double tool_radius, //!<radius of the tool
8282
double current_x, //!<first coordinate of current point
8383
double current_y, //!<second coordinate of current point
@@ -127,8 +127,8 @@ int Interp::arc_data_comp_ijk(int move, //!<either G_2 (cw arc) or G_3 (ccw arc
127127
a, end_x, b, end_y, arc_radius, radius2,
128128
abs_err, rel_err*100);
129129

130-
CHKS(((arc_radius <= tool_radius) && (((side == LEFT) && (move == G_3)) ||
131-
((side == RIGHT) && (move == G_2)))),
130+
CHKS(((arc_radius <= tool_radius) && (((side == CUTTER_COMP::LEFT) && (move == G_3)) ||
131+
((side == CUTTER_COMP::RIGHT) && (move == G_2)))),
132132
NCE_TOOL_RADIUS_NOT_LESS_THAN_ARC_RADIUS_WITH_COMP);
133133

134134
/* This catches an arc too small for the tool, also */
@@ -200,7 +200,7 @@ the pin is inside or outside the hoop.
200200

201201
int Interp::arc_data_comp_r(int move, //!< either G_2 (cw arc) or G_3 (ccw arc)
202202
int plane,
203-
int side, //!< either RIGHT or LEFT
203+
CUTTER_COMP side, //!< either RIGHT or LEFT
204204
double tool_radius, //!< radius of the tool
205205
double current_x, //!< first coordinate of current point
206206
double current_y, //!< second coordinate of current point
@@ -216,8 +216,8 @@ int Interp::arc_data_comp_r(int move, //!< either G_2 (cw arc) or G_3 (ccw ar
216216
double abs_radius; // absolute value of big_radius
217217

218218
abs_radius = fabs(big_radius);
219-
CHKS(((abs_radius <= tool_radius) && (((side == LEFT) && (move == G_3)) ||
220-
((side == RIGHT) && (move == G_2)))),
219+
CHKS(((abs_radius <= tool_radius) && (((side == CUTTER_COMP::LEFT) && (move == G_3)) ||
220+
((side == CUTTER_COMP::RIGHT) && (move == G_2)))),
221221
NCE_TOOL_RADIUS_NOT_LESS_THAN_ARC_RADIUS_WITH_COMP);
222222

223223
return arc_data_r(move, plane, current_x, current_y, end_x, end_y, big_radius, p_number,

src/emc/rs274ngc/interp_check.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ int Interp::check_g_codes(block_pointer block, //!< pointer to a block to be c
106106
NCE_MUST_USE_G0_OR_G1_WITH_G53);
107107
CHKS(((block->g_modes[GM_DISTANCE_MODE] == G_91) ||
108108
((block->g_modes[GM_DISTANCE_MODE] != G_90) &&
109-
(settings->distance_mode == MODE_INCREMENTAL))),
109+
(settings->distance_mode == DISTANCE_MODE::INCREMENTAL))),
110110
NCE_CANNOT_USE_G53_INCREMENTAL);
111111
} else if (mode0 == G_92) {
112112
} else

src/emc/rs274ngc/interp_convert.cc

Lines changed: 104 additions & 104 deletions
Large diffs are not rendered by default.

src/emc/rs274ngc/interp_cycles.cc

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -722,8 +722,8 @@ int Interp::convert_cycle(int motion, //!< a G-code between G_81 and G_89, a
722722
CANON_PLANE plane;
723723

724724
CHKS((settings->feed_rate == 0.0), _("Cannot feed with zero feed rate"));
725-
CHKS((settings->feed_mode == INVERSE_TIME), _("Cannot use inverse time feed with canned cycles"));
726-
CHKS((settings->cutter_comp_side), _("Cannot use canned cycles with cutter compensation on"));
725+
CHKS((settings->feed_mode == FEED_MODE::INVERSE_TIME), _("Cannot use inverse time feed with canned cycles"));
726+
CHKS((settings->cutter_comp_side != CUTTER_COMP::OFF), _("Cannot use canned cycles with cutter compensation on"));
727727

728728
plane = settings->plane;
729729
if (!block->r_flag) {
@@ -930,7 +930,7 @@ int Interp::convert_cycle_xy(int motion, //!< a G-code between G_81 and G_89, a
930930
settings->cycle_il_flag = true;
931931
}
932932

933-
if (settings->distance_mode == MODE_ABSOLUTE) {
933+
if (settings->distance_mode == DISTANCE_MODE::ABSOLUTE) {
934934
double radius, theta;
935935
aa_increment = 0.0;
936936
bb_increment = 0.0;
@@ -951,7 +951,7 @@ int Interp::convert_cycle_xy(int motion, //!< a G-code between G_81 and G_89, a
951951
aa = block->x_flag ? block->x_number : settings->current_x;
952952
bb = block->y_flag ? block->y_number : settings->current_y;
953953
}
954-
} else if (settings->distance_mode == MODE_INCREMENTAL) {
954+
} else if (settings->distance_mode == DISTANCE_MODE::INCREMENTAL) {
955955
if (block->x_flag) aa_increment = block->x_number;
956956
if (block->y_flag) bb_increment = block->y_number;
957957
if (block->radius_flag) radius_increment = block->radius;
@@ -973,7 +973,7 @@ int Interp::convert_cycle_xy(int motion, //!< a G-code between G_81 and G_89, a
973973
old_cc = r;
974974
current_cc = old_cc;
975975
}
976-
clear_cc = (settings->retract_mode == R_PLANE) ? r : old_cc;
976+
clear_cc = (settings->retract_mode == RETRACT_MODE::R_PLANE) ? r : old_cc;
977977

978978
save_mode = GET_EXTERNAL_MOTION_CONTROL_MODE();
979979
save_tolerance = GET_EXTERNAL_MOTION_CONTROL_TOLERANCE();
@@ -1054,7 +1054,7 @@ int Interp::convert_cycle_xy(int motion, //!< a G-code between G_81 and G_89, a
10541054
settings->cycle_i = i;
10551055
settings->cycle_j = j;
10561056
settings->cycle_k = k;
1057-
if (settings->distance_mode == MODE_INCREMENTAL) {
1057+
if (settings->distance_mode == DISTANCE_MODE::INCREMENTAL) {
10581058
k = (cc + k); /* k always absolute in function call below */
10591059
}
10601060
CYCLE_MACRO(convert_cycle_g87(block, CANON_PLANE_XY, aa, (aa + i), bb,
@@ -1139,14 +1139,14 @@ int Interp::convert_cycle_uv(int motion, //!< a G-code between G_81 and G_89, a
11391139
settings->cycle_il_flag = true;
11401140
}
11411141

1142-
if (settings->distance_mode == MODE_ABSOLUTE) {
1142+
if (settings->distance_mode == DISTANCE_MODE::ABSOLUTE) {
11431143
aa_increment = 0.0;
11441144
bb_increment = 0.0;
11451145
r = block->r_number;
11461146
cc = block->w_number;
11471147
aa = block->u_flag ? block->u_number : settings->u_current;
11481148
bb = block->v_flag ? block->v_number : settings->v_current;
1149-
} else if (settings->distance_mode == MODE_INCREMENTAL) {
1149+
} else if (settings->distance_mode == DISTANCE_MODE::INCREMENTAL) {
11501150
if (block->u_flag) aa_increment = block->u_number;
11511151
if (block->v_flag) bb_increment = block->v_number;
11521152
r = (block->r_number + old_cc);
@@ -1164,7 +1164,7 @@ int Interp::convert_cycle_uv(int motion, //!< a G-code between G_81 and G_89, a
11641164
old_cc = r;
11651165
current_cc = old_cc;
11661166
}
1167-
clear_cc = (settings->retract_mode == R_PLANE) ? r : old_cc;
1167+
clear_cc = (settings->retract_mode == RETRACT_MODE::R_PLANE) ? r : old_cc;
11681168

11691169
save_mode = GET_EXTERNAL_MOTION_CONTROL_MODE();
11701170
save_tolerance = GET_EXTERNAL_MOTION_CONTROL_TOLERANCE();
@@ -1244,7 +1244,7 @@ int Interp::convert_cycle_uv(int motion, //!< a G-code between G_81 and G_89, a
12441244
settings->cycle_i = i;
12451245
settings->cycle_j = j;
12461246
settings->cycle_k = k;
1247-
if (settings->distance_mode == MODE_INCREMENTAL) {
1247+
if (settings->distance_mode == DISTANCE_MODE::INCREMENTAL) {
12481248
k = (cc + k); /* k always absolute in function call below */
12491249
}
12501250
CYCLE_MACRO(convert_cycle_g87(block, CANON_PLANE_UV, aa, (aa + i), bb,
@@ -1376,14 +1376,14 @@ int Interp::convert_cycle_yz(int motion, //!< a G-code between G_81 and G_89, a
13761376
settings->cycle_il_flag = true;
13771377
}
13781378

1379-
if (settings->distance_mode == MODE_ABSOLUTE) {
1379+
if (settings->distance_mode == DISTANCE_MODE::ABSOLUTE) {
13801380
aa_increment = 0.0;
13811381
bb_increment = 0.0;
13821382
r = block->r_number;
13831383
cc = block->x_number;
13841384
aa = block->y_flag ? block->y_number : settings->current_y;
13851385
bb = block->z_flag ? block->z_number : settings->current_z;
1386-
} else if (settings->distance_mode == MODE_INCREMENTAL) {
1386+
} else if (settings->distance_mode == DISTANCE_MODE::INCREMENTAL) {
13871387
if (block->y_flag) aa_increment = block->y_number;
13881388
if (block->z_flag) bb_increment = block->z_number;
13891389
r = (block->r_number + old_cc);
@@ -1401,7 +1401,7 @@ int Interp::convert_cycle_yz(int motion, //!< a G-code between G_81 and G_89, a
14011401
old_cc = r;
14021402
current_cc = old_cc;
14031403
}
1404-
clear_cc = (settings->retract_mode == R_PLANE) ? r : old_cc;
1404+
clear_cc = (settings->retract_mode == RETRACT_MODE::R_PLANE) ? r : old_cc;
14051405

14061406
save_mode = GET_EXTERNAL_MOTION_CONTROL_MODE();
14071407
save_tolerance = GET_EXTERNAL_MOTION_CONTROL_TOLERANCE();
@@ -1481,7 +1481,7 @@ int Interp::convert_cycle_yz(int motion, //!< a G-code between G_81 and G_89, a
14811481
settings->cycle_i = i;
14821482
settings->cycle_j = j;
14831483
settings->cycle_k = k;
1484-
if (settings->distance_mode == MODE_INCREMENTAL) {
1484+
if (settings->distance_mode == DISTANCE_MODE::INCREMENTAL) {
14851485
i = (cc + i); /* i always absolute in function call below */
14861486
}
14871487
CYCLE_MACRO(convert_cycle_g87(block, CANON_PLANE_YZ, aa, (aa + j), bb,
@@ -1564,14 +1564,14 @@ int Interp::convert_cycle_vw(int motion, //!< a G-code between G_81 and G_89, a
15641564
settings->cycle_il_flag = true;
15651565
}
15661566

1567-
if (settings->distance_mode == MODE_ABSOLUTE) {
1567+
if (settings->distance_mode == DISTANCE_MODE::ABSOLUTE) {
15681568
aa_increment = 0.0;
15691569
bb_increment = 0.0;
15701570
r = block->r_number;
15711571
cc = block->u_number;
15721572
aa = block->v_flag ? block->v_number : settings->v_current;
15731573
bb = block->w_flag ? block->w_number : settings->w_current;
1574-
} else if (settings->distance_mode == MODE_INCREMENTAL) {
1574+
} else if (settings->distance_mode == DISTANCE_MODE::INCREMENTAL) {
15751575
if (block->v_flag) aa_increment = block->v_number;
15761576
if (block->w_flag) bb_increment = block->w_number;
15771577
r = (block->r_number + old_cc);
@@ -1589,7 +1589,7 @@ int Interp::convert_cycle_vw(int motion, //!< a G-code between G_81 and G_89, a
15891589
old_cc = r;
15901590
current_cc = old_cc;
15911591
}
1592-
clear_cc = (settings->retract_mode == R_PLANE) ? r : old_cc;
1592+
clear_cc = (settings->retract_mode == RETRACT_MODE::R_PLANE) ? r : old_cc;
15931593

15941594
save_mode = GET_EXTERNAL_MOTION_CONTROL_MODE();
15951595
save_tolerance = GET_EXTERNAL_MOTION_CONTROL_TOLERANCE();
@@ -1669,7 +1669,7 @@ int Interp::convert_cycle_vw(int motion, //!< a G-code between G_81 and G_89, a
16691669
settings->cycle_i = i;
16701670
settings->cycle_j = j;
16711671
settings->cycle_k = k;
1672-
if (settings->distance_mode == MODE_INCREMENTAL) {
1672+
if (settings->distance_mode == DISTANCE_MODE::INCREMENTAL) {
16731673
i = (cc + i); /* i always absolute in function call below */
16741674
}
16751675
CYCLE_MACRO(convert_cycle_g87(block, CANON_PLANE_VW, aa, (aa + j), bb,
@@ -1809,14 +1809,14 @@ int Interp::convert_cycle_zx(int motion, //!< a G-code between G_81 and G_89, a
18091809
settings->cycle_il_flag = true;
18101810
}
18111811

1812-
if (settings->distance_mode == MODE_ABSOLUTE) {
1812+
if (settings->distance_mode == DISTANCE_MODE::ABSOLUTE) {
18131813
aa_increment = 0.0;
18141814
bb_increment = 0.0;
18151815
r = block->r_number;
18161816
cc = block->y_number;
18171817
aa = block->z_flag ? block->z_number : settings->current_z;
18181818
bb = block->x_flag ? block->x_number : settings->current_x;
1819-
} else if (settings->distance_mode == MODE_INCREMENTAL) {
1819+
} else if (settings->distance_mode == DISTANCE_MODE::INCREMENTAL) {
18201820
if (block->z_flag) aa_increment = block->z_number;
18211821
if (block->x_flag) bb_increment = block->x_number;
18221822
r = (block->r_number + old_cc);
@@ -1834,7 +1834,7 @@ int Interp::convert_cycle_zx(int motion, //!< a G-code between G_81 and G_89, a
18341834
old_cc = r;
18351835
current_cc = old_cc;
18361836
}
1837-
clear_cc = (settings->retract_mode == R_PLANE) ? r : old_cc;
1837+
clear_cc = (settings->retract_mode == RETRACT_MODE::R_PLANE) ? r : old_cc;
18381838

18391839
save_mode = GET_EXTERNAL_MOTION_CONTROL_MODE();
18401840
save_tolerance = GET_EXTERNAL_MOTION_CONTROL_TOLERANCE();
@@ -1914,7 +1914,7 @@ int Interp::convert_cycle_zx(int motion, //!< a G-code between G_81 and G_89, a
19141914
settings->cycle_i = i;
19151915
settings->cycle_j = j;
19161916
settings->cycle_k = k;
1917-
if (settings->distance_mode == MODE_INCREMENTAL) {
1917+
if (settings->distance_mode == DISTANCE_MODE::INCREMENTAL) {
19181918
j = (cc + j); /* j always absolute in function call below */
19191919
}
19201920
CYCLE_MACRO(convert_cycle_g87(block, CANON_PLANE_XZ, aa, (aa + k), bb,
@@ -1996,14 +1996,14 @@ int Interp::convert_cycle_wu(int motion, //!< a G-code between G_81 and G_89, a
19961996
settings->cycle_il_flag = true;
19971997
}
19981998

1999-
if (settings->distance_mode == MODE_ABSOLUTE) {
1999+
if (settings->distance_mode == DISTANCE_MODE::ABSOLUTE) {
20002000
aa_increment = 0.0;
20012001
bb_increment = 0.0;
20022002
r = block->r_number;
20032003
cc = block->v_number;
20042004
aa = block->w_flag ? block->w_number : settings->w_current;
20052005
bb = block->u_flag ? block->u_number : settings->u_current;
2006-
} else if (settings->distance_mode == MODE_INCREMENTAL) {
2006+
} else if (settings->distance_mode == DISTANCE_MODE::INCREMENTAL) {
20072007
if (block->w_flag) aa_increment = block->w_number;
20082008
if (block->u_flag) bb_increment = block->u_number;
20092009
r = (block->r_number + old_cc);
@@ -2021,7 +2021,7 @@ int Interp::convert_cycle_wu(int motion, //!< a G-code between G_81 and G_89, a
20212021
old_cc = r;
20222022
current_cc = old_cc;
20232023
}
2024-
clear_cc = (settings->retract_mode == R_PLANE) ? r : old_cc;
2024+
clear_cc = (settings->retract_mode == RETRACT_MODE::R_PLANE) ? r : old_cc;
20252025

20262026
save_mode = GET_EXTERNAL_MOTION_CONTROL_MODE();
20272027
save_tolerance = GET_EXTERNAL_MOTION_CONTROL_TOLERANCE();
@@ -2111,7 +2111,7 @@ int Interp::convert_cycle_wu(int motion, //!< a G-code between G_81 and G_89, a
21112111
settings->cycle_i = i;
21122112
settings->cycle_j = j;
21132113
settings->cycle_k = k;
2114-
if (settings->distance_mode == MODE_INCREMENTAL) {
2114+
if (settings->distance_mode == DISTANCE_MODE::INCREMENTAL) {
21152115
j = (cc + j); /* j always absolute in function call below */
21162116
}
21172117
CYCLE_MACRO(convert_cycle_g87(block, CANON_PLANE_UW, aa, (aa + k), bb,

src/emc/rs274ngc/interp_execute.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ int Interp::execute_block(block_pointer block, //!< pointer to a block of RS27
265265

266266
}
267267
if (block->f_flag){
268-
if ((settings->feed_mode != INVERSE_TIME) && ONCE(STEP_SET_FEED_RATE)) {
268+
if ((settings->feed_mode != FEED_MODE::INVERSE_TIME) && ONCE(STEP_SET_FEED_RATE)) {
269269
if (STEP_REMAPPED_IN_BLOCK(block, STEP_SET_FEED_RATE)) {
270270
return (convert_remapped_code(block, settings, STEP_SET_FEED_RATE, 'F'));
271271
} else {

src/emc/rs274ngc/interp_find.cc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,11 @@ int Interp::find_ends(block_pointer block, //!< pointer to a block of RS27
161161
double *CC_p, //!< pointer to end_c
162162
double *u_p, double *v_p, double *w_p)
163163
{
164-
int middle;
165-
int comp;
164+
bool middle;
165+
CUTTER_COMP comp;
166166

167167
middle = !s->cutter_comp_firstmove;
168-
comp = (s->cutter_comp_side);
168+
comp = s->cutter_comp_side;
169169

170170
if (block->g_modes[GM_MODAL_0] == G_53) { /* distance mode is absolute in this case */
171171
#ifdef DEBUG_EMC
@@ -252,20 +252,20 @@ int Interp::find_ends(block_pointer block, //!< pointer to a block of RS27
252252
} else {
253253
*w_p = s->w_current;
254254
}
255-
} else if (s->distance_mode == MODE_ABSOLUTE) {
255+
} else if (s->distance_mode == DISTANCE_MODE::ABSOLUTE) {
256256

257257
if(block->x_flag) {
258258
*px = block->x_number;
259259
} else {
260260
// both cutter comp planes affect X ...
261-
*px = (comp && middle) ? s->program_x : s->current_x;
261+
*px = (comp != CUTTER_COMP::OFF && middle) ? s->program_x : s->current_x;
262262
}
263263

264264
if(block->y_flag) {
265265
*py = block->y_number;
266266
} else {
267267
// but only XY affects Y ...
268-
*py = (comp && middle && s->plane == CANON_PLANE_XY) ? s->program_y : s->current_y;
268+
*py = (comp != CUTTER_COMP::OFF && middle && s->plane == CANON_PLANE_XY) ? s->program_y : s->current_y;
269269
}
270270

271271
if(block->radius_flag && block->theta_flag) {
@@ -291,7 +291,7 @@ int Interp::find_ends(block_pointer block, //!< pointer to a block of RS27
291291
*pz = block->z_number;
292292
} else {
293293
// and only XZ affects Z.
294-
*pz = (comp && middle && s->plane == CANON_PLANE_XZ) ? s->program_z : s->current_z;
294+
*pz = (comp != CUTTER_COMP::OFF && middle && s->plane == CANON_PLANE_XZ) ? s->program_z : s->current_z;
295295
}
296296

297297
if(block->a_flag) {
@@ -328,14 +328,14 @@ int Interp::find_ends(block_pointer block, //!< pointer to a block of RS27
328328
*v_p = (block->v_flag) ? block->v_number : s->v_current;
329329
*w_p = (block->w_flag) ? block->w_number : s->w_current;
330330

331-
} else { /* mode is MODE_INCREMENTAL */
331+
} else { /* mode is DISTANCE_MODE::INCREMENTAL */
332332

333333
// both cutter comp planes affect X ...
334-
*px = (comp && middle) ? s->program_x: s->current_x;
334+
*px = (comp != CUTTER_COMP::OFF && middle) ? s->program_x: s->current_x;
335335
if(block->x_flag) *px += block->x_number;
336336

337337
// but only XY affects Y ...
338-
*py = (comp && middle && s->plane == CANON_PLANE_XY) ? s->program_y: s->current_y;
338+
*py = (comp != CUTTER_COMP::OFF && middle && s->plane == CANON_PLANE_XY) ? s->program_y: s->current_y;
339339
if(block->y_flag) *py += block->y_number;
340340

341341
if(block->radius_flag) {
@@ -359,7 +359,7 @@ int Interp::find_ends(block_pointer block, //!< pointer to a block of RS27
359359
}
360360

361361
// and only XZ affects Z.
362-
*pz = (comp && middle && s->plane == CANON_PLANE_XZ) ? s->program_z: s->current_z;
362+
*pz = (comp != CUTTER_COMP::OFF && middle && s->plane == CANON_PLANE_XZ) ? s->program_z: s->current_z;
363363
if(block->z_flag) *pz += block->z_number;
364364

365365
*AA_p = s->AA_current;

0 commit comments

Comments
 (0)