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. --- .../Images/camera.png | Bin 0 -> 1360 bytes .../Images/graphs.png | Bin 0 -> 1666 bytes .../Images/line_graph.png | Bin 0 -> 14612 bytes .../Images/no-signal.jpg | Bin 0 -> 611002 bytes .../Resources/GraphEx.xaml | 126 ++++++++++++ .../Tango.MachineStudio.Developer.csproj | 24 +++ .../ViewModels/MainViewVM.cs | 221 ++++++++++++++++++--- .../Views/MainView.xaml | 179 ++++++++++++++++- .../Views/MainView.xaml.cs | 27 +++ 9 files changed, 538 insertions(+), 39 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/camera.png create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/graphs.png create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/line_graph.png create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/no-signal.jpg create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Resources/GraphEx.xaml (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/camera.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/camera.png new file mode 100644 index 000000000..526573632 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/camera.png differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/graphs.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/graphs.png new file mode 100644 index 000000000..6a211693d Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/graphs.png differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/line_graph.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/line_graph.png new file mode 100644 index 000000000..7e21f4e97 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/line_graph.png differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/no-signal.jpg b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/no-signal.jpg new file mode 100644 index 000000000..e8b1313c9 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/no-signal.jpg differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Resources/GraphEx.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Resources/GraphEx.xaml new file mode 100644 index 000000000..a44a8191c --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Resources/GraphEx.xaml @@ -0,0 +1,126 @@ + + + Segoe UI + Lucida Console + + 28 + 26 + 20 + 16 + 14 + 12 + 9 + + + Silver + #FFE9E9E9 + Gray + #03A9F4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj index f5da6fca4..276dd6c54 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj @@ -82,6 +82,10 @@ GlobalVersionInfo.cs + + MSBuild:Compile + Designer + Designer MSBuild:Compile @@ -113,6 +117,10 @@ + + {b9ae25d6-be35-492f-9079-21a7f3e6f7cc} + RealTimeGraphEx + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} Tango.Core @@ -125,6 +133,10 @@ {38197109-8610-4d3f-92b9-16d48df94d7c} Tango.DAL.Remote + + {b112d89a-a106-41ae-a0c1-4abc84c477f5} + Tango.DragAndDrop + {8491d07b-c1f6-4b62-a412-41b9fd2d6538} Tango.SharedUI @@ -161,5 +173,17 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs index 2013de3c8..590474f9d 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 @@ -7,22 +7,37 @@ using System.Text; using System.Threading.Tasks; using Tango.Core.Commands; using Tango.DAL.Observables; +using Tango.MachineStudio.Common.Controls; using Tango.MachineStudio.Common.Notifications; using Tango.MachineStudio.Common.StudioApplication; using Tango.SharedUI; namespace Tango.MachineStudio.Developer.ViewModels { + /// + /// Represents the developer module main view, view model. + /// + /// public class MainViewVM : ViewModel { private INotificationProvider _notification; + #region Properties + + /// + /// Gets or sets the application manager. + /// public IStudioApplicationManager ApplicationManager { get; set; } + /// + /// Gets or sets observable entites database the adapter. + /// public ObservablesEntitiesAdapter Adapter { get; set; } private Machine _selectedMachine; - + /// + /// Gets or sets the selected machine. + /// public Machine SelectedMachine { get { return _selectedMachine; } @@ -30,7 +45,9 @@ namespace Tango.MachineStudio.Developer.ViewModels } private List _liquidTypesRmls; - + /// + /// Gets or sets the liquid types RMLS. + /// public List LiquidTypesRmls { get { return _liquidTypesRmls; } @@ -38,48 +55,49 @@ namespace Tango.MachineStudio.Developer.ViewModels } private ProcessParametersTablesGroup _rmlProcessParametersTablesGroup; - + /// + /// Gets or sets the RML process parameters table group (cloned). + /// public ProcessParametersTablesGroup RmlProcessParametersTableGroup { get { return _rmlProcessParametersTablesGroup; } set { _rmlProcessParametersTablesGroup = value; RaisePropertyChangedAuto(); } } - private ProcessParametersTablesGroup _selectedGroupHistory; - - public ProcessParametersTablesGroup SelectedGroupHistory - { - get { return _selectedGroupHistory; } - set { _selectedGroupHistory = value; RaisePropertyChangedAuto(); OnSelectedGroupHistoryChanged(); } - } - - private void OnSelectedGroupHistoryChanged() - { - if (SelectedGroupHistory != null) - { - RmlProcessParametersTableGroup = SelectedGroupHistory.CloneGroup(); - } - } - private ObservableCollection _groupsHistory; - + /// + /// Gets or sets the RML process parameters groups history. + /// public ObservableCollection GroupsHistory { get { return _groupsHistory; } set { _groupsHistory = value; RaisePropertyChangedAuto(); } } - private Job _selectedJob; + private ProcessParametersTablesGroup _selectedGroupHistory; + /// + /// Gets or sets the selected process parameters tables group history. + /// + public ProcessParametersTablesGroup SelectedGroupHistory + { + get { return _selectedGroupHistory; } + set { _selectedGroupHistory = value; RaisePropertyChangedAuto(); OnSelectedGroupHistoryChanged(); } + } + private Job _selectedJob; + /// + /// Gets or sets the selected machine job. + /// public Job SelectedJob { get { return _selectedJob; } set { _selectedJob = value; RaisePropertyChangedAuto(); } } - private Rml _selectedRML; - + /// + /// Gets or sets the selected RML. + /// public Rml SelectedRML { get { return _selectedRML; } @@ -87,43 +105,131 @@ namespace Tango.MachineStudio.Developer.ViewModels } private bool _isSideBarOpened; - + /// + /// Gets or sets a value indicating whether the configuration panels are opened. + /// public bool IsSideBarOpened { get { return _isSideBarOpened; } set { _isSideBarOpened = value; RaisePropertyChangedAuto(); } } + private ObservableCollection _availableSensors; + /// + /// Gets or sets the available sensors. + /// + public ObservableCollection AvailableSensors + { + get { return _availableSensors; } + set { _availableSensors = value; RaisePropertyChangedAuto(); } + } + private ObservableCollection _graphs; + /// + /// Gets or sets the collection of displayed graph controls. + /// + public ObservableCollection Graphs + { + get { return _graphs; } + set { _graphs = value; RaisePropertyChangedAuto(); } + } + + #endregion + + #region Commands + + /// + /// Gets or sets the edit machine command. + /// public RelayCommand EditMachineCommand { get; set; } + /// + /// Gets or sets the edit RML command. + /// public RelayCommand EditRMLCommand { get; set; } + /// + /// Gets or sets the toggle side bar command. + /// public RelayCommand ToggleSideBarCommand { get; set; } + /// + /// Gets or sets the save process parameters command. + /// public RelayCommand SaveProcessParametersCommand { get; set; } + /// + /// Gets or sets the save liquid factors command. + /// public RelayCommand SaveLiquidFactorsCommand { get; set; } + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// public MainViewVM() { IsSideBarOpened = true; + + if (!this.DesignMode) + { + Adapter = ObservablesEntitiesAdapter.Instance; + AvailableSensors = Adapter.Sensors.ToObservableCollection(); + } + + Graphs = new ObservableCollection(); } + /// + /// Initializes a new instance of the class. + /// + /// The application manager. + /// The notification provider. [PreferredConstructor] - public MainViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider) + public MainViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider) : this() { _notification = notificationProvider; - Adapter = ObservablesEntitiesAdapter.Instance; EditMachineCommand = new RelayCommand(EditMachine, (x) => SelectedMachine != null); ApplicationManager = applicationManager; EditRMLCommand = new RelayCommand(EditRML, (x) => SelectedRML != null); ToggleSideBarCommand = new RelayCommand(() => IsSideBarOpened = !IsSideBarOpened); SaveProcessParametersCommand = new RelayCommand(SaveProcessParameters); SaveLiquidFactorsCommand = new RelayCommand(SaveLiquidFactors); - IsSideBarOpened = true; } + #endregion + + #region Virtual Methods + + /// + /// Called when the selected group history has been changed + /// + protected virtual void OnSelectedGroupHistoryChanged() + { + if (SelectedGroupHistory != null) + { + RmlProcessParametersTableGroup = SelectedGroupHistory.CloneGroup(); + } + } + + /// + /// Called when the machine has been changed + /// + protected virtual void OnMachineChanged() + { + InvalidateLiquidFactorsAndProcessTables(); + } + + #endregion + + #region Private Methods + + /// + /// Saves the liquid factors. + /// private async void SaveLiquidFactors() { if (SelectedRML != null) @@ -141,21 +247,25 @@ namespace Tango.MachineStudio.Developer.ViewModels } } + /// + /// Navigates to the DB Module in order to edit the selected RML. + /// private void EditRML() { ApplicationManager.RequestModule("Data Base", SelectedRML); } + /// + /// Navigates to the Machine Designer Module in order to edit the selected machine. + /// private void EditMachine() { ApplicationManager.RequestModule("Machine Designer", SelectedMachine); } - private void OnMachineChanged() - { - InvalidateLiquidFactorsAndProcessTables(); - } - + /// + /// Saves the process parameters group. + /// private async void SaveProcessParameters() { var response = _notification.ShowTextInput("Enter Group Name", "Group Name"); @@ -196,6 +306,9 @@ namespace Tango.MachineStudio.Developer.ViewModels } } + /// + /// Invalidates the liquid factors and process parameters tables. + /// private void InvalidateLiquidFactorsAndProcessTables() { if (SelectedRML != null && SelectedMachine != null) @@ -212,5 +325,49 @@ namespace Tango.MachineStudio.Developer.ViewModels GroupsHistory = SelectedRML.ProcessParametersTablesGroups.OrderByDescending(x => x.SaveDate).OrderBy(x => !x.Active).ToObservableCollection(); } } + + #endregion + + #region Public Events + + /// + /// Add sensor graph from available sensors to displayed graphs. + /// + /// The sensor. + public void OnDropAvailableSensor(Sensor sensor) + { + if (Graphs.Count < 8) + { + RealTimeGraphControl graphControl = new RealTimeGraphControl(); + 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.GraphRemoveButtonPressed += (sender, __) => + { + RemoveGraph(sender as RealTimeGraphControl); + }; + Graphs.Add(graphControl); + AvailableSensors.Remove(sensor); + } + else + { + _notification.ShowInfo("The maximum number of real-time graphs is eight. Please remove a graph to add another."); + } + } + + /// + /// Removes the graph. + /// + /// The graph. + public void RemoveGraph(RealTimeGraphControl graph) + { + Graphs.Remove(graph); + AvailableSensors.Insert(0, graph.Tag as Sensor); + } + + #endregion } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml index 7d98fe2d7..40babfc74 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml @@ -5,6 +5,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:global="clr-namespace:Tango.MachineStudio.Developer" + xmlns:dragAndDrop="clr-namespace:Tango.DragAndDrop;assembly=Tango.DragAndDrop" xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" xmlns:db="clr-namespace:Tango.MachineStudio.DB.Views.DBViews;assembly=Tango.MachineStudio.DB" xmlns:commonControls="clr-namespace:Tango.MachineStudio.Common.Controls;assembly=Tango.MachineStudio.Common" @@ -31,6 +32,51 @@ + + + + @@ -291,7 +337,7 @@ - + @@ -331,9 +377,9 @@ - + - + @@ -402,7 +448,7 @@ - + - CAMERAS + + + + + USB CAMERAS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + AVAILABLE GRAPHS + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + DRAG & DROP GRAPHS + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs index 6ebfd9832..9eeff4975 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs @@ -12,6 +12,9 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using Tango.DAL.Observables; +using Tango.DragAndDrop; +using Tango.MachineStudio.Developer.ViewModels; namespace Tango.MachineStudio.Developer.Views { @@ -20,9 +23,33 @@ namespace Tango.MachineStudio.Developer.Views /// public partial class MainView : UserControl { + private MainViewVM _vm; + + public DraggingSurface DraggingSurface + { + get { return (DraggingSurface)GetValue(DraggingSurfaceProperty); } + set { SetValue(DraggingSurfaceProperty, value); } + } + public static readonly DependencyProperty DraggingSurfaceProperty = + DependencyProperty.Register("DraggingSurface", typeof(DraggingSurface), typeof(MainView), new PropertyMetadata(null)); + public MainView() { InitializeComponent(); + + DraggingSurface = draggingSurface; + this.Loaded += (x, y) => + { + _vm = DataContext as MainViewVM; + }; + } + + private void OnDropAvailableSensor(object sender, DropEventArgs e) + { + if (e.Draggable.DataContext is Sensor) + { + _vm.OnDropAvailableSensor(e.Draggable.DataContext as Sensor); + } } } } -- cgit v1.3.1