public async Task PrinterRecoveryTest() { await MatterControlUtilities.RunTest((testRunner) => { using (var emulator = testRunner.LaunchAndConnectToPrinterEmulator()) { 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.has_hardware_leveling, "0"); Assert.IsTrue(printer.Connection.RecoveryIsEnabled); // print a part testRunner.AddItemToBedplate() .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") .ClickByName("Connect to printer button") // Reconnect .WaitFor(() => printer.Connection.CommunicationState == CommunicationStates.Connected); // Assert that recovery happens Assert.IsTrue(PrintRecovery.RecoveryAvailable(printer), "Recovery should be enabled after Disconnect while printing"); // Recover the print testRunner.ClickButton("Yes Button", "Recover Print") .ClickResumeButton(printer, true, 5) // The first pause that we get after recovery should be layer 6. .WaitForPrintFinished(printer); } return(Task.CompletedTask); }, maxTimeToRun : 180); }
private void CheckForPrintRecovery(object s, EventArgs e) { UiThread.RunOnIdle(() => { PrintRecovery.CheckIfNeedToRecoverPrint(printer); }); }
public async Task PrinterRecoveryTest() { await MatterControlUtilities.RunTest((testRunner) => { using (var emulator = testRunner.LaunchAndConnectToPrinterEmulator()) { 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.has_hardware_leveling, "0"); // TODO: Delay needed to work around timing issue in MatterHackers/MCCentral#2415 testRunner.Delay(1); Assert.IsTrue(printer.Connection.RecoveryIsEnabled); // print a part testRunner.AddItemToBedplate(); testRunner.StartPrint(pauseAtLayers: "2;4;6"); // Wait for pause dialog testRunner.WaitForName("Yes Button", 15); // the yes button is 'Resume' // validate the current layer Assert.AreEqual(1, printer.Connection.CurrentlyPrintingLayer); // Resume testRunner.ClickByName("Yes Button"); // the printer is now paused // close the pause dialog pop-up do not resume ClickDialogButton(testRunner, printer, "No Button", 3); // Disconnect testRunner.ClickByName("Disconnect from printer button"); // Reconnect testRunner.WaitForName("Connect to printer button", 10); testRunner.ClickByName("Connect to printer button"); testRunner.WaitFor(() => printer.Connection.CommunicationState == CommunicationStates.Connected); // Assert that recovery happens Assert.IsTrue(PrintRecovery.RecoveryAvailable(printer), "Recovery should be enabled after Disconnect while printing"); // Recover the print ClickDialogButton(testRunner, printer, "Yes Button", -1); // The first pause that we get after recovery should be layer 6. // wait for the pause and continue ClickDialogButton(testRunner, printer, "Yes Button", 5); // Wait for done testRunner.WaitForPrintFinished(printer); } return(Task.CompletedTask); }, maxTimeToRun : 180); }
private void ConnectionSucceeded(object s, EventArgs e) { UiThread.RunOnIdle(() => { PrintRecovery.CheckIfNeedToRecoverPrint(printer); }); }
public PrinterActionsBar(PrinterConfig printer, PrinterTabPage printerTabPage, ThemeConfig theme) : base(theme) { this.printer = printer; this.printerTabPage = printerTabPage; this.HAnchor = HAnchor.Stretch; this.VAnchor = VAnchor.Fit; var defaultMargin = theme.ButtonSpacing; // add the reset button first (if there is one) if (printer.Settings.GetValue <bool>(SettingsKey.show_reset_connection)) { var resetConnectionButton = new TextIconButton( "Reset".Localize(), AggContext.StaticData.LoadIcon("e_stop.png", 14, 14, theme.InvertIcons), theme) { ToolTipText = "Reboots the firmware on the controller".Localize(), Margin = defaultMargin }; resetConnectionButton.Click += (s, e) => { UiThread.RunOnIdle(printer.Connection.RebootBoard); }; this.AddChild(resetConnectionButton); } this.AddChild(new PrinterConnectButton(printer, theme)); this.AddChild(new PrintButton(printer, theme)); this.AddChild(new SliceButton(printer, printerTabPage, theme) { Name = "Generate Gcode Button", Margin = theme.ButtonSpacing, }); // Add vertical separator this.AddChild(new ToolbarSeparator(theme) { VAnchor = VAnchor.Absolute, Height = theme.ButtonHeight, }); var buttonGroupB = new ObservableCollection <GuiWidget>(); var iconPath = Path.Combine("ViewTransformControls", "model.png"); modelViewButton = new RadioIconButton(AggContext.StaticData.LoadIcon(iconPath, 16, 16, theme.InvertIcons), theme) { SiblingRadioButtonList = buttonGroupB, Name = "Model View Button", Checked = printer?.ViewState.ViewMode == PartViewMode.Model || printer == null, ToolTipText = "Model View".Localize(), Margin = theme.ButtonSpacing }; modelViewButton.Click += SwitchModes_Click; buttonGroupB.Add(modelViewButton); AddChild(modelViewButton); iconPath = Path.Combine("ViewTransformControls", "gcode_3d.png"); layers3DButton = new RadioIconButton(AggContext.StaticData.LoadIcon(iconPath, 16, 16, theme.InvertIcons), theme) { SiblingRadioButtonList = buttonGroupB, Name = "Layers3D Button", Checked = printer?.ViewState.ViewMode == PartViewMode.Layers3D, ToolTipText = "3D Layer View".Localize(), Margin = theme.ButtonSpacing }; layers3DButton.Click += SwitchModes_Click; buttonGroupB.Add(layers3DButton); if (!UserSettings.Instance.IsTouchScreen) { this.AddChild(layers3DButton); } iconPath = Path.Combine("ViewTransformControls", "gcode_2d.png"); layers2DButton = new RadioIconButton(AggContext.StaticData.LoadIcon(iconPath, 16, 16, theme.InvertIcons), theme) { SiblingRadioButtonList = buttonGroupB, Name = "Layers2D Button", Checked = printer?.ViewState.ViewMode == PartViewMode.Layers2D, ToolTipText = "2D Layer View".Localize(), Margin = theme.ButtonSpacing, }; layers2DButton.Click += SwitchModes_Click; buttonGroupB.Add(layers2DButton); this.AddChild(layers2DButton); this.AddChild(new HorizontalSpacer()); bool shareTemp = printer.Settings.GetValue <bool>(SettingsKey.extruders_share_temperature); int extruderCount = shareTemp ? 1 : printer.Settings.GetValue <int>(SettingsKey.extruder_count); if (!printer.Settings.GetValue <bool>(SettingsKey.sla_printer)) { for (int extruderIndex = 0; extruderIndex < extruderCount; extruderIndex++) { this.AddChild(new TemperatureWidgetHotend(printer, extruderIndex, theme) { Margin = new BorderDouble(right: 10) }); } } if (printer.Settings.GetValue <bool>(SettingsKey.has_heated_bed)) { this.AddChild(new TemperatureWidgetBed(printer, theme)); } this.OverflowButton.Name = "Printer Overflow Menu"; this.ExtendOverflowMenu = (popupMenu) => { this.GeneratePrinterOverflowMenu(popupMenu, ApplicationController.Instance.MenuTheme); }; printer.ViewState.ViewModeChanged += (s, e) => { RadioIconButton activeButton = null; if (e.ViewMode == PartViewMode.Layers2D) { activeButton = layers2DButton; } else if (e.ViewMode == PartViewMode.Layers3D) { activeButton = layers3DButton; } else { activeButton = modelViewButton; } if (activeButton != null) { activeButton.Checked = true; if (!buttonIsBeingClicked) { activeButton.FlashBackground(theme.Colors.PrimaryAccentColor.WithContrast(theme.Colors.PrimaryTextColor, 6).ToColor()); } } }; printer.Connection.ConnectionSucceeded.RegisterEvent((s, e) => { UiThread.RunOnIdle(() => { PrintRecovery.CheckIfNeedToRecoverPrint(printer); }); }, ref unregisterEvents); }