Extract PrintRecovery logic for reuse
This commit is contained in:
parent
480851aa44
commit
9a8d31defd
1 changed files with 17 additions and 6 deletions
|
|
@ -39,6 +39,22 @@ namespace MatterHackers.MatterControl.PrintHistory
|
|||
{
|
||||
public static class PrintRecovery
|
||||
{
|
||||
public static bool RecoveryAvailable(PrinterConfig printer)
|
||||
{
|
||||
PrintTask lastPrint = PrintHistoryData.Instance.GetHistoryForPrinter(printer.Settings.ID.GetHashCode()).FirstOrDefault();
|
||||
return RecoveryAvailable(printer, lastPrint);
|
||||
}
|
||||
|
||||
public static bool RecoveryAvailable(PrinterConfig printer, PrintTask lastPrint)
|
||||
{
|
||||
return !lastPrint.PrintComplete // Top Print History Item is not complete
|
||||
&& !string.IsNullOrEmpty(lastPrint.PrintingGCodeFileName) // PrintingGCodeFileName is set
|
||||
&& File.Exists(lastPrint.PrintingGCodeFileName) // PrintingGCodeFileName is still on disk
|
||||
&& lastPrint.PercentDone > 0 // we are actually part way into the print
|
||||
&& printer.Settings.GetValue<bool>(SettingsKey.recover_is_enabled)
|
||||
&& !printer.Settings.GetValue<bool>(SettingsKey.has_hardware_leveling);
|
||||
}
|
||||
|
||||
public static void CheckIfNeedToRecoverPrint(PrinterConfig printer)
|
||||
{
|
||||
string recoverPrint = "Recover Print".Localize();
|
||||
|
|
@ -50,12 +66,7 @@ namespace MatterHackers.MatterControl.PrintHistory
|
|||
PrintTask lastPrint = PrintHistoryData.Instance.GetHistoryForPrinter(printer.Settings.ID.GetHashCode()).FirstOrDefault();
|
||||
if (lastPrint != null)
|
||||
{
|
||||
if (!lastPrint.PrintComplete // Top Print History Item is not complete
|
||||
&& !string.IsNullOrEmpty(lastPrint.PrintingGCodeFileName) // PrintingGCodeFileName is set
|
||||
&& File.Exists(lastPrint.PrintingGCodeFileName) // PrintingGCodeFileName is still on disk
|
||||
&& lastPrint.PercentDone > 0 // we are actually part way into the print
|
||||
&& printer.Settings.GetValue<bool>(SettingsKey.recover_is_enabled)
|
||||
&& !printer.Settings.GetValue<bool>(SettingsKey.has_hardware_leveling))
|
||||
if (RecoveryAvailable(printer))
|
||||
{
|
||||
bool safeHomingDirection = printer.Settings.GetValue<bool>(SettingsKey.z_homes_to_max);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue