aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules
diff options
context:
space:
mode:
authorRoy <roy.mail.net@gmail.com>2018-02-10 23:23:29 +0200
committerRoy <roy.mail.net@gmail.com>2018-02-10 23:23:29 +0200
commitdbfde8706313c147a28b16bcc7e7fef158d930bb (patch)
tree66643f03c403603f963067f721c2294d2671e9ab /Software/Visual_Studio/MachineStudio/Modules
parentf8e1ff79cc2fa09b52093c6e029392b3456ad8bb (diff)
downloadTango-dbfde8706313c147a28b16bcc7e7fef158d930bb.tar.gz
Tango-dbfde8706313c147a28b16bcc7e7fef158d930bb.zip
Implemented GPIO Controller.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/IOElementEditor.xaml106
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/IOElementEditor.xaml.cs102
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/binary.pngbin0 -> 2163 bytes
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/DispenserTemplate.xaml2
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/IOTemplate.xaml33
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/IOTemplate.xaml.cs37
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj18
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/IOItem.cs72
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs35
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml3
10 files changed, 405 insertions, 3 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/IOElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/IOElementEditor.xaml
new file mode 100644
index 000000000..aa4f8aee6
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/IOElementEditor.xaml
@@ -0,0 +1,106 @@
+<local:ElementEditor x:Class="Tango.MachineStudio.Technician.Editors.IOElementEditor"
+ 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: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="88.852" d:DesignWidth="142.323" Background="Transparent" ClipToBounds="False" BorderThickness="0" MinWidth="1" MinHeight="1" RenderTransformOrigin="0.5,0.5" d:DataContext="{d:DesignInstance Type=items:IOItem, IsDesignTimeCreatable=False}">
+
+ <UserControl.Resources>
+ <converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"></converters:BoolToVisibilityConverter>
+ <sharedConverters:BooleanInverseConverter x:Key="BooleanInverseConverter" />
+
+ <!--Theme-->
+ <SolidColorBrush x:Key="BorderBrush" Color="Transparent"></SolidColorBrush>
+ <SolidColorBrush x:Key="CornersBrush" Color="Red"></SolidColorBrush>
+ </UserControl.Resources>
+
+ <UserControl.RenderTransform>
+ <RotateTransform Angle="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=Angle}"></RotateTransform>
+ </UserControl.RenderTransform>
+
+ <Grid>
+
+
+ <!--Content-->
+ <Grid IsHitTestVisible="{Binding RelativeSource={RelativeSource AncestorType=local:ElementsEditor},Path=IsEditable,Converter={StaticResource BooleanInverseConverter}}">
+ <Grid.RowDefinitions>
+ <RowDefinition Height="221*"/>
+ <RowDefinition Height="Auto"/>
+ </Grid.RowDefinitions>
+
+ <Border BorderBrush="Gray" BorderThickness="1" CornerRadius="5" Padding="5">
+ <Border.Background>
+ <ImageBrush ImageSource="../Images/black-screen.jpg" Opacity="0.1" />
+ </Border.Background>
+ <Grid>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="55*"/>
+ <ColumnDefinition Width="55*"/>
+ </Grid.ColumnDefinitions>
+
+ <Viewbox Margin="5">
+ <visuals:Led Width="100" Height="100" IsChecked="{Binding EffectiveValue}" IsHitTestVisible="False" />
+ </Viewbox>
+ <visuals:AnalogSwitch Cursor="Hand" RenderTransformOrigin="0.5,0.5" Grid.Column="1" IsChecked="{Binding Value,Mode=TwoWay}">
+ <!--<visuals:AnalogSwitch.LayoutTransform>
+ <RotateTransform Angle="90" />
+ </visuals:AnalogSwitch.LayoutTransform>-->
+ </visuals:AnalogSwitch>
+ </Grid>
+ </Border>
+
+ <Border VerticalAlignment="Bottom" Grid.Row="1" Margin="0 0 0 0">
+ <TextBlock TextWrapping="Wrap" FontSize="14" Foreground="DimGray" HorizontalAlignment="Center">
+ <Run>GPIO</Run>
+ <Run Text="{Binding Port}"></Run>
+ </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/IOElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/IOElementEditor.xaml.cs
new file mode 100644
index 000000000..95710abd3
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/IOElementEditor.xaml.cs
@@ -0,0 +1,102 @@
+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.Integration.Observables;
+using Tango.MachineStudio.Technician.TechItems;
+
+namespace Tango.MachineStudio.Technician.Editors
+{
+ [ContentProperty("InnerContent")]
+ public partial class IOElementEditor : ElementEditor
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="MonitorElementEditor"/> class.
+ /// </summary>
+ public IOElementEditor()
+ : base()
+ {
+ InitializeComponent();
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="MonitorElementEditor"/> class.
+ /// </summary>
+ /// <param name="frameworkElement">The framework element.</param>
+ public IOElementEditor(IOItem ioItem)
+ : this()
+ {
+ IOItem = ioItem;
+ DataContext = IOItem;
+ }
+
+ /// <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 IOElementEditor(IOItem monitorItem, Rect bounds)
+ : this(monitorItem)
+ {
+ Left = bounds.Left;
+ Top = bounds.Top;
+ Width = bounds.Width;
+ Height = bounds.Height;
+ }
+
+ private IOItem _monitorItem;
+
+ public IOItem IOItem
+ {
+ get { return _monitorItem; }
+ set { _monitorItem = value; RaisePropertyChanged(nameof(IOItem)); }
+ }
+
+
+ /// <summary>
+ /// Clones this instance.
+ /// </summary>
+ /// <returns></returns>
+ public override IElementEditor Clone()
+ {
+ try
+ {
+ var clonedItem = IOItem.Clone() as IOItem;
+ IOElementEditor cloned = new IOElementEditor(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 IOItem; }
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/binary.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/binary.png
new file mode 100644
index 000000000..24b399f96
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/binary.png
Binary files differ
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/DispenserTemplate.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/DispenserTemplate.xaml
index 0eca72dcd..a732e2924 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/DispenserTemplate.xaml
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/DispenserTemplate.xaml
@@ -22,7 +22,7 @@
<Grid>
<StackPanel>
- <GroupBox Header="MOTOR">
+ <GroupBox Header="DISPENSER">
<StackPanel>
<TextBlock FontSize="10">Selected Motor</TextBlock>
<ComboBox Margin="0 5 0 0" ItemsSource="{Binding Adapter.TechDispensers}" SelectedItem="{Binding TechDispenser,Mode=TwoWay}" DisplayMemberPath="Description" />
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/IOTemplate.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/IOTemplate.xaml
new file mode 100644
index 000000000..c03b72837
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/IOTemplate.xaml
@@ -0,0 +1,33 @@
+<UserControl x:Class="Tango.MachineStudio.Technician.PropertiesTemplates.IOTemplate"
+ 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:IOItem, IsDesignTimeCreatable=False}">
+
+ <UserControl.Resources>
+ <converters:MonitorsToSingleChannleMonitorsConverter x:Key="MonitorsToSingleChannleMonitorsConverter" />
+
+ <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="GPIO PORT">
+ <StackPanel>
+ <TextBlock FontSize="10">Selected Port</TextBlock>
+ <ComboBox x:Name="combo" Margin="0 5 0 0" SelectedItem="{Binding Port,Mode=TwoWay}" />
+ </StackPanel>
+ </GroupBox>
+ </StackPanel>
+ </Grid>
+</UserControl>
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/IOTemplate.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/IOTemplate.xaml.cs
new file mode 100644
index 000000000..fae3586dc
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/IOTemplate.xaml.cs
@@ -0,0 +1,37 @@
+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 IOTemplate : UserControl
+ {
+ public IOTemplate()
+ {
+ InitializeComponent();
+
+ List<int> ports = new List<int>();
+
+ for (int i = 0; i < 120; i++)
+ {
+ ports.Add(i);
+ }
+
+ combo.ItemsSource = ports;
+ }
+ }
+}
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 34208aded..9af2c8ef8 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
@@ -100,6 +100,9 @@
<Compile Include="Editors\DispenserElementEditor.xaml.cs">
<DependentUpon>DispenserElementEditor.xaml</DependentUpon>
</Compile>
+ <Compile Include="Editors\IOElementEditor.xaml.cs">
+ <DependentUpon>IOElementEditor.xaml</DependentUpon>
+ </Compile>
<Compile Include="Editors\MotorElementEditor.xaml.cs">
<DependentUpon>MotorElementEditor.xaml</DependentUpon>
</Compile>
@@ -116,6 +119,9 @@
<DependentUpon>MonitorElementEditor.xaml</DependentUpon>
</Compile>
<Compile Include="Helpers\GraphsHelper.cs" />
+ <Compile Include="PropertiesTemplates\IOTemplate.xaml.cs">
+ <DependentUpon>IOTemplate.xaml</DependentUpon>
+ </Compile>
<Compile Include="PropertiesTemplates\MeterTemplate.xaml.cs">
<DependentUpon>MeterTemplate.xaml</DependentUpon>
</Compile>
@@ -134,6 +140,7 @@
<Compile Include="PropertiesTemplates\SingleGraphTemplate.xaml.cs">
<DependentUpon>SingleGraphTemplate.xaml</DependentUpon>
</Compile>
+ <Compile Include="TechItems\IOItem.cs" />
<Compile Include="TechItems\MeterItem.cs" />
<Compile Include="TechItems\MotorActionType.cs" />
<Compile Include="TechItems\DispenserItem.cs" />
@@ -171,6 +178,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
+ <Page Include="Editors\IOElementEditor.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </Page>
<Page Include="Editors\MotorElementEditor.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@@ -191,6 +202,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
+ <Page Include="PropertiesTemplates\IOTemplate.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </Page>
<Page Include="PropertiesTemplates\MeterTemplate.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@@ -358,5 +373,8 @@
<ItemGroup>
<Resource Include="Images\volume.png" />
</ItemGroup>
+ <ItemGroup>
+ <Resource Include="Images\binary.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/IOItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/IOItem.cs
new file mode 100644
index 000000000..c0a87842a
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/IOItem.cs
@@ -0,0 +1,72 @@
+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.SharedUI.Helpers;
+
+namespace Tango.MachineStudio.Technician.TechItems
+{
+ public class IOItem : TechItem
+ {
+ public event EventHandler<bool> ValueChanged;
+
+ public override object Data => new object();
+
+ private int _port;
+
+ public int Port
+ {
+ get { return _port; }
+ set { _port = value; RaisePropertyChangedAuto(); }
+ }
+
+ private bool _value;
+ [XmlIgnore]
+ public bool Value
+ {
+ get { return _value; }
+ set { _value = value; RaisePropertyChangedAuto(); ValueChanged?.Invoke(this, value); }
+ }
+
+ private bool _effectiveValue;
+ [XmlIgnore]
+ public bool EffectiveValue
+ {
+ get { return _effectiveValue; }
+ set
+ {
+ if (_effectiveValue != value)
+ {
+ _effectiveValue = value;
+ RaisePropertyChangedAuto();
+ _value = value;
+ RaisePropertyChanged(nameof(Value));
+ }
+ }
+ }
+
+
+ public IOItem() : base()
+ {
+ Name = "GPIO Controller";
+ Description = "GPIO Controller";
+ Image = ResourceHelper.GetImageFromResources("Images/binary.png");
+ Color = Colors.White;
+ }
+
+ public IOItem(int port) : this()
+ {
+ Port = port;
+ }
+
+ public override TechItem Clone()
+ {
+ IOItem cloned = base.Clone() as IOItem;
+ cloned.Port = Port;
+ return cloned;
+ }
+ }
+}
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 8ed8a4a80..21d2c50c2 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
@@ -116,6 +116,15 @@ namespace Tango.MachineStudio.Technician.ViewModels
}
}
}
+ else if (item.GetType() == typeof(IOItem))
+ {
+ IOItem ioItem = item as IOItem;
+
+ if (ioItem.Port < data.GPIO.Count)
+ {
+ ioItem.EffectiveValue = data.GPIO[ioItem.Port];
+ }
+ }
else if (item.GetType() == typeof(MeterItem))
{
MeterItem meterItem = item as MeterItem;
@@ -260,6 +269,13 @@ namespace Tango.MachineStudio.Technician.ViewModels
Elements.Add(editor);
InitDispenserItem(dispenserItem);
}
+ else if (SelectedTechItem is IOItem)
+ {
+ var ioItem = new IOItem(0);
+ IOElementEditor editor = new IOElementEditor(ioItem, bounds);
+ Elements.Add(editor);
+ InitIOItem(ioItem);
+ }
}
public void OnElementsRemoved(List<IElementEditor> elements)
@@ -366,13 +382,13 @@ namespace Tango.MachineStudio.Technician.ViewModels
{
Code = item.TechMotor.Code
})
- .Subscribe((response) =>
+ .Subscribe((response) =>
{
item.HomingMaximumProgress = response.Message.MaxProgress;
item.HomingProgress = response.Message.Progress;
- }, () =>
+ }, () =>
{
item.IsHoming = false;
@@ -461,5 +477,20 @@ namespace Tango.MachineStudio.Technician.ViewModels
}
};
}
+
+ private void InitIOItem(IOItem item)
+ {
+ item.ValueChanged += async (x, value) =>
+ {
+ try
+ {
+ await MachineOperator.SetGPIOState(new SetGPIOStateRequest() { Port = item.Port, Value = value });
+ }
+ catch (Exception ex)
+ {
+ //TODO: Show Exception.
+ }
+ };
+ }
}
}
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 9e3970719..494f0892f 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
@@ -200,6 +200,9 @@
<DataTemplate DataType="{x:Type items:MonitorItem}">
<templates:MonitorTemplate/>
</DataTemplate>
+ <DataTemplate DataType="{x:Type items:IOItem}">
+ <templates:IOTemplate/>
+ </DataTemplate>
<DataTemplate DataType="{x:Type items:DispenserItem}">
<templates:DispenserTemplate/>
</DataTemplate>