Split print and slice validation to reduce non-relevant reporting
- Issue MatterHackers/MCCentral#4884
This commit is contained in:
parent
05b4736535
commit
d45bf5e1d3
3 changed files with 58 additions and 38 deletions
|
|
@ -42,48 +42,17 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
public static class SettingsValidation
|
||||
{
|
||||
/// <summary>
|
||||
/// Validates the printer settings satisfy all requirements
|
||||
/// </summary>
|
||||
/// <param name="printer">The printer to validate</param>
|
||||
/// <returns>A list of all warnings and errors</returns>
|
||||
public static List<ValidationError> ValidateSettings(this PrinterConfig printer)
|
||||
{
|
||||
var settings = printer.Settings;
|
||||
|
||||
var errors = new List<ValidationError>();
|
||||
|
||||
var printerIsConnected = printer.Connection.CommunicationState != PrinterCommunication.CommunicationStates.Disconnected;
|
||||
if (!printerIsConnected)
|
||||
{
|
||||
errors.Add(new ValidationError()
|
||||
{
|
||||
Error = "Printer Disconnected".Localize(),
|
||||
Details = "Connect to your printer to continue".Localize()
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: Consider splitting out each individual requirement in PrinterNeedsToRunSetup and reporting validation in a more granular fashion
|
||||
if (ApplicationController.PrinterNeedsToRunSetup(printer))
|
||||
{
|
||||
errors.Add(new ValidationError()
|
||||
{
|
||||
Error = "Printer Setup Required".Localize(),
|
||||
Details = "Printer Setup must be run before printing".Localize(),
|
||||
FixAction = new NamedAction()
|
||||
{
|
||||
ID = "SetupPrinter",
|
||||
Title = "Setup".Localize() + "...",
|
||||
Action = () =>
|
||||
{
|
||||
UiThread.RunOnIdle(async () =>
|
||||
{
|
||||
await ApplicationController.Instance.PrintPart(
|
||||
printer.Bed.EditContext,
|
||||
printer,
|
||||
null,
|
||||
CancellationToken.None);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// last let's check if there is any support in the scene and if it looks like it is needed
|
||||
var supportGenerator = new SupportGenerator(printer.Bed.Scene);
|
||||
if (supportGenerator.RequiresSupport())
|
||||
|
|
@ -373,6 +342,57 @@ namespace MatterHackers.MatterControl
|
|||
return errors;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates printer satisfies all requirements
|
||||
/// </summary>
|
||||
/// <param name="printer">The printer to validate</param>
|
||||
/// <returns>A list of all warnings and errors</returns>
|
||||
public static List<ValidationError> Validate(this PrinterConfig printer)
|
||||
{
|
||||
var errors = new List<ValidationError>();
|
||||
|
||||
var printerIsConnected = printer.Connection.CommunicationState != PrinterCommunication.CommunicationStates.Disconnected;
|
||||
if (!printerIsConnected)
|
||||
{
|
||||
errors.Add(new ValidationError()
|
||||
{
|
||||
Error = "Printer Disconnected".Localize(),
|
||||
Details = "Connect to your printer to continue".Localize()
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: Consider splitting out each individual requirement in PrinterNeedsToRunSetup and reporting validation in a more granular fashion
|
||||
if (ApplicationController.PrinterNeedsToRunSetup(printer))
|
||||
{
|
||||
errors.Add(new ValidationError()
|
||||
{
|
||||
Error = "Printer Setup Required".Localize(),
|
||||
Details = "Printer Setup must be run before printing".Localize(),
|
||||
FixAction = new NamedAction()
|
||||
{
|
||||
ID = "SetupPrinter",
|
||||
Title = "Setup".Localize() + "...",
|
||||
Action = () =>
|
||||
{
|
||||
UiThread.RunOnIdle(async () =>
|
||||
{
|
||||
await ApplicationController.Instance.PrintPart(
|
||||
printer.Bed.EditContext,
|
||||
printer,
|
||||
null,
|
||||
CancellationToken.None);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Concat printer and settings errors
|
||||
errors.AddRange(printer.ValidateSettings());
|
||||
|
||||
return errors;
|
||||
}
|
||||
|
||||
private static string GetSettingsName(string settingsKey)
|
||||
{
|
||||
var settingData = PrinterSettings.SettingsData[settingsKey];
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ namespace MatterHackers.MatterControl.Library.Export
|
|||
// TODO: Prior code bypassed GCodeOverridePath mechanisms in EditContext. Consolidating into a single pathway
|
||||
string gcodePath = printer.Bed.EditContext.GCodeFilePath(printer);
|
||||
|
||||
List<ValidationError> errors = new List<ValidationError>();
|
||||
var errors = new List<ValidationError>();
|
||||
|
||||
if (ApplicationSettings.ValidFileExtensions.IndexOf(sourceExtension, StringComparison.OrdinalIgnoreCase) >= 0
|
||||
|| string.Equals(sourceExtension, ".mcx", StringComparison.OrdinalIgnoreCase))
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
};
|
||||
|
||||
// Perform validation before popup
|
||||
var errors = printer.ValidateSettings();
|
||||
var errors = printer.Validate();
|
||||
|
||||
// Enable print option when no validation Errors exists
|
||||
var printEnabled = !errors.Any(err => err.ErrorLevel == ValidationErrorLevel.Error);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue