diff options
Diffstat (limited to 'Software/Visual_Studio/MachineStudio')
13 files changed, 439 insertions, 6 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Converters/MonitorsToMultiChannleMonitorsConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Converters/MonitorsToMultiChannleMonitorsConverter.cs new file mode 100644 index 000000000..46a526f56 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Converters/MonitorsToMultiChannleMonitorsConverter.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using Tango.Integration.Observables; + +namespace Tango.MachineStudio.Technician.Converters +{ + public class MonitorsToMultiChannleMonitorsConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + ObservableCollection<TechMonitor> monitors = value as ObservableCollection<TechMonitor>; + + if (monitors != null) + { + return monitors.Where(x => x.MultiChannel).ToObservableCollection(); + } + else + { + return null; + } + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} 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 new file mode 100644 index 000000000..fd2db03e5 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MultiGraphElementEditor.xaml @@ -0,0 +1,79 @@ +<local:ElementEditor x:Class="Tango.MachineStudio.Technician.Editors.MultiGraphElementEditor" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:controls="clr-namespace:Tango.MachineStudio.Common.Controls;assembly=Tango.MachineStudio.Common" + xmlns:converters="clr-namespace:Tango.Editors.Converters;assembly=Tango.Editors" + xmlns:items="clr-namespace:Tango.MachineStudio.Technician.TechItems" + xmlns:local="clr-namespace:Tango.Editors;assembly=Tango.Editors" + mc:Ignorable="d" + d:DesignHeight="150" d:DesignWidth="400" Background="Transparent" ClipToBounds="False" BorderThickness="0" MinWidth="1" MinHeight="1" RenderTransformOrigin="0.5,0.5" d:DataContext="{d:DesignInstance Type=items:MultiGraphItem, IsDesignTimeCreatable=False}"> + + <UserControl.Resources> + <converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"></converters:BoolToVisibilityConverter> + + <!--Theme--> + <SolidColorBrush x:Key="BorderBrush" Color="Transparent"></SolidColorBrush> + <SolidColorBrush x:Key="CornersBrush" Color="Red"></SolidColorBrush> + </UserControl.Resources> + + <UserControl.RenderTransform> + <RotateTransform Angle="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=Angle}"></RotateTransform> + </UserControl.RenderTransform> + + <Grid> + + + <!--Content--> + <Grid> + <!--<Viewbox Stretch="Fill">--> + <controls:RealTimeGraphMultiControl x:Name="InnerGraph" x:FieldModifier="public" EnableToolBar="False" SensorName="{Binding TechMonitor.Description}" SensorUnits="{Binding TechMonitor.Units}" Minimum="{Binding TechMonitor.Min}" Maximum="{Binding TechMonitor.Max}" /> + <!--</Viewbox>--> + + <Border Margin="0 0 0 -23" VerticalAlignment="Bottom"> + <TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=MonitorItem.TechMonitor.Description}" FontSize="14" Foreground="DimGray" HorizontalAlignment="Center"></TextBlock> + </Border> + </Grid> + <!--Content--> + + + <Border BorderThickness="1" BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=BorderBrush,TargetNullValue={StaticResource BorderBrush},FallbackValue={StaticResource BorderBrush}}" Visibility="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=(local:ElementsEditor.IsSelected),Converter={StaticResource BoolToVisibilityConverter}}"> + <Grid> + <ContentPresenter Content="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=InnerContent}"></ContentPresenter> + + <Thumb Opacity="0" DragDelta="MoveDrag" DragStarted="DragStarted" DragCompleted="OnDragEnded"></Thumb> + <Thumb HorizontalAlignment="Left" Cursor="SizeWE" Opacity="0" DragDelta="DragLeft" DragStarted="DragStarted" DragCompleted="OnDragEnded"></Thumb> + <Thumb HorizontalAlignment="Right" Cursor="SizeWE" Opacity="0" DragDelta="DragRight" DragStarted="DragStarted" DragCompleted="OnDragEnded"></Thumb> + <Thumb VerticalAlignment="Top" Cursor="SizeNS" Opacity="0" DragDelta="DragTop" DragStarted="DragStarted" DragCompleted="OnDragEnded"></Thumb> + <Thumb VerticalAlignment="Bottom" Cursor="SizeNS" Opacity="0" DragDelta="DragBottom" DragStarted="DragStarted" DragCompleted="OnDragEnded"></Thumb> + + <Grid ClipToBounds="False" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0 -20 0 0" Width="10" Height="10"> + <Ellipse Stroke="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=CornersBrush,TargetNullValue={StaticResource CornersBrush},FallbackValue={StaticResource CornersBrush}}" StrokeThickness="2"></Ellipse> + <Rectangle HorizontalAlignment="Center" VerticalAlignment="Stretch" Margin="0 10 0 -8" StrokeThickness="1" Stroke="Red"></Rectangle> + <Thumb Opacity="0" DragDelta="DragAngle" DragStarted="DragStarted" Cursor="Arrow" DragCompleted="OnDragEnded"></Thumb> + </Grid> + + <Grid Width="10" Height="10" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="-8 -8 0 0"> + <Border BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=CornersBrush,TargetNullValue={StaticResource CornersBrush},FallbackValue={StaticResource CornersBrush}}" BorderThickness="2 2 0 0"></Border> + <Thumb Opacity="0" DragDelta="DragTopLeft" DragStarted="DragStarted" Cursor="SizeNWSE" DragCompleted="OnDragEnded"></Thumb> + </Grid> + + <Grid Width="10" Height="10" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0 -8 -8 0"> + <Border BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=CornersBrush,TargetNullValue={StaticResource CornersBrush},FallbackValue={StaticResource CornersBrush}}" BorderThickness="0 2 2 0"></Border> + <Thumb Opacity="0" DragDelta="DragTopRight" DragStarted="DragStarted" Cursor="SizeNESW" DragCompleted="OnDragEnded"></Thumb> + </Grid> + + <Grid Width="10" Height="10" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0 0 -8 -8"> + <Border BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=CornersBrush,TargetNullValue={StaticResource CornersBrush},FallbackValue={StaticResource CornersBrush}}" BorderThickness="0 0 2 2"></Border> + <Thumb Opacity="0" DragDelta="DragBottomRight" DragStarted="DragStarted" Cursor="SizeNWSE" DragCompleted="OnDragEnded"></Thumb> + </Grid> + + <Grid Width="10" Height="10" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="-8 0 0 -8"> + <Border BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=CornersBrush,TargetNullValue={StaticResource CornersBrush},FallbackValue={StaticResource CornersBrush}}" BorderThickness="2 0 0 2"></Border> + <Thumb Opacity="0" DragDelta="DragBottomLeft" DragStarted="DragStarted" Cursor="SizeNESW" DragCompleted="OnDragEnded"></Thumb> + </Grid> + </Grid> + </Border> + </Grid> +</local:ElementEditor> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MultiGraphElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MultiGraphElementEditor.xaml.cs new file mode 100644 index 000000000..35273ccda --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MultiGraphElementEditor.xaml.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Markup; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.Editors; +using Tango.Integration.Observables; +using Tango.MachineStudio.Technician.TechItems; + +namespace Tango.MachineStudio.Technician.Editors +{ + [ContentProperty("InnerContent")] + public partial class MultiGraphElementEditor : ElementEditor + { + /// <summary> + /// Initializes a new instance of the <see cref="GraphElementEditor"/> class. + /// </summary> + public MultiGraphElementEditor() + : base() + { + InitializeComponent(); + } + + /// <summary> + /// Initializes a new instance of the <see cref="GraphElementEditor"/> class. + /// </summary> + /// <param name="frameworkElement">The framework element.</param> + public MultiGraphElementEditor(MultiGraphItem graphItem) + : this() + { + GraphItem = graphItem; + } + + /// <summary> + /// Initializes a new instance of the <see cref="GraphElementEditor"/> class. + /// </summary> + /// <param name="frameworkElement">The framework element.</param> + /// <param name="bounds">The bounds.</param> + public MultiGraphElementEditor(MultiGraphItem graphItem, Rect bounds) + : this(graphItem) + { + Left = bounds.Left; + Top = bounds.Top; + Width = bounds.Width; + Height = bounds.Height; + } + + private MultiGraphItem _monitorItem; + + public MultiGraphItem GraphItem + { + get { return _monitorItem; } + set { _monitorItem = value; RaisePropertyChanged(nameof(GraphItem)); } + } + + + /// <summary> + /// Clones this instance. + /// </summary> + /// <returns></returns> + public override IElementEditor Clone() + { + try + { + MultiGraphElementEditor cloned = new MultiGraphElementEditor(); + + cloned.GraphItem = GraphItem.Clone() as MultiGraphItem; + cloned.Top = Top; + cloned.Left = Left; + cloned.Width = Width; + cloned.Height = Height; + cloned.Angle = Angle; + return cloned; + } + catch (Exception ex) + { + throw new InvalidOperationException("Could not clone this editor. You may have to create a custom editor and implement a custom Clone method.", ex); + } + } + + /// <summary> + /// Gets the hosted element. + /// </summary> + [ParameterIgnore] + public override Object HostedElement + { + get { return GraphItem; } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/multi-graph.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/multi-graph.png Binary files differnew file mode 100644 index 000000000..096d75cc4 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/multi-graph.png diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MultiGraphTemplate.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MultiGraphTemplate.xaml new file mode 100644 index 000000000..491a8b5c8 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MultiGraphTemplate.xaml @@ -0,0 +1,29 @@ +<UserControl x:Class="Tango.MachineStudio.Technician.PropertiesTemplates.MultiGraphTemplate" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:colorPicker="clr-namespace:Tango;assembly=Tango.ColorPicker" + xmlns:converters="clr-namespace:Tango.MachineStudio.Technician.Converters" + xmlns:items="clr-namespace:Tango.MachineStudio.Technician.TechItems" + xmlns:local="clr-namespace:Tango.MachineStudio.Technician.PropertiesTemplates" + mc:Ignorable="d" + d:DesignHeight="300" d:DesignWidth="200" d:DataContext="{d:DesignInstance Type=items:SingleGraphItem, IsDesignTimeCreatable=False}"> + + <UserControl.Resources> + <converters:MonitorsToMultiChannleMonitorsConverter x:Key="MonitorsToMultiChannleMonitorsConverter" /> + + <Style TargetType="{x:Type TabItem}" BasedOn="{StaticResource {x:Type TabItem}}"> + <Setter Property="mahapps:ControlsHelper.HeaderFontSize" Value="14" /> + <Setter Property="Margin" Value="2" /> + </Style> + </UserControl.Resources> + + <Grid> + <StackPanel> + <TextBlock FontSize="10">Selected Input</TextBlock> + <ComboBox Margin="0 5 0 0" ItemsSource="{Binding Adapter.TechMonitors,Converter={StaticResource MonitorsToMultiChannleMonitorsConverter}}" SelectedItem="{Binding TechMonitor,Mode=TwoWay}" DisplayMemberPath="Description" /> + </StackPanel> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MultiGraphTemplate.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MultiGraphTemplate.xaml.cs new file mode 100644 index 000000000..ae5cf4f89 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MultiGraphTemplate.xaml.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.MachineStudio.Technician.TechItems; + +namespace Tango.MachineStudio.Technician.PropertiesTemplates +{ + /// <summary> + /// Interaction logic for SingleGraphTemplate.xaml + /// </summary> + public partial class MultiGraphTemplate : UserControl + { + public MultiGraphTemplate() + { + InitializeComponent(); + } + } +} 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 502ec398d..ed270c017 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 @@ -77,9 +77,13 @@ <Reference Include="PresentationFramework" /> </ItemGroup> <ItemGroup> + <Compile Include="Converters\MonitorsToMultiChannleMonitorsConverter.cs" /> <Compile Include="Converters\MonitorsToSingleChannleMonitorsConverter.cs" /> <Compile Include="Converters\SecondsToGraphPointsConverter.cs" /> <Compile Include="Converters\TransitionLinkConverter.cs" /> + <Compile Include="Editors\MultiGraphElementEditor.xaml.cs"> + <DependentUpon>MultiGraphElementEditor.xaml</DependentUpon> + </Compile> <Compile Include="Editors\SingleGraphElementEditor.xaml.cs"> <DependentUpon>SingleGraphElementEditor.xaml</DependentUpon> </Compile> @@ -90,9 +94,13 @@ <Compile Include="PropertiesTemplates\MonitorTemplate.xaml.cs"> <DependentUpon>MonitorTemplate.xaml</DependentUpon> </Compile> + <Compile Include="PropertiesTemplates\MultiGraphTemplate.xaml.cs"> + <DependentUpon>MultiGraphTemplate.xaml</DependentUpon> + </Compile> <Compile Include="PropertiesTemplates\SingleGraphTemplate.xaml.cs"> <DependentUpon>SingleGraphTemplate.xaml</DependentUpon> </Compile> + <Compile Include="TechItems\MultiGraphItem.cs" /> <Compile Include="TechItems\SingleGraphItem.cs" /> <Compile Include="TechItems\MonitorItem.cs" /> <Compile Include="TechItems\TechItem.cs" /> @@ -121,6 +129,10 @@ <Compile Include="..\..\..\Versioning\GlobalVersionInfo.cs"> <Link>GlobalVersionInfo.cs</Link> </Compile> + <Page Include="Editors\MultiGraphElementEditor.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> <Page Include="Editors\SingleGraphElementEditor.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> @@ -133,6 +145,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="PropertiesTemplates\MultiGraphTemplate.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> <Page Include="PropertiesTemplates\SingleGraphTemplate.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -258,5 +274,8 @@ <ItemGroup> <Resource Include="Images\box.png" /> </ItemGroup> + <ItemGroup> + <Resource Include="Images\multi-graph.png" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> </Project>
\ No newline at end of file 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 new file mode 100644 index 000000000..13591fb01 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MultiGraphItem.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; +using Tango.Integration.Observables; +using Tango.MachineStudio.Technician.Editors; +using Tango.SharedUI.Helpers; + +namespace Tango.MachineStudio.Technician.TechItems +{ + public class MultiGraphItem : TechItem + { + private TechMonitor _techMonitor; + [XmlIgnore] + public TechMonitor TechMonitor + { + get { return _techMonitor; } + set + { + TechMonitor old = _techMonitor; + + _techMonitor = value; + RaisePropertyChangedAuto(); + RaisePropertyChanged(nameof(Data)); + + if (_techMonitor != old && Editor != null) + { + Editor.InnerGraph.InnerGraph.MaxPoints = Common.Helpers.GraphsHelper.GetMaxPoints(TechMonitor.PointsPerFrame); + Editor.InnerGraph.InvalidateGraph(); + } + } + } + + [XmlIgnore] + public MultiGraphElementEditor Editor { get; set; } + + public override object Data => TechMonitor; + + public MultiGraphItem() : base() + { + Name = "Single Channel Graph"; + Description = "Single channel real-time graph"; + Image = ResourceHelper.GetImageFromResources("Images/multi-graph.png"); + } + + public MultiGraphItem(TechMonitor techMonitor) : this() + { + TechMonitor = techMonitor; + } + + public override TechItem Clone() + { + MultiGraphItem cloned = base.Clone() as MultiGraphItem; + cloned.TechMonitor = TechMonitor; + return cloned; + } + } +} 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 9ce559047..ff87aa44d 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 @@ -52,7 +52,7 @@ namespace Tango.MachineStudio.Technician.TechItems public override TechItem Clone() { - MonitorItem cloned = base.Clone() as MonitorItem; + SingleGraphItem cloned = base.Clone() as SingleGraphItem; cloned.TechMonitor = TechMonitor; return cloned; } 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 2be98e619..8bbebdfb7 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 @@ -8,6 +8,8 @@ using System.Reflection; using System.Text; using System.Threading.Tasks; using System.Windows; +using System.Windows.Media; +using Tango.Core.Helpers; using Tango.Editors; using Tango.Integration.Observables; using Tango.Integration.Operators; @@ -23,6 +25,7 @@ namespace Tango.MachineStudio.Technician.ViewModels { private List<PropertyInfo> _diagnoticsDataProperties; private Dictionary<SingleGraphItem, GraphController> _singleControllers; + private Dictionary<MultiGraphItem, GraphMultiController> _multiControllers; private static object _elementsLock = new object(); private ObservableCollection<IElementEditor> _elements; @@ -62,6 +65,7 @@ namespace Tango.MachineStudio.Technician.ViewModels public MachineTechViewVM(IStudioApplicationManager applicationManager) { _singleControllers = new Dictionary<SingleGraphItem, GraphController>(); + _multiControllers = new Dictionary<MultiGraphItem, GraphMultiController>(); AvailableTechItems = TechItem.GetAvailableTechItems().ToObservableCollection(); SelectedTechItem = AvailableTechItems.FirstOrDefault(); _diagnoticsDataProperties = typeof(PushDiagnosticsResponse).GetProperties(BindingFlags.Public | BindingFlags.Instance).ToList(); @@ -127,6 +131,22 @@ namespace Tango.MachineStudio.Technician.ViewModels } } } + else if (item.GetType() == typeof(MultiGraphItem)) + { + MultiGraphItem graphItem = item as MultiGraphItem; + + var prop = _diagnoticsDataProperties.SingleOrDefault(x => x.Name == graphItem.TechMonitor.Name); + + if (prop != null) + { + GraphMultiController controller = null; + + if (_multiControllers.TryGetValue(graphItem, out controller)) + { + controller.PushData(GetMultiGraphValues(graphItem.TechMonitor, prop.GetValue(data))); + } + } + } } } } @@ -150,20 +170,26 @@ namespace Tango.MachineStudio.Technician.ViewModels return (value as RepeatedField<double>).ToList(); } + private List<List<double>> GetMultiGraphValues(TechMonitor monitor,object value) + { + DoubleArray[] arrayOfDoubles = Enumerable.ToArray(value as IEnumerable<DoubleArray>); + return arrayOfDoubles.Select(x => x.Data.ToList()).ToList(); + } + public void AddElement(Rect bounds) { lock (_elementsLock) { if (SelectedTechItem is MonitorItem) { - var monitorItem = new MonitorItem(Adapter.TechMonitors.FirstOrDefault()); + var monitorItem = new MonitorItem(Adapter.TechMonitors.Where(x => !x.MultiChannel).FirstOrDefault()); MonitorElementEditor editor = new MonitorElementEditor(monitorItem, bounds); editor.DataContext = monitorItem; Elements.Add(editor); } else if (SelectedTechItem is SingleGraphItem) { - var graphItem = new SingleGraphItem(Adapter.TechMonitors.FirstOrDefault()); + var graphItem = new SingleGraphItem(Adapter.TechMonitors.Where(x => !x.MultiChannel).FirstOrDefault()); SingleGraphElementEditor editor = new SingleGraphElementEditor(graphItem, bounds); editor.InnerGraph.InnerGraph.MaxPoints = Common.Helpers.GraphsHelper.GetMaxPoints(graphItem.TechMonitor.PointsPerFrame); editor.DataContext = graphItem; @@ -177,6 +203,33 @@ namespace Tango.MachineStudio.Technician.ViewModels Elements.Add(editor); } + else if (SelectedTechItem is MultiGraphItem) + { + var graphItem = new MultiGraphItem(Adapter.TechMonitors.Where(x => x.MultiChannel).FirstOrDefault()); + MultiGraphElementEditor editor = new MultiGraphElementEditor(graphItem, bounds); + editor.InnerGraph.InnerGraph.MaxPoints = Common.Helpers.GraphsHelper.GetMaxPoints(graphItem.TechMonitor.PointsPerFrame); + editor.DataContext = graphItem; + graphItem.Editor = editor; + + + GraphMultiController controller = new GraphMultiController(); + + for (int i = 0; i < graphItem.TechMonitor.ChannelCount; i++) + { + controller.AddSeries(new RealTimeGraphEx.DataSeries.DataYSeries() + { + UseFillAndStroke = true, + Name = graphItem.TechMonitor.Name.First() + (i + 1).ToString(), + Stroke = new SolidColorBrush(ColorHelper.GetRandomColor()), + }); + } + + editor.InnerGraph.Controller = controller; + + _multiControllers.Add(graphItem, controller); + + Elements.Add(editor); + } } } } 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 2c895a789..0f255fac8 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 @@ -157,6 +157,9 @@ <DataTemplate DataType="{x:Type items:SingleGraphItem}"> <templates:SingleGraphTemplate/> </DataTemplate> + <DataTemplate DataType="{x:Type items:MultiGraphItem}"> + <templates:MultiGraphTemplate/> + </DataTemplate> </ContentControl.Resources> </ContentControl> </GroupBox> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphMultiControl.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphMultiControl.xaml index 23573e574..9a5ae3636 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphMultiControl.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphMultiControl.xaml @@ -62,12 +62,12 @@ <Border BorderBrush="{StaticResource AccentColorBrush}" BorderThickness="1 1 0 1"> <StackPanel Orientation="Horizontal"> - <components:YAxisScroll Interval="6" Graph="{Binding ElementName=Graph}" Width="35" Foreground="{StaticResource MaterialDesignLightForeground}" VerticalOffset="-5" FontSize="8" StringFormat="#0.0"></components:YAxisScroll> - <components:YAxisTicks SmallTickTemplate="{StaticResource graphTicksTemplate}" Width="5" SmallTicks="6" Foreground="{StaticResource MaterialDesignLightForeground}" BigTicks="10" Graph="{Binding ElementName=Graph}"></components:YAxisTicks> + <components:YAxisScroll x:Name="yAxis" Interval="6" Graph="{Binding ElementName=Graph}" Width="35" Foreground="{StaticResource MaterialDesignLightForeground}" VerticalOffset="-5" FontSize="8" StringFormat="#0.0"></components:YAxisScroll> + <components:YAxisTicks x:Name="yAxisTicks" SmallTickTemplate="{StaticResource graphTicksTemplate}" Width="5" SmallTicks="6" Foreground="{StaticResource MaterialDesignLightForeground}" BigTicks="10" Graph="{Binding ElementName=Graph}"></components:YAxisTicks> </StackPanel> </Border> <Border Grid.Column="1" BorderThickness="1" BorderBrush="{StaticResource borderBrush}" Background="{DynamicResource graphBackground}" Margin="5 0 0 0"> - <graphEx:RealTimeGraphExMultiLineErase x:Name="Graph" x:FieldModifier="public" Controller="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=Controller}" Antialiased="True" RefreshRate="30" MarkerColor="{StaticResource graphsMarkerColor}" FillGraph="False" Stroke="DodgerBlue"> + <graphEx:RealTimeGraphExMultiLineErase x:Name="Graph" x:FieldModifier="public" Controller="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=Controller}" Antialiased="True" RefreshRate="30" MarkerColor="{StaticResource graphsMarkerColor}" FillGraph="False" Minimum="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=Minimum}" Maximum="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=Maximum}" Stroke="DodgerBlue"> <graphEx:RealTimeGraphExMultiLineErase.Components> <components:MouseValueToolTip ToolTipTemplate="{StaticResource graphTooltipTemplate}" /> <components:GridLines Rows="4" Columns="6" GridBrush="{DynamicResource graphGridLinesBrush}"></components:GridLines> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphMultiControl.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphMultiControl.xaml.cs index a18021ff5..8e3b6b6e3 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphMultiControl.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphMultiControl.xaml.cs @@ -50,6 +50,31 @@ namespace Tango.MachineStudio.Common.Controls public static readonly DependencyProperty SensorUnitsProperty = DependencyProperty.Register("SensorUnits", typeof(String), typeof(RealTimeGraphMultiControl), new PropertyMetadata(null)); + public double Minimum + { + get { return (double)GetValue(MinimumProperty); } + set { SetValue(MinimumProperty, value); } + } + public static readonly DependencyProperty MinimumProperty = + DependencyProperty.Register("Minimum", typeof(double), typeof(RealTimeGraphMultiControl), new PropertyMetadata(0.0)); + + + + public double Maximum + { + get { return (double)GetValue(MaximumProperty); } + set { SetValue(MaximumProperty, value); } + } + public static readonly DependencyProperty MaximumProperty = + DependencyProperty.Register("Maximum", typeof(double), typeof(RealTimeGraphMultiControl), new PropertyMetadata(100.0)); + + public void InvalidateGraph() + { + InnerGraph.Clear(); + yAxis.Render(InnerGraph); + yAxisTicks.Render(InnerGraph); + } + /// <summary> /// Gets or sets the inner real-time graph control. /// </summary> |
