Propagate LinuxCNC canon event line numbers
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
namespace {
|
||||
|
||||
CanonEventSink *active_sink = nullptr;
|
||||
int active_line = 0;
|
||||
std::string parameter_file_name = "rs274ngc.var";
|
||||
|
||||
CncSimPose make_pose(double x, double y, double z,
|
||||
@@ -81,17 +82,26 @@ void trace_call(const char *name) {
|
||||
}
|
||||
}
|
||||
|
||||
int event_line(int lineno = 0) {
|
||||
return lineno > 0 ? lineno : active_line;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void cnc_sim_linuxcnc_set_canon_sink(CanonEventSink *sink) {
|
||||
trace_call("cnc_sim_linuxcnc_set_canon_sink");
|
||||
active_sink = sink;
|
||||
active_line = 0;
|
||||
}
|
||||
|
||||
CanonEventSink *cnc_sim_linuxcnc_get_canon_sink() {
|
||||
return active_sink;
|
||||
}
|
||||
|
||||
void cnc_sim_linuxcnc_set_current_line(int line) {
|
||||
active_line = line > 0 ? line : 0;
|
||||
}
|
||||
|
||||
void INIT_CANON() {
|
||||
trace_call("INIT_CANON");
|
||||
if (active_sink) {
|
||||
@@ -102,28 +112,28 @@ void INIT_CANON() {
|
||||
void USE_LENGTH_UNITS(CANON_UNITS units) {
|
||||
trace_call("USE_LENGTH_UNITS");
|
||||
if (active_sink) {
|
||||
active_sink->use_length_units(units_to_scale(units), 0);
|
||||
active_sink->use_length_units(units_to_scale(units), event_line());
|
||||
}
|
||||
}
|
||||
|
||||
void SELECT_PLANE(CANON_PLANE plane) {
|
||||
trace_call("SELECT_PLANE");
|
||||
if (active_sink) {
|
||||
active_sink->select_plane(plane_to_g_code(plane), 0);
|
||||
active_sink->select_plane(plane_to_g_code(plane), event_line());
|
||||
}
|
||||
}
|
||||
|
||||
void SET_FEED_RATE(double rate) {
|
||||
trace_call("SET_FEED_RATE");
|
||||
if (active_sink) {
|
||||
active_sink->set_feed_rate(rate, 0);
|
||||
active_sink->set_feed_rate(rate, event_line());
|
||||
}
|
||||
}
|
||||
|
||||
void SET_SPINDLE_SPEED(int, double speed) {
|
||||
trace_call("SET_SPINDLE_SPEED");
|
||||
if (active_sink) {
|
||||
active_sink->set_spindle_speed(speed, 0);
|
||||
active_sink->set_spindle_speed(speed, event_line());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +147,7 @@ void SELECT_TOOL(int tool) {
|
||||
void CHANGE_TOOL() {
|
||||
trace_call("CHANGE_TOOL");
|
||||
if (active_sink) {
|
||||
active_sink->change_tool(0);
|
||||
active_sink->change_tool(event_line());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +157,7 @@ void STRAIGHT_TRAVERSE(int lineno,
|
||||
double u, double v, double w) {
|
||||
trace_call("STRAIGHT_TRAVERSE");
|
||||
if (active_sink) {
|
||||
active_sink->straight_traverse(lineno, make_pose(x, y, z, a, b, c, u, v, w));
|
||||
active_sink->straight_traverse(event_line(lineno), make_pose(x, y, z, a, b, c, u, v, w));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +167,7 @@ void STRAIGHT_FEED(int lineno,
|
||||
double u, double v, double w) {
|
||||
trace_call("STRAIGHT_FEED");
|
||||
if (active_sink) {
|
||||
active_sink->straight_feed(lineno, make_pose(x, y, z, a, b, c, u, v, w));
|
||||
active_sink->straight_feed(event_line(lineno), make_pose(x, y, z, a, b, c, u, v, w));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,20 +215,20 @@ void ARC_FEED(int lineno,
|
||||
end.u = u;
|
||||
end.v = v;
|
||||
end.w = w;
|
||||
active_sink->arc_feed(lineno, end, center, rotation);
|
||||
active_sink->arc_feed(event_line(lineno), end, center, rotation);
|
||||
}
|
||||
|
||||
void DWELL(double seconds) {
|
||||
trace_call("DWELL");
|
||||
if (active_sink) {
|
||||
active_sink->dwell(seconds, 0);
|
||||
active_sink->dwell(seconds, event_line());
|
||||
}
|
||||
}
|
||||
|
||||
void PROGRAM_END() {
|
||||
trace_call("PROGRAM_END");
|
||||
if (active_sink) {
|
||||
active_sink->program_end(0);
|
||||
active_sink->program_end(event_line());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,7 +242,7 @@ void SET_G5X_OFFSET(int index,
|
||||
double u, double v, double w) {
|
||||
trace_call("SET_G5X_OFFSET");
|
||||
if (active_sink) {
|
||||
active_sink->set_g5x_offset(index, make_pose(x, y, z, a, b, c, u, v, w), 0);
|
||||
active_sink->set_g5x_offset(index, make_pose(x, y, z, a, b, c, u, v, w), event_line());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,14 +251,14 @@ void SET_G92_OFFSET(double x, double y, double z,
|
||||
double u, double v, double w) {
|
||||
trace_call("SET_G92_OFFSET");
|
||||
if (active_sink) {
|
||||
active_sink->set_g92_offset(make_pose(x, y, z, a, b, c, u, v, w), 0);
|
||||
active_sink->set_g92_offset(make_pose(x, y, z, a, b, c, u, v, w), event_line());
|
||||
}
|
||||
}
|
||||
|
||||
void SET_XY_ROTATION(double angle) {
|
||||
trace_call("SET_XY_ROTATION");
|
||||
if (active_sink) {
|
||||
active_sink->set_xy_rotation(angle, 0);
|
||||
active_sink->set_xy_rotation(angle, event_line());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,7 +267,7 @@ void CANON_UPDATE_END_POINT(double x, double y, double z,
|
||||
double u, double v, double w) {
|
||||
trace_call("CANON_UPDATE_END_POINT");
|
||||
if (active_sink) {
|
||||
active_sink->straight_traverse(0, make_pose(x, y, z, a, b, c, u, v, w));
|
||||
active_sink->straight_traverse(event_line(), make_pose(x, y, z, a, b, c, u, v, w));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,4 +4,4 @@ class CanonEventSink;
|
||||
|
||||
void cnc_sim_linuxcnc_set_canon_sink(CanonEventSink *sink);
|
||||
CanonEventSink *cnc_sim_linuxcnc_get_canon_sink();
|
||||
|
||||
void cnc_sim_linuxcnc_set_current_line(int line);
|
||||
|
||||
@@ -126,6 +126,7 @@ int parse_linuxcnc_rs274_backend(CanonEventSink &sink,
|
||||
int line_number = 0;
|
||||
while (!program_done && std::getline(input, line)) {
|
||||
++line_number;
|
||||
cnc_sim_linuxcnc_set_current_line(line_number);
|
||||
std::vector<SimulatorGcodeControlAction> control_actions;
|
||||
if (parse_simulator_gcode_control_line(line, &control_actions)) {
|
||||
for (const auto &action : control_actions) {
|
||||
@@ -172,6 +173,7 @@ int parse_linuxcnc_rs274_backend(CanonEventSink &sink,
|
||||
}
|
||||
}
|
||||
|
||||
cnc_sim_linuxcnc_set_current_line(0);
|
||||
interp->exit();
|
||||
delete interp;
|
||||
cnc_sim_linuxcnc_set_canon_sink(nullptr);
|
||||
|
||||
Reference in New Issue
Block a user