Search in sources :

Example 11 with CommentProcessor

use of com.willwinder.universalgcodesender.gcode.processors.CommentProcessor in project Universal-G-Code-Sender by winder.

the class GcodeParserTest method testResetCommandProcessors.

/**
 * Test of resetCommandProcessors method, of class GcodeParser.
 */
@Test
public void testResetCommandProcessors() {
    System.out.println("resetCommandProcessors");
    GcodeParser instance = new GcodeParser();
    instance.addCommandProcessor(new CommentProcessor());
    assertEquals(1, instance.numCommandProcessors());
    instance.resetCommandProcessors();
    assertEquals(0, instance.numCommandProcessors());
}
Also used : CommentProcessor(com.willwinder.universalgcodesender.gcode.processors.CommentProcessor) Test(org.junit.Test)

Example 12 with CommentProcessor

use of com.willwinder.universalgcodesender.gcode.processors.CommentProcessor 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);
    }
}
Also used : LineSplitter(com.willwinder.universalgcodesender.gcode.processors.LineSplitter) GcodeParser(com.willwinder.universalgcodesender.gcode.GcodeParser) MeshLeveler(com.willwinder.universalgcodesender.gcode.processors.MeshLeveler) ArcExpander(com.willwinder.universalgcodesender.gcode.processors.ArcExpander) AutoLevelSettings(com.willwinder.universalgcodesender.utils.Settings.AutoLevelSettings) AutoLevelSettings(com.willwinder.universalgcodesender.utils.Settings.AutoLevelSettings) Settings(com.willwinder.universalgcodesender.utils.Settings) CommentProcessor(com.willwinder.universalgcodesender.gcode.processors.CommentProcessor)

Example 13 with CommentProcessor

use of com.willwinder.universalgcodesender.gcode.processors.CommentProcessor 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;
}
Also used : ArrayList(java.util.ArrayList) DecimalProcessor(com.willwinder.universalgcodesender.gcode.processors.DecimalProcessor) PatternRemover(com.willwinder.universalgcodesender.gcode.processors.PatternRemover) ProcessorConfig(com.willwinder.universalgcodesender.utils.ControllerSettings.ProcessorConfig) CommentProcessor(com.willwinder.universalgcodesender.gcode.processors.CommentProcessor) M3Dweller(com.willwinder.universalgcodesender.gcode.processors.M3Dweller) WhitespaceProcessor(com.willwinder.universalgcodesender.gcode.processors.WhitespaceProcessor) CommandLengthProcessor(com.willwinder.universalgcodesender.gcode.processors.CommandLengthProcessor) CommandProcessor(com.willwinder.universalgcodesender.gcode.processors.CommandProcessor) ArcExpander(com.willwinder.universalgcodesender.gcode.processors.ArcExpander) FeedOverrideProcessor(com.willwinder.universalgcodesender.gcode.processors.FeedOverrideProcessor) M30Processor(com.willwinder.universalgcodesender.gcode.processors.M30Processor)

Aggregations

CommentProcessor (com.willwinder.universalgcodesender.gcode.processors.CommentProcessor)13 Test (org.junit.Test)9 WhitespaceProcessor (com.willwinder.universalgcodesender.gcode.processors.WhitespaceProcessor)6 CommandLengthProcessor (com.willwinder.universalgcodesender.gcode.processors.CommandLengthProcessor)5 DecimalProcessor (com.willwinder.universalgcodesender.gcode.processors.DecimalProcessor)5 M30Processor (com.willwinder.universalgcodesender.gcode.processors.M30Processor)5 ArcExpander (com.willwinder.universalgcodesender.gcode.processors.ArcExpander)4 GcodeParser (com.willwinder.universalgcodesender.gcode.GcodeParser)3 FeedOverrideProcessor (com.willwinder.universalgcodesender.gcode.processors.FeedOverrideProcessor)3 CommandProcessor (com.willwinder.universalgcodesender.gcode.processors.CommandProcessor)2 LineSplitter (com.willwinder.universalgcodesender.gcode.processors.LineSplitter)2 M3Dweller (com.willwinder.universalgcodesender.gcode.processors.M3Dweller)2 MeshLeveler (com.willwinder.universalgcodesender.gcode.processors.MeshLeveler)2 PatternRemover (com.willwinder.universalgcodesender.gcode.processors.PatternRemover)2 Position (com.willwinder.universalgcodesender.model.Position)2 GcodeStreamReader (com.willwinder.universalgcodesender.utils.GcodeStreamReader)2 GcodeCommand (com.willwinder.universalgcodesender.types.GcodeCommand)1 ProcessorConfig (com.willwinder.universalgcodesender.utils.ControllerSettings.ProcessorConfig)1 Settings (com.willwinder.universalgcodesender.utils.Settings)1 AutoLevelSettings (com.willwinder.universalgcodesender.utils.Settings.AutoLevelSettings)1