aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorElementEditor.xaml267
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorElementEditor.xaml.cs186
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/SingleGraphElementEditor.xaml2
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/engine.pngbin0 -> 800 bytes
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/prop.pngbin0 -> 30883 bytes
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj15
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorActionType.cs18
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorItem.cs117
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs170
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml29
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml.cs22
11 files changed, 799 insertions, 27 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorElementEditor.xaml
new file mode 100644
index 000000000..bf7aaeff4
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorElementEditor.xaml
@@ -0,0 +1,267 @@
+<local:ElementEditor x:Class="Tango.MachineStudio.Technician.Editors.MotorElementEditor"
+ 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:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
+ xmlns:items="clr-namespace:Tango.MachineStudio.Technician.TechItems"
+ xmlns:converters="clr-namespace:Tango.Editors.Converters;assembly=Tango.Editors"
+ xmlns:visuals="clr-namespace:Tango.Visuals;assembly=Tango.Visuals"
+ xmlns:local="clr-namespace:Tango.Editors;assembly=Tango.Editors"
+ mc:Ignorable="d"
+ d:DesignHeight="164.393" d:DesignWidth="224.65" Background="Transparent" ClipToBounds="False" BorderThickness="0" MinWidth="1" MinHeight="1" RenderTransformOrigin="0.5,0.5" d:DataContext="{d:DesignInstance Type=items:MotorItem, IsDesignTimeCreatable=False}">
+
+ <UserControl.Resources>
+ <converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"></converters:BoolToVisibilityConverter>
+
+ <!--Theme-->
+ <SolidColorBrush x:Key="BorderBrush" Color="Transparent"></SolidColorBrush>
+ <SolidColorBrush x:Key="CornersBrush" Color="Red"></SolidColorBrush>
+
+ <Grid x:Key="gridHoming">
+ <DockPanel>
+ <Button Click="OnHomingStopped" DockPanel.Dock="Right" Padding="0" Style="{StaticResource emptyButton}" VerticalAlignment="Center" Margin="0 0 5 0">
+ <materialDesign:PackIcon Kind="Stop" Foreground="#FF5F5F" HorizontalAlignment="Center" VerticalAlignment="Center" Width="24" Height="24" />
+ </Button>
+ <ProgressBar Maximum="{Binding HomingMaximumProgress}" Value="{Binding HomingProgress}" VerticalAlignment="Center" Height="10" Margin="5 0 5 0" Background="Transparent"></ProgressBar>
+ </DockPanel>
+ </Grid>
+
+ <Grid x:Key="gridDefault">
+ <Viewbox Stretch="Fill">
+ <materialDesign:PackIcon Kind="Home" Margin="25 0" HorizontalAlignment="Center" VerticalAlignment="Center" Width="24" Height="24" Foreground="#202020" />
+ </Viewbox>
+
+ <Button Click="OnHomingStarted" Style="{StaticResource emptyButton}" Background="Transparent" BorderThickness="0"></Button>
+ </Grid>
+ </UserControl.Resources>
+
+ <UserControl.RenderTransform>
+ <RotateTransform Angle="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=Angle}"></RotateTransform>
+ </UserControl.RenderTransform>
+
+ <Grid>
+
+ <Grid Margin="5">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="20*"/>
+ <ColumnDefinition Width="100*"/>
+ <ColumnDefinition Width="20*"/>
+ </Grid.ColumnDefinitions>
+
+ <Grid.RowDefinitions>
+ <RowDefinition Height="100*" />
+ <RowDefinition Height="30*" />
+ </Grid.RowDefinitions>
+
+ <Grid Grid.Column="1">
+ <Border BorderThickness="1" BorderBrush="Gainsboro" CornerRadius="5">
+ <Border.Background>
+ <ImageBrush ImageSource="../Images/black-screen.jpg" Opacity="0.1" />
+ </Border.Background>
+
+ <Image RenderTransformOrigin="0.5,0.5" Margin="5" Source="../Images/prop.png" RenderOptions.BitmapScalingMode="Fant">
+ <Image.RenderTransform>
+ <RotateTransform x:Name="propRotate" Angle="0" />
+ </Image.RenderTransform>
+ </Image>
+ </Border>
+ </Grid>
+
+ <Grid>
+ <Border BorderBrush="Gainsboro" BorderThickness="1 1 0 1" Margin="0 10" CornerRadius="5 0 0 5" PreviewMouseDown="OnBackwardPressed" PreviewMouseUp="OnBackwardReleased">
+ <Border.Style>
+ <Style TargetType="Border">
+ <Setter Property="Background">
+ <Setter.Value>
+ <LinearGradientBrush EndPoint="1,0">
+ <GradientStop Color="#515151" Offset="1" />
+ <GradientStop Color="#FFEEEEEE" Offset="0"/>
+ </LinearGradientBrush>
+ </Setter.Value>
+ </Setter>
+ <Style.Triggers>
+ <EventTrigger RoutedEvent="PreviewMouseDown">
+ <EventTrigger.Actions>
+ <BeginStoryboard>
+ <Storyboard>
+ <ColorAnimation Storyboard.TargetProperty="Background.GradientStops[1].Color" To="#FFCECECE" Duration="00:00:0.1" />
+ </Storyboard>
+ </BeginStoryboard>
+ </EventTrigger.Actions>
+ </EventTrigger>
+ <EventTrigger RoutedEvent="PreviewMouseUp">
+ <EventTrigger.Actions>
+ <BeginStoryboard>
+ <Storyboard>
+ <ColorAnimation Storyboard.TargetProperty="Background.GradientStops[1].Color" To="#FFEEEEEE" Duration="00:00:0.1" />
+ </Storyboard>
+ </BeginStoryboard>
+ </EventTrigger.Actions>
+ </EventTrigger>
+ </Style.Triggers>
+ </Style>
+ </Border.Style>
+
+ <Viewbox Stretch="Fill" Margin="-10 10">
+ <materialDesign:PackIcon Kind="ChevronLeft" HorizontalAlignment="Center" VerticalAlignment="Center" Width="24" Height="24" Foreground="#202020" />
+ </Viewbox>
+ </Border>
+ </Grid>
+
+ <Grid Grid.Column="2">
+ <Border BorderBrush="Gainsboro" BorderThickness="0 1 1 1" Margin="0 10" CornerRadius="0 10 10 0" PreviewMouseDown="OnForwardPressed" PreviewMouseUp="OnForwardReleased">
+ <Border.Style>
+ <Style TargetType="Border">
+ <Setter Property="Background">
+ <Setter.Value>
+ <LinearGradientBrush EndPoint="1,0">
+ <GradientStop Color="#515151" Offset="0" />
+ <GradientStop Color="#FFEEEEEE" Offset="1"/>
+ </LinearGradientBrush>
+ </Setter.Value>
+ </Setter>
+ <Style.Triggers>
+ <EventTrigger RoutedEvent="PreviewMouseDown">
+ <EventTrigger.Actions>
+ <BeginStoryboard>
+ <Storyboard>
+ <ColorAnimation Storyboard.TargetProperty="Background.GradientStops[1].Color" To="#FFCECECE" Duration="00:00:0.1" />
+ </Storyboard>
+ </BeginStoryboard>
+ </EventTrigger.Actions>
+ </EventTrigger>
+ <EventTrigger RoutedEvent="PreviewMouseUp">
+ <EventTrigger.Actions>
+ <BeginStoryboard>
+ <Storyboard>
+ <ColorAnimation Storyboard.TargetProperty="Background.GradientStops[1].Color" To="#FFEEEEEE" Duration="00:00:0.1" />
+ </Storyboard>
+ </BeginStoryboard>
+ </EventTrigger.Actions>
+ </EventTrigger>
+ </Style.Triggers>
+ </Style>
+ </Border.Style>
+
+ <Viewbox Stretch="Fill" Margin="-10 10">
+ <materialDesign:PackIcon Kind="ChevronRight" HorizontalAlignment="Center" VerticalAlignment="Center" Width="24" Height="24" Foreground="#202020" />
+ </Viewbox>
+ </Border>
+ </Grid>
+
+ <Grid Grid.Column="1" Grid.Row="1">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="20*"/>
+ <ColumnDefinition Width="115*"/>
+ <ColumnDefinition Width="20*"/>
+ </Grid.ColumnDefinitions>
+
+ <Grid Grid.Column="1">
+ <Border BorderBrush="Gainsboro" BorderThickness="1 0 1 1" CornerRadius="0 0 10 10">
+ <Border.Style>
+ <Style TargetType="Border">
+ <Setter Property="Background">
+ <Setter.Value>
+ <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
+ <GradientStop Color="#515151" Offset="1" />
+ <GradientStop Color="#FFEEEEEE" Offset="0"/>
+ </LinearGradientBrush>
+ </Setter.Value>
+ </Setter>
+ <Style.Triggers>
+ <EventTrigger RoutedEvent="PreviewMouseDown">
+ <EventTrigger.Actions>
+ <BeginStoryboard>
+ <Storyboard>
+ <ColorAnimation Storyboard.TargetProperty="Background.GradientStops[1].Color" To="#FFCECECE" Duration="00:00:0.1" />
+ </Storyboard>
+ </BeginStoryboard>
+ </EventTrigger.Actions>
+ </EventTrigger>
+ <EventTrigger RoutedEvent="PreviewMouseUp">
+ <EventTrigger.Actions>
+ <BeginStoryboard>
+ <Storyboard>
+ <ColorAnimation Storyboard.TargetProperty="Background.GradientStops[1].Color" To="#FFEEEEEE" Duration="00:00:0.1" />
+ </Storyboard>
+ </BeginStoryboard>
+ </EventTrigger.Actions>
+ </EventTrigger>
+ </Style.Triggers>
+ </Style>
+ </Border.Style>
+
+ <Grid>
+ <ContentControl>
+ <ContentControl.Style>
+ <Style TargetType="ContentControl">
+ <Setter Property="Content" Value="{StaticResource gridDefault}">
+
+ </Setter>
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding IsHoming}" Value="True">
+ <Setter Property="Content" Value="{StaticResource gridHoming}">
+ </Setter>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </ContentControl.Style>
+
+ </ContentControl>
+ </Grid>
+ </Border>
+ </Grid>
+ </Grid>
+
+
+ </Grid>
+
+ <!--Content-->
+ <Grid>
+ <Border Margin="0 0 0 -23" VerticalAlignment="Bottom">
+ <TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=MonitorItem.TechMonitor.Description}" FontSize="14" Foreground="DimGray" HorizontalAlignment="Center"></TextBlock>
+ </Border>
+ </Grid>
+ <!--Content-->
+
+
+ <Border BorderThickness="1" BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=BorderBrush,TargetNullValue={StaticResource BorderBrush},FallbackValue={StaticResource BorderBrush}}" Visibility="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=(local:ElementsEditor.IsSelected),Converter={StaticResource BoolToVisibilityConverter}}">
+ <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/MotorElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorElementEditor.xaml.cs
new file mode 100644
index 000000000..6371cb83a
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorElementEditor.xaml.cs
@@ -0,0 +1,186 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Markup;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+using Tango.Editors;
+using Tango.Integration.Observables;
+using Tango.MachineStudio.Technician.TechItems;
+
+namespace Tango.MachineStudio.Technician.Editors
+{
+ [ContentProperty("InnerContent")]
+ public partial class MotorElementEditor : ElementEditor
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="MonitorElementEditor"/> class.
+ /// </summary>
+ public MotorElementEditor()
+ : base()
+ {
+ InitializeComponent();
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="MonitorElementEditor"/> class.
+ /// </summary>
+ /// <param name="frameworkElement">The framework element.</param>
+ public MotorElementEditor(MotorItem motorItem)
+ : this()
+ {
+ MotorItem = motorItem;
+ DataContext = MotorItem;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="MonitorElementEditor"/> class.
+ /// </summary>
+ /// <param name="frameworkElement">The framework element.</param>
+ /// <param name="bounds">The bounds.</param>
+ public MotorElementEditor(MotorItem monitorItem, Rect bounds)
+ : this(monitorItem)
+ {
+ Left = bounds.Left;
+ Top = bounds.Top;
+ Width = bounds.Width;
+ Height = bounds.Height;
+ }
+
+ private MotorItem _monitorItem;
+
+ public MotorItem MotorItem
+ {
+ get { return _monitorItem; }
+ set
+ {
+ _monitorItem = value; RaisePropertyChanged(nameof(MotorItem));
+
+ if (_monitorItem != null)
+ {
+ _monitorItem.HomingCompleted -= _monitorItem_HomingCompleted;
+ _monitorItem.HomingCompleted += _monitorItem_HomingCompleted;
+ }
+ }
+ }
+
+ private void _monitorItem_HomingCompleted(object sender, EventArgs e)
+ {
+ StopAnimation();
+ }
+
+
+ /// <summary>
+ /// Clones this instance.
+ /// </summary>
+ /// <returns></returns>
+ public override IElementEditor Clone()
+ {
+ try
+ {
+ var clonedItem = MotorItem.Clone() as MotorItem;
+ MotorElementEditor cloned = new MotorElementEditor(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 MotorItem; }
+ }
+
+ private void OnForwardPressed(object sender, MouseButtonEventArgs e)
+ {
+ MotorItem.RaiseAction(MotorActionType.ForwardPressed);
+ AnimateRight();
+ }
+
+ private void OnForwardReleased(object sender, MouseButtonEventArgs e)
+ {
+ MotorItem.RaiseAction(MotorActionType.ForwardReleased);
+ StopAnimation();
+ }
+
+ private void OnBackwardPressed(object sender, MouseButtonEventArgs e)
+ {
+ MotorItem.RaiseAction(MotorActionType.BackwardPressed);
+ AnimateLeft();
+ }
+
+ private void OnBackwardReleased(object sender, MouseButtonEventArgs e)
+ {
+ MotorItem.RaiseAction(MotorActionType.BackwardReleased);
+ StopAnimation();
+ }
+
+ private void OnHomingStarted(object sender, RoutedEventArgs e)
+ {
+ MotorItem.RaiseAction(MotorActionType.HomingStarted);
+ AnimateLeft();
+ }
+
+ private void OnHomingStopped(object sender, RoutedEventArgs e)
+ {
+ MotorItem.RaiseAction(MotorActionType.HomingStopped);
+ StopAnimation();
+ }
+
+ private void AnimateRight()
+ {
+ DoubleAnimation ani = new DoubleAnimation();
+ ani.Duration = TimeSpan.FromSeconds(1);
+ ani.RepeatBehavior = RepeatBehavior.Forever;
+ ani.FillBehavior = FillBehavior.HoldEnd;
+ ani.To = 360;
+ propRotate.BeginAnimation(RotateTransform.AngleProperty, ani);
+ }
+
+ private void AnimateLeft()
+ {
+ DoubleAnimation ani = new DoubleAnimation();
+ ani.Duration = TimeSpan.FromSeconds(1);
+ ani.RepeatBehavior = RepeatBehavior.Forever;
+ ani.FillBehavior = FillBehavior.HoldEnd;
+ ani.To = -360;
+ propRotate.BeginAnimation(RotateTransform.AngleProperty, ani);
+ }
+
+ public void StopAnimation()
+ {
+ this.Dispatcher.Invoke(() =>
+ {
+ propRotate.BeginAnimation(RotateTransform.AngleProperty, null);
+ });
+ }
+
+ private void Button_Click(object sender, RoutedEventArgs e)
+ {
+
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/SingleGraphElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/SingleGraphElementEditor.xaml
index 02acf5883..aa0ec24e8 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/SingleGraphElementEditor.xaml
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/SingleGraphElementEditor.xaml
@@ -28,7 +28,7 @@
<!--Content-->
<Grid>
<!--<Viewbox Stretch="Fill">-->
- <controls:RealTimeGraphControl x:Name="InnerGraph" x:FieldModifier="public" IsHitTestVisible="False" EnableToolBar="False" SensorName="{Binding TechMonitor.Description}" Color="{Binding Color,Mode=TwoWay}" SensorUnits="{Binding TechMonitor.Units}" Minimum="{Binding TechMonitor.Min}" Maximum="{Binding TechMonitor.Max}" />
+ <controls:RealTimeGraphControl x:Name="InnerGraph" x:FieldModifier="public" EnableToolBar="False" SensorName="{Binding TechMonitor.Description}" Color="{Binding Color,Mode=TwoWay}" SensorUnits="{Binding TechMonitor.Units}" Minimum="{Binding TechMonitor.Min}" Maximum="{Binding TechMonitor.Max}" />
<!--</Viewbox>-->
<Border Margin="0 0 0 -23" VerticalAlignment="Bottom">
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/engine.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/engine.png
new file mode 100644
index 000000000..731ddc4f6
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/engine.png
Binary files differ
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/prop.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/prop.png
new file mode 100644
index 000000000..268c1e557
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/prop.png
Binary files differ
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 654c6b9c1..0f92b6275 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj
@@ -81,6 +81,9 @@
<Compile Include="Converters\MonitorsToSingleChannleMonitorsConverter.cs" />
<Compile Include="Converters\SecondsToGraphPointsConverter.cs" />
<Compile Include="Converters\TransitionLinkConverter.cs" />
+ <Compile Include="Editors\MotorElementEditor.xaml.cs">
+ <DependentUpon>MotorElementEditor.xaml</DependentUpon>
+ </Compile>
<Compile Include="Editors\MeterElementEditor.xaml.cs">
<DependentUpon>MeterElementEditor.xaml</DependentUpon>
</Compile>
@@ -107,6 +110,8 @@
<DependentUpon>SingleGraphTemplate.xaml</DependentUpon>
</Compile>
<Compile Include="TechItems\MeterItem.cs" />
+ <Compile Include="TechItems\MotorActionType.cs" />
+ <Compile Include="TechItems\MotorItem.cs" />
<Compile Include="TechItems\MultiGraphItem.cs" />
<Compile Include="TechItems\SingleGraphItem.cs" />
<Compile Include="TechItems\MonitorItem.cs" />
@@ -136,6 +141,10 @@
<Compile Include="..\..\..\Versioning\GlobalVersionInfo.cs">
<Link>GlobalVersionInfo.cs</Link>
</Compile>
+ <Page Include="Editors\MotorElementEditor.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </Page>
<Page Include="Editors\MeterElementEditor.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@@ -296,5 +305,11 @@
<ItemGroup>
<Resource Include="Images\multi-graph.png" />
</ItemGroup>
+ <ItemGroup>
+ <Resource Include="Images\prop.png" />
+ </ItemGroup>
+ <ItemGroup>
+ <Resource Include="Images\engine.png" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> \ No newline at end of file
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorActionType.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorActionType.cs
new file mode 100644
index 000000000..319345926
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorActionType.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.MachineStudio.Technician.TechItems
+{
+ public enum MotorActionType
+ {
+ ForwardPressed,
+ ForwardReleased,
+ BackwardPressed,
+ BackwardReleased,
+ HomingStarted,
+ HomingStopped,
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorItem.cs
new file mode 100644
index 000000000..a7088ac3f
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorItem.cs
@@ -0,0 +1,117 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Serialization;
+using Tango.Core.Commands;
+using Tango.Integration.Observables;
+using Tango.SharedUI.Helpers;
+
+namespace Tango.MachineStudio.Technician.TechItems
+{
+ public class MotorItem : TechItem
+ {
+ public event EventHandler<MotorActionType> ActionExecuted;
+ public event EventHandler HomingCompleted;
+
+ private TechMotor _techMotor;
+ [XmlIgnore]
+ public TechMotor TechMotor
+ {
+ get { return _techMotor; }
+ set { _techMotor = value; RaisePropertyChangedAuto(); RaisePropertyChanged(nameof(Data)); }
+ }
+
+ private bool _isHoming;
+ [XmlIgnore]
+ public bool IsHoming
+ {
+ get { return _isHoming; }
+ set
+ {
+ _isHoming = value;
+ RaisePropertyChangedAuto();
+ }
+ }
+
+ private bool _isHomingCompleted;
+
+ public bool IsHomingCompleted
+ {
+ get { return _isHomingCompleted; }
+ set
+ {
+ _isHomingCompleted = value;
+ RaisePropertyChangedAuto();
+
+ if (value)
+ {
+ HomingCompleted?.Invoke(this, new EventArgs());
+ }
+ }
+ }
+
+ private double _homingProgress;
+ [XmlIgnore]
+ public double HomingProgress
+ {
+ get { return _homingProgress; }
+ set
+ {
+ _homingProgress = value;
+ RaisePropertyChangedAuto();
+ }
+ }
+
+ private double _homingMaximumProgress;
+ [XmlIgnore]
+ public double HomingMaximumProgress
+ {
+ get { return _homingMaximumProgress; }
+ set { _homingMaximumProgress = value; RaisePropertyChangedAuto(); }
+ }
+
+ private bool _isForwardPressed;
+ [XmlIgnore]
+ public bool IsForwardPressed
+ {
+ get { return _isForwardPressed; }
+ set { _isForwardPressed = value; RaisePropertyChangedAuto(); }
+ }
+
+ private bool _isBackwardPressed;
+ [XmlIgnore]
+ public bool IsBackwardPressed
+ {
+ get { return _isBackwardPressed; }
+ set { _isBackwardPressed = value; RaisePropertyChangedAuto(); }
+ }
+
+ public override object Data => TechMotor;
+
+ public MotorItem() : base()
+ {
+ Name = "Motor";
+ Description = "Motor Controller";
+ Image = ResourceHelper.GetImageFromResources("Images/engine.png");
+ }
+
+ public MotorItem(TechMotor techMotor) : this()
+ {
+ TechMotor = techMotor;
+ }
+
+ public override TechItem Clone()
+ {
+ MotorItem cloned = base.Clone() as MotorItem;
+ cloned.TechMotor = TechMotor;
+ return cloned;
+ }
+
+ public void RaiseAction(MotorActionType action)
+ {
+ ActionExecuted?.Invoke(this, action);
+ }
+ }
+}
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 b0c899f06..7bed3f441 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
@@ -6,6 +6,7 @@ using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
using System.Text;
+using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
@@ -184,7 +185,7 @@ namespace Tango.MachineStudio.Technician.ViewModels
return (value as RepeatedField<double>).ToList();
}
- private List<List<double>> GetMultiGraphValues(TechMonitor monitor,object value)
+ private List<List<double>> GetMultiGraphValues(TechMonitor monitor, object value)
{
DoubleArray[] arrayOfDoubles = Enumerable.ToArray(value as IEnumerable<DoubleArray>);
return arrayOfDoubles.Select(x => x.Data.ToList()).ToList();
@@ -192,39 +193,105 @@ namespace Tango.MachineStudio.Technician.ViewModels
public void AddElement(Rect bounds)
{
- lock (_elementsLock)
+ if (SelectedTechItem is MonitorItem)
{
- if (SelectedTechItem is MonitorItem)
- {
- var monitorItem = new MonitorItem(Adapter.TechMonitors.Where(x => !x.MultiChannel).FirstOrDefault());
- MonitorElementEditor editor = new MonitorElementEditor(monitorItem, bounds);
- Elements.Add(editor);
- }
- else if (SelectedTechItem is MeterItem)
+ var monitorItem = new MonitorItem(Adapter.TechMonitors.Where(x => !x.MultiChannel).FirstOrDefault());
+ MonitorElementEditor editor = new MonitorElementEditor(monitorItem, bounds);
+ Elements.Add(editor);
+ }
+ else if (SelectedTechItem is MeterItem)
+ {
+ var meterItem = new MeterItem(Adapter.TechMonitors.Where(x => !x.MultiChannel).FirstOrDefault());
+ MeterElementEditor editor = new MeterElementEditor(meterItem, bounds);
+ Elements.Add(editor);
+ }
+ else if (SelectedTechItem is SingleGraphItem)
+ {
+ var graphItem = new SingleGraphItem(Adapter.TechMonitors.Where(x => !x.MultiChannel).FirstOrDefault());
+ SingleGraphElementEditor editor = new SingleGraphElementEditor(graphItem, bounds);
+ editor.InnerGraph.InnerGraph.MaxPoints = Common.Helpers.GraphsHelper.GetMaxPoints(graphItem.TechMonitor.PointsPerFrame);
+ graphItem.Editor = editor;
+
+
+ GraphController controller = new GraphController();
+ editor.InnerGraph.Controller = controller;
+
+ _singleControllers.Add(graphItem, controller);
+
+ Elements.Add(editor);
+ }
+ else if (SelectedTechItem is MultiGraphItem)
+ {
+ var graphItem = new MultiGraphItem(Adapter.TechMonitors.Where(x => x.MultiChannel).FirstOrDefault());
+ MultiGraphElementEditor editor = new MultiGraphElementEditor(graphItem, bounds);
+ editor.InnerGraph.InnerGraph.MaxPoints = Common.Helpers.GraphsHelper.GetMaxPoints(graphItem.TechMonitor.PointsPerFrame);
+ graphItem.Editor = editor;
+
+
+ GraphMultiController controller = new GraphMultiController();
+
+ for (int i = 0; i < graphItem.TechMonitor.ChannelCount; i++)
{
- var meterItem = new MeterItem(Adapter.TechMonitors.Where(x => !x.MultiChannel).FirstOrDefault());
- MeterElementEditor editor = new MeterElementEditor(meterItem, bounds);
- Elements.Add(editor);
+ controller.AddSeries(new RealTimeGraphEx.DataSeries.DataYSeries()
+ {
+ UseFillAndStroke = true,
+ Name = graphItem.TechMonitor.Name.First() + (i + 1).ToString(),
+ Stroke = new SolidColorBrush(ColorHelper.GetRandomColor()),
+ });
}
- else if (SelectedTechItem is SingleGraphItem)
+
+ editor.InnerGraph.Controller = controller;
+
+ _multiControllers.Add(graphItem, controller);
+
+ Elements.Add(editor);
+ }
+ else if (SelectedTechItem is MotorItem)
+ {
+ var motorItem = new MotorItem(Adapter.TechMotors.FirstOrDefault());
+ MotorElementEditor editor = new MotorElementEditor(motorItem, bounds);
+ Elements.Add(editor);
+ InitMotorItem(motorItem);
+ }
+ }
+
+ public void OnElementsRemoved(List<IElementEditor> elements)
+ {
+ //foreach (var element in elements)
+ //{
+ // if (element.HostedElement is SingleGraphItem)
+ // {
+ // _singleControllers.Remove(element.HostedElement as SingleGraphItem);
+ // (element.HostedElement as SingleGraphItem).Editor.InnerGraph.InnerGraph.Dispose();
+ // }
+ // else if (element.HostedElement is MultiGraphItem)
+ // {
+ // _multiControllers.Remove(element.HostedElement as MultiGraphItem);
+ // (element.HostedElement as MultiGraphItem).Editor.InnerGraph.InnerGraph.Dispose();
+ // }
+ //}
+ }
+
+ public void OnElementsPasted(List<IElementEditor> elements)
+ {
+ foreach (var element in elements)
+ {
+ if (element is SingleGraphElementEditor)
{
- var graphItem = new SingleGraphItem(Adapter.TechMonitors.Where(x => !x.MultiChannel).FirstOrDefault());
- SingleGraphElementEditor editor = new SingleGraphElementEditor(graphItem, bounds);
- editor.InnerGraph.InnerGraph.MaxPoints = Common.Helpers.GraphsHelper.GetMaxPoints(graphItem.TechMonitor.PointsPerFrame);
+ var graphItem = element.HostedElement as SingleGraphItem;
+ var editor = element as SingleGraphElementEditor;
graphItem.Editor = editor;
-
+ editor.InnerGraph.InnerGraph.MaxPoints = Common.Helpers.GraphsHelper.GetMaxPoints(graphItem.TechMonitor.PointsPerFrame);
GraphController controller = new GraphController();
editor.InnerGraph.Controller = controller;
_singleControllers.Add(graphItem, controller);
-
- Elements.Add(editor);
}
- else if (SelectedTechItem is MultiGraphItem)
+ else if (element is MultiGraphElementEditor)
{
- var graphItem = new MultiGraphItem(Adapter.TechMonitors.Where(x => x.MultiChannel).FirstOrDefault());
- MultiGraphElementEditor editor = new MultiGraphElementEditor(graphItem, bounds);
+ var graphItem = element.HostedElement as MultiGraphItem;
+ var editor = element as MultiGraphElementEditor;
editor.InnerGraph.InnerGraph.MaxPoints = Common.Helpers.GraphsHelper.GetMaxPoints(graphItem.TechMonitor.PointsPerFrame);
graphItem.Editor = editor;
@@ -244,10 +311,65 @@ namespace Tango.MachineStudio.Technician.ViewModels
editor.InnerGraph.Controller = controller;
_multiControllers.Add(graphItem, controller);
-
- Elements.Add(editor);
}
}
}
+
+ private void InitMotorItem(MotorItem item)
+ {
+ item.ActionExecuted += async (x, action) =>
+ {
+ if (action == MotorActionType.HomingStarted)
+ {
+ item.HomingProgress = 0;
+ item.IsHoming = true;
+ item.IsHomingCompleted = false;
+
+ await Task.Factory.StartNew(() =>
+ {
+ for (int i = 0; i < 101; i++)
+ {
+ item.HomingMaximumProgress = 100;
+ item.HomingProgress++;
+
+ Thread.Sleep(60);
+ }
+
+ item.IsHoming = false;
+ item.IsHomingCompleted = true;
+ });
+ }
+ else if (action == MotorActionType.ForwardPressed)
+ {
+ await MachineOperator.StartMotorJogging(new MotorJoggingRequest()
+ {
+ Code = item.TechMotor.Code,
+ Direction = MotorDirection.Forward,
+ });
+ }
+ else if (action == MotorActionType.ForwardReleased)
+ {
+ await MachineOperator.StopMotorJogging(new MotorAbortJoggingRequest()
+ {
+ Code = item.TechMotor.Code,
+ });
+ }
+ else if (action == MotorActionType.BackwardPressed)
+ {
+ await MachineOperator.StartMotorJogging(new MotorJoggingRequest()
+ {
+ Code = item.TechMotor.Code,
+ Direction = MotorDirection.Backward,
+ });
+ }
+ else if (action == MotorActionType.BackwardReleased)
+ {
+ await MachineOperator.StopMotorJogging(new MotorAbortJoggingRequest()
+ {
+ Code = item.TechMotor.Code,
+ });
+ }
+ };
+ }
}
}
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 f353c92d1..7cdd92e06 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
@@ -41,7 +41,7 @@
</Menu>
<Grid Grid.Row="1">
- <StackPanel Orientation="Horizontal" Margin="20 0 0 0">
+ <StackPanel HorizontalAlignment="Left" Orientation="Horizontal" Margin="20 0 0 0">
<ListBox ItemContainerStyle="{StaticResource basicListBoxItem}" ItemsSource="{Binding AvailableTechItems}" SelectedItem="{Binding SelectedTechItem,Mode=TwoWay}" HorizontalContentAlignment="Stretch" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
@@ -69,6 +69,17 @@
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
+
+ <StackPanel HorizontalAlignment="Right" Orientation="Horizontal" Margin="0 0 255 10" VerticalAlignment="Bottom">
+ <ListBox x:Name="listMode" SelectedIndex="0" Style="{StaticResource MaterialDesignToolToggleListBox}">
+ <ListBoxItem Height="40" Width="60" HorizontalContentAlignment="Center" ToolTip="Edit Mode">
+ <materialDesign:PackIcon HorizontalAlignment="Center" Width="30" Height="30" Kind="Pencil" />
+ </ListBoxItem>
+ <ListBoxItem Height="40" Width="60" HorizontalContentAlignment="Center" ToolTip="Action Mode" MouseUp="OnActionModeClicked">
+ <materialDesign:PackIcon HorizontalAlignment="Center" Width="30" Height="30" Kind="HandPointingRight" />
+ </ListBoxItem>
+ </ListBox>
+ </StackPanel>
</Grid>
</Grid>
@@ -87,6 +98,8 @@
x:Name="editor"
Elements="{Binding Elements}"
ElementCreation="ElementsEditor_ElementCreation"
+ ElementsRemoved="ElementsEditor_ElementsRemoved"
+ AfterPaste="ElementsEditor_AfterPaste"
RulerHeight="32"
EditorWidth="1920"
EditorHeight="1080"
@@ -98,7 +111,19 @@
SelectionFillBrush="#338D8D8D"
SelectionStrokeBrush="{StaticResource AccentColorBrush}"
BorderBrush="{StaticResource AccentColorBrush}"
- BorderThickness="1" />
+ BorderThickness="1">
+
+ <editors:ElementsEditor.Style>
+ <Style TargetType="editors:ElementsEditor">
+ <Setter Property="IsEditable" Value="True"></Setter>
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding ElementName=listMode,Path=SelectedIndex}" Value="1">
+ <Setter Property="IsEditable" Value="False"></Setter>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </editors:ElementsEditor.Style>
+ </editors:ElementsEditor>
<Slider Grid.Column="1" Orientation="Vertical" Margin="5" Maximum="3" Minimum="0.2" Value="{Binding ElementName=editor,Path=ScaleFactor}"></Slider>
</Grid>
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 5944af1e2..6b84fb363 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,6 +32,13 @@ namespace Tango.MachineStudio.Technician.Views
{
_vm = DataContext as MachineTechViewVM;
};
+
+ (editor.UndoRedoStatesProvider as ElementsEditorUndoRedoStatesProvider).StateExecuted += MachineTechView_StateExecuted;
+ }
+
+ private void MachineTechView_StateExecuted(object sender, UndoRedoStateExecutedEventArgs e)
+ {
+ ElementsEditorUndoRedoState state = e.State as ElementsEditorUndoRedoState;
}
private void ElementsEditor_ElementCreation(object sender, ElementCreationEventArgs e)
@@ -39,5 +46,20 @@ namespace Tango.MachineStudio.Technician.Views
_vm.AddElement(e.Bounds);
e.AppendUndoState = true;
}
+
+ private void ElementsEditor_ElementsRemoved(object sender, ElementsEventArgs e)
+ {
+ _vm.OnElementsRemoved(e.Elements);
+ }
+
+ private void ElementsEditor_AfterPaste(object sender, ElementsEventArgs e)
+ {
+ _vm.OnElementsPasted(e.Elements);
+ }
+
+ private void OnActionModeClicked(object sender, MouseButtonEventArgs e)
+ {
+ editor.DeselectElements();
+ }
}
}