public static Command Parse(string gcode) { var tokenizer = new GCodeTokenizer(gcode); var commands = tokenizer.GetCommandTokens().ToArray(); if (commands.Length != 1) { throw new Exception("gcode may only contain a single command"); } return(FromTokens(commands[0])); }
void Init(Stream stream, GCodeFileOptions options) { var gcodeLines = GetAllGCodeLines(stream).ToArray(); if (options.CheckCRC) { CheckCRC(gcodeLines); } var gcodeString = string.Join(Environment.NewLine, gcodeLines.Select(l => l.GCode)); var tokenizer = new GCodeTokenizer(gcodeString); var commandTokens = tokenizer.GetCommandTokens().ToArray(); this.Commands.AddRange(commandTokens.Select(c => CreateCommandFromTokens(c, options.UseMappedObjects))); if (options.CheckLineNumers) { CheckLineNumbers(this.Commands); } }