use of com.willwinder.universalgcodesender.gcode.GcodeParser.GcodeMeta in project Universal-G-Code-Sender by winder.
the class ArcExpander method processCommand.
@Override
public List<String> processCommand(String command, GcodeState state) throws GcodeParserException {
if (state.currentPoint == null)
throw new GcodeParserException(Localization.getString("parser.processor.arc.start-error"));
List<String> results = new ArrayList<>();
List<GcodeMeta> commands = GcodeParser.processCommand(command, 0, state);
// If this is not an arc, there is nothing to do.
Code c = hasArcCommand(commands);
if (c == null) {
return Collections.singletonList(command);
}
SplitCommand sc = GcodePreprocessorUtils.extractMotion(c, command);
if (sc.remainder.length() > 0) {
results.add(sc.remainder);
}
GcodeMeta arcMeta = Iterables.getLast(commands);
PointSegment ps = arcMeta.point;
Position start = state.currentPoint;
Position end = arcMeta.point.point();
List<Position> points = GcodePreprocessorUtils.generatePointsAlongArcBDring(start, end, ps.center(), ps.isClockwise(), ps.getRadius(), 0, this.length, new PlaneFormatter(ps.getPlaneState()));
// That function returns the first and last points. Exclude the first
// point because the previous gcode command ends there already.
points.remove(0);
if (convertToLines) {
// Tack the speed onto the first line segment in case the arc also
// changed the feed value.
String feed = "F" + arcMeta.point.getSpeed();
for (Position point : points) {
results.add(GcodePreprocessorUtils.generateLineFromPoints(G1, start, point, state.inAbsoluteMode, df) + feed);
start = point;
feed = "";
}
} else {
// TODO: Generate arc segments.
throw new UnsupportedOperationException("I have not implemented this.");
}
return results;
}
Aggregations