diff options
| author | Roy <roy.mail.net@gmail.com> | 2018-02-10 02:13:37 +0200 |
|---|---|---|
| committer | Roy <roy.mail.net@gmail.com> | 2018-02-10 02:13:37 +0200 |
| commit | 07e686eb253ffd29f36dbe530b3a17633e02b353 (patch) | |
| tree | d9663f1c92a400349dffc743adb0114ee1a7f618 /Software | |
| parent | c8c9606e545f49aae3d9f0524775436adbdf27e9 (diff) | |
| download | Tango-07e686eb253ffd29f36dbe530b3a17633e02b353.tar.gz Tango-07e686eb253ffd29f36dbe530b3a17633e02b353.zip | |
Added support for motor controllers.
Diffstat (limited to 'Software')
64 files changed, 2727 insertions, 316 deletions
diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf Binary files differindex 5481ba429..576b52c73 100644 --- a/Software/DB/Tango.mdf +++ b/Software/DB/Tango.mdf diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf Binary files differindex 9249879a7..ebd2921bf 100644 --- a/Software/DB/Tango_log.ldf +++ b/Software/DB/Tango_log.ldf diff --git a/Software/Graphics/circuitjpg.jpg b/Software/Graphics/circuitjpg.jpg Binary files differnew file mode 100644 index 000000000..589559bd4 --- /dev/null +++ b/Software/Graphics/circuitjpg.jpg diff --git a/Software/Graphics/embedded-device.png b/Software/Graphics/embedded-device.png Binary files differnew file mode 100644 index 000000000..2b3be3dfd --- /dev/null +++ b/Software/Graphics/embedded-device.png diff --git a/Software/Graphics/engine.png b/Software/Graphics/engine.png Binary files differnew file mode 100644 index 000000000..731ddc4f6 --- /dev/null +++ b/Software/Graphics/engine.png diff --git a/Software/Graphics/prop.png b/Software/Graphics/prop.png Binary files differnew file mode 100644 index 000000000..268c1e557 --- /dev/null +++ b/Software/Graphics/prop.png diff --git a/Software/PMR/Messages/Common/MessageType.proto b/Software/PMR/Messages/Common/MessageType.proto index 20b83d9ed..24a398e01 100644 --- a/Software/PMR/Messages/Common/MessageType.proto +++ b/Software/PMR/Messages/Common/MessageType.proto @@ -60,9 +60,14 @@ enum MessageType //Diagnostics PushDiagnosticsRequest = 2000; PushDiagnosticsResponse = 2001; - ReportRequest = 2002; - ReportResponse = 2003; - StatusResponse = 2004; + MotorAbortHomingRequest = 2002; + MotorAbortHomingResponse = 2003; + MotorHomingRequest = 2004; + MotorHomingResponse = 2005; + MotorJoggingRequest = 2006; + MotorJoggingResponse = 2007; + MotorAbortJoggingRequest = 2008; + MotorAbortJoggingResponse = 2009; //Printing diff --git a/Software/PMR/Messages/Diagnostics/MotorAbortHomingRequest.proto b/Software/PMR/Messages/Diagnostics/MotorAbortHomingRequest.proto new file mode 100644 index 000000000..a06dde1ef --- /dev/null +++ b/Software/PMR/Messages/Diagnostics/MotorAbortHomingRequest.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package Tango.PMR.Diagnostics; +option java_package = "com.twine.tango.pmr.diagnostics"; + +message MotorAbortHomingRequest +{ + int32 Code = 1; +}
\ No newline at end of file diff --git a/Software/PMR/Messages/Diagnostics/MotorAbortHomingResponse.proto b/Software/PMR/Messages/Diagnostics/MotorAbortHomingResponse.proto new file mode 100644 index 000000000..acc226051 --- /dev/null +++ b/Software/PMR/Messages/Diagnostics/MotorAbortHomingResponse.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package Tango.PMR.Diagnostics; +option java_package = "com.twine.tango.pmr.diagnostics"; + +message MotorAbortHomingResponse +{ + +}
\ No newline at end of file diff --git a/Software/PMR/Messages/Diagnostics/MotorAbortJoggingRequest.proto b/Software/PMR/Messages/Diagnostics/MotorAbortJoggingRequest.proto new file mode 100644 index 000000000..d568ea1ca --- /dev/null +++ b/Software/PMR/Messages/Diagnostics/MotorAbortJoggingRequest.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package Tango.PMR.Diagnostics; +option java_package = "com.twine.tango.pmr.diagnostics"; + +message MotorAbortJoggingRequest +{ + int32 Code = 2; +}
\ No newline at end of file diff --git a/Software/PMR/Messages/Diagnostics/MotorAbortJoggingResponse.proto b/Software/PMR/Messages/Diagnostics/MotorAbortJoggingResponse.proto new file mode 100644 index 000000000..2e995fc3a --- /dev/null +++ b/Software/PMR/Messages/Diagnostics/MotorAbortJoggingResponse.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package Tango.PMR.Diagnostics; +option java_package = "com.twine.tango.pmr.diagnostics"; + +message MotorAbortJoggingResponse +{ + int32 Code = 2; +}
\ No newline at end of file diff --git a/Software/PMR/Messages/Diagnostics/MotorDirection.proto b/Software/PMR/Messages/Diagnostics/MotorDirection.proto new file mode 100644 index 000000000..ed577fc38 --- /dev/null +++ b/Software/PMR/Messages/Diagnostics/MotorDirection.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; + +package Tango.PMR.Diagnostics; +option java_package = "com.twine.tango.pmr.diagnostics"; + +enum MotorDirection +{ + Forward = 0; + Backward = 1; +}
\ No newline at end of file diff --git a/Software/PMR/Messages/Diagnostics/MotorHomingRequest.proto b/Software/PMR/Messages/Diagnostics/MotorHomingRequest.proto new file mode 100644 index 000000000..b5a1fcb9e --- /dev/null +++ b/Software/PMR/Messages/Diagnostics/MotorHomingRequest.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; + +package Tango.PMR.Diagnostics; +option java_package = "com.twine.tango.pmr.diagnostics"; + +message MotorHomingRequest +{ + int32 Code = 1; + double Speed = 2; +}
\ No newline at end of file diff --git a/Software/PMR/Messages/Diagnostics/MotorHomingResponse.proto b/Software/PMR/Messages/Diagnostics/MotorHomingResponse.proto new file mode 100644 index 000000000..f79b85955 --- /dev/null +++ b/Software/PMR/Messages/Diagnostics/MotorHomingResponse.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; + +package Tango.PMR.Diagnostics; +option java_package = "com.twine.tango.pmr.diagnostics"; + +message MotorHomingResponse +{ + int32 Progress = 1; + int32 MaxProgress = 2; +}
\ No newline at end of file diff --git a/Software/PMR/Messages/Diagnostics/MotorJoggingRequest.proto b/Software/PMR/Messages/Diagnostics/MotorJoggingRequest.proto new file mode 100644 index 000000000..9a2e0a6c5 --- /dev/null +++ b/Software/PMR/Messages/Diagnostics/MotorJoggingRequest.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; + +import "MotorDirection.proto"; + +package Tango.PMR.Diagnostics; +option java_package = "com.twine.tango.pmr.diagnostics"; + +message MotorJoggingRequest +{ + MotorDirection Direction = 1; + int32 Code = 2; + double Speed = 3; +}
\ No newline at end of file diff --git a/Software/PMR/Messages/Diagnostics/MotorJoggingResponse.proto b/Software/PMR/Messages/Diagnostics/MotorJoggingResponse.proto new file mode 100644 index 000000000..f7c855159 --- /dev/null +++ b/Software/PMR/Messages/Diagnostics/MotorJoggingResponse.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package Tango.PMR.Diagnostics; +option java_package = "com.twine.tango.pmr.diagnostics"; + +message MotorJoggingResponse +{ + +}
\ No newline at end of file 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 Binary files differnew file mode 100644 index 000000000..731ddc4f6 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/engine.png 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 Binary files differnew file mode 100644 index 000000000..268c1e557 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/prop.png 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(); + } } } diff --git a/Software/Visual_Studio/Tango.Editors/ElementEditor.cs b/Software/Visual_Studio/Tango.Editors/ElementEditor.cs index c839639b9..99520ba5b 100644 --- a/Software/Visual_Studio/Tango.Editors/ElementEditor.cs +++ b/Software/Visual_Studio/Tango.Editors/ElementEditor.cs @@ -464,15 +464,15 @@ namespace Tango.Editors /// <param name="e">The <see cref="DragDeltaEventArgs"/> instance containing the event data.</param> protected virtual void DragTopLeft(object sender, DragDeltaEventArgs e) { - if (!IsCtrlDown()) - { + //if (!IsCtrlDown()) + //{ DragLeft(sender, e); DragTop(sender, e); - } - else - { - DragAngle(sender, e); - } + //} + //else + //{ + // DragAngle(sender, e); + //} } /// <summary> @@ -482,15 +482,15 @@ namespace Tango.Editors /// <param name="e">The <see cref="DragDeltaEventArgs"/> instance containing the event data.</param> protected virtual void DragTopRight(object sender, DragDeltaEventArgs e) { - if (!IsCtrlDown()) - { + //if (!IsCtrlDown()) + //{ DragRight(sender, e); DragTop(sender, e); - } - else - { - DragAngle(sender, e); - } + //} + //else + //{ + // DragAngle(sender, e); + //} } /// <summary> @@ -500,15 +500,15 @@ namespace Tango.Editors /// <param name="e">The <see cref="DragDeltaEventArgs"/> instance containing the event data.</param> protected virtual void DragBottomRight(object sender, DragDeltaEventArgs e) { - if (!IsCtrlDown()) - { + //if (!IsCtrlDown()) + //{ DragRight(sender, e); DragBottom(sender, e); - } - else - { - DragAngle(sender, e); - } + //} + //else + //{ + // DragAngle(sender, e); + //} } /// <summary> @@ -518,15 +518,15 @@ namespace Tango.Editors /// <param name="e">The <see cref="DragDeltaEventArgs"/> instance containing the event data.</param> protected virtual void DragBottomLeft(object sender, DragDeltaEventArgs e) { - if (!IsCtrlDown()) - { + //if (!IsCtrlDown()) + //{ DragLeft(sender, e); DragBottom(sender, e); - } - else - { - DragAngle(sender, e); - } + //} + //else + //{ + // DragAngle(sender, e); + //} } /// <summary> diff --git a/Software/Visual_Studio/Tango.Editors/ElementsEditor.xaml.cs b/Software/Visual_Studio/Tango.Editors/ElementsEditor.xaml.cs index c6d4c00a3..cf602cac7 100644 --- a/Software/Visual_Studio/Tango.Editors/ElementsEditor.xaml.cs +++ b/Software/Visual_Studio/Tango.Editors/ElementsEditor.xaml.cs @@ -297,7 +297,18 @@ namespace Tango.Editors public static readonly DependencyProperty PreviewVisualSourceOpacityProperty = DependencyProperty.Register("PreviewVisualSourceOpacity", typeof(double), typeof(ElementsEditor), new PropertyMetadata(1.0)); - + /// <summary> + /// Gets or sets a value indicating whether this instance is editable. + /// </summary> + public bool IsEditable + { + get { return (bool)GetValue(IsEditableProperty); } + set { SetValue(IsEditableProperty, value); } + } + public static readonly DependencyProperty IsEditableProperty = + DependencyProperty.Register("IsEditable", typeof(bool), typeof(ElementsEditor), new PropertyMetadata(true)); + + #endregion #region Attached Properties @@ -730,7 +741,7 @@ namespace Tango.Editors /// <param name="e">The <see cref="MouseButtonEventArgs"/> instance containing the event data.</param> private void Element_PreviewMouseDown(object sender, MouseButtonEventArgs e) { - if (e.ChangedButton == MouseButton.Left && !Keyboard.IsKeyDown(Key.LeftShift) && !Keyboard.IsKeyDown(Key.LeftAlt)) + if (e.ChangedButton == MouseButton.Left && !Keyboard.IsKeyDown(Key.LeftShift) && IsEditable) { SelectedElement = sender as IElementEditor; } diff --git a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs index 87fddc183..cbda54d56 100644 --- a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs +++ b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs @@ -29,6 +29,9 @@ namespace Tango.Emulations.Emulators { private PushDiagnosticsRequest _diagnosticsRequest; private bool _cancelJob; + private List<int> _motorJoggingRequestCodes; + private double _graphAmplitude; + private double _graphFrequency; #region Constructors @@ -37,7 +40,7 @@ namespace Tango.Emulations.Emulators /// </summary> public MachineEmulator() : base() { - + Init(); } /// <summary> @@ -46,7 +49,20 @@ namespace Tango.Emulations.Emulators /// <param name="transporter">The transporter.</param> public MachineEmulator(ITransporter transporter) : base(transporter) { + LogManager.Log("Machine emulator initialized using transporter " + transporter.ToString()); + Init(); + } + + private void Init() + { + _motorJoggingRequestCodes = new List<int>(); + ResetGraphFactors(); + } + private void ResetGraphFactors() + { + _graphAmplitude = 75; + _graphFrequency = 1; } #endregion @@ -63,147 +79,202 @@ namespace Tango.Emulations.Emulators switch (container.Type) { case MessageType.CalculateRequest: - Task.Factory.StartNew(() => - { - var request = MessageFactory.ExtractMessageFromContainer<CalculateRequest>(container); - var response = MessageFactory.CreateTangoMessage<CalculateResponse>(container.Token); - response.Message.Sum = request.A + request.B; - Transporter.SendResponse(response); - }); + HandleCalculateRequest(MessageFactory.ParseTangoMessageFromContainer<CalculateRequest>(container)); break; case MessageType.ProgressRequest: + HandleProgressRequest(MessageFactory.ParseTangoMessageFromContainer<ProgressRequest>(container)); + break; + case MessageType.PushDiagnosticsRequest: + HandlePushDiagnosticsRequest(MessageFactory.ParseTangoMessageFromContainer<PushDiagnosticsRequest>(container)); + break; + case MessageType.JobRequest: + HandleJobRequest(MessageFactory.ParseTangoMessageFromContainer<JobRequest>(container)); + break; + case MessageType.AbortJobRequest: + HandleAbortJobRequest(MessageFactory.ParseTangoMessageFromContainer<AbortJobRequest>(container)); + break; + case MessageType.MotorJoggingRequest: + HandleMotorJoggingRequest(MessageFactory.ParseTangoMessageFromContainer<MotorJoggingRequest>(container)); + break; + case MessageType.MotorAbortJoggingRequest: + HandleAbortMotorJoggingRequest(MessageFactory.ParseTangoMessageFromContainer<MotorAbortJoggingRequest>(container)); + break; + } + } + + #endregion - var r = MessageFactory.ExtractMessageFromContainer<ProgressRequest>(container); + #region Request Handlers - Task.Factory.StartNew(() => - { - for (int i = 0; i < r.Amount; i++) - { - Thread.Sleep(r.Delay * 10); - var res = MessageFactory.CreateTangoMessage<ProgressResponse>(container.Token); - res.Message.Progress = i; + private void HandleCalculateRequest(TangoMessage<CalculateRequest> request) + { + Task.Factory.StartNew(() => + { + var response = MessageFactory.CreateTangoMessage<CalculateResponse>(request.Container.Token); + response.Message.Sum = request.Message.A + request.Message.B; + Transporter.SendResponse(response); + }); + } - if (i == r.Amount - 1) res.Container.Completed = true; + private void HandleProgressRequest(TangoMessage<ProgressRequest> request) + { + Task.Factory.StartNew(() => + { + for (int i = 0; i < request.Message.Amount; i++) + { + Thread.Sleep(request.Message.Delay * 10); + var res = MessageFactory.CreateTangoMessage<ProgressResponse>(request.Container.Token); + res.Message.Progress = i; - Transporter.SendResponse(res); - } - }); - break; - case MessageType.DirectSynchronizationRequest: + if (i == request.Message.Amount - 1) res.Container.Completed = true; - Task.Factory.StartNew(() => - { - var request = MessageFactory.ExtractMessageFromContainer<DirectSynchronizationRequest>(container); - var response = MessageFactory.CreateTangoMessage<DirectSynchronizationResponse>(container.Token); - response.Message.LocalDB = ByteString.CopyFrom(new byte[1024 * 1024 * 10]); - Transporter.SendResponse(response); - }); - break; - case MessageType.PushDiagnosticsRequest: + Transporter.SendResponse(res); + } + }); + } - _diagnosticsRequest = MessageFactory.ExtractMessageFromContainer<PushDiagnosticsRequest>(container); + private void HandlePushDiagnosticsRequest(TangoMessage<PushDiagnosticsRequest> request) + { + _diagnosticsRequest = request.Message; - int value = 0; - Random rnd = new Random(); + int value = 0; + Random rnd = new Random(); - Task.Factory.StartNew(() => + Task.Factory.StartNew(() => + { + while (Transporter.State == TransportComponentState.Connected) + { + PushDiagnosticsResponse res = new PushDiagnosticsResponse(); + + if (_diagnosticsRequest.PushSensors) { - while (Transporter.State == TransportComponentState.Connected) + for (int i = 0; i < 10; i++) { - PushDiagnosticsResponse res = new PushDiagnosticsResponse(); + value++; + res.Dancer1Angle.Add((int)(150 + _graphAmplitude * Math.Sin(2 * 3.14 * ((int)_graphFrequency) * value))); + } - if (_diagnosticsRequest.PushSensors) - { - for (int i = 0; i < 10; i++) - { - value++; - res.Dancer1Angle.Add((int)(150 + 75 * Math.Sin(2 * 3.14 * 10 * value))); - } + res.Dancer2Angle.Add(Cursor.Position.Y); + res.Dancer3Angle.Add(Cursor.Position.Y); + } - res.Dancer2Angle.Add(Cursor.Position.Y); - res.Dancer3Angle.Add(Cursor.Position.Y); - } + if (_diagnosticsRequest.PushMotors) + { + var dispenserFrequencies = new RepeatedField<DoubleArray>(); + + double cPosition = Cursor.Position.Y; + + for (int i = 0; i < 8; i++) + { + DoubleArray singleDispenser = new DoubleArray(); - if (_diagnosticsRequest.PushMotors) + for (int j = 0; j < 10; j++) { - var dispenserFrequencies = new RepeatedField<DoubleArray>(); + singleDispenser.Data.Add(cPosition + (i * 50)); + } - double cPosition = Cursor.Position.Y; + dispenserFrequencies.Add(singleDispenser); + } - for (int i = 0; i < 8; i++) - { - DoubleArray singleDispenser = new DoubleArray(); + res.DispensersMotorsFrequency.AddRange(dispenserFrequencies); - for (int j = 0; j < 10; j++) - { - singleDispenser.Data.Add(cPosition + (i * 50)); - } + res.Dispenser1MotorFrequency.AddRange(dispenserFrequencies[0].Data); + res.Dispenser2MotorFrequency.AddRange(dispenserFrequencies[1].Data); + res.Dispenser3MotorFrequency.AddRange(dispenserFrequencies[2].Data); + res.Dispenser4MotorFrequency.AddRange(dispenserFrequencies[3].Data); + res.Dispenser5MotorFrequency.AddRange(dispenserFrequencies[4].Data); + res.Dispenser6MotorFrequency.AddRange(dispenserFrequencies[5].Data); + res.Dispenser7MotorFrequency.AddRange(dispenserFrequencies[6].Data); + res.Dispenser8MotorFrequency.AddRange(dispenserFrequencies[7].Data); + } - dispenserFrequencies.Add(singleDispenser); - } + Transporter.SendResponse<PushDiagnosticsResponse>(res, request.Container.Token); + Thread.Sleep(10); + } + }); - res.DispensersMotorsFrequency.AddRange(dispenserFrequencies); + } - res.Dispenser1MotorFrequency.AddRange(dispenserFrequencies[0].Data); - res.Dispenser2MotorFrequency.AddRange(dispenserFrequencies[1].Data); - res.Dispenser3MotorFrequency.AddRange(dispenserFrequencies[2].Data); - res.Dispenser4MotorFrequency.AddRange(dispenserFrequencies[3].Data); - res.Dispenser5MotorFrequency.AddRange(dispenserFrequencies[4].Data); - res.Dispenser6MotorFrequency.AddRange(dispenserFrequencies[5].Data); - res.Dispenser7MotorFrequency.AddRange(dispenserFrequencies[6].Data); - res.Dispenser8MotorFrequency.AddRange(dispenserFrequencies[7].Data); - } + private void HandleJobRequest(TangoMessage<JobRequest> request) + { + JobTicket job = request.Message.JobTicket; - Transporter.SendResponse<PushDiagnosticsResponse>(res, container.Token); - Thread.Sleep(10); + LogManager.Log("Job request received: " + Environment.NewLine + job.ToString()); + + double progress = 0; + _cancelJob = false; + + Task.Factory.StartNew(() => + { + while (progress < job.Length && !_cancelJob) + { + Transporter.SendResponse<JobResponse>(new JobResponse() + { + Status = new JobStatus() + { + Progress = progress } - }); - break; - case MessageType.JobRequest: + }, request.Container.Token); - var JobRequest = MessageFactory.ExtractMessageFromContainer<JobRequest>(container); - JobTicket job = JobRequest.JobTicket; + progress += 0.03; - double progress = 0; - _cancelJob = false; + Thread.Sleep(30); + } - Task.Factory.StartNew(() => + Transporter.SendResponse<JobResponse>(new JobResponse() + { + Status = new JobStatus() { - while (progress < job.Length && !_cancelJob) - { - Transporter.SendResponse<JobResponse>(new JobResponse() - { - Status = new JobStatus() - { - Progress = progress - } + Progress = job.Length, + } - }, container.Token); + }, request.Container.Token, !_cancelJob); + }); + } - progress += 0.03; + private void HandleAbortJobRequest(TangoMessage<AbortJobRequest> request) + { + LogManager.Log("Abort job request received."); + _cancelJob = true; + Transporter.SendResponse<AbortJobResponse>(new AbortJobResponse(), request.Container.Token); + } - Thread.Sleep(30); - } + private void HandleMotorJoggingRequest(TangoMessage<MotorJoggingRequest> request) + { + var jogRequest = request.Message; - Transporter.SendResponse<JobResponse>(new JobResponse() - { - Status = new JobStatus() - { - Progress = job.Length, - } + _motorJoggingRequestCodes.Add(jogRequest.Code); - }, container.Token, !_cancelJob); - }); + LogManager.Log("Motor jogging request received: " + Environment.NewLine + jogRequest.ToString()); - break; - case MessageType.AbortJobRequest: + Task.Factory.StartNew(() => + { + while (_motorJoggingRequestCodes.Contains(jogRequest.Code)) + { - _cancelJob = true; - Transporter.SendResponse<AbortJobResponse>(new AbortJobResponse(), container.Token); + if (jogRequest.Direction == MotorDirection.Forward) + { + _graphFrequency += 0.1; + } + else + { + _graphFrequency -= 0.1; + } - break; - } + Thread.Sleep(30); + } + }); + + Transporter.SendResponse<MotorJoggingResponse>(new MotorJoggingResponse(), request.Container.Token); + } + + private void HandleAbortMotorJoggingRequest(TangoMessage<MotorAbortJoggingRequest> request) + { + LogManager.Log("Abort motor jogging request received: " + Environment.NewLine + request.Message.ToString()); + _motorJoggingRequestCodes.Remove(request.Message.Code); + ResetGraphFactors(); + Transporter.SendResponse<MotorAbortJoggingResponse>(new MotorAbortJoggingResponse(), request.Container.Token); } #endregion diff --git a/Software/Visual_Studio/Tango.Integration/Operators/IMachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operators/IMachineOperator.cs index bba5ff094..6b64575de 100644 --- a/Software/Visual_Studio/Tango.Integration/Operators/IMachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operators/IMachineOperator.cs @@ -9,6 +9,7 @@ using Tango.PMR.Printing; using Tango.Transport; using System.Reactive; using Tango.Integration.Printing; +using Tango.PMR; namespace Tango.Integration.Operators { @@ -35,5 +36,19 @@ namespace Tango.Integration.Operators /// <param name="processParameters">Process parameters table</param> /// <returns></returns> JobHandler Print(Job job, ProcessParametersTable processParameters); + + /// <summary> + /// Starts jogging the specified motor. + /// </summary> + /// <param name="request">The request.</param> + /// <returns></returns> + Task<TangoMessage<MotorJoggingResponse>> StartMotorJogging(MotorJoggingRequest request); + + /// <summary> + /// Stops jogging the specified motor. + /// </summary> + /// <param name="request">The request.</param> + /// <returns></returns> + Task<TangoMessage<MotorAbortJoggingResponse>> StopMotorJogging(MotorAbortJoggingRequest request); } } diff --git a/Software/Visual_Studio/Tango.Integration/Operators/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operators/MachineOperator.cs index cc42b64ed..56b7ec971 100644 --- a/Software/Visual_Studio/Tango.Integration/Operators/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operators/MachineOperator.cs @@ -184,6 +184,26 @@ namespace Tango.Integration.Operators return handler; } + /// <summary> + /// Starts jogging the specified motor. + /// </summary> + /// <param name="request">The request.</param> + /// <returns></returns> + public Task<TangoMessage<MotorJoggingResponse>> StartMotorJogging(MotorJoggingRequest request) + { + return SendRequest<MotorJoggingRequest, MotorJoggingResponse>(request); + } + + /// <summary> + /// Stops jogging the specified motor. + /// </summary> + /// <param name="request">The request.</param> + /// <returns></returns> + public Task<TangoMessage<MotorAbortJoggingResponse>> StopMotorJogging(MotorAbortJoggingRequest request) + { + return SendRequest<MotorAbortJoggingRequest, MotorAbortJoggingResponse>(request); + } + #endregion } } diff --git a/Software/Visual_Studio/Tango.Logging/ConsoleLogger.cs b/Software/Visual_Studio/Tango.Logging/ConsoleLogger.cs index 4eb77be5a..d073f81ed 100644 --- a/Software/Visual_Studio/Tango.Logging/ConsoleLogger.cs +++ b/Software/Visual_Studio/Tango.Logging/ConsoleLogger.cs @@ -38,23 +38,10 @@ namespace Tango.Logging } /// <summary> - /// Called when a new library exception is available. - /// </summary> - /// <param name="output">The output.</param> - public void OnError(LogItemBase output) - { - EnsureConsoleOpen(() => - { - console.SetColor(ConsoleColor.Red); - console.WriteLine(output.ToString()); - }); - } - - /// <summary> /// Called when a new library trace is available. /// </summary> /// <param name="output">The output.</param> - public void OnTrace(LogItemBase output) + public void OnLog(LogItemBase output) { EnsureConsoleOpen(() => { diff --git a/Software/Visual_Studio/Tango.Logging/FileLogger.cs b/Software/Visual_Studio/Tango.Logging/FileLogger.cs index ca17aa367..75c6e529e 100644 --- a/Software/Visual_Studio/Tango.Logging/FileLogger.cs +++ b/Software/Visual_Studio/Tango.Logging/FileLogger.cs @@ -45,16 +45,7 @@ namespace Tango.Logging /// Called when a new library trace is available. /// </summary> /// <param name="output">The output.</param> - public void OnTrace(LogItemBase output) - { - OnError(output); - } - - /// <summary> - /// Called when a new library exception is available. - /// </summary> - /// <param name="output">The output.</param> - public void OnError(LogItemBase output) + public void OnLog(LogItemBase output) { File.AppendAllText(LogFile, output.ToString() + Environment.NewLine); } diff --git a/Software/Visual_Studio/Tango.Logging/ILogger.cs b/Software/Visual_Studio/Tango.Logging/ILogger.cs index 61108962a..de3c3584b 100644 --- a/Software/Visual_Studio/Tango.Logging/ILogger.cs +++ b/Software/Visual_Studio/Tango.Logging/ILogger.cs @@ -12,16 +12,10 @@ namespace Tango.Logging public interface ILogger { /// <summary> - /// Called when a new library trace is available. + /// Called when a new log is available. /// </summary> - /// <param name="output">The output.</param> - void OnTrace(LogItemBase output); - - /// <summary> - /// Called when a new library exception is available. - /// </summary> - /// <param name="output">The output.</param> - void OnError(LogItemBase output); + /// <param name="log">The log.</param> + void OnLog(LogItemBase log); /// <summary> /// Gets or sets a value indicating whether this <see cref="ILogger"/> is enabled. diff --git a/Software/Visual_Studio/Tango.Logging/LogManager.cs b/Software/Visual_Studio/Tango.Logging/LogManager.cs index d6750ce0b..43f40fcbe 100644 --- a/Software/Visual_Studio/Tango.Logging/LogManager.cs +++ b/Software/Visual_Studio/Tango.Logging/LogManager.cs @@ -156,14 +156,7 @@ namespace Tango.Logging { if (log != null) { - if (log.GetType() == typeof(ExceptionLogItem)) - { - _loggers.Where(x => x.Enabled && x.Immediate).ToList().ForEach(x => x.OnError(log)); - } - else - { - _loggers.Where(x => x.Enabled && x.Immediate).ToList().ForEach(x => x.OnTrace(log)); - } + _loggers.Where(x => x.Enabled && x.Immediate).ToList().ForEach(x => x.OnLog(log)); } _logs.Enqueue(log); @@ -187,8 +180,8 @@ namespace Tango.Logging /// <summary> /// Loggings thread method. /// </summary> - [DebuggerStepThrough] - [DebuggerHidden] + //[DebuggerStepThrough] + //[DebuggerHidden] private static void LoggingThreadMethod() { while (_logs.Count > 0) @@ -199,14 +192,7 @@ namespace Tango.Logging { if (log != null) { - if (log.GetType() == typeof(ExceptionLogItem)) - { - _loggers.Where(x => x.Enabled && !x.Immediate).ToList().ForEach(x => x.OnError(log)); - } - else - { - _loggers.Where(x => x.Enabled && !x.Immediate).ToList().ForEach(x => x.OnTrace(log)); - } + _loggers.Where(x => x.Enabled && !x.Immediate).ToList().ForEach(x => x.OnLog(log)); } } @@ -238,14 +224,7 @@ namespace Tango.Logging { try { - if (log.GetType() == typeof(ExceptionLogItem)) - { - _loggers.Where(x => x.Enabled).ToList().ForEach(x => x.OnError(log)); - } - else - { - _loggers.Where(x => x.Enabled).ToList().ForEach(x => x.OnTrace(log)); - } + _loggers.Where(x => x.Enabled).ToList().ForEach(x => x.OnLog(log)); wroteLog = true; } diff --git a/Software/Visual_Studio/Tango.Logging/SimpleStringLogger.cs b/Software/Visual_Studio/Tango.Logging/SimpleStringLogger.cs new file mode 100644 index 000000000..57aea174f --- /dev/null +++ b/Software/Visual_Studio/Tango.Logging/SimpleStringLogger.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Logging +{ + public class SimpleStringLogger : ILogger + { + private bool _enabled; + private bool _immidiate; + + public bool Enabled { get => _enabled; set => _enabled = value; } + public bool Immediate { get => _immidiate; set => _immidiate = value; } + + public List<LogCategory> Categories { get; set; } + + public event EventHandler<LogItemBase> LogReceived; + + public SimpleStringLogger() + { + Categories = new List<LogCategory>(); + Categories.Add(LogCategory.Critical); + Categories.Add(LogCategory.Debug); + Categories.Add(LogCategory.Error); + Categories.Add(LogCategory.General); + Categories.Add(LogCategory.Warning); + Enabled = true; + } + + public SimpleStringLogger(params LogCategory[] categories) + { + Categories = categories.ToList(); + Enabled = true; + } + + public void OnLog(LogItemBase log) + { + if (Categories.Contains(log.Category)) + { + LogReceived?.Invoke(this, log); + } + } + } +} diff --git a/Software/Visual_Studio/Tango.Logging/Tango.Logging.csproj b/Software/Visual_Studio/Tango.Logging/Tango.Logging.csproj index 1e70e4cb1..04a651de8 100644 --- a/Software/Visual_Studio/Tango.Logging/Tango.Logging.csproj +++ b/Software/Visual_Studio/Tango.Logging/Tango.Logging.csproj @@ -64,6 +64,7 @@ <Compile Include="LogManager.cs" /> <Compile Include="MessageLogItem.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="SimpleStringLogger.cs" /> <Compile Include="VSOutputLogger.cs" /> </ItemGroup> <ItemGroup> diff --git a/Software/Visual_Studio/Tango.Logging/VSOutputLogger.cs b/Software/Visual_Studio/Tango.Logging/VSOutputLogger.cs index 80de5292f..3804bdaa3 100644 --- a/Software/Visual_Studio/Tango.Logging/VSOutputLogger.cs +++ b/Software/Visual_Studio/Tango.Logging/VSOutputLogger.cs @@ -25,21 +25,11 @@ namespace Tango.Logging /// Called when a new library trace is available. /// </summary> /// <param name="output">The output.</param> - public void OnTrace(LogItemBase output) + public void OnLog(LogItemBase output) { Debug.WriteLine(output.ToString()); } - /// <summary> - /// Called when a new library exception is available. - /// </summary> - /// <param name="output">The output.</param> - public void OnError(LogItemBase output) - { - Debug.WriteLine(output.ToString()); - } - - private bool _isEnabled; /// <summary> /// Gets or sets a value indicating whether this <see cref="ILogger" /> is enabled. diff --git a/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs b/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs index ac58c616b..ec378556b 100644 --- a/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs +++ b/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs @@ -22,7 +22,7 @@ namespace Tango.PMR.Common { static MessageTypeReflection() { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( - "ChFNZXNzYWdlVHlwZS5wcm90bxIQVGFuZ28uUE1SLkNvbW1vbiq4CwoLTWVz", + "ChFNZXNzYWdlVHlwZS5wcm90bxIQVGFuZ28uUE1SLkNvbW1vbireDAoLTWVz", "c2FnZVR5cGUSCAoETm9uZRAAEhQKEENhbGN1bGF0ZVJlcXVlc3QQAxIVChFD", "YWxjdWxhdGVSZXNwb25zZRAEEhMKD1Byb2dyZXNzUmVxdWVzdBAFEhQKEFBy", "b2dyZXNzUmVzcG9uc2UQBhIcChhTdHViQ2FydHJpZGdlUmVhZFJlcXVlc3QQ", @@ -52,11 +52,14 @@ namespace Tango.PMR.Common { "UmVxdWVzdBDtBxIdChhPdmVycmlkZURhdGFCYXNlUmVzcG9uc2UQ7gcSFQoQ", "S2VlcEFsaXZlUmVxdWVzdBDvBxIWChFLZWVwQWxpdmVSZXNwb25zZRDwBxIb", "ChZQdXNoRGlhZ25vc3RpY3NSZXF1ZXN0ENAPEhwKF1B1c2hEaWFnbm9zdGlj", - "c1Jlc3BvbnNlENEPEhIKDVJlcG9ydFJlcXVlc3QQ0g8SEwoOUmVwb3J0UmVz", - "cG9uc2UQ0w8SEwoOU3RhdHVzUmVzcG9uc2UQ1A8SDwoKSm9iUmVxdWVzdBC4", - "FxIQCgtKb2JSZXNwb25zZRC5FxIUCg9BYm9ydEpvYlJlcXVlc3QQuhcSFQoQ", - "QWJvcnRKb2JSZXNwb25zZRC7F0IcChpjb20udHdpbmUudGFuZ28ucG1yLmNv", - "bW1vbmIGcHJvdG8z")); + "c1Jlc3BvbnNlENEPEhwKF01vdG9yQWJvcnRIb21pbmdSZXF1ZXN0ENIPEh0K", + "GE1vdG9yQWJvcnRIb21pbmdSZXNwb25zZRDTDxIXChJNb3RvckhvbWluZ1Jl", + "cXVlc3QQ1A8SGAoTTW90b3JIb21pbmdSZXNwb25zZRDVDxIYChNNb3Rvckpv", + "Z2dpbmdSZXF1ZXN0ENYPEhkKFE1vdG9ySm9nZ2luZ1Jlc3BvbnNlENcPEh0K", + "GE1vdG9yQWJvcnRKb2dnaW5nUmVxdWVzdBDYDxIeChlNb3RvckFib3J0Sm9n", + "Z2luZ1Jlc3BvbnNlENkPEg8KCkpvYlJlcXVlc3QQuBcSEAoLSm9iUmVzcG9u", + "c2UQuRcSFAoPQWJvcnRKb2JSZXF1ZXN0ELoXEhUKEEFib3J0Sm9iUmVzcG9u", + "c2UQuxdCHAoaY29tLnR3aW5lLnRhbmdvLnBtci5jb21tb25iBnByb3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Tango.PMR.Common.MessageType), }, null)); @@ -124,9 +127,14 @@ namespace Tango.PMR.Common { /// </summary> [pbr::OriginalName("PushDiagnosticsRequest")] PushDiagnosticsRequest = 2000, [pbr::OriginalName("PushDiagnosticsResponse")] PushDiagnosticsResponse = 2001, - [pbr::OriginalName("ReportRequest")] ReportRequest = 2002, - [pbr::OriginalName("ReportResponse")] ReportResponse = 2003, - [pbr::OriginalName("StatusResponse")] StatusResponse = 2004, + [pbr::OriginalName("MotorAbortHomingRequest")] MotorAbortHomingRequest = 2002, + [pbr::OriginalName("MotorAbortHomingResponse")] MotorAbortHomingResponse = 2003, + [pbr::OriginalName("MotorHomingRequest")] MotorHomingRequest = 2004, + [pbr::OriginalName("MotorHomingResponse")] MotorHomingResponse = 2005, + [pbr::OriginalName("MotorJoggingRequest")] MotorJoggingRequest = 2006, + [pbr::OriginalName("MotorJoggingResponse")] MotorJoggingResponse = 2007, + [pbr::OriginalName("MotorAbortJoggingRequest")] MotorAbortJoggingRequest = 2008, + [pbr::OriginalName("MotorAbortJoggingResponse")] MotorAbortJoggingResponse = 2009, /// <summary> ///Printing /// </summary> diff --git a/Software/Visual_Studio/Tango.PMR/Diagnostics/MotorAbortHomingRequest.cs b/Software/Visual_Studio/Tango.PMR/Diagnostics/MotorAbortHomingRequest.cs new file mode 100644 index 000000000..d5385333c --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/Diagnostics/MotorAbortHomingRequest.cs @@ -0,0 +1,160 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: MotorAbortHomingRequest.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.Diagnostics { + + /// <summary>Holder for reflection information generated from MotorAbortHomingRequest.proto</summary> + public static partial class MotorAbortHomingRequestReflection { + + #region Descriptor + /// <summary>File descriptor for MotorAbortHomingRequest.proto</summary> + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static MotorAbortHomingRequestReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Ch1Nb3RvckFib3J0SG9taW5nUmVxdWVzdC5wcm90bxIVVGFuZ28uUE1SLkRp", + "YWdub3N0aWNzIicKF01vdG9yQWJvcnRIb21pbmdSZXF1ZXN0EgwKBENvZGUY", + "ASABKAVCIQofY29tLnR3aW5lLnRhbmdvLnBtci5kaWFnbm9zdGljc2IGcHJv", + "dG8z")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Diagnostics.MotorAbortHomingRequest), global::Tango.PMR.Diagnostics.MotorAbortHomingRequest.Parser, new[]{ "Code" }, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class MotorAbortHomingRequest : pb::IMessage<MotorAbortHomingRequest> { + private static readonly pb::MessageParser<MotorAbortHomingRequest> _parser = new pb::MessageParser<MotorAbortHomingRequest>(() => new MotorAbortHomingRequest()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser<MotorAbortHomingRequest> Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Tango.PMR.Diagnostics.MotorAbortHomingRequestReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public MotorAbortHomingRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public MotorAbortHomingRequest(MotorAbortHomingRequest other) : this() { + code_ = other.code_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public MotorAbortHomingRequest Clone() { + return new MotorAbortHomingRequest(this); + } + + /// <summary>Field number for the "Code" field.</summary> + public const int CodeFieldNumber = 1; + private int code_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Code { + get { return code_; } + set { + code_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as MotorAbortHomingRequest); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(MotorAbortHomingRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Code != other.Code) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Code != 0) hash ^= Code.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Code != 0) { + output.WriteRawTag(8); + output.WriteInt32(Code); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Code != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Code); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(MotorAbortHomingRequest other) { + if (other == null) { + return; + } + if (other.Code != 0) { + Code = other.Code; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 8: { + Code = input.ReadInt32(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Diagnostics/MotorAbortHomingResponse.cs b/Software/Visual_Studio/Tango.PMR/Diagnostics/MotorAbortHomingResponse.cs new file mode 100644 index 000000000..8f6401a3f --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/Diagnostics/MotorAbortHomingResponse.cs @@ -0,0 +1,131 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: MotorAbortHomingResponse.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.Diagnostics { + + /// <summary>Holder for reflection information generated from MotorAbortHomingResponse.proto</summary> + public static partial class MotorAbortHomingResponseReflection { + + #region Descriptor + /// <summary>File descriptor for MotorAbortHomingResponse.proto</summary> + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static MotorAbortHomingResponseReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Ch5Nb3RvckFib3J0SG9taW5nUmVzcG9uc2UucHJvdG8SFVRhbmdvLlBNUi5E", + "aWFnbm9zdGljcyIaChhNb3RvckFib3J0SG9taW5nUmVzcG9uc2VCIQofY29t", + "LnR3aW5lLnRhbmdvLnBtci5kaWFnbm9zdGljc2IGcHJvdG8z")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Diagnostics.MotorAbortHomingResponse), global::Tango.PMR.Diagnostics.MotorAbortHomingResponse.Parser, null, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class MotorAbortHomingResponse : pb::IMessage<MotorAbortHomingResponse> { + private static readonly pb::MessageParser<MotorAbortHomingResponse> _parser = new pb::MessageParser<MotorAbortHomingResponse>(() => new MotorAbortHomingResponse()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser<MotorAbortHomingResponse> Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Tango.PMR.Diagnostics.MotorAbortHomingResponseReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public MotorAbortHomingResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public MotorAbortHomingResponse(MotorAbortHomingResponse other) : this() { + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public MotorAbortHomingResponse Clone() { + return new MotorAbortHomingResponse(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as MotorAbortHomingResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(MotorAbortHomingResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(MotorAbortHomingResponse other) { + if (other == null) { + return; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Diagnostics/MotorAbortJoggingRequest.cs b/Software/Visual_Studio/Tango.PMR/Diagnostics/MotorAbortJoggingRequest.cs new file mode 100644 index 000000000..cf9f015d3 --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/Diagnostics/MotorAbortJoggingRequest.cs @@ -0,0 +1,160 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: MotorAbortJoggingRequest.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.Diagnostics { + + /// <summary>Holder for reflection information generated from MotorAbortJoggingRequest.proto</summary> + public static partial class MotorAbortJoggingRequestReflection { + + #region Descriptor + /// <summary>File descriptor for MotorAbortJoggingRequest.proto</summary> + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static MotorAbortJoggingRequestReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Ch5Nb3RvckFib3J0Sm9nZ2luZ1JlcXVlc3QucHJvdG8SFVRhbmdvLlBNUi5E", + "aWFnbm9zdGljcyIoChhNb3RvckFib3J0Sm9nZ2luZ1JlcXVlc3QSDAoEQ29k", + "ZRgCIAEoBUIhCh9jb20udHdpbmUudGFuZ28ucG1yLmRpYWdub3N0aWNzYgZw", + "cm90bzM=")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Diagnostics.MotorAbortJoggingRequest), global::Tango.PMR.Diagnostics.MotorAbortJoggingRequest.Parser, new[]{ "Code" }, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class MotorAbortJoggingRequest : pb::IMessage<MotorAbortJoggingRequest> { + private static readonly pb::MessageParser<MotorAbortJoggingRequest> _parser = new pb::MessageParser<MotorAbortJoggingRequest>(() => new MotorAbortJoggingRequest()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser<MotorAbortJoggingRequest> Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Tango.PMR.Diagnostics.MotorAbortJoggingRequestReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public MotorAbortJoggingRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public MotorAbortJoggingRequest(MotorAbortJoggingRequest other) : this() { + code_ = other.code_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public MotorAbortJoggingRequest Clone() { + return new MotorAbortJoggingRequest(this); + } + + /// <summary>Field number for the "Code" field.</summary> + public const int CodeFieldNumber = 2; + private int code_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Code { + get { return code_; } + set { + code_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as MotorAbortJoggingRequest); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(MotorAbortJoggingRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Code != other.Code) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Code != 0) hash ^= Code.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Code != 0) { + output.WriteRawTag(16); + output.WriteInt32(Code); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Code != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Code); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(MotorAbortJoggingRequest other) { + if (other == null) { + return; + } + if (other.Code != 0) { + Code = other.Code; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 16: { + Code = input.ReadInt32(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Diagnostics/MotorAbortJoggingResponse.cs b/Software/Visual_Studio/Tango.PMR/Diagnostics/MotorAbortJoggingResponse.cs new file mode 100644 index 000000000..5624c5827 --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/Diagnostics/MotorAbortJoggingResponse.cs @@ -0,0 +1,160 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: MotorAbortJoggingResponse.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.Diagnostics { + + /// <summary>Holder for reflection information generated from MotorAbortJoggingResponse.proto</summary> + public static partial class MotorAbortJoggingResponseReflection { + + #region Descriptor + /// <summary>File descriptor for MotorAbortJoggingResponse.proto</summary> + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static MotorAbortJoggingResponseReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Ch9Nb3RvckFib3J0Sm9nZ2luZ1Jlc3BvbnNlLnByb3RvEhVUYW5nby5QTVIu", + "RGlhZ25vc3RpY3MiKQoZTW90b3JBYm9ydEpvZ2dpbmdSZXNwb25zZRIMCgRD", + "b2RlGAIgASgFQiEKH2NvbS50d2luZS50YW5nby5wbXIuZGlhZ25vc3RpY3Ni", + "BnByb3RvMw==")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Diagnostics.MotorAbortJoggingResponse), global::Tango.PMR.Diagnostics.MotorAbortJoggingResponse.Parser, new[]{ "Code" }, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class MotorAbortJoggingResponse : pb::IMessage<MotorAbortJoggingResponse> { + private static readonly pb::MessageParser<MotorAbortJoggingResponse> _parser = new pb::MessageParser<MotorAbortJoggingResponse>(() => new MotorAbortJoggingResponse()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser<MotorAbortJoggingResponse> Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Tango.PMR.Diagnostics.MotorAbortJoggingResponseReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public MotorAbortJoggingResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public MotorAbortJoggingResponse(MotorAbortJoggingResponse other) : this() { + code_ = other.code_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public MotorAbortJoggingResponse Clone() { + return new MotorAbortJoggingResponse(this); + } + + /// <summary>Field number for the "Code" field.</summary> + public const int CodeFieldNumber = 2; + private int code_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Code { + get { return code_; } + set { + code_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as MotorAbortJoggingResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(MotorAbortJoggingResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Code != other.Code) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Code != 0) hash ^= Code.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Code != 0) { + output.WriteRawTag(16); + output.WriteInt32(Code); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Code != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Code); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(MotorAbortJoggingResponse other) { + if (other == null) { + return; + } + if (other.Code != 0) { + Code = other.Code; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 16: { + Code = input.ReadInt32(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Diagnostics/MotorDirection.cs b/Software/Visual_Studio/Tango.PMR/Diagnostics/MotorDirection.cs new file mode 100644 index 000000000..59c355cd6 --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/Diagnostics/MotorDirection.cs @@ -0,0 +1,45 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: MotorDirection.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.Diagnostics { + + /// <summary>Holder for reflection information generated from MotorDirection.proto</summary> + public static partial class MotorDirectionReflection { + + #region Descriptor + /// <summary>File descriptor for MotorDirection.proto</summary> + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static MotorDirectionReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "ChRNb3RvckRpcmVjdGlvbi5wcm90bxIVVGFuZ28uUE1SLkRpYWdub3N0aWNz", + "KisKDk1vdG9yRGlyZWN0aW9uEgsKB0ZvcndhcmQQABIMCghCYWNrd2FyZBAB", + "QiEKH2NvbS50d2luZS50YW5nby5wbXIuZGlhZ25vc3RpY3NiBnByb3RvMw==")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Tango.PMR.Diagnostics.MotorDirection), }, null)); + } + #endregion + + } + #region Enums + public enum MotorDirection { + [pbr::OriginalName("Forward")] Forward = 0, + [pbr::OriginalName("Backward")] Backward = 1, + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Diagnostics/MotorHomingRequest.cs b/Software/Visual_Studio/Tango.PMR/Diagnostics/MotorHomingRequest.cs new file mode 100644 index 000000000..5044fa2ed --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/Diagnostics/MotorHomingRequest.cs @@ -0,0 +1,188 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: MotorHomingRequest.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.Diagnostics { + + /// <summary>Holder for reflection information generated from MotorHomingRequest.proto</summary> + public static partial class MotorHomingRequestReflection { + + #region Descriptor + /// <summary>File descriptor for MotorHomingRequest.proto</summary> + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static MotorHomingRequestReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "ChhNb3RvckhvbWluZ1JlcXVlc3QucHJvdG8SFVRhbmdvLlBNUi5EaWFnbm9z", + "dGljcyIxChJNb3RvckhvbWluZ1JlcXVlc3QSDAoEQ29kZRgBIAEoBRINCgVT", + "cGVlZBgCIAEoAUIhCh9jb20udHdpbmUudGFuZ28ucG1yLmRpYWdub3N0aWNz", + "YgZwcm90bzM=")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Diagnostics.MotorHomingRequest), global::Tango.PMR.Diagnostics.MotorHomingRequest.Parser, new[]{ "Code", "Speed" }, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class MotorHomingRequest : pb::IMessage<MotorHomingRequest> { + private static readonly pb::MessageParser<MotorHomingRequest> _parser = new pb::MessageParser<MotorHomingRequest>(() => new MotorHomingRequest()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser<MotorHomingRequest> Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Tango.PMR.Diagnostics.MotorHomingRequestReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public MotorHomingRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public MotorHomingRequest(MotorHomingRequest other) : this() { + code_ = other.code_; + speed_ = other.speed_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public MotorHomingRequest Clone() { + return new MotorHomingRequest(this); + } + + /// <summary>Field number for the "Code" field.</summary> + public const int CodeFieldNumber = 1; + private int code_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Code { + get { return code_; } + set { + code_ = value; + } + } + + /// <summary>Field number for the "Speed" field.</summary> + public const int SpeedFieldNumber = 2; + private double speed_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double Speed { + get { return speed_; } + set { + speed_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as MotorHomingRequest); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(MotorHomingRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Code != other.Code) return false; + if (Speed != other.Speed) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Code != 0) hash ^= Code.GetHashCode(); + if (Speed != 0D) hash ^= Speed.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Code != 0) { + output.WriteRawTag(8); + output.WriteInt32(Code); + } + if (Speed != 0D) { + output.WriteRawTag(17); + output.WriteDouble(Speed); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Code != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Code); + } + if (Speed != 0D) { + size += 1 + 8; + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(MotorHomingRequest other) { + if (other == null) { + return; + } + if (other.Code != 0) { + Code = other.Code; + } + if (other.Speed != 0D) { + Speed = other.Speed; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 8: { + Code = input.ReadInt32(); + break; + } + case 17: { + Speed = input.ReadDouble(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Diagnostics/MotorHomingResponse.cs b/Software/Visual_Studio/Tango.PMR/Diagnostics/MotorHomingResponse.cs new file mode 100644 index 000000000..7dd9f982b --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/Diagnostics/MotorHomingResponse.cs @@ -0,0 +1,188 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: MotorHomingResponse.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.Diagnostics { + + /// <summary>Holder for reflection information generated from MotorHomingResponse.proto</summary> + public static partial class MotorHomingResponseReflection { + + #region Descriptor + /// <summary>File descriptor for MotorHomingResponse.proto</summary> + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static MotorHomingResponseReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "ChlNb3RvckhvbWluZ1Jlc3BvbnNlLnByb3RvEhVUYW5nby5QTVIuRGlhZ25v", + "c3RpY3MiPAoTTW90b3JIb21pbmdSZXNwb25zZRIQCghQcm9ncmVzcxgBIAEo", + "BRITCgtNYXhQcm9ncmVzcxgCIAEoBUIhCh9jb20udHdpbmUudGFuZ28ucG1y", + "LmRpYWdub3N0aWNzYgZwcm90bzM=")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Diagnostics.MotorHomingResponse), global::Tango.PMR.Diagnostics.MotorHomingResponse.Parser, new[]{ "Progress", "MaxProgress" }, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class MotorHomingResponse : pb::IMessage<MotorHomingResponse> { + private static readonly pb::MessageParser<MotorHomingResponse> _parser = new pb::MessageParser<MotorHomingResponse>(() => new MotorHomingResponse()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser<MotorHomingResponse> Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Tango.PMR.Diagnostics.MotorHomingResponseReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public MotorHomingResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public MotorHomingResponse(MotorHomingResponse other) : this() { + progress_ = other.progress_; + maxProgress_ = other.maxProgress_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public MotorHomingResponse Clone() { + return new MotorHomingResponse(this); + } + + /// <summary>Field number for the "Progress" field.</summary> + public const int ProgressFieldNumber = 1; + private int progress_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Progress { + get { return progress_; } + set { + progress_ = value; + } + } + + /// <summary>Field number for the "MaxProgress" field.</summary> + public const int MaxProgressFieldNumber = 2; + private int maxProgress_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int MaxProgress { + get { return maxProgress_; } + set { + maxProgress_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as MotorHomingResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(MotorHomingResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Progress != other.Progress) return false; + if (MaxProgress != other.MaxProgress) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Progress != 0) hash ^= Progress.GetHashCode(); + if (MaxProgress != 0) hash ^= MaxProgress.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Progress != 0) { + output.WriteRawTag(8); + output.WriteInt32(Progress); + } + if (MaxProgress != 0) { + output.WriteRawTag(16); + output.WriteInt32(MaxProgress); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Progress != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Progress); + } + if (MaxProgress != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(MaxProgress); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(MotorHomingResponse other) { + if (other == null) { + return; + } + if (other.Progress != 0) { + Progress = other.Progress; + } + if (other.MaxProgress != 0) { + MaxProgress = other.MaxProgress; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 8: { + Progress = input.ReadInt32(); + break; + } + case 16: { + MaxProgress = input.ReadInt32(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Diagnostics/MotorJoggingRequest.cs b/Software/Visual_Studio/Tango.PMR/Diagnostics/MotorJoggingRequest.cs new file mode 100644 index 000000000..99f1a56c6 --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/Diagnostics/MotorJoggingRequest.cs @@ -0,0 +1,217 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: MotorJoggingRequest.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.Diagnostics { + + /// <summary>Holder for reflection information generated from MotorJoggingRequest.proto</summary> + public static partial class MotorJoggingRequestReflection { + + #region Descriptor + /// <summary>File descriptor for MotorJoggingRequest.proto</summary> + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static MotorJoggingRequestReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "ChlNb3RvckpvZ2dpbmdSZXF1ZXN0LnByb3RvEhVUYW5nby5QTVIuRGlhZ25v", + "c3RpY3MaFE1vdG9yRGlyZWN0aW9uLnByb3RvImwKE01vdG9ySm9nZ2luZ1Jl", + "cXVlc3QSOAoJRGlyZWN0aW9uGAEgASgOMiUuVGFuZ28uUE1SLkRpYWdub3N0", + "aWNzLk1vdG9yRGlyZWN0aW9uEgwKBENvZGUYAiABKAUSDQoFU3BlZWQYAyAB", + "KAFCIQofY29tLnR3aW5lLnRhbmdvLnBtci5kaWFnbm9zdGljc2IGcHJvdG8z")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { global::Tango.PMR.Diagnostics.MotorDirectionReflection.Descriptor, }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Diagnostics.MotorJoggingRequest), global::Tango.PMR.Diagnostics.MotorJoggingRequest.Parser, new[]{ "Direction", "Code", "Speed" }, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class MotorJoggingRequest : pb::IMessage<MotorJoggingRequest> { + private static readonly pb::MessageParser<MotorJoggingRequest> _parser = new pb::MessageParser<MotorJoggingRequest>(() => new MotorJoggingRequest()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser<MotorJoggingRequest> Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Tango.PMR.Diagnostics.MotorJoggingRequestReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public MotorJoggingRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public MotorJoggingRequest(MotorJoggingRequest other) : this() { + direction_ = other.direction_; + code_ = other.code_; + speed_ = other.speed_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public MotorJoggingRequest Clone() { + return new MotorJoggingRequest(this); + } + + /// <summary>Field number for the "Direction" field.</summary> + public const int DirectionFieldNumber = 1; + private global::Tango.PMR.Diagnostics.MotorDirection direction_ = 0; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Tango.PMR.Diagnostics.MotorDirection Direction { + get { return direction_; } + set { + direction_ = value; + } + } + + /// <summary>Field number for the "Code" field.</summary> + public const int CodeFieldNumber = 2; + private int code_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Code { + get { return code_; } + set { + code_ = value; + } + } + + /// <summary>Field number for the "Speed" field.</summary> + public const int SpeedFieldNumber = 3; + private double speed_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double Speed { + get { return speed_; } + set { + speed_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as MotorJoggingRequest); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(MotorJoggingRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Direction != other.Direction) return false; + if (Code != other.Code) return false; + if (Speed != other.Speed) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Direction != 0) hash ^= Direction.GetHashCode(); + if (Code != 0) hash ^= Code.GetHashCode(); + if (Speed != 0D) hash ^= Speed.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Direction != 0) { + output.WriteRawTag(8); + output.WriteEnum((int) Direction); + } + if (Code != 0) { + output.WriteRawTag(16); + output.WriteInt32(Code); + } + if (Speed != 0D) { + output.WriteRawTag(25); + output.WriteDouble(Speed); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Direction != 0) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Direction); + } + if (Code != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Code); + } + if (Speed != 0D) { + size += 1 + 8; + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(MotorJoggingRequest other) { + if (other == null) { + return; + } + if (other.Direction != 0) { + Direction = other.Direction; + } + if (other.Code != 0) { + Code = other.Code; + } + if (other.Speed != 0D) { + Speed = other.Speed; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 8: { + direction_ = (global::Tango.PMR.Diagnostics.MotorDirection) input.ReadEnum(); + break; + } + case 16: { + Code = input.ReadInt32(); + break; + } + case 25: { + Speed = input.ReadDouble(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Diagnostics/MotorJoggingResponse.cs b/Software/Visual_Studio/Tango.PMR/Diagnostics/MotorJoggingResponse.cs new file mode 100644 index 000000000..259949ca4 --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/Diagnostics/MotorJoggingResponse.cs @@ -0,0 +1,131 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: MotorJoggingResponse.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.Diagnostics { + + /// <summary>Holder for reflection information generated from MotorJoggingResponse.proto</summary> + public static partial class MotorJoggingResponseReflection { + + #region Descriptor + /// <summary>File descriptor for MotorJoggingResponse.proto</summary> + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static MotorJoggingResponseReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "ChpNb3RvckpvZ2dpbmdSZXNwb25zZS5wcm90bxIVVGFuZ28uUE1SLkRpYWdu", + "b3N0aWNzIhYKFE1vdG9ySm9nZ2luZ1Jlc3BvbnNlQiEKH2NvbS50d2luZS50", + "YW5nby5wbXIuZGlhZ25vc3RpY3NiBnByb3RvMw==")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Diagnostics.MotorJoggingResponse), global::Tango.PMR.Diagnostics.MotorJoggingResponse.Parser, null, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class MotorJoggingResponse : pb::IMessage<MotorJoggingResponse> { + private static readonly pb::MessageParser<MotorJoggingResponse> _parser = new pb::MessageParser<MotorJoggingResponse>(() => new MotorJoggingResponse()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser<MotorJoggingResponse> Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Tango.PMR.Diagnostics.MotorJoggingResponseReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public MotorJoggingResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public MotorJoggingResponse(MotorJoggingResponse other) : this() { + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public MotorJoggingResponse Clone() { + return new MotorJoggingResponse(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as MotorJoggingResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(MotorJoggingResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(MotorJoggingResponse other) { + if (other == null) { + return; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/ITangoMessage.cs b/Software/Visual_Studio/Tango.PMR/ITangoMessage.cs index d61e374ff..6d3d8d405 100644 --- a/Software/Visual_Studio/Tango.PMR/ITangoMessage.cs +++ b/Software/Visual_Studio/Tango.PMR/ITangoMessage.cs @@ -15,7 +15,7 @@ namespace Tango.PMR /// <summary> /// Gets the container that will encapsulate the actual PMR message. /// </summary> - MessageContainer Container { get; } + MessageContainer Container { get; set; } /// <summary> /// Gets or sets the PMR message type. diff --git a/Software/Visual_Studio/Tango.PMR/MessageFactory.cs b/Software/Visual_Studio/Tango.PMR/MessageFactory.cs index 4e3f67570..2c4eb3d13 100644 --- a/Software/Visual_Studio/Tango.PMR/MessageFactory.cs +++ b/Software/Visual_Studio/Tango.PMR/MessageFactory.cs @@ -76,6 +76,20 @@ namespace Tango.PMR } /// <summary> + /// Parses the specified tango message type from the specified message container. + /// </summary> + /// <typeparam name="T"></typeparam> + /// <param name="data">The data.</param> + /// <returns></returns> + public static TangoMessage<T> ParseTangoMessageFromContainer<T>(MessageContainer container) where T : IMessage<T> + { + MessageParser<T> parser = new MessageParser<T>(() => Activator.CreateInstance<T>()); + TangoMessage<T> tango = new TangoMessage<T>(parser.ParseFrom(container.Data), container.Type); + tango.Container = container; + return tango; + } + + /// <summary> /// Parses an unknown tango message from the specified byte array. /// </summary> /// <param name="data">The data.</param> diff --git a/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj b/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj index e0f79daa9..e6f671ca7 100644 --- a/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj +++ b/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj @@ -56,6 +56,15 @@ <Compile Include="ColorLab\OutputColor.cs" /> <Compile Include="Diagnostics\DataFileFrame.cs" /> <Compile Include="Diagnostics\DoubleArray.cs" /> + <Compile Include="Diagnostics\MotorAbortHomingRequest.cs" /> + <Compile Include="Diagnostics\MotorAbortHomingResponse.cs" /> + <Compile Include="Diagnostics\MotorAbortJoggingRequest.cs" /> + <Compile Include="Diagnostics\MotorAbortJoggingResponse.cs" /> + <Compile Include="Diagnostics\MotorDirection.cs" /> + <Compile Include="Diagnostics\MotorHomingRequest.cs" /> + <Compile Include="Diagnostics\MotorHomingResponse.cs" /> + <Compile Include="Diagnostics\MotorJoggingRequest.cs" /> + <Compile Include="Diagnostics\MotorJoggingResponse.cs" /> <Compile Include="Diagnostics\PushDiagnosticsRequest.cs" /> <Compile Include="Diagnostics\PushDiagnosticsResponse.cs" /> <Compile Include="ExtensionMethods.cs" /> diff --git a/Software/Visual_Studio/Tango.PMR/TangoMessage.cs b/Software/Visual_Studio/Tango.PMR/TangoMessage.cs index 7bc951148..c2cf94b38 100644 --- a/Software/Visual_Studio/Tango.PMR/TangoMessage.cs +++ b/Software/Visual_Studio/Tango.PMR/TangoMessage.cs @@ -18,7 +18,7 @@ namespace Tango.PMR /// <summary> /// Gets the container that will encapsulate the actual PMR message. /// </summary> - public MessageContainer Container { get; } + public MessageContainer Container { get; set; } /// <summary> /// Gets or sets the message. diff --git a/Software/Visual_Studio/Tango.Transport/Encoders/ProtoEncoder.cs b/Software/Visual_Studio/Tango.Transport/Encoders/ProtoEncoder.cs index 79d3485fc..bdc47da70 100644 --- a/Software/Visual_Studio/Tango.Transport/Encoders/ProtoEncoder.cs +++ b/Software/Visual_Studio/Tango.Transport/Encoders/ProtoEncoder.cs @@ -43,5 +43,16 @@ namespace Tango.Transport.Encoders { return tangoMessage.ToBytes(); } + + /// <summary> + /// Returns a <see cref="System.String" /> that represents this instance. + /// </summary> + /// <returns> + /// A <see cref="System.String" /> that represents this instance. + /// </returns> + public override string ToString() + { + return "Protobuf Encoder"; + } } } diff --git a/Software/Visual_Studio/Tango.Transport/TransportAdapterBase.cs b/Software/Visual_Studio/Tango.Transport/TransportAdapterBase.cs index b996c82b2..715869520 100644 --- a/Software/Visual_Studio/Tango.Transport/TransportAdapterBase.cs +++ b/Software/Visual_Studio/Tango.Transport/TransportAdapterBase.cs @@ -179,5 +179,20 @@ namespace Tango.Transport public abstract Task Disconnect(); #endregion + + #region Override Methods + + /// <summary> + /// Returns a <see cref="System.String" /> that represents this instance. + /// </summary> + /// <returns> + /// A <see cref="System.String" /> that represents this instance. + /// </returns> + public override string ToString() + { + return this.GetType().Name + " [" + AdapterMode + "]"; + } + + #endregion } } diff --git a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs index c4232e5b2..0f4193aab 100644 --- a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs +++ b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs @@ -616,6 +616,21 @@ namespace Tango.Transport #endregion + #region Override Methods + + /// <summary> + /// Returns a <see cref="System.String" /> that represents this instance. + /// </summary> + /// <returns> + /// A <see cref="System.String" /> that represents this instance. + /// </returns> + public override string ToString() + { + return this.GetType().Name + ", Adapter: " + (Adapter != null ? Adapter.ToString() : "Null") + ", Encoder: " + (Encoder != null ? Encoder.ToString() : "Null"); + } + + #endregion + #region Dispose /// <summary> diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Images/circuit.jpg b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Images/circuit.jpg Binary files differnew file mode 100644 index 000000000..589559bd4 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Images/circuit.jpg diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Images/embedded-device.png b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Images/embedded-device.png Binary files differnew file mode 100644 index 000000000..2b3be3dfd --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Images/embedded-device.png diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/MainWindow.xaml b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/MainWindow.xaml index 318a4133e..0bedbb1fb 100644 --- a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/MainWindow.xaml +++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/MainWindow.xaml @@ -9,7 +9,7 @@ xmlns:local="clr-namespace:Tango.MachineEM.UI" xmlns:views="clr-namespace:Tango.MachineEM.UI.Views" mc:Ignorable="d" - Title="Tango Machine Emulator" Height="720" Width="1200" TitleCaps="False" BorderBrush="Gray" BorderThickness="1" WindowStartupLocation="CenterScreen" Background="#202020" Foreground="Gainsboro" DataContext="{Binding RelativeSource={RelativeSource Self}}"> + Title="Tango Embedded Emulator" Height="720" Width="1200" TitleCaps="False" BorderBrush="Gray" BorderThickness="1" WindowStartupLocation="CenterScreen" Background="#202020" Foreground="Gainsboro" DataContext="{Binding RelativeSource={RelativeSource Self}}"> <Grid> <views:MainView DataContext="{StaticResource MainViewVM}"></views:MainView> </Grid> diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Tango.MachineEM.UI.csproj b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Tango.MachineEM.UI.csproj index 8442cf3d6..e15e75bc5 100644 --- a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Tango.MachineEM.UI.csproj +++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Tango.MachineEM.UI.csproj @@ -162,6 +162,12 @@ <ItemGroup> <Resource Include="machine.ico" /> </ItemGroup> + <ItemGroup> + <Resource Include="Images\circuit.jpg" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\embedded-device.png" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <PropertyGroup> <PostBuildEvent>$(TargetDir)linkgen.exe -s "$(TargetPath)" -d "$(TargetDir)Utilities\Machine Emulator.lnk"</PostBuildEvent> diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/ViewModels/MainViewVM.cs index 0b1a10f13..99be80b29 100644 --- a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/ViewModels/MainViewVM.cs @@ -145,18 +145,21 @@ namespace Tango.MachineEM.UI.ViewModels /// </summary> public MainViewVM() { - MainViewLogger logger = new MainViewLogger(); - //logger.NewLog += (output) => - //{ - // Log += output + Environment.NewLine; - //}; + SimpleStringLogger logger = new SimpleStringLogger(LogCategory.Critical, LogCategory.Error, LogCategory.General, LogCategory.Warning); + logger.LogReceived += (sedner, log) => + { + Log += log.ToString() + Environment.NewLine; + }; LogManager.RegisterLogger(logger); + LogManager.Log("Embedded Emulator Started..."); + + Emulator = new MachineEmulator(new BasicTransporter()); StartCommand = new RelayCommand(Start, (x) => !Emulator.IsStarted); - StopCommand = new RelayCommand(Stop,(x) => Emulator.IsStarted); + StopCommand = new RelayCommand(Stop, (x) => Emulator.IsStarted); RunCommand = new RelayCommand(RunSelectedStub, (x) => !_running); CancelCommand = new RelayCommand(Cancel, (x) => _running); ClearCommand = new RelayCommand(() => Log = String.Empty); @@ -257,32 +260,5 @@ namespace Tango.MachineEM.UI.ViewModels } #endregion - - #region Custom Logger - - public class MainViewLogger : ILogger - { - public bool Enabled { get; set; } - public bool Immediate { get; set; } - public event Action<String> NewLog; - - public MainViewLogger() - { - Enabled = true; - Immediate = true; - } - - public void OnError(LogItemBase output) - { - NewLog?.Invoke(output.ToString()); - } - - public void OnTrace(LogItemBase output) - { - NewLog?.Invoke(output.ToString()); - } - } - - #endregion } } diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml index b48001a02..4e3c7bbc9 100644 --- a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml @@ -15,6 +15,9 @@ <converters:BooleanInverseConverter x:Key="BooleanInverseConverter"></converters:BooleanInverseConverter> </UserControl.Resources> <Grid> + <Grid.Background> + <ImageBrush ImageSource="../Images/circuit.jpg" Opacity="0.1" Stretch="UniformToFill"></ImageBrush> + </Grid.Background> <Grid> <Grid.RowDefinitions> <RowDefinition Height="100"/> @@ -22,16 +25,20 @@ </Grid.RowDefinitions> <Grid> + <Grid.Effect> + <DropShadowEffect BlurRadius="10"/> + </Grid.Effect> + <Grid.Background> + <SolidColorBrush Color="#151515" Opacity="0.8" /> + </Grid.Background> <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="20 15"> - <Image Source="/Images/machine-trans.png" RenderOptions.BitmapScalingMode="Fant"></Image> - <TextBlock Text="Tango Machine Emulator" VerticalAlignment="Center" Margin="20 0 0 0" FontSize="36" Foreground="Yellow"> + <Image Source="/Images/embedded-device.png" RenderOptions.BitmapScalingMode="Fant"></Image> + <TextBlock Text="Tango Embedded Emulator" VerticalAlignment="Center" Margin="20 0 0 0" FontSize="36" Foreground="Red"> <TextBlock.Effect> <DropShadowEffect/> </TextBlock.Effect> </TextBlock> </StackPanel> - - <Rectangle VerticalAlignment="Bottom" HorizontalAlignment="Stretch" Margin="20 0 50 0" Stroke="DimGray" StrokeThickness="1" StrokeDashArray="5"></Rectangle> </Grid> <Grid Grid.Row="1" Margin="20"> @@ -41,7 +48,13 @@ <RowDefinition Height="70"/> </Grid.RowDefinitions> - <Grid x:Name="gridContent" Background="#151515" Margin="5"> + <Grid> + <TextBox x:Name="txtLog" FontFamily="monospaced" TextChanged="txtLog_TextChanged" Text="{Binding Log}" Background="Transparent" Foreground="Red" FontSize="11" Padding="5" Style="{x:Null}" BorderThickness="0" IsReadOnly="True" AcceptsReturn="True" VerticalScrollBarVisibility="Auto" TextWrapping="Wrap"> + + </TextBox> + </Grid> + + <Grid x:Name="gridContent" Background="#151515" Margin="5" Visibility="Hidden"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="300" /> @@ -135,7 +148,13 @@ </Grid> </Grid> </Grid> - <Grid x:Name="gridActions" Grid.Row="1" Background="#151515" Margin="5"> + <Grid x:Name="gridActions" Grid.Row="1" Margin="5"> + <Grid.Effect> + <DropShadowEffect BlurRadius="10" /> + </Grid.Effect> + <Grid.Background> + <SolidColorBrush Color="#151515" Opacity="0.8" /> + </Grid.Background> <StackPanel HorizontalAlignment="Right" Orientation="Horizontal" Margin="5"> <ComboBox IsEnabled="{Binding Emulator.IsStarted,Converter={StaticResource BooleanInverseConverter}}" MinWidth="140" Margin="5" BorderThickness="0" ItemsSource="{Binding Ports}" SelectedItem="{Binding SelectedPort}"></ComboBox> <Button Margin="5" MinWidth="100" Style="{StaticResource AccentedSquareButtonStyle}" mahapps:ButtonHelper.PreserveTextCase="True" BorderThickness="0" Command="{Binding StopCommand}"> diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml.cs b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml.cs index 9112f28f4..358cd7927 100644 --- a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml.cs +++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; @@ -29,5 +30,19 @@ namespace Tango.MachineEM.UI.Views { //txtResponse.ScrollToEnd(); } + + private void txtLog_TextChanged(object sender, TextChangedEventArgs e) + { + Task.Factory.StartNew(() => + { + Thread.Sleep(50); + + this.Dispatcher.Invoke(() => + { + txtLog.SelectionStart = txtLog.Text.Length; + txtLog.ScrollToEnd(); + }); + }); + } } } diff --git a/Software/Visual_Studio/Utilities/Tango.Synchronization.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/Utilities/Tango.Synchronization.UI/ViewModels/MainViewVM.cs index 174b408bc..0cf824d28 100644 --- a/Software/Visual_Studio/Utilities/Tango.Synchronization.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/Utilities/Tango.Synchronization.UI/ViewModels/MainViewVM.cs @@ -131,10 +131,10 @@ namespace Tango.Synchronization.UI.ViewModels /// </summary> public MainViewVM() { - MainViewLogger logger = new MainViewLogger(); - logger.NewLog += (output) => + SimpleStringLogger logger = new SimpleStringLogger(LogCategory.Critical, LogCategory.Error, LogCategory.General, LogCategory.Warning); + logger.LogReceived += (sender,log) => { - Log += output + Environment.NewLine; + Log += log.ToString() + Environment.NewLine; }; LogManager.RegisterLogger(logger); @@ -301,32 +301,5 @@ namespace Tango.Synchronization.UI.ViewModels MessageBox.Show(message, "Tango", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.No, MessageBoxOptions.DefaultDesktopOnly); } #endregion - - #region Custom Logger - - public class MainViewLogger : ILogger - { - public bool Enabled { get; set; } - public bool Immediate { get; set; } - public event Action<String> NewLog; - - public MainViewLogger() - { - Enabled = true; - Immediate = true; - } - - public void OnError(LogItemBase output) - { - NewLog?.Invoke(output.TimeStamp.ToTimeString() + ": " + output.GetMessage()); - } - - public void OnTrace(LogItemBase output) - { - NewLog?.Invoke(output.TimeStamp.ToTimeString() + ": " + output.GetMessage()); - } - } - - #endregion } } |
