Cancel correctly during leveling validation

issue: MatterHackers/MCCentral#6259
If cancel while heating the bed w' leveling validation does not stop imediately
This commit is contained in:
Lars Brubaker 2021-02-09 16:54:31 -08:00
parent 9176639fd3
commit 71d2b13830
6 changed files with 31 additions and 13 deletions

View file

@ -454,7 +454,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
DataEditType = DataEditTypes.OFFSET3,
RequiredDisplayDetail = DisplayDetailRequired.Advanced,
Units = "mm".Localize(),
ShowIfSet = "!sla_printer",
ShowIfSet = "!sla_printer&extruder_count>1",
DefaultValue = "0x0,0x0,0x0,0x0"
},
new SliceSettingData()

View file

@ -70,7 +70,7 @@ namespace MatterHackers.MatterControl
this.Connection.TemporarilyHoldingTemp += ApplicationController.Instance.Connection_TemporarilyHoldingTemp;
this.Connection.PrintStarted += ApplicationController.Instance.Connection_PrintStarted;
this.Connection.PrintFinished += ApplicationController.Instance.Connection_PrintFinished;
this.Connection.PrintCanceled += ApplicationController.Instance.Connection_PrintCanceled;
this.Connection.CancelCompleted += ApplicationController.Instance.Connection_PrintCanceled;
this.Connection.ErrorReported += ApplicationController.Instance.Connection_ErrorReported;
this.Connection.CommunicationStateChanged += Connection_CommunicationStateChanged;
this.Connection.DetailedPrintingStateChanged += Connection_CommunicationStateChanged;
@ -353,7 +353,7 @@ namespace MatterHackers.MatterControl
this.Connection.PrintFinished -= Connection_PrintFinished;
this.Connection.TemporarilyHoldingTemp -= ApplicationController.Instance.Connection_TemporarilyHoldingTemp;
this.Connection.PrintFinished -= ApplicationController.Instance.Connection_PrintFinished;
this.Connection.PrintCanceled -= ApplicationController.Instance.Connection_PrintCanceled;
this.Connection.CancelCompleted -= ApplicationController.Instance.Connection_PrintCanceled;
this.Connection.ErrorReported -= ApplicationController.Instance.Connection_ErrorReported;
// Dispose children

View file

@ -36,6 +36,7 @@ using MatterHackers.Localizations;
using MatterHackers.MatterControl.ConfigurationPage.PrintLeveling;
using MatterHackers.MatterControl.DesignTools;
using MatterHackers.MatterControl.SlicerConfiguration;
using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl
{
@ -86,6 +87,24 @@ namespace MatterHackers.MatterControl
}
}
if (!settings.GetValue<bool>(SettingsKey.extruder_offset))
{
var t0Offset = printer.Settings.Helpers.ExtruderOffset(0);
if (t0Offset != Vector3.Zero)
{
errors.Add(
new SettingsValidationError(SettingsKey.extruder_offset)
{
Error = "Nozzle 1 should have offsets set to 0.".Localize(),
ValueDetails = "{0} = {1}\n{2} = {3}".FormatWith(
GetSettingsName(SettingsKey.extruder_offset),
settings.GetValue<double>(SettingsKey.extruder_offset),
GetSettingsName(SettingsKey.extruder_offset),
settings.GetValue<double>(SettingsKey.extruder_offset)),
});
}
}
// Check to see if current OEM layer matches downloaded OEM layer
{
if (printer.Settings.GetValue(SettingsKey.make) != "Other"

View file

@ -164,7 +164,7 @@ namespace MatterHackers.MatterControl
// register callbacks for print completion
printer.Connection.Disposed += this.Connection_Disposed;
printer.Connection.PrintCanceled += this.Connection_PrintCanceled;
printer.Connection.CancelCompleted += this.Connection_PrintCanceled;
printer.Connection.CommunicationStateChanged += this.Connection_CommunicationStateChanged;
// hide this window
@ -206,7 +206,7 @@ namespace MatterHackers.MatterControl
{
printer.Connection.Disposed -= this.Connection_Disposed;
printer.Connection.CommunicationStateChanged -= this.Connection_CommunicationStateChanged;
printer.Connection.PrintCanceled -= this.Connection_PrintCanceled;
printer.Connection.CancelCompleted -= this.Connection_PrintCanceled;
}
private void Connection_CommunicationStateChanged(object sender, EventArgs e)

View file

@ -63,7 +63,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
public ValidatePrintLevelingStream(PrinterConfig printer, GCodeStream internalStream)
: base(printer, internalStream)
{
printer.Connection.PrintCanceled += Connection_PrintCanceled;
printer.Connection.CanceleRequested += Connection_PrintCanceled;
}
private void Connection_PrintCanceled(object sender, EventArgs e)
@ -76,7 +76,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
public override void Dispose()
{
CancelValidation();
printer.Connection.PrintCanceled -= Connection_PrintCanceled;
printer.Connection.CanceleRequested -= Connection_PrintCanceled;
base.Dispose();
}
@ -145,10 +145,6 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
gcodeAlreadyLeveled = true;
}
if (validationRunning && printer.Connection.PrintWasCanceled)
{
CancelValidation();
}
if (lineToSend != null)
{

View file

@ -156,7 +156,9 @@ namespace MatterHackers.MatterControl.PrinterCommunication
public event EventHandler PrintStarted;
public event EventHandler PrintCanceled;
public event EventHandler CanceleRequested;
public event EventHandler CancelCompleted;
public event EventHandler<PrintPauseEventArgs> PauseOnLayer;
@ -2263,6 +2265,7 @@ Make sure that your printer is turned on. Some printers will appear to be connec
// let the process know we canceled not ended normally.
this.printMarkedCanceled = true;
CanceleRequested?.Invoke(this, null);
if (markPrintCanceled
&& ActivePrintTask != null)
{
@ -2697,7 +2700,7 @@ Make sure that your printer is turned on. Some printers will appear to be connec
this.PrintWasCanceled = true;
this.printMarkedCanceled = false;
// and finally notify anyone that wants to know
PrintCanceled?.Invoke(this, null);
CancelCompleted?.Invoke(this, null);
}
else if (CommunicationState == CommunicationStates.Printing) // we finished printing normally
{