gcodehs-0.1.2.0: GCode processor

Safe HaskellNone
LanguageHaskell2010

Data.GCode.Eval

Contents

Description

GCode evaluator

Evaluates RS274 GCode

Synopsis

Documentation

data IPState Source #

Interpreter state

Instances
Eq IPState Source # 
Instance details

Defined in Data.GCode.Eval

Methods

(==) :: IPState -> IPState -> Bool #

(/=) :: IPState -> IPState -> Bool #

Ord IPState Source # 
Instance details

Defined in Data.GCode.Eval

Show IPState Source # 
Instance details

Defined in Data.GCode.Eval

newState :: IPState Source #

Create new interpreter state

step :: IPState -> GCode -> (Maybe Code, IPState, GCode) Source #

Step Code interpreter

evalSteps :: [Code] -> [([Maybe Code], IPState, [Code])] Source #

Evaluate GCode and return each evaluation step

in absolute mode

with millimeters as units

with total commands in modal groups

toMillimeters :: Map RS274Group Code -> Code -> Code Source #

Convert all axis coordinates from inches to millimeters if needed

toAbsolute :: Map RS274Group Code -> Code -> Code Source #

Convert all motion coordinates from relative to absolute

toAbsoluteArcs :: Map RS274Group Code -> Code -> Code Source #

Convert all arc coordinates from relative to absolute

codeActive :: Code -> Map RS274Group Code -> Bool Source #

Return True if code is active (present) in modals

isMotion :: Code -> Bool Source #

Return True if code is a motion comand

updateCodeAndModals :: Code -> Map RS274Group Code -> (Code, Map RS274Group Code) Source #

Update code according to current modals then update modals with a resulting code

Return updated code and modals

updateModals :: Map RS274Group Code -> Code -> Map RS274Group Code Source #

Update modal groups according to Code c

updateFromCurrentModals :: Map RS274Group Code -> Code -> Code Source #

Take current motion group modal code and update this motion code with missing coordinates of the stored one

incomplete :: Code -> Bool Source #

Return True if this code contains only coordinates

updateIncompleteFromCurrentModals :: Map RS274Group Code -> Code -> Code Source #

Update incomplete motion Code with the stored one

appendOnlyAxes :: Ord k => Map k b -> Map k b -> Map k b Source #

Update axes that aren't defined in target

updateAxes :: Ord k => Map k a -> Map k a -> Map k a Source #

Update (replace) target axes with from axes

eval :: GCode -> ([Code], IPState) Source #

Fully evaluate GCode

evalToCanon :: GCode -> ([Canon], IPState) Source #

Evaluate GCode to canonical representation

evalToCanonAnn :: GCode -> ([Ann Canon], IPState) Source #

Evaluate GCode to annotated canonnical representation

toCanonAnn :: Code -> IPState -> [Ann Canon] Source #

Same as toCanon but result is wrapped in Ann according to current interpreter line

evalWith :: (Code -> IPState -> Maybe a) -> GCode -> ([a], IPState) Source #

Evaluate GCode and and apply function f to each successfuly evaluated Code

Slow due to list concatenation, use streaming variants from Pipes instead.

evalWith' :: (Code -> IPState -> [a]) -> GCode -> ([a], IPState) Source #

totalize :: GCode -> GCode Source #

Walk GCode adding missing axes coordinates according to previous moves

For example G0 X1 G0 Y2 G0 Z3

becomes G0 X1 G0 X1 Y2 G0 X1 Y2 Z3

also

G0 X1 Y2 Z2

becomes

G0 X1 G0 X1 Y2 Z2