diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-02-07 15:39:12 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-02-07 15:39:12 +0200 |
| commit | bd3cb640be12621ac37253e8a8c627ae40692e4d (patch) | |
| tree | cddc36bc95b966f48e1b7387fed1955504d3975b /Software/Visual_Studio/PPC | |
| parent | 7a1f9f14cc50001366be0efefc25fd5af403d02e (diff) | |
| download | Tango-bd3cb640be12621ac37253e8a8c627ae40692e4d.tar.gz Tango-bd3cb640be12621ac37253e8a8c627ae40692e4d.zip | |
Some fixes and improvements for PPC & Machine Studio.
Diffstat (limited to 'Software/Visual_Studio/PPC')
13 files changed, 69 insertions, 93 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Tango.PPC.Events.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Tango.PPC.Events.csproj index f38fe9162..fa7583e85 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Tango.PPC.Events.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Tango.PPC.Events.csproj @@ -129,6 +129,10 @@ <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project> <Name>Tango.Core</Name> </ProjectReference> + <ProjectReference Include="..\..\..\Tango.Integration\Tango.Integration.csproj"> + <Project>{4206ac58-3b57-4699-8835-90bf6db01a61}</Project> + <Name>Tango.Integration</Name> + </ProjectReference> <ProjectReference Include="..\..\..\Tango.Logging\Tango.Logging.csproj"> <Project>{bc932dbd-7cdb-488c-99e4-f02cf441f55e}</Project> <Name>Tango.Logging</Name> @@ -145,6 +149,10 @@ <Project>{fd86424c-6e84-491b-8df9-3d0f5c236a2a}</Project> <Name>Tango.Touch</Name> </ProjectReference> + <ProjectReference Include="..\..\..\Tango.Transport\Tango.Transport.csproj"> + <Project>{74e700b0-1156-4126-be40-ee450d3c3026}</Project> + <Name>Tango.Transport</Name> + </ProjectReference> <ProjectReference Include="..\..\Tango.PPC.Common\Tango.PPC.Common.csproj"> <Project>{0be74eee-22cb-4dba-b896-793b9e1a3ac0}</Project> <Name>Tango.PPC.Common</Name> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/ViewModels/MainViewVM.cs index ed35a9b2d..9ee24ad38 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/ViewModels/MainViewVM.cs @@ -12,6 +12,7 @@ using Tango.PPC.Common.Notifications; using Tango.PPC.Common.Notifications.NotificationItems; using Tango.PPC.Events.Enumerations; using System.Data.Entity; +using Tango.Integration.Operation; namespace Tango.PPC.Events.ViewModels { @@ -98,6 +99,26 @@ namespace Tango.PPC.Events.ViewModels var last_week = DateTime.UtcNow.AddDays(-7); HistoryEvents = (await db.MachinesEvents.Where(x => x.MachineGuid == MachineProvider.Machine.Guid && x.DateTime > last_week).Include(x => x.EventType).Where(x => (EventTypeNotificationTimes)x.EventType.EventNotificationTime != EventTypeNotificationTimes.None).ToListAsync()).OrderByDescending(x => x.DateTime).ToObservableCollection(); } + + MachineProvider.MachineOperator.StatusChanged += MachineOperator_StatusChanged; + } + + private void MachineOperator_StatusChanged(object sender, MachineStatuses status) + { + if (status == MachineStatuses.Disconnected) + { + foreach (var notification in _notifications.ToList()) + { + NotificationProvider.PopNotification(notification.Value); + } + + _notifications.Clear(); + + InvokeUI(() => + { + CurrentEvents.Clear(); + }); + } } private void EventLogger_EventReceived(object sender, MachinesEvent ev) diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs index 2a0392dd6..95912e1ea 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs @@ -33,11 +33,6 @@ namespace Tango.PPC.Common.Connection private bool _isInitialized; private Thread _connection_thread; - /// <summary> - /// Occurs when current <see cref="IMachineOperator" /> has changed. - /// </summary> - public event EventHandler<MachineOperatorChangedEventArgs> MachineOperatorChanged; - private Machine _machine; /// <summary> /// Gets the database machine entity associated with the current machine. @@ -67,24 +62,12 @@ namespace Tango.PPC.Common.Connection } private set { - var oldOperator = _machineOperator; _machineOperator = value; - OnMachineOperatorChanged(oldOperator, _machineOperator); RaisePropertyChangedAuto(); } } /// <summary> - /// Called when the machine operator has been changed - /// </summary> - /// <param name="oldOperator">The old operator.</param> - /// <param name="newOperator">The new operator.</param> - protected virtual void OnMachineOperatorChanged(IMachineOperator oldOperator, IMachineOperator newOperator) - { - MachineOperatorChanged?.Invoke(this, new MachineOperatorChangedEventArgs(oldOperator, newOperator)); - } - - /// <summary> /// Initializes a new instance of the <see cref="DefaultMachineProvider"/> class. /// </summary> public DefaultMachineProvider() @@ -128,7 +111,6 @@ namespace Tango.PPC.Common.Connection MachineOperator.Adapter = response.Adapter; MachineOperator.JobHandlingMode = JobHandlerModes.SettingUp; LogManager.Log("Connecting machine operator..."); - MachineOperatorChanged?.Invoke(this, new MachineOperatorChangedEventArgs(MachineOperator, MachineOperator)); await MachineOperator.Connect(); @@ -142,7 +124,6 @@ namespace Tango.PPC.Common.Connection UsbTransportAdapter adapter = new UsbTransportAdapter(settings.EmbeddedComPort, UsbSerialBaudRates.BR_115200); MachineOperator.Adapter = adapter; MachineOperator.JobHandlingMode = JobHandlerModes.SettingUp; - MachineOperatorChanged?.Invoke(this, new MachineOperatorChangedEventArgs(MachineOperator, MachineOperator)); await MachineOperator.Connect(); await Task.Delay(1000); @@ -165,7 +146,6 @@ namespace Tango.PPC.Common.Connection MachineOperator.Adapter = adapter; MachineOperator.JobHandlingMode = JobHandlerModes.SettingUp; LogManager.Log("Connecting machine operator..."); - MachineOperatorChanged?.Invoke(this, new MachineOperatorChangedEventArgs(MachineOperator, MachineOperator)); await MachineOperator.Connect(); await Task.Delay(1000); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/IMachineProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/IMachineProvider.cs index df4a448f7..43a6c290e 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/IMachineProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/IMachineProvider.cs @@ -15,11 +15,6 @@ namespace Tango.PPC.Common.Connection public interface IMachineProvider { /// <summary> - /// Occurs when current <see cref="IMachineOperator"/> has changed. - /// </summary> - event EventHandler<MachineOperatorChangedEventArgs> MachineOperatorChanged; - - /// <summary> /// Gets the database machine entity associated with the current machine. /// </summary> Machine Machine { get; } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Diagnostics/DefaultDiagnosticsFrameProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Diagnostics/DefaultDiagnosticsFrameProvider.cs index 6ef19c765..d99047f8f 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Diagnostics/DefaultDiagnosticsFrameProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Diagnostics/DefaultDiagnosticsFrameProvider.cs @@ -45,21 +45,7 @@ namespace Tango.PPC.Common.Diagnostics public DefaultDiagnosticsFrameProvider(IMachineProvider machineProvider) { _machineProvider = machineProvider; - machineProvider.MachineOperatorChanged += MachineProvider_MachineOperatorChanged; - } - - - /// <summary> - /// Handles the Machine Provider Machine Operator Changed event. - /// </summary> - /// <param name="sender">The source of the event.</param> - /// <param name="e">The event arguments.</param> - private void MachineProvider_MachineOperatorChanged(object sender, MachineOperatorChangedEventArgs e) - { - if (e.MachineOperator != null) - { - e.MachineOperator.DiagnosticsDataAvailable += MachineOperator_DiagnosticsDataAvailable; - } + machineProvider.MachineOperator.DiagnosticsDataAvailable += MachineOperator_DiagnosticsDataAvailable; } /// <summary> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/DefaultEventLogger.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/DefaultEventLogger.cs index 8e1f7c722..d540e3fd3 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/DefaultEventLogger.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/DefaultEventLogger.cs @@ -73,7 +73,12 @@ namespace Tango.PPC.Common.EventLogging _logThread.IsBackground = true; _logThread.Start(); - _machineProvider.MachineOperatorChanged += _machineProvider_MachineOperatorChanged; + _machineProvider.MachineOperator.MachineEventsStateProvider.NewEvents += MachineEventsStateProvider_NewEvents; + _machineProvider.MachineOperator.MachineEventsStateProvider.EventsResolved += MachineEventsStateProvider_EventsResolved; + + _machineProvider.MachineOperator.RequestSent += Machine_RequestSent; + _machineProvider.MachineOperator.RequestFailed += Machine_RequestFailed; + _machineProvider.MachineOperator.ResponseReceived += Machine_ResponseReceived; } #endregion @@ -108,30 +113,6 @@ namespace Tango.PPC.Common.EventLogging #region Event Handlers - private void _machineProvider_MachineOperatorChanged(object sender, MachineOperatorChangedEventArgs e) - { - var machine = e.MachineOperator; - - if (machine != null) - { - if (machine.MachineEventsStateProvider != null) - { - machine.MachineEventsStateProvider.NewEvents -= MachineEventsStateProvider_NewEvents; - machine.MachineEventsStateProvider.NewEvents += MachineEventsStateProvider_NewEvents; - machine.MachineEventsStateProvider.EventsResolved -= MachineEventsStateProvider_EventsResolved; - machine.MachineEventsStateProvider.EventsResolved += MachineEventsStateProvider_EventsResolved; - } - - machine.RequestSent -= Machine_RequestSent; - machine.RequestFailed -= Machine_RequestFailed; - machine.ResponseReceived -= Machine_ResponseReceived; - - machine.RequestSent += Machine_RequestSent; - machine.RequestFailed += Machine_RequestFailed; - machine.ResponseReceived += Machine_ResponseReceived; - } - } - /// <summary> /// Handles the RequestSent event of the connected machine. /// </summary> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs index 23722319c..a073c1c5e 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs @@ -82,7 +82,7 @@ namespace Tango.PPC.Common.OS CmdCommand command = new CmdCommand("cscript", $"C:\\Windows\\System32\\slmgr.vbs -ipk {activationKey}"); await command.Run(); - await Task.Delay(5000); + await Task.Delay(10000); if (!await IsActivated()) { diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs index f5c6f43b9..ee1b39ca6 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs @@ -142,6 +142,13 @@ namespace Tango.PPC.UI.ViewModels set { _deploymentSlot = value; RaisePropertyChangedAuto(); } } + private MachineSetupView _currentView; + public MachineSetupView CurrentView + { + get { return _currentView; } + set { _currentView = value; RaisePropertyChangedAuto(); } + } + #endregion #region Commands @@ -284,6 +291,7 @@ namespace Tango.PPC.UI.ViewModels /// <param name="view">The view.</param> private Task NavigateTo(MachineSetupView view) { + CurrentView = view; return View.NavigateTo(view); } @@ -312,11 +320,13 @@ namespace Tango.PPC.UI.ViewModels } } - private void ConnectivityProvider_ConnectionStateChanged(object sender, Common.Connectivity.ConnectionStateEventArgs e) + private async void ConnectivityProvider_ConnectionStateChanged(object sender, Common.Connectivity.ConnectionStateEventArgs e) { if (e.IsConnected) { ConnectivityProvider.ConnectionStateChanged -= ConnectivityProvider_ConnectionStateChanged; + await NavigateTo(MachineSetupView.WiFiTestView); + await Task.Delay(5000); EnsureWiFi(); } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs index a553f3a18..07d034964 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs @@ -213,13 +213,20 @@ namespace Tango.PPC.UI.ViewModels private void CompleteUpdate() { - String updater_exe = Path.Combine(_update_result.UpdatePackagePath, "Tango.PPC.Updater.exe"); - - LogManager.Log("Completing machine setup..."); - LogManager.Log($"Executing '{updater_exe}' with arguments '{PathHelper.GetStartupPath()}'..."); - Process.Start(updater_exe, PathHelper.GetStartupPath()); - LogManager.Log("Terminating application process!"); - Environment.Exit(0); + if (!IsDbUpdate) + { + String updater_exe = Path.Combine(_update_result.UpdatePackagePath, "Tango.PPC.Updater.exe"); + LogManager.Log("Completing machine setup..."); + LogManager.Log($"Executing '{updater_exe}' with arguments '{PathHelper.GetStartupPath()}'..."); + Process.Start(updater_exe, PathHelper.GetStartupPath()); + LogManager.Log("Terminating application process!"); + Environment.Exit(0); + } + else + { + LogManager.Log("Restarting Application..."); + ApplicationManager.Restart(); + } } #endregion diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml index 0b3e0b1ee..bf3a85543 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml @@ -151,7 +151,7 @@ </Grid> <!--External Header Content Here--> - <commonControls:AsyncAdornerControl> + <!--<commonControls:AsyncAdornerControl> <commonControls:AsyncAdornerControl.Style> <Style TargetType="commonControls:AsyncAdornerControl"> <Setter Property="Visibility" Value="Hidden"></Setter> @@ -169,7 +169,7 @@ <StackPanel VerticalAlignment="Center"> <touch:TouchGifAnimation Source="/Images/preloader_rectangles.gif" EnableAnimation="{Binding NotificationProvider.IsInGlobalBusyState}" /> </StackPanel> - </commonControls:AsyncAdornerControl> + </commonControls:AsyncAdornerControl>--> </Grid> </DockPanel> </Border> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoadingView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoadingView.xaml index 895619807..57793a9b3 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoadingView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoadingView.xaml @@ -13,7 +13,7 @@ d:DesignHeight="1280" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:LoadingViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.LoadingView}"> <Grid> <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> - <Image gif:ImageBehavior.EnableAnimation="{Binding IsLoading}" gif:ImageBehavior.AnimatedSource="/Images/Twine_Loading_GIF.gif" Margin="100 100 100 0" RenderTransformOrigin="0.5,0.5" RenderOptions.BitmapScalingMode="Fant" Height="382"> + <!--<Image gif:ImageBehavior.EnableAnimation="{Binding IsLoading}" gif:ImageBehavior.AnimatedSource="/Images/Twine_Loading_GIF.gif" Margin="100 100 100 0" RenderTransformOrigin="0.5,0.5" RenderOptions.BitmapScalingMode="Fant" Height="382"> <Image.Style> <Style TargetType="Image"> <Setter Property="RenderTransform"> @@ -45,8 +45,10 @@ </Style.Triggers> </Style> </Image.Style> - </Image> + </Image>--> + <touch:TouchBusyIndicator Width="250" Margin="0 100 0 0" Height="250" IsIndeterminate="{Binding IsLoading}" /> + <TextBlock Margin="0 40 0 0" HorizontalAlignment="Center" FontSize="{StaticResource TangoTitleFontSize}" Foreground="{StaticResource TangoGrayTextBrush}"> <Run>v</Run><Run Text="{Binding ApplicationManager.Version,Mode=OneWay}"></Run> </TextBlock> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml index 13f163ef5..30b99dbbf 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml @@ -65,7 +65,7 @@ <TextBlock DockPanel.Dock="Top" Margin="20 0" FontSize="{StaticResource TangoTitleFontSize}" HorizontalAlignment="Center" TextWrapping="Wrap" TextAlignment="Center"> Checking internet connection, please wait... </TextBlock> - <touch:TouchBusyIndicator Width="250" Margin="0 100 0 0" Height="250" IsIndeterminate="True" /> + <touch:TouchBusyIndicator Width="250" Margin="0 100 0 0" Height="250" IsIndeterminate="{Binding CurrentView,Converter={StaticResource EnumToVisibilityConverter},ConverterParameter='WiFiTestView'}" /> </StackPanel> </Grid> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml index 9df92bbcc..6d1bde59d 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml @@ -91,19 +91,5 @@ <local:MachineUpdateView></local:MachineUpdateView> </controls:NavigationControl> </touch:TouchPanel> - - <!--<Grid Background="#28000000" Visibility="{Binding NotificationProvider.IsInGlobalBusyState,Converter={StaticResource BooleanToVisibilityConverter}}"/> - - <commonControls:AsyncAdornerControl HorizontalAlignment="Center" VerticalAlignment="Center" Width="600" Height="200" Visibility="Visible"> - <Grid> - <Border Background="White" CornerRadius="10"> - <Border.Effect> - <DropShadowEffect ShadowDepth="0" BlurRadius="10" /> - </Border.Effect> - - <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center">Please wait...</TextBlock> - </Border> - </Grid> - </commonControls:AsyncAdornerControl>--> </Grid> </UserControl> |
