cleaning warnings

This commit is contained in:
Lars Brubaker 2019-04-30 18:16:56 -07:00
parent 6631f5742a
commit fbbd2b959c
3 changed files with 29 additions and 24 deletions

View file

@ -38,7 +38,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
{
public class SettingsHelpers
{
private PrinterSettings printerSettings;
private readonly PrinterSettings printerSettings;
private PrintLevelingData _printLevelingData = null;
public SettingsHelpers(PrinterSettings printerSettings)
@ -70,10 +70,9 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
{
string[] userValues = printerSettings.GetValue("layer_to_pause").Split(';');
int temp;
return userValues.Where(v => int.TryParse(v, out temp)).Select(v =>
return userValues.Where(v => int.TryParse(v, out int temp)).Select(v =>
{
//Convert from 0 based index to 1 based index
// Convert from 0 based index to 1 based index
int val = int.Parse(v);
// Special case for user entered zero that pushes 0 to 1, otherwise val = val - 1 for 1 based index
@ -142,6 +141,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
return _printLevelingData;
}
set
{
// Store new reference
@ -152,12 +152,11 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
}
}
private List<(Regex Regex, string Replacement)> _writeLineReplacements = new List<(Regex Regex, string Replacement)>();
private readonly List<(Regex Regex, string Replacement)> _writeLineReplacements = new List<(Regex Regex, string Replacement)>();
private string writeRegexString = "";
private static Regex getQuotedParts = new Regex(@"([""'])(\\?.)*?\1", RegexOptions.Compiled);
private static readonly Regex GetQuotedParts = new Regex(@"([""'])(\\?.)*?\1", RegexOptions.Compiled);
public List<(Regex Regex, string Replacement)> WriteLineReplacements
{
@ -172,7 +171,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
foreach (string regExLine in writeRegexString.Split(new string[] { "\\n" }, StringSplitOptions.RemoveEmptyEntries))
{
var matches = getQuotedParts.Matches(regExLine);
var matches = GetQuotedParts.Matches(regExLine);
if (matches.Count == 2)
{
var search = matches[0].Value.Substring(1, matches[0].Value.Length - 2);
@ -187,7 +186,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
}
}
public void DoPrintLeveling(bool doLeveling)
{
// Early exit if already set
@ -245,6 +243,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
{
newValue += ",";
}
newValue += $"{offset.X:0.###}x{offset.Y:0.###}x{offset.Z:0.###}";
first = false;
}
@ -275,6 +274,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
return new Vector3(double.Parse(xyz[0]), double.Parse(xyz[1]), double.Parse(xyz[2]));
}
}
count++;
}

View file

@ -59,6 +59,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
{
recoverFeedRate = 10;
}
recoverFeedRate *= 60;
queuedCommands = new QueuedCommandsStream(printer, null);
@ -147,6 +148,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
// home z
queuedCommands.Add("G28 Z0");
}
// We now know where the printer is re-enable print leveling
printer.Connection.AllowLeveling = true;
RecoveryState = RecoveryState.FindingRecoveryLayer;
@ -176,17 +178,19 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
while (internalStream.GCodeFile.PercentComplete(internalStream.LineIndex) < percentDone)
{
string line = internalStream.ReadLine();
if(line == null)
if (line == null)
{
break;
}
commandCount++;
// make sure we don't parse comments
if(line.Contains(";"))
if (line.Contains(";"))
{
line = line.Split(';')[0];
}
lastDestination = GetPosition(line, lastDestination);
if (commandCount > 100)
@ -218,7 +222,6 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
case RecoveryState.PrimingAndMovingToStart:
{
if (printer.Settings.GetValue("z_homes_to_max") == "0") // we are homed to the bed
{
// move to the height we can recover printing from
@ -229,8 +232,9 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
double extruderWidth = printer.Settings.GetValue<double>(SettingsKey.nozzle_diameter);
// move to a position outside the printed bounds
queuedCommands.Add(CreateMovementLine(new PrinterMove(
new Vector3(boundsOfSkippedLayers.Left - extruderWidth*2, boundsOfSkippedLayers.Bottom + boundsOfSkippedLayers.Height / 2, lastDestination.position.Z),
0, printer.Settings.XSpeed())));
new Vector3(boundsOfSkippedLayers.Left - extruderWidth * 2, boundsOfSkippedLayers.Bottom + boundsOfSkippedLayers.Height / 2, lastDestination.position.Z),
0,
printer.Settings.XSpeed())));
// let's prime the extruder
queuedCommands.Add("G1 E10 F{0}".FormatWith(printer.Settings.EFeedRate(0))); // extrude 10
@ -239,10 +243,11 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
// move to the actual print position
queuedCommands.Add(CreateMovementLine(new PrinterMove(lastDestination.position, 0, printer.Settings.XSpeed())));
/// reset the printer to know where the filament should be
// reset the printer to know where the filament should be
queuedCommands.Add("G92 E{0}".FormatWith(lastDestination.extrusion));
RecoveryState = RecoveryState.PrintingSlow;
}
return "";
case RecoveryState.PrintingSlow:

@ -1 +1 @@
Subproject commit b6c9515a7f6df15e24d52d208ab3a2e943910548
Subproject commit 8cdfe6d0fa3c7a178ceefb9cc9d14425e30cb121