From 7bb3b342d90074c3f3c697b71492708ea38b81fd Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Wed, 28 Dec 2016 13:10:39 -0800 Subject: [PATCH] Made firmware updater report state into terminal Refactoring Firmware update strings --- .../PrinterSettings/PrinterSettingsView.cs | 18 ++++------ .../PrinterConnectionAndCommunication.cs | 12 ++----- .../TerminalWindow/PrinterOutputCache.cs | 7 ++++ StaticData/Translations/Master.txt | 33 +++++++++++++++++++ Submodules/MatterSlice | 2 +- Submodules/agg-sharp | 2 +- 6 files changed, 51 insertions(+), 23 deletions(-) diff --git a/ConfigurationPage/PrinterSettings/PrinterSettingsView.cs b/ConfigurationPage/PrinterSettings/PrinterSettingsView.cs index 29d6ab7df..ace9cf560 100644 --- a/ConfigurationPage/PrinterSettings/PrinterSettingsView.cs +++ b/ConfigurationPage/PrinterSettings/PrinterSettingsView.cs @@ -49,11 +49,9 @@ namespace MatterHackers.MatterControl.ConfigurationPage AddChild(mainContainer); AddHandlers(); - SetVisibleControls(); + SetEnabledStates(); } - private TextWidget printLevelingStatusLabel; - public override void OnClosed(EventArgs e) { unregisterEvents?.Invoke(this, null); @@ -187,8 +185,8 @@ namespace MatterHackers.MatterControl.ConfigurationPage private void AddHandlers() { - PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents); - PrinterConnectionAndCommunication.Instance.EnableChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents); + PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent((e, s) => SetEnabledStates(), ref unregisterEvents); + PrinterConnectionAndCommunication.Instance.EnableChanged.RegisterEvent((e,s) => SetEnabledStates(), ref unregisterEvents); } private void openCameraPreview_Click(object sender, EventArgs e) @@ -249,13 +247,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage UiThread.RunOnIdle(TerminalWindow.Show); } - private void onPrinterStatusChanged(object sender, EventArgs e) - { - SetVisibleControls(); - this.Invalidate(); - } - - private void SetVisibleControls() + private void SetEnabledStates() { if (!ActiveSliceSettings.Instance.PrinterSelected) { @@ -315,6 +307,8 @@ namespace MatterHackers.MatterControl.ConfigurationPage throw new NotImplementedException(); } } + + this.Invalidate(); } } } \ No newline at end of file diff --git a/PrinterCommunication/PrinterConnectionAndCommunication.cs b/PrinterCommunication/PrinterConnectionAndCommunication.cs index 490b0a40e..846e96c19 100644 --- a/PrinterCommunication/PrinterConnectionAndCommunication.cs +++ b/PrinterCommunication/PrinterConnectionAndCommunication.cs @@ -161,8 +161,6 @@ namespace MatterHackers.MatterControl.PrinterCommunication private bool firmwareUriGcodeSend = false; - private string firmwareVersion; - private int currentLineIndexToSend = 0; private bool ForceImmediateWrites = false; @@ -659,10 +657,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication get { return firmwareType; } } - public string FirmwareVersion - { - get { return firmwareVersion; } - } + public string FirmwareVersion { get; private set; } public Vector3 LastReportedPosition { get { return lastReportedPosition.position; } } @@ -1072,7 +1067,6 @@ namespace MatterHackers.MatterControl.PrinterCommunication //Attempt connecting to a specific printer this.stopTryingToConnect = false; firmwareType = FirmwareTypes.Unknown; - firmwareVersion = null; firmwareUriGcodeSend = false; // On Android, there will never be more than one serial port available for us to connect to. Override the current .ComPort value to account for @@ -1565,9 +1559,9 @@ namespace MatterHackers.MatterControl.PrinterCommunication } //Firmware version was detected and is different - if (firmwareVersionReported != "" && firmwareVersion != firmwareVersionReported) + if (firmwareVersionReported != "" && FirmwareVersion != firmwareVersionReported) { - firmwareVersion = firmwareVersionReported; + FirmwareVersion = firmwareVersionReported; OnFirmwareVersionRead(null); } } diff --git a/PrinterControls/TerminalWindow/PrinterOutputCache.cs b/PrinterControls/TerminalWindow/PrinterOutputCache.cs index a0593eb8e..f650f85ec 100644 --- a/PrinterControls/TerminalWindow/PrinterOutputCache.cs +++ b/PrinterControls/TerminalWindow/PrinterOutputCache.cs @@ -106,6 +106,13 @@ namespace MatterHackers.MatterControl OnHasChanged(eventArgs); } + public void WriteLine(string line) + { + StringEventArgs eventArgs = new StringEventArgs(line); + PrinterLines.Add(eventArgs.Data); + OnHasChanged(eventArgs); + } + private void Instance_ConnectionFailed(object sender, EventArgs e) { OnHasChanged(null); diff --git a/StaticData/Translations/Master.txt b/StaticData/Translations/Master.txt index 1b22071e1..818cb8470 100644 --- a/StaticData/Translations/Master.txt +++ b/StaticData/Translations/Master.txt @@ -5698,3 +5698,36 @@ Translated:Sync Dashboard English:SD Card Translated:SD Card +English:MatterControl: Select Firmware File +Translated:MatterControl: Select Firmware File + +English:Starting firmware update... +Translated:Starting firmware update... + +English:Disconnecting from printer... +Translated:Disconnecting from printer... + +English:Initializing hardware... +Translated:Initializing hardware... + +English:Creating firmware backup... +Translated:Creating firmware backup... + +English:Update In Progress: {0} +Translated:Update In Progress: {0} + +English:Updating firmware... +Translated:Updating firmware... + +English:Firmware updated successfully. Please reconnect. +Translated:Firmware updated successfully. Please reconnect. + +English:The 'Serial Port' section lists all available serial\nports on your device. Changing which USB port the printer\nis conneted to may change the associated serial port.\n\nTip: If you are uncertain, unplug/plug in your printer\nand hit refresh. The new port that appears should be\nyour printer. +Translated:The 'Serial Port' section lists all available serial\nports on your device. Changing which USB port the printer\nis conneted to may change the associated serial port.\n\nTip: If you are uncertain, unplug/plug in your printer\nand hit refresh. The new port that appears should be\nyour printer. + +English:Reverting firmware to previous version... +Translated:Reverting firmware to previous version... + +English:Firmware restored successfully. Please reconnect. +Translated:Firmware restored successfully. Please reconnect. + diff --git a/Submodules/MatterSlice b/Submodules/MatterSlice index b4928e907..98818bfa4 160000 --- a/Submodules/MatterSlice +++ b/Submodules/MatterSlice @@ -1 +1 @@ -Subproject commit b4928e90793fc2f5bad70aff15ca5dee0f6e55e7 +Subproject commit 98818bfa46d8efef422c20b04bfbe80bff997553 diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index a91d41b90..0184b613a 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit a91d41b90a13fa7b86fcb8fb9a2b1e6231b0e35f +Subproject commit 0184b613a0c9b3306393090353dee8101199e5ce