Giter VIP home page Giter VIP logo

gcodes's Introduction

Gcodes

Build status

A basic C# gcode parser and interpreter.

Getting Started

Once you've downloaded a copy of the repository (e.g. as a git submodule), you should be able to start using the gcodes library by asking Visual Studio to add a reference to it.

Analysing Gcode Programs

If you just want to inspect a gcode program without doing any simulation you just need to run the Parser and inspect its output.

Parsing the input text takes place in two steps:

  • Tokenizing, using the Lexer class to convert source text into a stream of Tokens
  • Parsing, using a Parser to convert a stream of Tokens into a bunch of Gcode objects.
public static void ParseGcodeFile(string filename) {
	string src = File.ReadAllText(filename);

	var lexer = new Lexer(src);
	List<Token> tokens = lexer.Tokenize().ToList();

	var parser = new Parser(tokens);
	List<Code> gcodes = parser.Parse().ToList();

	// do something with the gcodes
}

Note: For convenience, Parser also has a constructor which accepts a string and will tokenize everything for you.

There is no guarantee that every argument is provided to a gcode, therefore if you want to fetch an argument's value (e.g. X or feed rate) you can use the ValueFor() method. This will search the arguments provided to a particular gcode for the specified ArgumentKind, and return its value.

Simulating A CNC Machine

gcodes's People

Contributors

michael-f-bryan avatar

Watchers

Baris avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.