blob: e21cddfbf82cb7753f81cfa70423ba6b1b34deb3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
/*
* GCodeMachineState.cpp
*
* Created on: 15 Nov 2016
* Author: David
*/
#include "GCodeMachineState.h"
GCodeMachineState *GCodeMachineState::freeList = nullptr;
unsigned int GCodeMachineState::numAllocated = 0;
// Create a default initialised GCodeMachineState
GCodeMachineState::GCodeMachineState()
: previous(nullptr), feedrate(DefaultFeedrate * secondsToMinutes), fileState(), lockedResources(0), state(GCodeState::normal),
drivesRelative(false), axesRelative(false), doingFileMacro(false), runningM502(false)
{
}
// Allocate a new GCodeMachineState
/*static*/ GCodeMachineState *GCodeMachineState::Allocate()
{
GCodeMachineState *ms = freeList;
if (ms != nullptr)
{
freeList = ms->previous;
ms->lockedResources = 0;
ms->state = GCodeState::normal;
}
else
{
ms = new GCodeMachineState();
++numAllocated;
}
return ms;
}
/*static*/ void GCodeMachineState::Release(GCodeMachineState *ms)
{
ms->fileState.Close();
ms->previous = freeList;
freeList = ms;
}
/*static*/ unsigned int GCodeMachineState::GetNumInUse()
{
unsigned int inUse = numAllocated;
for (GCodeMachineState *ms = freeList; ms != nullptr; ms = ms->previous)
{
--inUse;
}
return inUse;
}
// End
|