From 8d7ace94349c473c20fa5c06431897580e45aa82 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 11 Dec 2018 10:26:41 +0200 Subject: Implemented single segment per spool on PPC! --- .../Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs') diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs index 387b3e6a0..16ffdd906 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs @@ -8,6 +8,7 @@ using Tango.Integration.Operation; using Tango.PPC.Common; using Tango.PPC.Common.Navigation; using Tango.PPC.Jobs.AppBarItems; +using Tango.PPC.Jobs.Dialogs; using Tango.PPC.Jobs.Views; namespace Tango.PPC.Jobs.ViewModels @@ -95,9 +96,30 @@ namespace Tango.PPC.Jobs.ViewModels { Job = e.Job; e.JobHandler.StatusChanged += JobHandler_StatusChanged; + e.JobHandler.SpoolChangeRequired += JobHandler_SpoolChangeRequired; e.JobHandler.Stopped += JobHandler_Stopped; } + /// + /// Handles the SpoolChangeRequired event of the JobHandler. + /// + /// The source of the event. + /// The instance containing the event data. + private void JobHandler_SpoolChangeRequired(object sender, SpoolChangeRequiredEventArgs e) + { + InvokeUI(async () => + { + if ((await NotificationProvider.ShowDialog(new SpoolChangeViewVM(e))).DialogResult) + { + e.Confirm(); + } + else + { + e.Abort(); + } + }); + } + /// /// Handles the Stopped event of the JobHandler. /// -- cgit v1.3.1 From ae1cfd30f1efbd385eac04b3d02fa1ed161058a3 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 17 Dec 2018 16:43:40 +0200 Subject: Add AppButtons to PPC. Implemented Stop & Start job app buttons! --- Software/DB/PPC/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/PPC/Tango_log.ldf | Bin 20578304 -> 20578304 bytes .../AppButtons/StartPrintingButton.cs | 26 +++++ .../AppButtons/StopPrintingButton.cs | 17 ++++ .../Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj | 4 +- .../Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs | 23 +++++ .../Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs | 14 +++ .../PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml | 8 +- .../HotSpot/DefaultHotSpotProvider.cs | 6 +- .../MachineSetup/MachineSetupManager.cs | 2 +- .../Tango.PPC.Common/Notifications/AppButton.cs | 112 +++++++++++++++++++++ .../Notifications/INotificationProvider.cs | 17 ++++ .../PPC/Tango.PPC.Common/Resources/Merged.xaml | 2 + .../PPC/Tango.PPC.Common/Tango.PPC.Common.csproj | 3 +- .../Notifications/DefaultNotificationProvider.cs | 31 ++++++ .../PPC/Tango.PPC.UI/Views/LayoutView.xaml | 16 +-- .../Converters/IsNullToVisibilityConverter.cs | 24 +++++ .../Tango.SharedUI/Tango.SharedUI.csproj | 3 +- 18 files changed, 284 insertions(+), 24 deletions(-) create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/AppButtons/StartPrintingButton.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/AppButtons/StopPrintingButton.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/AppButton.cs create mode 100644 Software/Visual_Studio/Tango.SharedUI/Converters/IsNullToVisibilityConverter.cs (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs') diff --git a/Software/DB/PPC/Tango.mdf b/Software/DB/PPC/Tango.mdf index e13855e90..1e2085c5e 100644 Binary files a/Software/DB/PPC/Tango.mdf and b/Software/DB/PPC/Tango.mdf differ diff --git a/Software/DB/PPC/Tango_log.ldf b/Software/DB/PPC/Tango_log.ldf index 0349ff6b6..ee1123fef 100644 Binary files a/Software/DB/PPC/Tango_log.ldf and b/Software/DB/PPC/Tango_log.ldf differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/AppButtons/StartPrintingButton.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/AppButtons/StartPrintingButton.cs new file mode 100644 index 000000000..8efd46e18 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/AppButtons/StartPrintingButton.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.Integration.Operation; +using Tango.PPC.Common.Notifications; + +namespace Tango.PPC.Jobs.AppButtons +{ + public class StartPrintingButton : AppButton + { + public StartPrintingButton(RelayCommand command, IMachineOperator op) : base("START DYEING", command) + { + op.StatusChanged += Op_StatusChanged; + + Op_StatusChanged(this, op.Status); + } + + private void Op_StatusChanged(object sender, MachineStatuses status) + { + IsEnabled = status == MachineStatuses.ReadyToDye; + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/AppButtons/StopPrintingButton.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/AppButtons/StopPrintingButton.cs new file mode 100644 index 000000000..8c3b444b3 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/AppButtons/StopPrintingButton.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.PPC.Common.Notifications; + +namespace Tango.PPC.Jobs.AppButtons +{ + public class StopPrintingButton : AppButton + { + public StopPrintingButton() : base("STOP DYEING", true) + { + + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj index ddd8d1c07..8021e146f 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj @@ -145,6 +145,8 @@ JobProgressAppBarItemView.xaml + + RunningJobViewer.xaml @@ -384,7 +386,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs index 16ffdd906..264f41131 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs @@ -8,6 +8,7 @@ using Tango.Integration.Operation; using Tango.PPC.Common; using Tango.PPC.Common.Navigation; using Tango.PPC.Jobs.AppBarItems; +using Tango.PPC.Jobs.AppButtons; using Tango.PPC.Jobs.Dialogs; using Tango.PPC.Jobs.Views; @@ -19,6 +20,9 @@ namespace Tango.PPC.Jobs.ViewModels /// public class JobProgressViewVM : PPCViewModel { + private StopPrintingButton _stop_job_btn; + private JobHandler _handler; + #region Properties private Job _job; @@ -43,6 +47,20 @@ namespace Tango.PPC.Jobs.ViewModels #endregion + public JobProgressViewVM() + { + _stop_job_btn = new StopPrintingButton(); + _stop_job_btn.Pressed += _stop_job_btn_Pressed; + } + + private void _stop_job_btn_Pressed() + { + if (_handler != null) + { + _handler.Cancel(); + } + } + #region Override Methods /// @@ -81,6 +99,8 @@ namespace Tango.PPC.Jobs.ViewModels { NotificationProvider.CurrentAppBarItem.Close(); } + + _stop_job_btn.Push(); } #endregion @@ -94,6 +114,7 @@ namespace Tango.PPC.Jobs.ViewModels /// The instance containing the event data. private void MachineOperator_PrintingStarted(object sender, PrintingEventArgs e) { + _handler = e.JobHandler; Job = e.Job; e.JobHandler.StatusChanged += JobHandler_StatusChanged; e.JobHandler.SpoolChangeRequired += JobHandler_SpoolChangeRequired; @@ -131,6 +152,8 @@ namespace Tango.PPC.Jobs.ViewModels { NotificationProvider.CurrentAppBarItem.Close(); } + + _stop_job_btn.Pop(); } /// diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs index 98f429889..6a05eee12 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs @@ -30,6 +30,7 @@ using Tango.PPC.Common.Models; using Tango.Logging; using Tango.PPC.Common.Messages; using Tango.BL.Builders; +using Tango.PPC.Jobs.AppButtons; namespace Tango.PPC.Jobs.ViewModels { @@ -45,6 +46,7 @@ namespace Tango.PPC.Jobs.ViewModels private Job _job_to_load; private JobNavigationIntent _job_to_load_intent; private static Dictionary> _jobs_fine_tune_items; + private StartPrintingButton _start_printing_btn; #region Properties @@ -458,6 +460,8 @@ namespace Tango.PPC.Jobs.ViewModels LogManager.Log("Directing view to display fine tuning region."); View.DisplayFineTuning(); } + + DyeCommand.RaiseCanExecuteChanged(); } catch (Exception ex) { @@ -1017,6 +1021,8 @@ namespace Tango.PPC.Jobs.ViewModels /// public override void OnNavigatedTo() { + _start_printing_btn.Push(); + base.OnNavigatedTo(); LoadJob(); } @@ -1026,6 +1032,8 @@ namespace Tango.PPC.Jobs.ViewModels /// public override void OnNavigatedFrom() { + _start_printing_btn.Pop(); + base.OnNavigatedFrom(); _job_to_load_intent = JobNavigationIntent.Default; } @@ -1055,6 +1063,12 @@ namespace Tango.PPC.Jobs.ViewModels return result; } + public override void OnApplicationReady() + { + base.OnApplicationReady(); + + _start_printing_btn = new StartPrintingButton(DyeCommand, MachineProvider.MachineOperator); + } #endregion #region INavigationObjectReceiver diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml index ada22ce5a..9fb7ff5c0 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml @@ -1029,18 +1029,18 @@ - + - + --> + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/HotSpot/DefaultHotSpotProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/HotSpot/DefaultHotSpotProvider.cs index 1126a84bc..5a6b2405c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/HotSpot/DefaultHotSpotProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/HotSpot/DefaultHotSpotProvider.cs @@ -77,8 +77,12 @@ namespace Tango.PPC.Common.HotSpot { try { - CmdCommand command = new CmdCommand("netsh", $"wlan set hostednetwork mode=allow ssid='{"Tango_" + _machineProvider.Machine.SerialNumber}' key='{password}'"); + CmdCommand command = new CmdCommand("netsh", $"wlan set hostednetwork mode=allow ssid='{"Tango-" + _machineProvider.Machine.SerialNumber}' key='{password}'"); await command.Run(); + + command = new CmdCommand("netsh", "wlan start hosted network"); + await command.Run(); + IsEnabled = true; } catch (Exception ex) diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs index ead508488..31e3290d8 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs @@ -136,7 +136,7 @@ namespace Tango.PPC.Common.MachineSetup LogManager.Log("Installing remote assistance..."); UpdateProgress("Installing remote assistance", "Installing..."); - await _remoteAssistance.InstallRemoteAssistance(); + //await _remoteAssistance.InstallRemoteAssistance(); //Create temporary folders for packages. var _newPackageTempFolder = TemporaryManager.CreateFolder(); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/AppButton.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/AppButton.cs new file mode 100644 index 000000000..d5d6a0891 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/AppButton.cs @@ -0,0 +1,112 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; +using Tango.Core.Commands; +using Tango.Core.DI; + +namespace Tango.PPC.Common.Notifications +{ + /// + /// Represents an app button that will be displayed in the layout view. + /// + /// + public abstract class AppButton : ExtendedObject + { + /// + /// Occurs when the button has been pressed. + /// + public event Action Pressed; + + private String _text; + /// + /// Gets or sets the text. + /// + public String Text + { + get { return _text; } + set { _text = value; RaisePropertyChangedAuto(); } + } + + private bool _isEnabled; + /// + /// Gets or sets a value indicating whether this instance is enabled. + /// + public bool IsEnabled + { + get { return _isEnabled; } + set { _isEnabled = value; RaisePropertyChangedAuto(); } + } + + private RelayCommand _command; + /// + /// Gets or sets the command. + /// + public RelayCommand Command + { + get { return _command; } + set { _command = value; RaisePropertyChangedAuto(); } + } + + /// + /// Initializes a new instance of the class. + /// + public AppButton() + { + + } + + /// + /// Initializes a new instance of the class. + /// + /// The text. + /// if set to true [is enabled]. + /// The on execute. + /// The can execute. + public AppButton(String text, bool isEnabled) : this() + { + Text = text; + IsEnabled = isEnabled; + Command = new RelayCommand(() => + { + Pressed?.Invoke(); + }); + } + + /// + /// Initializes a new instance of the class. + /// + /// The text. + /// The command. + public AppButton(String text, RelayCommand command) : this(text, true) + { + Command = command; + } + + /// + /// Invalidates the button state. + /// + public void RaiseCanExecute() + { + Command.RaiseCanExecuteChanged(); + } + + /// + /// Pops this instance. + /// + public void Pop() + { + TangoIOC.Default.GetInstance().PopAppButton(this); + } + + /// + /// Pushes this instance. + /// + public void Push() + { + TangoIOC.Default.GetInstance().PushAppButton(this); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/INotificationProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/INotificationProvider.cs index c43e96b10..c4e82b7d2 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/INotificationProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/INotificationProvider.cs @@ -57,6 +57,11 @@ namespace Tango.PPC.Common.Notifications /// FrameworkElement CurrentDialog { get; } + /// + /// Gets the current app button. + /// + AppButton CurrentAppButton { get; } + /// /// Gets a value indicating whether this instance has a dialog. /// @@ -203,5 +208,17 @@ namespace Tango.PPC.Common.Notifications /// Gets or sets a value indicating whether to allow notifications visibility. /// bool NotificationsVisible { get; set; } + + /// + /// Pushes the app button. + /// + /// The app button. + void PushAppButton(AppButton appButton); + + /// + /// Pops the app button. + /// + /// The app button. + void PopAppButton(AppButton appButton); } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml index 01d69ecc9..266bef3eb 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml @@ -44,6 +44,8 @@ + + - - - STOP - - + diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/IsNullToVisibilityConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/IsNullToVisibilityConverter.cs new file mode 100644 index 000000000..4ce6d2f36 --- /dev/null +++ b/Software/Visual_Studio/Tango.SharedUI/Converters/IsNullToVisibilityConverter.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Data; + +namespace Tango.SharedUI.Converters +{ + public class IsNullToVisibilityConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return value != null ? Visibility.Visible : Visibility.Collapsed; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj b/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj index 04147e866..65aaf2a6f 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj +++ b/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj @@ -102,6 +102,7 @@ + @@ -231,7 +232,7 @@ - + \ No newline at end of file -- cgit v1.3.1