public GCodeFile(string gcode, GCodeFileOptions options) { MemoryStream stream = new MemoryStream(); StreamWriter writer = new StreamWriter(stream); writer.Write(gcode); writer.Flush(); stream.Position = 0; Init(stream, options); }
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); } }
public GCodeFile(Stream stream, GCodeFileOptions options) { Init(stream, options); }