aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-09-26 19:55:00 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-09-26 19:55:00 +0300
commit62aaf350dd5645c3778a0a40ea3ff66280e1bf8c (patch)
treea1403713dd0245772ac99c1c6b86a24042bee130 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician
parentf7c202490ad028ed6d501a4486a339e4e21eb404 (diff)
downloadTango-62aaf350dd5645c3778a0a40ea3ff66280e1bf8c.tar.gz
Tango-62aaf350dd5645c3778a0a40ea3ff66280e1bf8c.zip
Implemented Monitor Recorder element !!!
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorRecorderElementEditor.xaml167
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorRecorderElementEditor.xaml.cs103
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/csv.pngbin0 -> 1650 bytes
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Models/MultiTechRecordingData.cs6
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Models/SingleTechRecordingData.cs6
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Models/TechRecordingData.cs23
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorRecorderTemplate.xaml42
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorRecorderTemplate.xaml.cs28
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj27
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MonitorRecorderItem.cs131
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MultiGraphItem.cs20
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/SingleGraphItem.cs20
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/TechItem.cs1
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs155
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml3
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/packages.config2
16 files changed, 668 insertions, 66 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorRecorderElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorRecorderElementEditor.xaml
new file mode 100644
index 000000000..ce9675103
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorRecorderElementEditor.xaml
@@ -0,0 +1,167 @@
+<local:ElementEditor x:Class="Tango.MachineStudio.Technician.Editors.MonitorRecorderElementEditor"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:sharedConverters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI"
+ xmlns:items="clr-namespace:Tango.MachineStudio.Technician.TechItems"
+ xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
+ 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"
+ mc:Ignorable="d" Background="Transparent" ClipToBounds="False" BorderThickness="0" MinWidth="1" MinHeight="1" RenderTransformOrigin="0.5,0.5" d:DataContext="{d:DesignInstance Type=items:MonitorRecorderItem, IsDesignTimeCreatable=False}" Height="113.188" Width="365.459">
+
+ <UserControl.Resources>
+ <converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"></converters:BoolToVisibilityConverter>
+ <sharedConverters:BooleanInverseConverter x:Key="BooleanInverseConverter" />
+
+ <!--Theme-->
+ <SolidColorBrush x:Key="BorderBrush" Color="Transparent"></SolidColorBrush>
+ <SolidColorBrush x:Key="CornersBrush" Color="Red"></SolidColorBrush>
+ </UserControl.Resources>
+
+ <UserControl.RenderTransform>
+ <RotateTransform Angle="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=Angle}"></RotateTransform>
+ </UserControl.RenderTransform>
+
+ <Grid>
+
+
+ <!--Content-->
+ <Grid>
+ <Viewbox Stretch="Uniform">
+ <Border CornerRadius="5" Background="#151515" BorderThickness="1" BorderBrush="DimGray" Padding="5" Height="113.188" Width="365.459">
+ <Grid>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="27*"/>
+ <RowDefinition Height="47*"/>
+ <RowDefinition Height="27"/>
+ </Grid.RowDefinitions>
+
+ <TextBlock Text="CSV RECORDER" Foreground="#FF8585" FontFamily="digital-7" FontSize="18" VerticalAlignment="Center" Margin="0,6,0,3" Height="18"></TextBlock>
+
+ <DockPanel Grid.Row="1">
+ <Grid>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="47*"/>
+ <ColumnDefinition Width="48*"/>
+ </Grid.ColumnDefinitions>
+
+ <StackPanel Orientation="Horizontal">
+ <Button Command="{Binding ToggleRecordingCommand}" IsEnabled="{Binding IsRecording,Converter={StaticResource BooleanInverseConverter}}" Style="{StaticResource MaterialDesignFlatButton}" Padding="0" Height="Auto" VerticalAlignment="Center">
+ <materialDesign:PackIcon Kind="Record" Width="48" Height="48" Foreground="#FF6767" />
+ </Button>
+ <Button Command="{Binding TogglePauseCommand}" IsEnabled="{Binding IsRecording}" Style="{StaticResource MaterialDesignFlatButton}" Padding="0" Height="Auto" VerticalAlignment="Center">
+ <materialDesign:PackIcon Width="48" Height="48" Foreground="Gainsboro">
+ <materialDesign:PackIcon.Style>
+ <Style TargetType="materialDesign:PackIcon">
+ <Setter Property="Kind" Value="Pause"></Setter>
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding IsPaused}" Value="True">
+ <Setter Property="Kind" Value="Play"></Setter>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </materialDesign:PackIcon.Style>
+ </materialDesign:PackIcon>
+ </Button>
+ <Button Command="{Binding ToggleRecordingCommand}" IsEnabled="{Binding IsRecording}" Style="{StaticResource MaterialDesignFlatButton}" Padding="0" Height="Auto" VerticalAlignment="Center">
+ <materialDesign:PackIcon Kind="Stop" Width="48" Height="48" Foreground="#FFE9A0" />
+ </Button>
+ </StackPanel>
+ </Grid>
+
+ <Grid>
+ <TextBlock HorizontalAlignment="Center" Foreground="#FF6767" VerticalAlignment="Center" FontFamily="digital-7" FontSize="40" Text="{Binding RecordingTime,StringFormat=hh\\:mm\\:ss,TargetNullValue='00:00:00',FallbackValue='00:00:00'}">
+ <TextBlock.Style>
+ <Style TargetType="TextBlock">
+ <Setter Property="Opacity" Value="1"></Setter>
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding IsRecording}" Value="True">
+ <DataTrigger.EnterActions>
+ <BeginStoryboard Name="blink">
+ <Storyboard>
+ <DoubleAnimationUsingKeyFrames RepeatBehavior="Forever" Storyboard.TargetProperty="Opacity" FillBehavior="Stop">
+ <DiscreteDoubleKeyFrame KeyTime="00:00:00" Value="0" />
+ <DiscreteDoubleKeyFrame KeyTime="00:00:0.5" Value="1" />
+ <DiscreteDoubleKeyFrame KeyTime="00:00:1" Value="1" />
+ </DoubleAnimationUsingKeyFrames>
+ </Storyboard>
+ </BeginStoryboard>
+ </DataTrigger.EnterActions>
+ <DataTrigger.ExitActions>
+ <RemoveStoryboard BeginStoryboardName="blink" />
+ </DataTrigger.ExitActions>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </TextBlock.Style>
+ </TextBlock>
+ </Grid>
+ </DockPanel>
+
+ <TextBlock Grid.Row="2" Foreground="Gray" VerticalAlignment="Center" Height="16" Margin="0,2,0,9">
+ <Run Text="{Binding Monitors.SynchedSource.Count,Mode=OneWay}"></Run>
+ <Run>selected monitors to record</Run>
+ </TextBlock>
+ </Grid>
+ </Border>
+ </Viewbox>
+ </Grid>
+ <!--Content-->
+
+
+ <Border BorderThickness="1" BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=BorderBrush,TargetNullValue={StaticResource BorderBrush},FallbackValue={StaticResource BorderBrush}}">
+ <Border.Style>
+ <Style TargetType="Border">
+ <Setter Property="Visibility" Value="Collapsed"></Setter>
+ <Style.Triggers>
+ <MultiDataTrigger>
+ <MultiDataTrigger.Conditions>
+ <Condition Binding="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=(local:ElementsEditor.IsSelected)}" Value="True" />
+ <Condition Binding="{Binding RelativeSource={RelativeSource AncestorType=local:ElementsEditor},Path=IsEditable}" Value="True" />
+ </MultiDataTrigger.Conditions>
+
+ <Setter Property="Visibility" Value="Visible"></Setter>
+ </MultiDataTrigger>
+ </Style.Triggers>
+ </Style>
+ </Border.Style>
+ <Grid>
+ <ContentPresenter Content="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=InnerContent}"></ContentPresenter>
+
+ <Thumb Opacity="0" DragDelta="MoveDrag" DragStarted="DragStarted" DragCompleted="OnDragEnded"></Thumb>
+ <Thumb HorizontalAlignment="Left" Cursor="SizeWE" Opacity="0" DragDelta="DragLeft" DragStarted="DragStarted" DragCompleted="OnDragEnded"></Thumb>
+ <Thumb HorizontalAlignment="Right" Cursor="SizeWE" Opacity="0" DragDelta="DragRight" DragStarted="DragStarted" DragCompleted="OnDragEnded"></Thumb>
+ <Thumb VerticalAlignment="Top" Cursor="SizeNS" Opacity="0" DragDelta="DragTop" DragStarted="DragStarted" DragCompleted="OnDragEnded"></Thumb>
+ <Thumb VerticalAlignment="Bottom" Cursor="SizeNS" Opacity="0" DragDelta="DragBottom" DragStarted="DragStarted" DragCompleted="OnDragEnded"></Thumb>
+
+ <Grid ClipToBounds="False" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0 -20 0 0" Width="10" Height="10">
+ <Ellipse Stroke="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=CornersBrush,TargetNullValue={StaticResource CornersBrush},FallbackValue={StaticResource CornersBrush}}" StrokeThickness="2"></Ellipse>
+ <Rectangle HorizontalAlignment="Center" VerticalAlignment="Stretch" Margin="0 10 0 -8" StrokeThickness="1" Stroke="Red"></Rectangle>
+ <Thumb Opacity="0" DragDelta="DragAngle" DragStarted="DragStarted" Cursor="Arrow" DragCompleted="OnDragEnded"></Thumb>
+ </Grid>
+
+ <Grid Width="10" Height="10" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="-8 -8 0 0">
+ <Border BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=CornersBrush,TargetNullValue={StaticResource CornersBrush},FallbackValue={StaticResource CornersBrush}}" BorderThickness="2 2 0 0"></Border>
+ <Thumb Opacity="0" DragDelta="DragTopLeft" DragStarted="DragStarted" Cursor="SizeNWSE" DragCompleted="OnDragEnded"></Thumb>
+ </Grid>
+
+ <Grid Width="10" Height="10" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0 -8 -8 0">
+ <Border BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=CornersBrush,TargetNullValue={StaticResource CornersBrush},FallbackValue={StaticResource CornersBrush}}" BorderThickness="0 2 2 0"></Border>
+ <Thumb Opacity="0" DragDelta="DragTopRight" DragStarted="DragStarted" Cursor="SizeNESW" DragCompleted="OnDragEnded"></Thumb>
+ </Grid>
+
+ <Grid Width="10" Height="10" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0 0 -8 -8">
+ <Border BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=CornersBrush,TargetNullValue={StaticResource CornersBrush},FallbackValue={StaticResource CornersBrush}}" BorderThickness="0 0 2 2"></Border>
+ <Thumb Opacity="0" DragDelta="DragBottomRight" DragStarted="DragStarted" Cursor="SizeNWSE" DragCompleted="OnDragEnded"></Thumb>
+ </Grid>
+
+ <Grid Width="10" Height="10" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="-8 0 0 -8">
+ <Border BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=CornersBrush,TargetNullValue={StaticResource CornersBrush},FallbackValue={StaticResource CornersBrush}}" BorderThickness="2 0 0 2"></Border>
+ <Thumb Opacity="0" DragDelta="DragBottomLeft" DragStarted="DragStarted" Cursor="SizeNESW" DragCompleted="OnDragEnded"></Thumb>
+ </Grid>
+ </Grid>
+ </Border>
+ </Grid>
+</local:ElementEditor>
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/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
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="MonitorRecorderItem"/> class.
+ /// </summary>
+ public MonitorRecorderElementEditor()
+ : base()
+ {
+ InitializeComponent();
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="MonitorRecorderItem"/> class.
+ /// </summary>
+ /// <param name="frameworkElement">The framework element.</param>
+ public MonitorRecorderElementEditor(MonitorRecorderItem monitorRecorderItem)
+ : this()
+ {
+ MonitorRecorderItem = monitorRecorderItem;
+ DataContext = MonitorRecorderItem;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="MonitorRecorderItem"/> class.
+ /// </summary>
+ /// <param name="frameworkElement">The framework element.</param>
+ /// <param name="bounds">The bounds.</param>
+ 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)); }
+ }
+
+
+ /// <summary>
+ /// Clones this instance.
+ /// </summary>
+ /// <returns></returns>
+ 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);
+ }
+ }
+
+ /// <summary>
+ /// Gets the hosted element.
+ /// </summary>
+ [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
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/csv.png
Binary files 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<T> : TechRecordingData<T, MultiTechRecordingValue> where T : TechItem
+ public class MultiTechRecordingData : TechRecordingData<MultiTechRecordingValue>
{
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<string> 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<T> : TechRecordingData<T, SingleTechRecordingValue> where T : TechItem
+ public class SingleTechRecordingData : TechRecordingData<SingleTechRecordingValue>
{
- 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<string> GetColumnNames()
{
- return new List<string>() { TechItem.TechName };
+ return new List<string>() { 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<T, TValue> : ExtendedObject, IDisposable where T : TechItem where TValue : TechRecordingValue
+ public abstract class TechRecordingData<TValue> : ExtendedObject, IDisposable where TValue : TechRecordingValue
{
protected bool _initialized;
@@ -20,16 +20,18 @@ namespace Tango.MachineStudio.Technician.Models
public CsvFile<TValue> 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<String>() { "Time" }.Concat(GetColumnNames());
- CsvFile = new CsvFile<TValue>(new CsvDestination(TemporaryFile), definition);
+ CsvFile = new CsvFile<TValue>(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<String> 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 @@
+<UserControl x:Class="Tango.MachineStudio.Technician.PropertiesTemplates.MonitorRecorderTemplate"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:converters="clr-namespace:Tango.MachineStudio.Technician.Converters"
+ xmlns:sharedConverters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI"
+ xmlns:items="clr-namespace:Tango.MachineStudio.Technician.TechItems"
+ xmlns:editors="clr-namespace:Tango.SharedUI.Editors;assembly=Tango.SharedUI"
+ 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="500" d:DesignWidth="200" d:DataContext="{d:DesignInstance Type=items:MonitorRecorderItem, IsDesignTimeCreatable=False}">
+
+ <UserControl.Resources>
+ <sharedConverters:DoubleToIntConverter x:Key="DoubleToIntConverter" />
+ <sharedConverters:BooleanInverseConverter x:Key="BooleanInverseConverter" />
+
+ <Style TargetType="{x:Type TabItem}" BasedOn="{StaticResource {x:Type TabItem}}">
+ <Setter Property="mahApps:ControlsHelper.HeaderFontSize" Value="14" />
+ <Setter Property="Margin" Value="2" />
+ </Style>
+ </UserControl.Resources>
+
+ <Grid>
+ <StackPanel>
+ <GroupBox Header="Selected Monitors" IsEnabled="{Binding IsRecording,Converter={StaticResource BooleanInverseConverter}}">
+ <ItemsControl ItemsSource="{Binding Monitors}">
+ <ItemsControl.ItemTemplate>
+ <DataTemplate>
+ <StackPanel Orientation="Horizontal">
+ <CheckBox IsChecked="{Binding IsSelected}" VerticalAlignment="Center" />
+ <TextBlock Text="{Binding Data.Description}" VerticalAlignment="Center"></TextBlock>
+ </StackPanel>
+ </DataTemplate>
+ </ItemsControl.ItemTemplate>
+ </ItemsControl>
+ </GroupBox>
+ </StackPanel>
+ </Grid>
+</UserControl>
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
+{
+ /// <summary>
+ /// Interaction logic for MonitorTemplate.xaml
+ /// </summary>
+ 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 @@
<Reference Include="MaterialDesignThemes.Wpf, Version=2.3.1.953, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\MaterialDesignThemes.2.3.1.953\lib\net45\MaterialDesignThemes.Wpf.dll</HintPath>
</Reference>
+ <Reference Include="Microsoft.WindowsAPICodePack, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <HintPath>..\..\..\packages\Microsoft.WindowsAPICodePack-Core.1.1.0.0\lib\Microsoft.WindowsAPICodePack.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.WindowsAPICodePack.Shell, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <HintPath>..\..\..\packages\Microsoft.WindowsAPICodePack-Shell.1.1.0.0\lib\Microsoft.WindowsAPICodePack.Shell.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.WindowsAPICodePack.ShellExtensions, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <HintPath>..\..\..\packages\Microsoft.WindowsAPICodePack-Shell.1.1.0.0\lib\Microsoft.WindowsAPICodePack.ShellExtensions.dll</HintPath>
+ </Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Data" />
@@ -101,6 +110,9 @@
<Compile Include="Converters\TechIosToDigitalInsConverter.cs" />
<Compile Include="Converters\TechIosToDigitalOutsConverter.cs" />
<Compile Include="Converters\TransitionLinkConverter.cs" />
+ <Compile Include="Editors\MonitorRecorderElementEditor.xaml.cs">
+ <DependentUpon>MonitorRecorderElementEditor.xaml</DependentUpon>
+ </Compile>
<Compile Include="Editors\HeaterElementEditor.xaml.cs">
<DependentUpon>HeaterElementEditor.xaml</DependentUpon>
</Compile>
@@ -173,6 +185,9 @@
<Compile Include="Models\TechRecordingValue.cs" />
<Compile Include="Project\MachineTechViewProject.cs" />
<Compile Include="Project\MachineTechViewProjectTab.cs" />
+ <Compile Include="PropertiesTemplates\MonitorRecorderTemplate.xaml.cs">
+ <DependentUpon>MonitorRecorderTemplate.xaml</DependentUpon>
+ </Compile>
<Compile Include="PropertiesTemplates\HeaterTemplate.xaml.cs">
<DependentUpon>HeaterTemplate.xaml</DependentUpon>
</Compile>
@@ -244,6 +259,7 @@
<Compile Include="TechItems\HeaterItem.cs" />
<Compile Include="TechItems\JobRunnerItem.cs" />
<Compile Include="TechItems\MeterItem.cs" />
+ <Compile Include="TechItems\MonitorRecorderItem.cs" />
<Compile Include="TechItems\MotorActionType.cs" />
<Compile Include="TechItems\DispenserItem.cs" />
<Compile Include="TechItems\DancerItem.cs" />
@@ -268,6 +284,10 @@
<Compile Include="Views\MachineTechView.xaml.cs">
<DependentUpon>MachineTechView.xaml</DependentUpon>
</Compile>
+ <Page Include="Editors\MonitorRecorderElementEditor.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </Page>
<Page Include="Editors\HeaterElementEditor.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@@ -352,6 +372,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
+ <Page Include="PropertiesTemplates\MonitorRecorderTemplate.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </Page>
<Page Include="PropertiesTemplates\HeaterTemplate.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@@ -658,6 +682,9 @@
<ItemGroup>
<Resource Include="Images\temperature.png" />
</ItemGroup>
+ <ItemGroup>
+ <Resource Include="Images\csv.png" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
<VisualStudio>
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;
+
+ /// <summary>
+ /// Gets or sets the monitors.
+ /// </summary>
+ [XmlIgnore]
+ public SelectedObjectCollection<TechMonitor> Monitors { get; set; }
+
+ private bool _isRecording;
+ /// <summary>
+ /// Gets or sets a value indicating whether this instance is recording.
+ /// </summary>
+ [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(); }
+ }
+
+
+ /// <summary>
+ /// Gets or sets the toggle recording command.
+ /// </summary>
+ [XmlIgnore]
+ public RelayCommand ToggleRecordingCommand { get; set; }
+
+ [XmlIgnore]
+ public RelayCommand TogglePauseCommand { get; set; }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="MonitorRecorderItem"/> class.
+ /// </summary>
+ public MonitorRecorderItem() : base()
+ {
+ _timer = new DispatcherTimer();
+ _timer.Tick += _timer_Tick;
+ _timer.Interval = TimeSpan.FromSeconds(1);
+
+ Monitors = new SelectedObjectCollection<TechMonitor>(Adapter.TechMonitors.ToObservableCollection(), new ObservableCollection<TechMonitor>());
+ 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<TechMonitor> 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);
+ }
+
/// <summary>
/// Initializes a new instance of the <see cref="MultiGraphItem"/> class.
/// </summary>
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);
+ }
+
/// <summary>
/// Initializes a new instance of the <see cref="SingleGraphItem"/> class.
/// </summary>
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
{
/// <summary>
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<SingleTechRecordingData<SingleGraphItem>> _single_graphs_recordings;
- private List<MultiTechRecordingData<MultiGraphItem>> _multi_graph_recordings;
+ private List<SingleTechRecordingData> _single_graphs_recordings;
+ private List<MultiTechRecordingData> _multi_graph_recordings;
+ private List<SingleTechRecordingData> _single_monitors_recordings;
+ private List<MultiTechRecordingData> _multi_monitors_recordings;
#region Properties
@@ -276,8 +279,11 @@ namespace Tango.MachineStudio.Technician.ViewModels
_settings = SettingsManager.Default.GetOrCreate<TechnicianModuleSettings>();
- _single_graphs_recordings = new List<SingleTechRecordingData<SingleGraphItem>>();
- _multi_graph_recordings = new List<MultiTechRecordingData<MultiGraphItem>>();
+ _single_graphs_recordings = new List<SingleTechRecordingData>();
+ _multi_graph_recordings = new List<MultiTechRecordingData>();
+
+ _single_monitors_recordings = new List<SingleTechRecordingData>();
+ _multi_monitors_recordings = new List<MultiTechRecordingData>();
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<TextElementEditor, TextItem, object>(bounds, null);
}
+ else if (item is MonitorRecorderItem)
+ {
+ var editor = CreateElement<MonitorRecorderElementEditor, MonitorRecorderItem, object>(bounds, null);
+ InitMonitorRecorderItem(editor.MonitorRecorderItem);
+ }
}
/// <summary>
@@ -869,6 +902,10 @@ namespace Tango.MachineStudio.Technician.ViewModels
{
CreateElement<TextElementEditor>(item);
}
+ else if (item is MonitorRecorderItem)
+ {
+ CreateElement<MonitorRecorderElementEditor>(item);
+ }
}
/// <summary>
@@ -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();
+ };
+ }
+
/// <summary>
/// Initializes the blower item.
/// </summary>
@@ -1222,29 +1307,30 @@ namespace Tango.MachineStudio.Technician.ViewModels
item.RecordingStarted += () =>
{
- _single_graphs_recordings.Add(new SingleTechRecordingData<SingleGraphItem>(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<MultiGraphItem>(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
@@ -490,6 +490,9 @@
<DataTemplate DataType="{x:Type sys:Nullable}">
</DataTemplate>
+ <DataTemplate DataType="{x:Type items:MonitorRecorderItem}">
+ <templates:MonitorRecorderTemplate/>
+ </DataTemplate>
<DataTemplate DataType="{x:Type items:HeaterItem}">
<templates:HeaterTemplate/>
</DataTemplate>
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 @@
<package id="MahApps.Metro" version="1.5.0" targetFramework="net46" />
<package id="MaterialDesignColors" version="1.1.2" targetFramework="net46" />
<package id="MaterialDesignThemes" version="2.3.1.953" targetFramework="net46" />
+ <package id="Microsoft.WindowsAPICodePack-Core" version="1.1.0.0" targetFramework="net472" />
+ <package id="Microsoft.WindowsAPICodePack-Shell" version="1.1.0.0" targetFramework="net472" />
<package id="System.Reactive" version="3.1.1" targetFramework="net46" />
<package id="System.Reactive.Core" version="3.1.1" targetFramework="net46" />
<package id="System.Reactive.Interfaces" version="3.1.1" targetFramework="net46" />