aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-03-13 15:27:16 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-03-13 15:27:16 +0200
commit37b740c1d128d694b9dcbc3669808435b5d88fec (patch)
treee94cc6ddc9712dfdad00b7d6041606a0e024e65a /Software/Visual_Studio/MachineStudio/Modules
parente75cf513acb73558e948d6012b45f221c718dcf7 (diff)
downloadTango-37b740c1d128d694b9dcbc3669808435b5d88fec.tar.gz
Tango-37b740c1d128d694b9dcbc3669808435b5d88fec.zip
Implemented Gauge Control & Technician module controller item !
Auto generated diagnostics monitors & controllers PMR.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ControllerElementEditor.xaml140
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ControllerElementEditor.xaml.cs90
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/controller.pngbin0 -> 1667 bytes
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/ControllerTemplate.xaml41
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/ControllerTemplate.xaml.cs28
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj22
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/ControllerItem.cs121
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/TechItem.cs1
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs72
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml3
10 files changed, 508 insertions, 10 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ControllerElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ControllerElementEditor.xaml
new file mode 100644
index 000000000..60b96bc9d
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ControllerElementEditor.xaml
@@ -0,0 +1,140 @@
+<local:ElementEditor x:Class="Tango.MachineStudio.Technician.Editors.ControllerElementEditor"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:sharedConverters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI"
+ xmlns:items="clr-namespace:Tango.MachineStudio.Technician.TechItems"
+ xmlns:gauge="clr-namespace:Tango.CircularGauge;assembly=Tango.CircularGauge"
+ xmlns:converters="clr-namespace:Tango.Editors.Converters;assembly=Tango.Editors"
+ xmlns:visuals="clr-namespace:Tango.Visuals;assembly=Tango.Visuals"
+ xmlns:local="clr-namespace:Tango.Editors;assembly=Tango.Editors"
+ mc:Ignorable="d" Background="Transparent" ClipToBounds="False" BorderThickness="0" MinWidth="1" MinHeight="1" RenderTransformOrigin="0.5,0.5" d:DataContext="{d:DesignInstance Type=items:ControllerItem, IsDesignTimeCreatable=False}" Height="245.074" Width="321.75">
+
+ <UserControl.Resources>
+ <converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"></converters:BoolToVisibilityConverter>
+ <sharedConverters:BooleanInverseConverter x:Key="BooleanInverseConverter" />
+
+ <!--Theme-->
+ <SolidColorBrush x:Key="BorderBrush" Color="Transparent"></SolidColorBrush>
+ <SolidColorBrush x:Key="CornersBrush" Color="Red"></SolidColorBrush>
+ </UserControl.Resources>
+
+ <UserControl.RenderTransform>
+ <RotateTransform Angle="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=Angle}"></RotateTransform>
+ </UserControl.RenderTransform>
+
+ <Grid ClipToBounds="False">
+
+
+ <!--Content-->
+ <Grid ClipToBounds="False" IsHitTestVisible="{Binding RelativeSource={RelativeSource AncestorType=local:ElementsEditor},Path=IsEditable,Converter={StaticResource BooleanInverseConverter}}">
+ <Border>
+ <Grid>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="1*" />
+ <ColumnDefinition Width="100" />
+ </Grid.ColumnDefinitions>
+ <Viewbox>
+ <Grid>
+ <gauge:CircularGaugeControl
+ Margin="10"
+ Radius="150"
+ ScaleRadius="110"
+ ScaleStartAngle="120"
+ ScaleSweepAngle="300"
+ PointerLength="85"
+ PointerCapRadius="35"
+ MinValue="{Binding TechController.Min}"
+ MaxValue="{Binding TechController.Max}"
+ MajorDivisionsCount="10"
+ MinorDivisionsCount="5"
+ CurrentValue="{Binding EffectiveValue}"
+ ImageSize="40,50"
+ RangeIndicatorThickness="8"
+ RangeIndicatorRadius="120"
+ RangeIndicatorLightRadius="10"
+ RangeIndicatorLightOffset="80"
+ ScaleLabelRadius="90"
+ ScaleLabelSize="40,20"
+ ScaleLabelFontSize="10"
+ ScaleLabelForeground="LightGray"
+ MajorTickSize="10,3"
+ MinorTickSize="3,1"
+ MajorTickColor="LightGray"
+ MinorTickColor="LightGray"
+ ImageOffset="-50"
+ GaugeBackgroundColor="Black"
+ PointerThickness ="16"
+ OptimalRangeStartValue="300"
+ OptimalRangeEndValue="700"
+ DialTextOffset="40"
+ DialTextColor="Black"
+ >
+
+ </gauge:CircularGaugeControl>
+ </Grid>
+ </Viewbox>
+
+ <Grid Grid.Column="1" HorizontalAlignment="Right">
+ <Slider Orientation="Vertical" Margin="15" TickPlacement="None" Minimum="{Binding TechController.Min}" Maximum="{Binding TechController.Max}" Value="{Binding Value,Delay=1000}">
+ <Slider.Foreground>
+ <SolidColorBrush Color="{Binding Color}" />
+ </Slider.Foreground>
+ </Slider>
+
+ <TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" FontFamily="../Fonts/#digital-7" TextAlignment="Right" Margin="-80 10 0 0" FontSize="30" Text="{Binding Value,StringFormat=0.00}">
+ <TextBlock.Foreground>
+ <SolidColorBrush Color="{Binding Color}" />
+ </TextBlock.Foreground>
+ </TextBlock>
+ </Grid>
+ </Grid>
+ </Border>
+
+ <Border Margin="0 0 0 -23" VerticalAlignment="Bottom">
+ <TextBlock Text="{Binding TechController.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/ControllerElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ControllerElementEditor.xaml.cs
new file mode 100644
index 000000000..4d183dac6
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ControllerElementEditor.xaml.cs
@@ -0,0 +1,90 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Markup;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+using Tango.Editors;
+using Tango.BL.Entities;
+using Tango.MachineStudio.Technician.TechItems;
+
+namespace Tango.MachineStudio.Technician.Editors
+{
+ [ContentProperty("InnerContent")]
+ public partial class ControllerElementEditor : ElementEditor
+ {
+ public ControllerElementEditor()
+ : base()
+ {
+ InitializeComponent();
+ }
+
+ public ControllerElementEditor(ControllerItem controllerItem)
+ : this()
+ {
+ ControllerItem = controllerItem;
+ DataContext = ControllerItem;
+ }
+
+ public ControllerElementEditor(ControllerItem controllerItem, Rect bounds)
+ : this(controllerItem)
+ {
+ Left = bounds.Left;
+ Top = bounds.Top;
+ Width = bounds.Width;
+ Height = bounds.Height;
+ }
+
+ private ControllerItem _controllerItem;
+
+ public ControllerItem ControllerItem
+ {
+ get { return _controllerItem; }
+ set { _controllerItem = value; RaisePropertyChanged(nameof(ControllerItem)); }
+ }
+
+
+ /// <summary>
+ /// Clones this instance.
+ /// </summary>
+ /// <returns></returns>
+ public override IElementEditor Clone()
+ {
+ try
+ {
+ var clonedItem = ControllerItem.Clone() as ControllerItem;
+ ControllerElementEditor cloned = new ControllerElementEditor(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 ControllerItem; }
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/controller.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/controller.png
new file mode 100644
index 000000000..5794f6cd8
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/controller.png
Binary files differ
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/ControllerTemplate.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/ControllerTemplate.xaml
new file mode 100644
index 000000000..57d807b09
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/ControllerTemplate.xaml
@@ -0,0 +1,41 @@
+<UserControl x:Class="Tango.MachineStudio.Technician.PropertiesTemplates.ControllerTemplate"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:converters="clr-namespace:Tango.MachineStudio.Technician.Converters"
+ xmlns:items="clr-namespace:Tango.MachineStudio.Technician.TechItems"
+ xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls"
+ xmlns:colorPicker="clr-namespace:Tango;assembly=Tango.ColorPicker"
+ xmlns:local="clr-namespace:Tango.MachineStudio.Technician.PropertiesTemplates"
+ mc:Ignorable="d"
+ d:DesignHeight="500" d:DesignWidth="200" d:DataContext="{d:DesignInstance Type=items:ControllerItem, IsDesignTimeCreatable=False}">
+
+ <UserControl.Resources>
+ <Style TargetType="{x:Type TabItem}" BasedOn="{StaticResource {x:Type TabItem}}">
+ <Setter Property="mahapps:ControlsHelper.HeaderFontSize" Value="14" />
+ <Setter Property="Margin" Value="2" />
+ </Style>
+ </UserControl.Resources>
+
+ <Grid>
+ <StackPanel>
+ <GroupBox Header="INPUT">
+ <StackPanel>
+ <TextBlock FontSize="10">Selected Input</TextBlock>
+ <ComboBox Margin="0 5 0 0" ItemsSource="{Binding Adapter.TechControllers}" SelectedItem="{Binding TechController,Mode=TwoWay}" DisplayMemberPath="Description" />
+
+ <TextBlock FontSize="10" Margin="0 20 0 0"><Run>Update Interval</Run> <Run Text="{Binding UpdateInterval,StringFormat={}{0:N0} ms,FallbackValue=0}"></Run></TextBlock>
+ <Slider Margin="0 5 0 0" Minimum="1" Maximum="1000" Value="{Binding UpdateInterval,Mode=TwoWay}"></Slider>
+ </StackPanel>
+ </GroupBox>
+ <GroupBox Header="COLOR" Margin="0 10 0 0">
+ <StackPanel>
+ <Viewbox Margin="0 5 0 0">
+ <colorPicker:ColorCanvas SelectedColor="{Binding Color,Mode=TwoWay}" Background="Transparent" />
+ </Viewbox>
+ </StackPanel>
+ </GroupBox>
+ </StackPanel>
+ </Grid>
+</UserControl>
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/ControllerTemplate.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/ControllerTemplate.xaml.cs
new file mode 100644
index 000000000..624eef296
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/ControllerTemplate.xaml.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace Tango.MachineStudio.Technician.PropertiesTemplates
+{
+ /// <summary>
+ /// Interaction logic for MonitorTemplate.xaml
+ /// </summary>
+ public partial class ControllerTemplate : UserControl
+ {
+ public ControllerTemplate()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj
index 56bab4135..ecc235d02 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
@@ -102,6 +102,9 @@
<Compile Include="Converters\TechIosToDigitalInsConverter.cs" />
<Compile Include="Converters\TechIosToDigitalOutsConverter.cs" />
<Compile Include="Converters\TransitionLinkConverter.cs" />
+ <Compile Include="Editors\ControllerElementEditor.xaml.cs">
+ <DependentUpon>ControllerElementEditor.xaml</DependentUpon>
+ </Compile>
<Compile Include="Editors\DigitalInElementEditor.xaml.cs">
<DependentUpon>DigitalInElementEditor.xaml</DependentUpon>
</Compile>
@@ -146,6 +149,9 @@
<Compile Include="PropertiesTemplates\DispenserTemplate.xaml.cs">
<DependentUpon>DispenserTemplate.xaml</DependentUpon>
</Compile>
+ <Compile Include="PropertiesTemplates\ControllerTemplate.xaml.cs">
+ <DependentUpon>ControllerTemplate.xaml</DependentUpon>
+ </Compile>
<Compile Include="PropertiesTemplates\MotorGroupTemplate.xaml.cs">
<DependentUpon>MotorGroupTemplate.xaml</DependentUpon>
</Compile>
@@ -164,6 +170,7 @@
<Compile Include="PropertiesTemplates\SingleGraphTemplate.xaml.cs">
<DependentUpon>SingleGraphTemplate.xaml</DependentUpon>
</Compile>
+ <Compile Include="TechItems\ControllerItem.cs" />
<Compile Include="TechItems\DigitalInItem.cs" />
<Compile Include="TechItems\DigitalOutItem.cs" />
<Compile Include="TechItems\MeterItem.cs" />
@@ -202,6 +209,10 @@
<Compile Include="..\..\..\Versioning\GlobalVersionInfo.cs">
<Link>GlobalVersionInfo.cs</Link>
</Compile>
+ <Page Include="Editors\ControllerElementEditor.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </Page>
<Page Include="Editors\DigitalInElementEditor.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@@ -258,6 +269,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
+ <Page Include="PropertiesTemplates\ControllerTemplate.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </Page>
<Page Include="PropertiesTemplates\MotorGroupTemplate.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@@ -342,6 +357,10 @@
<Project>{f441feee-322a-4943-b566-110e12fd3b72}</Project>
<Name>Tango.BL</Name>
</ProjectReference>
+ <ProjectReference Include="..\..\..\Tango.CircularGauge\Tango.CircularGauge.csproj">
+ <Project>{6efd5895-177b-4bbb-af52-29f4d53b3fbd}</Project>
+ <Name>Tango.CircularGauge</Name>
+ </ProjectReference>
<ProjectReference Include="..\..\..\Tango.ColorPicker\Tango.ColorPicker.csproj">
<Project>{a2f5af44-29ff-45d6-9d25-ecda5cce88b5}</Project>
<Name>Tango.ColorPicker</Name>
@@ -460,5 +479,8 @@
<ItemGroup>
<Resource Include="Images\digital-in.png" />
</ItemGroup>
+ <ItemGroup>
+ <Resource Include="Images\controller.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/ControllerItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/ControllerItem.cs
new file mode 100644
index 000000000..67266ee66
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/ControllerItem.cs
@@ -0,0 +1,121 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Media;
+using System.Xml.Serialization;
+using Tango.BL.Entities;
+using Tango.SharedUI.Helpers;
+
+namespace Tango.MachineStudio.Technician.TechItems
+{
+ /// <summary>
+ /// Represents a single component value controller and monitor.
+ /// </summary>
+ /// <seealso cref="TechItem" />
+ [TechItem(10)]
+ public class ControllerItem : TechItem
+ {
+ /// <summary>
+ /// Occurs when the controller value has changed.
+ /// </summary>
+ public event EventHandler<double> ValueChanged;
+
+ private TechController _techController;
+ /// <summary>
+ /// Gets or sets the DB controller item.
+ /// </summary>
+ [XmlIgnore]
+ public TechController TechController
+ {
+ get { return _techController; }
+ set { _techController = value; RaisePropertyChangedAuto(); TechName = _techController != null ? _techController.Description : null; ItemGuid = value != null ? value.Guid : null; }
+ }
+
+ private double _value;
+ /// <summary>
+ /// Gets or sets the component value.
+ /// </summary>
+ [XmlIgnore]
+ public double Value
+ {
+ get { return _value; }
+ set
+ {
+ _value = value; RaisePropertyChangedAuto();
+ ValueChanged?.Invoke(this, _value);
+ }
+ }
+
+ private int _updateInterval;
+ /// <summary>
+ /// Gets or sets the update interval.
+ /// </summary>
+ public int UpdateInterval
+ {
+ get { return _updateInterval; }
+ set { _updateInterval = value; RaisePropertyChangedAuto(); }
+ }
+
+ /// <summary>
+ /// Gets or sets the last update time.
+ /// </summary>
+ [XmlIgnore]
+ public DateTime LastUpdateTime { get; set; }
+
+
+ private double _effectiveValue;
+ /// <summary>
+ /// Gets or sets the effective value received from the embedded device.
+ /// </summary>
+ [XmlIgnore]
+ public double EffectiveValue
+ {
+ get { return _effectiveValue; }
+ set
+ {
+ LastUpdateTime = DateTime.Now;
+
+ if (_effectiveValue != value)
+ {
+ _effectiveValue = value;
+ RaisePropertyChangedAuto();
+ }
+ }
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ControllerItem"/> class.
+ /// </summary>
+ public ControllerItem() : base()
+ {
+ Name = "Value Controller";
+ Description = "Single component value controller";
+ Image = ResourceHelper.GetImageFromResources("Images/controller.png");
+ Color = Colors.DodgerBlue;
+ LastUpdateTime = DateTime.Now;
+ UpdateInterval = 10;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ControllerItem"/> class.
+ /// </summary>
+ /// <param name="techController">The db tech controller.</param>
+ public ControllerItem(TechController techController) : this()
+ {
+ TechController = techController;
+ }
+
+ /// <summary>
+ /// Clones this instance.
+ /// </summary>
+ /// <returns></returns>
+ public override TechItem Clone()
+ {
+ ControllerItem cloned = base.Clone() as ControllerItem;
+ cloned.TechController = TechController;
+ return cloned;
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/TechItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/TechItem.cs
index 44d5d2c5a..e18250594 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/TechItem.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/TechItem.cs
@@ -29,6 +29,7 @@ namespace Tango.MachineStudio.Technician.TechItems
[XmlInclude(typeof(ThreadMotionItem))]
[XmlInclude(typeof(MotorGroupItem))]
[XmlInclude(typeof(DigitalInItem))]
+ [XmlInclude(typeof(ControllerItem))]
public abstract class TechItem : ExtendedObject
{
/// <summary>
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs
index a5a95fc35..63aca3e70 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
@@ -39,7 +39,7 @@ namespace Tango.MachineStudio.Technician.ViewModels
/// <seealso cref="Tango.MachineStudio.Common.StudioApplication.IShutdownListener" />
public class MachineTechViewVM : ViewModel, IShutdownListener
{
- private List<PropertyInfo> _diagnoticsDataProperties;
+ private List<PropertyInfo> _diagnoticsMonitorsDataProperties;
private Dictionary<SingleGraphItem, GraphController> _singleControllers;
private Dictionary<MultiGraphItem, GraphMultiController> _multiControllers;
private static object _elementsLock = new object();
@@ -178,7 +178,7 @@ namespace Tango.MachineStudio.Technician.ViewModels
_multiControllers = new Dictionary<MultiGraphItem, GraphMultiController>();
AvailableTechItems = TechItem.GetAvailableTechItems().ToObservableCollection();
SelectedTechItem = AvailableTechItems.FirstOrDefault();
- _diagnoticsDataProperties = typeof(PushDiagnosticsResponse).GetProperties(BindingFlags.Public | BindingFlags.Instance).ToList();
+ _diagnoticsMonitorsDataProperties = typeof(DiagnosticsMonitors).GetProperties(BindingFlags.Public | BindingFlags.Instance).ToList();
ApplicationManager = applicationManager;
ApplicationManager.ConnectedMachineChanged += ApplicationManager_ConnectedMachineChanged;
@@ -252,11 +252,11 @@ namespace Tango.MachineStudio.Technician.ViewModels
if (DateTime.Now > monitorItem.LastUpdateTime.AddMilliseconds(monitorItem.UpdateInterval))
{
- var prop = _diagnoticsDataProperties.SingleOrDefault(x => x.Name == monitorItem.TechMonitor.Name);
+ var prop = _diagnoticsMonitorsDataProperties.SingleOrDefault(x => x.Name == monitorItem.TechMonitor.Name);
if (prop != null)
{
- monitorItem.Value = GetDataLastValue(monitorItem.TechMonitor, prop.GetValue(data));
+ monitorItem.Value = GetDataLastValue(monitorItem.TechMonitor, prop.GetValue(data.Monitors));
}
}
}
@@ -266,11 +266,11 @@ namespace Tango.MachineStudio.Technician.ViewModels
if (DateTime.Now > meterItem.LastUpdateTime.AddMilliseconds(meterItem.UpdateInterval))
{
- var prop = _diagnoticsDataProperties.SingleOrDefault(x => x.Name == meterItem.TechMonitor.Name);
+ var prop = _diagnoticsMonitorsDataProperties.SingleOrDefault(x => x.Name == meterItem.TechMonitor.Name);
if (prop != null)
{
- meterItem.Value = GetDataLastValue(meterItem.TechMonitor, prop.GetValue(data));
+ meterItem.Value = GetDataLastValue(meterItem.TechMonitor, prop.GetValue(data.Monitors));
}
}
}
@@ -278,7 +278,7 @@ namespace Tango.MachineStudio.Technician.ViewModels
{
SingleGraphItem graphItem = item as SingleGraphItem;
- var prop = _diagnoticsDataProperties.SingleOrDefault(x => x.Name == graphItem.TechMonitor.Name);
+ var prop = _diagnoticsMonitorsDataProperties.SingleOrDefault(x => x.Name == graphItem.TechMonitor.Name);
if (prop != null)
{
@@ -286,7 +286,7 @@ namespace Tango.MachineStudio.Technician.ViewModels
if (_singleControllers.TryGetValue(graphItem, out controller))
{
- controller.PushData(GetDataArray(graphItem.TechMonitor, prop.GetValue(data)));
+ controller.PushData(GetDataArray(graphItem.TechMonitor, prop.GetValue(data.Monitors)));
}
}
}
@@ -294,7 +294,7 @@ namespace Tango.MachineStudio.Technician.ViewModels
{
MultiGraphItem graphItem = item as MultiGraphItem;
- var prop = _diagnoticsDataProperties.SingleOrDefault(x => x.Name == graphItem.TechMonitor.Name);
+ var prop = _diagnoticsMonitorsDataProperties.SingleOrDefault(x => x.Name == graphItem.TechMonitor.Name);
if (prop != null)
{
@@ -302,7 +302,7 @@ namespace Tango.MachineStudio.Technician.ViewModels
if (_multiControllers.TryGetValue(graphItem, out controller))
{
- controller.PushData(GetDataMatrix(graphItem.TechMonitor, prop.GetValue(data)));
+ controller.PushData(GetDataMatrix(graphItem.TechMonitor, prop.GetValue(data.Monitors)));
}
}
}
@@ -328,6 +328,20 @@ namespace Tango.MachineStudio.Technician.ViewModels
digitalInItem.Value = digitalPin.Value;
}
}
+ else if (item.GetType() == typeof(ControllerItem))
+ {
+ ControllerItem controllerItem = item as ControllerItem;
+
+ if (DateTime.Now > controllerItem.LastUpdateTime.AddMilliseconds(controllerItem.UpdateInterval))
+ {
+ var componentState = data.ComponentsStates.SingleOrDefault(x => (int)x.Component == controllerItem.TechController.Code);
+
+ if (componentState != null)
+ {
+ controllerItem.EffectiveValue = componentState.Value;
+ }
+ }
+ }
}
}
}
@@ -466,6 +480,11 @@ namespace Tango.MachineStudio.Technician.ViewModels
{
CreateElement<DigitalInElementEditor, DigitalInItem, TechIo>(bounds, Adapter.TechIos.Where(x => x.Type == IOType.DigitalInput.ToInt32()).FirstOrDefault());
}
+ else if (item is ControllerItem)
+ {
+ var editor = CreateElement<ControllerElementEditor, ControllerItem, TechController>(bounds, Adapter.TechControllers.FirstOrDefault());
+ InitControllerItem(editor.ControllerItem);
+ }
}
/// <summary>
@@ -559,6 +578,11 @@ namespace Tango.MachineStudio.Technician.ViewModels
(item as DigitalInItem).TechIo = Adapter.TechIos.FirstOrDefault(x => x.Guid == item.ItemGuid);
CreateElement<DigitalInElementEditor>(item);
}
+ else if (item is ControllerItem)
+ {
+ (item as ControllerItem).TechController = Adapter.TechControllers.FirstOrDefault(x => x.Guid == item.ItemGuid);
+ CreateElement<ControllerElementEditor>(item);
+ }
}
/// <summary>
@@ -651,6 +675,11 @@ namespace Tango.MachineStudio.Technician.ViewModels
var motorGroupItem = element.HostedElement as MotorGroupItem;
InitMotorGroupItem(motorGroupItem);
}
+ else if (element is ControllerItem)
+ {
+ var controllerItem = element.HostedElement as ControllerItem;
+ InitControllerItem(controllerItem);
+ }
}
}
@@ -971,6 +1000,29 @@ namespace Tango.MachineStudio.Technician.ViewModels
};
}
+ /// <summary>
+ /// Initializes the controller item.
+ /// </summary>
+ /// <param name="item">The controller item.</param>
+ private void InitControllerItem(ControllerItem item)
+ {
+ item.ValueChanged += async (x, value) =>
+ {
+ try
+ {
+ await MachineOperator.SetComponentValue(new SetComponentValueRequest()
+ {
+ Component = (ValueComponent)item.TechController.Code,
+ Value = value
+ });
+ }
+ catch (Exception ex)
+ {
+ //TODO: Show Exception.
+ }
+ };
+ }
+
#endregion
#region Public Methods
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 5996c351b..3d4ecdac1 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
@@ -364,6 +364,9 @@
<DataTemplate DataType="{x:Type sys:Nullable}">
</DataTemplate>
+ <DataTemplate DataType="{x:Type items:ControllerItem}">
+ <templates:ControllerTemplate/>
+ </DataTemplate>
<DataTemplate DataType="{x:Type items:MonitorItem}">
<templates:MonitorTemplate/>
</DataTemplate>