Track spindle direction in set-spindle events
This commit is contained in:
@@ -73,6 +73,9 @@ int main() {
|
||||
bool saw_l20_end_line = false;
|
||||
bool saw_probe = false;
|
||||
bool saw_probe_as_feed = false;
|
||||
bool saw_spindle_cw = false;
|
||||
bool saw_spindle_ccw = false;
|
||||
bool saw_spindle_stop = false;
|
||||
for (const auto &event : events) {
|
||||
saw_tool = saw_tool || event.type == CNC_SIM_EVENT_TOOL_CHANGE;
|
||||
saw_rapid = saw_rapid || event.type == CNC_SIM_EVENT_RAPID;
|
||||
@@ -121,6 +124,36 @@ int main() {
|
||||
ok &= expect(saw_g49, "expected LinuxCNC G49 RTCP off state");
|
||||
ok &= expect(saw_g434, "expected LinuxCNC G43.4 RTCP on state with H code");
|
||||
|
||||
const char spindle_program[] =
|
||||
"G21 G90 G17\n"
|
||||
"S1200 M3\n"
|
||||
"M4\n"
|
||||
"M5\n"
|
||||
"M30\n";
|
||||
events.clear();
|
||||
ok &= expect(cnc_sim_parse_program(sim, spindle_program, sizeof(spindle_program) - 1) == 0,
|
||||
cnc_sim_last_error(sim));
|
||||
for (const auto &event : events) {
|
||||
saw_spindle_cw = saw_spindle_cw ||
|
||||
(event.type == CNC_SIM_EVENT_SET_SPINDLE &&
|
||||
event.line == 2 &&
|
||||
event.spindle == 1200.0 &&
|
||||
event.reserved == 1);
|
||||
saw_spindle_ccw = saw_spindle_ccw ||
|
||||
(event.type == CNC_SIM_EVENT_SET_SPINDLE &&
|
||||
event.line == 3 &&
|
||||
event.spindle == 1200.0 &&
|
||||
event.reserved == 2);
|
||||
saw_spindle_stop = saw_spindle_stop ||
|
||||
(event.type == CNC_SIM_EVENT_SET_SPINDLE &&
|
||||
event.line == 4 &&
|
||||
event.spindle == 0.0 &&
|
||||
event.reserved == 0);
|
||||
}
|
||||
ok &= expect(saw_spindle_cw, "expected LinuxCNC M3 clockwise spindle state");
|
||||
ok &= expect(saw_spindle_ccw, "expected LinuxCNC M4 counterclockwise spindle state");
|
||||
ok &= expect(saw_spindle_stop, "expected LinuxCNC M5 stopped spindle state");
|
||||
|
||||
const char probe_program[] =
|
||||
"G21 G90 G17\n"
|
||||
"G0 X0 Y0 Z5\n"
|
||||
|
||||
@@ -67,6 +67,9 @@ int main() {
|
||||
bool saw_m430 = false;
|
||||
bool saw_g49 = false;
|
||||
bool saw_g434 = false;
|
||||
bool saw_spindle_cw = false;
|
||||
bool saw_spindle_ccw = false;
|
||||
bool saw_spindle_stop = false;
|
||||
bool saw_incremental_move = false;
|
||||
bool saw_r_arc_center = false;
|
||||
for (const auto &event : events) {
|
||||
@@ -106,6 +109,11 @@ int main() {
|
||||
event.feed == 1.0 &&
|
||||
event.tool == 7 &&
|
||||
event.dwell_seconds == 125.0);
|
||||
saw_spindle_cw = saw_spindle_cw ||
|
||||
(event.type == CNC_SIM_EVENT_SET_SPINDLE &&
|
||||
event.line == 6 &&
|
||||
event.spindle == 8000.0 &&
|
||||
event.reserved == 1);
|
||||
saw_incremental_move = saw_incremental_move ||
|
||||
(event.type == CNC_SIM_EVENT_LINEAR_FEED &&
|
||||
event.start.x == 20.0 && event.end.x == 25.0);
|
||||
@@ -127,9 +135,33 @@ int main() {
|
||||
ok &= expect(saw_m430, "expected M430 five-axis BC kinematics switch");
|
||||
ok &= expect(saw_g49, "expected G49 RTCP off state");
|
||||
ok &= expect(saw_g434, "expected G43.4 RTCP on state with H code");
|
||||
ok &= expect(saw_spindle_cw, "expected M3 clockwise spindle state");
|
||||
ok &= expect(saw_incremental_move, "expected G91 incremental move");
|
||||
ok &= expect(saw_r_arc_center, "expected R arc center calculation");
|
||||
|
||||
const char spindle_program[] =
|
||||
"G21\n"
|
||||
"S1200 M3\n"
|
||||
"M4\n"
|
||||
"M5\n";
|
||||
events.clear();
|
||||
ok &= expect(cnc_sim_parse_program(sim, spindle_program, sizeof(spindle_program) - 1) == 0,
|
||||
cnc_sim_last_error(sim));
|
||||
for (const auto &event : events) {
|
||||
saw_spindle_ccw = saw_spindle_ccw ||
|
||||
(event.type == CNC_SIM_EVENT_SET_SPINDLE &&
|
||||
event.line == 3 &&
|
||||
event.spindle == 1200.0 &&
|
||||
event.reserved == 2);
|
||||
saw_spindle_stop = saw_spindle_stop ||
|
||||
(event.type == CNC_SIM_EVENT_SET_SPINDLE &&
|
||||
event.line == 4 &&
|
||||
event.spindle == 0.0 &&
|
||||
event.reserved == 0);
|
||||
}
|
||||
ok &= expect(saw_spindle_ccw, "expected M4 counterclockwise spindle state");
|
||||
ok &= expect(saw_spindle_stop, "expected M5 stopped spindle state");
|
||||
|
||||
const char linuxcnc_config[] = "{\"backend\":\"linuxcnc-rs274\"}";
|
||||
config_rc = cnc_sim_load_config_json(sim, linuxcnc_config, sizeof(linuxcnc_config) - 1);
|
||||
rc = cnc_sim_parse_program(sim, program, sizeof(program) - 1);
|
||||
|
||||
@@ -34,6 +34,10 @@ int main() {
|
||||
USE_LENGTH_UNITS(CANON_UNITS_MM);
|
||||
SELECT_PLANE(CANON_PLANE::XY);
|
||||
SET_FEED_RATE(500.0);
|
||||
SET_SPINDLE_SPEED(0, 1200.0);
|
||||
START_SPINDLE_CLOCKWISE(0, 0);
|
||||
START_SPINDLE_COUNTERCLOCKWISE(0, 0);
|
||||
STOP_SPINDLE_TURNING(0);
|
||||
SELECT_TOOL(7);
|
||||
CHANGE_TOOL();
|
||||
STRAIGHT_TRAVERSE(10, 0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
|
||||
@@ -53,6 +57,9 @@ int main() {
|
||||
bool saw_tool = false;
|
||||
bool saw_rapid = false;
|
||||
bool saw_feed = false;
|
||||
bool saw_spindle_cw = false;
|
||||
bool saw_spindle_ccw = false;
|
||||
bool saw_spindle_stop = false;
|
||||
bool saw_arc = false;
|
||||
bool saw_probe = false;
|
||||
bool saw_g5x = false;
|
||||
@@ -61,6 +68,15 @@ int main() {
|
||||
bool saw_end = false;
|
||||
for (const auto &event : events) {
|
||||
saw_tool = saw_tool || (event.type == CNC_SIM_EVENT_TOOL_CHANGE && event.tool == 7);
|
||||
saw_spindle_cw = saw_spindle_cw || (event.type == CNC_SIM_EVENT_SET_SPINDLE &&
|
||||
event.spindle == 1200.0 &&
|
||||
event.reserved == 1);
|
||||
saw_spindle_ccw = saw_spindle_ccw || (event.type == CNC_SIM_EVENT_SET_SPINDLE &&
|
||||
event.spindle == 1200.0 &&
|
||||
event.reserved == 2);
|
||||
saw_spindle_stop = saw_spindle_stop || (event.type == CNC_SIM_EVENT_SET_SPINDLE &&
|
||||
event.spindle == 0.0 &&
|
||||
event.reserved == 0);
|
||||
saw_rapid = saw_rapid || (event.type == CNC_SIM_EVENT_RAPID && event.end.z == 5.0);
|
||||
saw_feed = saw_feed || (event.type == CNC_SIM_EVENT_LINEAR_FEED && event.end.x == 10.0);
|
||||
saw_arc = saw_arc || (event.type == CNC_SIM_EVENT_ARC_FEED &&
|
||||
@@ -90,6 +106,9 @@ int main() {
|
||||
}
|
||||
|
||||
ok &= expect(saw_tool, "expected tool change");
|
||||
ok &= expect(saw_spindle_cw, "expected clockwise spindle state");
|
||||
ok &= expect(saw_spindle_ccw, "expected counterclockwise spindle state");
|
||||
ok &= expect(saw_spindle_stop, "expected stopped spindle state");
|
||||
ok &= expect(saw_rapid, "expected rapid move");
|
||||
ok &= expect(saw_feed, "expected linear feed");
|
||||
ok &= expect(saw_arc, "expected arc feed");
|
||||
|
||||
Reference in New Issue
Block a user