diff options
author | David Crocker <dcrocker@eschertech.com> | 2019-06-10 11:48:57 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2019-06-10 11:48:57 +0300 |
commit | 8652a9f765f0c6fe1d3e2a3198c4ab72bcab7b81 (patch) | |
tree | 9a9ddd8d97791c728413420769e8d52de4098708 /src/GCodes/GCodeMachineState.cpp | |
parent | c62b3864f0a95b3a5975dda210588268741515eb (diff) |
Started work on conditional GCode
Implemented the basic language constructs for conditional GCode. As part of this, improved the interface between the GCodeBuffer class and the various GCode input streams.
Created file GCodes4.cpp and moved the state machine implementation into it.
Diffstat (limited to 'src/GCodes/GCodeMachineState.cpp')
-rw-r--r-- | src/GCodes/GCodeMachineState.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/GCodes/GCodeMachineState.cpp b/src/GCodes/GCodeMachineState.cpp index be73242a..a993572e 100644 --- a/src/GCodes/GCodeMachineState.cpp +++ b/src/GCodes/GCodeMachineState.cpp @@ -12,10 +12,11 @@ unsigned int GCodeMachineState::numAllocated = 0; // Create a default initialised GCodeMachineState GCodeMachineState::GCodeMachineState() - : previous(nullptr), feedRate(DefaultFeedRate * SecondsToMinutes), fileState(), lockedResources(0), errorMessage(nullptr), state(GCodeState::normal), + : previous(nullptr), feedRate(DefaultFeedRate * SecondsToMinutes), fileState(), lockedResources(0), errorMessage(nullptr), lineNumber(0), drivesRelative(false), axesRelative(false), doingFileMacro(false), runningM501(false), runningM502(false), volumetricExtrusion(false), g53Active(false), runningSystemMacro(false), usingInches(false), - waitingForAcknowledgement(false), messageAcknowledged(false) + waitingForAcknowledgement(false), messageAcknowledged(false), + indentLevel(0), state(GCodeState::normal) { } @@ -55,4 +56,23 @@ GCodeMachineState::GCodeMachineState() return inUse; } +GCodeMachineState::BlockState& GCodeMachineState::CurrentBlockState() +{ + return blockStates[min<size_t>(indentLevel, ARRAY_SIZE(blockStates) - 1)]; +} + +void GCodeMachineState::CreateBlock() +{ + ++indentLevel; + CurrentBlockState().SetPlainBlock(); +} + +void GCodeMachineState::EndBlock() +{ + if (indentLevel != 0) + { + --indentLevel; + } +} + // End |