use of com.willwinder.universalgcodesender.gcode.processors.FeedOverrideProcessor 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.FeedOverrideProcessor in project Universal-G-Code-Sender by winder.
the class GcodeParserTest method testPreprocessCommandFeedOverride.
@Test
public void testPreprocessCommandFeedOverride() throws Exception {
System.out.println("preprocessCommandFeedOverride");
// Tests:
// '(comment)' is removed
// '; Comment!' is removed
// 'M30' is removed
// Decimal truncated to 0.88889
// Remove spaces
String command = "(comment) G01 X0.888888888888888888 M30 F100; Comment!";
GcodeParser instance = new GcodeParser();
instance.addCommandProcessor(new CommentProcessor());
instance.addCommandProcessor(new FeedOverrideProcessor(0.));
instance.addCommandProcessor(new DecimalProcessor(5));
instance.addCommandProcessor(new M30Processor());
instance.addCommandProcessor(new WhitespaceProcessor());
instance.addCommandProcessor(new CommandLengthProcessor(50));
List<String> result = instance.preprocessCommand(command, instance.getCurrentState());
assertEquals(1, result.size());
assertEquals("G01X0.88889F100", result.get(0));
instance.resetCommandProcessors();
instance.addCommandProcessor(new CommentProcessor());
instance.addCommandProcessor(new FeedOverrideProcessor(200.));
instance.addCommandProcessor(new DecimalProcessor(5));
instance.addCommandProcessor(new M30Processor());
instance.addCommandProcessor(new WhitespaceProcessor());
instance.addCommandProcessor(new CommandLengthProcessor(50));
result = instance.preprocessCommand(command, instance.getCurrentState());
assertEquals(1, result.size());
assertEquals("G01X0.88889F200.0", result.get(0));
}
use of com.willwinder.universalgcodesender.gcode.processors.FeedOverrideProcessor 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