Remove PrinterConfig reference from PrinterSettings
This commit is contained in:
parent
55441d59a1
commit
2a2e052b53
7 changed files with 25 additions and 24 deletions
|
|
@ -2024,7 +2024,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
printer.Connection.PrintingItemName = printItemName;
|
||||
|
||||
if (SettingsValidation.SettingsValid(printer.Settings))
|
||||
if (SettingsValidation.SettingsValid(printer))
|
||||
{
|
||||
// check that current bed temp is is within 10 degrees of leveling temp
|
||||
var enabled = printer.Settings.GetValue<bool>(SettingsKey.print_leveling_enabled);
|
||||
|
|
|
|||
|
|
@ -114,9 +114,8 @@ namespace MatterHackers.MatterControl
|
|||
this.Connection.ConnectionSucceeded += Connection_ConnectionSucceeded;
|
||||
this.Connection.CommunicationStateChanged += Connection_CommunicationStateChanged;
|
||||
this.Connection.PrintFinished += Connection_PrintFinished;
|
||||
|
||||
|
||||
this.Settings = settings;
|
||||
this.Settings.printer = this;
|
||||
this.Settings.SettingChanged += Printer_SettingChanged;
|
||||
|
||||
if (!string.IsNullOrEmpty(this.Settings.GetValue(SettingsKey.baud_rate)))
|
||||
|
|
|
|||
|
|
@ -38,8 +38,10 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
public static class SettingsValidation
|
||||
{
|
||||
public static bool SettingsValid(PrinterSettings settings)
|
||||
public static bool SettingsValid(PrinterConfig printer)
|
||||
{
|
||||
var settings = printer.Settings;
|
||||
|
||||
try
|
||||
{
|
||||
if (settings.GetValue<bool>(SettingsKey.validate_layer_height))
|
||||
|
|
@ -257,19 +259,19 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
|
||||
// If the given speed is part of the current slice engine then check that it is greater than 0.
|
||||
if (!ValidateGoodSpeedSettingGreaterThan0("bridge_speed", settings)) return false;
|
||||
if (!ValidateGoodSpeedSettingGreaterThan0("air_gap_speed", settings)) return false;
|
||||
if (!ValidateGoodSpeedSettingGreaterThan0("external_perimeter_speed", settings)) return false;
|
||||
if (!ValidateGoodSpeedSettingGreaterThan0(SettingsKey.first_layer_speed, settings)) return false;
|
||||
if (!ValidateGoodSpeedSettingGreaterThan0("infill_speed", settings)) return false;
|
||||
if (!ValidateGoodSpeedSettingGreaterThan0("perimeter_speed", settings)) return false;
|
||||
if (!ValidateGoodSpeedSettingGreaterThan0("small_perimeter_speed", settings)) return false;
|
||||
if (!ValidateGoodSpeedSettingGreaterThan0("solid_infill_speed", settings)) return false;
|
||||
if (!ValidateGoodSpeedSettingGreaterThan0("support_material_speed", settings)) return false;
|
||||
if (!ValidateGoodSpeedSettingGreaterThan0(SettingsKey.top_solid_infill_speed, settings)) return false;
|
||||
if (!ValidateGoodSpeedSettingGreaterThan0("travel_speed", settings)) return false;
|
||||
if (!ValidateGoodSpeedSettingGreaterThan0("bridge_speed", printer)) return false;
|
||||
if (!ValidateGoodSpeedSettingGreaterThan0("air_gap_speed", printer)) return false;
|
||||
if (!ValidateGoodSpeedSettingGreaterThan0("external_perimeter_speed", printer)) return false;
|
||||
if (!ValidateGoodSpeedSettingGreaterThan0(SettingsKey.first_layer_speed, printer)) return false;
|
||||
if (!ValidateGoodSpeedSettingGreaterThan0("infill_speed", printer)) return false;
|
||||
if (!ValidateGoodSpeedSettingGreaterThan0("perimeter_speed", printer)) return false;
|
||||
if (!ValidateGoodSpeedSettingGreaterThan0("small_perimeter_speed", printer)) return false;
|
||||
if (!ValidateGoodSpeedSettingGreaterThan0("solid_infill_speed", printer)) return false;
|
||||
if (!ValidateGoodSpeedSettingGreaterThan0("support_material_speed", printer)) return false;
|
||||
if (!ValidateGoodSpeedSettingGreaterThan0(SettingsKey.top_solid_infill_speed, printer)) return false;
|
||||
if (!ValidateGoodSpeedSettingGreaterThan0("travel_speed", printer)) return false;
|
||||
|
||||
if (!ValidateGoodSpeedSettingGreaterThan0("retract_speed", settings)) return false;
|
||||
if (!ValidateGoodSpeedSettingGreaterThan0("retract_speed", printer)) return false;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
@ -317,9 +319,9 @@ namespace MatterHackers.MatterControl
|
|||
return settingData.PresentationName.Localize();
|
||||
}
|
||||
|
||||
private static bool ValidateGoodSpeedSettingGreaterThan0(string speedSetting, PrinterSettings settings)
|
||||
private static bool ValidateGoodSpeedSettingGreaterThan0(string speedSetting, PrinterConfig printer)
|
||||
{
|
||||
var actualSpeedValueString = settings.GetValue(speedSetting);
|
||||
var actualSpeedValueString = printer.Settings.GetValue(speedSetting);
|
||||
var speedValueString = actualSpeedValueString;
|
||||
if (speedValueString.EndsWith("%"))
|
||||
{
|
||||
|
|
@ -333,7 +335,7 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
|
||||
if (!valueWasNumber
|
||||
|| (settings.printer.EngineMappingsMatterSlice.MapContains(speedSetting)
|
||||
|| (printer.EngineMappingsMatterSlice.MapContains(speedSetting)
|
||||
&& speedToCheck <= 0))
|
||||
{
|
||||
SliceSettingData data = SettingsOrganizer.Instance.GetSettingsData(speedSetting);
|
||||
|
|
|
|||
|
|
@ -529,7 +529,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
UiThread.RunOnIdle(async () =>
|
||||
{
|
||||
if (!activelySlicing
|
||||
&& SettingsValidation.SettingsValid(printer.Settings)
|
||||
&& SettingsValidation.SettingsValid(printer)
|
||||
&& printer.Bed.EditContext.SourceItem != null)
|
||||
{
|
||||
activelySlicing = true;
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
if (printer.Settings.PrinterSelected)
|
||||
{
|
||||
if (!activelySlicing
|
||||
&& SettingsValidation.SettingsValid(printer.Settings)
|
||||
&& SettingsValidation.SettingsValid(printer)
|
||||
&& printer.Bed.EditContext.SourceItem != null)
|
||||
{
|
||||
activelySlicing = true;
|
||||
|
|
|
|||
|
|
@ -93,8 +93,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
|
||||
public PrinterSettingsLayer StagedUserSettings { get; set; } = new PrinterSettingsLayer();
|
||||
|
||||
[JsonIgnore]
|
||||
internal PrinterConfig printer { get; set; }
|
||||
|
||||
static PrinterSettings()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -680,7 +680,9 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
|
||||
private void Printer_SettingsChanged(object sender, EventArgs e)
|
||||
{
|
||||
var printer = (sender as PrinterSettings)?.printer;
|
||||
string printerID = (sender as PrinterSettings)?.ID;
|
||||
|
||||
var printer = ApplicationController.Instance.ActivePrinters.FirstOrDefault(p => p.Settings.ID == printerID);
|
||||
|
||||
if (Instance?.OpenPrinterIDs.Any() != true
|
||||
|| printer == null)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue