use of com.willwinder.universalgcodesender.gcode.processors.LineSplitter in project Universal-G-Code-Sender by winder.
the class GcodeParserTest method autoLevelerProcessorSet.
@Test
public void autoLevelerProcessorSet() throws Exception {
System.out.println("autoLevelerProcessorSet");
GcodeParser gcp = new GcodeParser();
gcp.addCommandProcessor(new CommentProcessor());
gcp.addCommandProcessor(new ArcExpander(true, 0.1));
gcp.addCommandProcessor(new LineSplitter(1));
Position[][] grid = { { new Position(-5, -5, 0, MM), new Position(-5, 35, 0, MM) }, { new Position(35, -5, 0, MM), new Position(35, 35, 0, MM) } };
gcp.addCommandProcessor(new MeshLeveler(0, grid, Units.MM));
Path output = Files.createTempFile("autoleveler_processor_set_test.nc", "");
// Copy resource to temp file since my parser methods need it that way.
URL file = this.getClass().getClassLoader().getResource("./gcode/circle_test.nc");
File tempFile = File.createTempFile("temp", "file");
IOUtils.copy(file.openStream(), FileUtils.openOutputStream(tempFile));
GcodeParserUtils.processAndExport(gcp, tempFile, output.toFile());
GcodeStreamReader reader = new GcodeStreamReader(output.toFile());
file = this.getClass().getClassLoader().getResource("./gcode/circle_test.nc.processed");
Files.lines(Paths.get(file.toURI())).forEach((t) -> {
try {
GcodeCommand c = reader.getNextCommand();
if (c == null) {
Assert.fail("Reached end of gcode reader before end of expected commands.");
}
Assert.assertEquals(c.getCommandString(), t);
} catch (IOException ex) {
Assert.fail("Unexpected exception.");
}
});
assertEquals(1027, reader.getNumRows());
output.toFile().delete();
}
use of com.willwinder.universalgcodesender.gcode.processors.LineSplitter in project Universal-G-Code-Sender by winder.
the class AutoLevelerTopComponent method applyToGcodeActionPerformed.
// GEN-LAST:event_dataViewerActionPerformed
private void applyToGcodeActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_applyToGcodeActionPerformed
GcodeParser gcp = new GcodeParser();
Settings.AutoLevelSettings autoLevelSettings = this.settings.getAutoLevelSettings();
// Step 0: Get rid of comments.
gcp.addCommandProcessor(new CommentProcessor());
// Step 1: The arc processor and line processors NO LONGER need to be split!
// Step 2: Must convert arcs to line segments.
gcp.addCommandProcessor(new ArcExpander(true, autoLevelSettings.autoLevelArcSliceLength));
// Step 3: Line splitter. No line should be longer than some fraction of "resolution"
gcp.addCommandProcessor(new LineSplitter(getValue(stepResolution) / 10));
// Step 4: Adjust Z heights codes based on mesh offsets.
gcp.addCommandProcessor(new MeshLeveler(getValue(this.zSurface), scanner.getProbePositionGrid(), scanner.getUnits()));
try {
backend.applyGcodeParser(gcp);
} catch (Exception ex) {
GUIHelpers.displayErrorDialog(ex.getMessage());
Exceptions.printStackTrace(ex);
}
}
Aggregations