From 11e64f69d00d84974bb09bef6f921c7eeab7c47e Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 24 Jan 2018 18:30:53 +0200 Subject: Added Graphs Drag & Drop to Developer Module. --- .../Controls/RealTimeGraphControl.xaml | 90 ++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml new file mode 100644 index 000000000..687bc6030 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.3.1 From d36a5ab7115ec53405622e4437cd3f8f615d515d Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 24 Jan 2018 19:32:14 +0200 Subject: Added support for multi sensor frame on developer module graph. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 8388608 -> 8388608 bytes .../ViewModels/MainViewVM.cs | 44 +++++++-- .../Controls/IRealTimeGraph.cs | 48 +++++++++ .../Controls/RealTimeGraphControl.xaml | 2 +- .../Controls/RealTimeGraphControl.xaml.cs | 15 ++- .../Controls/RealTimeGraphMultiControl.xaml | 95 ++++++++++++++++++ .../Controls/RealTimeGraphMultiControl.xaml.cs | 107 +++++++++++++++++++++ .../Resources/MaterialDesign.xaml | 40 ++++++++ .../Tango.MachineStudio.Common.csproj | 8 ++ .../FastGraphs/RealTimeGraphExLineScroll.cs | 12 --- .../RealTimeGraphEx/RealTimeGraphExBase.cs | 11 +++ .../RealTimeGraphEx/RealTimeGraphExMultiBase.cs | 12 --- .../Tango.Core/Helpers/ColorHelper.cs | 11 +++ 14 files changed, 370 insertions(+), 35 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/IRealTimeGraph.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphMultiControl.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphMultiControl.xaml.cs (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 27da03f9b..875b88771 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index bdff96627..3a65c84fa 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ 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 _graphs; + private ObservableCollection _graphs; /// /// Gets or sets the collection of displayed graph controls. /// - public ObservableCollection Graphs + public ObservableCollection Graphs { get { return _graphs; } set { _graphs = value; RaisePropertyChangedAuto(); } @@ -180,7 +183,7 @@ namespace Tango.MachineStudio.Developer.ViewModels AvailableSensors = Adapter.Sensors.ToObservableCollection(); } - Graphs = new ObservableCollection(); + Graphs = new ObservableCollection(); } /// @@ -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. /// /// The graph. - public void RemoveGraph(RealTimeGraphControl graph) + public void RemoveGraph(IRealTimeGraph graph) { Graphs.Remove(graph); AvailableSensors.Insert(0, graph.Tag as Sensor); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/IRealTimeGraph.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/IRealTimeGraph.cs new file mode 100644 index 000000000..5ca930c91 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/IRealTimeGraph.cs @@ -0,0 +1,48 @@ +using RealTimeGraphEx; +using RealTimeGraphEx.Controllers; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.Common.Controls +{ + public interface IRealTimeGraph + { + /// + /// Gets or sets the name of the sensor. + /// + String SensorName { get; set; } + + /// + /// Gets or sets the tag. + /// + Object Tag { get; set; } + + /// + /// Gets or sets the sensor units. + /// + String SensorUnits { get; set; } + + /// + /// Occurs when the graph remove button has been pressed. + /// + event EventHandler GraphRemoveButtonPressed; + + /// + /// Occurs when the graph full screen button has been pressed. + /// + event EventHandler GraphFullScreenButtonPressed; + + /// + /// Gets or sets the inner real-time graph control. + /// + RealTimeGraphExBase InnerGraph { get; set; } + + /// + /// Gets or sets the inner graph controller. + /// + GraphControllerBase Controller { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml index 687bc6030..449cea493 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml @@ -67,7 +67,7 @@ - + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml.cs index 6396ab91a..359e52823 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml.cs @@ -14,13 +14,15 @@ using System.Windows.Media.Animation; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using RealTimeGraphEx; +using RealTimeGraphEx.Controllers; namespace Tango.MachineStudio.Common.Controls { /// /// Interaction logic for RealTimeGraphControl.xaml /// - public partial class RealTimeGraphControl : UserControl + public partial class RealTimeGraphControl : UserControl, IRealTimeGraph { #region Properties @@ -46,6 +48,15 @@ namespace Tango.MachineStudio.Common.Controls public static readonly DependencyProperty SensorUnitsProperty = DependencyProperty.Register("SensorUnits", typeof(String), typeof(RealTimeGraphControl), new PropertyMetadata(null)); + /// + /// Gets or sets the inner real-time graph control. + /// + public RealTimeGraphExBase InnerGraph { get; set; } + + /// + /// Gets or sets the inner graph controller. + /// + public GraphControllerBase Controller { get; set; } #endregion @@ -59,6 +70,8 @@ namespace Tango.MachineStudio.Common.Controls public RealTimeGraphControl() { InitializeComponent(); + InnerGraph = Graph; + Controller = new GraphController(); } private void OnGraphFullScreen(object sender, RoutedEventArgs e) diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphMultiControl.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphMultiControl.xaml new file mode 100644 index 000000000..23573e574 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphMultiControl.xaml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 new file mode 100644 index 000000000..5cb69b786 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphMultiControl.xaml.cs @@ -0,0 +1,107 @@ +using RealTimeGraphEx; +using RealTimeGraphEx.Controllers; +using System; +using System.Collections.Generic; +using System.ComponentModel; +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.Animation; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.Common.Controls +{ + /// + /// Interaction logic for RealTimeGraphControl.xaml + /// + public partial class RealTimeGraphMultiControl : UserControl , IRealTimeGraph + { + #region Properties + + /// + /// Gets or sets the name of the sensor. + /// + public String SensorName + { + get { return (String)GetValue(SensorNameProperty); } + set { SetValue(SensorNameProperty, value); } + } + public static readonly DependencyProperty SensorNameProperty = + DependencyProperty.Register("SensorName", typeof(String), typeof(RealTimeGraphMultiControl), new PropertyMetadata(null)); + + /// + /// Gets or sets the sensor units. + /// + public String SensorUnits + { + get { return (String)GetValue(SensorUnitsProperty); } + set { SetValue(SensorUnitsProperty, value); } + } + public static readonly DependencyProperty SensorUnitsProperty = + DependencyProperty.Register("SensorUnits", typeof(String), typeof(RealTimeGraphMultiControl), new PropertyMetadata(null)); + + /// + /// Gets or sets the inner real-time graph control. + /// + public RealTimeGraphExBase InnerGraph { get; set; } + + /// + /// Gets or sets the inner graph controller. + /// + public GraphControllerBase Controller { get; set; } + + #endregion + + #region Events + + public event EventHandler GraphRemoveButtonPressed; + public event EventHandler GraphFullScreenButtonPressed; + + #endregion + + public RealTimeGraphMultiControl() + { + InitializeComponent(); + InnerGraph = Graph; + Controller = new GraphMultiController(); + } + + private void OnGraphFullScreen(object sender, RoutedEventArgs e) + { + GraphFullScreenButtonPressed?.Invoke(this, new EventArgs()); + } + + private void Graph_MouseEnter(object sender, MouseEventArgs e) + { + Grid mainGrid = sender as Grid; + var headerGrid = mainGrid.Children.OfType().ToList().First(); + ThicknessAnimation ani = new ThicknessAnimation(); + ani.To = new Thickness(0, 0, 0, 0); + ani.Duration = TimeSpan.FromSeconds(0.2); + headerGrid.BeginAnimation(Grid.MarginProperty, ani); + } + + private void Graph_MouseLeave(object sender, MouseEventArgs e) + { + Grid mainGrid = sender as Grid; + var headerGrid = mainGrid.Children.OfType().ToList().First(); + ThicknessAnimation ani = new ThicknessAnimation(); + ani.To = new Thickness(0, -35, 0, 0); + ani.Duration = TimeSpan.FromSeconds(0.2); + headerGrid.BeginAnimation(Grid.MarginProperty, ani); + } + + private void OnGraphRemove(object sender, RoutedEventArgs e) + { + GraphRemoveButtonPressed?.Invoke(this, new EventArgs()); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Resources/MaterialDesign.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Resources/MaterialDesign.xaml index cc18c31c5..8c5464930 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Resources/MaterialDesign.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Resources/MaterialDesign.xaml @@ -267,6 +267,46 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj index b89ec2e09..bc7f00d58 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj @@ -71,6 +71,10 @@ + + + RealTimeGraphMultiControl.xaml + RealTimeGraphControl.xaml @@ -103,6 +107,10 @@ + + MSBuild:Compile + Designer + Designer MSBuild:Compile diff --git a/Software/Visual_Studio/SideChains/RealTimeGraphEx/FastGraphs/RealTimeGraphExLineScroll.cs b/Software/Visual_Studio/SideChains/RealTimeGraphEx/FastGraphs/RealTimeGraphExLineScroll.cs index 216683d39..a2260030c 100644 --- a/Software/Visual_Studio/SideChains/RealTimeGraphEx/FastGraphs/RealTimeGraphExLineScroll.cs +++ b/Software/Visual_Studio/SideChains/RealTimeGraphEx/FastGraphs/RealTimeGraphExLineScroll.cs @@ -40,18 +40,6 @@ namespace RealTimeGraphEx.FastGraphs #region Properties - /// - /// Gets or sets the maximum vectorsCollection to display on the graph (default 1000, affects performance). - /// - public int MaxPoints - { - get { return (int)GetValue(MaxPointsProperty); } - set { SetValue(MaxPointsProperty, value); } - } - public static readonly DependencyProperty MaxPointsProperty = - DependencyProperty.Register("MaxPoints", typeof(int), typeof(RealTimeGraphExLineScroll), new PropertyMetadata(1000, new PropertyChangedCallback(CrossModelChanged))); - - /// /// Gets or sets the graph fill color. /// diff --git a/Software/Visual_Studio/SideChains/RealTimeGraphEx/RealTimeGraphExBase.cs b/Software/Visual_Studio/SideChains/RealTimeGraphEx/RealTimeGraphExBase.cs index cf8d6c0fe..c1ed37474 100644 --- a/Software/Visual_Studio/SideChains/RealTimeGraphEx/RealTimeGraphExBase.cs +++ b/Software/Visual_Studio/SideChains/RealTimeGraphEx/RealTimeGraphExBase.cs @@ -349,6 +349,17 @@ namespace RealTimeGraphEx public static readonly DependencyProperty ZoomDirectionProperty = DependencyProperty.Register("ZoomDirection", typeof(ZoomDirectionEnum), typeof(RealTimeGraphExBase), new PropertyMetadata(ZoomDirectionEnum.Both)); + /// + /// Gets or sets the maximum points to display on the graph (default 1000). + /// + public int MaxPoints + { + get { return (int)GetValue(MaxPointsProperty); } + set { SetValue(MaxPointsProperty, value); } + } + public static readonly DependencyProperty MaxPointsProperty = + DependencyProperty.Register("MaxPoints", typeof(int), typeof(RealTimeGraphExBase), new PropertyMetadata(1000, new PropertyChangedCallback(CrossModelChanged))); + #endregion #region Cross Thread Fields diff --git a/Software/Visual_Studio/SideChains/RealTimeGraphEx/RealTimeGraphExMultiBase.cs b/Software/Visual_Studio/SideChains/RealTimeGraphEx/RealTimeGraphExMultiBase.cs index d9edc478e..108ff4ea3 100644 --- a/Software/Visual_Studio/SideChains/RealTimeGraphEx/RealTimeGraphExMultiBase.cs +++ b/Software/Visual_Studio/SideChains/RealTimeGraphEx/RealTimeGraphExMultiBase.cs @@ -22,18 +22,6 @@ namespace RealTimeGraphEx #region Properties - /// - /// Gets or sets the maximum points to display on the graph (default 1000). - /// - public int MaxPoints - { - get { return (int)GetValue(MaxPointsProperty); } - set { SetValue(MaxPointsProperty, value); } - } - public static readonly DependencyProperty MaxPointsProperty = - DependencyProperty.Register("MaxPoints", typeof(int), typeof(RealTimeGraphExMultiBase), new PropertyMetadata(1000, new PropertyChangedCallback(CrossModelChanged))); - - /// /// Gets or sets the collection of data series to display on the graph. /// diff --git a/Software/Visual_Studio/Tango.Core/Helpers/ColorHelper.cs b/Software/Visual_Studio/Tango.Core/Helpers/ColorHelper.cs index c5ebc7474..3d0532985 100644 --- a/Software/Visual_Studio/Tango.Core/Helpers/ColorHelper.cs +++ b/Software/Visual_Studio/Tango.Core/Helpers/ColorHelper.cs @@ -12,6 +12,8 @@ namespace Tango.Core.Helpers /// public static class ColorHelper { + private static Random rnd = new Random(); + /// /// Converts the specified color to integer. /// @@ -36,5 +38,14 @@ namespace Tango.Core.Helpers byte b = (byte)(integer >> 0); return Color.FromArgb(a, r, g, b); } + + /// + /// Returns a random color. + /// + /// + public static Color GetRandomColor() + { + return Color.FromRgb((byte)rnd.Next(256), (byte)rnd.Next(256), (byte)rnd.Next(256)); + } } } -- cgit v1.3.1 From 6103db0f792e396583929c08117e07fb6b9aa389 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 8 Feb 2018 19:22:42 +0200 Subject: Working on MachineTechView... --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 8388608 -> 8388608 bytes Software/Graphics/analog.png | Bin 0 -> 7334 bytes Software/Graphics/graph.png | Bin 0 -> 1842 bytes Software/Graphics/single-graph.png | Bin 0 -> 4236 bytes .../Diagnostics/PushDiagnosticsResponse.proto | 12 ++ .../MonitorsToSingleChannleMonitorsConverter.cs | 34 ++++ .../Editors/MonitorElementEditor.xaml | 2 +- .../Editors/MonitorElementEditor.xaml.cs | 27 +-- .../Editors/SingleGraphElementEditor.xaml | 79 +++++++++ .../Editors/SingleGraphElementEditor.xaml.cs | 102 +++++++++++ .../Images/analog.png | Bin 0 -> 7334 bytes .../Images/graph.png | Bin 0 -> 1842 bytes .../Images/single-graph.png | Bin 0 -> 4236 bytes .../Items/MonitorItem.cs | 43 ----- .../Items/TechItem.cs | 99 ----------- .../PropertiesTemplates/MonitorTemplate.xaml | 22 +++ .../PropertiesTemplates/MonitorTemplate.xaml.cs | 28 +++ .../PropertiesTemplates/SingleGraphTemplate.xaml | 22 +++ .../SingleGraphTemplate.xaml.cs | 29 ++++ .../Tango.MachineStudio.Technician.csproj | 36 +++- .../TechItems/MonitorItem.cs | 51 ++++++ .../TechItems/SingleGraphItem.cs | 60 +++++++ .../TechItems/TechItem.cs | 138 +++++++++++++++ .../TechnicianModule.cs | 2 +- .../ViewModels/MachineTechViewVM.cs | 153 ++++++++++++++++- .../Views/MachineTechView.xaml | 94 ++++++++++- .../Controls/RealTimeGraphControl.xaml | 6 +- .../Controls/RealTimeGraphControl.xaml.cs | 29 ++++ .../RealTimeGraphEx/RealTimeGraphExBase.cs | 11 +- .../Tango.Emulations/Emulators/MachineEmulator.cs | 9 + .../Diagnostics/PushDiagnosticsResponse.cs | 188 ++++++++++++++++++++- 32 files changed, 1083 insertions(+), 193 deletions(-) create mode 100644 Software/Graphics/analog.png create mode 100644 Software/Graphics/graph.png create mode 100644 Software/Graphics/single-graph.png create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Converters/MonitorsToSingleChannleMonitorsConverter.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/SingleGraphElementEditor.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/SingleGraphElementEditor.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/analog.png create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/graph.png create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/single-graph.png delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Items/MonitorItem.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Items/TechItem.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorTemplate.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorTemplate.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/SingleGraphTemplate.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/SingleGraphTemplate.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MonitorItem.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/SingleGraphItem.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/TechItem.cs (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 1f3e96a4c..8f36c9d40 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index d64502c82..29ebe00a1 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Graphics/analog.png b/Software/Graphics/analog.png new file mode 100644 index 000000000..2651a64b0 Binary files /dev/null and b/Software/Graphics/analog.png differ diff --git a/Software/Graphics/graph.png b/Software/Graphics/graph.png new file mode 100644 index 000000000..0aca05e00 Binary files /dev/null and b/Software/Graphics/graph.png differ diff --git a/Software/Graphics/single-graph.png b/Software/Graphics/single-graph.png new file mode 100644 index 000000000..f72f56a87 Binary files /dev/null and b/Software/Graphics/single-graph.png differ diff --git a/Software/PMR/Messages/Diagnostics/PushDiagnosticsResponse.proto b/Software/PMR/Messages/Diagnostics/PushDiagnosticsResponse.proto index 340a636df..e45cb3040 100644 --- a/Software/PMR/Messages/Diagnostics/PushDiagnosticsResponse.proto +++ b/Software/PMR/Messages/Diagnostics/PushDiagnosticsResponse.proto @@ -10,5 +10,17 @@ message PushDiagnosticsResponse repeated double Dancer1Angle = 1; repeated double Dancer2Angle = 2; repeated double Dancer3Angle = 3; + + //Dispensers Motors Frequency Multi repeated DoubleArray DispensersMotorsFrequency = 4; + + //Dispensers Motors Frequency Singles + repeated double Dispenser1MotorFrequency = 5; + repeated double Dispenser2MotorFrequency = 6; + repeated double Dispenser3MotorFrequency = 7; + repeated double Dispenser4MotorFrequency = 8; + repeated double Dispenser5MotorFrequency = 9; + repeated double Dispenser6MotorFrequency = 10; + repeated double Dispenser7MotorFrequency = 11; + repeated double Dispenser8MotorFrequency = 12; } \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Converters/MonitorsToSingleChannleMonitorsConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Converters/MonitorsToSingleChannleMonitorsConverter.cs new file mode 100644 index 000000000..b5f9cffef --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Converters/MonitorsToSingleChannleMonitorsConverter.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 MonitorsToSingleChannleMonitorsConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + ObservableCollection monitors = value as ObservableCollection; + + 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/MonitorElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml index d3ce4fc10..84eae5f75 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml @@ -33,7 +33,7 @@ - + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml.cs index f50fc9039..c11ca4417 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml.cs @@ -17,35 +17,10 @@ using System.Windows.Navigation; using System.Windows.Shapes; using Tango.Editors; using Tango.Integration.Observables; -using Tango.MachineStudio.Technician.Items; +using Tango.MachineStudio.Technician.TechItems; namespace Tango.MachineStudio.Technician.Editors { - /// - /// - /// Represents a editor with position, size and angle control. - /// - /// - /// - /// - /// - /// The following example demonstrates a basic scenario of using and by creating a simple video projection application with the following features: - /// - /// - /// Use the mouse to draw any type of tile of the editor surface. - /// Apply any input shape on any tile. - /// Load any video and display it on any of the selected tile. - /// Built in support for undo, redo, cut, copy and paste, delete and select operations. - /// Built in support for saving/loading the editor state to memory or file. - /// Built in support for tile and editor properties adjustment using the . - /// - /// - /// - /// - /// Code-Behind. - /// - /// - /// [ContentProperty("InnerContent")] public partial class MonitorElementEditor : ElementEditor { 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 new file mode 100644 index 000000000..eafc7b5d3 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/SingleGraphElementEditor.xaml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/SingleGraphElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/SingleGraphElementEditor.xaml.cs new file mode 100644 index 000000000..8e8ac556e --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/SingleGraphElementEditor.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 SingleGraphElementEditor : ElementEditor + { + /// + /// Initializes a new instance of the class. + /// + public SingleGraphElementEditor() + : base() + { + InitializeComponent(); + } + + /// + /// Initializes a new instance of the class. + /// + /// The framework element. + public SingleGraphElementEditor(SingleGraphItem graphItem) + : this() + { + GraphItem = graphItem; + } + + /// + /// Initializes a new instance of the class. + /// + /// The framework element. + /// The bounds. + public SingleGraphElementEditor(SingleGraphItem graphItem, Rect bounds) + : this(graphItem) + { + Left = bounds.Left; + Top = bounds.Top; + Width = bounds.Width; + Height = bounds.Height; + } + + private SingleGraphItem _monitorItem; + + public SingleGraphItem GraphItem + { + get { return _monitorItem; } + set { _monitorItem = value; RaisePropertyChanged(nameof(GraphItem)); } + } + + + /// + /// Clones this instance. + /// + /// + public override IElementEditor Clone() + { + try + { + SingleGraphElementEditor cloned = new SingleGraphElementEditor(); + + cloned.GraphItem = GraphItem.Clone() as SingleGraphItem; + 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); + } + } + + /// + /// Gets the hosted element. + /// + [ParameterIgnore] + public override Object HostedElement + { + get { return GraphItem; } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/analog.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/analog.png new file mode 100644 index 000000000..2651a64b0 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/analog.png differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/graph.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/graph.png new file mode 100644 index 000000000..0aca05e00 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/graph.png differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/single-graph.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/single-graph.png new file mode 100644 index 000000000..f72f56a87 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/single-graph.png differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Items/MonitorItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Items/MonitorItem.cs deleted file mode 100644 index 4150e3784..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Items/MonitorItem.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Integration.Observables; - -namespace Tango.MachineStudio.Technician.Items -{ - public class MonitorItem : TechItem - { - private TechMonitor _techMonitor; - public TechMonitor TechMonitor - { - get { return _techMonitor; } - set { _techMonitor = value; RaisePropertyChangedAuto(); } - } - - private double _value; - public double Value - { - get { return _value; } - set { _value = value; RaisePropertyChanged(nameof(Value)); } - } - - public MonitorItem() : base() - { - - } - - public MonitorItem(TechMonitor techMonitor) : this() - { - TechMonitor = techMonitor; - } - - public override TechItem Clone() - { - MonitorItem cloned = base.Clone() as MonitorItem; - cloned.TechMonitor = TechMonitor; - return cloned; - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Items/TechItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Items/TechItem.cs deleted file mode 100644 index bfeeef011..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Items/TechItem.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Core; - -namespace Tango.MachineStudio.Technician.Items -{ - public abstract class TechItem : ExtendedObject - { - public TechItem() - { - ID = Guid.NewGuid().ToString(); - Name = "Untitled"; - } - - private String _id; - /// - /// Unique Item ID. - /// - public String ID - { - get { return _id; } - set { _id = value; RaisePropertyChanged(nameof(ID)); } - } - - private String _name; - /// - /// item Name. - /// - public String Name - { - get { return _name; } - set { _name = value; RaisePropertyChanged(nameof(Name)); } - } - - private double _left; - /// - /// Item Left. - /// - public double Left - { - get { return _left; } - set { _left = value; RaisePropertyChanged(nameof(Left)); } - } - - private double _top; - /// - /// Item Top. - /// - public double Top - { - get { return _top; } - set { _top = value; RaisePropertyChanged(nameof(Top)); } - } - - private double _width; - /// - /// Item Width. - /// - public double Width - { - get { return _width; } - set { _width = value; RaisePropertyChanged(nameof(Width)); } - } - - private double _height; - /// - /// Item Height. - /// - public double Height - { - get { return _height; } - set { _height = value; RaisePropertyChanged(nameof(Height)); } - } - - private double _angle; - /// - /// Item Angle. - /// - public double Angle - { - get { return _angle; } - set { _angle = value; RaisePropertyChanged(nameof(Angle)); } - } - - public virtual TechItem Clone() - { - TechItem cloned = Activator.CreateInstance(this.GetType()) as TechItem; - cloned.Left = Left; - cloned.Top = Top; - cloned.Width = Width; - cloned.Height = Height; - cloned.Angle = Angle; - return cloned; - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorTemplate.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorTemplate.xaml new file mode 100644 index 000000000..66e0e5cba --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorTemplate.xaml @@ -0,0 +1,22 @@ + + + + + + + + + Selected Input + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorTemplate.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorTemplate.xaml.cs new file mode 100644 index 000000000..8b5396ffc --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorTemplate.xaml.cs @@ -0,0 +1,28 @@ +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; + +namespace Tango.MachineStudio.Technician.PropertiesTemplates +{ + /// + /// Interaction logic for MonitorTemplate.xaml + /// + public partial class MonitorTemplate : UserControl + { + public MonitorTemplate() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/SingleGraphTemplate.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/SingleGraphTemplate.xaml new file mode 100644 index 000000000..098e7a3dd --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/SingleGraphTemplate.xaml @@ -0,0 +1,22 @@ + + + + + + + + + Selected Input + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/SingleGraphTemplate.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/SingleGraphTemplate.xaml.cs new file mode 100644 index 000000000..4ccb703b4 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/SingleGraphTemplate.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 +{ + /// + /// Interaction logic for SingleGraphTemplate.xaml + /// + public partial class SingleGraphTemplate : UserControl + { + public SingleGraphTemplate() + { + 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 6d3ae9c1a..05ab7cc38 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,14 +77,25 @@ + + + SingleGraphElementEditor.xaml + MonitorElementEditor.xaml - - + + MonitorTemplate.xaml + + + SingleGraphTemplate.xaml + + + + @@ -110,10 +121,22 @@ GlobalVersionInfo.cs + + MSBuild:Compile + Designer + MSBuild:Compile Designer + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -213,5 +236,14 @@ + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MonitorItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MonitorItem.cs new file mode 100644 index 000000000..cc1ca4083 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MonitorItem.cs @@ -0,0 +1,51 @@ +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.SharedUI.Helpers; + +namespace Tango.MachineStudio.Technician.TechItems +{ + public class MonitorItem : TechItem + { + private TechMonitor _techMonitor; + [XmlIgnore] + public TechMonitor TechMonitor + { + get { return _techMonitor; } + set { _techMonitor = value; RaisePropertyChangedAuto(); RaisePropertyChanged(nameof(Data)); } + } + + private double _value; + [XmlIgnore] + public double Value + { + get { return _value; } + set { _value = value; RaisePropertyChanged(nameof(Value)); } + } + + public override object Data => TechMonitor; + + public MonitorItem() : base() + { + Name = "Monitor"; + Description = "Simple analogue like monitor"; + Image = ResourceHelper.GetImageFromResources("Images/analog.png"); + } + + public MonitorItem(TechMonitor techMonitor) : this() + { + TechMonitor = techMonitor; + } + + public override TechItem Clone() + { + MonitorItem cloned = base.Clone() as MonitorItem; + 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 new file mode 100644 index 000000000..9ce559047 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/SingleGraphItem.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 SingleGraphItem : 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 SingleGraphElementEditor Editor { get; set; } + + public override object Data => TechMonitor; + + public SingleGraphItem() : base() + { + Name = "Single Channel Graph"; + Description = "Single channel real-time graph"; + Image = ResourceHelper.GetImageFromResources("Images/single-graph.png"); + } + + public SingleGraphItem(TechMonitor techMonitor) : this() + { + TechMonitor = techMonitor; + } + + public override TechItem Clone() + { + MonitorItem cloned = base.Clone() as MonitorItem; + cloned.TechMonitor = TechMonitor; + return cloned; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/TechItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/TechItem.cs new file mode 100644 index 000000000..820c765cc --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/TechItem.cs @@ -0,0 +1,138 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media.Imaging; +using System.Xml.Serialization; +using Tango.Core; +using Tango.Integration.Observables; + +namespace Tango.MachineStudio.Technician.TechItems +{ + public abstract class TechItem : ExtendedObject + { + public TechItem() + { + ID = Guid.NewGuid().ToString(); + Name = "Untitled"; + Adapter = ObservablesEntitiesAdapter.Instance; + } + + private String _description; + [XmlIgnore] + public String Description + { + get { return _description; } + set { _description = value; RaisePropertyChangedAuto(); } + } + + private BitmapSource _image; + [XmlIgnore] + public BitmapSource Image + { + get { return _image; } + set { _image = value; RaisePropertyChangedAuto(); } + } + + [XmlIgnore] + public ObservablesEntitiesAdapter Adapter { get; set; } + + private String _id; + /// + /// Unique Item ID. + /// + public String ID + { + get { return _id; } + set { _id = value; RaisePropertyChanged(nameof(ID)); } + } + + private String _name; + /// + /// item Name. + /// + [XmlIgnore] + public String Name + { + get { return _name; } + set { _name = value; RaisePropertyChanged(nameof(Name)); } + } + + private double _left; + /// + /// Item Left. + /// + public double Left + { + get { return _left; } + set { _left = value; RaisePropertyChanged(nameof(Left)); } + } + + private double _top; + /// + /// Item Top. + /// + public double Top + { + get { return _top; } + set { _top = value; RaisePropertyChanged(nameof(Top)); } + } + + private double _width; + /// + /// Item Width. + /// + public double Width + { + get { return _width; } + set { _width = value; RaisePropertyChanged(nameof(Width)); } + } + + private double _height; + /// + /// Item Height. + /// + public double Height + { + get { return _height; } + set { _height = value; RaisePropertyChanged(nameof(Height)); } + } + + private double _angle; + /// + /// Item Angle. + /// + public double Angle + { + get { return _angle; } + set { _angle = value; RaisePropertyChanged(nameof(Angle)); } + } + + [XmlIgnore] + public abstract object Data { get; } + + public virtual TechItem Clone() + { + TechItem cloned = Activator.CreateInstance(this.GetType()) as TechItem; + cloned.Left = Left; + cloned.Top = Top; + cloned.Width = Width; + cloned.Height = Height; + cloned.Angle = Angle; + return cloned; + } + + public static List GetAvailableTechItems() + { + List items = new List(); + + foreach (var type in typeof(TechItem).Assembly.GetTypes().Where(x => typeof(TechItem).IsAssignableFrom(x) && !x.IsAbstract)) + { + items.Add(Activator.CreateInstance(type) as TechItem); + } + + return items; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechnicianModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechnicianModule.cs index 6bdc4c7df..c75bcdf29 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechnicianModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechnicianModule.cs @@ -43,7 +43,7 @@ namespace Tango.MachineStudio.Technician /// /// Gets the module entry point view. /// - public FrameworkElement MainView => new MainView(); + public FrameworkElement MainView => new MachineTechView(); /// /// Gets the permission required to see and load this module. 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 51c2b840d..4420aa4c9 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,42 +1,179 @@ -using System; +using Google.Protobuf.Collections; +using RealTimeGraphEx.Controllers; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; +using System.Reflection; using System.Text; using System.Threading.Tasks; using System.Windows; using Tango.Editors; using Tango.Integration.Observables; +using Tango.Integration.Operators; +using Tango.MachineStudio.Common.StudioApplication; using Tango.MachineStudio.Technician.Editors; -using Tango.MachineStudio.Technician.Items; +using Tango.MachineStudio.Technician.TechItems; +using Tango.PMR.Diagnostics; using Tango.SharedUI; namespace Tango.MachineStudio.Technician.ViewModels { public class MachineTechViewVM : ViewModel { - private ObservableCollection _elements; + private List _diagnoticsDataProperties; + private Dictionary _singleControllers; + private static object _elementsLock = new object(); + private ObservableCollection _elements; public ObservableCollection Elements { get { return _elements; } set { _elements = value; RaisePropertyChangedAuto(); } } + private ObservableCollection _availableTechItems; + public ObservableCollection AvailableTechItems + { + get { return _availableTechItems; } + set { _availableTechItems = value; RaisePropertyChangedAuto(); } + } + + private TechItem _selectedTechItem; + + public TechItem SelectedTechItem + { + get { return _selectedTechItem; } + set { _selectedTechItem = value; RaisePropertyChangedAuto(); } + } + public ObservablesEntitiesAdapter Adapter { get; set; } - public MachineTechViewVM() + public IStudioApplicationManager ApplicationManager { get; set; } + + private IMachineOperator _machineOperator; + + public IMachineOperator MachineOperator { + get { return _machineOperator; } + set { _machineOperator = value; RaisePropertyChangedAuto(); } + } + + public MachineTechViewVM(IStudioApplicationManager applicationManager) + { + _singleControllers = new Dictionary(); + AvailableTechItems = TechItem.GetAvailableTechItems().ToObservableCollection(); + SelectedTechItem = AvailableTechItems.FirstOrDefault(); + _diagnoticsDataProperties = typeof(PushDiagnosticsResponse).GetProperties(BindingFlags.Public | BindingFlags.Instance).ToList(); + ApplicationManager = applicationManager; + ApplicationManager.ConnectedMachineChanged += ApplicationManager_ConnectedMachineChanged; + Adapter = ObservablesEntitiesAdapter.Instance; - Adapter.Initialize(); //TODO: Remove on Machine Studio. + //Adapter.Initialize(); //TODO: Remove on Machine Studio. Elements = new ObservableCollection(); } + private void ApplicationManager_ConnectedMachineChanged(object sender, Integration.Services.IExternalBridgeClient machine) + { + MachineOperator = machine; + + if (MachineOperator != null) + { + MachineOperator.DiagnosticsDataAvailable -= MachineOperator_DiagnosticsDataAvailable; + MachineOperator.DiagnosticsDataAvailable += MachineOperator_DiagnosticsDataAvailable; + } + } + + private void MachineOperator_DiagnosticsDataAvailable(object sender, PushDiagnosticsResponse response) + { + PopulateDiagnosticsData(response); + } + + private void PopulateDiagnosticsData(PushDiagnosticsResponse data) + { + lock (_elementsLock) + { + var elements = Elements.ToList(); + + foreach (var item in elements.Select(x => x.HostedElement as TechItem)) + { + if (item.GetType() == typeof(MonitorItem)) + { + MonitorItem monitorItem = item as MonitorItem; + + var prop = _diagnoticsDataProperties.SingleOrDefault(x => x.Name == monitorItem.TechMonitor.Name); + + if (prop != null) + { + monitorItem.Value = GetLastMonitorValue(monitorItem.TechMonitor, prop.GetValue(data)); + } + } + else if (item.GetType() == typeof(SingleGraphItem)) + { + SingleGraphItem graphItem = item as SingleGraphItem; + + var prop = _diagnoticsDataProperties.SingleOrDefault(x => x.Name == graphItem.TechMonitor.Name); + + if (prop != null) + { + GraphController controller = null; + + if (_singleControllers.TryGetValue(graphItem, out controller)) + { + controller.PushData(GetSingleGraphValues(graphItem.TechMonitor, prop.GetValue(data))); + } + } + } + } + } + } + + private double GetLastMonitorValue(TechMonitor monitor, object value) + { + if (!monitor.MultiChannel) + { + RepeatedField arr = value as RepeatedField; + return arr.LastOrDefault(); + } + else + { + RepeatedField arr = value as RepeatedField; + return arr.Last().Data.Last(); + } + } + + private List GetSingleGraphValues(TechMonitor monitor, object value) + { + return (value as RepeatedField).ToList(); + } + public void AddElement(Rect bounds) { - MonitorItem item = new MonitorItem(Adapter.TechMonitors.FirstOrDefault()); - MonitorElementEditor editor = new MonitorElementEditor(item, bounds); - Elements.Add(editor); + lock (_elementsLock) + { + if (SelectedTechItem is MonitorItem) + { + var monitorItem = new MonitorItem(Adapter.TechMonitors.FirstOrDefault()); + MonitorElementEditor editor = new MonitorElementEditor(monitorItem, bounds); + Elements.Add(editor); + } + else if (SelectedTechItem is SingleGraphItem) + { + var graphItem = new SingleGraphItem(Adapter.TechMonitors.FirstOrDefault()); + SingleGraphElementEditor editor = new SingleGraphElementEditor(graphItem, bounds); + editor.InnerGraph.InnerGraph.MaxPoints = Common.Helpers.GraphsHelper.GetMaxPoints(graphItem.TechMonitor.PointsPerFrame); + editor.DataContext = graphItem; + graphItem.Editor = editor; + + + GraphController controller = new GraphController(); + editor.InnerGraph.Controller = controller; + + _singleControllers.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 256a4a385..371caf5d7 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 @@ -5,8 +5,11 @@ xmlns:vm="clr-namespace:Tango.MachineStudio.Technician.ViewModels" xmlns:global="clr-namespace:Tango.MachineStudio.Technician" xmlns:editors="clr-namespace:Tango.Editors;assembly=Tango.Editors" + xmlns:techItems="clr-namespace:Tango.MachineStudio.Technician.TechItems" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:templates="clr-namespace:Tango.MachineStudio.Technician.PropertiesTemplates" + xmlns:items="clr-namespace:Tango.MachineStudio.Technician.TechItems" xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:Tango.MachineStudio.Technician.Views" @@ -37,7 +40,34 @@ - + + + + + + + + + + + + + + + + + + + @@ -49,12 +79,15 @@ - - - + + + + + + + + Left + + + + Top + + + + + + + + Width + + + + Height + + + + + + + + + + + Angle + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml index 449cea493..0f9edee55 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml @@ -62,12 +62,12 @@ - - + + - + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml.cs index c1728a975..57d5ab88a 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml.cs @@ -50,6 +50,35 @@ namespace Tango.MachineStudio.Common.Controls public static readonly DependencyProperty SensorUnitsProperty = DependencyProperty.Register("SensorUnits", typeof(String), typeof(RealTimeGraphControl), 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(RealTimeGraphControl), 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(RealTimeGraphControl), new PropertyMetadata(100.0)); + + + + public void InvalidateGraph() + { + InnerGraph.Clear(); + yAxis.Render(InnerGraph); + yAxisTicks.Render(InnerGraph); + } + /// /// Gets or sets the inner real-time graph control. /// diff --git a/Software/Visual_Studio/SideChains/RealTimeGraphEx/RealTimeGraphExBase.cs b/Software/Visual_Studio/SideChains/RealTimeGraphEx/RealTimeGraphExBase.cs index 16264aa4b..f0c612608 100644 --- a/Software/Visual_Studio/SideChains/RealTimeGraphEx/RealTimeGraphExBase.cs +++ b/Software/Visual_Studio/SideChains/RealTimeGraphEx/RealTimeGraphExBase.cs @@ -901,7 +901,6 @@ namespace RealTimeGraphEx { } - #endregion #region Protected Methods @@ -1051,6 +1050,16 @@ namespace RealTimeGraphEx return b; } + public void Clear() + { + ClearGraph(); + } + + public void RenderComponents() + { + OnRenderComponents(); + } + #endregion #region Static Methods diff --git a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs index 197e4f369..87fddc183 100644 --- a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs +++ b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs @@ -143,6 +143,15 @@ namespace Tango.Emulations.Emulators } res.DispensersMotorsFrequency.AddRange(dispenserFrequencies); + + res.Dispenser1MotorFrequency.AddRange(dispenserFrequencies[0].Data); + res.Dispenser2MotorFrequency.AddRange(dispenserFrequencies[1].Data); + res.Dispenser3MotorFrequency.AddRange(dispenserFrequencies[2].Data); + res.Dispenser4MotorFrequency.AddRange(dispenserFrequencies[3].Data); + res.Dispenser5MotorFrequency.AddRange(dispenserFrequencies[4].Data); + res.Dispenser6MotorFrequency.AddRange(dispenserFrequencies[5].Data); + res.Dispenser7MotorFrequency.AddRange(dispenserFrequencies[6].Data); + res.Dispenser8MotorFrequency.AddRange(dispenserFrequencies[7].Data); } Transporter.SendResponse(res, container.Token); diff --git a/Software/Visual_Studio/Tango.PMR/Diagnostics/PushDiagnosticsResponse.cs b/Software/Visual_Studio/Tango.PMR/Diagnostics/PushDiagnosticsResponse.cs index 85fba5d22..d654f77a1 100644 --- a/Software/Visual_Studio/Tango.PMR/Diagnostics/PushDiagnosticsResponse.cs +++ b/Software/Visual_Studio/Tango.PMR/Diagnostics/PushDiagnosticsResponse.cs @@ -23,16 +23,22 @@ namespace Tango.PMR.Diagnostics { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( "Ch1QdXNoRGlhZ25vc3RpY3NSZXNwb25zZS5wcm90bxIVVGFuZ28uUE1SLkRp", - "YWdub3N0aWNzGhFEb3VibGVBcnJheS5wcm90byKiAQoXUHVzaERpYWdub3N0", + "YWdub3N0aWNzGhFEb3VibGVBcnJheS5wcm90byKyAwoXUHVzaERpYWdub3N0", "aWNzUmVzcG9uc2USFAoMRGFuY2VyMUFuZ2xlGAEgAygBEhQKDERhbmNlcjJB", "bmdsZRgCIAMoARIUCgxEYW5jZXIzQW5nbGUYAyADKAESRQoZRGlzcGVuc2Vy", "c01vdG9yc0ZyZXF1ZW5jeRgEIAMoCzIiLlRhbmdvLlBNUi5EaWFnbm9zdGlj", - "cy5Eb3VibGVBcnJheUIhCh9jb20udHdpbmUudGFuZ28ucG1yLmRpYWdub3N0", - "aWNzYgZwcm90bzM=")); + "cy5Eb3VibGVBcnJheRIgChhEaXNwZW5zZXIxTW90b3JGcmVxdWVuY3kYBSAD", + "KAESIAoYRGlzcGVuc2VyMk1vdG9yRnJlcXVlbmN5GAYgAygBEiAKGERpc3Bl", + "bnNlcjNNb3RvckZyZXF1ZW5jeRgHIAMoARIgChhEaXNwZW5zZXI0TW90b3JG", + "cmVxdWVuY3kYCCADKAESIAoYRGlzcGVuc2VyNU1vdG9yRnJlcXVlbmN5GAkg", + "AygBEiAKGERpc3BlbnNlcjZNb3RvckZyZXF1ZW5jeRgKIAMoARIgChhEaXNw", + "ZW5zZXI3TW90b3JGcmVxdWVuY3kYCyADKAESIAoYRGlzcGVuc2VyOE1vdG9y", + "RnJlcXVlbmN5GAwgAygBQiEKH2NvbS50d2luZS50YW5nby5wbXIuZGlhZ25v", + "c3RpY3NiBnByb3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Tango.PMR.Diagnostics.DoubleArrayReflection.Descriptor, }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Diagnostics.PushDiagnosticsResponse), global::Tango.PMR.Diagnostics.PushDiagnosticsResponse.Parser, new[]{ "Dancer1Angle", "Dancer2Angle", "Dancer3Angle", "DispensersMotorsFrequency" }, null, null, null) + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Diagnostics.PushDiagnosticsResponse), global::Tango.PMR.Diagnostics.PushDiagnosticsResponse.Parser, new[]{ "Dancer1Angle", "Dancer2Angle", "Dancer3Angle", "DispensersMotorsFrequency", "Dispenser1MotorFrequency", "Dispenser2MotorFrequency", "Dispenser3MotorFrequency", "Dispenser4MotorFrequency", "Dispenser5MotorFrequency", "Dispenser6MotorFrequency", "Dispenser7MotorFrequency", "Dispenser8MotorFrequency" }, null, null, null) })); } #endregion @@ -67,6 +73,14 @@ namespace Tango.PMR.Diagnostics { dancer2Angle_ = other.dancer2Angle_.Clone(); dancer3Angle_ = other.dancer3Angle_.Clone(); dispensersMotorsFrequency_ = other.dispensersMotorsFrequency_.Clone(); + dispenser1MotorFrequency_ = other.dispenser1MotorFrequency_.Clone(); + dispenser2MotorFrequency_ = other.dispenser2MotorFrequency_.Clone(); + dispenser3MotorFrequency_ = other.dispenser3MotorFrequency_.Clone(); + dispenser4MotorFrequency_ = other.dispenser4MotorFrequency_.Clone(); + dispenser5MotorFrequency_ = other.dispenser5MotorFrequency_.Clone(); + dispenser6MotorFrequency_ = other.dispenser6MotorFrequency_.Clone(); + dispenser7MotorFrequency_ = other.dispenser7MotorFrequency_.Clone(); + dispenser8MotorFrequency_ = other.dispenser8MotorFrequency_.Clone(); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -109,11 +123,97 @@ namespace Tango.PMR.Diagnostics { private static readonly pb::FieldCodec _repeated_dispensersMotorsFrequency_codec = pb::FieldCodec.ForMessage(34, global::Tango.PMR.Diagnostics.DoubleArray.Parser); private readonly pbc::RepeatedField dispensersMotorsFrequency_ = new pbc::RepeatedField(); + /// + ///Dispensers Motors Frequency Multi + /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField DispensersMotorsFrequency { get { return dispensersMotorsFrequency_; } } + /// Field number for the "Dispenser1MotorFrequency" field. + public const int Dispenser1MotorFrequencyFieldNumber = 5; + private static readonly pb::FieldCodec _repeated_dispenser1MotorFrequency_codec + = pb::FieldCodec.ForDouble(42); + private readonly pbc::RepeatedField dispenser1MotorFrequency_ = new pbc::RepeatedField(); + /// + ///Dispensers Motors Frequency Singles + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField Dispenser1MotorFrequency { + get { return dispenser1MotorFrequency_; } + } + + /// Field number for the "Dispenser2MotorFrequency" field. + public const int Dispenser2MotorFrequencyFieldNumber = 6; + private static readonly pb::FieldCodec _repeated_dispenser2MotorFrequency_codec + = pb::FieldCodec.ForDouble(50); + private readonly pbc::RepeatedField dispenser2MotorFrequency_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField Dispenser2MotorFrequency { + get { return dispenser2MotorFrequency_; } + } + + /// Field number for the "Dispenser3MotorFrequency" field. + public const int Dispenser3MotorFrequencyFieldNumber = 7; + private static readonly pb::FieldCodec _repeated_dispenser3MotorFrequency_codec + = pb::FieldCodec.ForDouble(58); + private readonly pbc::RepeatedField dispenser3MotorFrequency_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField Dispenser3MotorFrequency { + get { return dispenser3MotorFrequency_; } + } + + /// Field number for the "Dispenser4MotorFrequency" field. + public const int Dispenser4MotorFrequencyFieldNumber = 8; + private static readonly pb::FieldCodec _repeated_dispenser4MotorFrequency_codec + = pb::FieldCodec.ForDouble(66); + private readonly pbc::RepeatedField dispenser4MotorFrequency_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField Dispenser4MotorFrequency { + get { return dispenser4MotorFrequency_; } + } + + /// Field number for the "Dispenser5MotorFrequency" field. + public const int Dispenser5MotorFrequencyFieldNumber = 9; + private static readonly pb::FieldCodec _repeated_dispenser5MotorFrequency_codec + = pb::FieldCodec.ForDouble(74); + private readonly pbc::RepeatedField dispenser5MotorFrequency_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField Dispenser5MotorFrequency { + get { return dispenser5MotorFrequency_; } + } + + /// Field number for the "Dispenser6MotorFrequency" field. + public const int Dispenser6MotorFrequencyFieldNumber = 10; + private static readonly pb::FieldCodec _repeated_dispenser6MotorFrequency_codec + = pb::FieldCodec.ForDouble(82); + private readonly pbc::RepeatedField dispenser6MotorFrequency_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField Dispenser6MotorFrequency { + get { return dispenser6MotorFrequency_; } + } + + /// Field number for the "Dispenser7MotorFrequency" field. + public const int Dispenser7MotorFrequencyFieldNumber = 11; + private static readonly pb::FieldCodec _repeated_dispenser7MotorFrequency_codec + = pb::FieldCodec.ForDouble(90); + private readonly pbc::RepeatedField dispenser7MotorFrequency_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField Dispenser7MotorFrequency { + get { return dispenser7MotorFrequency_; } + } + + /// Field number for the "Dispenser8MotorFrequency" field. + public const int Dispenser8MotorFrequencyFieldNumber = 12; + private static readonly pb::FieldCodec _repeated_dispenser8MotorFrequency_codec + = pb::FieldCodec.ForDouble(98); + private readonly pbc::RepeatedField dispenser8MotorFrequency_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField Dispenser8MotorFrequency { + get { return dispenser8MotorFrequency_; } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as PushDiagnosticsResponse); @@ -131,6 +231,14 @@ namespace Tango.PMR.Diagnostics { if(!dancer2Angle_.Equals(other.dancer2Angle_)) return false; if(!dancer3Angle_.Equals(other.dancer3Angle_)) return false; if(!dispensersMotorsFrequency_.Equals(other.dispensersMotorsFrequency_)) return false; + if(!dispenser1MotorFrequency_.Equals(other.dispenser1MotorFrequency_)) return false; + if(!dispenser2MotorFrequency_.Equals(other.dispenser2MotorFrequency_)) return false; + if(!dispenser3MotorFrequency_.Equals(other.dispenser3MotorFrequency_)) return false; + if(!dispenser4MotorFrequency_.Equals(other.dispenser4MotorFrequency_)) return false; + if(!dispenser5MotorFrequency_.Equals(other.dispenser5MotorFrequency_)) return false; + if(!dispenser6MotorFrequency_.Equals(other.dispenser6MotorFrequency_)) return false; + if(!dispenser7MotorFrequency_.Equals(other.dispenser7MotorFrequency_)) return false; + if(!dispenser8MotorFrequency_.Equals(other.dispenser8MotorFrequency_)) return false; return true; } @@ -141,6 +249,14 @@ namespace Tango.PMR.Diagnostics { hash ^= dancer2Angle_.GetHashCode(); hash ^= dancer3Angle_.GetHashCode(); hash ^= dispensersMotorsFrequency_.GetHashCode(); + hash ^= dispenser1MotorFrequency_.GetHashCode(); + hash ^= dispenser2MotorFrequency_.GetHashCode(); + hash ^= dispenser3MotorFrequency_.GetHashCode(); + hash ^= dispenser4MotorFrequency_.GetHashCode(); + hash ^= dispenser5MotorFrequency_.GetHashCode(); + hash ^= dispenser6MotorFrequency_.GetHashCode(); + hash ^= dispenser7MotorFrequency_.GetHashCode(); + hash ^= dispenser8MotorFrequency_.GetHashCode(); return hash; } @@ -155,6 +271,14 @@ namespace Tango.PMR.Diagnostics { dancer2Angle_.WriteTo(output, _repeated_dancer2Angle_codec); dancer3Angle_.WriteTo(output, _repeated_dancer3Angle_codec); dispensersMotorsFrequency_.WriteTo(output, _repeated_dispensersMotorsFrequency_codec); + dispenser1MotorFrequency_.WriteTo(output, _repeated_dispenser1MotorFrequency_codec); + dispenser2MotorFrequency_.WriteTo(output, _repeated_dispenser2MotorFrequency_codec); + dispenser3MotorFrequency_.WriteTo(output, _repeated_dispenser3MotorFrequency_codec); + dispenser4MotorFrequency_.WriteTo(output, _repeated_dispenser4MotorFrequency_codec); + dispenser5MotorFrequency_.WriteTo(output, _repeated_dispenser5MotorFrequency_codec); + dispenser6MotorFrequency_.WriteTo(output, _repeated_dispenser6MotorFrequency_codec); + dispenser7MotorFrequency_.WriteTo(output, _repeated_dispenser7MotorFrequency_codec); + dispenser8MotorFrequency_.WriteTo(output, _repeated_dispenser8MotorFrequency_codec); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -164,6 +288,14 @@ namespace Tango.PMR.Diagnostics { size += dancer2Angle_.CalculateSize(_repeated_dancer2Angle_codec); size += dancer3Angle_.CalculateSize(_repeated_dancer3Angle_codec); size += dispensersMotorsFrequency_.CalculateSize(_repeated_dispensersMotorsFrequency_codec); + size += dispenser1MotorFrequency_.CalculateSize(_repeated_dispenser1MotorFrequency_codec); + size += dispenser2MotorFrequency_.CalculateSize(_repeated_dispenser2MotorFrequency_codec); + size += dispenser3MotorFrequency_.CalculateSize(_repeated_dispenser3MotorFrequency_codec); + size += dispenser4MotorFrequency_.CalculateSize(_repeated_dispenser4MotorFrequency_codec); + size += dispenser5MotorFrequency_.CalculateSize(_repeated_dispenser5MotorFrequency_codec); + size += dispenser6MotorFrequency_.CalculateSize(_repeated_dispenser6MotorFrequency_codec); + size += dispenser7MotorFrequency_.CalculateSize(_repeated_dispenser7MotorFrequency_codec); + size += dispenser8MotorFrequency_.CalculateSize(_repeated_dispenser8MotorFrequency_codec); return size; } @@ -176,6 +308,14 @@ namespace Tango.PMR.Diagnostics { dancer2Angle_.Add(other.dancer2Angle_); dancer3Angle_.Add(other.dancer3Angle_); dispensersMotorsFrequency_.Add(other.dispensersMotorsFrequency_); + dispenser1MotorFrequency_.Add(other.dispenser1MotorFrequency_); + dispenser2MotorFrequency_.Add(other.dispenser2MotorFrequency_); + dispenser3MotorFrequency_.Add(other.dispenser3MotorFrequency_); + dispenser4MotorFrequency_.Add(other.dispenser4MotorFrequency_); + dispenser5MotorFrequency_.Add(other.dispenser5MotorFrequency_); + dispenser6MotorFrequency_.Add(other.dispenser6MotorFrequency_); + dispenser7MotorFrequency_.Add(other.dispenser7MotorFrequency_); + dispenser8MotorFrequency_.Add(other.dispenser8MotorFrequency_); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -205,6 +345,46 @@ namespace Tango.PMR.Diagnostics { dispensersMotorsFrequency_.AddEntriesFrom(input, _repeated_dispensersMotorsFrequency_codec); break; } + case 42: + case 41: { + dispenser1MotorFrequency_.AddEntriesFrom(input, _repeated_dispenser1MotorFrequency_codec); + break; + } + case 50: + case 49: { + dispenser2MotorFrequency_.AddEntriesFrom(input, _repeated_dispenser2MotorFrequency_codec); + break; + } + case 58: + case 57: { + dispenser3MotorFrequency_.AddEntriesFrom(input, _repeated_dispenser3MotorFrequency_codec); + break; + } + case 66: + case 65: { + dispenser4MotorFrequency_.AddEntriesFrom(input, _repeated_dispenser4MotorFrequency_codec); + break; + } + case 74: + case 73: { + dispenser5MotorFrequency_.AddEntriesFrom(input, _repeated_dispenser5MotorFrequency_codec); + break; + } + case 82: + case 81: { + dispenser6MotorFrequency_.AddEntriesFrom(input, _repeated_dispenser6MotorFrequency_codec); + break; + } + case 90: + case 89: { + dispenser7MotorFrequency_.AddEntriesFrom(input, _repeated_dispenser7MotorFrequency_codec); + break; + } + case 98: + case 97: { + dispenser8MotorFrequency_.AddEntriesFrom(input, _repeated_dispenser8MotorFrequency_codec); + break; + } } } } -- cgit v1.3.1 From 1b74cee6e9073f3542b4733574ab304f40fc033b Mon Sep 17 00:00:00 2001 From: Roy Date: Thu, 8 Feb 2018 23:53:00 +0200 Subject: Working on MachineTechView.. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 8388608 -> 8388608 bytes Software/Graphics/box.png | Bin 0 -> 64765 bytes Software/Graphics/glass.png | Bin 0 -> 17468 bytes Software/Graphics/white-box.png | Bin 0 -> 56987 bytes .../Editors/MonitorElementEditor.xaml | 24 +++++++++++++--- .../Editors/SingleGraphElementEditor.xaml | 4 +-- .../Tango.MachineStudio.Technician/Images/box.png | Bin 0 -> 64765 bytes .../Images/seamless-grid.jpg | Bin 0 -> 12022 bytes .../Images/white-box.png | Bin 0 -> 56987 bytes .../PropertiesTemplates/MonitorTemplate.xaml | 18 +++++++++++- .../PropertiesTemplates/SingleGraphTemplate.xaml | 12 ++++++++ .../Tango.MachineStudio.Technician.csproj | 13 +++++++++ .../TechItems/MonitorItem.cs | 18 ++++++++++-- .../TechItems/TechItem.cs | 10 +++++++ .../ViewModels/MachineTechViewVM.cs | 12 +++++--- .../Views/MachineTechView.xaml | 31 +++++++++++++-------- .../Controls/RealTimeGraphControl.xaml | 4 +-- .../Controls/RealTimeGraphControl.xaml.cs | 10 +++++++ .../Tango.MachineStudio.UI/ViewModelLocator.cs | 8 ++++++ 20 files changed, 138 insertions(+), 26 deletions(-) create mode 100644 Software/Graphics/box.png create mode 100644 Software/Graphics/glass.png create mode 100644 Software/Graphics/white-box.png create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/box.png create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/seamless-grid.jpg create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/white-box.png (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 8f36c9d40..5be040772 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 29ebe00a1..85a0b368d 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Graphics/box.png b/Software/Graphics/box.png new file mode 100644 index 000000000..105de7979 Binary files /dev/null and b/Software/Graphics/box.png differ diff --git a/Software/Graphics/glass.png b/Software/Graphics/glass.png new file mode 100644 index 000000000..eeb67d27c Binary files /dev/null and b/Software/Graphics/glass.png differ diff --git a/Software/Graphics/white-box.png b/Software/Graphics/white-box.png new file mode 100644 index 000000000..aee42d95a Binary files /dev/null and b/Software/Graphics/white-box.png differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml index 84eae5f75..8e4520cc5 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml @@ -3,10 +3,11 @@ 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:items="clr-namespace:Tango.MachineStudio.Technician.TechItems" xmlns:converters="clr-namespace:Tango.Editors.Converters;assembly=Tango.Editors" xmlns:local="clr-namespace:Tango.Editors;assembly=Tango.Editors" mc:Ignorable="d" - d:DesignHeight="300" d:DesignWidth="300" Background="Transparent" ClipToBounds="False" BorderThickness="0" MinWidth="1" MinHeight="1" RenderTransformOrigin="0.5,0.5"> + d:DesignHeight="250" d:DesignWidth="300" Background="Transparent" ClipToBounds="False" BorderThickness="0" MinWidth="1" MinHeight="1" RenderTransformOrigin="0.5,0.5" d:DataContext="{d:DesignInstance Type=items:MonitorItem, IsDesignTimeCreatable=False}"> @@ -28,12 +29,27 @@ - + - + - + + + + + + + + + + + + + + + + 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 eafc7b5d3..02acf5883 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 @@ -8,7 +8,7 @@ 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:MonitorItem, IsDesignTimeCreatable=False}"> + 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:SingleGraphItem, IsDesignTimeCreatable=False}"> @@ -28,7 +28,7 @@ - + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/box.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/box.png new file mode 100644 index 000000000..105de7979 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/box.png differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/seamless-grid.jpg b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/seamless-grid.jpg new file mode 100644 index 000000000..59bb9c370 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/seamless-grid.jpg differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/white-box.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/white-box.png new file mode 100644 index 000000000..aee42d95a Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/white-box.png differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorTemplate.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorTemplate.xaml index 66e0e5cba..f87926d28 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorTemplate.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorTemplate.xaml @@ -5,18 +5,34 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:converters="clr-namespace:Tango.MachineStudio.Technician.Converters" xmlns:items="clr-namespace:Tango.MachineStudio.Technician.TechItems" + xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:colorPicker="clr-namespace:Tango;assembly=Tango.ColorPicker" xmlns:local="clr-namespace:Tango.MachineStudio.Technician.PropertiesTemplates" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="200" d:DataContext="{d:DesignInstance Type=items:MonitorItem, IsDesignTimeCreatable=False}"> + + - + Selected Input + + Update Interval + + + Color + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/SingleGraphTemplate.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/SingleGraphTemplate.xaml index 098e7a3dd..bc31f8b31 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/SingleGraphTemplate.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/SingleGraphTemplate.xaml @@ -3,6 +3,8 @@ 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" @@ -11,12 +13,22 @@ + + Selected Input + + Color + + + 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 05ab7cc38..502ec398d 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 @@ -193,6 +193,10 @@ {b9ae25d6-be35-492f-9079-21a7f3e6f7cc} RealTimeGraphEx + + {a2f5af44-29ff-45d6-9d25-ecda5cce88b5} + Tango.ColorPicker + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} Tango.Core @@ -245,5 +249,14 @@ + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MonitorItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MonitorItem.cs index cc1ca4083..e04cdf675 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MonitorItem.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MonitorItem.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Media; using System.Xml.Serialization; using Tango.Integration.Observables; using Tango.SharedUI.Helpers; @@ -24,16 +25,29 @@ namespace Tango.MachineStudio.Technician.TechItems public double Value { get { return _value; } - set { _value = value; RaisePropertyChanged(nameof(Value)); } + set { _value = value; RaisePropertyChanged(nameof(Value)); LastUpdateTime = DateTime.Now; } } + private int _updateInterval; + public int UpdateInterval + { + get { return _updateInterval; } + set { _updateInterval = value; RaisePropertyChangedAuto(); } + } + + [XmlIgnore] + public DateTime LastUpdateTime { get; set; } + public override object Data => TechMonitor; public MonitorItem() : base() { Name = "Monitor"; + Color = Color.FromRgb(20, 20, 20); Description = "Simple analogue like monitor"; Image = ResourceHelper.GetImageFromResources("Images/analog.png"); + LastUpdateTime = DateTime.Now; + UpdateInterval = 10; } public MonitorItem(TechMonitor techMonitor) : this() @@ -43,7 +57,7 @@ namespace Tango.MachineStudio.Technician.TechItems public override TechItem Clone() { - MonitorItem cloned = base.Clone() as MonitorItem; + MonitorItem cloned = base.Clone() as MonitorItem; cloned.TechMonitor = TechMonitor; return cloned; } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/TechItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/TechItem.cs index 820c765cc..75296561a 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/TechItem.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/TechItem.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Media; using System.Windows.Media.Imaging; using System.Xml.Serialization; using Tango.Core; @@ -17,6 +18,7 @@ namespace Tango.MachineStudio.Technician.TechItems ID = Guid.NewGuid().ToString(); Name = "Untitled"; Adapter = ObservablesEntitiesAdapter.Instance; + _color = Colors.DodgerBlue; } private String _description; @@ -112,6 +114,14 @@ namespace Tango.MachineStudio.Technician.TechItems [XmlIgnore] public abstract object Data { get; } + private Color _color; + [XmlIgnore] + public Color Color + { + get { return _color; } + set { _color = value; RaisePropertyChangedAuto(); } + } + public virtual TechItem Clone() { TechItem cloned = Activator.CreateInstance(this.GetType()) as TechItem; 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 4420aa4c9..2be98e619 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 @@ -101,11 +101,14 @@ namespace Tango.MachineStudio.Technician.ViewModels { MonitorItem monitorItem = item as MonitorItem; - var prop = _diagnoticsDataProperties.SingleOrDefault(x => x.Name == monitorItem.TechMonitor.Name); - - if (prop != null) + if (DateTime.Now > monitorItem.LastUpdateTime.AddMilliseconds(monitorItem.UpdateInterval)) { - monitorItem.Value = GetLastMonitorValue(monitorItem.TechMonitor, prop.GetValue(data)); + var prop = _diagnoticsDataProperties.SingleOrDefault(x => x.Name == monitorItem.TechMonitor.Name); + + if (prop != null) + { + monitorItem.Value = GetLastMonitorValue(monitorItem.TechMonitor, prop.GetValue(data)); + } } } else if (item.GetType() == typeof(SingleGraphItem)) @@ -155,6 +158,7 @@ namespace Tango.MachineStudio.Technician.ViewModels { var monitorItem = new MonitorItem(Adapter.TechMonitors.FirstOrDefault()); MonitorElementEditor editor = new MonitorElementEditor(monitorItem, bounds); + editor.DataContext = monitorItem; Elements.Add(editor); } else if (SelectedTechItem is SingleGraphItem) 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 371caf5d7..2c895a789 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 @@ -4,6 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:vm="clr-namespace:Tango.MachineStudio.Technician.ViewModels" xmlns:global="clr-namespace:Tango.MachineStudio.Technician" + xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:editors="clr-namespace:Tango.Editors;assembly=Tango.Editors" xmlns:techItems="clr-namespace:Tango.MachineStudio.Technician.TechItems" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" @@ -14,7 +15,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:Tango.MachineStudio.Technician.Views" mc:Ignorable="d" - d:DesignHeight="720" d:DesignWidth="1280" Background="White" d:DataContext="{d:DesignInstance Type=vm:MachineTechViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MachineTechViewVM}"> + d:DesignHeight="720" d:DesignWidth="1280" d:DataContext="{d:DesignInstance Type=vm:MachineTechViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MachineTechViewVM}"> @@ -33,7 +34,7 @@ - + @@ -78,29 +79,34 @@ + + + + + + - - - + + + @@ -142,6 +148,9 @@ + + + @@ -151,7 +160,7 @@ - + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml index 0f9edee55..aa8fd74ad 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml @@ -60,14 +60,14 @@ - + - + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml.cs index 57d5ab88a..dd9aa1414 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml.cs @@ -72,6 +72,16 @@ namespace Tango.MachineStudio.Common.Controls + public Color Color + { + get { return (Color)GetValue(ColorProperty); } + set { SetValue(ColorProperty, value); } + } + public static readonly DependencyProperty ColorProperty = + DependencyProperty.Register("Color", typeof(Color), typeof(RealTimeGraphControl), new PropertyMetadata(Colors.DodgerBlue)); + + + public void InvalidateGraph() { InnerGraph.Clear(); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs index 597dfd819..daa24f087 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs @@ -71,6 +71,14 @@ namespace Tango.MachineStudio.UI LogManager.Categories.Clear(); LogManager.Categories.AddRange(SettingsManager.Default.MachineStudio.LoggingCategories); + if (LogManager.Categories.Count == 0) + { + LogManager.Categories.Add(LogCategory.Critical); + LogManager.Categories.Add(LogCategory.Error); + LogManager.Categories.Add(LogCategory.General); + LogManager.Categories.Add(LogCategory.Warning); + } + LogManager.RegisterLogger(new VSOutputLogger()); LogManager.RegisterLogger(new FileLogger()); } -- cgit v1.3.1 From c8c9606e545f49aae3d9f0524775436adbdf27e9 Mon Sep 17 00:00:00 2001 From: Roy Date: Fri, 9 Feb 2018 13:41:58 +0200 Subject: Added my Controls Library ! Implemented Tech VU Item. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 8388608 -> 8388608 bytes .../Editors/MeterElementEditor.xaml | 86 + .../Editors/MeterElementEditor.xaml.cs | 102 + .../Editors/MonitorElementEditor.xaml.cs | 6 +- .../Editors/MultiGraphElementEditor.xaml.cs | 6 +- .../Editors/SingleGraphElementEditor.xaml.cs | 6 +- .../PropertiesTemplates/MeterTemplate.xaml | 64 + .../PropertiesTemplates/MeterTemplate.xaml.cs | 28 + .../PropertiesTemplates/MonitorTemplate.xaml | 27 +- .../PropertiesTemplates/MultiGraphTemplate.xaml | 8 +- .../PropertiesTemplates/SingleGraphTemplate.xaml | 21 +- .../Tango.MachineStudio.Technician.csproj | 19 + .../TechItems/MeterItem.cs | 94 + .../TechItems/MonitorItem.cs | 3 +- .../TechItems/MultiGraphItem.cs | 4 +- .../TechItems/TechItem.cs | 1 + .../ViewModels/MachineTechViewVM.cs | 23 +- .../Views/MachineTechView.xaml | 36 +- .../Controls/RealTimeGraphControl.xaml | 2 +- .../Controls/RealTimeGraphMultiControl.xaml | 2 +- .../Visual_Studio/Tango.Visuals/Components/Arc.cs | 64 + .../Tango.Visuals/Components/PieAxisTicks.xaml | 41 + .../Tango.Visuals/Components/PieAxisTicks.xaml.cs | 31 + .../Tango.Visuals/Components/PolarPoint.cs | 81 + .../Tango.Visuals/Components/VULed.cs | 29 + .../Tango.Visuals/Components/XAxisDoubles.xaml | 12 + .../Tango.Visuals/Components/XAxisDoubles.xaml.cs | 142 + .../Tango.Visuals/Components/XAxisLabels.xaml | 11 + .../Tango.Visuals/Components/XAxisLabels.xaml.cs | 147 + .../Tango.Visuals/Components/XAxisTicks.xaml | 11 + .../Tango.Visuals/Components/XAxisTicks.xaml.cs | 137 + .../Tango.Visuals/Components/YAxisLabels.xaml | 11 + .../Tango.Visuals/Components/YAxisLabels.xaml.cs | 149 + .../Converters/BooleanToVisibilityConverter.cs | 24 + .../Converters/DoubleTunerConverter.cs | 25 + .../Converters/NullToVisibilityConverter.cs | 24 + .../Tango.Visuals/DoubleValueChangedEventArgs.cs | 38 + .../ExtensionMethods/ControlExtensions.cs | 12 + .../Visual_Studio/Tango.Visuals/Fader/Fader.xaml | 132 + .../Tango.Visuals/Fader/Fader.xaml.cs | 276 ++ .../Tango.Visuals/Fader/fader-dark.png | Bin 0 -> 1443 bytes .../Tango.Visuals/Fader/fader-light.png | Bin 0 -> 1668 bytes .../Visual_Studio/Tango.Visuals/Knob/Knob.xaml | 58 + .../Visual_Studio/Tango.Visuals/Knob/Knob.xaml.cs | 562 ++++ .../Visual_Studio/Tango.Visuals/Knob/KnobType.cs | 35 + .../Tango.Visuals/Knob/completeKnobBright.png | Bin 0 -> 6569 bytes .../Tango.Visuals/Knob/completeKnobDark.png | Bin 0 -> 5974 bytes .../Tango.Visuals/Knob/volumeKnobComplex.png | Bin 0 -> 28868 bytes .../Tango.Visuals/Knob/volumeKnobDark.png | Bin 0 -> 67518 bytes .../Tango.Visuals/Knob/volumeKnobLight.png | Bin 0 -> 86942 bytes .../Tango.Visuals/Knob/volumeKnobMetroDark.png | Bin 0 -> 42015 bytes .../Tango.Visuals/Knob/volumeKnobMetroLight.png | Bin 0 -> 46800 bytes .../MetroWindowControl/MetroWindowControl.cs | 301 ++ .../Tango.Visuals/MetroWindowControl/Style.xaml | 158 + .../Tango.Visuals/Properties/AssemblyInfo.cs | 6 + .../Tango.Visuals/Properties/Resources.Designer.cs | 63 + .../Tango.Visuals/Properties/Resources.resx | 117 + .../Tango.Visuals/Properties/Settings.Designer.cs | 26 + .../Tango.Visuals/Properties/Settings.settings | 7 + .../Tango.Visuals/Tango.Visuals.csproj | 199 ++ .../Tango.Visuals/Themes/DarkTheme.xaml | 3397 ++++++++++++++++++++ .../Tango.Visuals/Themes/Generic.xaml | 11 + .../Themes/LeftMarginMultiplierConverter.cs | 31 + .../Tango.Visuals/Themes/TreeViewItemExtensions.cs | 38 + .../Tango.Visuals/VUMeter/VUMeter.xaml | 220 ++ .../Tango.Visuals/VUMeter/VUMeter.xaml.cs | 253 ++ .../Tango.Visuals/VUMeter/led-texture.png | Bin 0 -> 4257 bytes .../Tango.Visuals/YAxisDoubles/YAxisDoubles.xaml | 11 + .../YAxisDoubles/YAxisDoubles.xaml.cs | 172 + .../Tango.Visuals/YAxisTicks/YAxisTicks.xaml | 11 + .../Tango.Visuals/YAxisTicks/YAxisTicks.xaml.cs | 197 ++ Software/Visual_Studio/Tango.sln | 34 +- .../Utilities/Tango.UITests/MainWindow.xaml | 3 +- .../Utilities/Tango.UITests/Tango.UITests.csproj | 4 + 75 files changed, 7792 insertions(+), 57 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MeterElementEditor.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MeterElementEditor.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MeterTemplate.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MeterTemplate.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MeterItem.cs create mode 100644 Software/Visual_Studio/Tango.Visuals/Components/Arc.cs create mode 100644 Software/Visual_Studio/Tango.Visuals/Components/PieAxisTicks.xaml create mode 100644 Software/Visual_Studio/Tango.Visuals/Components/PieAxisTicks.xaml.cs create mode 100644 Software/Visual_Studio/Tango.Visuals/Components/PolarPoint.cs create mode 100644 Software/Visual_Studio/Tango.Visuals/Components/VULed.cs create mode 100644 Software/Visual_Studio/Tango.Visuals/Components/XAxisDoubles.xaml create mode 100644 Software/Visual_Studio/Tango.Visuals/Components/XAxisDoubles.xaml.cs create mode 100644 Software/Visual_Studio/Tango.Visuals/Components/XAxisLabels.xaml create mode 100644 Software/Visual_Studio/Tango.Visuals/Components/XAxisLabels.xaml.cs create mode 100644 Software/Visual_Studio/Tango.Visuals/Components/XAxisTicks.xaml create mode 100644 Software/Visual_Studio/Tango.Visuals/Components/XAxisTicks.xaml.cs create mode 100644 Software/Visual_Studio/Tango.Visuals/Components/YAxisLabels.xaml create mode 100644 Software/Visual_Studio/Tango.Visuals/Components/YAxisLabels.xaml.cs create mode 100644 Software/Visual_Studio/Tango.Visuals/Converters/BooleanToVisibilityConverter.cs create mode 100644 Software/Visual_Studio/Tango.Visuals/Converters/DoubleTunerConverter.cs create mode 100644 Software/Visual_Studio/Tango.Visuals/Converters/NullToVisibilityConverter.cs create mode 100644 Software/Visual_Studio/Tango.Visuals/DoubleValueChangedEventArgs.cs create mode 100644 Software/Visual_Studio/Tango.Visuals/ExtensionMethods/ControlExtensions.cs create mode 100644 Software/Visual_Studio/Tango.Visuals/Fader/Fader.xaml create mode 100644 Software/Visual_Studio/Tango.Visuals/Fader/Fader.xaml.cs create mode 100644 Software/Visual_Studio/Tango.Visuals/Fader/fader-dark.png create mode 100644 Software/Visual_Studio/Tango.Visuals/Fader/fader-light.png create mode 100644 Software/Visual_Studio/Tango.Visuals/Knob/Knob.xaml create mode 100644 Software/Visual_Studio/Tango.Visuals/Knob/Knob.xaml.cs create mode 100644 Software/Visual_Studio/Tango.Visuals/Knob/KnobType.cs create mode 100644 Software/Visual_Studio/Tango.Visuals/Knob/completeKnobBright.png create mode 100644 Software/Visual_Studio/Tango.Visuals/Knob/completeKnobDark.png create mode 100644 Software/Visual_Studio/Tango.Visuals/Knob/volumeKnobComplex.png create mode 100644 Software/Visual_Studio/Tango.Visuals/Knob/volumeKnobDark.png create mode 100644 Software/Visual_Studio/Tango.Visuals/Knob/volumeKnobLight.png create mode 100644 Software/Visual_Studio/Tango.Visuals/Knob/volumeKnobMetroDark.png create mode 100644 Software/Visual_Studio/Tango.Visuals/Knob/volumeKnobMetroLight.png create mode 100644 Software/Visual_Studio/Tango.Visuals/MetroWindowControl/MetroWindowControl.cs create mode 100644 Software/Visual_Studio/Tango.Visuals/MetroWindowControl/Style.xaml create mode 100644 Software/Visual_Studio/Tango.Visuals/Properties/AssemblyInfo.cs create mode 100644 Software/Visual_Studio/Tango.Visuals/Properties/Resources.Designer.cs create mode 100644 Software/Visual_Studio/Tango.Visuals/Properties/Resources.resx create mode 100644 Software/Visual_Studio/Tango.Visuals/Properties/Settings.Designer.cs create mode 100644 Software/Visual_Studio/Tango.Visuals/Properties/Settings.settings create mode 100644 Software/Visual_Studio/Tango.Visuals/Tango.Visuals.csproj create mode 100644 Software/Visual_Studio/Tango.Visuals/Themes/DarkTheme.xaml create mode 100644 Software/Visual_Studio/Tango.Visuals/Themes/Generic.xaml create mode 100644 Software/Visual_Studio/Tango.Visuals/Themes/LeftMarginMultiplierConverter.cs create mode 100644 Software/Visual_Studio/Tango.Visuals/Themes/TreeViewItemExtensions.cs create mode 100644 Software/Visual_Studio/Tango.Visuals/VUMeter/VUMeter.xaml create mode 100644 Software/Visual_Studio/Tango.Visuals/VUMeter/VUMeter.xaml.cs create mode 100644 Software/Visual_Studio/Tango.Visuals/VUMeter/led-texture.png create mode 100644 Software/Visual_Studio/Tango.Visuals/YAxisDoubles/YAxisDoubles.xaml create mode 100644 Software/Visual_Studio/Tango.Visuals/YAxisDoubles/YAxisDoubles.xaml.cs create mode 100644 Software/Visual_Studio/Tango.Visuals/YAxisTicks/YAxisTicks.xaml create mode 100644 Software/Visual_Studio/Tango.Visuals/YAxisTicks/YAxisTicks.xaml.cs (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 496e5cdc7..5481ba429 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index e6ef281ec..9249879a7 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MeterElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MeterElementEditor.xaml new file mode 100644 index 000000000..8a9345fa9 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MeterElementEditor.xaml @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MeterElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MeterElementEditor.xaml.cs new file mode 100644 index 000000000..deaab4bed --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MeterElementEditor.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 MeterElementEditor : ElementEditor + { + /// + /// Initializes a new instance of the class. + /// + public MeterElementEditor() + : base() + { + InitializeComponent(); + } + + /// + /// Initializes a new instance of the class. + /// + /// The framework element. + public MeterElementEditor(MeterItem meterItem) + : this() + { + MeterItem = meterItem; + DataContext = MeterItem; + } + + /// + /// Initializes a new instance of the class. + /// + /// The framework element. + /// The bounds. + public MeterElementEditor(MeterItem monitorItem, Rect bounds) + : this(monitorItem) + { + Left = bounds.Left; + Top = bounds.Top; + Width = bounds.Width; + Height = bounds.Height; + } + + private MeterItem _monitorItem; + + public MeterItem MeterItem + { + get { return _monitorItem; } + set { _monitorItem = value; RaisePropertyChanged(nameof(MeterItem)); } + } + + + /// + /// Clones this instance. + /// + /// + public override IElementEditor Clone() + { + try + { + var clonedItem = MeterItem.Clone() as MeterItem; + MeterElementEditor cloned = new MeterElementEditor(clonedItem); + 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); + } + } + + /// + /// Gets the hosted element. + /// + [ParameterIgnore] + public override Object HostedElement + { + get { return MeterItem; } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml.cs index c11ca4417..d4df8e5cd 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml.cs @@ -41,6 +41,7 @@ namespace Tango.MachineStudio.Technician.Editors : this() { MonitorItem = monitorItem; + DataContext = MonitorItem; } /// @@ -74,9 +75,8 @@ namespace Tango.MachineStudio.Technician.Editors { try { - MonitorElementEditor cloned = new MonitorElementEditor(); - - cloned.MonitorItem = MonitorItem.Clone() as MonitorItem; + var clonedItem = MonitorItem.Clone() as MonitorItem; + MonitorElementEditor cloned = new MonitorElementEditor(clonedItem); cloned.Top = Top; cloned.Left = Left; cloned.Width = Width; 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 index 35273ccda..88b25bddb 100644 --- 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 @@ -41,6 +41,7 @@ namespace Tango.MachineStudio.Technician.Editors : this() { GraphItem = graphItem; + DataContext = GraphItem; } /// @@ -74,9 +75,8 @@ namespace Tango.MachineStudio.Technician.Editors { try { - MultiGraphElementEditor cloned = new MultiGraphElementEditor(); - - cloned.GraphItem = GraphItem.Clone() as MultiGraphItem; + var clonedItem = GraphItem.Clone() as MultiGraphItem; + MultiGraphElementEditor cloned = new MultiGraphElementEditor(clonedItem); cloned.Top = Top; cloned.Left = Left; cloned.Width = Width; diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/SingleGraphElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/SingleGraphElementEditor.xaml.cs index 8e8ac556e..b0efd1a02 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/SingleGraphElementEditor.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/SingleGraphElementEditor.xaml.cs @@ -41,6 +41,7 @@ namespace Tango.MachineStudio.Technician.Editors : this() { GraphItem = graphItem; + DataContext = GraphItem; } /// @@ -74,9 +75,8 @@ namespace Tango.MachineStudio.Technician.Editors { try { - SingleGraphElementEditor cloned = new SingleGraphElementEditor(); - - cloned.GraphItem = GraphItem.Clone() as SingleGraphItem; + var clonedItem = GraphItem.Clone() as SingleGraphItem; + SingleGraphElementEditor cloned = new SingleGraphElementEditor(clonedItem); cloned.Top = Top; cloned.Left = Left; cloned.Width = Width; diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MeterTemplate.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MeterTemplate.xaml new file mode 100644 index 000000000..d56925bbd --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MeterTemplate.xaml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + Selected Input + + + Update Interval + + + + + + Led Count: + + + Ticks Count: + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MeterTemplate.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MeterTemplate.xaml.cs new file mode 100644 index 000000000..11de9f85e --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MeterTemplate.xaml.cs @@ -0,0 +1,28 @@ +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; + +namespace Tango.MachineStudio.Technician.PropertiesTemplates +{ + /// + /// Interaction logic for MonitorTemplate.xaml + /// + public partial class MeterTemplate : UserControl + { + public MeterTemplate() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorTemplate.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorTemplate.xaml index f87926d28..3b84abee2 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorTemplate.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorTemplate.xaml @@ -9,7 +9,7 @@ xmlns:colorPicker="clr-namespace:Tango;assembly=Tango.ColorPicker" xmlns:local="clr-namespace:Tango.MachineStudio.Technician.PropertiesTemplates" mc:Ignorable="d" - d:DesignHeight="300" d:DesignWidth="200" d:DataContext="{d:DesignInstance Type=items:MonitorItem, IsDesignTimeCreatable=False}"> + d:DesignHeight="500" d:DesignWidth="200" d:DataContext="{d:DesignInstance Type=items:MonitorItem, IsDesignTimeCreatable=False}"> @@ -22,17 +22,22 @@ - Selected Input - + + + Selected Input + - Update Interval - - - Color - - - - + Update Interval + + + + + + + + + + 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 index 491a8b5c8..8602b4a1d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MultiGraphTemplate.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MultiGraphTemplate.xaml @@ -22,8 +22,12 @@ - Selected Input - + + + Selected Input + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/SingleGraphTemplate.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/SingleGraphTemplate.xaml index bc31f8b31..4546c0a75 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/SingleGraphTemplate.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/SingleGraphTemplate.xaml @@ -9,7 +9,7 @@ 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}"> + d:DesignHeight="400" d:DesignWidth="200" d:DataContext="{d:DesignInstance Type=items:SingleGraphItem, IsDesignTimeCreatable=False}"> @@ -22,13 +22,20 @@ - Selected Input - + + + Selected Input + + + - Color - - - + + + + + + + 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 ed270c017..654c6b9c1 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 @@ -81,6 +81,9 @@ + + MeterElementEditor.xaml + MultiGraphElementEditor.xaml @@ -91,6 +94,9 @@ MonitorElementEditor.xaml + + MeterTemplate.xaml + MonitorTemplate.xaml @@ -100,6 +106,7 @@ SingleGraphTemplate.xaml + @@ -129,6 +136,10 @@ GlobalVersionInfo.cs + + MSBuild:Compile + Designer + MSBuild:Compile Designer @@ -141,6 +152,10 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + Designer MSBuild:Compile @@ -245,6 +260,10 @@ {74e700b0-1156-4126-be40-ee450d3c3026} Tango.Transport + + {cf7c0ff4-9440-42cf-83b8-c060772792d4} + Tango.Visuals + {cb0b0aa2-bb24-4bca-a720-45e397684e12} Tango.MachineStudio.Common diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MeterItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MeterItem.cs new file mode 100644 index 000000000..9d4fd9d60 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MeterItem.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Controls.Primitives; +using System.Windows.Media; +using System.Xml.Serialization; +using Tango.Integration.Observables; +using Tango.SharedUI.Helpers; + +namespace Tango.MachineStudio.Technician.TechItems +{ + public class MeterItem : TechItem + { + private TechMonitor _techMonitor; + [XmlIgnore] + public TechMonitor TechMonitor + { + get { return _techMonitor; } + set { _techMonitor = value; RaisePropertyChangedAuto(); RaisePropertyChanged(nameof(Data)); } + } + + private double _value; + [XmlIgnore] + public double Value + { + get { return _value; } + set { _value = value; RaisePropertyChanged(nameof(Value)); LastUpdateTime = DateTime.Now; } + } + + private int _updateInterval; + public int UpdateInterval + { + get { return _updateInterval; } + set { _updateInterval = value; RaisePropertyChangedAuto(); } + } + + private int _ledCount; + public int LedCount + { + get { return _ledCount; } + set { _ledCount = value; RaisePropertyChangedAuto(); } + } + + private int _ticksCount; + public int TicksCount + { + get { return _ticksCount; } + set { _ticksCount = value; RaisePropertyChangedAuto(); } + } + + + private TickPlacement _tickPlacement; + public TickPlacement TickPlacement + { + get { return _tickPlacement; } + set { _tickPlacement = value; RaisePropertyChangedAuto(); } + } + + [XmlIgnore] + public DateTime LastUpdateTime { get; set; } + + public override object Data => TechMonitor; + + public MeterItem() : base() + { + Name = "VU Monitor"; + Description = "VU Meter monitor"; + Image = ResourceHelper.GetImageFromResources("Images/analog.png"); + LastUpdateTime = DateTime.Now; + UpdateInterval = 10; + LedCount = 14; + TicksCount = 14; + TickPlacement = TickPlacement.BottomRight; + Color = Colors.DimGray; + } + + public MeterItem(TechMonitor techMonitor) : this() + { + TechMonitor = techMonitor; + } + + public override TechItem Clone() + { + MeterItem cloned = base.Clone() as MeterItem; + cloned.TechMonitor = TechMonitor; + cloned.UpdateInterval = UpdateInterval; + cloned.LedCount = LedCount; + cloned.TicksCount = TicksCount; + return cloned; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MonitorItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MonitorItem.cs index e04cdf675..50cd2e8eb 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MonitorItem.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MonitorItem.cs @@ -44,7 +44,7 @@ namespace Tango.MachineStudio.Technician.TechItems { Name = "Monitor"; Color = Color.FromRgb(20, 20, 20); - Description = "Simple analogue like monitor"; + Description = "Simple analogue monitor"; Image = ResourceHelper.GetImageFromResources("Images/analog.png"); LastUpdateTime = DateTime.Now; UpdateInterval = 10; @@ -59,6 +59,7 @@ namespace Tango.MachineStudio.Technician.TechItems { MonitorItem cloned = base.Clone() as MonitorItem; cloned.TechMonitor = TechMonitor; + cloned.UpdateInterval = UpdateInterval; return cloned; } } 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 13591fb01..a642d63e2 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 @@ -40,8 +40,8 @@ namespace Tango.MachineStudio.Technician.TechItems public MultiGraphItem() : base() { - Name = "Single Channel Graph"; - Description = "Single channel real-time graph"; + Name = "Multi Channel Graph"; + Description = "Multi channel real-time graph"; Image = ResourceHelper.GetImageFromResources("Images/multi-graph.png"); } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/TechItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/TechItem.cs index 75296561a..0ae6218cf 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/TechItem.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/TechItem.cs @@ -130,6 +130,7 @@ namespace Tango.MachineStudio.Technician.TechItems cloned.Width = Width; cloned.Height = Height; cloned.Angle = Angle; + cloned.Color = Color; 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 8bbebdfb7..b0c899f06 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 @@ -115,6 +115,20 @@ namespace Tango.MachineStudio.Technician.ViewModels } } } + else if (item.GetType() == typeof(MeterItem)) + { + MeterItem meterItem = item as MeterItem; + + if (DateTime.Now > meterItem.LastUpdateTime.AddMilliseconds(meterItem.UpdateInterval)) + { + var prop = _diagnoticsDataProperties.SingleOrDefault(x => x.Name == meterItem.TechMonitor.Name); + + if (prop != null) + { + meterItem.Value = GetLastMonitorValue(meterItem.TechMonitor, prop.GetValue(data)); + } + } + } else if (item.GetType() == typeof(SingleGraphItem)) { SingleGraphItem graphItem = item as SingleGraphItem; @@ -184,7 +198,12 @@ namespace Tango.MachineStudio.Technician.ViewModels { 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 MeterItem) + { + var meterItem = new MeterItem(Adapter.TechMonitors.Where(x => !x.MultiChannel).FirstOrDefault()); + MeterElementEditor editor = new MeterElementEditor(meterItem, bounds); Elements.Add(editor); } else if (SelectedTechItem is SingleGraphItem) @@ -192,7 +211,6 @@ namespace Tango.MachineStudio.Technician.ViewModels 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; graphItem.Editor = editor; @@ -208,7 +226,6 @@ namespace Tango.MachineStudio.Technician.ViewModels 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; 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 0f255fac8..f353c92d1 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 @@ -144,25 +144,25 @@ + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml index aa8fd74ad..8c364dde9 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml @@ -60,7 +60,7 @@ - + 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 9a5ae3636..2055e282c 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphMultiControl.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphMultiControl.xaml @@ -60,7 +60,7 @@ - + diff --git a/Software/Visual_Studio/Tango.Visuals/Components/Arc.cs b/Software/Visual_Studio/Tango.Visuals/Components/Arc.cs new file mode 100644 index 000000000..02fc3aab5 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Components/Arc.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Windows; +using System.Windows.Documents; +using System.Windows.Media; +using System.Windows.Shapes; + +namespace Tango.Visuals.Components +{ + internal class Arc : Shape + { + public double StartAngle + { + get { return (double)GetValue(StartAngleProperty); } + set { SetValue(StartAngleProperty, value); } + } + public static readonly DependencyProperty StartAngleProperty = + DependencyProperty.Register("StartAngle", typeof(double), typeof(Arc), new PropertyMetadata(0.0)); + + public double EndAngle + { + get { return (double)GetValue(EndAngleProperty); } + set { SetValue(EndAngleProperty, value); } + } + public static readonly DependencyProperty EndAngleProperty = + DependencyProperty.Register("EndAngle", typeof(double), typeof(Arc), new PropertyMetadata(90.0)); + + protected override Geometry DefiningGeometry + { + get + { + double maxWidth = RenderSize.Width; + double maxHeight = RenderSize.Height; + double maxRadius = Math.Min(maxWidth, maxHeight) / 2.0; + + PolarPoint arcStart = new PolarPoint(maxRadius, StartAngle); + PolarPoint arcFinish = new PolarPoint(maxRadius, EndAngle); + + StreamGeometry geom = new StreamGeometry(); + using (StreamGeometryContext ctx = geom.Open()) + { + ctx.BeginFigure( + new Point((maxWidth / 2.0) + arcStart.X, + (maxHeight / 2.0) - arcStart.Y), + false, + false); + ctx.ArcTo( + new Point((maxWidth / 2.0) + arcFinish.X, + (maxHeight / 2.0) - arcFinish.Y), + new Size(maxRadius, maxRadius), + 0.0, // rotationAngle + EndAngle > 180 && StartAngle < 180 && (EndAngle - StartAngle) > 180, // greater than 180 deg? + SweepDirection.Counterclockwise, + true, // isStroked + true); + } + + geom.Transform = new RotateTransform((-90 + EndAngle) + StartAngle, maxWidth / 2, maxHeight / 2); + + return geom; + } + } + } +} \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Visuals/Components/PieAxisTicks.xaml b/Software/Visual_Studio/Tango.Visuals/Components/PieAxisTicks.xaml new file mode 100644 index 000000000..535524d32 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Components/PieAxisTicks.xaml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/Tango.Visuals/Components/PieAxisTicks.xaml.cs b/Software/Visual_Studio/Tango.Visuals/Components/PieAxisTicks.xaml.cs new file mode 100644 index 000000000..5c5ca61c9 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Components/PieAxisTicks.xaml.cs @@ -0,0 +1,31 @@ +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; + +namespace Tango.Visuals.Components +{ + /// + /// Interaction logic for PieAxisTicks.xaml + /// + internal partial class PieAxisTicks : UserControl + { + /// + /// Initializes a new instance of the class. + /// + public PieAxisTicks() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/Tango.Visuals/Components/PolarPoint.cs b/Software/Visual_Studio/Tango.Visuals/Components/PolarPoint.cs new file mode 100644 index 000000000..b2063b7a1 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Components/PolarPoint.cs @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Visuals.Components +{ + internal class PolarPoint + { + /// + /// Initializes a new instance of the class. + /// + /// The radius. + /// Angle expressed in degrees. + /// + /// Radius must be non-negative + /// or + /// Angle must be in range [0,360) + /// + public PolarPoint(double radius, double angleDeg) + { + if (radius < 0.0) + throw new ArgumentException("Radius must be non-negative"); + if ((angleDeg < 0) || (angleDeg >= 360.0)) + throw new ArgumentException("Angle must be in range [0,360)"); + + Radius = radius; + AngleDeg = angleDeg; + } + + /// + /// Gets or sets the Polar coordinates. + /// + /// + /// The radius. + /// + public double Radius { get; set; } + + /// + /// Gets or sets the angle degree. + /// + /// + /// The angle deg. + /// + public double AngleDeg { get; set; } + + /// + /// Cartesian X Coordinate. + /// + /// + /// The x. + /// + public double X + { + get { return Radius * Math.Cos(AngleDeg * Math.PI / 180.0); } + } + + /// + /// Cartesian Y Coordinate. + /// + /// + /// The y. + /// + public double Y + { + get { return Radius * Math.Sin(AngleDeg * Math.PI / 180.0); } + } + + /// + /// Returns a that represents this instance. + /// + /// + /// A that represents this instance. + /// + public override string ToString() + { + return string.Format("({0},{1})", X, Y); + } + } +} diff --git a/Software/Visual_Studio/Tango.Visuals/Components/VULed.cs b/Software/Visual_Studio/Tango.Visuals/Components/VULed.cs new file mode 100644 index 000000000..609d2ce26 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Components/VULed.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.Media; + +namespace Tango.Visuals.Components +{ + internal class VULed : DependencyObject + { + public bool On + { + get { return (bool)GetValue(OnProperty); } + set { SetValue(OnProperty, value); } + } + public static readonly DependencyProperty OnProperty = + DependencyProperty.Register("On", typeof(bool), typeof(VULed), new PropertyMetadata(false)); + + public Brush Brush + { + get { return (Brush)GetValue(BrushProperty); } + set { SetValue(BrushProperty, value); } + } + public static readonly DependencyProperty BrushProperty = + DependencyProperty.Register("Brush", typeof(Brush), typeof(VULed), new PropertyMetadata(Brushes.Red)); + } +} diff --git a/Software/Visual_Studio/Tango.Visuals/Components/XAxisDoubles.xaml b/Software/Visual_Studio/Tango.Visuals/Components/XAxisDoubles.xaml new file mode 100644 index 000000000..5761491d7 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Components/XAxisDoubles.xaml @@ -0,0 +1,12 @@ + + + + + diff --git a/Software/Visual_Studio/Tango.Visuals/Components/XAxisDoubles.xaml.cs b/Software/Visual_Studio/Tango.Visuals/Components/XAxisDoubles.xaml.cs new file mode 100644 index 000000000..de1d1c9b7 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Components/XAxisDoubles.xaml.cs @@ -0,0 +1,142 @@ +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; + +namespace Tango.Visuals.Components +{ + /// + /// Interaction logic for XAxisDoubles.xaml + /// + internal partial class XAxisDoubles : UserControl + { + /// + /// Initializes a new instance of the class. + /// + public XAxisDoubles() + { + InitializeComponent(); + this.Loaded += XAxisDoubles_Loaded; + } + + /// + /// Handles the Loaded event of the XAxisDoubles control. + /// + /// The source of the event. + /// The instance containing the event data. + private void XAxisDoubles_Loaded(object sender, RoutedEventArgs e) + { + DrawTicks(); + } + + /// + /// Gets or sets the number of ticks. + /// + public int Ticks + { + get { return (int)GetValue(TicksProperty); } + set { SetValue(TicksProperty, value); } + } + public static readonly DependencyProperty TicksProperty = + DependencyProperty.Register("Ticks", typeof(int), typeof(XAxisDoubles), new PropertyMetadata(8, (d, e) => (d as XAxisDoubles).DrawTicks())); + + /// + /// Gets or sets the minimum. + /// + public double Minimum + { + get { return (double)GetValue(MinimumProperty); } + set { SetValue(MinimumProperty, value); } + } + public static readonly DependencyProperty MinimumProperty = + DependencyProperty.Register("Minimum", typeof(double), typeof(XAxisDoubles), new PropertyMetadata(0.0, (d, e) => (d as XAxisDoubles).DrawTicks())); + + /// + /// Gets or sets the maximum. + /// + public double Maximum + { + get { return (double)GetValue(MaximumProperty); } + set { SetValue(MaximumProperty, value); } + } + public static readonly DependencyProperty MaximumProperty = + DependencyProperty.Register("Maximum", typeof(double), typeof(XAxisDoubles), new PropertyMetadata(100.0, (d, e) => (d as XAxisDoubles).DrawTicks())); + + /// + /// Gets or sets the string format. + /// + public String StringFormat + { + get { return (String)GetValue(StringFormatProperty); } + set { SetValue(StringFormatProperty, value); } + } + public static readonly DependencyProperty StringFormatProperty = + DependencyProperty.Register("StringFormat", typeof(String), typeof(XAxisDoubles), new PropertyMetadata(null)); + + /// + /// Draws the labels. + /// + private void DrawTicks() + { + grid.ColumnDefinitions.Clear(); + grid.Children.Clear(); + grid.ClipToBounds = false; + + var steps = Enumerable.Range(0, Ticks) + .Select(i => Minimum + (Maximum - Minimum) * ((double)i / (Ticks - 1))).ToList(); + + for (int i = 0; i < Ticks; i++) + { + if (i == Ticks - 1) + { + var container = AddLabel(steps[i].ToString(StringFormat != null ? StringFormat : "0.0"), i); + container.HorizontalAlignment = HorizontalAlignment.Right; + grid.Children.Add(container); + container.Loaded += (x, y) => + { + container.Margin = new Thickness(0, 0, (container.ActualWidth / 2) * -1, 0); + }; + } + else + { + + ColumnDefinition column = new ColumnDefinition(); + column.Width = new GridLength(1, GridUnitType.Star); + grid.ColumnDefinitions.Add(column); + var container = AddLabel(steps[i].ToString(StringFormat != null ? StringFormat : "0.0"), i); + grid.Children.Add(container); + container.Loaded += (x, y) => + { + container.Margin = new Thickness((container.ActualWidth / 2) * -1, 0, 0, 0); + }; + } + } + } + + /// + /// Adds the label. + /// + /// The text. + /// The index. + /// + private ContentControl AddLabel(String text, int index) + { + ContentControl label = new ContentControl(); + label.Content = text; + label.VerticalAlignment = System.Windows.VerticalAlignment.Top; + label.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; + Grid.SetColumn(label, index); + return label; + } + } +} diff --git a/Software/Visual_Studio/Tango.Visuals/Components/XAxisLabels.xaml b/Software/Visual_Studio/Tango.Visuals/Components/XAxisLabels.xaml new file mode 100644 index 000000000..57513ffac --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Components/XAxisLabels.xaml @@ -0,0 +1,11 @@ + + + + + diff --git a/Software/Visual_Studio/Tango.Visuals/Components/XAxisLabels.xaml.cs b/Software/Visual_Studio/Tango.Visuals/Components/XAxisLabels.xaml.cs new file mode 100644 index 000000000..cc2e1297c --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Components/XAxisLabels.xaml.cs @@ -0,0 +1,147 @@ +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; +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; + +namespace Tango.Visuals.Components +{ + /// + /// Interaction logic for YAxisLabels.xaml + /// + internal partial class XAxisLabels : UserControl + { + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + public XAxisLabels() + { + InitializeComponent(); + this.Loaded += YAxisLabels_Loaded; + } + + #endregion + + #region Properties + + /// + /// Gets or sets the labels. + /// + /// + /// The labels. + /// + public ObservableCollection Labels + { + get { return (ObservableCollection)GetValue(LabelsProperty); } + set { SetValue(LabelsProperty, value); } + } + public static readonly DependencyProperty LabelsProperty = + DependencyProperty.Register("Labels", typeof(ObservableCollection), typeof(XAxisLabels), new PropertyMetadata(new ObservableCollection())); + + /// + /// Gets or sets the label template. + /// + /// + /// The label template. + /// + public DataTemplate LabelTemplate + { + get { return (DataTemplate)GetValue(LabelTemplateProperty); } + set { SetValue(LabelTemplateProperty, value); } + } + public static readonly DependencyProperty LabelTemplateProperty = + DependencyProperty.Register("LabelTemplate", typeof(DataTemplate), typeof(XAxisLabels), new PropertyMetadata(null)); + + #endregion + + #region Event Handlers + + private void YAxisLabels_Loaded(object sender, RoutedEventArgs e) + { + DrawLabels(); + } + + #endregion + + #region Methods + + /// + /// Draws the labels. + /// + private void DrawLabels() + { + grid.ColumnDefinitions.Clear(); + grid.Children.Clear(); + grid.ClipToBounds = false; + + if (Labels == null) return; + + for (int i = 0; i < Labels.Count; i++) + { + if (i == Labels.Count - 1) + { + var container = AddLabel(Labels[i].ToString(), i); + container.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; + grid.Children.Add(container); + container.Loaded += (x, y) => + { + container.Margin = new Thickness(0, 0, (container.ActualHeight / 2) * -1, 0); + }; + } + else + { + + ColumnDefinition column = new ColumnDefinition(); + column.Width = new GridLength(1, GridUnitType.Star); + grid.ColumnDefinitions.Add(column); + var container = AddLabel(Labels[i].ToString(), i); + grid.Children.Add(container); + container.Loaded += (x, y) => + { + container.Margin = new Thickness((container.ActualHeight / 2) * -1, 0, 0, 0); + }; + } + } + } + + /// + /// Adds the label. + /// + /// The text. + /// The index. + /// + private ContentControl AddLabel(String text, int index) + { + ContentControl label = new ContentControl(); + label.Content = text; + label.VerticalAlignment = System.Windows.VerticalAlignment.Stretch; + label.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; + + label.LayoutTransform = new RotateTransform(270); + + Grid.SetColumn(label, index); + + if (LabelTemplate != null) + { + label.ContentTemplate = LabelTemplate; + } + + return label; + } + + #endregion + } +} diff --git a/Software/Visual_Studio/Tango.Visuals/Components/XAxisTicks.xaml b/Software/Visual_Studio/Tango.Visuals/Components/XAxisTicks.xaml new file mode 100644 index 000000000..779148155 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Components/XAxisTicks.xaml @@ -0,0 +1,11 @@ + + + + + diff --git a/Software/Visual_Studio/Tango.Visuals/Components/XAxisTicks.xaml.cs b/Software/Visual_Studio/Tango.Visuals/Components/XAxisTicks.xaml.cs new file mode 100644 index 000000000..cc8e9660f --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Components/XAxisTicks.xaml.cs @@ -0,0 +1,137 @@ +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; + +namespace Tango.Visuals.Components +{ + /// + /// Interaction logic for TicksAxis.xaml + /// + internal partial class XAxisTicks : UserControl + { + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + public XAxisTicks() + { + InitializeComponent(); + this.Loaded += TicksAxis_Loaded; + } + + #endregion + + #region Event Handlers + + /// + /// Handles the Loaded event of the TicksAxis control. + /// + /// The source of the event. + /// The instance containing the event data. + private void TicksAxis_Loaded(object sender, RoutedEventArgs e) + { + DrawTicks(); + } + + #endregion + + #region Properties + + /// + /// Gets or sets the ticks. + /// + /// + /// The ticks. + /// + public int Ticks + { + get { return (int)GetValue(TicksProperty); } + set { SetValue(TicksProperty, value); } + } + public static readonly DependencyProperty TicksProperty = + DependencyProperty.Register("Ticks", typeof(int), typeof(XAxisTicks), new PropertyMetadata(11)); + + /// + /// Gets or sets the tick template. + /// + /// + /// The tick template. + /// + public DataTemplate TickTemplate + { + get { return (DataTemplate)GetValue(TickTemplateProperty); } + set { SetValue(TickTemplateProperty, value); } + } + public static readonly DependencyProperty TickTemplateProperty = + DependencyProperty.Register("TickTemplate", typeof(DataTemplate), typeof(XAxisTicks), new PropertyMetadata(null)); + + #endregion + + #region Methods + + /// + /// Draws the ticks. + /// + private void DrawTicks() + { + grid.Children.Clear(); + grid.ColumnDefinitions.Clear(); + + for (int i = 0; i < Ticks; i++) + { + if (i == Ticks - 1) + { + var rec = AddTick(i, i); + rec.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; + grid.Children.Add(rec); + } + else + { + + ColumnDefinition column = new ColumnDefinition(); + column.Width = new GridLength(1, GridUnitType.Star); + grid.ColumnDefinitions.Add(column); + var rec = AddTick(i, i); + grid.Children.Add(rec); + } + } + } + + /// + /// Adds the tick. + /// + /// The value. + /// The index. + /// + private ContentControl AddTick(double value, int index) + { + ContentControl tick = new ContentControl(); + tick.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; + tick.VerticalAlignment = System.Windows.VerticalAlignment.Stretch; + Grid.SetColumn(tick, index); + + if (TickTemplate != null) + { + tick.ContentTemplate = TickTemplate; + } + + return tick; + } + + #endregion + + } +} diff --git a/Software/Visual_Studio/Tango.Visuals/Components/YAxisLabels.xaml b/Software/Visual_Studio/Tango.Visuals/Components/YAxisLabels.xaml new file mode 100644 index 000000000..16d72ca56 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Components/YAxisLabels.xaml @@ -0,0 +1,11 @@ + + + + + diff --git a/Software/Visual_Studio/Tango.Visuals/Components/YAxisLabels.xaml.cs b/Software/Visual_Studio/Tango.Visuals/Components/YAxisLabels.xaml.cs new file mode 100644 index 000000000..21d32faf4 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Components/YAxisLabels.xaml.cs @@ -0,0 +1,149 @@ +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; +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; + +namespace Tango.Visuals.Components +{ + /// + /// Interaction logic for YAxisLabels.xaml + /// + internal partial class YAxisLabels : UserControl + { + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + public YAxisLabels() + { + InitializeComponent(); + this.Loaded += YAxisLabels_Loaded; + } + + #endregion + + #region Properties + + /// + /// Gets or sets the labels. + /// + /// + /// The labels. + /// + public ObservableCollection Labels + { + get { return (ObservableCollection)GetValue(LabelsProperty); } + set { SetValue(LabelsProperty, value); } + } + public static readonly DependencyProperty LabelsProperty = + DependencyProperty.Register("Labels", typeof(ObservableCollection), typeof(YAxisLabels), new PropertyMetadata(new ObservableCollection())); + + /// + /// Gets or sets the label template. + /// + /// + /// The label template. + /// + public DataTemplate LabelTemplate + { + get { return (DataTemplate)GetValue(LabelTemplateProperty); } + set { SetValue(LabelTemplateProperty, value); } + } + public static readonly DependencyProperty LabelTemplateProperty = + DependencyProperty.Register("LabelTemplate", typeof(DataTemplate), typeof(YAxisLabels), new PropertyMetadata(null)); + + #endregion + + #region Event Handlers + + /// + /// Handles the Loaded event of the YAxisLabels control. + /// + /// The source of the event. + /// The instance containing the event data. + private void YAxisLabels_Loaded(object sender, RoutedEventArgs e) + { + DrawLabels(); + } + + #endregion + + #region Methods + + /// + /// Draws the labels. + /// + private void DrawLabels() + { + grid.RowDefinitions.Clear(); + grid.Children.Clear(); + grid.ClipToBounds = false; + + if (Labels == null) return; + + for (int i = 0; i < Labels.Count; i++) + { + if (i == Labels.Count - 1) + { + var container = AddLabel(Labels[i].ToString(), i); + container.VerticalAlignment = System.Windows.VerticalAlignment.Bottom; + grid.Children.Add(container); + container.Loaded += (x, y) => + { + container.Margin = new Thickness(0, 0, 0, (container.ActualHeight / 2) * -1); + }; + } + else + { + + RowDefinition row = new RowDefinition(); + row.Height = new GridLength(1, GridUnitType.Star); + grid.RowDefinitions.Add(row); + var container = AddLabel(Labels[i].ToString(), i); + grid.Children.Add(container); + container.Loaded += (x, y) => + { + container.Margin = new Thickness(0, (container.ActualHeight / 2) * -1, 0, 0); + }; + } + } + } + + /// + /// Adds the label. + /// + /// The text. + /// The index. + /// + private ContentControl AddLabel(String text, int index) + { + ContentControl label = new ContentControl(); + label.Content = text; + label.VerticalAlignment = System.Windows.VerticalAlignment.Top; + label.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; + Grid.SetRow(label, index); + + if (LabelTemplate != null) + { + label.ContentTemplate = LabelTemplate; + } + + return label; + } + + #endregion + } +} diff --git a/Software/Visual_Studio/Tango.Visuals/Converters/BooleanToVisibilityConverter.cs b/Software/Visual_Studio/Tango.Visuals/Converters/BooleanToVisibilityConverter.cs new file mode 100644 index 000000000..8c16aa8b0 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Converters/BooleanToVisibilityConverter.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Data; + +namespace Tango.Visuals.Converters +{ + internal class BooleanToVisibilityConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return (bool)value ? Visibility.Visible : Visibility.Collapsed; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/Tango.Visuals/Converters/DoubleTunerConverter.cs b/Software/Visual_Studio/Tango.Visuals/Converters/DoubleTunerConverter.cs new file mode 100644 index 000000000..07bd0cb57 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Converters/DoubleTunerConverter.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; + +namespace Tango.Visuals.Converters +{ + internal class DoubleTunerConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + double add = System.Convert.ToDouble(parameter.ToString()); + double num = System.Convert.ToDouble(value.ToString()); + + return num + add; + } + + public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/Tango.Visuals/Converters/NullToVisibilityConverter.cs b/Software/Visual_Studio/Tango.Visuals/Converters/NullToVisibilityConverter.cs new file mode 100644 index 000000000..a21585b91 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Converters/NullToVisibilityConverter.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Data; + +namespace Tango.Visuals.Converters +{ + internal class NullToVisibilityConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return value != null ? Visibility.Visible : Visibility.Collapsed; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/Tango.Visuals/DoubleValueChangedEventArgs.cs b/Software/Visual_Studio/Tango.Visuals/DoubleValueChangedEventArgs.cs new file mode 100644 index 000000000..7c4ca571e --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/DoubleValueChangedEventArgs.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Visuals +{ + /// + /// Represents a double value changed event argument. + /// + /// + public class DoubleValueChangedEventArgs : EventArgs + { + /// + /// Gets or sets the new value. + /// + public double Value { get; set; } + + /// + /// Initializes a new instance of the class. + /// + public DoubleValueChangedEventArgs() + { + + } + + /// + /// Initializes a new instance of the class. + /// + /// The value. + public DoubleValueChangedEventArgs(double value) + : this() + { + Value = value; + } + } +} diff --git a/Software/Visual_Studio/Tango.Visuals/ExtensionMethods/ControlExtensions.cs b/Software/Visual_Studio/Tango.Visuals/ExtensionMethods/ControlExtensions.cs new file mode 100644 index 000000000..0a9e08fa8 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/ExtensionMethods/ControlExtensions.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Controls; + +internal static class ControlExtensions +{ + +} + diff --git a/Software/Visual_Studio/Tango.Visuals/Fader/Fader.xaml b/Software/Visual_Studio/Tango.Visuals/Fader/Fader.xaml new file mode 100644 index 000000000..e3313ef43 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Fader/Fader.xaml @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/Tango.Visuals/Fader/Fader.xaml.cs b/Software/Visual_Studio/Tango.Visuals/Fader/Fader.xaml.cs new file mode 100644 index 000000000..b7f470624 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Fader/Fader.xaml.cs @@ -0,0 +1,276 @@ +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; + +namespace Tango.Visuals +{ + /// + /// Interaction logic for Fader.xaml + /// + public partial class Fader : UserControl + { + public Fader() + { + InitializeComponent(); + this.Loaded += Fader_Loaded; + this.SizeChanged += Fader_SizeChanged; + } + + private void Fader_SizeChanged(object sender, SizeChangedEventArgs e) + { + SetSize(); + } + + private void SetSize() + { + border.Margin = new Thickness(0, gridThumb.ActualHeight / 2, 0, gridThumb.ActualHeight / 2); + } + + private void Fader_Loaded(object sender, RoutedEventArgs e) + { + SetSize(); + OnValueChanged(); + } + + public Brush TrackBrush + { + get { return (Brush)GetValue(TrackBrushProperty); } + set { SetValue(TrackBrushProperty, value); } + } + public static readonly DependencyProperty TrackBrushProperty = + DependencyProperty.Register("TrackBrush", typeof(Brush), typeof(Fader), new PropertyMetadata(null)); + + public Brush TrackHighlighBrush + { + get { return (Brush)GetValue(TrackHighlighBrushProperty); } + set { SetValue(TrackHighlighBrushProperty, value); } + } + public static readonly DependencyProperty TrackHighlighBrushProperty = + DependencyProperty.Register("TrackHighlighBrush", typeof(Brush), typeof(Fader), new PropertyMetadata(null)); + + public bool HighlightTrack + { + get { return (bool)GetValue(HighlightTrackProperty); } + set { SetValue(HighlightTrackProperty, value); } + } + public static readonly DependencyProperty HighlightTrackProperty = + DependencyProperty.Register("HighlightTrack", typeof(bool), typeof(Fader), new PropertyMetadata(false)); + + public double Minimum + { + get { return (double)GetValue(MinimumProperty); } + set { SetValue(MinimumProperty, value); } + } + public static readonly DependencyProperty MinimumProperty = + DependencyProperty.Register("Minimum", typeof(double), typeof(Fader), new PropertyMetadata(0.0, (d, e) => (d as Fader).OnValueChanged())); + + public double Maximum + { + get { return (double)GetValue(MaximumProperty); } + set { SetValue(MaximumProperty, value); } + } + public static readonly DependencyProperty MaximumProperty = + DependencyProperty.Register("Maximum", typeof(double), typeof(Fader), new PropertyMetadata(100.0, (d, e) => (d as Fader).OnValueChanged())); + + public double Value + { + get { return (double)GetValue(ValueProperty); } + set { SetValue(ValueProperty, value); } + } + public static readonly DependencyProperty ValueProperty = + DependencyProperty.Register("Value", typeof(double), typeof(Fader), new FrameworkPropertyMetadata(0.0, (d, e) => (d as Fader).OnValueChanged(), (d, baseValue) => (d as Fader).OnCoerceValue((double)baseValue)) { BindsTwoWayByDefault = true }); + + public bool SnapToValues + { + get { return (bool)GetValue(SnapToValuesProperty); } + set { SetValue(SnapToValuesProperty, value); } + } + public static readonly DependencyProperty SnapToValuesProperty = + DependencyProperty.Register("SnapToValues", typeof(bool), typeof(Fader), new PropertyMetadata(false)); + + public int SnapPercision + { + get { return (int)GetValue(SnapPercisionProperty); } + set { SetValue(SnapPercisionProperty, value); } + } + public static readonly DependencyProperty SnapPercisionProperty = + DependencyProperty.Register("SnapPercision", typeof(int), typeof(Fader), new PropertyMetadata(1)); + + public int Ticks + { + get { return (int)GetValue(TicksProperty); } + set { SetValue(TicksProperty, value); } + } + public static readonly DependencyProperty TicksProperty = + DependencyProperty.Register("Ticks", typeof(int), typeof(Fader), new PropertyMetadata(50)); + + public int? BigTicksInterval + { + get { return (int?)GetValue(BigTicksIntervalProperty); } + set { SetValue(BigTicksIntervalProperty, value); } + } + public static readonly DependencyProperty BigTicksIntervalProperty = + DependencyProperty.Register("BigTicksInterval", typeof(int?), typeof(Fader), new PropertyMetadata(5)); + + public Brush TicksBrush + { + get { return (Brush)GetValue(TicksBrushProperty); } + set { SetValue(TicksBrushProperty, value); } + } + public static readonly DependencyProperty TicksBrushProperty = + DependencyProperty.Register("TicksBrush", typeof(Brush), typeof(Fader), new PropertyMetadata(null)); + + public Brush BigTicksBrush + { + get { return (Brush)GetValue(BigTicksBrushProperty); } + set { SetValue(BigTicksBrushProperty, value); } + } + public static readonly DependencyProperty BigTicksBrushProperty = + DependencyProperty.Register("BigTicksBrush", typeof(Brush), typeof(Fader), new PropertyMetadata(null)); + + public double FaderWidth + { + get { return (double)GetValue(FaderWidthProperty); } + set { SetValue(FaderWidthProperty, value); } + } + public static readonly DependencyProperty FaderWidthProperty = + DependencyProperty.Register("FaderWidth", typeof(double), typeof(Fader), new PropertyMetadata(40.0)); + + public double TrackWidth + { + get { return (double)GetValue(TrackWidthProperty); } + set { SetValue(TrackWidthProperty, value); } + } + public static readonly DependencyProperty TrackWidthProperty = + DependencyProperty.Register("TrackWidth", typeof(double), typeof(Fader), new PropertyMetadata(10.0)); + + public bool ShowTicks + { + get { return (bool)GetValue(ShowTicksProperty); } + set { SetValue(ShowTicksProperty, value); } + } + public static readonly DependencyProperty ShowTicksProperty = + DependencyProperty.Register("ShowTicks", typeof(bool), typeof(Fader), new PropertyMetadata(true)); + + public Color? FaderColor + { + get { return (Color?)GetValue(FaderColorProperty); } + set { SetValue(FaderColorProperty, value); } + } + public static readonly DependencyProperty FaderColorProperty = + DependencyProperty.Register("FaderColor", typeof(Color?), typeof(Fader), new PropertyMetadata(null)); + + public double TicksWidth + { + get { return (double)GetValue(TicksWidthProperty); } + set { SetValue(TicksWidthProperty, value); } + } + public static readonly DependencyProperty TicksWidthProperty = + DependencyProperty.Register("TicksWidth", typeof(double), typeof(Fader), new PropertyMetadata(8.0)); + + public double BigTicksWidth + { + get { return (double)GetValue(BigTicksWidthProperty); } + set { SetValue(BigTicksWidthProperty, value); } + } + public static readonly DependencyProperty BigTicksWidthProperty = + DependencyProperty.Register("BigTicksWidth", typeof(double), typeof(Fader), new PropertyMetadata(20.0)); + + public Brush FaderLightBrush + { + get { return (Brush)GetValue(FaderLightBrushProperty); } + set { SetValue(FaderLightBrushProperty, value); } + } + public static readonly DependencyProperty FaderLightBrushProperty = + DependencyProperty.Register("FaderLightBrush", typeof(Brush), typeof(Fader), new PropertyMetadata(null)); + + public double Change + { + get { return (double)GetValue(ChangeProperty); } + set { SetValue(ChangeProperty, value); } + } + public static readonly DependencyProperty ChangeProperty = + DependencyProperty.Register("Change", typeof(double), typeof(Fader), new PropertyMetadata(0.01)); + + internal bool IsKeyDown + { + get { return (bool)GetValue(IsKeyDownProperty); } + set { SetValue(IsKeyDownProperty, value); } + } + internal static readonly DependencyProperty IsKeyDownProperty = + DependencyProperty.Register("IsKeyDown", typeof(bool), typeof(Fader), new PropertyMetadata(false)); + + + private object OnCoerceValue(double value) + { + if (value > Maximum) return Maximum; + if (value < Minimum) return Minimum; + return SnapToValues ? Math.Round(value, SnapPercision) : value; + } + + private void OnValueChanged() + { + double percentage = (Value - Minimum) / (Maximum - Minimum); + double faderHeight = gridThumb.ActualHeight; + faderTranslate.Y = -((this.ActualHeight - faderHeight) * percentage); + borderHighLight.Height = Math.Abs(faderTranslate.Y); + } + + private void OnThumbDrag(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) + { + double value = (faderTranslate.Y + e.VerticalChange); + double faderHeight = gridThumb.ActualHeight; + + if (value > 0) value = 0; + if (value < -(this.ActualHeight - faderHeight)) + { + value = -(this.ActualHeight - faderHeight); + } + + faderTranslate.Y = value; + borderHighLight.Height = Math.Abs(faderTranslate.Y); + + double percentage = Math.Abs(value / (this.ActualHeight - faderHeight)); + Value = (Minimum + (Maximum - Minimum) * percentage); + } + + private void OnKeyDown(object sender, KeyEventArgs e) + { + if (e.Key == Key.Down) + { + Value -= Change; + } + else if (e.Key == Key.Up) + { + Value += Change; + } + + Focus(); + + IsKeyDown = true; + + e.Handled = true; + } + + private void OnPreviewMouseDown(object sender, MouseButtonEventArgs e) + { + Focus(); + } + + private void OnKeyUp(object sender, KeyEventArgs e) + { + IsKeyDown = false; + } + } +} diff --git a/Software/Visual_Studio/Tango.Visuals/Fader/fader-dark.png b/Software/Visual_Studio/Tango.Visuals/Fader/fader-dark.png new file mode 100644 index 000000000..b458e5d13 Binary files /dev/null and b/Software/Visual_Studio/Tango.Visuals/Fader/fader-dark.png differ diff --git a/Software/Visual_Studio/Tango.Visuals/Fader/fader-light.png b/Software/Visual_Studio/Tango.Visuals/Fader/fader-light.png new file mode 100644 index 000000000..006498759 Binary files /dev/null and b/Software/Visual_Studio/Tango.Visuals/Fader/fader-light.png differ diff --git a/Software/Visual_Studio/Tango.Visuals/Knob/Knob.xaml b/Software/Visual_Studio/Tango.Visuals/Knob/Knob.xaml new file mode 100644 index 000000000..9c70ad3b9 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Knob/Knob.xaml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/Tango.Visuals/Knob/Knob.xaml.cs b/Software/Visual_Studio/Tango.Visuals/Knob/Knob.xaml.cs new file mode 100644 index 000000000..dab75f2a4 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Knob/Knob.xaml.cs @@ -0,0 +1,562 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Reflection; +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.Media; +using System.Windows.Media.Animation; +using System.Windows.Media.Effects; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.Visuals; + +namespace Tango.Visuals +{ + /// + /// + /// Represents a knob control. + /// + public partial class Knob : UserControl + { + private List lines; + private Line markLine; + private Brush oldTicksHighlightBrush; + private double initialAngle; + private bool _showBigMarkers; + private bool _showSmallMarkers; + private double _initialValue; + + #region Events + + /// + /// Occurs when the knob's value has changed. + /// + public event EventHandler ValueChanged; + + #endregion + + #region Private Methods + + private void SetValueFromMouse(double angle) + { + if (angle < -140) + { + angle = -140; + } + if (angle > 140) + { + angle = 140; + } + + double value = angle + 140; + value = ((value) * 100) / 280; + value = (value * (Maximum - Minimum)) / 100; + value += Minimum; + + if (value < Minimum) + { + Value = Minimum; + } + else if (value > Maximum) + { + Value = Maximum; + } + else + { + Value = value; + } + } + + private void SetAngle(double angle) + { + if (ellipseGrid != null) + { + ellipseGrid.RenderTransformOrigin = new Point(0.5, 0.5); + ellipseGrid.RenderTransform = new RotateTransform(angle); + ellipseGrid.InvalidateMeasure(); + } + } + + private void LightMarkers() + { + if (ellipseGrid != null) + { + RotateTransform rotate = ellipseGrid.RenderTransform as RotateTransform; + double currentAngle = rotate.Angle; + + if (lines != null) + { + foreach (Line m in lines) + { + RotateTransform t = m.RenderTransform as RotateTransform; + if (currentAngle >= t.Angle) + { + m.Stroke = TicksHighlightBrush; + } + else + { + m.Stroke = TicksBrush; + } + } + } + } + } + + private void RenderMarkers() + { + lines = new List(); + + double angleChange = 280 / 20; + double markChange = 5; + double counter = 0; + int marksCounter = 0; + + mainGrid.Children.OfType().ToList().ForEach(x => mainGrid.Children.Remove(x)); + ellipseGrid.Children.OfType().ToList().ForEach(x => mainGrid.Children.Remove(x)); + + if (_showSmallMarkers) + { + for (int i = 0; i < 21; i++) + { + Line line = new Line(); + line.StrokeThickness = TicksWidth; + line.Stroke = TicksBrush; + line.X1 = this.ActualWidth / 2; + if ((marksCounter == markChange || marksCounter == 0) && _showBigMarkers) + { + line.Y1 = 0; + marksCounter = 0; + } + else + { + line.Y1 = 3; + } + line.X2 = this.ActualWidth / 2; + line.Y2 = TicksHeight; + mainGrid.Children.Add(line); + line.RenderTransform = new RotateTransform(counter - 140, this.ActualWidth / 2, this.ActualHeight / 2); + counter += angleChange; + marksCounter++; + lines.Add(line); + } + } + + ellipseGrid.Children.Remove(markLine); + markLine = new Line(); + markLine.StrokeThickness = 2; + markLine.Stroke = TicksHighlightBrush; + markLine.X1 = ellipseGrid.ActualWidth / 2; + markLine.Y1 = 5; + markLine.X2 = markLine.X1; + markLine.Y2 = (ellipseGrid.ActualWidth / 2) * 0.8; + ellipseGrid.Children.Add(markLine); + } + + private static BitmapSource GetImageFromApplicationResource(String resourcePath) + { + String callingAssembly = Assembly.GetCallingAssembly().GetName().Name; + Uri uri = new Uri("/" + callingAssembly + ";component/" + resourcePath, UriKind.Relative); + System.Windows.Resources.StreamResourceInfo info = Application.GetResourceStream(uri); + + var bitmapImage = new BitmapImage(); + bitmapImage.BeginInit(); + bitmapImage.CacheOption = BitmapCacheOption.OnLoad; + bitmapImage.StreamSource = info.Stream; + bitmapImage.EndInit(); + return bitmapImage; + } + + #endregion + + #region Virtual Methods + + /// + /// Called when the value changed. + /// + protected virtual void OnValueChanged() + { + try + { + if (Value < Minimum) + { + Value = Minimum; + } + + if (Value > Maximum) + { + Value = Maximum; + } + + double angle = ((Value - Minimum) * 100) / (Maximum - Minimum); + angle = ((angle * 280) / 100) - 140; + + SetAngle(angle); + LightMarkers(); + } + catch { } + + if (ValueChanged != null) ValueChanged(this, new DoubleValueChangedEventArgs(Value)); + } + + /// + /// Invoked before the value has changed. + /// + /// The value. + /// + protected virtual object OnCoerceValue(double value) + { + var v = SnapToValues ? Math.Round(value, SnapPercision) : value; + return v; + } + + /// + /// Draws the knob. + /// + protected virtual void OnDrawKnob() + { + try + { + RenderMarkers(); + LightMarkers(); + + if (KnobType == KnobType.MetroDark) + { + img.Source = GetImageFromApplicationResource("Knob/volumeKnobMetroDark.png"); + } + else if (KnobType == KnobType.MetroLight) + { + img.Source = GetImageFromApplicationResource("Knob/volumeKnobMetroLight.png"); + } + else if (KnobType == KnobType.Dark) + { + img.Source = GetImageFromApplicationResource("Knob/volumeKnobDark.png"); + } + else if (KnobType == KnobType.Light) + { + img.Source = GetImageFromApplicationResource("Knob/volumeKnobLight.png"); + } + else if (KnobType == KnobType.Complex) + { + img.Source = GetImageFromApplicationResource("Knob/volumeKnobComplex.png"); + } + + + } + catch { } + } + + #endregion + + #region Properties + + /// + /// Gets or sets the ticks highlight brush. + /// + public Brush TicksHighlightBrush + { + get { return (Brush)GetValue(TicksHighlightBrushProperty); } + set { SetValue(TicksHighlightBrushProperty, value); } + } + public static readonly DependencyProperty TicksHighlightBrushProperty = + DependencyProperty.Register("TicksHighlightBrush", typeof(Brush), typeof(Knob), new PropertyMetadata(Brushes.Red, OnPropertiesChanged)); + + /// + /// Gets or sets the ticks brush. + /// + public Brush TicksBrush + { + get { return (Brush)GetValue(TicksBrushProperty); } + set { SetValue(TicksBrushProperty, value); } + } + public static readonly DependencyProperty TicksBrushProperty = + DependencyProperty.Register("TicksBrush", typeof(Brush), typeof(Knob), new PropertyMetadata(Brushes.DimGray, OnPropertiesChanged)); + + /// + /// Gets or sets the type of the knob. + /// + public KnobType KnobType + { + get { return (KnobType)GetValue(KnobTypeProperty); } + set { SetValue(KnobTypeProperty, value); } + } + public static readonly DependencyProperty KnobTypeProperty = + DependencyProperty.Register("KnobType", typeof(KnobType), typeof(Knob), new PropertyMetadata(KnobType.Dark, OnPropertiesChanged)); + + /// + /// Gets or sets amount of change when using keyboard arrows. + /// + public double Change + { + get { return (double)GetValue(ChangeProperty); } + set { SetValue(ChangeProperty, value); } + } + public static readonly DependencyProperty ChangeProperty = + DependencyProperty.Register("Change", typeof(double), typeof(Knob), new PropertyMetadata(0.01)); + + /// + /// Gets or sets the width of the ticks. + /// + public double TicksWidth + { + get { return (double)GetValue(TicksWidthProperty); } + set { SetValue(TicksWidthProperty, value); } + } + public static readonly DependencyProperty TicksWidthProperty = + DependencyProperty.Register("TicksWidth", typeof(double), typeof(Knob), new PropertyMetadata(3.0, OnPropertiesChanged)); + + /// + /// Gets or sets the height of the ticks. + /// + public double TicksHeight + { + get { return (double)GetValue(TicksHeightProperty); } + set { SetValue(TicksHeightProperty, value); } + } + public static readonly DependencyProperty TicksHeightProperty = + DependencyProperty.Register("TicksHeight", typeof(double), typeof(Knob), new PropertyMetadata(10.0, OnPropertiesChanged)); + + /// + /// Gets or sets the value. + /// + public double Value + { + get { return (double)GetValue(ValueProperty); } + set { SetValue(ValueProperty, SnapToValues ? Math.Round(value, SnapPercision) : value); } + } + public static readonly DependencyProperty ValueProperty = + DependencyProperty.Register("Value", typeof(double), typeof(Knob), new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, (d, e) => (d as Knob).OnValueChanged(), (d, value) => (d as Knob).OnCoerceValue((double)value))); + + /// + /// Gets or sets the minimum value. + /// + public double Minimum + { + get { return (double)GetValue(MinimumProperty); } + set { SetValue(MinimumProperty, value); } + } + public static readonly DependencyProperty MinimumProperty = + DependencyProperty.Register("Minimum", typeof(double), typeof(Knob), new PropertyMetadata(0.0, OnPropertiesChanged)); + + public bool SnapToValues + { + get { return (bool)GetValue(SnapToValuesProperty); } + set { SetValue(SnapToValuesProperty, value); } + } + public static readonly DependencyProperty SnapToValuesProperty = + DependencyProperty.Register("SnapToValues", typeof(bool), typeof(Knob), new PropertyMetadata(false)); + + public int SnapPercision + { + get { return (int)GetValue(SnapPercisionProperty); } + set { SetValue(SnapPercisionProperty, value); } + } + public static readonly DependencyProperty SnapPercisionProperty = + DependencyProperty.Register("SnapPercision", typeof(int), typeof(Knob), new PropertyMetadata(1)); + + /// + /// Gets or sets the maximum value. + /// + public double Maximum + { + get { return (double)GetValue(MaximumProperty); } + set { SetValue(MaximumProperty, value); } + } + public static readonly DependencyProperty MaximumProperty = + DependencyProperty.Register("Maximum", typeof(double), typeof(Knob), new PropertyMetadata(1.0, OnPropertiesChanged)); + private static void OnPropertiesChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + (d as Knob).OnDrawKnob(); + (d as Knob).OnValueChanged(); + } + + #endregion + + #region Constructors + + public Knob() + { + _showSmallMarkers = true; + InitializeComponent(); + this.Loaded += Knob_Loaded; + moveThumb.AddHandler(Thumb.MouseEnterEvent, new MouseEventHandler(ellipseGrid_MouseEnter), true); + moveThumb.AddHandler(Thumb.MouseLeaveEvent, new MouseEventHandler(ellipseGrid_MouseLeave), true); + this.PreviewKeyDown += Knob_PreviewKeyDown; + this.PreviewMouseDown += Knob_PreviewMouseDown; + this.Focusable = true; + + KnobType = KnobType.MetroLight; + + this.IsEnabledChanged += Knob_IsEnabledChanged; + + moveThumb.DragStarted += moveThumb_DragStarted; + moveThumb.DragDelta += moveThumb_DragDelta; + + this.SizeChanged += VolumeKnob_SizeChanged; + } + + #endregion + + #region Event Handlers + + /// + /// Handles the SizeChanged event of the VolumeKnob control. + /// + /// The source of the event. + /// The instance containing the event data. + private void VolumeKnob_SizeChanged(object sender, SizeChangedEventArgs e) + { + OnDrawKnob(); + } + + /// + /// Handles the DragDelta event of the moveThumb control. + /// + /// The source of the event. + /// The instance containing the event data. + private void moveThumb_DragDelta(object sender, DragDeltaEventArgs e) + { + double angle = 0; + + angle = e.VerticalChange * -1; + + angle = this.initialAngle + angle; + + this.SetValueFromMouse(angle); + } + + /// + /// Handles the DragStarted event of the moveThumb control. + /// + /// The source of the event. + /// The instance containing the event data. + private void moveThumb_DragStarted(object sender, DragStartedEventArgs e) + { + Point startPoint = Mouse.GetPosition(ellipseGrid); + + RotateTransform t = ellipseGrid.RenderTransform as RotateTransform; + if (t != null) + { + this.initialAngle = t.Angle; + } + } + + /// + /// Handles the IsEnabledChanged event of the Knob control. + /// + /// The source of the event. + /// The instance containing the event data. + private void Knob_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue == e.OldValue) return; + + if (IsEnabled) + { + TicksHighlightBrush = oldTicksHighlightBrush; + RenderMarkers(); + } + else + { + oldTicksHighlightBrush = TicksHighlightBrush; + TicksHighlightBrush = Brushes.Gray; + RenderMarkers(); + } + } + + /// + /// Handles the PreviewMouseDown event of the Knob control. + /// + /// The source of the event. + /// The instance containing the event data. + private void Knob_PreviewMouseDown(object sender, MouseButtonEventArgs e) + { + this.FocusVisualStyle = null; + this.Focusable = true; + this.Focus(); + } + + /// + /// Handles the PreviewKeyDown event of the Knob control. + /// + /// The source of the event. + /// The instance containing the event data. + private void Knob_PreviewKeyDown(object sender, KeyEventArgs e) + { + if (e.Key == Key.Up && Value < Maximum) + { + Value += Change; + } + else if (e.Key == Key.Down && Value > Minimum) + { + Value -= Change; + } + + this.Focusable = true; + this.Focus(); + e.Handled = true; + } + + /// + /// Handles the Loaded event of the Knob control. + /// + /// The source of the event. + /// The instance containing the event data. + private void Knob_Loaded(object sender, RoutedEventArgs e) + { + OnDrawKnob(); + } + + /// + /// Handles the MouseLeave event of the ellipseGrid control. + /// + /// The source of the event. + /// The instance containing the event data. + private void ellipseGrid_MouseLeave(object sender, MouseEventArgs e) + { + DoubleAnimation maskAni = new DoubleAnimation(0, new Duration(TimeSpan.FromMilliseconds(200))); + + maskEllipse.Fill.BeginAnimation(RadialGradientBrush.OpacityProperty, maskAni); + + DoubleAnimation glowAni = new DoubleAnimation(0, new Duration(TimeSpan.FromMilliseconds(200))); + glowEllipse.BeginAnimation(OpacityProperty, glowAni); + + //DoubleAnimation efxAni = new DoubleAnimation(0, new Duration(TimeSpan.FromMilliseconds(200))); + //glowEffect.BeginAnimation(OpacityProperty, efxAni); + + DoubleAnimation glow = new DoubleAnimation(0, new Duration(TimeSpan.FromMilliseconds(200))); + imgGlow.BeginAnimation(RadialGradientBrush.OpacityProperty, glow); + } + + /// + /// Handles the MouseEnter event of the ellipseGrid control. + /// + /// The source of the event. + /// The instance containing the event data. + private void ellipseGrid_MouseEnter(object sender, MouseEventArgs e) + { + DoubleAnimation maskAni = new DoubleAnimation(0.5, new Duration(TimeSpan.FromMilliseconds(200))); + + maskEllipse.Fill.BeginAnimation(RadialGradientBrush.OpacityProperty, maskAni); + + DoubleAnimation glowAni = new DoubleAnimation(1, new Duration(TimeSpan.FromMilliseconds(200))); + glowEllipse.BeginAnimation(OpacityProperty, glowAni); + + //DoubleAnimation efxAni = new DoubleAnimation(1, new Duration(TimeSpan.FromMilliseconds(200))); + //glowEffect.BeginAnimation(OpacityProperty, efxAni); + + DoubleAnimation glow = new DoubleAnimation(0.5, new Duration(TimeSpan.FromMilliseconds(200))); + imgGlow.BeginAnimation(RadialGradientBrush.OpacityProperty, glow); + + } + + #endregion + } +} diff --git a/Software/Visual_Studio/Tango.Visuals/Knob/KnobType.cs b/Software/Visual_Studio/Tango.Visuals/Knob/KnobType.cs new file mode 100644 index 000000000..42ad47aee --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Knob/KnobType.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Visuals +{ + /// + /// Represents enumeration of various styles. + /// + public enum KnobType + { + /// + /// Dark knob theme. + /// + Dark, + /// + /// Light knob theme. + /// + Light, + /// + /// Light metro knob theme. + /// + MetroLight, + /// + /// Dark metro knob theme. + /// + MetroDark, + /// + /// Complex knob theme. + /// + Complex + } +} diff --git a/Software/Visual_Studio/Tango.Visuals/Knob/completeKnobBright.png b/Software/Visual_Studio/Tango.Visuals/Knob/completeKnobBright.png new file mode 100644 index 000000000..d8340deb2 Binary files /dev/null and b/Software/Visual_Studio/Tango.Visuals/Knob/completeKnobBright.png differ diff --git a/Software/Visual_Studio/Tango.Visuals/Knob/completeKnobDark.png b/Software/Visual_Studio/Tango.Visuals/Knob/completeKnobDark.png new file mode 100644 index 000000000..213fffe23 Binary files /dev/null and b/Software/Visual_Studio/Tango.Visuals/Knob/completeKnobDark.png differ diff --git a/Software/Visual_Studio/Tango.Visuals/Knob/volumeKnobComplex.png b/Software/Visual_Studio/Tango.Visuals/Knob/volumeKnobComplex.png new file mode 100644 index 000000000..131f19191 Binary files /dev/null and b/Software/Visual_Studio/Tango.Visuals/Knob/volumeKnobComplex.png differ diff --git a/Software/Visual_Studio/Tango.Visuals/Knob/volumeKnobDark.png b/Software/Visual_Studio/Tango.Visuals/Knob/volumeKnobDark.png new file mode 100644 index 000000000..ec265344d Binary files /dev/null and b/Software/Visual_Studio/Tango.Visuals/Knob/volumeKnobDark.png differ diff --git a/Software/Visual_Studio/Tango.Visuals/Knob/volumeKnobLight.png b/Software/Visual_Studio/Tango.Visuals/Knob/volumeKnobLight.png new file mode 100644 index 000000000..f9d51a128 Binary files /dev/null and b/Software/Visual_Studio/Tango.Visuals/Knob/volumeKnobLight.png differ diff --git a/Software/Visual_Studio/Tango.Visuals/Knob/volumeKnobMetroDark.png b/Software/Visual_Studio/Tango.Visuals/Knob/volumeKnobMetroDark.png new file mode 100644 index 000000000..4a2c665a8 Binary files /dev/null and b/Software/Visual_Studio/Tango.Visuals/Knob/volumeKnobMetroDark.png differ diff --git a/Software/Visual_Studio/Tango.Visuals/Knob/volumeKnobMetroLight.png b/Software/Visual_Studio/Tango.Visuals/Knob/volumeKnobMetroLight.png new file mode 100644 index 000000000..8dd498dfe Binary files /dev/null and b/Software/Visual_Studio/Tango.Visuals/Knob/volumeKnobMetroLight.png differ diff --git a/Software/Visual_Studio/Tango.Visuals/MetroWindowControl/MetroWindowControl.cs b/Software/Visual_Studio/Tango.Visuals/MetroWindowControl/MetroWindowControl.cs new file mode 100644 index 000000000..26835d4d4 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/MetroWindowControl/MetroWindowControl.cs @@ -0,0 +1,301 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +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; + +namespace Tango.Visuals +{ + /// + /// Interaction logic for MetroWindowControl.xaml + /// + //[ContentProperty("RealContent")] + public partial class MetroWindowControl : ContentControl + { + private Window _window; + private bool _preventNextWindowMove; + private Grid PART_MainGrid; + private Thumb PART_ThumbMove; + private Button PART_ButtonClose; + private Button PART_ButtonMaximize; + private Button PART_ButtonMinimize; + private Thumb PART_ThumbResizeRight; + private Thumb PART_ThumbResizeBottom; + private Thumb PART_ThumbResizeBottomRight1; + private Thumb PART_ThumbResizeBottomRight2; + + static MetroWindowControl() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(MetroWindowControl), new FrameworkPropertyMetadata(typeof(MetroWindowControl))); + } + + public bool ShowCloseButton + { + get { return (bool)GetValue(ShowCloseButtonProperty); } + set { SetValue(ShowCloseButtonProperty, value); } + } + public static readonly DependencyProperty ShowCloseButtonProperty = + DependencyProperty.Register("ShowCloseButton", typeof(bool), typeof(MetroWindowControl), new PropertyMetadata(true)); + + public bool ShowMaximizeButton + { + get { return (bool)GetValue(ShowMaximizeButtonProperty); } + set { SetValue(ShowMaximizeButtonProperty, value); } + } + public static readonly DependencyProperty ShowMaximizeButtonProperty = + DependencyProperty.Register("ShowMaximizeButton", typeof(bool), typeof(MetroWindowControl), new PropertyMetadata(true)); + + public bool ShowMinimizeButton + { + get { return (bool)GetValue(ShowMinimizeButtonProperty); } + set { SetValue(ShowMinimizeButtonProperty, value); } + } + public static readonly DependencyProperty ShowMinimizeButtonProperty = + DependencyProperty.Register("ShowMinimizeButton", typeof(bool), typeof(MetroWindowControl), new PropertyMetadata(true)); + + public Brush TitleBackground + { + get { return (Brush)GetValue(TitleBackgroundProperty); } + set { SetValue(TitleBackgroundProperty, value); } + } + public static readonly DependencyProperty TitleBackgroundProperty = + DependencyProperty.Register("TitleBackground", typeof(Brush), typeof(MetroWindowControl), new PropertyMetadata(null)); + + public Brush TitleInactiveBackground + { + get { return (Brush)GetValue(TitleInactiveBackgroundProperty); } + set { SetValue(TitleInactiveBackgroundProperty, value); } + } + public static readonly DependencyProperty TitleInactiveBackgroundProperty = + DependencyProperty.Register("TitleInactiveBackground", typeof(Brush), typeof(MetroWindowControl), new PropertyMetadata(null)); + + public Brush TitleForeground + { + get { return (Brush)GetValue(TitleForegroundProperty); } + set { SetValue(TitleForegroundProperty, value); } + } + public static readonly DependencyProperty TitleForegroundProperty = + DependencyProperty.Register("TitleForeground", typeof(Brush), typeof(MetroWindowControl), new PropertyMetadata(null)); + + public Brush TitleControlsHoverBrush + { + get { return (Brush)GetValue(TitleControlsHoverBrushProperty); } + set { SetValue(TitleControlsHoverBrushProperty, value); } + } + public static readonly DependencyProperty TitleControlsHoverBrushProperty = + DependencyProperty.Register("TitleControlsHoverBrush", typeof(Brush), typeof(MetroWindowControl), new PropertyMetadata(null)); + + public double TitleHeight + { + get { return (double)GetValue(TitleHeightProperty); } + set { SetValue(TitleHeightProperty, value); } + } + public static readonly DependencyProperty TitleHeightProperty = + DependencyProperty.Register("TitleHeight", typeof(double), typeof(MetroWindowControl), new PropertyMetadata(35.0)); + + public Brush TitleControlsPressedBrush + { + get { return (Brush)GetValue(TitleControlsPressedBrushProperty); } + set { SetValue(TitleControlsPressedBrushProperty, value); } + } + public static readonly DependencyProperty TitleControlsPressedBrushProperty = + DependencyProperty.Register("TitleControlsPressedBrush", typeof(Brush), typeof(MetroWindowControl), new PropertyMetadata(null)); + + public double TitleFontSize + { + get { return (double)GetValue(TitleFontSizeProperty); } + set { SetValue(TitleFontSizeProperty, value); } + } + public static readonly DependencyProperty TitleFontSizeProperty = + DependencyProperty.Register("TitleFontSize", typeof(double), typeof(MetroWindowControl), new PropertyMetadata(12.0)); + + public double BlurRadius + { + get { return (double)GetValue(BlurRadiusProperty); } + set { SetValue(BlurRadiusProperty, value); } + } + public static readonly DependencyProperty BlurRadiusProperty = + DependencyProperty.Register("BlurRadius", typeof(double), typeof(MetroWindowControl), new PropertyMetadata(10.0)); + + public Brush BorderInactiveBrush + { + get { return (Brush)GetValue(BorderInactiveBrushProperty); } + set { SetValue(BorderInactiveBrushProperty, value); } + } + public static readonly DependencyProperty BorderInactiveBrushProperty = + DependencyProperty.Register("BorderInactiveBrush", typeof(Brush), typeof(MetroWindowControl), new PropertyMetadata(null)); + + public Brush BorderActiveBrush + { + get { return (Brush)GetValue(BorderActiveBrushProperty); } + set { SetValue(BorderActiveBrushProperty, value); } + } + public static readonly DependencyProperty BorderActiveBrushProperty = + DependencyProperty.Register("BorderActiveBrush", typeof(Brush), typeof(MetroWindowControl), new PropertyMetadata(null)); + + public bool AllowResize + { + get { return (bool)GetValue(AllowResizeProperty); } + set { SetValue(AllowResizeProperty, value); } + } + public static readonly DependencyProperty AllowResizeProperty = + DependencyProperty.Register("AllowResize", typeof(bool), typeof(MetroWindowControl), new PropertyMetadata(true)); + + public DataTemplate TitleTemplate + { + get { return (DataTemplate)GetValue(TitleTemplateProperty); } + set { SetValue(TitleTemplateProperty, value); } + } + public static readonly DependencyProperty TitleTemplateProperty = + DependencyProperty.Register("TitleTemplate", typeof(DataTemplate), typeof(MetroWindowControl), new PropertyMetadata(null)); + public FrameworkElement RealContent + { + get { return (FrameworkElement)GetValue(RealContentProperty); } + set { SetValue(RealContentProperty, value); } + } + public static readonly DependencyProperty RealContentProperty = + DependencyProperty.Register("RealContent", typeof(FrameworkElement), typeof(MetroWindowControl), new PropertyMetadata(null)); + + public MetroWindowControl() + { + //this.Loaded += MetroWindowControl_Loaded; + } + + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + + if (DesignerProperties.GetIsInDesignMode(this)) return; + + _window = Window.GetWindow(this); + + if (_window == null) throw new InvalidOperationException("MetroWindowControl must be nested inside a window."); + + _window.WindowStyle = WindowStyle.None; + _window.ResizeMode = ResizeMode.NoResize; + + PART_MainGrid = GetTemplateChild(nameof(PART_MainGrid)) as Grid; + PART_ThumbMove = GetTemplateChild(nameof(PART_ThumbMove)) as Thumb; + PART_ButtonMinimize = GetTemplateChild(nameof(PART_ButtonMinimize)) as Button; + PART_ButtonMaximize = GetTemplateChild(nameof(PART_ButtonMaximize)) as Button; + PART_ButtonClose = GetTemplateChild(nameof(PART_ButtonClose)) as Button; + PART_ThumbResizeRight = GetTemplateChild(nameof(PART_ThumbResizeRight)) as Thumb; + PART_ThumbResizeBottom = GetTemplateChild(nameof(PART_ThumbResizeBottom)) as Thumb; + PART_ThumbResizeBottomRight1 = GetTemplateChild(nameof(PART_ThumbResizeBottomRight1)) as Thumb; + PART_ThumbResizeBottomRight2 = GetTemplateChild(nameof(PART_ThumbResizeBottomRight2)) as Thumb; + + if (_window.AllowsTransparency == true) + { + PART_MainGrid.Margin = new Thickness(BlurRadius / 2); + _window.Background = Brushes.Transparent; + } + + _window.StateChanged += _window_StateChanged; + + this.BorderBrush = null; + + PART_ThumbMove.MouseDoubleClick += OnMoveThumbDoubleClick; + PART_ThumbMove.DragDelta += OnTitleThumbMove; + PART_ButtonMinimize.Click += OnMinimizeClick; + PART_ButtonMaximize.Click += OnMaximizeRestoreClick; + PART_ButtonClose.Click += OnCloseClick; + PART_ThumbResizeRight.DragDelta += OnRightThumbResize; + PART_ThumbResizeBottom.DragDelta += OnBottomThumbResize; + PART_ThumbResizeBottomRight1.DragDelta += OnRightBottomThumbResize; + PART_ThumbResizeBottomRight2.DragDelta += OnRightBottomThumbResize; + } + + private void OnTitleThumbMove(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) + { + if (_preventNextWindowMove) + { + _preventNextWindowMove = false; + return; + } + + _window.Left += e.HorizontalChange; + _window.Top += e.VerticalChange; + } + + private void OnRightThumbResize(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) + { + _window.Width += e.HorizontalChange; + } + + private void OnBottomThumbResize(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) + { + _window.Height += e.VerticalChange; + } + + private void OnRightBottomThumbResize(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) + { + _window.Width += e.HorizontalChange; + _window.Height += e.VerticalChange; + } + + private void OnMoveThumbDoubleClick(object sender, MouseButtonEventArgs e) + { + if (!ShowMaximizeButton) return; + + _preventNextWindowMove = true; + + if (_window.WindowState == WindowState.Normal) + { + _window.WindowState = WindowState.Maximized; + } + else if (_window.WindowState == WindowState.Maximized) + { + _window.WindowState = WindowState.Normal; + } + } + + private void _window_StateChanged(object sender, EventArgs e) + { + if (_window.WindowState == WindowState.Maximized) + { + PART_MainGrid.Margin = new Thickness(); + } + else if (_window.WindowState == WindowState.Normal) + { + if (_window.AllowsTransparency == true) + { + PART_MainGrid.Margin = new Thickness(5); + } + } + } + + private void OnCloseClick(object sender, RoutedEventArgs e) + { + _window.Close(); + } + + private void OnMaximizeRestoreClick(object sender, RoutedEventArgs e) + { + if (_window.WindowState == WindowState.Normal) + { + _window.WindowState = WindowState.Maximized; + } + else if (_window.WindowState == WindowState.Maximized) + { + _window.WindowState = WindowState.Normal; + } + } + + private void OnMinimizeClick(object sender, RoutedEventArgs e) + { + _window.WindowState = WindowState.Minimized; + } + } +} diff --git a/Software/Visual_Studio/Tango.Visuals/MetroWindowControl/Style.xaml b/Software/Visual_Studio/Tango.Visuals/MetroWindowControl/Style.xaml new file mode 100644 index 000000000..86456921e --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/MetroWindowControl/Style.xaml @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Visuals/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Tango.Visuals/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..074e070df --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Properties/AssemblyInfo.cs @@ -0,0 +1,6 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Tango - Exotic Visual Elements")] +[assembly: ComVisible(false)] \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Visuals/Properties/Resources.Designer.cs b/Software/Visual_Studio/Tango.Visuals/Properties/Resources.Designer.cs new file mode 100644 index 000000000..60752a83a --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.Visuals.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tango.Visuals.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/Software/Visual_Studio/Tango.Visuals/Properties/Resources.resx b/Software/Visual_Studio/Tango.Visuals/Properties/Resources.resx new file mode 100644 index 000000000..af7dbebba --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Visuals/Properties/Settings.Designer.cs b/Software/Visual_Studio/Tango.Visuals/Properties/Settings.Designer.cs new file mode 100644 index 000000000..7543ff006 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.Visuals.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.1.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/Software/Visual_Studio/Tango.Visuals/Properties/Settings.settings b/Software/Visual_Studio/Tango.Visuals/Properties/Settings.settings new file mode 100644 index 000000000..033d7a5e9 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Visuals/Tango.Visuals.csproj b/Software/Visual_Studio/Tango.Visuals/Tango.Visuals.csproj new file mode 100644 index 000000000..4eaa3376e --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Tango.Visuals.csproj @@ -0,0 +1,199 @@ + + + + + Debug + AnyCPU + {CF7C0FF4-9440-42CF-83B8-C060772792D4} + library + Properties + Tango.Visuals + Tango.Visuals + v4.6 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + + + + true + full + false + ..\Build\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + 4.0 + + + + + + + + GlobalVersionInfo.cs + + + + PieAxisTicks.xaml + + + + + XAxisDoubles.xaml + + + XAxisLabels.xaml + + + XAxisTicks.xaml + + + + + + Knob.xaml + + + YAxisDoubles.xaml + + + YAxisLabels.xaml + + + YAxisTicks.xaml + + + Fader.xaml + + + + + VUMeter.xaml + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + + + Designer + MSBuild:Compile + + + + + + + + + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Visuals/Themes/DarkTheme.xaml b/Software/Visual_Studio/Tango.Visuals/Themes/DarkTheme.xaml new file mode 100644 index 000000000..9bdbb33fa --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Themes/DarkTheme.xaml @@ -0,0 +1,3397 @@ + + + + + + + #444444 + #252525 + #595959 + #353535 + #595959 + #3D3D3D + #545454 + #666666 + + Gainsboro + + #BDBDBD + #525252 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + M-0.7,5.2 L-2.2,6.7 3.6,12.6 9.5,6.7 8,5.2 3.6,9.6 z + M-2.2,10.9 L-0.7,12.4 3.7,8 8,12.4 9.5,10.9 3.7,5 z + M1.0E-41,4.2 L0,2.1 2.5,4.5 6.7,4.4E-47 6.7,2.3 2.5,6.7 z + M7.2,5 L5.5,7.16 4.16,6.3 3.5,6.7 5.5,8.4 8.6,5.25 C8.6,5.25 8,4.7 7.22,5 + M 0,0 L 4,3.5 L 0,7 Z + M 1,1.5 L 4.5,5 L 8,1.5 + M 1,4.5 L 4.5,1 L 8,4.5 + M6.5,2.6C4.767,0.973 2.509,0 0,0 0,0 0,19 0,19L23,19z + M3.5445026,0 L7.0890052,7.0890053 L3.0459049E-09,7.0890053 z + M-0,6 L-0,8 8,8 8,-0 6,-0 6,6 z + M5,-0 L9,5 1,5 z + + + + #FF595959 + #FF393939 + #FF9BB1C5 + + + + #FFFFFFFF + #FF737373 + + #FF000000 + #FFFFFFFF + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/Tango.Visuals/Themes/Generic.xaml b/Software/Visual_Studio/Tango.Visuals/Themes/Generic.xaml new file mode 100644 index 000000000..38a8b8ea6 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Themes/Generic.xaml @@ -0,0 +1,11 @@ + + + + + + + diff --git a/Software/Visual_Studio/Tango.Visuals/Themes/LeftMarginMultiplierConverter.cs b/Software/Visual_Studio/Tango.Visuals/Themes/LeftMarginMultiplierConverter.cs new file mode 100644 index 000000000..95a5219ab --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Themes/LeftMarginMultiplierConverter.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; + +namespace DarkBlendTheme +{ + internal class LeftMarginMultiplierConverter : IValueConverter + { + public double Length { get; set; } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + var item = value as TreeViewItem; + if (item == null) + return new Thickness(0); + + return new Thickness(Length * item.GetDepth(), 0, 0, 0); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new System.NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/Tango.Visuals/Themes/TreeViewItemExtensions.cs b/Software/Visual_Studio/Tango.Visuals/Themes/TreeViewItemExtensions.cs new file mode 100644 index 000000000..736b84d47 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Themes/TreeViewItemExtensions.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Media; + +namespace DarkBlendTheme +{ + internal static class TreeViewItemExtensions + { + public static int GetDepth(this TreeViewItem item) + { + TreeViewItem parent; + while ((parent = GetParent(item)) != null) + { + return GetDepth(parent) + 1; + } + return 0; + } + + private static TreeViewItem GetParent(TreeViewItem item) + { + var parent = VisualTreeHelper.GetParent(item); + + while (!(parent is TreeViewItem || parent is TreeView)) + { + if (parent == null) return null; + parent = VisualTreeHelper.GetParent(parent); + } + return parent as TreeViewItem; + } + } +} diff --git a/Software/Visual_Studio/Tango.Visuals/VUMeter/VUMeter.xaml b/Software/Visual_Studio/Tango.Visuals/VUMeter/VUMeter.xaml new file mode 100644 index 000000000..2f514e9ca --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/VUMeter/VUMeter.xaml @@ -0,0 +1,220 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/Tango.Visuals/VUMeter/VUMeter.xaml.cs b/Software/Visual_Studio/Tango.Visuals/VUMeter/VUMeter.xaml.cs new file mode 100644 index 000000000..a3a6c4e40 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/VUMeter/VUMeter.xaml.cs @@ -0,0 +1,253 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +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.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.Visuals.Components; + +namespace Tango.Visuals +{ + /// + /// Interaction logic for VUMeter.xaml + /// + public partial class VUMeter : UserControl + { + private const double RED_PRECENTAGE = 0.1; + private const double YELLOW_PRECENTAGE = 0.2; + + public VUMeter() + { + Leds = new ObservableCollection(); + CreateLeds(); + InitializeComponent(); + } + + internal ObservableCollection Leds + { + get { return (ObservableCollection)GetValue(LedsProperty); } + set { SetValue(LedsProperty, value); } + } + internal static readonly DependencyProperty LedsProperty = + DependencyProperty.Register("Leds", typeof(ObservableCollection), typeof(VUMeter), new PropertyMetadata(null)); + public int LedCount + { + get { return (int)GetValue(LedCountProperty); } + set { SetValue(LedCountProperty, value); } + } + public static readonly DependencyProperty LedCountProperty = + DependencyProperty.Register("LedCount", typeof(int), typeof(VUMeter), new PropertyMetadata(14, (d, e) => (d as VUMeter).CreateLeds())); + + public double Maximum + { + get { return (double)GetValue(MaximumProperty); } + set { SetValue(MaximumProperty, value); } + } + public static readonly DependencyProperty MaximumProperty = + DependencyProperty.Register("Maximum", typeof(double), typeof(VUMeter), new PropertyMetadata(1.0, (d, e) => (d as VUMeter).RenderCurrentValue())); + + public double Minimum + { + get { return (double)GetValue(MinimumProperty); } + set { SetValue(MinimumProperty, value); } + } + public static readonly DependencyProperty MinimumProperty = + DependencyProperty.Register("Minimum", typeof(double), typeof(VUMeter), new PropertyMetadata(0.0, (d, e) => (d as VUMeter).RenderCurrentValue())); + + public double Value + { + get { return (double)GetValue(ValueProperty); } + set { SetValue(ValueProperty, value); } + } + public static readonly DependencyProperty ValueProperty = + DependencyProperty.Register("Value", typeof(double), typeof(VUMeter), new PropertyMetadata(0.0, (d, e) => (d as VUMeter).RenderCurrentValue())); + + public Brush HighBrush + { + get { return (Brush)GetValue(HighBrushProperty); } + set { SetValue(HighBrushProperty, value); } + } + public static readonly DependencyProperty HighBrushProperty = + DependencyProperty.Register("HighBrush", typeof(Brush), typeof(VUMeter), new PropertyMetadata(new SolidColorBrush(Color.FromRgb(255, 81, 3)), (d, e) => (d as VUMeter).CreateLeds())); + + public Brush MidBrush + { + get { return (Brush)GetValue(MidBrushProperty); } + set { SetValue(MidBrushProperty, value); } + } + public static readonly DependencyProperty MidBrushProperty = + DependencyProperty.Register("MidBrush", typeof(Brush), typeof(VUMeter), new PropertyMetadata(new SolidColorBrush(Color.FromRgb(255, 254, 82)), (d, e) => (d as VUMeter).CreateLeds())); + + public Brush LowBrush + { + get { return (Brush)GetValue(LowBrushProperty); } + set { SetValue(LowBrushProperty, value); } + } + public static readonly DependencyProperty LowBrushProperty = + DependencyProperty.Register("LowBrush", typeof(Brush), typeof(VUMeter), new PropertyMetadata(new SolidColorBrush(Color.FromRgb(80, 254, 0)), (d, e) => (d as VUMeter).CreateLeds())); + public bool UseTexture + { + get { return (bool)GetValue(UseTextureProperty); } + set { SetValue(UseTextureProperty, value); } + } + public static readonly DependencyProperty UseTextureProperty = + DependencyProperty.Register("UseTexture", typeof(bool), typeof(VUMeter), new PropertyMetadata(true)); + + public bool SunkenLeds + { + get { return (bool)GetValue(SunkenLedsProperty); } + set { SetValue(SunkenLedsProperty, value); } + } + public static readonly DependencyProperty SunkenLedsProperty = + DependencyProperty.Register("SunkenLeds", typeof(bool), typeof(VUMeter), new PropertyMetadata(true)); + + public bool EmulateLight + { + get { return (bool)GetValue(EmulateLightProperty); } + set { SetValue(EmulateLightProperty, value); } + } + public static readonly DependencyProperty EmulateLightProperty = + DependencyProperty.Register("EmulateLight", typeof(bool), typeof(VUMeter), new PropertyMetadata(true)); + + public bool EmulateOuterLight + { + get { return (bool)GetValue(EmulateOuterLightProperty); } + set { SetValue(EmulateOuterLightProperty, value); } + } + public static readonly DependencyProperty EmulateOuterLightProperty = + DependencyProperty.Register("EmulateOuterLight", typeof(bool), typeof(VUMeter), new PropertyMetadata(true)); + + public Thickness LedsMargin + { + get { return (Thickness)GetValue(LedsMarginProperty); } + set { SetValue(LedsMarginProperty, value); } + } + public static readonly DependencyProperty LedsMarginProperty = + DependencyProperty.Register("LedsMargin", typeof(Thickness), typeof(VUMeter), new PropertyMetadata(new Thickness(2, 2, 2, 1))); + + public TickPlacement TicksPlacement + { + get { return (TickPlacement)GetValue(TicksPlacementProperty); } + set { SetValue(TicksPlacementProperty, value); } + } + public static readonly DependencyProperty TicksPlacementProperty = + DependencyProperty.Register("TicksPlacement", typeof(TickPlacement), typeof(VUMeter), new PropertyMetadata(TickPlacement.TopLeft)); + + public double TicksMinimum + { + get { return (double)GetValue(TicksMinimumProperty); } + set { SetValue(TicksMinimumProperty, value); } + } + public static readonly DependencyProperty TicksMinimumProperty = + DependencyProperty.Register("TicksMinimum", typeof(double), typeof(VUMeter), new PropertyMetadata(-60.0)); + + public double TicksMaximum + { + get { return (double)GetValue(TicksMaximumProperty); } + set { SetValue(TicksMaximumProperty, value); } + } + public static readonly DependencyProperty TicksMaximumProperty = + DependencyProperty.Register("TicksMaximum", typeof(double), typeof(VUMeter), new PropertyMetadata(8.0)); + + public int TicksCount + { + get { return (int)GetValue(TicksCountProperty); } + set { SetValue(TicksCountProperty, value); } + } + public static readonly DependencyProperty TicksCountProperty = + DependencyProperty.Register("TicksCount", typeof(int), typeof(VUMeter), new PropertyMetadata(10)); + + public String TicksFormat + { + get { return (String)GetValue(TicksFormatProperty); } + set { SetValue(TicksFormatProperty, value); } + } + public static readonly DependencyProperty TicksFormatProperty = + DependencyProperty.Register("TicksFormat", typeof(String), typeof(VUMeter), new PropertyMetadata("0")); + + public bool ShowTicksLines + { + get { return (bool)GetValue(ShowTicksLinesProperty); } + set { SetValue(ShowTicksLinesProperty, value); } + } + public static readonly DependencyProperty ShowTicksLinesProperty = + DependencyProperty.Register("ShowTicksLines", typeof(bool), typeof(VUMeter), new PropertyMetadata(false)); + + public bool ShowTicksLabels + { + get { return (bool)GetValue(ShowTicksLabelsProperty); } + set { SetValue(ShowTicksLabelsProperty, value); } + } + public static readonly DependencyProperty ShowTicksLabelsProperty = + DependencyProperty.Register("ShowTicksLabels", typeof(bool), typeof(VUMeter), new PropertyMetadata(false)); + + public double LedCornerRadius + { + get { return (double)GetValue(LedCornerRadiusProperty); } + set { SetValue(LedCornerRadiusProperty, value); } + } + public static readonly DependencyProperty LedCornerRadiusProperty = + DependencyProperty.Register("LedCornerRadius", typeof(double), typeof(VUMeter), new PropertyMetadata(2.0)); + + public Orientation Orientation + { + get { return (Orientation)GetValue(OrientationProperty); } + set { SetValue(OrientationProperty, value); } + } + public static readonly DependencyProperty OrientationProperty = + DependencyProperty.Register("Orientation", typeof(Orientation), typeof(VUMeter), new PropertyMetadata(Orientation.Vertical)); + + public Brush LedBackground + { + get { return (Brush)GetValue(LedBackgroundProperty); } + set { SetValue(LedBackgroundProperty, value); } + } + public static readonly DependencyProperty LedBackgroundProperty = + DependencyProperty.Register("LedBackground", typeof(Brush), typeof(VUMeter), new PropertyMetadata(new SolidColorBrush(Color.FromRgb(15, 15, 15)))); + + private void RenderCurrentValue() + { + double percentage = (Value - Minimum) / (Maximum - Minimum); + int ledsToTurn = (int)((double)LedCount - (LedCount * percentage)); + + for (int i = LedCount - 1; i >= 0; i--) + { + Leds[i].On = i >= ledsToTurn; + } + } + + private void CreateLeds() + { + Leds.Clear(); + + for (int i = 0; i < LedCount * RED_PRECENTAGE; i++) + { + Leds.Add(new VULed() { Brush = HighBrush }); + } + + for (int i = 0; i < LedCount * YELLOW_PRECENTAGE; i++) + { + Leds.Add(new VULed() { Brush = MidBrush }); + } + + int remaining = LedCount - Leds.Count; + + for (int i = 0; i < remaining; i++) + { + Leds.Add(new VULed() { Brush = LowBrush }); + } + + RenderCurrentValue(); + } + } +} diff --git a/Software/Visual_Studio/Tango.Visuals/VUMeter/led-texture.png b/Software/Visual_Studio/Tango.Visuals/VUMeter/led-texture.png new file mode 100644 index 000000000..0c4b1609e Binary files /dev/null and b/Software/Visual_Studio/Tango.Visuals/VUMeter/led-texture.png differ diff --git a/Software/Visual_Studio/Tango.Visuals/YAxisDoubles/YAxisDoubles.xaml b/Software/Visual_Studio/Tango.Visuals/YAxisDoubles/YAxisDoubles.xaml new file mode 100644 index 000000000..8db68b780 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/YAxisDoubles/YAxisDoubles.xaml @@ -0,0 +1,11 @@ + + + + + diff --git a/Software/Visual_Studio/Tango.Visuals/YAxisDoubles/YAxisDoubles.xaml.cs b/Software/Visual_Studio/Tango.Visuals/YAxisDoubles/YAxisDoubles.xaml.cs new file mode 100644 index 000000000..218aefbfa --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/YAxisDoubles/YAxisDoubles.xaml.cs @@ -0,0 +1,172 @@ +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; + +namespace Tango.Visuals +{ + /// + /// Interaction logic for YAxisDoubles.xaml + /// + public partial class YAxisDoubles : UserControl + { + /// + /// Initializes a new instance of the class. + /// + public YAxisDoubles() + { + InitializeComponent(); + this.FocusVisualStyle = null; + this.Focusable = false; + this.Loaded += YAxisDoubles_Loaded; + } + + /// + /// Handles the Loaded event of the YAxisDoubles control. + /// + /// The source of the event. + /// The instance containing the event data. + private void YAxisDoubles_Loaded(object sender, RoutedEventArgs e) + { + DrawTicks(); + } + + /// + /// Gets or sets the number of ticks. + /// + public int Ticks + { + get { return (int)GetValue(TicksProperty); } + set { SetValue(TicksProperty, value); } + } + public static readonly DependencyProperty TicksProperty = + DependencyProperty.Register("Ticks", typeof(int), typeof(YAxisDoubles), new PropertyMetadata(8, (d, e) => (d as YAxisDoubles).DrawTicks())); + + /// + /// Gets or sets the minimum value. + /// + public double Minimum + { + get { return (double)GetValue(MinimumProperty); } + set { SetValue(MinimumProperty, value); } + } + public static readonly DependencyProperty MinimumProperty = + DependencyProperty.Register("Minimum", typeof(double), typeof(YAxisDoubles), new PropertyMetadata(0.0, (d, e) => (d as YAxisDoubles).DrawTicks())); + + /// + /// Gets or sets the maximum value. + /// + public double Maximum + { + get { return (double)GetValue(MaximumProperty); } + set { SetValue(MaximumProperty, value); } + } + public static readonly DependencyProperty MaximumProperty = + DependencyProperty.Register("Maximum", typeof(double), typeof(YAxisDoubles), new PropertyMetadata(100.0, (d, e) => (d as YAxisDoubles).DrawTicks())); + + /// + /// Gets or sets the string format. + /// + public String StringFormat + { + get { return (String)GetValue(StringFormatProperty); } + set { SetValue(StringFormatProperty, value); } + } + public static readonly DependencyProperty StringFormatProperty = + DependencyProperty.Register("StringFormat", typeof(String), typeof(YAxisDoubles), new PropertyMetadata(null, (d, e) => (d as YAxisDoubles).DrawTicks())); + + + /// + /// Gets or sets the label alignment. + /// + public HorizontalAlignment LabelAlignment + { + get { return (HorizontalAlignment)GetValue(LabelAlignmentProperty); } + set { SetValue(LabelAlignmentProperty, value); } + } + public static readonly DependencyProperty LabelAlignmentProperty = + DependencyProperty.Register("LabelAlignment", typeof(HorizontalAlignment), typeof(YAxisDoubles), new PropertyMetadata(HorizontalAlignment.Right, (d, e) => (d as YAxisDoubles).DrawTicks())); + + /// + /// Gets or sets the label template. + /// + public DataTemplate LabelTemplate + { + get { return (DataTemplate)GetValue(LabelTemplateProperty); } + set { SetValue(LabelTemplateProperty, value); } + } + public static readonly DependencyProperty LabelTemplateProperty = + DependencyProperty.Register("LabelTemplate", typeof(DataTemplate), typeof(YAxisDoubles), new PropertyMetadata(null)); + + + + /// + /// Draws the labels. + /// + private void DrawTicks() + { + grid.RowDefinitions.Clear(); + grid.Children.Clear(); + grid.ClipToBounds = false; + + var steps = Enumerable.Range(0, Ticks) + .Select(i => Minimum + (Maximum - Minimum) * ((double)i / (Ticks - 1))).ToList(); + + steps.Reverse(); + + for (int i = 0; i < Ticks; i++) + { + if (i == Ticks - 1) + { + var container = AddLabel(steps[i].ToString(StringFormat != null ? StringFormat : "0.0"), i); + container.VerticalAlignment = System.Windows.VerticalAlignment.Bottom; + grid.Children.Add(container); + container.Loaded += (x, y) => + { + container.Margin = new Thickness(0, 0, 0, (container.ActualHeight / 2) * -1); + }; + } + else + { + + RowDefinition row = new RowDefinition(); + row.Height = new GridLength(1, GridUnitType.Star); + grid.RowDefinitions.Add(row); + var container = AddLabel(steps[i].ToString(StringFormat != null ? StringFormat : "0.0"), i); + grid.Children.Add(container); + container.Loaded += (x, y) => + { + container.Margin = new Thickness(0, (container.ActualHeight / 2) * -1, 0, 0); + }; + } + } + } + + /// + /// Adds the label. + /// + /// The text. + /// The index. + /// + private ContentControl AddLabel(String text, int index) + { + ContentControl label = new ContentControl(); + label.Content = text; + label.ContentTemplate = LabelTemplate; + label.VerticalAlignment = System.Windows.VerticalAlignment.Top; + label.HorizontalAlignment = LabelAlignment; + Grid.SetRow(label, index); + return label; + } + } +} diff --git a/Software/Visual_Studio/Tango.Visuals/YAxisTicks/YAxisTicks.xaml b/Software/Visual_Studio/Tango.Visuals/YAxisTicks/YAxisTicks.xaml new file mode 100644 index 000000000..68eca47c0 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/YAxisTicks/YAxisTicks.xaml @@ -0,0 +1,11 @@ + + + + + diff --git a/Software/Visual_Studio/Tango.Visuals/YAxisTicks/YAxisTicks.xaml.cs b/Software/Visual_Studio/Tango.Visuals/YAxisTicks/YAxisTicks.xaml.cs new file mode 100644 index 000000000..6aa713d16 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/YAxisTicks/YAxisTicks.xaml.cs @@ -0,0 +1,197 @@ +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; + +namespace Tango.Visuals +{ + /// + /// Interaction logic for TicksAxis.xaml + /// + public partial class YAxisTicks : UserControl + { + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + public YAxisTicks() + { + InitializeComponent(); + this.FocusVisualStyle = null; + this.Focusable = false; + this.Loaded += TicksAxis_Loaded; + } + + #endregion + + #region Event Handlers + + /// + /// Handles the Loaded event of the TicksAxis control. + /// + /// The source of the event. + /// The instance containing the event data. + private void TicksAxis_Loaded(object sender, RoutedEventArgs e) + { + DrawTicks(); + } + + #endregion + + #region Properties + + /// + /// Gets or sets the ticks. + /// + public int Ticks + { + get { return (int)GetValue(TicksProperty); } + set { SetValue(TicksProperty, value); } + } + public static readonly DependencyProperty TicksProperty = + DependencyProperty.Register("Ticks", typeof(int), typeof(YAxisTicks), new PropertyMetadata(11, (d, e) => (d as YAxisTicks).DrawTicks())); + + /// + /// Gets or sets the tick template. + /// + public DataTemplate TickTemplate + { + get { return (DataTemplate)GetValue(TickTemplateProperty); } + set { SetValue(TickTemplateProperty, value); } + } + public static readonly DependencyProperty TickTemplateProperty = + DependencyProperty.Register("TickTemplate", typeof(DataTemplate), typeof(YAxisTicks), new PropertyMetadata(null, (d, e) => (d as YAxisTicks).DrawTicks())); + + /// + /// Gets or sets the big tick interval. + /// + public int? BigTickInterval + { + get { return (int?)GetValue(BigTickIntervalProperty); } + set { SetValue(BigTickIntervalProperty, value); } + } + public static readonly DependencyProperty BigTickIntervalProperty = + DependencyProperty.Register("BigTickInterval", typeof(int?), typeof(YAxisTicks), new PropertyMetadata(null, (d, e) => (d as YAxisTicks).DrawTicks())); + + /// + /// Gets or sets the big tick template. + /// + public DataTemplate BigTickTemplate + { + get { return (DataTemplate)GetValue(BigTickTemplateProperty); } + set { SetValue(BigTickTemplateProperty, value); } + } + public static readonly DependencyProperty BigTickTemplateProperty = + DependencyProperty.Register("BigTickTemplate", typeof(DataTemplate), typeof(YAxisTicks), new PropertyMetadata(null)); + + #endregion + + #region Methods + + /// + /// Draws the ticks. + /// + private void DrawTicks() + { + grid.Children.Clear(); + grid.RowDefinitions.Clear(); + + for (int i = 0; i < Ticks; i++) + { + if (i == Ticks - 1) + { + ContentControl tick = null; + + if (BigTickInterval != null && BigTickTemplate != null) + { + tick = AddBigTick(i, i); + } + else + { + tick = AddTick(i, i); + } + tick.VerticalAlignment = System.Windows.VerticalAlignment.Bottom; + grid.Children.Add(tick); + } + else + { + ContentControl tick = null; + + RowDefinition row = new RowDefinition(); + row.Height = new GridLength(1, GridUnitType.Star); + grid.RowDefinitions.Add(row); + + + if (BigTickInterval != null && (double)i % (double)BigTickInterval == 0 && BigTickTemplate != null) + { + tick = AddBigTick(i, i); + } + else + { + tick = AddTick(i, i); + } + + grid.Children.Add(tick); + } + } + } + + /// + /// Adds the tick. + /// + /// The value. + /// The index. + /// + private ContentControl AddTick(double value, int index) + { + ContentControl tick = new ContentControl(); + tick.Focusable = false; + tick.VerticalAlignment = System.Windows.VerticalAlignment.Top; + tick.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; + Grid.SetRow(tick, index); + + if (TickTemplate != null) + { + tick.ContentTemplate = TickTemplate; + } + + return tick; + } + + /// + /// Adds big tick. + /// + /// The value. + /// The index. + /// + private ContentControl AddBigTick(double value, int index) + { + ContentControl tick = new ContentControl(); + tick.Focusable = false; + tick.VerticalAlignment = System.Windows.VerticalAlignment.Top; + tick.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; + Grid.SetRow(tick, index); + + if (BigTickTemplate != null) + { + tick.ContentTemplate = BigTickTemplate; + } + + return tick; + } + + #endregion + + } +} diff --git a/Software/Visual_Studio/Tango.sln b/Software/Visual_Studio/Tango.sln index 7c1b522ee..7d1339354 100644 --- a/Software/Visual_Studio/Tango.sln +++ b/Software/Visual_Studio/Tango.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26430.16 +VisualStudioVersion = 15.0.26430.14 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.Protobuf", "Tango.Protobuf\Tango.Protobuf.csproj", "{40073806-914E-4E78-97AB-FA9639308EBE}" EndProject @@ -123,6 +123,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.UITests", "Utilities\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.Editors", "Tango.Editors\Tango.Editors.csproj", "{DE2F2B86-025B-4F26-83A4-38BD48224ED5}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.Visuals", "Tango.Visuals\Tango.Visuals.csproj", "{CF7C0FF4-9440-42CF-83B8-C060772792D4}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1593,6 +1595,36 @@ Global {DE2F2B86-025B-4F26-83A4-38BD48224ED5}.Release|x64.Build.0 = Release|Any CPU {DE2F2B86-025B-4F26-83A4-38BD48224ED5}.Release|x86.ActiveCfg = Release|Any CPU {DE2F2B86-025B-4F26-83A4-38BD48224ED5}.Release|x86.Build.0 = Release|Any CPU + {CF7C0FF4-9440-42CF-83B8-C060772792D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CF7C0FF4-9440-42CF-83B8-C060772792D4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CF7C0FF4-9440-42CF-83B8-C060772792D4}.Debug|ARM.ActiveCfg = Debug|Any CPU + {CF7C0FF4-9440-42CF-83B8-C060772792D4}.Debug|ARM.Build.0 = Debug|Any CPU + {CF7C0FF4-9440-42CF-83B8-C060772792D4}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {CF7C0FF4-9440-42CF-83B8-C060772792D4}.Debug|ARM64.Build.0 = Debug|Any CPU + {CF7C0FF4-9440-42CF-83B8-C060772792D4}.Debug|x64.ActiveCfg = Debug|Any CPU + {CF7C0FF4-9440-42CF-83B8-C060772792D4}.Debug|x64.Build.0 = Debug|Any CPU + {CF7C0FF4-9440-42CF-83B8-C060772792D4}.Debug|x86.ActiveCfg = Debug|Any CPU + {CF7C0FF4-9440-42CF-83B8-C060772792D4}.Debug|x86.Build.0 = Debug|Any CPU + {CF7C0FF4-9440-42CF-83B8-C060772792D4}.DefaultBuild|Any CPU.ActiveCfg = Debug|Any CPU + {CF7C0FF4-9440-42CF-83B8-C060772792D4}.DefaultBuild|Any CPU.Build.0 = Debug|Any CPU + {CF7C0FF4-9440-42CF-83B8-C060772792D4}.DefaultBuild|ARM.ActiveCfg = Debug|Any CPU + {CF7C0FF4-9440-42CF-83B8-C060772792D4}.DefaultBuild|ARM.Build.0 = Debug|Any CPU + {CF7C0FF4-9440-42CF-83B8-C060772792D4}.DefaultBuild|ARM64.ActiveCfg = Debug|Any CPU + {CF7C0FF4-9440-42CF-83B8-C060772792D4}.DefaultBuild|ARM64.Build.0 = Debug|Any CPU + {CF7C0FF4-9440-42CF-83B8-C060772792D4}.DefaultBuild|x64.ActiveCfg = Debug|Any CPU + {CF7C0FF4-9440-42CF-83B8-C060772792D4}.DefaultBuild|x64.Build.0 = Debug|Any CPU + {CF7C0FF4-9440-42CF-83B8-C060772792D4}.DefaultBuild|x86.ActiveCfg = Debug|Any CPU + {CF7C0FF4-9440-42CF-83B8-C060772792D4}.DefaultBuild|x86.Build.0 = Debug|Any CPU + {CF7C0FF4-9440-42CF-83B8-C060772792D4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CF7C0FF4-9440-42CF-83B8-C060772792D4}.Release|Any CPU.Build.0 = Release|Any CPU + {CF7C0FF4-9440-42CF-83B8-C060772792D4}.Release|ARM.ActiveCfg = Release|Any CPU + {CF7C0FF4-9440-42CF-83B8-C060772792D4}.Release|ARM.Build.0 = Release|Any CPU + {CF7C0FF4-9440-42CF-83B8-C060772792D4}.Release|ARM64.ActiveCfg = Release|Any CPU + {CF7C0FF4-9440-42CF-83B8-C060772792D4}.Release|ARM64.Build.0 = Release|Any CPU + {CF7C0FF4-9440-42CF-83B8-C060772792D4}.Release|x64.ActiveCfg = Release|Any CPU + {CF7C0FF4-9440-42CF-83B8-C060772792D4}.Release|x64.Build.0 = Release|Any CPU + {CF7C0FF4-9440-42CF-83B8-C060772792D4}.Release|x86.ActiveCfg = Release|Any CPU + {CF7C0FF4-9440-42CF-83B8-C060772792D4}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml b/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml index 0954bb59a..861cdfec7 100644 --- a/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml +++ b/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml @@ -8,6 +8,7 @@ xmlns:common="clr-namespace:Tango.MachineStudio.Common.Controls;assembly=Tango.MachineStudio.Common" xmlns:developer="clr-namespace:Tango.MachineStudio.Developer.Controls;assembly=Tango.MachineStudio.Developer" xmlns:tech="clr-namespace:Tango.MachineStudio.Technician.Views;assembly=Tango.MachineStudio.Technician" + xmlns:visuals="clr-namespace:Tango.Visuals;assembly=Tango.Visuals" xmlns:editors="clr-namespace:Tango.Editors;assembly=Tango.Editors" mc:Ignorable="d" Title="MainWindow" Height="720" Width="1280"> @@ -17,6 +18,6 @@ - + diff --git a/Software/Visual_Studio/Utilities/Tango.UITests/Tango.UITests.csproj b/Software/Visual_Studio/Utilities/Tango.UITests/Tango.UITests.csproj index 57d1e7459..e381ede6d 100644 --- a/Software/Visual_Studio/Utilities/Tango.UITests/Tango.UITests.csproj +++ b/Software/Visual_Studio/Utilities/Tango.UITests/Tango.UITests.csproj @@ -122,6 +122,10 @@ {8491d07b-c1f6-4b62-a412-41b9fd2d6538} Tango.SharedUI + + {cf7c0ff4-9440-42cf-83b8-c060772792d4} + Tango.Visuals + \ No newline at end of file -- cgit v1.3.1 From f8e1ff79cc2fa09b52093c6e029392b3456ad8bb Mon Sep 17 00:00:00 2001 From: Roy Date: Sat, 10 Feb 2018 17:27:37 +0200 Subject: Added dispensers support on technician module. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 8388608 -> 8388608 bytes Software/Graphics/cogwheel.svg | 52 ++++ Software/Graphics/cogwheel.xaml | 36 +++ Software/Graphics/dispenser-big.png | Bin 0 -> 1580 bytes Software/Graphics/dispenser-line.png | Bin 0 -> 36326 bytes Software/Graphics/ico-ac.svg | 16 ++ Software/Graphics/miscellaneous.svg | 78 ++++++ Software/Graphics/propeller.svg | 47 ++++ Software/Graphics/propeller.xaml | 17 ++ Software/Graphics/propeller2.xaml | 47 ++++ Software/Graphics/propeller3.svg | 5 + Software/Graphics/transportation.svg | 143 ++++++++++ Software/Graphics/volume.png | Bin 0 -> 1929 bytes Software/PMR/Messages/Common/MessageType.proto | 9 + .../Diagnostics/DispenserAbortHomingRequest.proto | 9 + .../Diagnostics/DispenserAbortHomingResponse.proto | 9 + .../Diagnostics/DispenserAbortJoggingRequest.proto | 9 + .../DispenserAbortJoggingResponse.proto | 9 + .../Diagnostics/DispenserHomingRequest.proto | 10 + .../Diagnostics/DispenserHomingResponse.proto | 10 + .../Diagnostics/DispenserJoggingRequest.proto | 13 + .../Diagnostics/DispenserJoggingResponse.proto | 9 + .../Messages/Diagnostics/MotorHomingResponse.proto | 4 +- .../Editors/DispenserElementEditor.xaml | 288 +++++++++++++++++++++ .../Editors/DispenserElementEditor.xaml.cs | 181 +++++++++++++ .../Editors/MeterElementEditor.xaml | 6 +- .../Editors/MonitorElementEditor.xaml | 4 +- .../Editors/MotorElementEditor.xaml | 50 ++-- .../Editors/MultiGraphElementEditor.xaml | 4 +- .../Editors/SingleGraphElementEditor.xaml | 4 +- .../Images/dispenser-big.png | Bin 0 -> 1580 bytes .../Images/dispenser-line.png | Bin 0 -> 36326 bytes .../Images/volume.png | Bin 0 -> 1929 bytes .../PropertiesTemplates/DispenserTemplate.xaml | 44 ++++ .../PropertiesTemplates/DispenserTemplate.xaml.cs | 28 ++ .../PropertiesTemplates/MotorTemplate.xaml | 44 ++++ .../PropertiesTemplates/MotorTemplate.xaml.cs | 28 ++ .../Tango.MachineStudio.Technician.csproj | 47 ++++ .../TechItems/DispenserItem.cs | 127 +++++++++ .../TechItems/MeterItem.cs | 2 +- .../TechItems/MotorItem.cs | 10 + .../ViewModels/MachineTechViewVM.cs | 122 +++++++-- .../Views/MachineTechView.xaml | 33 ++- .../Tango.MachineStudio.Technician/packages.config | 6 + .../Controls/RealTimeGraphControl.xaml | 2 +- .../Controls/RealTimeGraphMultiControl.xaml | 2 +- .../ExtensionMethods/ObjectExtensions.cs | 13 +- .../Visual_Studio/Tango.Core/Tango.Core.csproj | 3 + Software/Visual_Studio/Tango.Core/packages.config | 1 + .../Tango.Emulations/Emulators/MachineEmulator.cs | 163 +++++++++++- .../Operators/IMachineOperator.cs | 43 +++ .../Tango.Integration/Operators/MachineOperator.cs | 60 +++++ Software/Visual_Studio/Tango.Logging/LogManager.cs | 25 +- .../Visual_Studio/Tango.PMR/Common/MessageType.cs | 22 +- .../Diagnostics/DispenserAbortHomingRequest.cs | 160 ++++++++++++ .../Diagnostics/DispenserAbortHomingResponse.cs | 131 ++++++++++ .../Diagnostics/DispenserAbortJoggingRequest.cs | 160 ++++++++++++ .../Diagnostics/DispenserAbortJoggingResponse.cs | 160 ++++++++++++ .../Diagnostics/DispenserHomingRequest.cs | 188 ++++++++++++++ .../Diagnostics/DispenserHomingResponse.cs | 188 ++++++++++++++ .../Diagnostics/DispenserJoggingRequest.cs | 218 ++++++++++++++++ .../Diagnostics/DispenserJoggingResponse.cs | 131 ++++++++++ .../Tango.PMR/Diagnostics/MotorHomingResponse.cs | 46 ++-- Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj | 8 + .../Visual_Studio/Tango.UnitTesting/App.config | 8 + .../Tango.Visuals/AnalogSwitch/AnalogSwitch.xaml | 12 + .../AnalogSwitch/AnalogSwitch.xaml.cs | 66 +++++ .../Visual_Studio/Tango.Visuals/Images/off.png | Bin 0 -> 14366 bytes Software/Visual_Studio/Tango.Visuals/Images/on.png | Bin 0 -> 19420 bytes Software/Visual_Studio/Tango.Visuals/Led/Led.xaml | 117 +++++++++ .../Visual_Studio/Tango.Visuals/Led/Led.xaml.cs | 179 +++++++++++++ .../Tango.Visuals/Tango.Visuals.csproj | 25 ++ .../Utilities/Tango.UITests/App.config | 10 +- .../Utilities/Tango.UITests/MainWindow.xaml | 3 +- 75 files changed, 3603 insertions(+), 101 deletions(-) create mode 100644 Software/Graphics/cogwheel.svg create mode 100644 Software/Graphics/cogwheel.xaml create mode 100644 Software/Graphics/dispenser-big.png create mode 100644 Software/Graphics/dispenser-line.png create mode 100644 Software/Graphics/ico-ac.svg create mode 100644 Software/Graphics/miscellaneous.svg create mode 100644 Software/Graphics/propeller.svg create mode 100644 Software/Graphics/propeller.xaml create mode 100644 Software/Graphics/propeller2.xaml create mode 100644 Software/Graphics/propeller3.svg create mode 100644 Software/Graphics/transportation.svg create mode 100644 Software/Graphics/volume.png create mode 100644 Software/PMR/Messages/Diagnostics/DispenserAbortHomingRequest.proto create mode 100644 Software/PMR/Messages/Diagnostics/DispenserAbortHomingResponse.proto create mode 100644 Software/PMR/Messages/Diagnostics/DispenserAbortJoggingRequest.proto create mode 100644 Software/PMR/Messages/Diagnostics/DispenserAbortJoggingResponse.proto create mode 100644 Software/PMR/Messages/Diagnostics/DispenserHomingRequest.proto create mode 100644 Software/PMR/Messages/Diagnostics/DispenserHomingResponse.proto create mode 100644 Software/PMR/Messages/Diagnostics/DispenserJoggingRequest.proto create mode 100644 Software/PMR/Messages/Diagnostics/DispenserJoggingResponse.proto create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DispenserElementEditor.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DispenserElementEditor.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/dispenser-big.png create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/dispenser-line.png create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/volume.png create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/DispenserTemplate.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/DispenserTemplate.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MotorTemplate.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MotorTemplate.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/DispenserItem.cs create mode 100644 Software/Visual_Studio/Tango.PMR/Diagnostics/DispenserAbortHomingRequest.cs create mode 100644 Software/Visual_Studio/Tango.PMR/Diagnostics/DispenserAbortHomingResponse.cs create mode 100644 Software/Visual_Studio/Tango.PMR/Diagnostics/DispenserAbortJoggingRequest.cs create mode 100644 Software/Visual_Studio/Tango.PMR/Diagnostics/DispenserAbortJoggingResponse.cs create mode 100644 Software/Visual_Studio/Tango.PMR/Diagnostics/DispenserHomingRequest.cs create mode 100644 Software/Visual_Studio/Tango.PMR/Diagnostics/DispenserHomingResponse.cs create mode 100644 Software/Visual_Studio/Tango.PMR/Diagnostics/DispenserJoggingRequest.cs create mode 100644 Software/Visual_Studio/Tango.PMR/Diagnostics/DispenserJoggingResponse.cs create mode 100644 Software/Visual_Studio/Tango.Visuals/AnalogSwitch/AnalogSwitch.xaml create mode 100644 Software/Visual_Studio/Tango.Visuals/AnalogSwitch/AnalogSwitch.xaml.cs create mode 100644 Software/Visual_Studio/Tango.Visuals/Images/off.png create mode 100644 Software/Visual_Studio/Tango.Visuals/Images/on.png create mode 100644 Software/Visual_Studio/Tango.Visuals/Led/Led.xaml create mode 100644 Software/Visual_Studio/Tango.Visuals/Led/Led.xaml.cs (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 576b52c73..2352d6907 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index ebd2921bf..1a3991eae 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Graphics/cogwheel.svg b/Software/Graphics/cogwheel.svg new file mode 100644 index 000000000..c6e68a60d --- /dev/null +++ b/Software/Graphics/cogwheel.svg @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Graphics/cogwheel.xaml b/Software/Graphics/cogwheel.xaml new file mode 100644 index 000000000..140885be7 --- /dev/null +++ b/Software/Graphics/cogwheel.xaml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Graphics/dispenser-big.png b/Software/Graphics/dispenser-big.png new file mode 100644 index 000000000..284b1da0e Binary files /dev/null and b/Software/Graphics/dispenser-big.png differ diff --git a/Software/Graphics/dispenser-line.png b/Software/Graphics/dispenser-line.png new file mode 100644 index 000000000..9e2e344c0 Binary files /dev/null and b/Software/Graphics/dispenser-line.png differ diff --git a/Software/Graphics/ico-ac.svg b/Software/Graphics/ico-ac.svg new file mode 100644 index 000000000..c72933a0b --- /dev/null +++ b/Software/Graphics/ico-ac.svg @@ -0,0 +1,16 @@ + + + + + + diff --git a/Software/Graphics/miscellaneous.svg b/Software/Graphics/miscellaneous.svg new file mode 100644 index 000000000..e04c7ce3c --- /dev/null +++ b/Software/Graphics/miscellaneous.svg @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Graphics/propeller.svg b/Software/Graphics/propeller.svg new file mode 100644 index 000000000..9299250a9 --- /dev/null +++ b/Software/Graphics/propeller.svg @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Graphics/propeller.xaml b/Software/Graphics/propeller.xaml new file mode 100644 index 000000000..bc688df26 --- /dev/null +++ b/Software/Graphics/propeller.xaml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/Software/Graphics/propeller2.xaml b/Software/Graphics/propeller2.xaml new file mode 100644 index 000000000..d083f9aef --- /dev/null +++ b/Software/Graphics/propeller2.xaml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Graphics/propeller3.svg b/Software/Graphics/propeller3.svg new file mode 100644 index 000000000..110115909 --- /dev/null +++ b/Software/Graphics/propeller3.svg @@ -0,0 +1,5 @@ + + ed244817-8d6e-440e-a6f5-07dd506aa9a9 + + + diff --git a/Software/Graphics/transportation.svg b/Software/Graphics/transportation.svg new file mode 100644 index 000000000..a77a1e017 --- /dev/null +++ b/Software/Graphics/transportation.svg @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Graphics/volume.png b/Software/Graphics/volume.png new file mode 100644 index 000000000..4f48f7528 Binary files /dev/null and b/Software/Graphics/volume.png differ diff --git a/Software/PMR/Messages/Common/MessageType.proto b/Software/PMR/Messages/Common/MessageType.proto index 24a398e01..0c43f2b2d 100644 --- a/Software/PMR/Messages/Common/MessageType.proto +++ b/Software/PMR/Messages/Common/MessageType.proto @@ -69,6 +69,15 @@ enum MessageType MotorAbortJoggingRequest = 2008; MotorAbortJoggingResponse = 2009; + DispenserAbortHomingRequest = 2010; + DispenserAbortHomingResponse = 2011; + DispenserHomingRequest = 2012; + DispenserHomingResponse = 2013; + DispenserJoggingRequest = 2014; + DispenserJoggingResponse = 2015; + DispenserAbortJoggingRequest = 2016; + DispenserAbortJoggingResponse = 2017; + //Printing JobRequest = 3000; diff --git a/Software/PMR/Messages/Diagnostics/DispenserAbortHomingRequest.proto b/Software/PMR/Messages/Diagnostics/DispenserAbortHomingRequest.proto new file mode 100644 index 000000000..a50c64c76 --- /dev/null +++ b/Software/PMR/Messages/Diagnostics/DispenserAbortHomingRequest.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package Tango.PMR.Diagnostics; +option java_package = "com.twine.tango.pmr.diagnostics"; + +message DispenserAbortHomingRequest +{ + int32 Code = 1; +} \ No newline at end of file diff --git a/Software/PMR/Messages/Diagnostics/DispenserAbortHomingResponse.proto b/Software/PMR/Messages/Diagnostics/DispenserAbortHomingResponse.proto new file mode 100644 index 000000000..04c242ddd --- /dev/null +++ b/Software/PMR/Messages/Diagnostics/DispenserAbortHomingResponse.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package Tango.PMR.Diagnostics; +option java_package = "com.twine.tango.pmr.diagnostics"; + +message DispenserAbortHomingResponse +{ + +} \ No newline at end of file diff --git a/Software/PMR/Messages/Diagnostics/DispenserAbortJoggingRequest.proto b/Software/PMR/Messages/Diagnostics/DispenserAbortJoggingRequest.proto new file mode 100644 index 000000000..7767ea60f --- /dev/null +++ b/Software/PMR/Messages/Diagnostics/DispenserAbortJoggingRequest.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package Tango.PMR.Diagnostics; +option java_package = "com.twine.tango.pmr.diagnostics"; + +message DispenserAbortJoggingRequest +{ + int32 Code = 2; +} \ No newline at end of file diff --git a/Software/PMR/Messages/Diagnostics/DispenserAbortJoggingResponse.proto b/Software/PMR/Messages/Diagnostics/DispenserAbortJoggingResponse.proto new file mode 100644 index 000000000..df0fa3fad --- /dev/null +++ b/Software/PMR/Messages/Diagnostics/DispenserAbortJoggingResponse.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package Tango.PMR.Diagnostics; +option java_package = "com.twine.tango.pmr.diagnostics"; + +message DispenserAbortJoggingResponse +{ + int32 Code = 2; +} \ No newline at end of file diff --git a/Software/PMR/Messages/Diagnostics/DispenserHomingRequest.proto b/Software/PMR/Messages/Diagnostics/DispenserHomingRequest.proto new file mode 100644 index 000000000..6263b228c --- /dev/null +++ b/Software/PMR/Messages/Diagnostics/DispenserHomingRequest.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; + +package Tango.PMR.Diagnostics; +option java_package = "com.twine.tango.pmr.diagnostics"; + +message DispenserHomingRequest +{ + int32 Code = 1; + double Speed = 2; +} \ No newline at end of file diff --git a/Software/PMR/Messages/Diagnostics/DispenserHomingResponse.proto b/Software/PMR/Messages/Diagnostics/DispenserHomingResponse.proto new file mode 100644 index 000000000..c7e249ad3 --- /dev/null +++ b/Software/PMR/Messages/Diagnostics/DispenserHomingResponse.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; + +package Tango.PMR.Diagnostics; +option java_package = "com.twine.tango.pmr.diagnostics"; + +message DispenserHomingResponse +{ + double Progress = 1; + double MaxProgress = 2; +} \ No newline at end of file diff --git a/Software/PMR/Messages/Diagnostics/DispenserJoggingRequest.proto b/Software/PMR/Messages/Diagnostics/DispenserJoggingRequest.proto new file mode 100644 index 000000000..2eba7cd1b --- /dev/null +++ b/Software/PMR/Messages/Diagnostics/DispenserJoggingRequest.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; + +import "MotorDirection.proto"; + +package Tango.PMR.Diagnostics; +option java_package = "com.twine.tango.pmr.diagnostics"; + +message DispenserJoggingRequest +{ + MotorDirection Direction = 1; + int32 Code = 2; + double Speed = 3; +} \ No newline at end of file diff --git a/Software/PMR/Messages/Diagnostics/DispenserJoggingResponse.proto b/Software/PMR/Messages/Diagnostics/DispenserJoggingResponse.proto new file mode 100644 index 000000000..7b6ccea8d --- /dev/null +++ b/Software/PMR/Messages/Diagnostics/DispenserJoggingResponse.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package Tango.PMR.Diagnostics; +option java_package = "com.twine.tango.pmr.diagnostics"; + +message DispenserJoggingResponse +{ + +} \ No newline at end of file diff --git a/Software/PMR/Messages/Diagnostics/MotorHomingResponse.proto b/Software/PMR/Messages/Diagnostics/MotorHomingResponse.proto index f79b85955..1ee59cd3b 100644 --- a/Software/PMR/Messages/Diagnostics/MotorHomingResponse.proto +++ b/Software/PMR/Messages/Diagnostics/MotorHomingResponse.proto @@ -5,6 +5,6 @@ option java_package = "com.twine.tango.pmr.diagnostics"; message MotorHomingResponse { - int32 Progress = 1; - int32 MaxProgress = 2; + double Progress = 1; + double MaxProgress = 2; } \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DispenserElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DispenserElementEditor.xaml new file mode 100644 index 000000000..b84da3b42 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DispenserElementEditor.xaml @@ -0,0 +1,288 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DispenserElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DispenserElementEditor.xaml.cs new file mode 100644 index 000000000..ef6e4c47c --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DispenserElementEditor.xaml.cs @@ -0,0 +1,181 @@ +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.Animation; +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 DispenserElementEditor : ElementEditor + { + /// + /// Initializes a new instance of the class. + /// + public DispenserElementEditor() + : base() + { + InitializeComponent(); + } + + /// + /// Initializes a new instance of the class. + /// + /// The framework element. + public DispenserElementEditor(DispenserItem dispenserItem) + : this() + { + DispenserItem = dispenserItem; + DataContext = DispenserItem; + } + + /// + /// Initializes a new instance of the class. + /// + /// The framework element. + /// The bounds. + public DispenserElementEditor(DispenserItem monitorItem, Rect bounds) + : this(monitorItem) + { + Left = bounds.Left; + Top = bounds.Top; + Width = bounds.Width; + Height = bounds.Height; + } + + private DispenserItem _monitorItem; + + public DispenserItem DispenserItem + { + get { return _monitorItem; } + set + { + _monitorItem = value; RaisePropertyChanged(nameof(DispenserItem)); + + if (_monitorItem != null) + { + _monitorItem.HomingCompleted -= _monitorItem_HomingCompleted; + _monitorItem.HomingCompleted += _monitorItem_HomingCompleted; + } + } + } + + private void _monitorItem_HomingCompleted(object sender, EventArgs e) + { + StopAnimation(); + } + + + /// + /// Clones this instance. + /// + /// + public override IElementEditor Clone() + { + try + { + var clonedItem = DispenserItem.Clone() as DispenserItem; + DispenserElementEditor cloned = new DispenserElementEditor(clonedItem); + 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); + } + } + + /// + /// Gets the hosted element. + /// + [ParameterIgnore] + public override Object HostedElement + { + get { return DispenserItem; } + } + + private void OnForwardPressed(object sender, MouseButtonEventArgs e) + { + DispenserItem.RaiseAction(MotorActionType.ForwardPressed); + AnimateRight(); + } + + private void OnForwardReleased(object sender, MouseButtonEventArgs e) + { + DispenserItem.RaiseAction(MotorActionType.ForwardReleased); + StopAnimation(); + } + + private void OnBackwardPressed(object sender, MouseButtonEventArgs e) + { + DispenserItem.RaiseAction(MotorActionType.BackwardPressed); + AnimateLeft(); + } + + private void OnBackwardReleased(object sender, MouseButtonEventArgs e) + { + DispenserItem.RaiseAction(MotorActionType.BackwardReleased); + StopAnimation(); + } + + private void OnHomingStarted(object sender, RoutedEventArgs e) + { + DispenserItem.RaiseAction(MotorActionType.HomingStarted); + AnimateLeft(); + } + + private void OnHomingStopped(object sender, RoutedEventArgs e) + { + DispenserItem.RaiseAction(MotorActionType.HomingStopped); + StopAnimation(); + } + + private void AnimateRight() + { + DoubleAnimation ani = new DoubleAnimation(); + ani.Duration = TimeSpan.FromSeconds(1); + ani.RepeatBehavior = RepeatBehavior.Forever; + ani.FillBehavior = FillBehavior.HoldEnd; + ani.To = 360; + propRotate.BeginAnimation(RotateTransform.AngleProperty, ani); + } + + private void AnimateLeft() + { + DoubleAnimation ani = new DoubleAnimation(); + ani.Duration = TimeSpan.FromSeconds(1); + ani.RepeatBehavior = RepeatBehavior.Forever; + ani.FillBehavior = FillBehavior.HoldEnd; + ani.To = -360; + propRotate.BeginAnimation(RotateTransform.AngleProperty, ani); + } + + public void StopAnimation() + { + this.Dispatcher.Invoke(() => + { + propRotate.BeginAnimation(RotateTransform.AngleProperty, null); + }); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MeterElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MeterElementEditor.xaml index 8a9345fa9..98ace7816 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MeterElementEditor.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MeterElementEditor.xaml @@ -3,6 +3,7 @@ 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:sharedConverters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:items="clr-namespace:Tango.MachineStudio.Technician.TechItems" xmlns:converters="clr-namespace:Tango.Editors.Converters;assembly=Tango.Editors" xmlns:visuals="clr-namespace:Tango.Visuals;assembly=Tango.Visuals" @@ -12,6 +13,7 @@ + @@ -26,13 +28,13 @@ - + - + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml index 8e4520cc5..081a853bb 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml @@ -5,12 +5,14 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:items="clr-namespace:Tango.MachineStudio.Technician.TechItems" xmlns:converters="clr-namespace:Tango.Editors.Converters;assembly=Tango.Editors" + xmlns:sharedConverters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:local="clr-namespace:Tango.Editors;assembly=Tango.Editors" mc:Ignorable="d" d:DesignHeight="250" d:DesignWidth="300" Background="Transparent" ClipToBounds="False" BorderThickness="0" MinWidth="1" MinHeight="1" RenderTransformOrigin="0.5,0.5" d:DataContext="{d:DesignInstance Type=items:MonitorItem, IsDesignTimeCreatable=False}"> + @@ -25,7 +27,7 @@ - + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorElementEditor.xaml index bf7aaeff4..a69f81538 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorElementEditor.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorElementEditor.xaml @@ -5,6 +5,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:items="clr-namespace:Tango.MachineStudio.Technician.TechItems" + xmlns:sharedConverters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:converters="clr-namespace:Tango.Editors.Converters;assembly=Tango.Editors" xmlns:visuals="clr-namespace:Tango.Visuals;assembly=Tango.Visuals" xmlns:local="clr-namespace:Tango.Editors;assembly=Tango.Editors" @@ -13,6 +14,7 @@ + @@ -20,10 +22,12 @@ - - + + + @@ -42,7 +46,7 @@ - + @@ -55,27 +59,35 @@ - + - - - - - + + + + + + + + + + + + + - + - + - + - + @@ -158,13 +170,13 @@ - + + + + + + + + Selected Motor + + + Speed + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/DispenserTemplate.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/DispenserTemplate.xaml.cs new file mode 100644 index 000000000..dd3a21b07 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/DispenserTemplate.xaml.cs @@ -0,0 +1,28 @@ +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; + +namespace Tango.MachineStudio.Technician.PropertiesTemplates +{ + /// + /// Interaction logic for MonitorTemplate.xaml + /// + public partial class DispenserTemplate : UserControl + { + public DispenserTemplate() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MotorTemplate.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MotorTemplate.xaml new file mode 100644 index 000000000..0d92230ad --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MotorTemplate.xaml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + Selected Motor + + + Speed + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MotorTemplate.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MotorTemplate.xaml.cs new file mode 100644 index 000000000..3ac58ce5d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MotorTemplate.xaml.cs @@ -0,0 +1,28 @@ +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; + +namespace Tango.MachineStudio.Technician.PropertiesTemplates +{ + /// + /// Interaction logic for MonitorTemplate.xaml + /// + public partial class MotorTemplate : UserControl + { + public MotorTemplate() + { + 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 0f92b6275..34208aded 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 @@ -60,6 +60,22 @@ + + ..\..\..\packages\System.Reactive.Core.3.1.1\lib\net46\System.Reactive.Core.dll + + + ..\..\..\packages\System.Reactive.Interfaces.3.1.1\lib\net45\System.Reactive.Interfaces.dll + + + ..\..\..\packages\System.Reactive.Linq.3.1.1\lib\net46\System.Reactive.Linq.dll + + + ..\..\..\packages\System.Reactive.PlatformServices.3.1.1\lib\net46\System.Reactive.PlatformServices.dll + + + ..\..\..\packages\System.Reactive.Windows.Threading.3.1.1\lib\net45\System.Reactive.Windows.Threading.dll + + ..\..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\System.Windows.Interactivity.dll @@ -81,6 +97,9 @@ + + DispenserElementEditor.xaml + MotorElementEditor.xaml @@ -100,6 +119,12 @@ MeterTemplate.xaml + + DispenserTemplate.xaml + + + MotorTemplate.xaml + MonitorTemplate.xaml @@ -111,6 +136,7 @@ + @@ -141,6 +167,10 @@ GlobalVersionInfo.cs + + MSBuild:Compile + Designer + MSBuild:Compile Designer @@ -165,6 +195,14 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + Designer MSBuild:Compile @@ -311,5 +349,14 @@ + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/DispenserItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/DispenserItem.cs new file mode 100644 index 000000000..3cea8d127 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/DispenserItem.cs @@ -0,0 +1,127 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; +using System.Xml.Serialization; +using Tango.Core.Commands; +using Tango.Integration.Observables; +using Tango.SharedUI.Helpers; + +namespace Tango.MachineStudio.Technician.TechItems +{ + public class DispenserItem : TechItem + { + public event EventHandler ActionExecuted; + public event EventHandler HomingCompleted; + + private TechDispenser _techDispenser; + [XmlIgnore] + public TechDispenser TechDispenser + { + get { return _techDispenser; } + set { _techDispenser = value; RaisePropertyChangedAuto(); RaisePropertyChanged(nameof(Data)); } + } + + private bool _isHoming; + [XmlIgnore] + public bool IsHoming + { + get { return _isHoming; } + set + { + _isHoming = value; + RaisePropertyChangedAuto(); + } + } + + private bool _isHomingCompleted; + + public bool IsHomingCompleted + { + get { return _isHomingCompleted; } + set + { + _isHomingCompleted = value; + RaisePropertyChangedAuto(); + + if (value) + { + HomingCompleted?.Invoke(this, new EventArgs()); + } + } + } + + private double _homingProgress; + [XmlIgnore] + public double HomingProgress + { + get { return _homingProgress; } + set + { + _homingProgress = value; + RaisePropertyChangedAuto(); + } + } + + private double _homingMaximumProgress; + [XmlIgnore] + public double HomingMaximumProgress + { + get { return _homingMaximumProgress; } + set { _homingMaximumProgress = value; RaisePropertyChangedAuto(); } + } + + private bool _isForwardPressed; + [XmlIgnore] + public bool IsForwardPressed + { + get { return _isForwardPressed; } + set { _isForwardPressed = value; RaisePropertyChangedAuto(); } + } + + private bool _isBackwardPressed; + [XmlIgnore] + public bool IsBackwardPressed + { + get { return _isBackwardPressed; } + set { _isBackwardPressed = value; RaisePropertyChangedAuto(); } + } + + private double _speed; + public double Speed + { + get { return _speed; } + set { _speed = value; RaisePropertyChangedAuto(); } + } + + + public override object Data => TechDispenser; + + public DispenserItem() : base() + { + Name = "Dispenser"; + Description = "Dispenser Controller"; + Image = ResourceHelper.GetImageFromResources("Images/dispenser-big.png"); + Color = Colors.White; + } + + public DispenserItem(TechDispenser techDispenser) : this() + { + TechDispenser = techDispenser; + } + + public override TechItem Clone() + { + DispenserItem cloned = base.Clone() as DispenserItem; + cloned.TechDispenser = TechDispenser; + return cloned; + } + + public void RaiseAction(MotorActionType action) + { + ActionExecuted?.Invoke(this, action); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MeterItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MeterItem.cs index 9d4fd9d60..7cc2913eb 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MeterItem.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MeterItem.cs @@ -67,7 +67,7 @@ namespace Tango.MachineStudio.Technician.TechItems { Name = "VU Monitor"; Description = "VU Meter monitor"; - Image = ResourceHelper.GetImageFromResources("Images/analog.png"); + Image = ResourceHelper.GetImageFromResources("Images/volume.png"); LastUpdateTime = DateTime.Now; UpdateInterval = 10; LedCount = 14; diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorItem.cs index a7088ac3f..272aedf44 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorItem.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorItem.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Media; using System.Xml.Serialization; using Tango.Core.Commands; using Tango.Integration.Observables; @@ -88,6 +89,14 @@ namespace Tango.MachineStudio.Technician.TechItems set { _isBackwardPressed = value; RaisePropertyChangedAuto(); } } + private double _speed; + public double Speed + { + get { return _speed; } + set { _speed = value; RaisePropertyChangedAuto(); } + } + + public override object Data => TechMotor; public MotorItem() : base() @@ -95,6 +104,7 @@ namespace Tango.MachineStudio.Technician.TechItems Name = "Motor"; Description = "Motor Controller"; Image = ResourceHelper.GetImageFromResources("Images/engine.png"); + Color = Colors.White; } public MotorItem(TechMotor techMotor) : this() 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 7bed3f441..8ed8a4a80 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 @@ -253,6 +253,13 @@ namespace Tango.MachineStudio.Technician.ViewModels Elements.Add(editor); InitMotorItem(motorItem); } + else if (SelectedTechItem is DispenserItem) + { + var dispenserItem = new DispenserItem(Adapter.TechDispensers.FirstOrDefault()); + DispenserElementEditor editor = new DispenserElementEditor(dispenserItem, bounds); + Elements.Add(editor); + InitDispenserItem(dispenserItem); + } } public void OnElementsRemoved(List elements) @@ -319,56 +326,139 @@ namespace Tango.MachineStudio.Technician.ViewModels { item.ActionExecuted += async (x, action) => { - if (action == MotorActionType.HomingStarted) + if (action == MotorActionType.ForwardPressed) + { + await MachineOperator.StartMotorJogging(new MotorJoggingRequest() + { + Code = item.TechMotor.Code, + Direction = MotorDirection.Forward, + }); + } + else if (action == MotorActionType.ForwardReleased) + { + await MachineOperator.StopMotorJogging(new MotorAbortJoggingRequest() + { + Code = item.TechMotor.Code, + }); + } + else if (action == MotorActionType.BackwardPressed) + { + await MachineOperator.StartMotorJogging(new MotorJoggingRequest() + { + Code = item.TechMotor.Code, + Direction = MotorDirection.Backward, + }); + } + else if (action == MotorActionType.BackwardReleased) + { + await MachineOperator.StopMotorJogging(new MotorAbortJoggingRequest() + { + Code = item.TechMotor.Code, + }); + } + else if (action == MotorActionType.HomingStarted) { item.HomingProgress = 0; item.IsHoming = true; item.IsHomingCompleted = false; - await Task.Factory.StartNew(() => + MachineOperator.StartMotorHoming(new MotorHomingRequest() + { + Code = item.TechMotor.Code + }) + .Subscribe((response) => { - for (int i = 0; i < 101; i++) - { - item.HomingMaximumProgress = 100; - item.HomingProgress++; - Thread.Sleep(60); - } + item.HomingMaximumProgress = response.Message.MaxProgress; + item.HomingProgress = response.Message.Progress; + + }, () => + { item.IsHoming = false; item.IsHomingCompleted = true; + }); } - else if (action == MotorActionType.ForwardPressed) + else if (action == MotorActionType.HomingStopped) { - await MachineOperator.StartMotorJogging(new MotorJoggingRequest() + await MachineOperator.StopMotorHoming(new MotorAbortHomingRequest() { Code = item.TechMotor.Code, + }); + + item.IsHoming = false; + } + }; + } + + private void InitDispenserItem(DispenserItem item) + { + item.ActionExecuted += async (x, action) => + { + if (action == MotorActionType.ForwardPressed) + { + await MachineOperator.StartDispenserJogging(new DispenserJoggingRequest() + { + Code = item.TechDispenser.Code, Direction = MotorDirection.Forward, }); } else if (action == MotorActionType.ForwardReleased) { - await MachineOperator.StopMotorJogging(new MotorAbortJoggingRequest() + await MachineOperator.StopDispenserJogging(new DispenserAbortJoggingRequest() { - Code = item.TechMotor.Code, + Code = item.TechDispenser.Code, }); } else if (action == MotorActionType.BackwardPressed) { - await MachineOperator.StartMotorJogging(new MotorJoggingRequest() + await MachineOperator.StartDispenserJogging(new DispenserJoggingRequest() { - Code = item.TechMotor.Code, + Code = item.TechDispenser.Code, Direction = MotorDirection.Backward, }); } else if (action == MotorActionType.BackwardReleased) { - await MachineOperator.StopMotorJogging(new MotorAbortJoggingRequest() + await MachineOperator.StopDispenserJogging(new DispenserAbortJoggingRequest() { - Code = item.TechMotor.Code, + Code = item.TechDispenser.Code, + }); + } + else if (action == MotorActionType.HomingStarted) + { + item.HomingProgress = 0; + item.IsHoming = true; + item.IsHomingCompleted = false; + + MachineOperator.StartDispenserHoming(new DispenserHomingRequest() + { + Code = item.TechDispenser.Code + }) + .Subscribe((response) => + { + + item.HomingMaximumProgress = response.Message.MaxProgress; + item.HomingProgress = response.Message.Progress; + + }, () => + { + + item.IsHoming = false; + item.IsHomingCompleted = true; + }); } + else if (action == MotorActionType.HomingStopped) + { + await MachineOperator.StopDispenserHoming(new DispenserAbortHomingRequest() + { + Code = item.TechDispenser.Code, + }); + + item.IsHoming = false; + } }; } } 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 7cdd92e06..9e3970719 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 @@ -50,15 +50,38 @@ - + @@ -177,6 +200,12 @@ + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/packages.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/packages.config index 1d449350a..61695a8c5 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/packages.config +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/packages.config @@ -7,4 +7,10 @@ + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml index 8c364dde9..2f43869d5 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml @@ -53,7 +53,7 @@ - + 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 2055e282c..5548c452e 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphMultiControl.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphMultiControl.xaml @@ -53,7 +53,7 @@ - + diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObjectExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObjectExtensions.cs index 88403f8a6..82bcaa9d4 100644 --- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObjectExtensions.cs +++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObjectExtensions.cs @@ -1,4 +1,5 @@ -using System; +using Newtonsoft.Json; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -49,4 +50,14 @@ public static class ObjectExtensions } } } + + /// + /// Serializes the specified object to indented json string. + /// + /// The object. + /// + public static String ToJsonString(this Object obj) + { + return JsonConvert.SerializeObject(obj, Formatting.Indented); + } } diff --git a/Software/Visual_Studio/Tango.Core/Tango.Core.csproj b/Software/Visual_Studio/Tango.Core/Tango.Core.csproj index da33c3f0a..e9d96417b 100644 --- a/Software/Visual_Studio/Tango.Core/Tango.Core.csproj +++ b/Software/Visual_Studio/Tango.Core/Tango.Core.csproj @@ -46,6 +46,9 @@ ..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll + + ..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll + diff --git a/Software/Visual_Studio/Tango.Core/packages.config b/Software/Visual_Studio/Tango.Core/packages.config index 114eefdba..bb569f026 100644 --- a/Software/Visual_Studio/Tango.Core/packages.config +++ b/Software/Visual_Studio/Tango.Core/packages.config @@ -3,5 +3,6 @@ + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs index cbda54d56..5e76c2d1b 100644 --- a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs +++ b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs @@ -30,6 +30,9 @@ namespace Tango.Emulations.Emulators private PushDiagnosticsRequest _diagnosticsRequest; private bool _cancelJob; private List _motorJoggingRequestCodes; + private List _motorHomingRequestCodes; + private List _dispenserJoggingRequestCodes; + private List _dispenserHomingRequestCodes; private double _graphAmplitude; private double _graphFrequency; @@ -53,9 +56,16 @@ namespace Tango.Emulations.Emulators Init(); } + #endregion + + #region Private Methods + private void Init() { _motorJoggingRequestCodes = new List(); + _motorHomingRequestCodes = new List(); + _dispenserJoggingRequestCodes = new List(); + _dispenserHomingRequestCodes = new List(); ResetGraphFactors(); } @@ -99,6 +109,24 @@ namespace Tango.Emulations.Emulators case MessageType.MotorAbortJoggingRequest: HandleAbortMotorJoggingRequest(MessageFactory.ParseTangoMessageFromContainer(container)); break; + case MessageType.MotorHomingRequest: + HandleMotorHomingRequest(MessageFactory.ParseTangoMessageFromContainer(container)); + break; + case MessageType.MotorAbortHomingRequest: + HandleAbortMotorHomingRequest(MessageFactory.ParseTangoMessageFromContainer(container)); + break; + case MessageType.DispenserJoggingRequest: + HandleDispenserJoggingRequest(MessageFactory.ParseTangoMessageFromContainer(container)); + break; + case MessageType.DispenserAbortJoggingRequest: + HandleAbortDispenserJoggingRequest(MessageFactory.ParseTangoMessageFromContainer(container)); + break; + case MessageType.DispenserHomingRequest: + HandleDispenserHomingRequest(MessageFactory.ParseTangoMessageFromContainer(container)); + break; + case MessageType.DispenserAbortHomingRequest: + HandleAbortDispenserHomingRequest(MessageFactory.ParseTangoMessageFromContainer(container)); + break; } } @@ -135,6 +163,8 @@ namespace Tango.Emulations.Emulators private void HandlePushDiagnosticsRequest(TangoMessage request) { + LogManager.Log("Push diagnostics request received " + Environment.NewLine + request.Message.ToJsonString()); + _diagnosticsRequest = request.Message; int value = 0; @@ -199,7 +229,7 @@ namespace Tango.Emulations.Emulators { JobTicket job = request.Message.JobTicket; - LogManager.Log("Job request received: " + Environment.NewLine + job.ToString()); + LogManager.Log("Job request received: " + Environment.NewLine + job.ToJsonString()); double progress = 0; _cancelJob = false; @@ -246,24 +276,25 @@ namespace Tango.Emulations.Emulators _motorJoggingRequestCodes.Add(jogRequest.Code); - LogManager.Log("Motor jogging request received: " + Environment.NewLine + jogRequest.ToString()); + LogManager.Log("Motor jogging request received: " + Environment.NewLine + jogRequest.ToJsonString()); - Task.Factory.StartNew(() => + Task.Factory.StartNew(() => { while (_motorJoggingRequestCodes.Contains(jogRequest.Code)) { - if (jogRequest.Direction == MotorDirection.Forward) { - _graphFrequency += 0.1; + _graphFrequency = 10; } else { - _graphFrequency -= 0.1; + _graphFrequency = 18; } Thread.Sleep(30); } + + ResetGraphFactors(); }); Transporter.SendResponse(new MotorJoggingResponse(), request.Container.Token); @@ -271,12 +302,128 @@ namespace Tango.Emulations.Emulators private void HandleAbortMotorJoggingRequest(TangoMessage request) { - LogManager.Log("Abort motor jogging request received: " + Environment.NewLine + request.Message.ToString()); - _motorJoggingRequestCodes.Remove(request.Message.Code); + LogManager.Log("Abort motor jogging request received: " + Environment.NewLine + request.Message.ToJsonString()); + _motorJoggingRequestCodes.RemoveAll(x => x == request.Message.Code); ResetGraphFactors(); Transporter.SendResponse(new MotorAbortJoggingResponse(), request.Container.Token); } + private void HandleMotorHomingRequest(TangoMessage request) + { + var homeRequest = request.Message; + + LogManager.Log("Motor homing request received: " + Environment.NewLine + homeRequest.ToJsonString()); + + _motorHomingRequestCodes.Add(homeRequest.Code); + + Task.Factory.StartNew(() => + { + _graphFrequency = 10; + + for (int i = 0; i < 100; i++) + { + Transporter.SendResponse(new MotorHomingResponse() { MaxProgress = 100, Progress = i }, request.Container.Token); + + if (!_motorHomingRequestCodes.Contains(homeRequest.Code)) + { + ResetGraphFactors(); + return; + } + + Thread.Sleep(30); + } + + Transporter.SendResponse(new MotorHomingResponse() { MaxProgress = 100, Progress = 100 }, request.Container.Token, true); + _motorHomingRequestCodes.Remove(homeRequest.Code); + ResetGraphFactors(); + }); + } + + private void HandleAbortMotorHomingRequest(TangoMessage request) + { + LogManager.Log("Abort motor homing request received: " + Environment.NewLine + request.Message.ToJsonString()); + _motorHomingRequestCodes.RemoveAll(x => x == request.Message.Code); + ResetGraphFactors(); + Transporter.SendResponse(new MotorAbortHomingResponse(), request.Container.Token); + } + + private void HandleDispenserJoggingRequest(TangoMessage request) + { + var jogRequest = request.Message; + + _dispenserJoggingRequestCodes.Add(jogRequest.Code); + + LogManager.Log("Dispenser jogging request received: " + Environment.NewLine + jogRequest.ToJsonString()); + + Task.Factory.StartNew(() => + { + while (_dispenserJoggingRequestCodes.Contains(jogRequest.Code)) + { + if (jogRequest.Direction == MotorDirection.Forward) + { + _graphFrequency = 10; + } + else + { + _graphFrequency = 18; + } + + Thread.Sleep(30); + } + + ResetGraphFactors(); + }); + + Transporter.SendResponse(new DispenserJoggingResponse(), request.Container.Token); + } + + private void HandleAbortDispenserJoggingRequest(TangoMessage request) + { + LogManager.Log("Abort dispenser jogging request received: " + Environment.NewLine + request.Message.ToJsonString()); + _dispenserJoggingRequestCodes.RemoveAll(x => x == request.Message.Code); + ResetGraphFactors(); + Transporter.SendResponse(new DispenserAbortJoggingResponse(), request.Container.Token); + } + + private void HandleDispenserHomingRequest(TangoMessage request) + { + var homeRequest = request.Message; + + LogManager.Log("Dispenser homing request received: " + Environment.NewLine + homeRequest.ToJsonString()); + + _dispenserHomingRequestCodes.Add(homeRequest.Code); + + Task.Factory.StartNew(() => + { + _graphFrequency = 10; + + for (int i = 0; i < 100; i++) + { + Transporter.SendResponse(new DispenserHomingResponse() { MaxProgress = 100, Progress = i }, request.Container.Token); + + if (!_dispenserHomingRequestCodes.Contains(homeRequest.Code)) + { + ResetGraphFactors(); + return; + } + + Thread.Sleep(30); + } + + Transporter.SendResponse(new DispenserHomingResponse() { MaxProgress = 100, Progress = 100 }, request.Container.Token, true); + _dispenserHomingRequestCodes.Remove(homeRequest.Code); + ResetGraphFactors(); + }); + } + + private void HandleAbortDispenserHomingRequest(TangoMessage request) + { + LogManager.Log("Abort dispenser homing request received: " + Environment.NewLine + request.Message.ToJsonString()); + _dispenserHomingRequestCodes.RemoveAll(x => x == request.Message.Code); + ResetGraphFactors(); + Transporter.SendResponse(new DispenserAbortHomingResponse(), request.Container.Token); + } + #endregion } } diff --git a/Software/Visual_Studio/Tango.Integration/Operators/IMachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operators/IMachineOperator.cs index 6b64575de..14c5114f3 100644 --- a/Software/Visual_Studio/Tango.Integration/Operators/IMachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operators/IMachineOperator.cs @@ -10,6 +10,7 @@ using Tango.Transport; using System.Reactive; using Tango.Integration.Printing; using Tango.PMR; +using System.Reactive.Linq; namespace Tango.Integration.Operators { @@ -50,5 +51,47 @@ namespace Tango.Integration.Operators /// The request. /// Task> StopMotorJogging(MotorAbortJoggingRequest request); + + /// + /// Starts homing the specified motor. + /// + /// The request. + /// + IObservable> StartMotorHoming(MotorHomingRequest request); + + /// + /// Stops homing the specified motor. + /// + /// The request. + /// + Task> StopMotorHoming(MotorAbortHomingRequest request); + + /// + /// Starts jogging the specified dispenser. + /// + /// The request. + /// + Task> StartDispenserJogging(DispenserJoggingRequest request); + + /// + /// Stops jogging the specified dispenser. + /// + /// The request. + /// + Task> StopDispenserJogging(DispenserAbortJoggingRequest request); + + /// + /// Starts homing the specified dispenser. + /// + /// The request. + /// + IObservable> StartDispenserHoming(DispenserHomingRequest request); + + /// + /// Stops homing the specified dispenser. + /// + /// The request. + /// + Task> StopDispenserHoming(DispenserAbortHomingRequest request); } } diff --git a/Software/Visual_Studio/Tango.Integration/Operators/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operators/MachineOperator.cs index 56b7ec971..f0d780191 100644 --- a/Software/Visual_Studio/Tango.Integration/Operators/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operators/MachineOperator.cs @@ -204,6 +204,66 @@ namespace Tango.Integration.Operators return SendRequest(request); } + /// + /// Starts homing the specified motor. + /// + /// The request. + /// + public IObservable> StartMotorHoming(MotorHomingRequest request) + { + return SendContinuousRequest(request); + } + + /// + /// Stops homing the specified motor. + /// + /// The request. + /// + public Task> StopMotorHoming(MotorAbortHomingRequest request) + { + return SendRequest(request); + } + + /// + /// Starts jogging the specified dispenser. + /// + /// The request. + /// + public Task> StartDispenserJogging(DispenserJoggingRequest request) + { + return SendRequest(request); + } + + /// + /// Stops jogging the specified dispenser. + /// + /// The request. + /// + public Task> StopDispenserJogging(DispenserAbortJoggingRequest request) + { + return SendRequest(request); + } + + /// + /// Starts homing the specified dispenser. + /// + /// The request. + /// + public IObservable> StartDispenserHoming(DispenserHomingRequest request) + { + return SendContinuousRequest(request); + } + + /// + /// Stops homing the specified dispenser. + /// + /// The request. + /// + public Task> StopDispenserHoming(DispenserAbortHomingRequest request) + { + return SendRequest(request); + } + #endregion } } diff --git a/Software/Visual_Studio/Tango.Logging/LogManager.cs b/Software/Visual_Studio/Tango.Logging/LogManager.cs index 43f40fcbe..b97058bfe 100644 --- a/Software/Visual_Studio/Tango.Logging/LogManager.cs +++ b/Software/Visual_Studio/Tango.Logging/LogManager.cs @@ -184,30 +184,23 @@ namespace Tango.Logging //[DebuggerHidden] private static void LoggingThreadMethod() { - while (_logs.Count > 0) + while (_isStarted) { - LogItemBase log; - - if (_logs.TryDequeue(out log)) + while (_logs.Count > 0) { - if (log != null) + LogItemBase log; + + if (_logs.TryDequeue(out log)) { - _loggers.Where(x => x.Enabled && !x.Immediate).ToList().ForEach(x => x.OnLog(log)); + if (log != null) + { + _loggers.Where(x => x.Enabled && !x.Immediate).ToList().ForEach(x => x.OnLog(log)); + } } } Thread.Sleep(10); } - - Thread.Sleep(400); - - if (_logs.Count > 0) - { - LoggingThreadMethod(); - return; - } - - _isStarted = false; } /// diff --git a/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs b/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs index ec378556b..86dfe19ad 100644 --- a/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs +++ b/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs @@ -22,7 +22,7 @@ namespace Tango.PMR.Common { static MessageTypeReflection() { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( - "ChFNZXNzYWdlVHlwZS5wcm90bxIQVGFuZ28uUE1SLkNvbW1vbireDAoLTWVz", + "ChFNZXNzYWdlVHlwZS5wcm90bxIQVGFuZ28uUE1SLkNvbW1vbiriDgoLTWVz", "c2FnZVR5cGUSCAoETm9uZRAAEhQKEENhbGN1bGF0ZVJlcXVlc3QQAxIVChFD", "YWxjdWxhdGVSZXNwb25zZRAEEhMKD1Byb2dyZXNzUmVxdWVzdBAFEhQKEFBy", "b2dyZXNzUmVzcG9uc2UQBhIcChhTdHViQ2FydHJpZGdlUmVhZFJlcXVlc3QQ", @@ -57,9 +57,15 @@ namespace Tango.PMR.Common { "cXVlc3QQ1A8SGAoTTW90b3JIb21pbmdSZXNwb25zZRDVDxIYChNNb3Rvckpv", "Z2dpbmdSZXF1ZXN0ENYPEhkKFE1vdG9ySm9nZ2luZ1Jlc3BvbnNlENcPEh0K", "GE1vdG9yQWJvcnRKb2dnaW5nUmVxdWVzdBDYDxIeChlNb3RvckFib3J0Sm9n", - "Z2luZ1Jlc3BvbnNlENkPEg8KCkpvYlJlcXVlc3QQuBcSEAoLSm9iUmVzcG9u", - "c2UQuRcSFAoPQWJvcnRKb2JSZXF1ZXN0ELoXEhUKEEFib3J0Sm9iUmVzcG9u", - "c2UQuxdCHAoaY29tLnR3aW5lLnRhbmdvLnBtci5jb21tb25iBnByb3RvMw==")); + "Z2luZ1Jlc3BvbnNlENkPEiAKG0Rpc3BlbnNlckFib3J0SG9taW5nUmVxdWVz", + "dBDaDxIhChxEaXNwZW5zZXJBYm9ydEhvbWluZ1Jlc3BvbnNlENsPEhsKFkRp", + "c3BlbnNlckhvbWluZ1JlcXVlc3QQ3A8SHAoXRGlzcGVuc2VySG9taW5nUmVz", + "cG9uc2UQ3Q8SHAoXRGlzcGVuc2VySm9nZ2luZ1JlcXVlc3QQ3g8SHQoYRGlz", + "cGVuc2VySm9nZ2luZ1Jlc3BvbnNlEN8PEiEKHERpc3BlbnNlckFib3J0Sm9n", + "Z2luZ1JlcXVlc3QQ4A8SIgodRGlzcGVuc2VyQWJvcnRKb2dnaW5nUmVzcG9u", + "c2UQ4Q8SDwoKSm9iUmVxdWVzdBC4FxIQCgtKb2JSZXNwb25zZRC5FxIUCg9B", + "Ym9ydEpvYlJlcXVlc3QQuhcSFQoQQWJvcnRKb2JSZXNwb25zZRC7F0IcChpj", + "b20udHdpbmUudGFuZ28ucG1yLmNvbW1vbmIGcHJvdG8z")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Tango.PMR.Common.MessageType), }, null)); @@ -135,6 +141,14 @@ namespace Tango.PMR.Common { [pbr::OriginalName("MotorJoggingResponse")] MotorJoggingResponse = 2007, [pbr::OriginalName("MotorAbortJoggingRequest")] MotorAbortJoggingRequest = 2008, [pbr::OriginalName("MotorAbortJoggingResponse")] MotorAbortJoggingResponse = 2009, + [pbr::OriginalName("DispenserAbortHomingRequest")] DispenserAbortHomingRequest = 2010, + [pbr::OriginalName("DispenserAbortHomingResponse")] DispenserAbortHomingResponse = 2011, + [pbr::OriginalName("DispenserHomingRequest")] DispenserHomingRequest = 2012, + [pbr::OriginalName("DispenserHomingResponse")] DispenserHomingResponse = 2013, + [pbr::OriginalName("DispenserJoggingRequest")] DispenserJoggingRequest = 2014, + [pbr::OriginalName("DispenserJoggingResponse")] DispenserJoggingResponse = 2015, + [pbr::OriginalName("DispenserAbortJoggingRequest")] DispenserAbortJoggingRequest = 2016, + [pbr::OriginalName("DispenserAbortJoggingResponse")] DispenserAbortJoggingResponse = 2017, /// ///Printing /// diff --git a/Software/Visual_Studio/Tango.PMR/Diagnostics/DispenserAbortHomingRequest.cs b/Software/Visual_Studio/Tango.PMR/Diagnostics/DispenserAbortHomingRequest.cs new file mode 100644 index 000000000..492f9bdaf --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/Diagnostics/DispenserAbortHomingRequest.cs @@ -0,0 +1,160 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: DispenserAbortHomingRequest.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.Diagnostics { + + /// Holder for reflection information generated from DispenserAbortHomingRequest.proto + public static partial class DispenserAbortHomingRequestReflection { + + #region Descriptor + /// File descriptor for DispenserAbortHomingRequest.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static DispenserAbortHomingRequestReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CiFEaXNwZW5zZXJBYm9ydEhvbWluZ1JlcXVlc3QucHJvdG8SFVRhbmdvLlBN", + "Ui5EaWFnbm9zdGljcyIrChtEaXNwZW5zZXJBYm9ydEhvbWluZ1JlcXVlc3QS", + "DAoEQ29kZRgBIAEoBUIhCh9jb20udHdpbmUudGFuZ28ucG1yLmRpYWdub3N0", + "aWNzYgZwcm90bzM=")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Diagnostics.DispenserAbortHomingRequest), global::Tango.PMR.Diagnostics.DispenserAbortHomingRequest.Parser, new[]{ "Code" }, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class DispenserAbortHomingRequest : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DispenserAbortHomingRequest()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Tango.PMR.Diagnostics.DispenserAbortHomingRequestReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DispenserAbortHomingRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DispenserAbortHomingRequest(DispenserAbortHomingRequest other) : this() { + code_ = other.code_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DispenserAbortHomingRequest Clone() { + return new DispenserAbortHomingRequest(this); + } + + /// Field number for the "Code" field. + public const int CodeFieldNumber = 1; + private int code_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Code { + get { return code_; } + set { + code_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as DispenserAbortHomingRequest); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(DispenserAbortHomingRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Code != other.Code) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Code != 0) hash ^= Code.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Code != 0) { + output.WriteRawTag(8); + output.WriteInt32(Code); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Code != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Code); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(DispenserAbortHomingRequest other) { + if (other == null) { + return; + } + if (other.Code != 0) { + Code = other.Code; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 8: { + Code = input.ReadInt32(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Diagnostics/DispenserAbortHomingResponse.cs b/Software/Visual_Studio/Tango.PMR/Diagnostics/DispenserAbortHomingResponse.cs new file mode 100644 index 000000000..94e32eb29 --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/Diagnostics/DispenserAbortHomingResponse.cs @@ -0,0 +1,131 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: DispenserAbortHomingResponse.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.Diagnostics { + + /// Holder for reflection information generated from DispenserAbortHomingResponse.proto + public static partial class DispenserAbortHomingResponseReflection { + + #region Descriptor + /// File descriptor for DispenserAbortHomingResponse.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static DispenserAbortHomingResponseReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CiJEaXNwZW5zZXJBYm9ydEhvbWluZ1Jlc3BvbnNlLnByb3RvEhVUYW5nby5Q", + "TVIuRGlhZ25vc3RpY3MiHgocRGlzcGVuc2VyQWJvcnRIb21pbmdSZXNwb25z", + "ZUIhCh9jb20udHdpbmUudGFuZ28ucG1yLmRpYWdub3N0aWNzYgZwcm90bzM=")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Diagnostics.DispenserAbortHomingResponse), global::Tango.PMR.Diagnostics.DispenserAbortHomingResponse.Parser, null, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class DispenserAbortHomingResponse : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DispenserAbortHomingResponse()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Tango.PMR.Diagnostics.DispenserAbortHomingResponseReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DispenserAbortHomingResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DispenserAbortHomingResponse(DispenserAbortHomingResponse other) : this() { + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DispenserAbortHomingResponse Clone() { + return new DispenserAbortHomingResponse(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as DispenserAbortHomingResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(DispenserAbortHomingResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(DispenserAbortHomingResponse other) { + if (other == null) { + return; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Diagnostics/DispenserAbortJoggingRequest.cs b/Software/Visual_Studio/Tango.PMR/Diagnostics/DispenserAbortJoggingRequest.cs new file mode 100644 index 000000000..4f879102b --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/Diagnostics/DispenserAbortJoggingRequest.cs @@ -0,0 +1,160 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: DispenserAbortJoggingRequest.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.Diagnostics { + + /// Holder for reflection information generated from DispenserAbortJoggingRequest.proto + public static partial class DispenserAbortJoggingRequestReflection { + + #region Descriptor + /// File descriptor for DispenserAbortJoggingRequest.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static DispenserAbortJoggingRequestReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CiJEaXNwZW5zZXJBYm9ydEpvZ2dpbmdSZXF1ZXN0LnByb3RvEhVUYW5nby5Q", + "TVIuRGlhZ25vc3RpY3MiLAocRGlzcGVuc2VyQWJvcnRKb2dnaW5nUmVxdWVz", + "dBIMCgRDb2RlGAIgASgFQiEKH2NvbS50d2luZS50YW5nby5wbXIuZGlhZ25v", + "c3RpY3NiBnByb3RvMw==")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Diagnostics.DispenserAbortJoggingRequest), global::Tango.PMR.Diagnostics.DispenserAbortJoggingRequest.Parser, new[]{ "Code" }, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class DispenserAbortJoggingRequest : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DispenserAbortJoggingRequest()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Tango.PMR.Diagnostics.DispenserAbortJoggingRequestReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DispenserAbortJoggingRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DispenserAbortJoggingRequest(DispenserAbortJoggingRequest other) : this() { + code_ = other.code_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DispenserAbortJoggingRequest Clone() { + return new DispenserAbortJoggingRequest(this); + } + + /// Field number for the "Code" field. + public const int CodeFieldNumber = 2; + private int code_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Code { + get { return code_; } + set { + code_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as DispenserAbortJoggingRequest); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(DispenserAbortJoggingRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Code != other.Code) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Code != 0) hash ^= Code.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Code != 0) { + output.WriteRawTag(16); + output.WriteInt32(Code); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Code != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Code); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(DispenserAbortJoggingRequest other) { + if (other == null) { + return; + } + if (other.Code != 0) { + Code = other.Code; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 16: { + Code = input.ReadInt32(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Diagnostics/DispenserAbortJoggingResponse.cs b/Software/Visual_Studio/Tango.PMR/Diagnostics/DispenserAbortJoggingResponse.cs new file mode 100644 index 000000000..e8e2c8efe --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/Diagnostics/DispenserAbortJoggingResponse.cs @@ -0,0 +1,160 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: DispenserAbortJoggingResponse.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.Diagnostics { + + /// Holder for reflection information generated from DispenserAbortJoggingResponse.proto + public static partial class DispenserAbortJoggingResponseReflection { + + #region Descriptor + /// File descriptor for DispenserAbortJoggingResponse.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static DispenserAbortJoggingResponseReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CiNEaXNwZW5zZXJBYm9ydEpvZ2dpbmdSZXNwb25zZS5wcm90bxIVVGFuZ28u", + "UE1SLkRpYWdub3N0aWNzIi0KHURpc3BlbnNlckFib3J0Sm9nZ2luZ1Jlc3Bv", + "bnNlEgwKBENvZGUYAiABKAVCIQofY29tLnR3aW5lLnRhbmdvLnBtci5kaWFn", + "bm9zdGljc2IGcHJvdG8z")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Diagnostics.DispenserAbortJoggingResponse), global::Tango.PMR.Diagnostics.DispenserAbortJoggingResponse.Parser, new[]{ "Code" }, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class DispenserAbortJoggingResponse : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DispenserAbortJoggingResponse()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Tango.PMR.Diagnostics.DispenserAbortJoggingResponseReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DispenserAbortJoggingResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DispenserAbortJoggingResponse(DispenserAbortJoggingResponse other) : this() { + code_ = other.code_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DispenserAbortJoggingResponse Clone() { + return new DispenserAbortJoggingResponse(this); + } + + /// Field number for the "Code" field. + public const int CodeFieldNumber = 2; + private int code_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Code { + get { return code_; } + set { + code_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as DispenserAbortJoggingResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(DispenserAbortJoggingResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Code != other.Code) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Code != 0) hash ^= Code.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Code != 0) { + output.WriteRawTag(16); + output.WriteInt32(Code); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Code != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Code); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(DispenserAbortJoggingResponse other) { + if (other == null) { + return; + } + if (other.Code != 0) { + Code = other.Code; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 16: { + Code = input.ReadInt32(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Diagnostics/DispenserHomingRequest.cs b/Software/Visual_Studio/Tango.PMR/Diagnostics/DispenserHomingRequest.cs new file mode 100644 index 000000000..f5b45c802 --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/Diagnostics/DispenserHomingRequest.cs @@ -0,0 +1,188 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: DispenserHomingRequest.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.Diagnostics { + + /// Holder for reflection information generated from DispenserHomingRequest.proto + public static partial class DispenserHomingRequestReflection { + + #region Descriptor + /// File descriptor for DispenserHomingRequest.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static DispenserHomingRequestReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "ChxEaXNwZW5zZXJIb21pbmdSZXF1ZXN0LnByb3RvEhVUYW5nby5QTVIuRGlh", + "Z25vc3RpY3MiNQoWRGlzcGVuc2VySG9taW5nUmVxdWVzdBIMCgRDb2RlGAEg", + "ASgFEg0KBVNwZWVkGAIgASgBQiEKH2NvbS50d2luZS50YW5nby5wbXIuZGlh", + "Z25vc3RpY3NiBnByb3RvMw==")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Diagnostics.DispenserHomingRequest), global::Tango.PMR.Diagnostics.DispenserHomingRequest.Parser, new[]{ "Code", "Speed" }, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class DispenserHomingRequest : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DispenserHomingRequest()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Tango.PMR.Diagnostics.DispenserHomingRequestReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DispenserHomingRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DispenserHomingRequest(DispenserHomingRequest other) : this() { + code_ = other.code_; + speed_ = other.speed_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DispenserHomingRequest Clone() { + return new DispenserHomingRequest(this); + } + + /// Field number for the "Code" field. + public const int CodeFieldNumber = 1; + private int code_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Code { + get { return code_; } + set { + code_ = value; + } + } + + /// Field number for the "Speed" field. + public const int SpeedFieldNumber = 2; + private double speed_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double Speed { + get { return speed_; } + set { + speed_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as DispenserHomingRequest); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(DispenserHomingRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Code != other.Code) return false; + if (Speed != other.Speed) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Code != 0) hash ^= Code.GetHashCode(); + if (Speed != 0D) hash ^= Speed.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Code != 0) { + output.WriteRawTag(8); + output.WriteInt32(Code); + } + if (Speed != 0D) { + output.WriteRawTag(17); + output.WriteDouble(Speed); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Code != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Code); + } + if (Speed != 0D) { + size += 1 + 8; + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(DispenserHomingRequest other) { + if (other == null) { + return; + } + if (other.Code != 0) { + Code = other.Code; + } + if (other.Speed != 0D) { + Speed = other.Speed; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 8: { + Code = input.ReadInt32(); + break; + } + case 17: { + Speed = input.ReadDouble(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Diagnostics/DispenserHomingResponse.cs b/Software/Visual_Studio/Tango.PMR/Diagnostics/DispenserHomingResponse.cs new file mode 100644 index 000000000..dce4f5777 --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/Diagnostics/DispenserHomingResponse.cs @@ -0,0 +1,188 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: DispenserHomingResponse.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.Diagnostics { + + /// Holder for reflection information generated from DispenserHomingResponse.proto + public static partial class DispenserHomingResponseReflection { + + #region Descriptor + /// File descriptor for DispenserHomingResponse.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static DispenserHomingResponseReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Ch1EaXNwZW5zZXJIb21pbmdSZXNwb25zZS5wcm90bxIVVGFuZ28uUE1SLkRp", + "YWdub3N0aWNzIkAKF0Rpc3BlbnNlckhvbWluZ1Jlc3BvbnNlEhAKCFByb2dy", + "ZXNzGAEgASgBEhMKC01heFByb2dyZXNzGAIgASgBQiEKH2NvbS50d2luZS50", + "YW5nby5wbXIuZGlhZ25vc3RpY3NiBnByb3RvMw==")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Diagnostics.DispenserHomingResponse), global::Tango.PMR.Diagnostics.DispenserHomingResponse.Parser, new[]{ "Progress", "MaxProgress" }, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class DispenserHomingResponse : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DispenserHomingResponse()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Tango.PMR.Diagnostics.DispenserHomingResponseReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DispenserHomingResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DispenserHomingResponse(DispenserHomingResponse other) : this() { + progress_ = other.progress_; + maxProgress_ = other.maxProgress_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DispenserHomingResponse Clone() { + return new DispenserHomingResponse(this); + } + + /// Field number for the "Progress" field. + public const int ProgressFieldNumber = 1; + private double progress_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double Progress { + get { return progress_; } + set { + progress_ = value; + } + } + + /// Field number for the "MaxProgress" field. + public const int MaxProgressFieldNumber = 2; + private double maxProgress_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double MaxProgress { + get { return maxProgress_; } + set { + maxProgress_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as DispenserHomingResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(DispenserHomingResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Progress != other.Progress) return false; + if (MaxProgress != other.MaxProgress) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Progress != 0D) hash ^= Progress.GetHashCode(); + if (MaxProgress != 0D) hash ^= MaxProgress.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Progress != 0D) { + output.WriteRawTag(9); + output.WriteDouble(Progress); + } + if (MaxProgress != 0D) { + output.WriteRawTag(17); + output.WriteDouble(MaxProgress); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Progress != 0D) { + size += 1 + 8; + } + if (MaxProgress != 0D) { + size += 1 + 8; + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(DispenserHomingResponse other) { + if (other == null) { + return; + } + if (other.Progress != 0D) { + Progress = other.Progress; + } + if (other.MaxProgress != 0D) { + MaxProgress = other.MaxProgress; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 9: { + Progress = input.ReadDouble(); + break; + } + case 17: { + MaxProgress = input.ReadDouble(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Diagnostics/DispenserJoggingRequest.cs b/Software/Visual_Studio/Tango.PMR/Diagnostics/DispenserJoggingRequest.cs new file mode 100644 index 000000000..48894af8d --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/Diagnostics/DispenserJoggingRequest.cs @@ -0,0 +1,218 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: DispenserJoggingRequest.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.Diagnostics { + + /// Holder for reflection information generated from DispenserJoggingRequest.proto + public static partial class DispenserJoggingRequestReflection { + + #region Descriptor + /// File descriptor for DispenserJoggingRequest.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static DispenserJoggingRequestReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Ch1EaXNwZW5zZXJKb2dnaW5nUmVxdWVzdC5wcm90bxIVVGFuZ28uUE1SLkRp", + "YWdub3N0aWNzGhRNb3RvckRpcmVjdGlvbi5wcm90byJwChdEaXNwZW5zZXJK", + "b2dnaW5nUmVxdWVzdBI4CglEaXJlY3Rpb24YASABKA4yJS5UYW5nby5QTVIu", + "RGlhZ25vc3RpY3MuTW90b3JEaXJlY3Rpb24SDAoEQ29kZRgCIAEoBRINCgVT", + "cGVlZBgDIAEoAUIhCh9jb20udHdpbmUudGFuZ28ucG1yLmRpYWdub3N0aWNz", + "YgZwcm90bzM=")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { global::Tango.PMR.Diagnostics.MotorDirectionReflection.Descriptor, }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Diagnostics.DispenserJoggingRequest), global::Tango.PMR.Diagnostics.DispenserJoggingRequest.Parser, new[]{ "Direction", "Code", "Speed" }, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class DispenserJoggingRequest : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DispenserJoggingRequest()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Tango.PMR.Diagnostics.DispenserJoggingRequestReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DispenserJoggingRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DispenserJoggingRequest(DispenserJoggingRequest other) : this() { + direction_ = other.direction_; + code_ = other.code_; + speed_ = other.speed_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DispenserJoggingRequest Clone() { + return new DispenserJoggingRequest(this); + } + + /// Field number for the "Direction" field. + public const int DirectionFieldNumber = 1; + private global::Tango.PMR.Diagnostics.MotorDirection direction_ = 0; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Tango.PMR.Diagnostics.MotorDirection Direction { + get { return direction_; } + set { + direction_ = value; + } + } + + /// Field number for the "Code" field. + public const int CodeFieldNumber = 2; + private int code_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Code { + get { return code_; } + set { + code_ = value; + } + } + + /// Field number for the "Speed" field. + public const int SpeedFieldNumber = 3; + private double speed_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double Speed { + get { return speed_; } + set { + speed_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as DispenserJoggingRequest); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(DispenserJoggingRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Direction != other.Direction) return false; + if (Code != other.Code) return false; + if (Speed != other.Speed) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Direction != 0) hash ^= Direction.GetHashCode(); + if (Code != 0) hash ^= Code.GetHashCode(); + if (Speed != 0D) hash ^= Speed.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Direction != 0) { + output.WriteRawTag(8); + output.WriteEnum((int) Direction); + } + if (Code != 0) { + output.WriteRawTag(16); + output.WriteInt32(Code); + } + if (Speed != 0D) { + output.WriteRawTag(25); + output.WriteDouble(Speed); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Direction != 0) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Direction); + } + if (Code != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Code); + } + if (Speed != 0D) { + size += 1 + 8; + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(DispenserJoggingRequest other) { + if (other == null) { + return; + } + if (other.Direction != 0) { + Direction = other.Direction; + } + if (other.Code != 0) { + Code = other.Code; + } + if (other.Speed != 0D) { + Speed = other.Speed; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 8: { + direction_ = (global::Tango.PMR.Diagnostics.MotorDirection) input.ReadEnum(); + break; + } + case 16: { + Code = input.ReadInt32(); + break; + } + case 25: { + Speed = input.ReadDouble(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Diagnostics/DispenserJoggingResponse.cs b/Software/Visual_Studio/Tango.PMR/Diagnostics/DispenserJoggingResponse.cs new file mode 100644 index 000000000..ab32d6f98 --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/Diagnostics/DispenserJoggingResponse.cs @@ -0,0 +1,131 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: DispenserJoggingResponse.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.Diagnostics { + + /// Holder for reflection information generated from DispenserJoggingResponse.proto + public static partial class DispenserJoggingResponseReflection { + + #region Descriptor + /// File descriptor for DispenserJoggingResponse.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static DispenserJoggingResponseReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Ch5EaXNwZW5zZXJKb2dnaW5nUmVzcG9uc2UucHJvdG8SFVRhbmdvLlBNUi5E", + "aWFnbm9zdGljcyIaChhEaXNwZW5zZXJKb2dnaW5nUmVzcG9uc2VCIQofY29t", + "LnR3aW5lLnRhbmdvLnBtci5kaWFnbm9zdGljc2IGcHJvdG8z")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Diagnostics.DispenserJoggingResponse), global::Tango.PMR.Diagnostics.DispenserJoggingResponse.Parser, null, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class DispenserJoggingResponse : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DispenserJoggingResponse()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Tango.PMR.Diagnostics.DispenserJoggingResponseReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DispenserJoggingResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DispenserJoggingResponse(DispenserJoggingResponse other) : this() { + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DispenserJoggingResponse Clone() { + return new DispenserJoggingResponse(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as DispenserJoggingResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(DispenserJoggingResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(DispenserJoggingResponse other) { + if (other == null) { + return; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Diagnostics/MotorHomingResponse.cs b/Software/Visual_Studio/Tango.PMR/Diagnostics/MotorHomingResponse.cs index 7dd9f982b..487eb32a6 100644 --- a/Software/Visual_Studio/Tango.PMR/Diagnostics/MotorHomingResponse.cs +++ b/Software/Visual_Studio/Tango.PMR/Diagnostics/MotorHomingResponse.cs @@ -24,7 +24,7 @@ namespace Tango.PMR.Diagnostics { string.Concat( "ChlNb3RvckhvbWluZ1Jlc3BvbnNlLnByb3RvEhVUYW5nby5QTVIuRGlhZ25v", "c3RpY3MiPAoTTW90b3JIb21pbmdSZXNwb25zZRIQCghQcm9ncmVzcxgBIAEo", - "BRITCgtNYXhQcm9ncmVzcxgCIAEoBUIhCh9jb20udHdpbmUudGFuZ28ucG1y", + "ARITCgtNYXhQcm9ncmVzcxgCIAEoAUIhCh9jb20udHdpbmUudGFuZ28ucG1y", "LmRpYWdub3N0aWNzYgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, @@ -71,9 +71,9 @@ namespace Tango.PMR.Diagnostics { /// Field number for the "Progress" field. public const int ProgressFieldNumber = 1; - private int progress_; + private double progress_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int Progress { + public double Progress { get { return progress_; } set { progress_ = value; @@ -82,9 +82,9 @@ namespace Tango.PMR.Diagnostics { /// Field number for the "MaxProgress" field. public const int MaxProgressFieldNumber = 2; - private int maxProgress_; + private double maxProgress_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int MaxProgress { + public double MaxProgress { get { return maxProgress_; } set { maxProgress_ = value; @@ -112,8 +112,8 @@ namespace Tango.PMR.Diagnostics { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; - if (Progress != 0) hash ^= Progress.GetHashCode(); - if (MaxProgress != 0) hash ^= MaxProgress.GetHashCode(); + if (Progress != 0D) hash ^= Progress.GetHashCode(); + if (MaxProgress != 0D) hash ^= MaxProgress.GetHashCode(); return hash; } @@ -124,24 +124,24 @@ namespace Tango.PMR.Diagnostics { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { - if (Progress != 0) { - output.WriteRawTag(8); - output.WriteInt32(Progress); + if (Progress != 0D) { + output.WriteRawTag(9); + output.WriteDouble(Progress); } - if (MaxProgress != 0) { - output.WriteRawTag(16); - output.WriteInt32(MaxProgress); + if (MaxProgress != 0D) { + output.WriteRawTag(17); + output.WriteDouble(MaxProgress); } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; - if (Progress != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(Progress); + if (Progress != 0D) { + size += 1 + 8; } - if (MaxProgress != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(MaxProgress); + if (MaxProgress != 0D) { + size += 1 + 8; } return size; } @@ -151,10 +151,10 @@ namespace Tango.PMR.Diagnostics { if (other == null) { return; } - if (other.Progress != 0) { + if (other.Progress != 0D) { Progress = other.Progress; } - if (other.MaxProgress != 0) { + if (other.MaxProgress != 0D) { MaxProgress = other.MaxProgress; } } @@ -167,12 +167,12 @@ namespace Tango.PMR.Diagnostics { default: input.SkipLastField(); break; - case 8: { - Progress = input.ReadInt32(); + case 9: { + Progress = input.ReadDouble(); break; } - case 16: { - MaxProgress = input.ReadInt32(); + case 17: { + MaxProgress = input.ReadDouble(); break; } } diff --git a/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj b/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj index e6f671ca7..c50ce853f 100644 --- a/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj +++ b/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj @@ -55,6 +55,14 @@ + + + + + + + + diff --git a/Software/Visual_Studio/Tango.UnitTesting/App.config b/Software/Visual_Studio/Tango.UnitTesting/App.config index 901eeb586..80fd5e3fa 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/App.config +++ b/Software/Visual_Studio/Tango.UnitTesting/App.config @@ -17,4 +17,12 @@ + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Visuals/AnalogSwitch/AnalogSwitch.xaml b/Software/Visual_Studio/Tango.Visuals/AnalogSwitch/AnalogSwitch.xaml new file mode 100644 index 000000000..c7ae4fe57 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/AnalogSwitch/AnalogSwitch.xaml @@ -0,0 +1,12 @@ + + + + + + diff --git a/Software/Visual_Studio/Tango.Visuals/AnalogSwitch/AnalogSwitch.xaml.cs b/Software/Visual_Studio/Tango.Visuals/AnalogSwitch/AnalogSwitch.xaml.cs new file mode 100644 index 000000000..2149409a1 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/AnalogSwitch/AnalogSwitch.xaml.cs @@ -0,0 +1,66 @@ +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.Effects; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.Visuals +{ + /// + /// Interaction logic for AnalogSwitch.xaml + /// + public partial class AnalogSwitch : UserControl + { + public event Action CheckedChanged; + + public AnalogSwitch() + { + InitializeComponent(); + this.PreviewMouseUp += AnalogSwitch_PreviewMouseUp; + } + + void AnalogSwitch_PreviewMouseUp(object sender, MouseButtonEventArgs e) + { + IsChecked = !IsChecked; + } + + public bool IsChecked + { + get { return (bool)GetValue(IsCheckedProperty); } + set { SetValue(IsCheckedProperty, value); } + } + + // Using a DependencyProperty as the backing store for IsChecked. This enables animation, styling, binding, etc... + public static readonly DependencyProperty IsCheckedProperty = + DependencyProperty.Register("IsChecked", typeof(bool), typeof(AnalogSwitch), new PropertyMetadata(false,new PropertyChangedCallback(CheckChanged))); + + private static void CheckChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + AnalogSwitch s = d as AnalogSwitch; + if ((bool)e.NewValue) + { + s.imgON.Visibility = Visibility.Visible; + s.imgOFF.Visibility = Visibility.Hidden; + } + else + { + s.imgOFF.Visibility = Visibility.Visible; + s.imgON.Visibility = Visibility.Hidden; + } + + if (s.CheckedChanged != null) s.CheckedChanged(s); + } + + + } +} diff --git a/Software/Visual_Studio/Tango.Visuals/Images/off.png b/Software/Visual_Studio/Tango.Visuals/Images/off.png new file mode 100644 index 000000000..67f2f4a6f Binary files /dev/null and b/Software/Visual_Studio/Tango.Visuals/Images/off.png differ diff --git a/Software/Visual_Studio/Tango.Visuals/Images/on.png b/Software/Visual_Studio/Tango.Visuals/Images/on.png new file mode 100644 index 000000000..9922b1901 Binary files /dev/null and b/Software/Visual_Studio/Tango.Visuals/Images/on.png differ diff --git a/Software/Visual_Studio/Tango.Visuals/Led/Led.xaml b/Software/Visual_Studio/Tango.Visuals/Led/Led.xaml new file mode 100644 index 000000000..b59ed5d15 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Led/Led.xaml @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/Tango.Visuals/Led/Led.xaml.cs b/Software/Visual_Studio/Tango.Visuals/Led/Led.xaml.cs new file mode 100644 index 000000000..5a1e67913 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Led/Led.xaml.cs @@ -0,0 +1,179 @@ +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.Core.Commands; + +namespace Tango.Visuals +{ + /// + /// Represents an LED like button that acts like a check box. + /// + public partial class Led : UserControl + { + #region Constructors + + public Led() + { + InitializeComponent(); + this.PreviewMouseUp += LedControl_PreviewMouseUp; + } + + #endregion + + #region Event Handlers + + void LedControl_PreviewMouseUp(object sender, MouseButtonEventArgs e) + { + if (IsPassive) return; + + IsChecked = !IsChecked; + + if (Command != null) + { + Command.Execute(null); + } + } + + #endregion + + #region Properties + + /// + /// Gets or sets whether the LED is on or off. + /// + public bool IsChecked + { + get { return (bool)GetValue(IsCheckedProperty); } + set { SetValue(IsCheckedProperty, value); } + } + public static readonly DependencyProperty IsCheckedProperty = + DependencyProperty.Register("IsChecked", typeof(bool), typeof(Led), new PropertyMetadata(false)); + + + /// + /// Gets or sets whether the control is enabled. + /// + public bool Enabled + { + get { return (bool)GetValue(EnabledProperty); } + set { SetValue(EnabledProperty, value); } + } + public static readonly DependencyProperty EnabledProperty = + DependencyProperty.Register("Enabled", typeof(bool), typeof(Led), new PropertyMetadata(true, new PropertyChangedCallback(EnabledChanged))); + private static void EnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + Led l = d as Led; + if ((bool)e.NewValue) + { + l.gridMask.Visibility = Visibility.Hidden; + l.grid.Visibility = Visibility.Visible; + } + else + { + l.gridMask.Visibility = Visibility.Visible; + l.grid.Visibility = Visibility.Hidden; + } + } + + + public Brush FillBrush + { + get { return (Brush)GetValue(FillBrushProperty); } + set { SetValue(FillBrushProperty, value); } + } + public static readonly DependencyProperty FillBrushProperty = + DependencyProperty.Register("FillBrush", typeof(Brush), typeof(Led), new PropertyMetadata(null)); + + + public double InnerOpacity + { + get { return (double)GetValue(InnerOpacityProperty); } + set { SetValue(InnerOpacityProperty, value); } + } + public static readonly DependencyProperty InnerOpacityProperty = + DependencyProperty.Register("InnerOpacity", typeof(double), typeof(Led), new PropertyMetadata(1.0)); + + + public bool IsPassive + { + get { return (bool)GetValue(IsPassiveProperty); } + set { SetValue(IsPassiveProperty, value); } + } + public static readonly DependencyProperty IsPassiveProperty = + DependencyProperty.Register("IsPassive", typeof(bool), typeof(Led), new PropertyMetadata(false)); + + + + public Brush CheckedBrush + { + get { return (Brush)GetValue(CheckedBrushProperty); } + set { SetValue(CheckedBrushProperty, value); } + } + public static readonly DependencyProperty CheckedBrushProperty = + DependencyProperty.Register("CheckedBrush", typeof(Brush), typeof(Led), new PropertyMetadata(null,CheckBrushChanged)); + + private static void CheckBrushChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var control = d as Led; + control.Resources["inner"] = control.CheckedBrush; + } + + + + public Brush UnCheckedBrush + { + get { return (Brush)GetValue(UnCheckedBrushProperty); } + set { SetValue(UnCheckedBrushProperty, value); } + } + public static readonly DependencyProperty UnCheckedBrushProperty = + DependencyProperty.Register("UnCheckedBrush", typeof(Brush), typeof(Led), new PropertyMetadata(null,UnCheckedBrushChanged)); + + private static void UnCheckedBrushChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var control = d as Led; + control.Resources["innerOff"] = control.UnCheckedBrush; + } + + + + #endregion + + #region Commands + + /// + /// Represents the command to bind for CanExecute event. + /// + public RelayCommand Command + { + get { return (RelayCommand)GetValue(CommandProperty); } + set { SetValue(CommandProperty, value); } + } + public static readonly DependencyProperty CommandProperty = + DependencyProperty.Register("Command", typeof(RelayCommand), typeof(Led), new PropertyMetadata(null, new PropertyChangedCallback(CommandChanged))); + private static void CommandChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + Led l = d as Led; + + if (l.Command != null) + { + l.Command.CanExecuteChanged += (x, y) => + { + l.IsEnabled = l.Command.CanExecute(null); + }; + } + } + + #endregion + } +} \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Visuals/Tango.Visuals.csproj b/Software/Visual_Studio/Tango.Visuals/Tango.Visuals.csproj index 4eaa3376e..53c87d0f5 100644 --- a/Software/Visual_Studio/Tango.Visuals/Tango.Visuals.csproj +++ b/Software/Visual_Studio/Tango.Visuals/Tango.Visuals.csproj @@ -52,6 +52,9 @@ GlobalVersionInfo.cs + + AnalogSwitch.xaml + PieAxisTicks.xaml @@ -73,6 +76,9 @@ Knob.xaml + + Led.xaml + YAxisDoubles.xaml @@ -90,6 +96,10 @@ VUMeter.xaml + + MSBuild:Compile + Designer + MSBuild:Compile Designer @@ -110,6 +120,10 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + MSBuild:Compile Designer @@ -188,6 +202,17 @@ + + + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} + Tango.Core + + + + + + +