diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2020-01-12 15:56:50 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2020-01-12 15:56:50 +0200 |
| commit | 9949e351e152a929da696ef2f0a1f8b1668e83fa (patch) | |
| tree | 40212bc488ea64cbaf137455c6a2280333c997dc | |
| parent | 9016d57f876a70952dda4419d68b568b586ef0ec (diff) | |
| download | Tango-9949e351e152a929da696ef2f0a1f8b1668e83fa.tar.gz Tango-9949e351e152a929da696ef2f0a1f8b1668e83fa.zip | |
Merged Beta+ fixes to master.
18 files changed, 266 insertions, 63 deletions
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 1de54b784..a2f67b2ba 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 @@ -178,6 +178,7 @@ namespace Tango.PPC.Jobs.ViewModels { if (_handler != null) { + _stop_job_btn.Pop(); _handler.Cancel(); } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobProgressView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobProgressView.xaml index 2a21f772e..6bc1337b9 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobProgressView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobProgressView.xaml @@ -38,6 +38,8 @@ <Setter Property="Visibility" Value="Visible"></Setter> </DataTrigger> <DataTrigger Binding="{Binding RunningJobStatus.IsCompleted}" Value="True"> + <Setter Property="Maximum" Value="100"></Setter> + <Setter Property="Value" Value="99.9999999"></Setter> <Setter Property="Foreground" Value="{StaticResource TangoSuccessBrush}"></Setter> </DataTrigger> <DataTrigger Binding="{Binding RunningJobStatus.IsCanceled}" Value="True"> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/SystemViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/SystemViewVM.cs index 13aeeb671..f3ffcda14 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/SystemViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/SystemViewVM.cs @@ -265,7 +265,7 @@ namespace Tango.PPC.Technician.ViewModels { using (ObservablesContext db = ObservablesContext.CreateDefault()) { - var jobRuns = await db.JobRuns.Where(x => x.MachineGuid == MachineProvider.Machine.Guid).ToListAsync(); + var jobRuns = await db.JobRuns.ToListAsync(); TotalDyeTime = TimeSpan.FromHours(jobRuns.Select(x => x.EndDate - x.StartDate).Sum(x => x.TotalHours)).ToString(@"hh\:mm\:ss"); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs index b90a1afff..dec58f336 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs @@ -61,6 +61,12 @@ namespace Tango.PPC.UI has_touch = true; } } + +#if !DEBUG + ForceTouch(); + has_touch = true; +#endif + #endif if (!has_touch) @@ -72,7 +78,7 @@ namespace Tango.PPC.UI gridMain.Height = 1280; viewBox.Child = gridMain; LockAspectRatio(); - this.SizeChanged += (x, y) => + this.SizeChanged += (x, y) => { LockAspectRatio(); }; @@ -81,6 +87,18 @@ namespace Tango.PPC.UI Closing += MainWindow_Closing; } + private void ForceTouch() + { + WindowStyle = WindowStyle.None; + ResizeMode = ResizeMode.NoResize; + WindowStartupLocation = WindowStartupLocation.Manual; + Topmost = false; // sure? + Left = 0; + Top = 0; + Width = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width; + Height = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height; + } + protected override void OnSourceInitialized(EventArgs e) { //var hwndSource = PresentationSource.FromVisual(this) as HwndSource; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs index d7717e6db..2bb4e9286 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs @@ -23,6 +23,7 @@ namespace Tango.PPC.UI.ViewModels public class LayoutViewVM : PPCViewModel<ILayoutView> { private JobHandler _jobHandler; + private bool _resettingDevice; /// <summary> /// Gets or sets the module loader. @@ -127,6 +128,11 @@ namespace Tango.PPC.UI.ViewModels /// </summary> public RelayCommand PowerOffCommand { get; set; } + /// <summary> + /// Gets or sets the reset command. + /// </summary> + public RelayCommand ResetCommand { get; set; } + #endregion #region Constructors @@ -152,7 +158,8 @@ namespace Tango.PPC.UI.ViewModels PowerCommand = new RelayCommand(() => IsPowerOpened = true); RestartApplicationCommand = new RelayCommand(RestartApplication); - PowerOffCommand = new RelayCommand(PowerOffMachine); + PowerOffCommand = new RelayCommand(PowerOffMachine, () => MachineProvider.MachineOperator.Status != MachineStatuses.Disconnected); + ResetCommand = new RelayCommand(ResetMachine, () => MachineProvider.MachineOperator.Status != MachineStatuses.Disconnected); } #endregion @@ -252,6 +259,7 @@ namespace Tango.PPC.UI.ViewModels private async void PowerOffMachine() { IsMenuOpened = false; + if (await NotificationProvider.ShowQuestion("Are you sure you wish to turn off the machine?")) { try @@ -261,10 +269,38 @@ namespace Tango.PPC.UI.ViewModels catch (Exception ex) { LogManager.Log(ex, "Error triggering power down."); + await NotificationProvider.ShowError(ex.FlattenMessage()); } } } + /// <summary> + /// Resets the machine. + /// </summary> + private async void ResetMachine() + { + IsMenuOpened = false; + + if (!await NotificationProvider.ShowQuestion("Are you sure you want to reset the machine?")) return; + + try + { + _resettingDevice = true; + ResetCommand.RaiseCanExecuteChanged(); + await MachineProvider.MachineOperator.Reset(); + await NotificationProvider.ShowInfo("Machine was successfully restarted."); + } + catch (Exception ex) + { + await NotificationProvider.ShowError(ex.FlattenMessage()); + } + finally + { + _resettingDevice = false; + ResetCommand.RaiseCanExecuteChanged(); + } + } + #endregion #region Override Methods @@ -286,6 +322,21 @@ namespace Tango.PPC.UI.ViewModels } + public override void OnApplicationReady() + { + base.OnApplicationReady(); + MachineProvider.MachineOperator.StatusChanged += MachineOperator_StatusChanged; + } + + private void MachineOperator_StatusChanged(object sender, MachineStatuses e) + { + InvokeUI(() => + { + PowerOffCommand.RaiseCanExecuteChanged(); + ResetCommand.RaiseCanExecuteChanged(); + }); + } + #endregion #region Public Methods 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 b4f93fd0a..1700749c2 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml @@ -130,6 +130,21 @@ <Border Background="{StaticResource TangoPowerMenuOpenedBackgroundBrush}" Height="350" Padding="20" RenderTransformOrigin="0.5,1" VerticalAlignment="Bottom"> + <Border.Resources> + <Style x:Key="PowerButton" TargetType="touch:TouchButton" BasedOn="{StaticResource TangoLinkButton}"> + <Setter Property="Foreground" Value="{StaticResource TangoPrimaryBackgroundBrush}"></Setter> + <Setter Property="FontSize" Value="{StaticResource TangoTitleFontSize}"></Setter> + <Setter Property="HorizontalAlignment" Value="Left"></Setter> + <Setter Property="VerticalAlignment" Value="Center"></Setter> + <Setter Property="Padding" Value="50 20"></Setter> + <Setter Property="Height" Value="Auto"></Setter> + <Style.Triggers> + <Trigger Property="IsEnabled" Value="False"> + <Setter Property="Foreground" Value="{StaticResource TangoGrayBrush}"></Setter> + </Trigger> + </Style.Triggers> + </Style> + </Border.Resources> <Border.Style> <Style TargetType="Border"> <Setter Property="RenderTransform"> @@ -159,7 +174,7 @@ </Border.Style> <Grid> <Grid.RowDefinitions> - <RowDefinition Height="1*"/> + <RowDefinition Height="1.4*"/> <RowDefinition Height="1*"/> </Grid.RowDefinitions> @@ -171,9 +186,10 @@ <Image Source="/Images/power-machine.png" Margin="30" /> - <UniformGrid Grid.Column="1" Rows="2"> - <touch:TouchButton HorizontalAlignment="Left" VerticalAlignment="Center" Padding="50 20" Height="Auto" Style="{StaticResource TangoLinkButton}" FontSize="{StaticResource TangoTitleFontSize}" Foreground="{StaticResource TangoPrimaryBackgroundBrush}" Command="{Binding PowerOffCommand}" >Turn Off</touch:TouchButton> - <touch:TouchButton HorizontalAlignment="Left" VerticalAlignment="Center" Padding="50 20" Height="Auto" Style="{StaticResource TangoLinkButton}" FontSize="{StaticResource TangoTitleFontSize}" Foreground="{StaticResource TangoPrimaryBackgroundBrush}">Stand By</touch:TouchButton> + <UniformGrid Grid.Column="1" Rows="3"> + <touch:TouchButton Style="{StaticResource PowerButton}" Command="{Binding PowerOffCommand}">Turn Off</touch:TouchButton> + <touch:TouchButton Style="{StaticResource PowerButton}">Stand By</touch:TouchButton> + <touch:TouchButton Style="{StaticResource PowerButton}" Command="{Binding ResetCommand}">Reset</touch:TouchButton> </UniformGrid> </Grid> @@ -186,7 +202,7 @@ </Grid.ColumnDefinitions> <Image Source="/Images/power-tablet.png" Margin="30" /> - <touch:TouchButton Command="{Binding RestartApplicationCommand}" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center" Padding="50 20" Height="Auto" Style="{StaticResource TangoLinkButton}" Foreground="{StaticResource TangoPrimaryBackgroundBrush}" FontSize="{StaticResource TangoTitleFontSize}">Restart</touch:TouchButton> + <touch:TouchButton Command="{Binding RestartApplicationCommand}" Grid.Column="1" Style="{StaticResource PowerButton}">Restart</touch:TouchButton> </Grid> </Grid> </Border> diff --git a/Software/Visual_Studio/Tango.AdvancedInstaller/InstallerBuilder.cs b/Software/Visual_Studio/Tango.AdvancedInstaller/InstallerBuilder.cs index ed52aeb05..2beb849ea 100644 --- a/Software/Visual_Studio/Tango.AdvancedInstaller/InstallerBuilder.cs +++ b/Software/Visual_Studio/Tango.AdvancedInstaller/InstallerBuilder.cs @@ -1,7 +1,9 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; +using System.Text.RegularExpressions; using System.Threading.Tasks; using Tango.Core.Components; @@ -9,13 +11,32 @@ namespace Tango.AdvancedInstaller { public class InstallerBuilder { + private const string ADVANCED_INSTALLER_BASE_FOLDER = @"C:\Program Files (x86)\Caphyon"; + public String AdvancedInstallerPath { get; set; } public String ProjectFile { get; private set; } private InstallerBuilder() { - AdvancedInstallerPath = @"C:\Program Files (x86)\Caphyon\Advanced Installer 15.6\bin\x86\AdvancedInstaller.com"; + double latestVersion = 0.0; + + //Extract the latest advanced installer version... + foreach (var folder in Directory.GetDirectories(ADVANCED_INSTALLER_BASE_FOLDER)) + { + try + { + var versionString = Regex.Match(Path.GetFileName(folder), @"\d+\.*\d+").Value; + double version = double.Parse(versionString); + if (version > latestVersion) + { + latestVersion = version; + } + } + catch { } + } + + AdvancedInstallerPath = $@"{ADVANCED_INSTALLER_BASE_FOLDER}\Advanced Installer {latestVersion}\bin\x86\AdvancedInstaller.com"; } public InstallerBuilder(String projectFile) : this() @@ -72,7 +93,7 @@ namespace Tango.AdvancedInstaller public Task Uninstall() { - return Task.Factory.StartNew(() => + return Task.Factory.StartNew(() => { String productName = GetProperty(ProjectProperty.ProductName).Result; CmdCommand command = new CmdCommand("wmic", $"product where name=\"{productName}\" call uninstall /nointeractive"); @@ -83,7 +104,7 @@ namespace Tango.AdvancedInstaller public Task<bool> IsInstalled() { - return Task.Factory.StartNew<bool>(() => + return Task.Factory.StartNew<bool>(() => { String productName = GetProperty(ProjectProperty.ProductName).Result; CmdCommand command = new CmdCommand("wmic", $"product get name"); diff --git a/Software/Visual_Studio/Tango.BL/Entities/Job.cs b/Software/Visual_Studio/Tango.BL/Entities/Job.cs index 1a5883557..28dd0a0e9 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/Job.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/Job.cs @@ -80,7 +80,7 @@ namespace Tango.BL.Entities get { _lastLength = GetLength(); - var l = _lastLength * NumberOfUnits; + var l = _lastLength * Math.Max(NumberOfUnits, 1); if (EnableInterSegment && NumberOfUnits > 1) { diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeTcpClient.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeTcpClient.cs index d3344aa16..ca019affe 100644 --- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeTcpClient.cs +++ b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeTcpClient.cs @@ -133,7 +133,8 @@ namespace Tango.Integration.ExternalBridge OnEnableEventsNotification(EnableEventsNotification); OnEnableApplicationLogsChanged(EnableApplicationLogs); OnEnableMachineStatusUpdatesChanged(EnableMachineStatusUpdates); - OnEnableAutomaticThreadLoadingChanged(EnableAutomaticThreadLoading); + //TODO: Uncomment this only when Machine Studio enables automatic thread loading (ExternalBridgeTCPClient). + //OnEnableAutomaticThreadLoadingChanged(EnableAutomaticThreadLoading); } } diff --git a/Software/Visual_Studio/Tango.Integration/Operation/JobHandler.cs b/Software/Visual_Studio/Tango.Integration/Operation/JobHandler.cs index 7b3ed0612..d4a16a7e3 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/JobHandler.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/JobHandler.cs @@ -240,6 +240,12 @@ namespace Tango.Integration.Operation /// </summary> internal void RaiseCompleted() { + InvalidateJobProgress(new JobStatus() + { + Progress = Status.TotalProgress, + CurrentSegmentIndex = 0, + }); + LogManager.Log($"Job completed at position {Status.Progress}/{Status.TotalProgress}..."); Status.Segments.Last().Completed = true; Status.RemainingUnits = 0; @@ -284,14 +290,17 @@ namespace Tango.Integration.Operation { bool invalidProgress = false; - if (s.Progress <= PROGRESS_REPORT_RANGE_METERS || s.Progress >= Status.TotalProgress - PROGRESS_REPORT_RANGE_METERS) - { - LogManager.Log($"Updating job progress {s.Progress}/{Status.TotalProgress}..."); - } - else if (!loggedContinueMessage) + if (_last_progress != s.Progress) { - loggedContinueMessage = true; - LogManager.Log($"Progress logging will continue {PROGRESS_REPORT_RANGE_METERS} meters before completion..."); + if (s.Progress <= PROGRESS_REPORT_RANGE_METERS || s.Progress >= Status.TotalProgress - PROGRESS_REPORT_RANGE_METERS) + { + LogManager.Log($"Updating job progress {s.Progress}/{Status.TotalProgress}..."); + } + else if (!loggedContinueMessage) + { + loggedContinueMessage = true; + LogManager.Log($"Progress logging will continue {PROGRESS_REPORT_RANGE_METERS} meters before completion..."); + } } if (s.Progress < 0) diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index 6d9a987cb..30f2e9b0a 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -567,7 +567,7 @@ namespace Tango.Integration.Operation { _diagnosticsSent = false; - if (!(ex is ContinuousResponseAbortedException)) + if (!(ex is ContinuousResponseAbortedException) && !(ex is TransporterDisconnectedException)) { LogRequestFailed(request, ex); } @@ -630,7 +630,7 @@ namespace Tango.Integration.Operation { _eventsSent = false; - if (!(ex is ContinuousResponseAbortedException)) + if (!(ex is ContinuousResponseAbortedException) && !(ex is TransporterDisconnectedException)) { LogRequestFailed(request, ex); } @@ -695,7 +695,7 @@ namespace Tango.Integration.Operation { _debugSent = false; - if (!(ex is ContinuousResponseAbortedException)) + if (!(ex is ContinuousResponseAbortedException) && !(ex is TransporterDisconnectedException)) { LogRequestFailed(request, ex); } @@ -757,7 +757,7 @@ namespace Tango.Integration.Operation { _machineStatusSent = false; - if (!(ex is ContinuousResponseAbortedException)) + if (!(ex is ContinuousResponseAbortedException) && !(ex is TransporterDisconnectedException)) { LogRequestFailed(request, ex); } @@ -792,6 +792,10 @@ namespace Tango.Integration.Operation } } + /// <summary> + /// Called when the enable automatic thread loading has been changed + /// </summary> + /// <param name="value">if set to <c>true</c> [value].</param> protected virtual async void OnEnableAutomaticThreadLoadingChanged(bool value) { if (value && State == TransportComponentState.Connected && !_threadLoadingSent) @@ -816,7 +820,7 @@ namespace Tango.Integration.Operation { _threadLoadingSent = false; - if (!(ex is ContinuousResponseAbortedException)) + if (!(ex is ContinuousResponseAbortedException) && !(ex is TransporterDisconnectedException)) { LogRequestFailed(request, ex); } @@ -1154,6 +1158,8 @@ namespace Tango.Integration.Operation { if (Status == MachineStatuses.Upgrading) return; + Status = MachineStatuses.Disconnected; + if (State == TransportComponentState.Connected) { DisconnectRequest request = new DisconnectRequest(); @@ -1208,6 +1214,8 @@ namespace Tango.Integration.Operation var response = await SendRequest<ConnectRequest, ConnectResponse>(request); LogResponseReceived(response.Message); + _isPowerDownRequestInProgress = false; + if (Status != MachineStatuses.Upgrading) { Status = MachineStatuses.ReadyToDye; @@ -2260,7 +2268,7 @@ namespace Tango.Integration.Operation bool responseLogged = false; bool completed = false; //Use this in case Shlomo is sending progress after completion. - SendContinuousRequest<JobRequest, JobResponse>(request, null, ContinuousRequestTimeout).Subscribe((response) => + SendContinuousRequest<JobRequest, JobResponse>(request, null, ContinuousRequestTimeout.Add(TimeSpan.FromSeconds(3))).Subscribe((response) => { if (!completed) { @@ -2314,7 +2322,10 @@ namespace Tango.Integration.Operation if (!(ex is ContinuousResponseAbortedException)) { - Status = MachineStatuses.ReadyToDye; + if (Status != MachineStatuses.Disconnected) + { + Status = MachineStatuses.ReadyToDye; + } if (!handler.IsCanceled) { @@ -2326,7 +2337,10 @@ namespace Tango.Integration.Operation } else { - Status = MachineStatuses.ReadyToDye; + if (Status != MachineStatuses.Disconnected) + { + Status = MachineStatuses.ReadyToDye; + } } } }, () => @@ -3390,10 +3404,16 @@ namespace Tango.Integration.Operation /// <returns></returns> public Task<PowerDownHandler> PowerDown() { + if (_isPowerDownRequestInProgress) + { + throw new InvalidOperationException("Machine power down is already in progress."); + } + _isPowerDownRequestInProgress = true; PowerDownHandler handler = new PowerDownHandler(new Task(() => { + _isPowerDownRequestInProgress = false; Thread.Sleep(2000); var r = SendRequest<AbortPowerDownRequest, AbortPowerDownResponse>(new AbortPowerDownRequest()).Result; })); @@ -3404,25 +3424,31 @@ namespace Tango.Integration.Operation bool firstResponse = true; - SendContinuousRequest<StartPowerDownRequest, StartPowerDownResponse>(new StartPowerDownRequest()).ObserveOn(new NewThreadScheduler()).Subscribe((response) => - { - if (firstResponse) - { - firstResponse = false; - Status = MachineStatuses.ShuttingDown; - } + SendContinuousRequest<StartPowerDownRequest, StartPowerDownResponse>(new StartPowerDownRequest(), RequestTimeout, TimeSpan.FromSeconds(5)).ObserveOn(new NewThreadScheduler()).Subscribe((response) => + { + if (firstResponse) + { + firstResponse = false; + Status = MachineStatuses.ShuttingDown; + } - handler.RaiseStatusChanged(response); - }, (ex) => - { - _isPowerDownRequestInProgress = false; - LogManager.Log(ex, "Power down error."); - handler.RaiseFailed(ex); - }, () => - { - _isPowerDownRequestInProgress = false; - handler.RaiseCompleted(); - }); + handler.RaiseStatusChanged(response); + }, (ex) => + { + if (_isPowerDownRequestInProgress) + { + _isPowerDownRequestInProgress = false; + LogManager.Log(ex, "Power down error."); + handler.RaiseFailed(ex); + } + }, () => + { + if (_isPowerDownRequestInProgress) + { + _isPowerDownRequestInProgress = false; + handler.RaiseCompleted(); + } + }); }); PowerDownStarted?.Invoke(this, new PowerDownStartedEventArgs() diff --git a/Software/Visual_Studio/Tango.Logging/FileLogger.cs b/Software/Visual_Studio/Tango.Logging/FileLogger.cs index 3b911b4d4..0839a5ee7 100644 --- a/Software/Visual_Studio/Tango.Logging/FileLogger.cs +++ b/Software/Visual_Studio/Tango.Logging/FileLogger.cs @@ -98,12 +98,14 @@ namespace Tango.Logging /// <summary> /// Initializes a new instance of the <see cref="FileLogger"/> class. /// </summary> - public FileLogger() + /// <param name="folder">Logs folder path.</param> + /// <param name="tag">The tag name which will be appended to the file name.</param> + public FileLogger(String folder, String tag) { _isEnabled = true; - Tag = Path.GetFileNameWithoutExtension(AppDomain.CurrentDomain.FriendlyName); - Folder = DefaultLogsFolder; + Tag = tag; + Folder = folder; Directory.CreateDirectory(Folder); _logFileTimeDate = DateTime.Now; LogFile = CreateLogFileName(); @@ -117,22 +119,17 @@ namespace Tango.Logging _removal_timer.Elapsed += _removal_timer_Elapsed; _removal_timer.Start(); - EnableMaxFileSizeLimit = false; - MaxFileSizeLimit = 1000000 * 10; //10 MB + EnableMaxFileSizeLimit = true; + MaxFileSizeLimit = 1000000 * 10; + _fileExtensionIndex = 0; } /// <summary> /// Initializes a new instance of the <see cref="FileLogger"/> class. /// </summary> - /// <param name="folder">Logs folder path.</param> - /// <param name="tag">The tag name which will be appended to the file name.</param> - public FileLogger(String folder, String tag) - : this() + public FileLogger() : this(DefaultLogsFolder, Path.GetFileNameWithoutExtension(AppDomain.CurrentDomain.FriendlyName)) { - Folder = folder; - Tag = tag; - Directory.CreateDirectory(Folder); - LogFile = CreateLogFileName(); + } /// <summary> diff --git a/Software/Visual_Studio/Tango.Touch/Styles/TouchButton.xaml b/Software/Visual_Studio/Tango.Touch/Styles/TouchButton.xaml index 2fd056b6d..b4eb5a9e1 100644 --- a/Software/Visual_Studio/Tango.Touch/Styles/TouchButton.xaml +++ b/Software/Visual_Studio/Tango.Touch/Styles/TouchButton.xaml @@ -37,6 +37,11 @@ <Setter Property="Padding" Value="10 5"></Setter> <Setter Property="RippleBrush" Value="{StaticResource TangoRippleDarkBrush}"></Setter> <Setter Property="FontSize" Value="{StaticResource TangoDefaultFontSize}"></Setter> + <Style.Triggers> + <Trigger Property="IsEnabled" Value="False"> + <Setter Property="Foreground" Value="{StaticResource TangoDisabledBackgroundBrush}"></Setter> + </Trigger> + </Style.Triggers> </Style> <Style x:Key="TangoHollowButton" TargetType="{x:Type controls:TouchButton}"> diff --git a/Software/Visual_Studio/Tango.Transport/Tango.Transport.csproj b/Software/Visual_Studio/Tango.Transport/Tango.Transport.csproj index 542a0a92d..4fb5178db 100644 --- a/Software/Visual_Studio/Tango.Transport/Tango.Transport.csproj +++ b/Software/Visual_Studio/Tango.Transport/Tango.Transport.csproj @@ -104,6 +104,7 @@ <Compile Include="TransportAdapterBase.cs" /> <Compile Include="TransportComponentState.cs" /> <Compile Include="TransporterBase.cs" /> + <Compile Include="TransporterDisconnectedException.cs" /> <Compile Include="Transporters\BasicTransporter.cs" /> <Compile Include="TransportMessage.cs" /> <Compile Include="TransportMessageBase.cs" /> @@ -151,7 +152,7 @@ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> + <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Transport/TransportMessage.cs b/Software/Visual_Studio/Tango.Transport/TransportMessage.cs index 73bf3b1e0..4a1d44892 100644 --- a/Software/Visual_Studio/Tango.Transport/TransportMessage.cs +++ b/Software/Visual_Studio/Tango.Transport/TransportMessage.cs @@ -18,6 +18,8 @@ namespace Tango.Transport /// <seealso cref="Tango.Transport.TransportMessageBase" /> internal class TransportMessage<T> : TransportMessageBase { + private bool exceptionRaised; + private TaskCompletionSource<T> _completionSource; public Subject<T> ContinuesResponseSubject { get; set; } @@ -116,7 +118,13 @@ namespace Tango.Transport /// <param name="ex">The ex.</param> public override void SetException(Exception ex) { + if (exceptionRaised) + { + return; + } + Completed = true; + exceptionRaised = true; Task.Factory.StartNew(() => { diff --git a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs index 6088d99b1..7f8bfa016 100644 --- a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs +++ b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs @@ -17,6 +17,7 @@ using System.ServiceModel; using Tango.Transport.Encoders; using Tango.PMR.Connection; using Tango.Core.Threading; +using System.IO; namespace Tango.Transport { @@ -356,6 +357,20 @@ namespace Tango.Transport await Adapter.Disconnect(); } LogManager.Log($"{GetExtendedComponentName()}: Transporter Disconnected..."); + + LogManager.Log("Notifying all continuous request messages about disconnection..."); + foreach (var request in _pendingRequests.ToList().Where(x => x.Direction == TransportMessageDirection.Request && x.IsContinuous)) + { + try + { + LogManager.Log($"Notifying continuous request '{(request.Message as ITangoMessage).Type}'..."); + request.SetException(new TransporterDisconnectedException("Transporter disconnected.")); + } + catch (Exception e) + { + System.Diagnostics.Debug.WriteLine(e.ToString()); + } + } } /// <summary> diff --git a/Software/Visual_Studio/Tango.Transport/TransporterDisconnectedException.cs b/Software/Visual_Studio/Tango.Transport/TransporterDisconnectedException.cs new file mode 100644 index 000000000..cb10360a5 --- /dev/null +++ b/Software/Visual_Studio/Tango.Transport/TransporterDisconnectedException.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Transport +{ + public class TransporterDisconnectedException : Exception + { + public TransporterDisconnectedException(String message) : base(message) + { + + } + } +} diff --git a/Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/Program.cs b/Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/Program.cs index 61e74957c..960795da0 100644 --- a/Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/Program.cs +++ b/Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/Program.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Data.Entity; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -15,7 +16,7 @@ namespace Tango.JobRunsGenerator static void Main(string[] args) { DataSource dataSource = new DataSource(); - dataSource.Catalog = "Tango_DEV"; + dataSource.Catalog = "Tango_TEST"; dataSource.Address = "twine.database.windows.net"; dataSource.IntegratedSecurity = false; dataSource.UserName = "Roy"; @@ -23,11 +24,26 @@ namespace Tango.JobRunsGenerator using (ObservablesContext db = ObservablesContext.CreateDefault(dataSource)) { - foreach (var run in db.JobRuns.OrderBy(x => x.JobGuid)) + var count = db.JobRuns.Where(x => x.MachineGuid == null).Count(); + + int index = 0; + int saveIndex = 0; + + var runs = db.JobRuns.Where(x => x.MachineGuid == null).OrderBy(x => x.JobGuid).ToList(); + + foreach (var run in runs) { var job = db.Jobs.SingleOrDefault(x => x.Guid == run.JobGuid); - Console.WriteLine($"Fixing job {job.Name}..."); + Console.WriteLine($"Fixing job {job.Name}... ({index++}/{count})"); run.MachineGuid = job.MachineGuid; + + saveIndex++; + + if (saveIndex > 100) + { + saveIndex = 0; + db.SaveChanges(); + } } Console.WriteLine("Saving changed..."); |
