use of com.willwinder.universalgcodesender.gcode.processors.ArcExpander in project Universal-G-Code-Sender by winder.
the class CommandProcessorLoader method getHelpForConfig.
/**
* Helper to instantiate a processor by name and call the getHelp method.
* @param pc
* @return
*/
public static String getHelpForConfig(ProcessorConfig pc) {
CommandProcessor p;
try {
switch(pc.name) {
case "ArcExpander":
double length = pc.args.get("segmentLengthMM").getAsDouble();
p = new ArcExpander(true, length);
break;
case "CommandLengthProcessor":
int commandLength = pc.args.get("commandLength").getAsInt();
p = new CommandLengthProcessor(commandLength);
break;
case "CommentProcessor":
p = new CommentProcessor();
break;
case "DecimalProcessor":
int decimals = pc.args.get("decimals").getAsInt();
p = new DecimalProcessor(decimals);
break;
case "FeedOverrideProcessor":
double override = pc.args.get("speedOverridePercent").getAsDouble();
p = new FeedOverrideProcessor(override);
break;
case "M30Processor":
p = new M30Processor();
break;
case "PatternRemover":
String pattern = pc.args.get("pattern").getAsString();
p = new PatternRemover(pattern);
break;
case "WhitespaceProcessor":
p = new WhitespaceProcessor();
break;
case "M3Dweller":
int duration = pc.args.get("duration").getAsInt();
p = new M3Dweller(duration);
break;
default:
throw new IllegalArgumentException("Unknown processor: " + pc.name);
}
return p.getHelp();
} catch (Exception e) {
return Localization.getString("settings.processors.loadError") + ": " + Localization.getString(pc.name);
}
}
use of com.willwinder.universalgcodesender.gcode.processors.ArcExpander 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.ArcExpander 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);
}
}
use of com.willwinder.universalgcodesender.gcode.processors.ArcExpander in project Universal-G-Code-Sender by winder.
the class CommandProcessorLoader method initializeWithProcessors.
public static List<CommandProcessor> initializeWithProcessors(List<ProcessorConfig> config) {
List<CommandProcessor> list = new ArrayList<>();
for (ProcessorConfig pc : config) {
CommandProcessor p = null;
// Check if the processor is enabled.
if (pc.optional && !pc.enabled) {
continue;
}
switch(pc.name) {
case "ArcExpander":
double length = pc.args.get("segmentLengthMM").getAsDouble();
p = new ArcExpander(true, length);
break;
case "CommandLengthProcessor":
int commandLength = pc.args.get("commandLength").getAsInt();
p = new CommandLengthProcessor(commandLength);
break;
case "CommentProcessor":
p = new CommentProcessor();
break;
case "DecimalProcessor":
int decimals = pc.args.get("decimals").getAsInt();
p = new DecimalProcessor(decimals);
break;
case "FeedOverrideProcessor":
double override = pc.args.get("speedOverridePercent").getAsDouble();
p = new FeedOverrideProcessor(override);
break;
case "M30Processor":
p = new M30Processor();
break;
case "PatternRemover":
String pattern = pc.args.get("pattern").getAsString();
p = new PatternRemover(pattern);
break;
case "WhitespaceProcessor":
p = new WhitespaceProcessor();
break;
case "M3Dweller":
double duration = pc.args.get("duration").getAsDouble();
p = new M3Dweller(duration);
break;
default:
throw new IllegalArgumentException("Unknown processor: " + pc.name);
}
list.add(p);
}
return list;
}
Aggregations