diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2019-05-03 10:08:08 +0300 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2019-05-03 10:08:08 +0300 |
| commit | ec4baf29ede89bf4290f52578df517dc784cb71c (patch) | |
| tree | edfdf93b1394a15529ee28e57b2b31aa5044fa99 /Software/Visual_Studio/MachineStudio/Modules | |
| parent | 12aeb0e61bc3f177a9b85a6067d4909e925c8326 (diff) | |
| parent | 0b593edbbd1ba4072d7a18a9395acdb5b8c21693 (diff) | |
| download | Tango-ec4baf29ede89bf4290f52578df517dc784cb71c.tar.gz Tango-ec4baf29ede89bf4290f52578df517dc784cb71c.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules')
21 files changed, 454 insertions, 204 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/ColorLabModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/ColorCaptureModule.cs index ef616daca..8724f675c 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/ColorLabModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/ColorCaptureModule.cs @@ -13,7 +13,7 @@ using Tango.SharedUI.Helpers; namespace Tango.MachineStudio.ColorCapture { [StudioModule(15)] - public class ColorLabModule : StudioModuleBase + public class ColorCaptureModule : StudioModuleBase { public override string Name { @@ -51,7 +51,7 @@ namespace Tango.MachineStudio.ColorCapture { get { - return Permissions.RunColorLabModule; + return Permissions.RunColorCaptureModule; } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Graph/WpfGraphController.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Graph/WpfGraphController.cs deleted file mode 100644 index 63ce7035e..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Graph/WpfGraphController.cs +++ /dev/null @@ -1,36 +0,0 @@ -using RealTimeGraphX; -using RealTimeGraphX.DataPoints; -using RealTimeGraphX.Renderers; -using RealTimeGraphX.WPF.DataSeries; -using RealTimeGraphX.WPF.Painters; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Media; - -namespace Tango.MachineStudio.ColorCapture.Graph -{ - public class WpfGraphController : GraphControllerBase<WpfDataSeries, DoubleDataPoint, DoubleDataPoint> - { - public WpfGraphController(int refreshRate = 50) - { - AddDataSeries(new WpfDataSeries() - { - StrokeThickness = 1, - Stroke = Colors.DodgerBlue, - }); - - var renderer = new GraphScrollingRenderer<WpfDataSeries, DoubleDataPoint, DoubleDataPoint>() - { - RefreshRate = TimeSpan.FromMilliseconds(refreshRate) - }; - - var painter = new WpfScrollingGraphPainter(); - - ConnectOutput(renderer); - renderer.ConnectOutput(painter); - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Tango.MachineStudio.ColorCapture.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Tango.MachineStudio.ColorCapture.csproj index c30520f13..9f21cadf2 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Tango.MachineStudio.ColorCapture.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Tango.MachineStudio.ColorCapture.csproj @@ -97,10 +97,9 @@ <Link>GlobalVersionInfo.cs</Link> </Compile> <Compile Include="ColorCaptureSettings.cs" /> - <Compile Include="ColorLabModule.cs" /> + <Compile Include="ColorCaptureModule.cs" /> <Compile Include="Controls\ColorMatrixControl.cs" /> <Compile Include="Controls\IndexedUniformGrid.cs" /> - <Compile Include="Graph\WpfGraphController.cs" /> <Compile Include="Models\BenchmarkItem.cs" /> <Compile Include="Models\CaptureConfig.cs" /> <Compile Include="Models\CaptureItem.cs" /> @@ -139,12 +138,12 @@ <Project>{37e4ceab-b54b-451f-b535-04cf7da9c459}</Project> <Name>ColorMine</Name> </ProjectReference> - <ProjectReference Include="..\..\..\SideChains\RealTimeGraphX.WPF\RealTimeGraphX.WPF.csproj"> - <Project>{99d233c5-fee7-418e-9c25-d4584cb52e28}</Project> + <ProjectReference Include="..\..\..\SideChains\RealTimeGraphX-master\RealTimeGraphX.WPF\RealTimeGraphX.WPF.csproj"> + <Project>{6b9774f7-960d-438e-ad81-c6b9be328d50}</Project> <Name>RealTimeGraphX.WPF</Name> </ProjectReference> - <ProjectReference Include="..\..\..\SideChains\RealTimeGraphX\RealTimeGraphX.csproj"> - <Project>{6d55a3b8-46d3-493a-a143-aebd2b98d683}</Project> + <ProjectReference Include="..\..\..\SideChains\RealTimeGraphX-master\RealTimeGraphX\RealTimeGraphX.csproj"> + <Project>{f13a489c-80ee-4cd0-bdd4-92d959215646}</Project> <Name>RealTimeGraphX</Name> </ProjectReference> <ProjectReference Include="..\..\..\Tango.BL\Tango.BL.csproj"> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/ViewModels/MainViewVM.cs index 5ea5747d5..31eec0871 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/ViewModels/MainViewVM.cs @@ -2,6 +2,8 @@ using ColorMine.ColorSpaces.Comparisons; using Microsoft.Win32; using Microsoft.WindowsAPICodePack.Dialogs; +using RealTimeGraphX.DataPoints; +using RealTimeGraphX.WPF; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -16,7 +18,6 @@ using Tango.Core; using Tango.Core.Commands; using Tango.CSV; using Tango.Logging; -using Tango.MachineStudio.ColorCapture.Graph; using Tango.MachineStudio.ColorCapture.Models; using Tango.MachineStudio.Common; using Tango.MachineStudio.Common.Notifications; @@ -106,7 +107,7 @@ namespace Tango.MachineStudio.ColorCapture.ViewModels public double DeltaE { get; set; } - public WpfGraphController CaptureDeltaEController { get; set; } + public WpfGraphController<DoubleDataPoint, DoubleDataPoint> CaptureDeltaEController { get; set; } public RelayCommand ToggleCameraCommand { get; set; } @@ -169,7 +170,11 @@ namespace Tango.MachineStudio.ColorCapture.ViewModels Benchmarks = new ObservableCollection<BenchmarkItem>(); _cardDetector = new CardDetector(); ToggleCameraCommand = new RelayCommand(ToggleCamera); - CaptureDeltaEController = new WpfGraphController(); + CaptureDeltaEController = new WpfGraphController<DoubleDataPoint, DoubleDataPoint>(); + CaptureDeltaEController.DataSeriesCollection.Add(new WpfGraphDataSeries() + { + Stroke = System.Windows.Media.Colors.DodgerBlue, + }); CaptureDeltaEController.Range.AutoY = true; CaptureDeltaEController.Range.MaximumX = 1000; @@ -461,6 +466,11 @@ namespace Tango.MachineStudio.ColorCapture.ViewModels } } + if (double.IsInfinity(DeltaE)) + { + DeltaE = 0; + } + CaptureDeltaEController.PushData(_sampleCounter++, DeltaE); } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Views/MainView.xaml index ba8e3f281..afdac7e18 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Views/MainView.xaml @@ -9,12 +9,11 @@ xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:vm="clr-namespace:Tango.MachineStudio.ColorCapture.ViewModels" xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" - xmlns:graphX="clr-namespace:RealTimeGraphX.WPF.Surfaces;assembly=RealTimeGraphX.WPF" - xmlns:componentsX="clr-namespace:RealTimeGraphX.WPF.Components;assembly=RealTimeGraphX.WPF" + xmlns:commonControls="clr-namespace:Tango.MachineStudio.Common.Controls;assembly=Tango.MachineStudio.Common" xmlns:controls="clr-namespace:Tango.MachineStudio.ColorCapture.Controls" xmlns:sharedControls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" xmlns:tcc="clr-namespace:Tango.TCC.BL;assembly=Tango.TCC.BL" - xmlns:realtimeGraphX="clr-namespace:RealTimeGraphX.WPF.Surfaces;assembly=RealTimeGraphX.WPF" + xmlns:realtimeGraphX="clr-namespace:RealTimeGraphX.WPF;assembly=RealTimeGraphX.WPF" xmlns:global="clr-namespace:Tango.MachineStudio.ColorCapture" xmlns:local="clr-namespace:Tango.MachineStudio.ColorCapture.Views" mc:Ignorable="d" @@ -435,14 +434,14 @@ </Grid.ColumnDefinitions> <Border Margin="0 1 0 2"> - <componentsX:GraphAxisControl Orientation="Vertical" Foreground="{StaticResource Accent}" FontSize="12" Surface="{Binding ElementName=Graph}" StringFormat="Δ 0.00;-#" /> + <realtimeGraphX:WpfGraphAxisControl Orientation="Vertical" Foreground="{StaticResource Accent}" FontSize="12" Controller="{Binding CaptureDeltaEController}" StringFormat="Δ 0.00;-#" /> </Border> <Border Grid.Column="1" BorderThickness="1" BorderBrush="{StaticResource Accent}" Margin="1 0 0 0" Background="{StaticResource LightBackground}"> <Grid> - <componentsX:GraphGridLines Foreground="#3E3E3E" /> + <realtimeGraphX:WpfGraphGridLines Foreground="#3E3E3E" /> - <graphX:WpfGraphSurface x:Name="Graph"></graphX:WpfGraphSurface> + <realtimeGraphX:WpfGraphSurface Controller="{Binding CaptureDeltaEController}"></realtimeGraphX:WpfGraphSurface> </Grid> </Border> </Grid> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Views/MainView.xaml.cs index 05b5daf7e..aa7ff5d49 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Views/MainView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Views/MainView.xaml.cs @@ -29,7 +29,6 @@ namespace Tango.MachineStudio.ColorCapture.Views Loaded += (_, __) => { _vm = DataContext as MainViewVM; - _vm.CaptureDeltaEController.Output.Output.ConnectOutput(Graph); }; } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj index 190e8d0fe..cd00557b1 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj @@ -196,10 +196,6 @@ <Project>{37e4ceab-b54b-451f-b535-04cf7da9c459}</Project> <Name>ColorMine</Name> </ProjectReference> - <ProjectReference Include="..\..\..\SideChains\RealTimeGraphEx\RealTimeGraphEx.csproj"> - <Project>{b9ae25d6-be35-492f-9079-21a7f3e6f7cc}</Project> - <Name>RealTimeGraphEx</Name> - </ProjectReference> <ProjectReference Include="..\..\..\SideChains\Tango.AutoComplete\Tango.AutoComplete.csproj"> <Project>{BB2ABB74-BA58-4812-83AA-EC8171F42DF4}</Project> <Name>Tango.AutoComplete</Name> @@ -361,7 +357,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/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs index db9d9dbae..4ce8ab39d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs @@ -966,9 +966,23 @@ namespace Tango.MachineStudio.Developer.ViewModels private void MachineOperator_PreparingJobProgress(object sender, PreparingJobProgressEventArgs e) { - if (_preparingTaskItem != null) + var percent = (e.Progress / e.Total * 100d); + + if (_preparingTaskItem == null && percent == 0) + { + _preparingTaskItem = _notification.PushTaskItem("Preparing job for printing..."); + } + else if (percent == 100) { - _preparingTaskItem.Message = $"Preparing job for printing {(e.Progress / e.Total * 100d).ToString("0.0")}%..."; + _preparingTaskItem.Pop(); + _preparingTaskItem = null; + } + else + { + if (_preparingTaskItem != null) + { + _preparingTaskItem.Message = $"Preparing job for printing {(e.Progress / e.Total * 100d).ToString("0.0")}%..."; + } } } @@ -1067,13 +1081,13 @@ namespace Tango.MachineStudio.Developer.ViewModels { _speech.SpeakError(events.Last().EventType.Name); - if (events.ToList().Exists(x => x.Actions.Contains(BL.Enumerations.EventTypeActions.StopJob))) - { - if (JobHandler != null) - { - InvokeUI(StopJob); - } - } + //if (events.ToList().Exists(x => x.Actions.Contains(BL.Enumerations.EventTypeActions.StopJob))) + //{ + // if (JobHandler != null) + // { + // InvokeUI(StopJob); + // } + //} } } @@ -1293,6 +1307,8 @@ namespace Tango.MachineStudio.Developer.ViewModels /// </summary> private async void StartJob(Func<Job, JobHandler> resumeFunc = null) { + SettingsManager.Default.Save(); + LogManager.Log(String.Format("Starting job {0}...", ActiveJob.Name)); if (MachineOperator == null || MachineOperator.State != TransportComponentState.Connected) { @@ -1327,11 +1343,7 @@ namespace Tango.MachineStudio.Developer.ViewModels if (resumeFunc == null) { - using (var item = _notification.PushTaskItem("Preparing job for printing...")) - { - _preparingTaskItem = item; - JobHandler = await MachineOperator.Print(ActiveJob, SelectedProcessParametersTable); - } + JobHandler = await MachineOperator.Print(ActiveJob, SelectedProcessParametersTable); } else { @@ -1386,7 +1398,7 @@ namespace Tango.MachineStudio.Developer.ViewModels InvokeUI(() => { - _notification.ShowError("Job failed. " + ex.Message); + _notification.ShowError("Job failed. " + ex.FlattenMessage()); StopRecordingIfInProgress(); }); }; @@ -1408,6 +1420,12 @@ namespace Tango.MachineStudio.Developer.ViewModels JobHandler.Canceled += (x, y) => { + if (_preparingTaskItem != null) + { + _preparingTaskItem.Pop(); + _preparingTaskItem = null; + } + LogManager.Log(String.Format("Job {0} has been canceled.", RunningJob.Name)); _eventLogger.Log(String.Format("Job {0} has been canceled.", RunningJob.Name)); StopRecordingIfInProgress(); @@ -1750,6 +1768,11 @@ namespace Tango.MachineStudio.Developer.ViewModels InvalidateRelayCommands(); _disable_gamut_check = false; + + _settings.LastSelectedMachineGuid = SelectedMachine != null ? SelectedMachine.Guid : null; + _settings.LastSelectedJobGuid = SelectedMachineJob != null ? SelectedMachineJob.Guid : null; + + _settings.Save(); }); SegmentsCollectionView = CollectionViewSource.GetDefaultView(ActiveJob.Segments); @@ -1987,6 +2010,11 @@ namespace Tango.MachineStudio.Developer.ViewModels SelectedSegments.ToList().ForEach(x => { + if (ActiveJob.Segments.Count == 1) + { + _notification.ShowInfo("A job must contain at least one segment."); + return; + } ActiveJob.Segments.Remove(x); x.DefferedDelete(_activeJobDbContext); }); @@ -2114,12 +2142,17 @@ namespace Tango.MachineStudio.Developer.ViewModels { if (SelectedBrushStop != null && SelectedSegment != null) { - if (_notification.ShowQuestion("Are you sure you want to delete the selected colors?")) + if (_notification.ShowQuestion("Are you sure you want to delete the selected brush stops?")) { LogManager.Log(String.Format("Removing {0} brush stops...", SelectedBrushStops.Count)); SelectedBrushStops.ToList().ForEach(x => { + if (SelectedSegment.BrushStops.Count == 1) + { + _notification.ShowInfo("A job segment must contain at least one brush stop."); + return; + } SelectedSegment.BrushStops.Remove(x); x.DefferedDelete(_activeJobDbContext); }); @@ -2406,8 +2439,7 @@ namespace Tango.MachineStudio.Developer.ViewModels public override void OnShuttingDown() { - _settings.LastSelectedMachineGuid = SelectedMachine != null ? SelectedMachine.Guid : null; - _settings.LastSelectedJobGuid = SelectedMachineJob != null ? SelectedMachineJob.Guid : null; + } #endregion diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml index c4c831011..a5d137e67 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml @@ -865,9 +865,15 @@ </StackPanel> <DockPanel> - <StackPanel Orientation="Horizontal" DockPanel.Dock="Right" VerticalAlignment="Center" Margin="0 0 15 0"> - <ToggleButton IsChecked="{Binding ApplicationManager.ConnectedMachine.GradientGenerationConfiguration.IsEnabled}" /> - <TextBlock Margin="10 0 0 0" VerticalAlignment="Center" Foreground="DimGray">Enable Gradient Generation</TextBlock> + <StackPanel Orientation="Horizontal" DockPanel.Dock="Right" VerticalAlignment="Center" Margin="0 0 0 0"> + <TextBlock VerticalAlignment="Center" Foreground="DimGray">Generate Gradient</TextBlock> + <ToggleButton Margin="10 0 0 0" IsChecked="{Binding ApplicationManager.ConnectedMachine.GradientGenerationConfiguration.IsEnabled,Mode=TwoWay}" /> + <TextBlock Margin="10 0 0 0" VerticalAlignment="Center" Foreground="DimGray">Resolution:</TextBlock> + <mahapps:NumericUpDown HideUpDownButtons="True" Width="90" HorizontalAlignment="Left" FontSize="14" FontFamily="{StaticResource digital-7}" StringFormat="{}{0:N0} cm" Margin="5 1 0 0" Minimum="10" Maximum="1000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" BorderBrush="DimGray" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Left" Value="{Binding MachineOperator.GradientGenerationConfiguration.ResolutionCM,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"> + <mahapps:NumericUpDown.Resources> + <StaticResource ResourceKey="SelectAllTextBoxResource"></StaticResource> + </mahapps:NumericUpDown.Resources> + </mahapps:NumericUpDown> </StackPanel> <Rectangle HorizontalAlignment="Stretch" VerticalAlignment="Center" Height="15" Margin="200 0 10 0" StrokeThickness="1" Stroke="Gainsboro"> <Rectangle.Fill> @@ -1214,7 +1220,7 @@ </Grid> <Grid DockPanel.Dock="Right" Margin="0 0 10 0"> - <StackPanel Orientation="Horizontal" Visibility="{Binding IsJobRunning,Converter={StaticResource BooleanToVisibilityInverseConverter}}"> + <StackPanel Orientation="Horizontal" Visibility="{Binding IsJobRunning,Converter={StaticResource BooleanToVisibilityInverseConverter}}" IsEnabled="{Binding MachineOperator.CanPrint}"> <Button Height="60" Width="280" Command="{Binding StartJobCommand}" Click="OnJobStartClick"> <StackPanel Orientation="Horizontal"> <materialDesign:PackIcon VerticalAlignment="Center" Width="32" Height="32" Kind="ClockFast" /> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/RunningJobView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/RunningJobView.xaml index dbe0d835b..d0f0c2af6 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/RunningJobView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/RunningJobView.xaml @@ -194,7 +194,13 @@ <DataGridTextColumn SortDirection="Descending" Header="DATE TIME" Binding="{Binding DateTime,Converter={StaticResource DateTimeUTCToStringConverter},ConverterParameter='MM/dd/yyyy HH:mm:ss.fff'}" /> <DataGridTextColumn Header="GROUP" Binding="{Binding EventType.Group}" /> <DataGridTextColumn Header="EVENT" Binding="{Binding EventType.Title}" /> - <DataGridTextColumn Header="MESSAGE" Width="1*" Binding="{Binding Description,Converter={StaticResource StringToEllipsisConverter},ConverterParameter=100}" /> + <DataGridTemplateColumn Header="MESSAGE" Width="1*"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <TextBlock Height="20" Text="{Binding Description,Converter={StaticResource StringToEllipsisConverter},ConverterParameter=100}" TextWrapping="NoWrap"></TextBlock> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> </DataGrid.Columns> </DataGrid> </Grid> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/MainViewVM.cs index fd897e811..ef9561d0b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/MainViewVM.cs @@ -12,6 +12,8 @@ using Tango.BL.Enumerations; using Tango.Core.Helpers; using Tango.MachineStudio.Common; using Tango.MachineStudio.Statistics.Models; +using System.Data.Entity; +using Tango.MachineStudio.Common.Notifications; namespace Tango.MachineStudio.Statistics.ViewModels { @@ -20,6 +22,8 @@ namespace Tango.MachineStudio.Statistics.ViewModels private ObservablesContext _context; private List<JobRun> _job_runs; private bool rendered; + private INotificationProvider _notification; + private bool _loaded; private LabeledSeriesCollection _timelineJobStatusSeries; public LabeledSeriesCollection TimelineJobStatusSeries @@ -35,24 +39,58 @@ namespace Tango.MachineStudio.Statistics.ViewModels set { _pieJobFailedReasons = value; RaisePropertyChangedAuto(); } } - public MainViewVM() + private LabeledSeriesCollection _printPerWeekSeries; + public LabeledSeriesCollection PrintPerWeekSeries { + get { return _printPerWeekSeries; } + set { _printPerWeekSeries = value; RaisePropertyChangedAuto(); } + } + + private DateTime _startDate; + public DateTime StartDate + { + get { return _startDate; } + set { _startDate = value; RaisePropertyChangedAuto(); OnDateRangeChanged(); } + } + + private DateTime _endDate; + public DateTime EndDate + { + get { return _endDate; } + set { _endDate = value; RaisePropertyChangedAuto(); OnDateRangeChanged(); } + } + + private DateTime _minDate; + public DateTime MinDate + { + get { return _minDate; } + set { _minDate = value; RaisePropertyChangedAuto(); } + } + + private DateTime _maxDate; + public DateTime MaxDate + { + get { return _maxDate; } + set { _maxDate = value; RaisePropertyChangedAuto(); } + } + + + public MainViewVM(INotificationProvider notificationProvider) + { + _notification = notificationProvider; + StartDate = DateTime.Now.AddMonths(-1); + EndDate = DateTime.Now; } public override void OnApplicationReady() { - Task.Factory.StartNew(() => - { - _context = ObservablesContext.CreateDefault(); - DateTime start_date = DateTime.UtcNow.AddMonths(-1); - _job_runs = _context.JobRuns.OrderBy(x => x.StartDate).ToList(); - }); + } - private List<JobRun> GetJobRunsByStartDate(DateTime startDate, JobRunStatus? status = null) + private List<JobRun> GetJobRunsByDateRange(DateTime startDate, DateTime endTime, JobRunStatus? status = null) { - return _job_runs.Where(x => x.StartDate.ToLocalTime() >= startDate && (status == null || x.JobRunStatus == status)).ToList(); + return _job_runs.Where(x => x.StartDate.ToLocalTime() >= startDate && x.StartDate.ToLocalTime() <= endTime && (status == null || x.JobRunStatus == status)).ToList(); } private List<JobRun> GetJobRunsByDate(DateTime date, JobRunStatus? status = null) @@ -68,7 +106,9 @@ namespace Tango.MachineStudio.Statistics.ViewModels } } - public override void OnNavigatedTo() + + + public override async void OnNavigatedTo() { base.OnNavigatedTo(); @@ -76,21 +116,49 @@ namespace Tango.MachineStudio.Statistics.ViewModels rendered = true; - InvokeUIOnIdle(() => + + using (_notification.PushTaskItem("Loading statistics...")) { + IsFree = false; + + await Task.Factory.StartNew(() => + { + _context = ObservablesContext.CreateDefault(); + _job_runs = _context.JobRuns.Include(x => x.Job).Include(x => x.Job.Machine).OrderBy(x => x.StartDate).ToList(); + }); + if (_job_runs.Count > 0) { - GenerateTimelineJobStatusChart(); - GeneratePieFailedReasonsChart(); + MinDate = _job_runs.Min(x => x.StartDate); + MaxDate = _job_runs.Max(x => x.StartDate); } - }); + + InvokeUIOnIdle(() => + { + OnDateRangeChanged(); + }); + + _loaded = true; + + IsFree = true; + } + } + + private void OnDateRangeChanged() + { + if (_job_runs != null && _job_runs.Count > 0 && _loaded) + { + GenerateTimelineJobStatusChart(); + GeneratePieFailedReasonsChart(); + GeneratePrintPerWeekChart(); + } } private void GenerateTimelineJobStatusChart() { TimelineJobStatusSeries = new LabeledSeriesCollection() { - Title = "This Month Job Runs Status", + Title = "Job Runs Status", ChartTitle = "Number Of Runs", LabelsTitle = "Date", SeriesColors = new List<Color>() @@ -101,26 +169,62 @@ namespace Tango.MachineStudio.Statistics.ViewModels }, }; - var completed_job_runs = new ColumnSeries() + Series completed_job_runs = new ColumnSeries() { Title = "Completed", Values = new ChartValues<int>(), Fill = Brushes.Green, + MinWidth = 1, + }; - var aborted_job_runs = new ColumnSeries() + Series aborted_job_runs = new ColumnSeries() { Title = "Aborted", Values = new ChartValues<int>(), Fill = Brushes.Orange, + MinWidth = 1, }; - var failed_job_runs = new ColumnSeries() + Series failed_job_runs = new ColumnSeries() { Title = "Failed", Values = new ChartValues<int>(), Fill = Brushes.Red, + MinWidth = 1, }; - foreach (var date in CreateDates(DateTime.Now.AddMonths(-1), DateTime.Now)) + if (EndDate - StartDate > TimeSpan.FromDays(40)) + { + completed_job_runs = new LineSeries() + { + Title = "Completed", + Values = new ChartValues<int>(), + Fill = new SolidColorBrush(Colors.Green) { Opacity = 0.5 }, + MinWidth = 1, + PointGeometry = null, + StrokeThickness = 0, + + }; + aborted_job_runs = new LineSeries() + { + Title = "Aborted", + Values = new ChartValues<int>(), + Fill = new SolidColorBrush(Colors.Orange) { Opacity = 0.5 }, + MinWidth = 1, + PointGeometry = null, + StrokeThickness = 0, + }; + failed_job_runs = new LineSeries() + { + Title = "Failed", + Values = new ChartValues<int>(), + Fill = new SolidColorBrush(Colors.Red) { Opacity = 0.5 }, + MinWidth = 1, + PointGeometry = null, + StrokeThickness = 0, + }; + } + + foreach (var date in CreateDates(StartDate, EndDate)) { completed_job_runs.Values.Add(GetJobRunsByDate(date, JobRunStatus.Completed).Count()); aborted_job_runs.Values.Add(GetJobRunsByDate(date, JobRunStatus.Aborted).Count()); @@ -129,18 +233,20 @@ namespace Tango.MachineStudio.Statistics.ViewModels TimelineJobStatusSeries.Labels.Add(date.ToShortDateString()); } - TimelineJobStatusSeries.SeriesCollection.Add(completed_job_runs); - TimelineJobStatusSeries.SeriesCollection.Add(aborted_job_runs); + + TimelineJobStatusSeries.SeriesCollection.Add(failed_job_runs); + TimelineJobStatusSeries.SeriesCollection.Add(aborted_job_runs); + TimelineJobStatusSeries.SeriesCollection.Add(completed_job_runs); } private void GeneratePieFailedReasonsChart() { - var groups = GetJobRunsByStartDate(DateTime.Now.AddMonths(-1), JobRunStatus.Failed).GroupBy(x => x.FailedMessage).OrderBy(x => x.Count()); + var groups = GetJobRunsByDateRange(StartDate, EndDate, JobRunStatus.Failed).GroupBy(x => x.FailedMessage).OrderBy(x => x.Count()); List<Color> colors = new List<Color>(); - int max = groups.Max(x => x.Count()); + int max = groups.Count() > 0 ? groups.Max(x => x.Count()) : 0; for (int i = 0; i < groups.Count(); i++) { @@ -151,7 +257,7 @@ namespace Tango.MachineStudio.Statistics.ViewModels PieJobFailedReasons = new LabeledSeriesCollection() { - Title = "This Month Job Failure Reasons", + Title = "Job Failure Reasons", SeriesColors = colors, }; @@ -173,5 +279,88 @@ namespace Tango.MachineStudio.Statistics.ViewModels PieJobFailedReasons.SeriesCollection.Add(series); } } + + private void GeneratePrintPerWeekChart() + { + List<JobRun> range_job_runs = GetJobRunsByDateRange(StartDate, EndDate); + + Dictionary<Machine, List<double>> weeks_print_avg = new Dictionary<Machine, List<double>>(); + + //Init machines weeks averages dictionary. + foreach (var machine in range_job_runs.Select(x => x.Job.Machine).OrderBy(x => x.Name).DistinctBy(x => x.Guid)) + { + weeks_print_avg[machine] = new List<double>(); + } + + //Create all available dates + List<DateTime> all_dates = range_job_runs.Select(x => x.StartDate).ToList(); + + //get first Sunday. + DateTime current_sunday = all_dates.FirstOrDefault(x => x.DayOfWeek == DayOfWeek.Sunday); + + if (current_sunday != null && all_dates.Count > 0) + { + //Iterate over each week starting from the earliest Sunday. + while (current_sunday <= all_dates.Last()) + { + var week_job_runs = range_job_runs.Where(x => x.EndPosition > 10 && x.StartDate >= current_sunday && x.StartDate <= current_sunday.AddDays(7)).ToList(); + + foreach (var machine_job_runs in week_job_runs.GroupBy(x => x.Job.Machine)) + { + weeks_print_avg[machine_job_runs.Key].Add(machine_job_runs.Select(x => x.EndPosition).Average()); + } + + current_sunday = current_sunday.AddDays(8); + } + } + + Dictionary<Machine, double> week_print_avg = new Dictionary<Machine, double>(); + + //Init machines week average dictionary. + foreach (var machine in weeks_print_avg) + { + if (machine.Value.Count > 0) + { + week_print_avg[machine.Key] = machine.Value.Average(); + } + } + + //Init chart series + PrintPerWeekSeries = new LabeledSeriesCollection() + { + Title = "Average Printed Thread Per Week (m)", + ChartTitle = "Average Print Per Week (m)", + LabelsTitle = "Date", + SeriesColors = new List<Color>() + { + + }, + }; + + //Init series colors intensity by number of prints. + double max = week_print_avg.Count > 0 ? week_print_avg.Max(x => x.Value) : 0; + foreach (var machine in week_print_avg) + { + double a = (machine.Value / max); + PrintPerWeekSeries.SeriesColors.Add(Color.FromArgb((byte)(255d * (machine.Value / max)), 0, 200, 0)); + } + + //Init columns. + int index = 0; + + foreach (var machine in week_print_avg) + { + var series = new ColumnSeries() + { + Title = machine.Key.Name, + Values = new ChartValues<int>() { (int)machine.Value }, + Fill = new SolidColorBrush(PrintPerWeekSeries.SeriesColors[index++]), + DataLabels = true, + ToolTip = machine.Key.SerialNumber, + }; + + PrintPerWeekSeries.SeriesCollection.Add(series); + } + } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/MainView.xaml index f063c1675..69708f517 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/MainView.xaml @@ -5,13 +5,31 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:vm="clr-namespace:Tango.MachineStudio.Statistics.ViewModels" xmlns:global="clr-namespace:Tango.MachineStudio.Statistics" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:local="clr-namespace:Tango.MachineStudio.Statistics.Views" xmlns:tooltips="clr-namespace:Tango.MachineStudio.Statistics.Tooltips" xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf" mc:Ignorable="d" d:DesignHeight="1080" d:DesignWidth="1920" Background="Transparent" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> - <Grid> - <UniformGrid Columns="3" Margin="50" Rows="3"> + <Grid IsEnabled="{Binding IsFree}"> + <Grid.RowDefinitions> + <RowDefinition Height="80"/> + <RowDefinition Height="337*"/> + </Grid.RowDefinitions> + + <StackPanel Margin="60 20 0 0" VerticalAlignment="Center" HorizontalAlignment="Left" Orientation="Horizontal"> + <StackPanel> + <TextBlock FontSize="10">Start Date:</TextBlock> + <DatePicker DisplayDateStart="{Binding MinDate}" DisplayDateEnd="{Binding MaxDate}" SelectedDate="{Binding StartDate}" materialDesign:HintAssist.Hint="Pick start date" Width="200" VerticalAlignment="Bottom" FontSize="16"></DatePicker> + </StackPanel> + + <StackPanel Margin="40 0 0 0"> + <TextBlock FontSize="10">End Date:</TextBlock> + <DatePicker DisplayDateStart="{Binding MinDate}" DisplayDateEnd="{Binding MaxDate}" SelectedDate="{Binding EndDate}" materialDesign:HintAssist.Hint="Pick end date" Width="200" VerticalAlignment="Bottom" FontSize="16"></DatePicker> + </StackPanel> + </StackPanel> + + <UniformGrid Columns="3" Margin="50 20 50 50" Rows="2" Grid.Row="1"> <Border BorderBrush="#181818" Padding="5" BorderThickness="1" CornerRadius="5" Margin="10"> <DockPanel> <TextBlock DockPanel.Dock="Top" FontSize="16" FontWeight="Bold" HorizontalAlignment="Center" Padding="10" Text="{Binding TimelineJobStatusSeries.Title}"></TextBlock> @@ -48,6 +66,28 @@ </UniformGrid> </DockPanel> </Border> + + <Border BorderBrush="#181818" Padding="5" BorderThickness="1" CornerRadius="5" Margin="10"> + <DockPanel> + <TextBlock DockPanel.Dock="Top" FontSize="16" FontWeight="Bold" HorizontalAlignment="Center" Padding="10" Text="{Binding PrintPerWeekSeries.Title}"></TextBlock> + <lvc:CartesianChart Series="{Binding PrintPerWeekSeries.SeriesCollection}" LegendLocation="Bottom" SeriesColors="{Binding PrintPerWeekSeries.SeriesColors}"> + <lvc:CartesianChart.AxisX> + <lvc:Axis Title="{Binding PrintPerWeekSeries.LabelsTitle}" Labels="{Binding PrintPerWeekSeries.Labels}" Foreground="#202020"> + <lvc:Axis.Separator> + <lvc:Separator Stroke="#A5A5A5" /> + </lvc:Axis.Separator> + </lvc:Axis> + </lvc:CartesianChart.AxisX> + <lvc:CartesianChart.AxisY> + <lvc:Axis Title="{Binding PrintPerWeekSeries.ChartTitle}" MinValue="0" Foreground="#202020" > + <lvc:Axis.Separator> + <lvc:Separator Stroke="#B0B0B0" /> + </lvc:Axis.Separator> + </lvc:Axis> + </lvc:CartesianChart.AxisY> + </lvc:CartesianChart> + </DockPanel> + </Border> </UniformGrid> </Grid> </UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MultiGraphElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MultiGraphElementEditor.xaml index 22fd8eaa8..9b9334355 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MultiGraphElementEditor.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MultiGraphElementEditor.xaml @@ -32,7 +32,7 @@ <!--Content--> <Grid> <!--<Viewbox Stretch="Fill">--> - <controls:RealTimeGraphControl x:Name="InnerGraph" IsHitTestVisible="{Binding RelativeSource={RelativeSource AncestorType=local:ElementsEditor},Path=IsEditable,Converter={StaticResource BooleanInverseConverter}}" x:FieldModifier="public" DisplayName="{Binding TechMonitor.Description}" DisplayUnits="{Binding TechMonitor.Units}" StringFormat="{Binding DecimalPlaces,Converter={StaticResource DecimalPlacesToStringFormatConverter}}" /> + <controls:WpfGraphControl x:Name="InnerGraph" IsHitTestVisible="{Binding RelativeSource={RelativeSource AncestorType=local:ElementsEditor},Path=IsEditable,Converter={StaticResource BooleanInverseConverter}}" x:FieldModifier="public" DisplayName="{Binding TechMonitor.Description}" DisplayUnits="{Binding TechMonitor.Units}" StringFormat="{Binding DecimalPlaces,Converter={StaticResource DecimalPlacesToStringFormatConverter}}" /> <!--</Viewbox>--> </Grid> <!--Content--> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/SingleGraphElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/SingleGraphElementEditor.xaml index ca2481de6..622ddfa8b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/SingleGraphElementEditor.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/SingleGraphElementEditor.xaml @@ -32,9 +32,9 @@ <!--Content--> <Grid> <!--<Viewbox Stretch="Fill">--> - <controls:RealTimeGraphControl x:Name="InnerGraph" IsHitTestVisible="{Binding RelativeSource={RelativeSource AncestorType=local:ElementsEditor},Path=IsEditable,Converter={StaticResource BooleanInverseConverter}}" x:FieldModifier="public" DisplayName="{Binding TechMonitor.Description}" DisplayUnits="{Binding TechMonitor.Units}" StringFormat="{Binding DecimalPlaces,Converter={StaticResource DecimalPlacesToStringFormatConverter}}"> + <controls:WpfGraphControl x:Name="InnerGraph" IsHitTestVisible="{Binding RelativeSource={RelativeSource AncestorType=local:ElementsEditor},Path=IsEditable,Converter={StaticResource BooleanInverseConverter}}" x:FieldModifier="public" DisplayName="{Binding TechMonitor.Description}" DisplayUnits="{Binding TechMonitor.Units}" StringFormat="{Binding DecimalPlaces,Converter={StaticResource DecimalPlacesToStringFormatConverter}}"> - </controls:RealTimeGraphControl> + </controls:WpfGraphControl> <!--</Viewbox>--> </Grid> <!--Content--> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj index 7e6f4e111..ff45bcbf9 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj @@ -522,16 +522,12 @@ </None> </ItemGroup> <ItemGroup> - <ProjectReference Include="..\..\..\SideChains\RealTimeGraphEx\RealTimeGraphEx.csproj"> - <Project>{b9ae25d6-be35-492f-9079-21a7f3e6f7cc}</Project> - <Name>RealTimeGraphEx</Name> - </ProjectReference> - <ProjectReference Include="..\..\..\SideChains\RealTimeGraphX.WPF\RealTimeGraphX.WPF.csproj"> - <Project>{99d233c5-fee7-418e-9c25-d4584cb52e28}</Project> + <ProjectReference Include="..\..\..\SideChains\RealTimeGraphX-master\RealTimeGraphX.WPF\RealTimeGraphX.WPF.csproj"> + <Project>{6b9774f7-960d-438e-ad81-c6b9be328d50}</Project> <Name>RealTimeGraphX.WPF</Name> </ProjectReference> - <ProjectReference Include="..\..\..\SideChains\RealTimeGraphX\RealTimeGraphX.csproj"> - <Project>{6d55a3b8-46d3-493a-a143-aebd2b98d683}</Project> + <ProjectReference Include="..\..\..\SideChains\RealTimeGraphX-master\RealTimeGraphX\RealTimeGraphX.csproj"> + <Project>{f13a489c-80ee-4cd0-bdd4-92d959215646}</Project> <Name>RealTimeGraphX</Name> </ProjectReference> <ProjectReference Include="..\..\..\Tango.BL\Tango.BL.csproj"> @@ -728,7 +724,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/MachineStudio/Modules/Tango.MachineStudio.Technician/TechGraphController.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechGraphController.cs index 28c75f79f..ca132095c 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechGraphController.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechGraphController.cs @@ -1,8 +1,7 @@ using RealTimeGraphX; using RealTimeGraphX.DataPoints; using RealTimeGraphX.Renderers; -using RealTimeGraphX.WPF.DataSeries; -using RealTimeGraphX.WPF.Painters; +using RealTimeGraphX.WPF; using System; using System.Collections.Generic; using System.Linq; @@ -11,19 +10,11 @@ using System.Threading.Tasks; namespace Tango.MachineStudio.Technician { - public class TechGraphController : GraphControllerBase<WpfDataSeries, TimeSpanDataPoint, DoubleDataPoint> + public class TechGraphController : WpfGraphController<TimeSpanDataPoint, DoubleDataPoint> { public TechGraphController(int refreshRate = 50) { - var renderer = new GraphScrollingRenderer<WpfDataSeries, TimeSpanDataPoint, DoubleDataPoint>() - { - RefreshRate = TimeSpan.FromMilliseconds(refreshRate) - }; - - var painter = new WpfScrollingGraphPainter(); - - ConnectOutput(renderer); - renderer.ConnectOutput(painter); + RefreshRate = TimeSpan.FromMilliseconds(50); } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MultiGraphItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MultiGraphItem.cs index 377738d09..1412175a0 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MultiGraphItem.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MultiGraphItem.cs @@ -1,4 +1,5 @@ using RealTimeGraphX.DataPoints; +using RealTimeGraphX.WPF; using System; using System.Collections.Generic; using System.Linq; @@ -213,7 +214,7 @@ namespace Tango.MachineStudio.Technician.TechItems { if (Editor != null) { - var controller = Editor.InnerGraph.Controller; + var controller = Editor.InnerGraph.Controller as WpfGraphController<TimeSpanDataPoint,DoubleDataPoint>; controller.Range.MaximumX = new TimeSpanDataPoint(TimeSpan.FromSeconds(_duration)); controller.Range.MinimumY = new DoubleDataPoint(_min); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/SingleGraphItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/SingleGraphItem.cs index 808dadb68..8ccd5e718 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/SingleGraphItem.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/SingleGraphItem.cs @@ -1,4 +1,5 @@ using RealTimeGraphX.DataPoints; +using RealTimeGraphX.WPF; using System; using System.Collections.Generic; using System.Linq; @@ -217,7 +218,7 @@ namespace Tango.MachineStudio.Technician.TechItems { if (Editor != null) { - var controller = Editor.InnerGraph.Controller; + var controller = Editor.InnerGraph.Controller as WpfGraphController<TimeSpanDataPoint, DoubleDataPoint>; ; controller.Range.MaximumX = new TimeSpanDataPoint(TimeSpan.FromSeconds(_duration)); controller.Range.MinimumY = new DoubleDataPoint(_min); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs index e78047563..72e43d7b0 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs @@ -1,6 +1,5 @@ using Google.Protobuf.Collections; using Microsoft.Win32; -using RealTimeGraphEx.Controllers; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -36,9 +35,9 @@ using Tango.MachineStudio.Technician.Models; using Tango.Logging; using Microsoft.WindowsAPICodePack.Dialogs; using RealTimeGraphX; -using RealTimeGraphX.WPF.DataSeries; using RealTimeGraphX.DataPoints; using Tango.MachineStudio.Technician.Views; +using RealTimeGraphX.WPF; namespace Tango.MachineStudio.Technician.ViewModels { @@ -1024,7 +1023,7 @@ namespace Tango.MachineStudio.Technician.ViewModels var editor = element as SingleGraphElementEditor; TechGraphController controller = new TechGraphController(); - controller.AddDataSeries(new WpfDataSeries() + controller.DataSeriesCollection.Add(new WpfGraphDataSeries() { Stroke = Colors.DodgerBlue, }); @@ -1043,7 +1042,7 @@ namespace Tango.MachineStudio.Technician.ViewModels for (int i = 0; i < graphItem.TechMonitor.ChannelCount; i++) { - controller.AddDataSeries(new WpfDataSeries() + controller.DataSeriesCollection.Add(new WpfGraphDataSeries() { Stroke = ColorHelper.GetRandomColor(), Name = graphItem.TechMonitor.Name.First() + (i + 1).ToString(), @@ -1437,7 +1436,7 @@ namespace Tango.MachineStudio.Technician.ViewModels controller.Range.MaximumY = item.TechMonitor.Max; controller.Range.MaximumX = TimeSpan.FromSeconds(10); - controller.AddDataSeries(new WpfDataSeries() + controller.DataSeriesCollection.Add(new WpfGraphDataSeries() { Stroke = Colors.DodgerBlue, }); @@ -1498,7 +1497,7 @@ namespace Tango.MachineStudio.Technician.ViewModels for (int i = 0; i < item.TechMonitor.ChannelCount; i++) { - controller.AddDataSeries(new WpfDataSeries() + controller.DataSeriesCollection.Add(new WpfGraphDataSeries() { Stroke = ColorHelper.GetRandomColor(), Name = item.TechMonitor.Name.First() + (i + 1).ToString(), diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml index 92e2b292a..8820fcd4d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml @@ -26,9 +26,9 @@ <localConverters:SecondsToTimeSpanConverter x:Key="SecondsToTimeSpanConverter" /> <DataTemplate x:Key="TabTemplate"> - <Grid> - <Grid.Style> - <Style TargetType="Grid"> + <Border IsVisibleChanged="Border_IsVisibleChanged"> + <Border.Style> + <Style TargetType="Border"> <Setter Property="Visibility" Value="Visible"></Setter> <Style.Triggers> <DataTrigger Binding="{Binding IsSelected}" Value="False"> @@ -36,12 +36,13 @@ </DataTrigger> </Style.Triggers> </Style> - </Grid.Style> - <Grid.ColumnDefinitions> - <ColumnDefinition Width="1*"/> - <ColumnDefinition Width="Auto"/> - </Grid.ColumnDefinitions> - <editors:ElementsEditor + </Border.Style> + <Grid> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="1*"/> + <ColumnDefinition Width="Auto"/> + </Grid.ColumnDefinitions> + <editors:ElementsEditor x:Name="editor" Elements="{Binding Elements}" Loaded="Editor_Loaded" @@ -61,63 +62,64 @@ BorderBrush="#1EA9FF" BorderThickness="1"> - <editors:ElementsEditor.Style> - <Style TargetType="editors:ElementsEditor"> - <Setter Property="IsEditable" Value="True"></Setter> - <Style.Triggers> - <DataTrigger Binding="{Binding ElementName=listMode,Path=SelectedIndex}" Value="1"> - <Setter Property="IsEditable" Value="False"></Setter> - </DataTrigger> - </Style.Triggers> - </Style> - </editors:ElementsEditor.Style> + <editors:ElementsEditor.Style> + <Style TargetType="editors:ElementsEditor"> + <Setter Property="IsEditable" Value="True"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding ElementName=listMode,Path=SelectedIndex}" Value="1"> + <Setter Property="IsEditable" Value="False"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </editors:ElementsEditor.Style> - <editors:ElementsEditor.ContextMenu> - <ContextMenu DataContext="{Binding Path=PlacementTarget, RelativeSource={RelativeSource Self}}"> - <MenuItem Header="Cut (Ctrl+X)" Command="{Binding CutCommand}" MinWidth="210"> - <MenuItem.Icon> - <fa:ImageAwesome Icon="Cut" Width="16" /> - </MenuItem.Icon> - </MenuItem> - <MenuItem Header="Copy (Ctrl+C)" Command="{Binding CopyCommand}"> - <MenuItem.Icon> - <fa:ImageAwesome Icon="Copy" Width="16" /> - </MenuItem.Icon> - </MenuItem> - <MenuItem Header="Paste (Ctrl+V)" Command="{Binding PasteCommand}"> - <MenuItem.Icon> - <fa:ImageAwesome Icon="Paste" Width="16" /> - </MenuItem.Icon> - </MenuItem> - <Separator/> - <MenuItem Header="Undo (Ctrl+Z)" Command="{Binding UndoCommand}"> - <MenuItem.Icon> - <fa:ImageAwesome Icon="Undo" Width="16" /> - </MenuItem.Icon> - </MenuItem> - <MenuItem Header="Redo (Ctrl+Y)" Command="{Binding RedoCommand}"> - <MenuItem.Icon> - <fa:ImageAwesome Icon="RotateRight" Width="16"></fa:ImageAwesome> - </MenuItem.Icon> - </MenuItem> - <Separator/> - <MenuItem Header="Delete (DELETE)" Command="{Binding DeleteCommand}"> - <MenuItem.Icon> - <fa:ImageAwesome Icon="Recycle" Width="16" /> - </MenuItem.Icon> - </MenuItem> - <Separator/> - <MenuItem Header="Select All (Ctrl+A)" Command="{Binding SelectAllCommand}"> - <MenuItem.Icon> - <fa:ImageAwesome Icon="Th" Width="16" /> - </MenuItem.Icon> - </MenuItem> - </ContextMenu> - </editors:ElementsEditor.ContextMenu> - </editors:ElementsEditor> + <editors:ElementsEditor.ContextMenu> + <ContextMenu DataContext="{Binding Path=PlacementTarget, RelativeSource={RelativeSource Self}}"> + <MenuItem Header="Cut (Ctrl+X)" Command="{Binding CutCommand}" MinWidth="210"> + <MenuItem.Icon> + <fa:ImageAwesome Icon="Cut" Width="16" /> + </MenuItem.Icon> + </MenuItem> + <MenuItem Header="Copy (Ctrl+C)" Command="{Binding CopyCommand}"> + <MenuItem.Icon> + <fa:ImageAwesome Icon="Copy" Width="16" /> + </MenuItem.Icon> + </MenuItem> + <MenuItem Header="Paste (Ctrl+V)" Command="{Binding PasteCommand}"> + <MenuItem.Icon> + <fa:ImageAwesome Icon="Paste" Width="16" /> + </MenuItem.Icon> + </MenuItem> + <Separator/> + <MenuItem Header="Undo (Ctrl+Z)" Command="{Binding UndoCommand}"> + <MenuItem.Icon> + <fa:ImageAwesome Icon="Undo" Width="16" /> + </MenuItem.Icon> + </MenuItem> + <MenuItem Header="Redo (Ctrl+Y)" Command="{Binding RedoCommand}"> + <MenuItem.Icon> + <fa:ImageAwesome Icon="RotateRight" Width="16"></fa:ImageAwesome> + </MenuItem.Icon> + </MenuItem> + <Separator/> + <MenuItem Header="Delete (DELETE)" Command="{Binding DeleteCommand}"> + <MenuItem.Icon> + <fa:ImageAwesome Icon="Recycle" Width="16" /> + </MenuItem.Icon> + </MenuItem> + <Separator/> + <MenuItem Header="Select All (Ctrl+A)" Command="{Binding SelectAllCommand}"> + <MenuItem.Icon> + <fa:ImageAwesome Icon="Th" Width="16" /> + </MenuItem.Icon> + </MenuItem> + </ContextMenu> + </editors:ElementsEditor.ContextMenu> + </editors:ElementsEditor> - <Slider Grid.Column="1" Orientation="Vertical" Margin="5" Maximum="3" Minimum="0.2" Value="{Binding ElementName=editor,Path=ScaleFactor}"></Slider> - </Grid> + <Slider Grid.Column="1" Orientation="Vertical" Margin="5" Maximum="3" Minimum="0.2" Value="{Binding ElementName=editor,Path=ScaleFactor}"></Slider> + </Grid> + </Border> </DataTemplate> </UserControl.Resources> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml.cs index 694debd26..e4ebe2424 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml.cs @@ -23,11 +23,14 @@ namespace Tango.MachineStudio.Technician.Views public partial class MachineTechView : UserControl { private MachineTechViewVM _vm; + private Dictionary<Border, UIElement> _tabs_content; public MachineTechView() { InitializeComponent(); + _tabs_content = new Dictionary<Border, UIElement>(); + this.Loaded += (x, y) => { _vm = DataContext as MachineTechViewVM; @@ -67,5 +70,22 @@ namespace Tango.MachineStudio.Technician.Views (editor.UndoRedoStatesProvider as ElementsEditorUndoRedoStatesProvider).StateExecuted += MachineTechView_StateExecuted; } + + private void Border_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) + { + Border border = sender as Border; + if (border.Visibility != Visibility.Visible) + { + _tabs_content[border] = border.Child; + border.Child = null; + } + else + { + if (_tabs_content.ContainsKey(border)) + { + border.Child = _tabs_content[border]; + } + } + } } } |
