GcodeInterpreter 0.1.0
dotnet add package GcodeInterpreter --version 0.1.0
NuGet\Install-Package GcodeInterpreter -Version 0.1.0
<PackageReference Include="GcodeInterpreter" Version="0.1.0" />
paket add GcodeInterpreter --version 0.1.0
#r "nuget: GcodeInterpreter, 0.1.0"
// Install GcodeInterpreter as a Cake Addin
#addin nuget:?package=GcodeInterpreter&version=0.1.0
// Install GcodeInterpreter as a Cake Tool
#tool nuget:?package=GcodeInterpreter&version=0.1.0
G-code Interpreter
Simple .NET G-code interpreter
The G-code interpreter will read a G-code file and produce a GcodeProgram
from it.
Setup
Install the GcodeInterpreter package from NuGet.
Install-Package GcodeInterpreter
Add services to DI
services.AddGcodeInterpreter();
Using the interpreter
Inject IGcodeInterpreter
into a class and use it to produce a GcodeProgram
public class Class1
{
private readonly IGcodeInterpreter _interpreter;
public Class1(IGcodeInterpreter interpreter)
{
_interpreter = interpreter;
}
public async Task<GcodeProgram> Build(string path)
{
return await _interpreter.ParseAsync(path);
}
}
A produced GcodeProgram
contains a Lines
property that contains the parsed lines of the G-code file.
Each Line
contains a Command
and Parameters
property. A Command
is of type Field
and the Parameters
is of type List<Field>
. A Field
contains a FieldLetter
and Code
property that represents a G-code
command or parameter.
// Loop through the G-code lines while printing each
// lines command
foreach (var line in program.Lines)
{
Console.WriteLine(line.Command.ToString());
}
// Print a line as it was in the G-code file
var line = program.Lines[0].ToString();
//M190 S60.000000
// Run the program somehow
foreach (var line in program.Lines)
{
switch (line.Command.FieldLetter.Letter)
{
case 'G':
DoSomething(line.Command.Code, line.Parameters);
break;
case 'M':
DoSomething(line.Command.Code, line.Parameters);
break;
}
}
References
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.