diff options
author | David Crocker <dcrocker@eschertech.com> | 2019-07-01 17:04:37 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2019-07-01 17:04:37 +0300 |
commit | e14f84e930073bd33d6ecc2ebdad9c3147ed6e18 (patch) | |
tree | 38429f8903de0926414f3196641972236ace37a0 /src/GCodes/GCodeMachineState.cpp | |
parent | e9ad66b07a3c00739e3d5dd30eca5e139ffa7da5 (diff) | |
parent | 8cdc3d9afe81c9f0ba4b250949bb0e6c30a38dbf (diff) |
Merge remote-tracking branch 'origin/v3-chrishamm' into v3-dev
Diffstat (limited to 'src/GCodes/GCodeMachineState.cpp')
-rw-r--r-- | src/GCodes/GCodeMachineState.cpp | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/src/GCodes/GCodeMachineState.cpp b/src/GCodes/GCodeMachineState.cpp index a993572e..f638e59c 100644 --- a/src/GCodes/GCodeMachineState.cpp +++ b/src/GCodes/GCodeMachineState.cpp @@ -5,19 +5,61 @@ * Author: David */ +#include <limits> + #include "GCodeMachineState.h" GCodeMachineState *GCodeMachineState::freeList = nullptr; unsigned int GCodeMachineState::numAllocated = 0; +#if HAS_LINUX_INTERFACE +static unsigned int LastFileId = 1; +#endif + // Create a default initialised GCodeMachineState GCodeMachineState::GCodeMachineState() - : previous(nullptr), feedRate(DefaultFeedRate * SecondsToMinutes), fileState(), lockedResources(0), errorMessage(nullptr), lineNumber(0), + : previous(nullptr), feedRate(DefaultFeedRate * SecondsToMinutes), 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), indentLevel(0), state(GCodeState::normal) { +#if HAS_LINUX_INTERFACE + fileId = 0; + isFileFinished = false; +#endif +} + +#if HAS_LINUX_INTERFACE +// Set the state to indicate a file is being processed +void GCodeMachineState::SetFileExecuting() +{ + fileId = LastFileId++; + isFileFinished = false; +} + +// Mark the currently executing file as finished +void GCodeMachineState::SetFileFinished() +{ + isFileFinished = true; +} +#endif + +// Close the currently executing file +void GCodeMachineState::CloseFile() +{ +#if HAS_HIGH_SPEED_SD + fileState.Close(); +#elif HAS_LINUX_INTERFACE + for (GCodeMachineState *ms = this; ms != nullptr; ms = ms->previous) + { + if (ms->fileId == fileId) + { + ms->isFileFinished = false; + ms->fileId = 0; + } + } +#endif } // Allocate a new GCodeMachineState @@ -41,7 +83,12 @@ GCodeMachineState::GCodeMachineState() /*static*/ void GCodeMachineState::Release(GCodeMachineState *ms) { +#if HAS_HIGH_SPEED_SD ms->fileState.Close(); +#elif HAS_LINUX_INTERFACE + ms->fileId = 0; + ms->isFileFinished = false; +#endif ms->previous = freeList; freeList = ms; } |