Print recovery test working for dual extruder no probe

This commit is contained in:
LarsBrubaker 2020-08-09 08:23:22 -07:00
parent f7457c6758
commit 23e7263da5
10 changed files with 121 additions and 69 deletions

View file

@ -60,7 +60,8 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
loadFilamentButton.Click += (s, e) =>
{
base.setupWizard.MoveNext();
if(base.setupWizard.Current is WizardPage wizardPage)
if (base.setupWizard.Current is WizardPage wizardPage)
{
this.DialogWindow.ChangeToPage(wizardPage);
}

View file

@ -35,6 +35,7 @@ using System.Threading.Tasks;
using MatterHackers.Agg;
using MatterHackers.Agg.Image;
using MatterHackers.Agg.UI;
using MatterHackers.Localizations;
using MatterHackers.MatterControl.Library;
using MatterHackers.MatterControl.PartPreviewWindow;
using MatterHackers.MatterControl.PrintQueue;
@ -51,8 +52,6 @@ namespace MatterHackers.MatterControl.CustomWidgets
private ThemeConfig theme;
private ILibraryContext LibraryContext;
private int scrollAmount = -1;
private GuiWidget stashedContentView;
private ILibraryContainerLink loadingContainerLink;
@ -133,8 +132,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
}
// If the current view doesn't match the view requested by the container, construct and switch to the requested view
var targetView = Activator.CreateInstance(targetType) as GuiWidget;
if (targetView != null)
if (Activator.CreateInstance(targetType) is GuiWidget targetView)
{
this.ListContentView = targetView;
}
@ -264,10 +262,11 @@ namespace MatterHackers.MatterControl.CustomWidgets
using (contentView.LayoutLock())
{
IEnumerable<ILibraryItem> containerItems = from item in sourceContainer.ChildContainers
where item.IsVisible && this.ContainerFilter(item)
&& this.ContainsActiveFilter(item)
select item;
var containerItems = sourceContainer.ChildContainers
.Where(item => item.IsVisible
&& this.ContainerFilter(item)
&& this.ContainsActiveFilter(item))
.Select(item => item);
// Folder items
foreach (var childContainer in this.SortItems(containerItems))
@ -369,8 +368,6 @@ namespace MatterHackers.MatterControl.CustomWidgets
{
if (value is IListContentView)
{
scrollAmount = -1;
if (contentView != null
&& contentView != value)
{
@ -580,18 +577,6 @@ namespace MatterHackers.MatterControl.CustomWidgets
this.Reload().ConfigureAwait(false);
}
public override void OnMouseWheel(MouseEventArgs mouseEvent)
{
if (scrollAmount == -1)
{
scrollAmount = (int)(this.contentView.Children.FirstOrDefault()?.Height ?? 20);
}
int direction = (mouseEvent.WheelDelta > 0) ? -1 : 1;
ScrollPosition += new Vector2(0, scrollAmount * direction);
}
public override void OnClosed(EventArgs e)
{
if (this.LibraryContext != null)

View file

@ -43,7 +43,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
private ColorButton materialColorButton;
public event EventHandler<int> MaterialChanged;
int currentIndex;
private int currentIndex;
public ItemMaterialButton(ThemeConfig theme, int initialMaterialIndex)
{
@ -56,6 +57,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
var menuTheme = AppContext.MenuTheme;
this.Name = "ItemMaterialButton";
this.DynamicPopupContent = () =>
{
var materialControl = new MaterialControls(menuTheme, currentIndex)

View file

@ -54,8 +54,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
int extruderCount = 4;
for (int extruderIndex = -1; extruderIndex < extruderCount; extruderIndex++)
{
var name = $"{"Material".Localize()} {extruderIndex +1}";
if(extruderIndex == -1)
var name = $"{"Material".Localize()} {extruderIndex + 1}";
if (extruderIndex == -1)
{
name = "Default".Localize();
}
@ -93,7 +93,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
HAnchor = HAnchor.Fit,
VAnchor = VAnchor.Fit,
TextColor = theme.TextColor,
Checked = extruderIndex == initialMaterialIndex
Checked = extruderIndex == initialMaterialIndex,
Name = name + " Button"
};
materialButtons.Add(radioButton);
this.AddChild(radioButton);

View file

@ -89,7 +89,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
{
VAnchor = VAnchor.Center,
Margin = new BorderDouble(right: 8),
Enabled = action.IsEnabled == null || action.IsEnabled()
Enabled = action.IsEnabled == null || action.IsEnabled(),
Name = action.Title + " Button"
};
if (!string.IsNullOrEmpty(action.ID))

@ -1 +1 @@
Subproject commit ee46a80139064a3c661b25f0bc99b09b4b5ba581
Subproject commit d0ee73eb25acad88fb93259364b4ddb860385971

View file

@ -49,7 +49,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
// Shorten the delay so the test runs in a reasonable time
printer.Connection.TimeToHoldTemperature = 5;
testRunner.StartPrint();
testRunner.StartPrint(printer);
// Wait for print to finish
testRunner.WaitForPrintFinished(printer);
@ -63,7 +63,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
Assert.Less(printer.Connection.ActualBedTemperature, 10);
// Make sure we can run this whole thing again
testRunner.StartPrint();
testRunner.StartPrint(printer);
// Wait for print to finish
testRunner.WaitForPrintFinished(printer);
@ -105,7 +105,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
currentSettings.SetValue(SettingsKey.pause_gcode, "");
currentSettings.SetValue(SettingsKey.resume_gcode, "");
testRunner.StartPrint(pauseAtLayers: "2");
testRunner.StartPrint(printer, pauseAtLayers: "2");
testRunner.WaitForName("Yes Button", 20); // the yes button is 'Resume'
@ -125,7 +125,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
testRunner.Complete9StepLeveling(2);
testRunner.StartPrint(pauseAtLayers: "2");
testRunner.StartPrint(printer, pauseAtLayers: "2");
testRunner.WaitForName("Yes Button", 20); // the yes button is 'Resume'
@ -154,7 +154,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
testRunner.ClickByName("Cancel Wizard Button");
testRunner.StartPrint(pauseAtLayers: "2");
testRunner.StartPrint(printer, pauseAtLayers: "2");
testRunner.WaitForName("Yes Button", 20); // the yes button is 'Resume'
@ -291,7 +291,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
// print a part
testRunner.AddItemToBedplate();
testRunner.StartPrint(pauseAtLayers: "2;6");
testRunner.StartPrint(testRunner.FirstPrinter(), pauseAtLayers: "2;6");
// turn on line error simulation
emulator.SimulateLineErrors = true;
@ -329,7 +329,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
// print a part
testRunner.AddItemToBedplate();
testRunner.StartPrint(pauseAtLayers: "2");
testRunner.StartPrint(printer, pauseAtLayers: "2");
ProfileManager.DebugPrinterDelete = true;
// Wait for pause dialog
@ -360,7 +360,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
// print a part
testRunner.AddItemToBedplate()
.StartPrint(pauseAtLayers: "2;4;6")
.StartPrint(printer, pauseAtLayers: "2;4;6")
.ClickResumeButton(printer, true, 1) // Resume
.ClickResumeButton(printer, false, 3) // close the pause dialog pop-up do not resume
.ClickByName("Disconnect from printer button")
@ -381,33 +381,48 @@ namespace MatterHackers.MatterControl.Tests.Automation
}
[Test, Category("Emulator")]
public async Task ExtruderT1RecoveryTest()
public async Task RecoveryT1NoProbe()
{
await ExtruderT1RecoveryTest("Airwolf 3D", "HD");
}
[Test, Category("Emulator")]
public async Task RecoveryT1WithProbe()
{
await ExtruderT1RecoveryTest("Pulse", "S-500");
}
public async Task ExtruderT1RecoveryTest(string make, string model)
{
await MatterControlUtilities.RunTest((testRunner) =>
{
using (var emulator = testRunner.LaunchAndConnectToPrinterEmulator("Pulse", "S-500"))
using (var emulator = testRunner.LaunchAndConnectToPrinterEmulator(make, model))
{
Assert.AreEqual(1, ApplicationController.Instance.ActivePrinters.Count(), "One printer should exist after add");
var printer = testRunner.FirstPrinter();
printer.Settings.SetValue(SettingsKey.recover_is_enabled, "1");
printer.Settings.SetValue(SettingsKey.extruder_count, "2");
printer.Settings.SetValue(SettingsKey.has_hardware_leveling, "0");
testRunner.ChangeSettings(
new (string, string)[]
{
(SettingsKey.recover_is_enabled, "1"),
(SettingsKey.extruder_count, "2"),
(SettingsKey.has_hardware_leveling, "0"),
}, printer);
Assert.IsTrue(printer.Connection.RecoveryIsEnabled);
// print a part
testRunner.AddItemToBedplate()
.ClickByName("ItemMaterialButton")
.ClickByName("Material 2 Button");
testRunner.StartPrint(pauseAtLayers: "2;4;6");
.ClickByName("Material 2 Button")
.StartPrint(printer, pauseAtLayers: "2;3;4;5");
testRunner.ClickResumeButton(printer, true, 1); // Resume
// make sure we are printing with extruder 2 (T1)
Assert.AreEqual(0, printer.Connection.GetTargetHotendTemperature(0));
Assert.Greater(printer.Connection.GetTargetHotendTemperature(1), 0);
testRunner.ClickResumeButton(printer, false, 3) // close the pause dialog pop-up do not resume
testRunner.ClickResumeButton(printer, false, 2) // close the pause dialog pop-up do not resume
.ClickByName("Disconnect from printer button")
.ClickByName("Connect to printer button") // Reconnect
.WaitFor(() => printer.Connection.CommunicationState == CommunicationStates.Connected);
@ -418,12 +433,13 @@ namespace MatterHackers.MatterControl.Tests.Automation
// Recover the print
testRunner.ClickButton("Yes Button", "Recover Print");
testRunner.ClickResumeButton(printer, true, 5); // The first pause that we get after recovery should be layer 6.
emulator.RunSlow = true;
// The first pause that we get after recovery should be layer 4 (index 3).
testRunner.ClickResumeButton(printer, true, 3);
// make sure we are printing with extruder 2 (T1)
Assert.AreEqual(0, printer.Connection.GetTargetHotendTemperature(0));
Assert.Greater(printer.Connection.GetTargetHotendTemperature(1), 0);
emulator.RunSlow = false;
testRunner.ClickResumeButton(printer, true, 4);
testRunner.WaitForPrintFinished(printer);
}
@ -459,7 +475,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
printFinishedResetEvent.Set();
};
testRunner.StartPrint()
testRunner.StartPrint(printer)
.ScrollIntoView("Extrusion Multiplier NumberEdit")
.ScrollIntoView("Feed Rate NumberEdit");
@ -489,7 +505,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
ConfirmExpectedSpeeds(testRunner, targetExtrusionRate, targetFeedRate, "After print finished");
testRunner.WaitForPrintFinished(printer)
.StartPrint() // Restart the print
.StartPrint(printer) // Restart the print
.Delay(1);
// Values should match entered values
@ -537,7 +553,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
var printFinishedResetEvent = new AutoResetEvent(false);
printer.Connection.PrintFinished += (s, e) => printFinishedResetEvent.Set();
testRunner.StartPrint();
testRunner.StartPrint(printer);
var container = testRunner.GetWidgetByName("ManualPrinterControls.ControlsContainer", out _, 5);
@ -581,7 +597,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
testRunner.WaitForPrintFinished(printer);
// Values should match entered values
testRunner.StartPrint();
testRunner.StartPrint(printer);
testRunner.WaitFor(() => printer.Connection.CommunicationState == CommunicationStates.Printing, 15);
// Values should match entered values
@ -655,7 +671,9 @@ namespace MatterHackers.MatterControl.Tests.Automation
testRunner.AddItemToBedplate();
testRunner.StartPrint();
var printer = testRunner.FirstPrinter();
testRunner.StartPrint(printer);
int fanChangedCount = 0;
emulator.FanSpeedChanged += (s, e) =>
@ -663,8 +681,6 @@ namespace MatterHackers.MatterControl.Tests.Automation
fanChangedCount++;
};
var printer = testRunner.FirstPrinter();
emulator.WaitForLayer(printer.Settings, 2);
emulator.RunSlow = true;

View file

@ -94,7 +94,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
testRunner.ClickByName("Add to Bed Menu Item");
// start the print
testRunner.StartPrint(pauseAtLayers: "50;60");
testRunner.StartPrint(printer, pauseAtLayers: "50;60");
// Wait for pause
testRunner.WaitForName("No Button", 80); // the yes button is 'Resume'

View file

@ -52,11 +52,11 @@ namespace MatterHackers.MatterControl.Tests.Automation
using (var emulator = testRunner.LaunchAndConnectToPrinterEmulator())
{
testRunner.AddItemToBedplate();
testRunner.StartPrint(pauseAtLayers: "4;2;a;not;6");
var printer = testRunner.FirstPrinter();
testRunner.AddItemToBedplate();
testRunner.StartPrint(printer, pauseAtLayers: "4;2;a;not;6");
WaitForLayerAndResume(testRunner, printer, 2);
WaitForLayerAndResume(testRunner, printer, 4);
WaitForLayerAndResume(testRunner, printer, 6);
@ -82,7 +82,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
testRunner.AddItemToBedplate();
testRunner.StartPrint(pauseAtLayers: "2");
testRunner.StartPrint(printer, pauseAtLayers: "2");
// Wait for the Ok button
testRunner.WaitForName("Yes Button", 30);

View file

@ -114,6 +114,41 @@ namespace MatterHackers.MatterControl.Tests.Automation
testRunner.Delay(.5);
}
public static void ChangeSettings(this AutomationRunner testRunner,
IEnumerable<(string key, string value)> settings,
PrinterConfig printer)
{
bool needReload = false;
foreach (var setting in settings)
{
if (printer.Settings.GetValue(setting.key) != setting.value
&& PrinterSettings.SettingsData[setting.key].ReloadUiWhenChanged)
{
needReload = true;
break;
}
}
if (needReload)
{
testRunner.WaitForReloadAll(() =>
{
foreach (var setting in settings)
{
printer.Settings.SetValue(setting.key, setting.value);
}
});
}
else
{
foreach (var setting in settings)
{
printer.Settings.SetValue(setting.key, setting.value);
}
}
}
public static void WaitForReloadAll(this AutomationRunner testRunner, Action reloadAllAction)
{
// Wire up a block and release mechanism to wait until the sign in process has completed
@ -380,8 +415,6 @@ namespace MatterHackers.MatterControl.Tests.Automation
return widget.TreeLoaded;
});
testRunner.Delay(1000);
// Apply filter
testRunner.ClickByName("Search")
.Type(model)
@ -470,7 +503,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
{
File.WriteAllText(mcpPath, JsonConvert.SerializeObject(new ManifestFile()
{
ProjectFiles = new System.Collections.Generic.List<PrintItem>()
ProjectFiles = new List<PrintItem>()
}, Formatting.Indented));
}
@ -919,8 +952,10 @@ namespace MatterHackers.MatterControl.Tests.Automation
/// </summary>
/// <param name="testRunner">The AutomationRunner we are using.</param>
/// <param name="pauseAtLayers">The string to write into the pause field in the print menu.</param>
/// <returns></returns>
public static AutomationRunner StartPrint(this AutomationRunner testRunner, string pauseAtLayers = null)
/// <returns>The automation runner to allow fluid design</returns>
public static AutomationRunner StartPrint(this AutomationRunner testRunner,
PrinterConfig printer,
string pauseAtLayers = null)
{
// Open popup
testRunner.OpenPrintPopupMenu();
@ -935,10 +970,20 @@ namespace MatterHackers.MatterControl.Tests.Automation
if (testRunner.NameExists("SetupPrinter"))
{
testRunner.ClickByName("SetupPrinter")
.ClickByName("Already Loaded Button")
.ClickByName("Cancel Wizard Button")
.OpenPrintPopupMenu();
if (printer.Settings.GetValue<bool>(SettingsKey.use_z_probe))
{
testRunner.ClickByName("SetupPrinter")
.ClickByName("Already Loaded Button")
.ClickByName("Cancel Wizard Button")
.OpenPrintPopupMenu();
}
else
{
testRunner.ClickByName("SetupPrinter")
.ClickByName("Already Loaded Button")
.ClickByName("Cancel Wizard Button")
.OpenPrintPopupMenu();
}
}
testRunner.ClickByName("Start Print Button");