Making GCodeFile a abstract base class

implementing a loaded gcode file and as streamed gcode file
This commit is contained in:
Lars Brubaker 2015-01-20 12:57:30 -08:00
parent e1979e770e
commit 55fa89d684
5 changed files with 13 additions and 18 deletions

View file

@ -398,7 +398,7 @@ namespace MatterHackers.MatterControl
{
if (ActivePrinterProfile.Instance.DoPrintLeveling)
{
GCodeFile unleveledGCode = new GCodeFile(source);
GCodeFileLoaded unleveledGCode = new GCodeFileLoaded(source);
if (applyLeveling.Checked)
{
PrintLevelingPlane.Instance.ApplyLeveling(unleveledGCode);

View file

@ -264,11 +264,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
if (firstExtrusionIndex > 0)
{
for (int i = 0; i < loadedGCode.NumChangesInZ; i++)
for (int layerIndex = 0; layerIndex < loadedGCode.NumChangesInZ; layerIndex++)
{
if (firstExtrusionIndex < loadedGCode.IndexOfChangeInZ[i])
if (firstExtrusionIndex < loadedGCode.GetInstructionIndexAtLayer(layerIndex))
{
activeLayerIndex = Math.Max(0, i-1);
activeLayerIndex = Math.Max(0, layerIndex-1);
break;
}
}
@ -481,7 +481,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
public void Load(string gcodePathAndFileName)
{
loadedGCode = new GCodeFile(gcodePathAndFileName);
loadedGCode = GCodeFile.Load(gcodePathAndFileName);
SetInitalLayer();
CenterPartInView();
}
@ -497,7 +497,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(initialLoading_RunWorkerCompleted);
loadedGCode = null;
GCodeFile.LoadInBackground(backgroundWorker, gcodePathAndFileName);
GCodeFileLoaded.LoadInBackground(backgroundWorker, gcodePathAndFileName);
}
public override void OnClosed(EventArgs e)

View file

@ -177,11 +177,6 @@ namespace MatterHackers.MatterControl.PrintQueue
}
}
}
if (!foundAmountInGCode)
{
GCodeFile gcodeFile = new GCodeFile(gcodeFileName);
total += gcodeFile.GetFilamentCubicMm(ActiveSliceSettings.Instance.FilamentDiameter) / 1000;
}
}
}
@ -195,7 +190,7 @@ namespace MatterHackers.MatterControl.PrintQueue
if (ActivePrinterProfile.Instance.DoPrintLeveling)
{
GCodeFile unleveledGCode = new GCodeFile(savedGcodeFileName);
GCodeFileLoaded unleveledGCode = new GCodeFileLoaded(savedGcodeFileName);
PrintLevelingPlane.Instance.ApplyLeveling(unleveledGCode);
unleveledGCode.Save(outputPathAndName);
}

View file

@ -37,7 +37,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
{
public class PrinterIoGCodeFile : PrinterIoBase
{
GCodeFile loadedGCode = new GCodeFile();
GCodeFile loadedGCode;
int printerCommandQueueIndex;
public PrinterIoGCodeFile(GCodeFile loadedGCode)
{
@ -68,7 +68,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
{
for (int zIndex = 0; zIndex < loadedGCode.NumChangesInZ; zIndex++)
{
if (currentIndex < loadedGCode.IndexOfChangeInZ[zIndex])
if (currentIndex < loadedGCode.GetInstructionIndexAtLayer(zIndex))
{
return zIndex - 1;
}
@ -106,11 +106,11 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
&& currentIndex < loadedGCode.Count)
{
int currentLayer = CurrentlyPrintingLayer;
int startIndex = loadedGCode.IndexOfChangeInZ[currentLayer];
int startIndex = loadedGCode.GetInstructionIndexAtLayer(currentLayer);
int endIndex = loadedGCode.Count - 1;
if (currentLayer < loadedGCode.NumChangesInZ - 2)
{
endIndex = loadedGCode.IndexOfChangeInZ[currentLayer + 1] - 1;
endIndex = loadedGCode.GetInstructionIndexAtLayer(currentLayer + 1) - 1;
}
int deltaFromStart = Math.Max(0, currentIndex - startIndex);

View file

@ -296,7 +296,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
double actualBedTemperature;
double targetBedTemperature;
string printJobDisplayName = null;
GCodeFile loadedGCode = new GCodeFile();
GCodeFile loadedGCode = new GCodeFileLoaded(); // we start out by setting it to a nothing file
IFrostedSerialPort serialPort;
Thread readFromPrinterThread;
Thread connectThread;
@ -2450,7 +2450,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
LinesToWriteQueue.Clear();
ClearQueuedGCode();
loadedGCode = new GCodeFile(gcodeFilename);
loadedGCode = GCodeFile.Load(gcodeFilename);
switch (communicationState)
{