From 1e5d6d1b458aa963e6ddcd9b15d692a274acd561 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 20 Sep 2018 17:35:49 +0300 Subject: Implemented Heater widget on tech board! --- .../Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml') 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 3fe82944c..cbc296e32 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 @@ -202,7 +202,7 @@ - + + + + + + + + Selected Heater + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/HeaterTemplate.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/HeaterTemplate.xaml.cs new file mode 100644 index 000000000..011c41ddc --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/HeaterTemplate.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 HeaterTemplate : UserControl + { + public HeaterTemplate() + { + 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 2a1660bcc..2c6a08554 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 @@ -171,6 +171,9 @@ + + HeaterTemplate.xaml + TextTemplate.xaml @@ -346,6 +349,10 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + MSBuild:Compile Designer 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 cbc296e32..ea833db99 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 @@ -393,6 +393,9 @@ + + + -- cgit v1.3.1 From 3e4bec71b356231134ccb1b52d8faf264c57c6a1 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 26 Sep 2018 11:07:32 +0300 Subject: Working on new tech module tabs. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 15400960 -> 15400960 bytes .../Project/MachineTechViewProject.cs | 4 +- .../Project/MachineTechViewProjectTab.cs | 20 + .../Tango.MachineStudio.Technician.csproj | 9 + .../ViewModels/MachineTechTabVM.cs | 62 +++ .../ViewModels/MachineTechViewVM.cs | 84 ++-- .../Views/MachineTechTabView.xaml | 13 + .../Views/MachineTechTabView.xaml.cs | 28 ++ .../Views/MachineTechView.xaml | 435 ++++++++++++--------- .../Views/MachineTechView.xaml.cs | 10 +- .../Tango.Editors/ElementsEditor.xaml | 12 +- .../Tango.Editors/ElementsEditor.xaml.cs | 12 +- 13 files changed, 456 insertions(+), 233 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Project/MachineTechViewProjectTab.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechTabVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechTabView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechTabView.xaml.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index a0ba6351e..15b63d95f 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 7d419821a..d14575ea3 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/Project/MachineTechViewProject.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Project/MachineTechViewProject.cs index 700e04f7d..0837fde53 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Project/MachineTechViewProject.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Project/MachineTechViewProject.cs @@ -10,11 +10,11 @@ namespace Tango.MachineStudio.Technician.Project { public class MachineTechViewProject { - public List Items { get; set; } + public List Tabs { get; set; } public MachineTechViewProject() { - Items = new List(); + Tabs = new List(); } public void Save(String fileName) diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Project/MachineTechViewProjectTab.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Project/MachineTechViewProjectTab.cs new file mode 100644 index 000000000..c86e1ae55 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Project/MachineTechViewProjectTab.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.MachineStudio.Technician.TechItems; + +namespace Tango.MachineStudio.Technician.Project +{ + public class MachineTechViewProjectTab + { + public String Name { get; set; } + public List Items { get; set; } + + public MachineTechViewProjectTab() + { + Items = new List(); + } + } +} 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 2c6a08554..4df317c6a 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 @@ -171,6 +171,7 @@ + HeaterTemplate.xaml @@ -261,7 +262,11 @@ + + + MachineTechTabView.xaml + MachineTechView.xaml @@ -437,6 +442,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + MSBuild:Compile Designer diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechTabVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechTabVM.cs new file mode 100644 index 000000000..4e04a078c --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechTabVM.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Editors; +using Tango.SharedUI; + +namespace Tango.MachineStudio.Technician.ViewModels +{ + public class MachineTechTabVM : ViewModel + { + private ElementsEditor _editor; + + public ElementsEditor Editor + { + get { return _editor; } + set { _editor = value; RaisePropertyChangedAuto(); } + } + + private String _name; + /// + /// Gets or sets the name. + /// + public String Name + { + get { return _name; } + set { _name = value; RaisePropertyChangedAuto(); } + } + + private bool _isSelected; + /// + /// Gets or sets a value indicating whether this instance is selected. + /// + public bool IsSelected + { + get { return _isSelected; } + set { _isSelected = value; RaisePropertyChangedAuto(); } + } + + + private ObservableCollection _elements; + /// + /// Gets or sets the visual elements. + /// + public ObservableCollection Elements + { + get { return _elements; } + set { _elements = value; RaisePropertyChangedAuto(); } + } + + /// + /// Initializes a new instance of the class. + /// + public MachineTechTabVM() + { + Name = "untitled"; + Elements = new ObservableCollection(); + } + } +} 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 6a9725106..85a431594 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 @@ -61,14 +61,35 @@ namespace Tango.MachineStudio.Technician.ViewModels #region Properties - private ObservableCollection _elements; + private ObservableCollection _tabs; /// - /// Gets or sets the visual elements. + /// Gets or sets the elements tabs. /// - public ObservableCollection Elements + public ObservableCollection Tabs { - get { return _elements; } - set { _elements = value; RaisePropertyChangedAuto(); } + get { return _tabs; } + set { _tabs = value; RaisePropertyChangedAuto(); } + } + + private MachineTechTabVM _selectedTab; + /// + /// Gets or sets the selected tab. + /// + public MachineTechTabVM SelectedTab + { + get { return _selectedTab; } + set + { + _selectedTab = value; + RaisePropertyChangedAuto(); + + foreach (var tab in Tabs.Where(x => x != _selectedTab)) + { + tab.IsSelected = false; + } + + _selectedTab.IsSelected = true; + } } private ObservableCollection _availableTechItems; @@ -223,6 +244,10 @@ namespace Tango.MachineStudio.Technician.ViewModels /// The notification provider. public MachineTechViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IDiagnosticsFrameProvider diagnosticsFrameProvider, IEventLogger eventLogger) { + Tabs = new ObservableCollection(); + Tabs.Add(new MachineTechTabVM() { IsSelected = true }); + SelectedTab = Tabs.First(); + _settings = SettingsManager.Default.GetOrCreate(); _single_graphs_recordings = new List>(); @@ -242,7 +267,6 @@ namespace Tango.MachineStudio.Technician.ViewModels ApplicationManager.ConnectedMachineChanged += ApplicationManager_ConnectedMachineChanged; Adapter = ObservablesStaticCollections.Instance; - Elements = new ObservableCollection(); OpenProjectCommand = new RelayCommand(OpenProject); SaveAsProjectCommand = new RelayCommand(SaveAsProject); @@ -325,7 +349,7 @@ namespace Tango.MachineStudio.Technician.ViewModels lock (_elementsLock) { - var elements = Elements.ToList(); + var elements = Tabs.SelectMany(x => x.Elements).ToList(); foreach (var item in elements.Select(x => x.HostedElement as TechItem)) { @@ -680,7 +704,7 @@ namespace Tango.MachineStudio.Technician.ViewModels { TechItem item = Activator.CreateInstance(typeof(Tech), new object[] { value }) as TechItem; IElementEditor editor = Activator.CreateInstance(typeof(Editor), new object[] { ((Tech)item), bounds }) as IElementEditor; - Elements.Add(editor); + SelectedTab.Elements.Add(editor); return (Editor)editor; } @@ -693,7 +717,7 @@ namespace Tango.MachineStudio.Technician.ViewModels private Editor CreateElement(TechItem item) where Editor : IElementEditor { IElementEditor editor = Activator.CreateInstance(typeof(Editor), new object[] { item, item.GetBounds() }) as IElementEditor; - Elements.Add(editor); + SelectedTab.Elements.Add(editor); return (Editor)editor; } @@ -1555,18 +1579,26 @@ namespace Tango.MachineStudio.Technician.ViewModels { using (_notification.PushTaskItem("Loading technician project file...")) { - Elements.Clear(); + Tabs.Clear(); _singleControllers.Clear(); _multiControllers.Clear(); - foreach (var item in project.Items) + foreach (var tab in project.Tabs) { - if (item is MotorGroupItem) + MachineTechTabVM t = new MachineTechTabVM(); + t.Name = tab.Name; + t.IsSelected = true; + Tabs.Add(t); + + foreach (var item in tab.Items) { - (item as MotorGroupItem).TechMotors = ObservablesStaticCollections.Instance.HardwareMotorTypes.Where(x => (item as MotorGroupItem).ItemsGuids.Contains(x.Guid)).ToObservableCollection(); - } + if (item is MotorGroupItem) + { + (item as MotorGroupItem).TechMotors = ObservablesStaticCollections.Instance.HardwareMotorTypes.Where(x => (item as MotorGroupItem).ItemsGuids.Contains(x.Guid)).ToObservableCollection(); + } - AddTechItem(item); + AddTechItem(item); + } } } } @@ -1623,16 +1655,24 @@ namespace Tango.MachineStudio.Technician.ViewModels { MachineTechViewProject project = new MachineTechViewProject(); - foreach (var element in Elements) + foreach (var tab in Tabs) { - if (element.HostedElement is MotorGroupItem) + MachineTechViewProjectTab pTab = new MachineTechViewProjectTab(); + pTab.Name = tab.Name; + + foreach (var element in tab.Elements) { - var group = element.HostedElement as MotorGroupItem; - group.ItemsGuids = group.TechMotors.Select(x => x.Guid).ToList(); + if (element.HostedElement is MotorGroupItem) + { + var group = element.HostedElement as MotorGroupItem; + group.ItemsGuids = group.TechMotors.Select(x => x.Guid).ToList(); + } + + (element.HostedElement as TechItem).SetBounds(element.GetBounds()); + pTab.Items.Add(element.HostedElement as TechItem); } - (element.HostedElement as TechItem).SetBounds(element.GetBounds()); - project.Items.Add(element.HostedElement as TechItem); + project.Tabs.Add(pTab); } return project; @@ -1673,7 +1713,7 @@ namespace Tango.MachineStudio.Technician.ViewModels private void SyncHardwareConfiguration() { - var elements = Elements.ToList(); + var elements = Tabs.SelectMany(x => x.Elements).ToList(); if (MachineOperator != null && MachineOperator.CurrentHardwareConfiguration != null) { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechTabView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechTabView.xaml new file mode 100644 index 000000000..fc14343a2 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechTabView.xaml @@ -0,0 +1,13 @@ + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechTabView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechTabView.xaml.cs new file mode 100644 index 000000000..38b1ae045 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechTabView.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.Views +{ + /// + /// Interaction logic for MachineTechTabView.xaml + /// + public partial class MachineTechTabView : UserControl + { + public MachineTechTabView() + { + InitializeComponent(); + } + } +} 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 ea833db99..99ecf72f2 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 @@ -22,6 +22,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -192,7 +287,7 @@ - + @@ -258,210 +353,160 @@ - - - - - + + + + + - + + + + + + + + + + + + + + + + + + - + - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - - - + + + + + + + + Left + + + + Top + + + - - - - - - - - Left - - - - Top - - - + + + + Width + + + + Height + + + - - - - Width - - - - Height - - - + + + + + + + Angle + + + + + + + - - - - - - - Angle - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml.cs index 977974f8a..694debd26 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml.cs @@ -32,8 +32,6 @@ namespace Tango.MachineStudio.Technician.Views { _vm = DataContext as MachineTechViewVM; }; - - (editor.UndoRedoStatesProvider as ElementsEditorUndoRedoStatesProvider).StateExecuted += MachineTechView_StateExecuted; } private void MachineTechView_StateExecuted(object sender, UndoRedoStateExecutedEventArgs e) @@ -61,5 +59,13 @@ namespace Tango.MachineStudio.Technician.Views { //editor.DeselectElements(); } + + private void Editor_Loaded(object sender, RoutedEventArgs e) + { + ElementsEditor editor = sender as ElementsEditor; + (editor.DataContext as MachineTechTabVM).Editor = editor; + + (editor.UndoRedoStatesProvider as ElementsEditorUndoRedoStatesProvider).StateExecuted += MachineTechView_StateExecuted; + } } } diff --git a/Software/Visual_Studio/Tango.Editors/ElementsEditor.xaml b/Software/Visual_Studio/Tango.Editors/ElementsEditor.xaml index 19db3992d..3d1bedc46 100644 --- a/Software/Visual_Studio/Tango.Editors/ElementsEditor.xaml +++ b/Software/Visual_Studio/Tango.Editors/ElementsEditor.xaml @@ -7,7 +7,7 @@ xmlns:converters="clr-namespace:Tango.Editors.Converters" xmlns:core="clr-namespace:Tango.Editors" mc:Ignorable="d" - x:Name="editor" Foreground="White" Background="#151515" FontSize="8" FocusVisualStyle="{x:Null}"> + x:Name="editor" FontSize="8" FocusVisualStyle="{x:Null}"> @@ -129,7 +129,7 @@ - + @@ -137,13 +137,13 @@ - - + - + @@ -181,7 +181,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 74ce549bf..bf2e41afa 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml @@ -56,13 +56,13 @@ - + - + @@ -72,8 +72,8 @@ 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 c5ecf60d5..4976739e4 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphMultiControl.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphMultiControl.xaml @@ -56,13 +56,13 @@ - + - + @@ -72,8 +72,8 @@ 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 eea369dfe..acddeec6e 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Resources/MaterialDesign.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Resources/MaterialDesign.xaml @@ -251,7 +251,7 @@ - + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/TextInputBoxWindow.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/TextInputBoxWindow.xaml.cs index d774c14eb..bc11dfd18 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/TextInputBoxWindow.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/TextInputBoxWindow.xaml.cs @@ -26,6 +26,14 @@ namespace Tango.MachineStudio.UI.Notifications { InitializeComponent(); this.Loaded += TextInputBoxWindow_Loaded; + + ContentRendered += TextInputBoxWindow_ContentRendered; + } + + private void TextInputBoxWindow_ContentRendered(object sender, EventArgs e) + { + txtText.Focus(); + txtText.SelectAll(); } private void TextInputBoxWindow_Loaded(object sender, RoutedEventArgs e) @@ -34,12 +42,8 @@ namespace Tango.MachineStudio.UI.Notifications ani.To = 1; ani.Duration = TimeSpan.FromSeconds(0.5); this.BeginAnimation(Window.OpacityProperty, ani); - - txtText.Focus(); } - - public String Hint { get { return (String)GetValue(HintProperty); } -- cgit v1.3.1 From 8bb81a7302e5a72322eae61b82389dfa7039c98c Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 26 Sep 2018 15:22:13 +0300 Subject: Default step division 8. Extend graphs FIFO capacity. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 15400960 -> 15400960 bytes .../ViewModels/MainViewVM.cs | 5 ++++- .../Views/JobView.xaml | 2 +- .../Converters/SecondsToTimeSpanConverter.cs | 23 +++++++++++++++++++++ .../Tango.MachineStudio.Technician.csproj | 1 + .../Views/MachineTechView.xaml | 9 ++++---- .../Tango.BL/EntitiesExtensions/BrushStop.cs | 10 ++++++++- Software/Visual_Studio/Tango.sln | 12 +++++------ 9 files changed, 49 insertions(+), 13 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Converters/SecondsToTimeSpanConverter.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index b3f54005e..ac80b21a8 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 e1545e683..19c454a47 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 ff4f47471..1dc59ab55 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 @@ -1908,7 +1908,9 @@ namespace Tango.MachineStudio.Developer.ViewModels newJob.Machine = SelectedMachine; SelectedMachine.Jobs.Add(newJob); - newJob.AddSolidSegment(); + var segment = newJob.AddSolidSegment(); + segment.BrushStops[0].SetAllDispensingStepDivisions(BL.Dispensing.DispenserStepDivisions.D8); + LogManager.Log("Saving selected machine to database..."); await SelectedMachine.SaveAsync(_machineDbContext); SelectedMachineJob = newJob; @@ -1963,6 +1965,7 @@ namespace Tango.MachineStudio.Developer.ViewModels stop.Segment = SelectedSegment; stop.ColorSpace = ColorSpaces.FirstOrDefault(); stop.Color = Colors.Black; + stop.SetAllDispensingStepDivisions(BL.Dispensing.DispenserStepDivisions.D8); stop.SetLiquidVolumes(SelectedMachine.Configuration, SelectedRML, SelectedProcessParametersTable); SelectedSegment.BrushStops.Add(stop); SelectedSegment.BrushStops.ToList().ForEach(x => x.RaiseOffsetChanged()); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml index 627e4d63e..f891f6520 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml @@ -1067,7 +1067,7 @@ - + + + + + + + + + + + + + + + + + + + + selected monitors to record + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorRecorderElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorRecorderElementEditor.xaml.cs new file mode 100644 index 000000000..213fa78e0 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorRecorderElementEditor.xaml.cs @@ -0,0 +1,103 @@ +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.BL.Entities; +using Tango.MachineStudio.Technician.TechItems; +using Tango.Core; + +namespace Tango.MachineStudio.Technician.Editors +{ + [ContentProperty("InnerContent")] + public partial class MonitorRecorderElementEditor : ElementEditor + { + /// + /// Initializes a new instance of the class. + /// + public MonitorRecorderElementEditor() + : base() + { + InitializeComponent(); + } + + /// + /// Initializes a new instance of the class. + /// + /// The framework element. + public MonitorRecorderElementEditor(MonitorRecorderItem monitorRecorderItem) + : this() + { + MonitorRecorderItem = monitorRecorderItem; + DataContext = MonitorRecorderItem; + } + + /// + /// Initializes a new instance of the class. + /// + /// The framework element. + /// The bounds. + public MonitorRecorderElementEditor(MonitorRecorderItem monitorRecorderItem, Rect bounds) + : this(monitorRecorderItem) + { + Left = bounds.Left; + Top = bounds.Top; + Width = bounds.Width; + Height = bounds.Height; + } + + private MonitorRecorderItem _monitorRecorderItem; + + public MonitorRecorderItem MonitorRecorderItem + { + get { return _monitorRecorderItem; } + set { _monitorRecorderItem = value; RaisePropertyChanged(nameof(MonitorRecorderItem)); } + } + + + /// + /// Clones this instance. + /// + /// + public override IElementEditor Clone() + { + try + { + var clonedItem = MonitorRecorderItem.Clone() as MonitorRecorderItem; + MonitorRecorderElementEditor cloned = new MonitorRecorderElementEditor(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 MonitorRecorderItem; } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/csv.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/csv.png new file mode 100644 index 000000000..5f03ac6bd Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/csv.png differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Models/MultiTechRecordingData.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Models/MultiTechRecordingData.cs index e9471fa74..ad3ea1352 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Models/MultiTechRecordingData.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Models/MultiTechRecordingData.cs @@ -11,11 +11,11 @@ using Tango.MachineStudio.Technician.TechItems; namespace Tango.MachineStudio.Technician.Models { - public class MultiTechRecordingData : TechRecordingData where T : TechItem + public class MultiTechRecordingData : TechRecordingData { public int ChannelCount { get; set; } - public MultiTechRecordingData(T techItem, int channel_count) : base(techItem) + public MultiTechRecordingData(String name, int channel_count, String fileName) : base(name, fileName) { ChannelCount = channel_count; Init(); @@ -54,7 +54,7 @@ namespace Tango.MachineStudio.Technician.Models protected override List GetColumnNames() { - return Enumerable.Range(1, ChannelCount).Select(x => TechItem.TechName + " " + x).ToList(); + return Enumerable.Range(1, ChannelCount).Select(x => Name + " " + x).ToList(); } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Models/SingleTechRecordingData.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Models/SingleTechRecordingData.cs index 7aa9a2b3f..8b480bbf3 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Models/SingleTechRecordingData.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Models/SingleTechRecordingData.cs @@ -7,9 +7,9 @@ using Tango.MachineStudio.Technician.TechItems; namespace Tango.MachineStudio.Technician.Models { - public class SingleTechRecordingData : TechRecordingData where T : TechItem + public class SingleTechRecordingData : TechRecordingData { - public SingleTechRecordingData(T techItem) : base(techItem) + public SingleTechRecordingData(String name, String fileName) : base(name, fileName) { Init(); } @@ -35,7 +35,7 @@ namespace Tango.MachineStudio.Technician.Models protected override List GetColumnNames() { - return new List() { TechItem.TechName }; + return new List() { Name }; } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Models/TechRecordingData.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Models/TechRecordingData.cs index 8024a1375..7b6439dbf 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Models/TechRecordingData.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Models/TechRecordingData.cs @@ -11,7 +11,7 @@ using Tango.MachineStudio.Technician.TechItems; namespace Tango.MachineStudio.Technician.Models { - public abstract class TechRecordingData : ExtendedObject, IDisposable where T : TechItem where TValue : TechRecordingValue + public abstract class TechRecordingData : ExtendedObject, IDisposable where TValue : TechRecordingValue { protected bool _initialized; @@ -20,16 +20,18 @@ namespace Tango.MachineStudio.Technician.Models public CsvFile CsvFile { get; set; } - public TemporaryFile TemporaryFile { get; set; } + public String File { get; set; } - public T TechItem { get; set; } + public String Name { get; set; } - public TechRecordingData(T techItem) + public Object Tag { get; set; } + + public TechRecordingData(String name, String fileName) { + File = fileName; _start_time = DateTime.Now; _last_time = DateTime.Now; - TechItem = techItem; - TemporaryFile = TemporaryManager.CreateFile(".csv"); + Name = name; } protected void Init() @@ -37,20 +39,13 @@ namespace Tango.MachineStudio.Technician.Models CsvDefinition definition = new CsvDefinition(); definition.Columns = new List() { "Time" }.Concat(GetColumnNames()); - CsvFile = new CsvFile(new CsvDestination(TemporaryFile), definition); + CsvFile = new CsvFile(new CsvDestination(File), definition); _initialized = true; } - public void Save(String fileName) - { - CsvFile.Dispose(); - File.Copy(TemporaryFile.Path, fileName, true); - } - public void Dispose() { CsvFile.Dispose(); - TemporaryFile.Delete(); } protected abstract List GetColumnNames(); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorRecorderTemplate.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorRecorderTemplate.xaml new file mode 100644 index 000000000..023191656 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorRecorderTemplate.xaml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorRecorderTemplate.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorRecorderTemplate.xaml.cs new file mode 100644 index 000000000..011e108cb --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorRecorderTemplate.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 MonitorRecorderTemplate : UserControl + { + public MonitorRecorderTemplate() + { + 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 0d9cd5b63..d937ca15b 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 @@ -52,6 +52,15 @@ ..\..\..\packages\MaterialDesignThemes.2.3.1.953\lib\net45\MaterialDesignThemes.Wpf.dll + + ..\..\..\packages\Microsoft.WindowsAPICodePack-Core.1.1.0.0\lib\Microsoft.WindowsAPICodePack.dll + + + ..\..\..\packages\Microsoft.WindowsAPICodePack-Shell.1.1.0.0\lib\Microsoft.WindowsAPICodePack.Shell.dll + + + ..\..\..\packages\Microsoft.WindowsAPICodePack-Shell.1.1.0.0\lib\Microsoft.WindowsAPICodePack.ShellExtensions.dll + @@ -101,6 +110,9 @@ + + MonitorRecorderElementEditor.xaml + HeaterElementEditor.xaml @@ -173,6 +185,9 @@ + + MonitorRecorderTemplate.xaml + HeaterTemplate.xaml @@ -244,6 +259,7 @@ + @@ -268,6 +284,10 @@ MachineTechView.xaml + + MSBuild:Compile + Designer + MSBuild:Compile Designer @@ -352,6 +372,10 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + MSBuild:Compile Designer @@ -658,6 +682,9 @@ + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MonitorRecorderItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MonitorRecorderItem.cs new file mode 100644 index 000000000..e2b62092d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MonitorRecorderItem.cs @@ -0,0 +1,131 @@ +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 System.Windows.Threading; +using System.Xml.Serialization; +using Tango.BL.Entities; +using Tango.Core.Commands; +using Tango.SharedUI.Components; +using Tango.SharedUI.Helpers; + +namespace Tango.MachineStudio.Technician.TechItems +{ + [TechItem(25)] + public class MonitorRecorderItem : TechItem + { + private DispatcherTimer _timer; + private DateTime _recording_start_time; + + public event Action RecordingStarted; + public event Action RecordingStopped; + + /// + /// Gets or sets the monitors. + /// + [XmlIgnore] + public SelectedObjectCollection Monitors { get; set; } + + private bool _isRecording; + /// + /// Gets or sets a value indicating whether this instance is recording. + /// + [XmlIgnore] + public bool IsRecording + { + get { return _isRecording; } + set { _isRecording = value; RaisePropertyChangedAuto(); } + } + + private TimeSpan _recordingTime; + [XmlIgnore] + public TimeSpan RecordingTime + { + get { return _recordingTime; } + set { _recordingTime = value; RaisePropertyChangedAuto(); } + } + + private bool _isPaused; + [XmlIgnore] + public bool IsPaused + { + get { return _isPaused; } + set { _isPaused = value; RaisePropertyChangedAuto(); } + } + + + /// + /// Gets or sets the toggle recording command. + /// + [XmlIgnore] + public RelayCommand ToggleRecordingCommand { get; set; } + + [XmlIgnore] + public RelayCommand TogglePauseCommand { get; set; } + + /// + /// Initializes a new instance of the class. + /// + public MonitorRecorderItem() : base() + { + _timer = new DispatcherTimer(); + _timer.Tick += _timer_Tick; + _timer.Interval = TimeSpan.FromSeconds(1); + + Monitors = new SelectedObjectCollection(Adapter.TechMonitors.ToObservableCollection(), new ObservableCollection()); + Name = "CSV Recorder"; + Description = "Record multiple monitors to a CSV file"; + Image = ResourceHelper.GetImageFromResources("Images/csv.png"); + Color = Colors.White; + + ToggleRecordingCommand = new RelayCommand(ToggleRecording); + TogglePauseCommand = new RelayCommand(() => { IsPaused = !IsPaused; }); + } + + public MonitorRecorderItem(object dummy) : this() + { + + } + + private void _timer_Tick(object sender, EventArgs e) + { + RecordingTime = DateTime.Now - _recording_start_time; + } + + private void ToggleRecording() + { + if (!IsRecording) + { + RecordingStarted?.Invoke(); + } + else + { + RecordingStopped?.Invoke(); + } + } + + public void StartRecording() + { + _recording_start_time = DateTime.Now; + IsRecording = true; + IsPaused = false; + _timer.Start(); + } + + public void StopRecording() + { + _timer.Stop(); + IsPaused = false; + IsRecording = false; + RecordingTime = TimeSpan.FromSeconds(0); + } + + public List GetSelectedMonitors() + { + return Monitors.SynchedSource.ToList(); + } + } +} 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 5a3bd0327..a935ee5a6 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 @@ -191,20 +191,28 @@ namespace Tango.MachineStudio.Technician.TechItems { if (!IsRecording) { - _recording_start_time = DateTime.Now; - IsRecording = true; - _timer.Start(); RecordingStarted?.Invoke(); } else { - _timer.Stop(); - IsRecording = false; - RecordingTime = TimeSpan.FromSeconds(0); RecordingStopped?.Invoke(); } } + public void StartRecording() + { + _recording_start_time = DateTime.Now; + IsRecording = true; + _timer.Start(); + } + + public void StopRecording() + { + _timer.Stop(); + IsRecording = false; + RecordingTime = TimeSpan.FromSeconds(0); + } + /// /// Initializes a new instance of the class. /// diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/SingleGraphItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/SingleGraphItem.cs index aa404b215..87d971233 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/SingleGraphItem.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/SingleGraphItem.cs @@ -184,20 +184,28 @@ namespace Tango.MachineStudio.Technician.TechItems { if (!IsRecording) { - _recording_start_time = DateTime.Now; - IsRecording = true; - _timer.Start(); RecordingStarted?.Invoke(); } else { - _timer.Stop(); - IsRecording = false; - RecordingTime = TimeSpan.FromSeconds(0); RecordingStopped?.Invoke(); } } + public void StartRecording() + { + _recording_start_time = DateTime.Now; + IsRecording = true; + _timer.Start(); + } + + public void StopRecording() + { + _timer.Stop(); + IsRecording = false; + RecordingTime = TimeSpan.FromSeconds(0); + } + /// /// Initializes a new instance of the class. /// 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 0d7568d68..6fa00ae0a 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 @@ -40,6 +40,7 @@ namespace Tango.MachineStudio.Technician.TechItems [XmlInclude(typeof(JobRunnerItem))] [XmlInclude(typeof(TextItem))] [XmlInclude(typeof(HeaterItem))] + [XmlInclude(typeof(MonitorRecorderItem))] public abstract class TechItem : ExtendedObject { /// 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 738e871c9..9051b5fa9 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 @@ -34,6 +34,7 @@ using Tango.Core.Commands; using Tango.MachineStudio.Technician.Helpers; using Tango.MachineStudio.Technician.Models; using Tango.Logging; +using Microsoft.WindowsAPICodePack.Dialogs; namespace Tango.MachineStudio.Technician.ViewModels { @@ -56,8 +57,10 @@ namespace Tango.MachineStudio.Technician.ViewModels private const int MIN_DIAGNOSTICS_UPDATE_MILI = 500; private TechnicianModuleSettings _settings; - private List> _single_graphs_recordings; - private List> _multi_graph_recordings; + private List _single_graphs_recordings; + private List _multi_graph_recordings; + private List _single_monitors_recordings; + private List _multi_monitors_recordings; #region Properties @@ -276,8 +279,11 @@ namespace Tango.MachineStudio.Technician.ViewModels _settings = SettingsManager.Default.GetOrCreate(); - _single_graphs_recordings = new List>(); - _multi_graph_recordings = new List>(); + _single_graphs_recordings = new List(); + _multi_graph_recordings = new List(); + + _single_monitors_recordings = new List(); + _multi_monitors_recordings = new List(); GraphsDurationSeconds = _settings.GraphsDuration; TempGraphsDurationSeconds = GraphsDurationSeconds; @@ -378,6 +384,28 @@ namespace Tango.MachineStudio.Technician.ViewModels } + foreach (var sr in _single_monitors_recordings) + { + var prop = _diagnoticsMonitorsDataProperties.SingleOrDefault(x => x.Name == (sr.Tag as TechMonitor).Name); + + if (prop != null) + { + var points = GetDataArray((sr.Tag as TechMonitor), prop.GetValue(data.Monitors)); + sr.PushData(points); + } + } + + foreach (var mr in _multi_monitors_recordings) + { + var prop = _diagnoticsMonitorsDataProperties.SingleOrDefault(x => x.Name == (mr.Tag as TechMonitor).Name); + + if (prop != null) + { + var points = GetDataMatrix((mr.Tag as TechMonitor), prop.GetValue(data.Monitors)); + mr.PushData(points); + } + } + lock (_elementsLock) { var elements = Tabs.SelectMany(x => x.Elements).ToList(); @@ -435,7 +463,7 @@ namespace Tango.MachineStudio.Technician.ViewModels controller.PushData(points); - var _graph_recording = _single_graphs_recordings.SingleOrDefault(x => x.TechItem == graphItem); + var _graph_recording = _single_graphs_recordings.SingleOrDefault(x => x.Tag == graphItem); if (_graph_recording != null) { _graph_recording.PushData(points); @@ -469,7 +497,7 @@ namespace Tango.MachineStudio.Technician.ViewModels controller.PushData(points); - var _graph_recording = _multi_graph_recordings.SingleOrDefault(x => x.TechItem == graphItem); + var _graph_recording = _multi_graph_recordings.SingleOrDefault(x => x.Tag == graphItem); if (_graph_recording != null) { _graph_recording.PushData(points); @@ -720,6 +748,11 @@ namespace Tango.MachineStudio.Technician.ViewModels { CreateElement(bounds, null); } + else if (item is MonitorRecorderItem) + { + var editor = CreateElement(bounds, null); + InitMonitorRecorderItem(editor.MonitorRecorderItem); + } } /// @@ -869,6 +902,10 @@ namespace Tango.MachineStudio.Technician.ViewModels { CreateElement(item); } + else if (item is MonitorRecorderItem) + { + CreateElement(item); + } } /// @@ -881,20 +918,24 @@ namespace Tango.MachineStudio.Technician.ViewModels { if (element.HostedElement is SingleGraphItem) { - var _graph_recording = _single_graphs_recordings.SingleOrDefault(x => x.TechItem == element.HostedElement); + var _graph_recording = _single_graphs_recordings.SingleOrDefault(x => x.Tag == element.HostedElement); if (_graph_recording != null) { + (_graph_recording.Tag as SingleGraphItem).StopRecording(); _single_graphs_recordings.Remove(_graph_recording); + _graph_recording.Dispose(); } } else if (element.HostedElement is MultiGraphItem) { - var _graph_recording = _multi_graph_recordings.SingleOrDefault(x => x.TechItem == element.HostedElement); + var _graph_recording = _multi_graph_recordings.SingleOrDefault(x => x.Tag == element.HostedElement); if (_graph_recording != null) { + (_graph_recording.Tag as MultiGraphItem).StopRecording(); _multi_graph_recordings.Remove(_graph_recording); + _graph_recording.Dispose(); } } } @@ -981,6 +1022,50 @@ namespace Tango.MachineStudio.Technician.ViewModels #region Init Tech Items + private void InitMonitorRecorderItem(MonitorRecorderItem item) + { + item.RecordingStarted += () => + { + CommonOpenFileDialog dlg = new CommonOpenFileDialog(); + dlg.Title = "Select a folder to place all CSV files."; + dlg.IsFolderPicker = true; + if (dlg.ShowDialog() == CommonFileDialogResult.Ok) + { + foreach (var monitor in item.GetSelectedMonitors()) + { + if (!monitor.MultiChannel) + { + _single_monitors_recordings.Add(new SingleTechRecordingData(monitor.Name, dlg.FileName + "\\" + monitor.Name + ".csv") { Tag = monitor }); + } + else + { + _multi_monitors_recordings.Add(new MultiTechRecordingData(monitor.Name, monitor.ChannelCount, dlg.FileName + "\\" + monitor.Name + ".csv") { Tag = monitor }); + } + item.StartRecording(); + } + } + }; + + item.RecordingStopped += () => + { + item.StopRecording(); + + foreach (var sr in _single_monitors_recordings) + { + sr.Dispose(); + } + + _single_monitors_recordings.Clear(); + + foreach (var mr in _multi_monitors_recordings) + { + mr.Dispose(); + } + + _multi_monitors_recordings.Clear(); + }; + } + /// /// Initializes the blower item. /// @@ -1222,29 +1307,30 @@ namespace Tango.MachineStudio.Technician.ViewModels item.RecordingStarted += () => { - _single_graphs_recordings.Add(new SingleTechRecordingData(item)); + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Title = "Save graph data as csv file"; + dlg.Filter = "CSV Files|*.csv"; + dlg.DefaultExt = ".csv"; + dlg.FileName = item.TechName; + if (dlg.ShowDialog().Value) + { + _single_graphs_recordings.Add(new SingleTechRecordingData(item.TechName, dlg.FileName) { Tag = item }); + item.StartRecording(); + } }; item.RecordingStopped += () => { try { - var graph_recording = _single_graphs_recordings.SingleOrDefault(x => x.TechItem == item); + item.StopRecording(); + + var graph_recording = _single_graphs_recordings.SingleOrDefault(x => x.Tag == item); if (graph_recording != null) { _single_graphs_recordings.Remove(graph_recording); - - SaveFileDialog dlg = new SaveFileDialog(); - dlg.Title = "Save graph data as csv file"; - dlg.Filter = "CSV Files|*.csv"; - dlg.DefaultExt = ".csv"; - dlg.FileName = item.TechName; - if (dlg.ShowDialog().Value) - { - graph_recording.Save(dlg.FileName); - graph_recording.Dispose(); - } + graph_recording.Dispose(); } } catch (Exception ex) @@ -1282,29 +1368,30 @@ namespace Tango.MachineStudio.Technician.ViewModels item.RecordingStarted += () => { - _multi_graph_recordings.Add(new MultiTechRecordingData(item, item.TechMonitor.ChannelCount)); + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Title = "Save graph data as csv file"; + dlg.Filter = "CSV Files|*.csv"; + dlg.DefaultExt = ".csv"; + dlg.FileName = item.TechName; + if (dlg.ShowDialog().Value) + { + _multi_graph_recordings.Add(new MultiTechRecordingData(item.TechName, item.TechMonitor.ChannelCount, dlg.FileName) { Tag = item }); + item.StartRecording(); + } }; item.RecordingStopped += () => { try { - var graph_recording = _multi_graph_recordings.SingleOrDefault(x => x.TechItem == item); + item.StopRecording(); + + var graph_recording = _multi_graph_recordings.SingleOrDefault(x => x.Tag == item); if (graph_recording != null) { _multi_graph_recordings.Remove(graph_recording); - - SaveFileDialog dlg = new SaveFileDialog(); - dlg.Title = "Save graph data as csv file"; - dlg.Filter = "CSV Files|*.csv"; - dlg.DefaultExt = ".csv"; - dlg.FileName = item.TechName; - if (dlg.ShowDialog().Value) - { - graph_recording.Save(dlg.FileName); - graph_recording.Dispose(); - } + graph_recording.Dispose(); } } catch (Exception ex) 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 9e675b2ff..ac207fc55 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 @@ -489,6 +489,9 @@ + + + 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 ea48e62ff..adee6f7b4 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/packages.config +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/packages.config @@ -8,6 +8,8 @@ + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config index 4147a78ec..0395c36bb 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config @@ -87,6 +87,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- cgit v1.3.1