Skip to content

Commit 13f4448

Browse files
author
Sven Erb
committed
Added progress tracking.
1 parent 77dfb64 commit 13f4448

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

  • ReaderWriter/3rdPartyFormatAdapters/GCODE/GCodeReaderWriter

ReaderWriter/3rdPartyFormatAdapters/GCODE/GCodeReaderWriter/GCodeReader.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,10 @@ public override void OpenJob(string filename, IFileReaderWriterProgress progress
155155

156156
this._filename = filename;
157157

158-
ParseGCodeFile();
158+
ParseGCodeFile(progress);
159159
}
160160

161-
public void ParseGCodeFile()
161+
public void ParseGCodeFile(IFileReaderWriterProgress progress = null)
162162
{
163163
MapField<int, MarkingParams> MPsMap = new MapField<int, MarkingParams>();
164164
Dictionary<MarkingParams, int> cachedMP = new Dictionary<MarkingParams, int>();
@@ -191,9 +191,12 @@ public void ParseGCodeFile()
191191
}
192192
};
193193

194-
foreach (GCodeCommand currentGCodeCommand in gCodeCommands)
194+
int gCodeCommandCount = gCodeCommands.Count;
195+
196+
for (int i = 0; i < gCodeCommandCount; i++)
195197
{
196-
switch (currentGCodeCommand)
198+
199+
switch (gCodeCommands[i])
197200
{
198201
case MovementCommand movementCmd:
199202
ProcessMovementCmd(movementCmd);
@@ -216,6 +219,9 @@ public void ParseGCodeFile()
216219
}
217220

218221
VBlocked = false;
222+
223+
int percentComplete = (i + 1) * 100 / gCodeCommandCount;
224+
progress?.Update("Command " + i + " of ", percentComplete);
219225
}
220226

221227
NewWorkPlane();

0 commit comments

Comments
 (0)