diff options
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules')
11 files changed, 104 insertions, 90 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Converters/TechIosToDigitalOutsConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Converters/TechIosToDigitalOutsConverter.cs new file mode 100644 index 000000000..734c4bebf --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Converters/TechIosToDigitalOutsConverter.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using Tango.Integration.Observables; +using Tango.Integration.Observables.Enumerations; + +namespace Tango.MachineStudio.Technician.Converters +{ + public class TechIosToDigitalOutsConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + ObservableCollection<TechIo> ios = value as ObservableCollection<TechIo>; + + if (ios != null) + { + return ios.Where(x => x.Type == IOType.DigitalOutput.ToInt32()).ToObservableCollection(); + } + else + { + return null; + } + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/IOElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DigitalOutElementEditor.xaml index aa4f8aee6..dcf78ca69 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/IOElementEditor.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DigitalOutElementEditor.xaml @@ -1,4 +1,4 @@ -<local:ElementEditor x:Class="Tango.MachineStudio.Technician.Editors.IOElementEditor" +<local:ElementEditor x:Class="Tango.MachineStudio.Technician.Editors.DigitalOutElementEditor" 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" @@ -9,7 +9,7 @@ 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}"> + 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:DigitalOutItem, IsDesignTimeCreatable=False}"> <UserControl.Resources> <converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"></converters:BoolToVisibilityConverter> @@ -56,10 +56,7 @@ </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> + <TextBlock TextWrapping="Wrap" FontSize="14" Foreground="DimGray" HorizontalAlignment="Center" Text="{Binding TechIo.Description}"></TextBlock> </Border> </Grid> <!--Content--> 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/DigitalOutElementEditor.xaml.cs index 95710abd3..6428ccf1d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/IOElementEditor.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DigitalOutElementEditor.xaml.cs @@ -22,35 +22,23 @@ using Tango.MachineStudio.Technician.TechItems; namespace Tango.MachineStudio.Technician.Editors { [ContentProperty("InnerContent")] - public partial class IOElementEditor : ElementEditor + public partial class DigitalOutElementEditor : ElementEditor { - /// <summary> - /// Initializes a new instance of the <see cref="MonitorElementEditor"/> class. - /// </summary> - public IOElementEditor() + public DigitalOutElementEditor() : 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) + public DigitalOutElementEditor(DigitalOutItem digitalOutItem) : this() { - IOItem = ioItem; - DataContext = IOItem; + DigitalOutItem = digitalOutItem; + DataContext = DigitalOutItem; } - /// <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) + public DigitalOutElementEditor(DigitalOutItem digitalOutItem, Rect bounds) + : this(digitalOutItem) { Left = bounds.Left; Top = bounds.Top; @@ -58,12 +46,12 @@ namespace Tango.MachineStudio.Technician.Editors Height = bounds.Height; } - private IOItem _monitorItem; + private DigitalOutItem _digitalOutItem; - public IOItem IOItem + public DigitalOutItem DigitalOutItem { - get { return _monitorItem; } - set { _monitorItem = value; RaisePropertyChanged(nameof(IOItem)); } + get { return _digitalOutItem; } + set { _digitalOutItem = value; RaisePropertyChanged(nameof(DigitalOutItem)); } } @@ -75,8 +63,8 @@ namespace Tango.MachineStudio.Technician.Editors { try { - var clonedItem = IOItem.Clone() as IOItem; - IOElementEditor cloned = new IOElementEditor(clonedItem); + var clonedItem = DigitalOutItem.Clone() as DigitalOutItem; + DigitalOutElementEditor cloned = new DigitalOutElementEditor(clonedItem); cloned.Top = Top; cloned.Left = Left; cloned.Width = Width; @@ -96,7 +84,7 @@ namespace Tango.MachineStudio.Technician.Editors [ParameterIgnore] public override Object HostedElement { - get { return IOItem; } + get { return DigitalOutItem; } } } } 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 index 860072282..fb0466177 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorElementEditor.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorElementEditor.xaml @@ -162,7 +162,7 @@ </Border> </Grid> - <Grid Grid.Column="1" Grid.Row="1"> + <Grid Grid.Column="1" Grid.Row="1" Visibility="{Binding TechMotor.SupportsHoming,Converter={StaticResource BoolToVisibilityConverter}}"> <Grid.ColumnDefinitions> <ColumnDefinition Width="20*"/> <ColumnDefinition Width="115*"/> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/IOTemplate.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/DigitalOutTemplate.xaml index c03b72837..9d30e744c 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/IOTemplate.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/DigitalOutTemplate.xaml @@ -1,4 +1,4 @@ -<UserControl x:Class="Tango.MachineStudio.Technician.PropertiesTemplates.IOTemplate" +<UserControl x:Class="Tango.MachineStudio.Technician.PropertiesTemplates.DigitalOutTemplate" 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" @@ -9,10 +9,10 @@ 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}"> + d:DesignHeight="500" d:DesignWidth="200" d:DataContext="{d:DesignInstance Type=items:DigitalOutItem, IsDesignTimeCreatable=False}"> <UserControl.Resources> - <converters:MonitorsToSingleChannleMonitorsConverter x:Key="MonitorsToSingleChannleMonitorsConverter" /> + <converters:TechIosToDigitalOutsConverter x:Key="TechIosToDigitalOutsConverter" /> <Style TargetType="{x:Type TabItem}" BasedOn="{StaticResource {x:Type TabItem}}"> <Setter Property="mahapps:ControlsHelper.HeaderFontSize" Value="14" /> @@ -22,10 +22,10 @@ <Grid> <StackPanel> - <GroupBox Header="GPIO PORT"> + <GroupBox Header="INPUT"> <StackPanel> - <TextBlock FontSize="10">Selected Port</TextBlock> - <ComboBox x:Name="combo" Margin="0 5 0 0" SelectedItem="{Binding Port,Mode=TwoWay}" /> + <TextBlock FontSize="10">Selected Pin</TextBlock> + <ComboBox Margin="0 5 0 0" ItemsSource="{Binding Adapter.TechIos,Converter={StaticResource TechIosToDigitalOutsConverter}}" SelectedItem="{Binding TechIo,Mode=TwoWay}" DisplayMemberPath="Description" /> </StackPanel> </GroupBox> </StackPanel> 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/DigitalOutTemplate.xaml.cs index fae3586dc..58a3fcb8f 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/IOTemplate.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/DigitalOutTemplate.xaml.cs @@ -18,20 +18,11 @@ namespace Tango.MachineStudio.Technician.PropertiesTemplates /// <summary> /// Interaction logic for MonitorTemplate.xaml /// </summary> - public partial class IOTemplate : UserControl + public partial class DigitalOutTemplate : UserControl { - public IOTemplate() + public DigitalOutTemplate() { 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 e8b14e277..820a7ee57 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 @@ -99,12 +99,13 @@ <Compile Include="Converters\MonitorsToMultiChannleMonitorsConverter.cs" /> <Compile Include="Converters\MonitorsToSingleChannleMonitorsConverter.cs" /> <Compile Include="Converters\SecondsToGraphPointsConverter.cs" /> + <Compile Include="Converters\TechIosToDigitalOutsConverter.cs" /> <Compile Include="Converters\TransitionLinkConverter.cs" /> <Compile Include="Editors\DispenserElementEditor.xaml.cs"> <DependentUpon>DispenserElementEditor.xaml</DependentUpon> </Compile> - <Compile Include="Editors\IOElementEditor.xaml.cs"> - <DependentUpon>IOElementEditor.xaml</DependentUpon> + <Compile Include="Editors\DigitalOutElementEditor.xaml.cs"> + <DependentUpon>DigitalOutElementEditor.xaml</DependentUpon> </Compile> <Compile Include="Editors\MotorGroupElementEditor.xaml.cs"> <DependentUpon>MotorGroupElementEditor.xaml</DependentUpon> @@ -129,8 +130,8 @@ </Compile> <Compile Include="Helpers\GraphsHelper.cs" /> <Compile Include="Project\MachineTechViewProject.cs" /> - <Compile Include="PropertiesTemplates\IOTemplate.xaml.cs"> - <DependentUpon>IOTemplate.xaml</DependentUpon> + <Compile Include="PropertiesTemplates\DigitalOutTemplate.xaml.cs"> + <DependentUpon>DigitalOutTemplate.xaml</DependentUpon> </Compile> <Compile Include="PropertiesTemplates\MeterTemplate.xaml.cs"> <DependentUpon>MeterTemplate.xaml</DependentUpon> @@ -156,7 +157,7 @@ <Compile Include="PropertiesTemplates\SingleGraphTemplate.xaml.cs"> <DependentUpon>SingleGraphTemplate.xaml</DependentUpon> </Compile> - <Compile Include="TechItems\IOItem.cs" /> + <Compile Include="TechItems\DigitalOutItem.cs" /> <Compile Include="TechItems\MeterItem.cs" /> <Compile Include="TechItems\MotorActionType.cs" /> <Compile Include="TechItems\DispenserItem.cs" /> @@ -196,7 +197,7 @@ <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </Page> - <Page Include="Editors\IOElementEditor.xaml"> + <Page Include="Editors\DigitalOutElementEditor.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </Page> @@ -228,7 +229,7 @@ <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </Page> - <Page Include="PropertiesTemplates\IOTemplate.xaml"> + <Page Include="PropertiesTemplates\DigitalOutTemplate.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </Page> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/IOItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/DigitalOutItem.cs index 60d47b1c0..817cfd9b7 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/IOItem.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/DigitalOutItem.cs @@ -5,21 +5,21 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Media; using System.Xml.Serialization; -using Tango.Core; +using Tango.Integration.Observables; using Tango.SharedUI.Helpers; namespace Tango.MachineStudio.Technician.TechItems { - public class IOItem : TechItem + public class DigitalOutItem : TechItem { public event EventHandler<bool> ValueChanged; - private int _port; - - public int Port + private TechIo _techIo; + [XmlIgnore] + public TechIo TechIo { - get { return _port; } - set { _port = value; RaisePropertyChangedAuto(); TechName = "GPIO " + Port; } + get { return _techIo; } + set { _techIo = value; RaisePropertyChangedAuto(); TechName = _techIo != null ? _techIo.Description : null; ItemGuid = value != null ? value.Guid : null; } } private bool _value; @@ -47,24 +47,23 @@ namespace Tango.MachineStudio.Technician.TechItems } } - - public IOItem() : base() + public DigitalOutItem() : base() { - Name = "GPIO Controller"; - Description = "GPIO Controller"; + Name = "Digital Out"; + Description = "Digital Output Pin Controller"; Image = ResourceHelper.GetImageFromResources("Images/binary.png"); Color = Colors.White; } - public IOItem(int port) : this() + public DigitalOutItem(TechIo techIo) : this() { - Port = port; + TechIo = techIo; } public override TechItem Clone() { - IOItem cloned = base.Clone() as IOItem; - cloned.Port = Port; + DigitalOutItem cloned = base.Clone() as DigitalOutItem; + cloned.TechIo = TechIo; 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 a7b5ae5b9..92ad1c536 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 @@ -14,7 +14,7 @@ using Tango.Integration.Observables; namespace Tango.MachineStudio.Technician.TechItems { [XmlInclude(typeof(DispenserItem))] - [XmlInclude(typeof(IOItem))] + [XmlInclude(typeof(DigitalOutItem))] [XmlInclude(typeof(MeterItem))] [XmlInclude(typeof(MonitorItem))] [XmlInclude(typeof(MotorItem))] 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 1b0ee0a56..c886c2345 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 @@ -16,6 +16,7 @@ using System.Windows.Media; using Tango.Core.Helpers; using Tango.Editors; using Tango.Integration.Observables; +using Tango.Integration.Observables.Enumerations; using Tango.Integration.Operators; using Tango.MachineStudio.Common.Notifications; using Tango.MachineStudio.Common.StudioApplication; @@ -211,13 +212,15 @@ namespace Tango.MachineStudio.Technician.ViewModels } } } - else if (item.GetType() == typeof(IOItem)) + else if (item.GetType() == typeof(DigitalOutItem)) { - IOItem ioItem = item as IOItem; + DigitalOutItem digitalOutItem = item as DigitalOutItem; - if (ioItem.Port < data.GPIO.Count) + var digitalPin = data.DigitalPins.SingleOrDefault(x => x.Port == digitalOutItem.TechIo.Port); + + if (digitalPin != null) { - ioItem.EffectiveValue = data.GPIO[ioItem.Port]; + digitalOutItem.EffectiveValue = digitalPin.Value; } } else if (item.GetType() == typeof(MeterItem)) @@ -355,10 +358,10 @@ namespace Tango.MachineStudio.Technician.ViewModels var editor = CreateElement<DispenserElementEditor, DispenserItem, TechDispenser>(bounds, Adapter.TechDispensers.FirstOrDefault()); InitDispenserItem(editor.DispenserItem); } - else if (item is IOItem) + else if (item is DigitalOutItem) { - var editor = CreateElement<IOElementEditor, IOItem, int>(bounds, 0); - InitIOItem(editor.IOItem); + var editor = CreateElement<DigitalOutElementEditor, DigitalOutItem, TechIo>(bounds, Adapter.TechIos.Where(x => x.Type == IOType.DigitalOutput.ToInt32()).FirstOrDefault()); + InitDigitalOutItem(editor.DigitalOutItem); } else if (item is ThreadMotionItem) { @@ -423,10 +426,10 @@ namespace Tango.MachineStudio.Technician.ViewModels var editor = CreateElement<DispenserElementEditor>(item); InitDispenserItem(editor.DispenserItem); } - else if (item is IOItem) + else if (item is DigitalOutItem) { - var editor = CreateElement<IOElementEditor>(item); - InitIOItem(editor.IOItem); + var editor = CreateElement<DigitalOutElementEditor>(item); + InitDigitalOutItem(editor.DigitalOutItem); } else if (item is ThreadMotionItem) { @@ -507,10 +510,10 @@ namespace Tango.MachineStudio.Technician.ViewModels var dispenser = element.HostedElement as DispenserItem; InitDispenserItem(dispenser); } - else if (element is IOElementEditor) + else if (element is DigitalOutItem) { - var ioItem = element.HostedElement as IOItem; - InitIOItem(ioItem); + var ioItem = element.HostedElement as DigitalOutItem; + InitDigitalOutItem(ioItem); } else if (element is ThreadMotionItem) { @@ -669,13 +672,13 @@ namespace Tango.MachineStudio.Technician.ViewModels }; } - private void InitIOItem(IOItem item) + private void InitDigitalOutItem(DigitalOutItem item) { item.ValueChanged += async (x, value) => { try { - await MachineOperator.SetGPIOState(new SetGPIOStateRequest() { Port = item.Port, Value = value }); + await MachineOperator.SetDigitalOut(new SetDigitalOutRequest() { Port = item.TechIo.Port, Value = value }); } catch (Exception ex) { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml index 1658b97d8..784bd56fb 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 @@ -361,8 +361,8 @@ <DataTemplate DataType="{x:Type items:ThreadMotionItem}"> <templates:ThreadMotionTemplate/> </DataTemplate> - <DataTemplate DataType="{x:Type items:IOItem}"> - <templates:IOTemplate/> + <DataTemplate DataType="{x:Type items:DigitalOutItem}"> + <templates:DigitalOutTemplate/> </DataTemplate> <DataTemplate DataType="{x:Type items:DispenserItem}"> <templates:DispenserTemplate/> |
