diff options
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels')
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs | 44 |
1 files changed, 35 insertions, 9 deletions
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 590474f9d..dc3ba0ec5 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 @@ -1,10 +1,13 @@ using GalaSoft.MvvmLight.Ioc; +using RealTimeGraphEx.Controllers; +using RealTimeGraphEx.DataSeries; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Media; using Tango.Core.Commands; using Tango.DAL.Observables; using Tango.MachineStudio.Common.Controls; @@ -124,11 +127,11 @@ namespace Tango.MachineStudio.Developer.ViewModels set { _availableSensors = value; RaisePropertyChangedAuto(); } } - private ObservableCollection<RealTimeGraphControl> _graphs; + private ObservableCollection<IRealTimeGraph> _graphs; /// <summary> /// Gets or sets the collection of displayed graph controls. /// </summary> - public ObservableCollection<RealTimeGraphControl> Graphs + public ObservableCollection<IRealTimeGraph> Graphs { get { return _graphs; } set { _graphs = value; RaisePropertyChangedAuto(); } @@ -180,7 +183,7 @@ namespace Tango.MachineStudio.Developer.ViewModels AvailableSensors = Adapter.Sensors.ToObservableCollection(); } - Graphs = new ObservableCollection<RealTimeGraphControl>(); + Graphs = new ObservableCollection<IRealTimeGraph>(); } /// <summary> @@ -338,16 +341,39 @@ namespace Tango.MachineStudio.Developer.ViewModels { if (Graphs.Count < 8) { - RealTimeGraphControl graphControl = new RealTimeGraphControl(); + IRealTimeGraph graphControl = null; + + if (!sensor.MultiChannel) + { + graphControl = new RealTimeGraphControl(); + } + else + { + graphControl = new RealTimeGraphMultiControl(); + GraphMultiController controller = new GraphMultiController(); + + for (int i = 0; i < sensor.ChannelCount; i++) + { + controller.AddSeries(new DataYSeries() + { + Name = sensor.Description.First().ToString() + (i + 1), + UseFillAndStroke = true, + Stroke = new SolidColorBrush(Core.Helpers.ColorHelper.GetRandomColor()) + }); + } + + graphControl.Controller = controller; + } + graphControl.Tag = sensor; graphControl.SensorName = sensor.Description; graphControl.SensorUnits = sensor.Units; - graphControl.Graph.Minimum = sensor.Min; - graphControl.Graph.Maximum = sensor.Max; - graphControl.Graph.MaxPoints = Common.Helpers.GraphsHelper.GetMaxPoints(sensor.PointsPerFrame); + graphControl.InnerGraph.Minimum = sensor.Min; + graphControl.InnerGraph.Maximum = sensor.Max; + graphControl.InnerGraph.MaxPoints = Common.Helpers.GraphsHelper.GetMaxPoints(sensor.PointsPerFrame); graphControl.GraphRemoveButtonPressed += (sender, __) => { - RemoveGraph(sender as RealTimeGraphControl); + RemoveGraph(sender as IRealTimeGraph); }; Graphs.Add(graphControl); AvailableSensors.Remove(sensor); @@ -362,7 +388,7 @@ namespace Tango.MachineStudio.Developer.ViewModels /// Removes the graph. /// </summary> /// <param name="graph">The graph.</param> - public void RemoveGraph(RealTimeGraphControl graph) + public void RemoveGraph(IRealTimeGraph graph) { Graphs.Remove(graph); AvailableSensors.Insert(0, graph.Tag as Sensor); |
