diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-05-03 16:00:01 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-05-03 16:00:01 +0300 |
| commit | 09862076bf6569468e722dd5a8a236f7020ab7b5 (patch) | |
| tree | ecb78c76c586c7dc10c87cd3c5fcea61bb8ec878 /Software/Visual_Studio/MachineStudio | |
| parent | 52ada8c6fa887d0dc418194655bea0f8e88e9805 (diff) | |
| download | Tango-09862076bf6569468e722dd5a8a236f7020ab7b5.tar.gz Tango-09862076bf6569468e722dd5a8a236f7020ab7b5.zip | |
Lots of work !!
Diffstat (limited to 'Software/Visual_Studio/MachineStudio')
12 files changed, 314 insertions, 147 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs index 88007b5f4..21021c6b8 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs @@ -347,7 +347,7 @@ namespace Tango.MachineStudio.ColorLab.ViewModels { if (SelectedMachine != null) { - LiquidVolumes = SelectedMachine.Configuration.IdsPacks.OrderBy(x => x.PackIndex).Select(x => new LiquidVolumeVM() + LiquidVolumes = SelectedMachine.Configuration.NoneEmptyIdsPacks.OrderBy(x => x.PackIndex).Select(x => new LiquidVolumeVM() { Color = x.LiquidType.Color, Name = x.LiquidType.Name, @@ -364,12 +364,12 @@ namespace Tango.MachineStudio.ColorLab.ViewModels { if (SelectedRML != null && SelectedMachine != null) { - LiquidTypesRmls = SelectedMachine.Configuration.IdsPacks.OrderBy(x => x.PackIndex).Select(x => x.LiquidType).SelectMany(x => x.LiquidTypesRmls).Where(x => x.Rml.Guid == SelectedRML.Guid).ToList(); + LiquidTypesRmls = SelectedMachine.Configuration.NoneEmptyIdsPacks.OrderBy(x => x.PackIndex).Select(x => x.LiquidType).SelectMany(x => x.LiquidTypesRmls).Where(x => x.Rml.Guid == SelectedRML.Guid).ToList(); //RmlProcessParametersTableGroup = SelectedRML.ProcessParametersTablesGroups.ToList().SingleOrDefault(x => x.Active); LiquidsCalibrationData = new ObservableCollection<CalibrationDataVM>(); - foreach (var idsPack in SelectedMachine.Configuration.IdsPacks.OrderBy(x => x.PackIndex)) + foreach (var idsPack in SelectedMachine.Configuration.NoneEmptyIdsPacks.OrderBy(x => x.PackIndex)) { CalibrationDataVM vm = new CalibrationDataVM(); vm.Name = idsPack.LiquidType.Name; diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs index b2f476eab..f557e2923 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs @@ -1223,7 +1223,7 @@ namespace Tango.MachineStudio.Developer.ViewModels if (SelectedRML != null && SelectedMachine != null) { LogManager.Log("Invalidating liquid factors, process parameters and process group history..."); - LiquidTypesRmls = SelectedMachine.Configuration.IdsPacks.OrderBy(x => x.PackIndex).Select(x => x.LiquidType).SelectMany(x => x.LiquidTypesRmls).Where(x => x.Rml.Guid == SelectedRML.Guid).ToList(); + LiquidTypesRmls = SelectedMachine.Configuration.NoneEmptyIdsPacks.Where(x => !x.IsEmpty).OrderBy(x => x.PackIndex).Select(x => x.LiquidType).SelectMany(x => x.LiquidTypesRmls).Where(x => x.Rml.Guid == SelectedRML.Guid).ToList(); RmlProcessParametersTableGroup = SelectedRML.ProcessParametersTablesGroups.ToList().SingleOrDefault(x => x.Active); var selectedHistory = RmlProcessParametersTableGroup; diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs index f92c51aa4..c4f391c55 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs @@ -151,8 +151,11 @@ namespace Tango.MachineStudio.Logging.ViewModels Dates.Add(day); } - MinDate = Dates.Min(); - MaxDate = Dates.Max(); + if (Dates.Count > 0) + { + MinDate = Dates.Min(); + MaxDate = Dates.Max(); + } SelectedDate = Dates.FirstOrDefault(); } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs index 421f2daa7..a1da10db9 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs @@ -479,26 +479,38 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels foreach (var pack in Configuration.IdsPacks) { - if (pack.Name.IsNullOrWhiteSpace()) + if (pack.LiquidType != null || pack.CartridgeType != null || pack.DispenserType != null || pack.IdsPackFormula != null || pack.MidTankType != null) { - errors.Add(String.Format("Name is required on IDS pack number '{0}'.", Configuration.IdsPacks.IndexOf(pack) + 1)); - continue; - } - if (pack.CartridgeType == null) - { - errors.Add(String.Format("Cartridge type is required on IDS pack '{0}'.", pack.Name)); - } - if (pack.DispenserType == null) - { - errors.Add(String.Format("Dispenser type is required on IDS pack '{0}'.", pack.Name)); - } - if (pack.LiquidType == null) - { - errors.Add(String.Format("Liquid type is required on IDS pack '{0}'.", pack.Name)); + if (pack.Name.IsNullOrWhiteSpace()) + { + errors.Add(String.Format("Name is required on IDS pack number '{0}'.", Configuration.IdsPacks.IndexOf(pack) + 1)); + continue; + } + if (pack.CartridgeType == null) + { + errors.Add(String.Format("Cartridge type is required on IDS pack '{0}'.", pack.Name)); + } + if (pack.DispenserType == null) + { + errors.Add(String.Format("Dispenser type is required on IDS pack '{0}'.", pack.Name)); + } + if (pack.LiquidType == null) + { + errors.Add(String.Format("Liquid type is required on IDS pack '{0}'.", pack.Name)); + } + if (pack.MidTankType == null) + { + errors.Add(String.Format("Mid Tank type is required on IDS pack '{0}'.", pack.Name)); + } + if (pack.IdsPackFormula == null) + { + errors.Add(String.Format("Formula type is required on IDS pack '{0}'.", pack.Name)); + } } - if (pack.MidTankType == null) + else { - errors.Add(String.Format("Mid Tank type is required on IDS pack '{0}'.", pack.Name)); + pack.IsEmpty = true; + pack.Name = String.Empty; } } 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 fb0466177..7c575d7af 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" Visibility="{Binding TechMotor.SupportsHoming,Converter={StaticResource BoolToVisibilityConverter}}"> + <Grid Grid.Column="1" Grid.Row="1" Visibility="{Binding HardwareMotorType.SupportsHoming,Converter={StaticResource BoolToVisibilityConverter}}"> <Grid.ColumnDefinitions> <ColumnDefinition Width="20*"/> <ColumnDefinition Width="115*"/> @@ -232,7 +232,7 @@ <!--Content--> <Grid> <Border Margin="0 0 0 -23" VerticalAlignment="Bottom"> - <TextBlock Text="{Binding TechMotor.Description}" FontSize="14" Foreground="DimGray" HorizontalAlignment="Center"></TextBlock> + <TextBlock Text="{Binding HardwareMotorType.Description}" FontSize="14" Foreground="DimGray" HorizontalAlignment="Center"></TextBlock> </Border> </Grid> <!--Content--> 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 a732e2924..df9ebbd4e 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 @@ -5,7 +5,10 @@ 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:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:sharedConverters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" + xmlns:editors="clr-namespace:Tango.SharedUI.Editors;assembly=Tango.SharedUI" + 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" @@ -13,6 +16,7 @@ <UserControl.Resources> <converters:MonitorsToSingleChannleMonitorsConverter x:Key="MonitorsToSingleChannleMonitorsConverter" /> + <sharedConverters:DoubleToIntConverter x:Key="DoubleToIntConverter" /> <Style TargetType="{x:Type TabItem}" BasedOn="{StaticResource {x:Type TabItem}}"> <Setter Property="mahapps:ControlsHelper.HeaderFontSize" Value="14" /> @@ -24,14 +28,54 @@ <StackPanel> <GroupBox Header="DISPENSER"> <StackPanel> - <TextBlock FontSize="10">Selected Motor</TextBlock> + <TextBlock FontSize="10">Selected Dispenser</TextBlock> <ComboBox Margin="0 5 0 0" ItemsSource="{Binding Adapter.TechDispensers}" SelectedItem="{Binding TechDispenser,Mode=TwoWay}" DisplayMemberPath="Description" /> - - <TextBlock FontSize="10" Margin="0 20 0 0"><Run>Speed</Run> <Run Text="{Binding Speed,StringFormat={}{0:N0} ms,FallbackValue=0}"></Run></TextBlock> - <Slider Margin="0 5 0 0" Minimum="1" Maximum="1000" Value="{Binding Speed,Mode=TwoWay}"></Slider> </StackPanel> </GroupBox> + <GroupBox Header="PARAMETERS" Margin="0 10 0 0"> + <editors:ParameterizedEditor ParameterizedObject="{Binding DispenserType}" Padding="10"> + <editors:ParameterizedEditor.ItemsPanel> + <ItemsPanelTemplate> + <StackPanel></StackPanel> + </ItemsPanelTemplate> + </editors:ParameterizedEditor.ItemsPanel> + <editors:ParameterizedEditor.DoubleTemplate> + <DataTemplate> + <DockPanel> + <mahApps:NumericUpDown DockPanel.Dock="Right" Background="Transparent" BorderThickness="0 0 0 0" Value="{Binding Value,UpdateSourceTrigger=PropertyChanged}" HasDecimals="True" HorizontalContentAlignment="Center" Width="100" /> + <TextBlock Text="{Binding Name}" VerticalAlignment="Center"></TextBlock> + </DockPanel> + </DataTemplate> + </editors:ParameterizedEditor.DoubleTemplate> + <editors:ParameterizedEditor.Int32Template> + <DataTemplate> + <DockPanel> + <DockPanel.Style> + <Style TargetType="DockPanel"> + <Style.Triggers> + <DataTrigger Binding="{Binding Name}" Value="Code"> + <Setter Property="Visibility" Value="Collapsed"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </DockPanel.Style> + <mahApps:NumericUpDown DockPanel.Dock="Right" Background="Transparent" BorderThickness="0 0 0 0" Value="{Binding Value,Converter={StaticResource DoubleToIntConverter},UpdateSourceTrigger=PropertyChanged}" HasDecimals="False" HorizontalContentAlignment="Center" Width="100" /> + <TextBlock Text="{Binding Name}" VerticalAlignment="Center"></TextBlock> + </DockPanel> + </DataTemplate> + </editors:ParameterizedEditor.Int32Template> + <editors:ParameterizedEditor.BooleanTemplate> + <DataTemplate> + <DockPanel Margin="0 5 0 0"> + <ToggleButton DockPanel.Dock="Right" Width="100" IsChecked="{Binding Value}" HorizontalAlignment="Right" /> + <TextBlock Text="{Binding Name}" VerticalAlignment="Center"></TextBlock> + </DockPanel> + </DataTemplate> + </editors:ParameterizedEditor.BooleanTemplate> + </editors:ParameterizedEditor> + </GroupBox> + <GroupBox Header="COLOR" Margin="0 10 0 0"> <StackPanel> <Viewbox Margin="0 5 0 0"> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MotorTemplate.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MotorTemplate.xaml index 0d92230ad..9c166bab0 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MotorTemplate.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MotorTemplate.xaml @@ -4,8 +4,10 @@ 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:sharedConverters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:items="clr-namespace:Tango.MachineStudio.Technician.TechItems" - xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:editors="clr-namespace:Tango.SharedUI.Editors;assembly=Tango.SharedUI" + 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" @@ -13,9 +15,10 @@ <UserControl.Resources> <converters:MonitorsToSingleChannleMonitorsConverter x:Key="MonitorsToSingleChannleMonitorsConverter" /> + <sharedConverters:DoubleToIntConverter x:Key="DoubleToIntConverter" /> <Style TargetType="{x:Type TabItem}" BasedOn="{StaticResource {x:Type TabItem}}"> - <Setter Property="mahapps:ControlsHelper.HeaderFontSize" Value="14" /> + <Setter Property="mahApps:ControlsHelper.HeaderFontSize" Value="14" /> <Setter Property="Margin" Value="2" /> </Style> </UserControl.Resources> @@ -25,13 +28,44 @@ <GroupBox Header="MOTOR"> <StackPanel> <TextBlock FontSize="10">Selected Motor</TextBlock> - <ComboBox Margin="0 5 0 0" ItemsSource="{Binding Adapter.TechMotors}" SelectedItem="{Binding TechMotor,Mode=TwoWay}" DisplayMemberPath="Description" /> - - <TextBlock FontSize="10" Margin="0 20 0 0"><Run>Speed</Run> <Run Text="{Binding Speed,StringFormat={}{0:N0} ms,FallbackValue=0}"></Run></TextBlock> - <Slider Margin="0 5 0 0" Minimum="1" Maximum="1000" Value="{Binding Speed,Mode=TwoWay}"></Slider> + <ComboBox Margin="0 5 0 0" ItemsSource="{Binding Adapter.HardwareMotorTypes}" SelectedItem="{Binding HardwareMotorType,Mode=TwoWay}" DisplayMemberPath="Description" /> </StackPanel> </GroupBox> + <GroupBox Header="PARAMETERS" Margin="0 10 0 0"> + <editors:ParameterizedEditor ParameterizedObject="{Binding HardwareMotor}" Padding="10"> + <editors:ParameterizedEditor.ItemsPanel> + <ItemsPanelTemplate> + <StackPanel></StackPanel> + </ItemsPanelTemplate> + </editors:ParameterizedEditor.ItemsPanel> + <editors:ParameterizedEditor.DoubleTemplate> + <DataTemplate> + <DockPanel> + <mahApps:NumericUpDown DockPanel.Dock="Right" Background="Transparent" BorderThickness="0 0 0 0" Value="{Binding Value,UpdateSourceTrigger=PropertyChanged}" HasDecimals="True" HorizontalContentAlignment="Center" Width="100" /> + <TextBlock Text="{Binding Name}" VerticalAlignment="Center"></TextBlock> + </DockPanel> + </DataTemplate> + </editors:ParameterizedEditor.DoubleTemplate> + <editors:ParameterizedEditor.Int32Template> + <DataTemplate> + <DockPanel> + <mahApps:NumericUpDown DockPanel.Dock="Right" Background="Transparent" BorderThickness="0 0 0 0" Value="{Binding Value,Converter={StaticResource DoubleToIntConverter},UpdateSourceTrigger=PropertyChanged}" HasDecimals="False" HorizontalContentAlignment="Center" Width="100" /> + <TextBlock Text="{Binding Name}" VerticalAlignment="Center"></TextBlock> + </DockPanel> + </DataTemplate> + </editors:ParameterizedEditor.Int32Template> + <editors:ParameterizedEditor.BooleanTemplate> + <DataTemplate> + <DockPanel Margin="0 5 0 0"> + <ToggleButton DockPanel.Dock="Right" Width="100" IsChecked="{Binding Value}" HorizontalAlignment="Right" /> + <TextBlock Text="{Binding Name}" VerticalAlignment="Center"></TextBlock> + </DockPanel> + </DataTemplate> + </editors:ParameterizedEditor.BooleanTemplate> + </editors:ParameterizedEditor> + </GroupBox> + <GroupBox Header="COLOR" Margin="0 10 0 0"> <StackPanel> <Viewbox Margin="0 5 0 0"> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/DispenserItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/DispenserItem.cs index b0d4cb595..573e497d5 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/DispenserItem.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/DispenserItem.cs @@ -23,6 +23,26 @@ namespace Tango.MachineStudio.Technician.TechItems /// </summary> public event EventHandler<MotorActionType> ActionExecuted; + private static List<DispenserType> _dispenserTypes; + /// <summary> + /// Gets or sets the motor configurations. + /// </summary> + public static List<DispenserType> DispenserTypes + { + get { return _dispenserTypes; } + set { _dispenserTypes = value; } + } + + static DispenserItem() + { + DispenserTypes = new List<DispenserType>(); + + foreach (var techDispenser in BL.ObservablesEntitiesAdapter.Instance.TechDispensers) + { + DispenserTypes.Add(new DispenserType() { Code = int.Parse(techDispenser.Name.Replace("Dispenser", "")) - 1 }); + } + } + /// <summary> /// Occurs when dispenser homing has completed. /// </summary> @@ -36,7 +56,26 @@ namespace Tango.MachineStudio.Technician.TechItems public TechDispenser TechDispenser { get { return _techDispenser; } - set { _techDispenser = value; RaisePropertyChangedAuto(); TechName = _techDispenser != null ? _techDispenser.Description : null; ItemGuid = value != null ? value.Guid : null; } + set + { + _techDispenser = value; RaisePropertyChangedAuto(); TechName = _techDispenser != null ? _techDispenser.Description : null; ItemGuid = value != null ? value.Guid : null; + + if (_techDispenser != null) + { + DispenserType = DispenserTypes.SingleOrDefault(x => x.Code == int.Parse(_techDispenser.Name.Replace("Dispenser", "")) - 1); + } + } + } + + private DispenserType _dispenserType; + /// <summary> + /// Gets or sets the type of the dispenser. + /// </summary> + [XmlIgnore] + public DispenserType DispenserType + { + get { return _dispenserType; } + set { _dispenserType = value; RaisePropertyChangedAuto(); } } private bool _isHoming; @@ -119,6 +158,7 @@ namespace Tango.MachineStudio.Technician.TechItems Description = "Dispenser Controller"; Image = ResourceHelper.GetImageFromResources("Images/dispenser-big.png"); Color = Colors.White; + DispenserType = new DispenserType(); } /// <summary> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorGroupItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorGroupItem.cs index 8199dd11e..5cdb8017e 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorGroupItem.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorGroupItem.cs @@ -30,23 +30,23 @@ namespace Tango.MachineStudio.Technician.TechItems /// </summary> public event EventHandler HomingCompleted; - private SelectedObjectCollection<TechMotor> _selectedMotors; + private SelectedObjectCollection<HardwareMotorType> _selectedMotors; /// <summary> /// Gets or sets the selected db tech motors. /// </summary> [XmlIgnore] - public SelectedObjectCollection<TechMotor> SelectedMotors + public SelectedObjectCollection<HardwareMotorType> SelectedMotors { get { return _selectedMotors; } set { _selectedMotors = value; RaisePropertyChangedAuto(); } } - private ObservableCollection<TechMotor> _techMotors; + private ObservableCollection<HardwareMotorType> _techMotors; /// <summary> /// Gets or sets the available db tech motors. /// </summary> [XmlIgnore] - public ObservableCollection<TechMotor> TechMotors + public ObservableCollection<HardwareMotorType> TechMotors { get { return _techMotors; } set { _techMotors = value; RaisePropertyChangedAuto(); SetSelectedMotors(); } @@ -59,7 +59,7 @@ namespace Tango.MachineStudio.Technician.TechItems { if (TechMotors != null) { - SelectedMotors = new SelectedObjectCollection<TechMotor>(ObservablesEntitiesAdapter.Instance.TechMotors.ToObservableCollection(), TechMotors); + SelectedMotors = new SelectedObjectCollection<HardwareMotorType>(ObservablesEntitiesAdapter.Instance.HardwareMotorTypes.ToObservableCollection(), TechMotors); } } @@ -155,7 +155,7 @@ namespace Tango.MachineStudio.Technician.TechItems public MotorGroupItem() : base() { ItemsGuids = new List<string>(); - TechMotors = new ObservableCollection<TechMotor>(); + TechMotors = new ObservableCollection<HardwareMotorType>(); Name = "Motor Group"; Description = "Motor Group Controller"; Image = ResourceHelper.GetImageFromResources("Images/motor-group.png"); @@ -179,7 +179,7 @@ namespace Tango.MachineStudio.Technician.TechItems public override TechItem Clone() { MotorGroupItem cloned = base.Clone() as MotorGroupItem; - cloned.TechMotors = new ObservableCollection<TechMotor>(TechMotors); + cloned.TechMotors = new ObservableCollection<HardwareMotorType>(TechMotors); cloned.Speed = Speed; cloned.ItemsGuids = ItemsGuids; cloned.TechMotors = cloned.TechMotors.ToObservableCollection(); 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 index 294c137dc..2df926093 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorItem.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorItem.cs @@ -8,6 +8,7 @@ using System.Xml.Serialization; using Tango.Core.Commands; using Tango.BL.Entities; using Tango.SharedUI.Helpers; +using System.Collections.ObjectModel; namespace Tango.MachineStudio.Technician.TechItems { @@ -23,22 +24,62 @@ namespace Tango.MachineStudio.Technician.TechItems /// </summary> public event EventHandler<MotorActionType> ActionExecuted; + private static List<HardwareMotor> _motorConfigurations; + /// <summary> + /// Gets or sets the motor configurations. + /// </summary> + public static List<HardwareMotor> MotorConfigurations + { + get { return _motorConfigurations; } + set { _motorConfigurations = value; } + } + + static MotorItem() + { + MotorConfigurations = new List<HardwareMotor>(); + + foreach (var motorType in BL.ObservablesEntitiesAdapter.Instance.HardwareMotorTypes) + { + MotorConfigurations.Add(new HardwareMotor() { HardwareMotorType = motorType }); + } + } + /// <summary> /// Occurs when motor homing has completed. /// </summary> public event EventHandler HomingCompleted; - private TechMotor _techMotor; + private HardwareMotorType _hardwareMotorType; /// <summary> /// Gets or sets the db tech motor. /// </summary> [XmlIgnore] - public TechMotor TechMotor + public HardwareMotorType HardwareMotorType + { + get { return _hardwareMotorType; } + set + { + _hardwareMotorType = value; RaisePropertyChangedAuto(); TechName = _hardwareMotorType != null ? _hardwareMotorType.Description : null; ItemGuid = value != null ? value.Guid : null; + + if (_hardwareMotorType != null) + { + HardwareMotor = MotorConfigurations.SingleOrDefault(x => x.HardwareMotorType == _hardwareMotorType); + } + } + } + + private HardwareMotor _hardwareMotor; + /// <summary> + /// Gets or sets the hardware motor. + /// </summary> + [XmlIgnore] + public HardwareMotor HardwareMotor { - get { return _techMotor; } - set { _techMotor = value; RaisePropertyChangedAuto(); TechName = _techMotor != null ? _techMotor.Description : null; ItemGuid = value != null ? value.Guid : null; } + get { return _hardwareMotor; } + set { _hardwareMotor = value; RaisePropertyChangedAuto(); } } + private bool _isHoming; /// <summary> /// Gets or sets a value indicating whether the motor is currently homing. @@ -119,15 +160,16 @@ namespace Tango.MachineStudio.Technician.TechItems Description = "Motor Controller"; Image = ResourceHelper.GetImageFromResources("Images/engine.png"); Color = Colors.White; + HardwareMotor = new HardwareMotor(); } /// <summary> /// Initializes a new instance of the <see cref="MotorItem"/> class. /// </summary> /// <param name="techMotor">The tech motor.</param> - public MotorItem(TechMotor techMotor) : this() + public MotorItem(HardwareMotorType techMotor) : this() { - TechMotor = techMotor; + HardwareMotorType = techMotor; } /// <summary> @@ -137,7 +179,7 @@ namespace Tango.MachineStudio.Technician.TechItems public override TechItem Clone() { MotorItem cloned = base.Clone() as MotorItem; - cloned.TechMotor = TechMotor; + cloned.HardwareMotorType = HardwareMotorType; cloned.Speed = Speed; 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 91c80a41a..4cc1852a6 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 @@ -49,7 +49,6 @@ namespace Tango.MachineStudio.Technician.ViewModels private IEventLogger _eventLogger; private DateTime _lastDiagnosticsResponseUpdate; private const int MIN_DIAGNOSTICS_UPDATE_MILI = 500; - private bool _isViewLoaded; #region Properties @@ -458,7 +457,7 @@ namespace Tango.MachineStudio.Technician.ViewModels } else if (item is MotorItem) { - var editor = CreateElement<MotorElementEditor, MotorItem, TechMotor>(bounds, Adapter.TechMotors.FirstOrDefault()); + var editor = CreateElement<MotorElementEditor, MotorItem, HardwareMotorType>(bounds, Adapter.HardwareMotorTypes.FirstOrDefault()); InitMotorItem(editor.MotorItem); } else if (item is DispenserItem) @@ -552,7 +551,7 @@ namespace Tango.MachineStudio.Technician.ViewModels } else if (item is MotorItem) { - (item as MotorItem).TechMotor = Adapter.TechMotors.FirstOrDefault(x => x.Guid == item.ItemGuid); + (item as MotorItem).HardwareMotorType = Adapter.HardwareMotorTypes.FirstOrDefault(x => x.Guid == item.ItemGuid); var editor = CreateElement<MotorElementEditor>(item); InitMotorItem(editor.MotorItem); } @@ -709,7 +708,7 @@ namespace Tango.MachineStudio.Technician.ViewModels { await MachineOperator.StartMotorJogging(new MotorJoggingRequest() { - Code = item.TechMotor.Code, + Code = item.HardwareMotorType.Code, Direction = MotorDirection.Forward, }); } @@ -717,14 +716,14 @@ namespace Tango.MachineStudio.Technician.ViewModels { await MachineOperator.StopMotorJogging(new MotorAbortJoggingRequest() { - Code = item.TechMotor.Code, + Code = item.HardwareMotorType.Code, }); } else if (action == MotorActionType.BackwardPressed) { await MachineOperator.StartMotorJogging(new MotorJoggingRequest() { - Code = item.TechMotor.Code, + Code = item.HardwareMotorType.Code, Direction = MotorDirection.Backward, }); } @@ -732,7 +731,7 @@ namespace Tango.MachineStudio.Technician.ViewModels { await MachineOperator.StopMotorJogging(new MotorAbortJoggingRequest() { - Code = item.TechMotor.Code, + Code = item.HardwareMotorType.Code, }); } else if (action == MotorActionType.HomingStarted) @@ -743,7 +742,7 @@ namespace Tango.MachineStudio.Technician.ViewModels MachineOperator.StartMotorHoming(new MotorHomingRequest() { - Code = item.TechMotor.Code + Code = item.HardwareMotorType.Code }) .Subscribe((response) => { @@ -763,7 +762,7 @@ namespace Tango.MachineStudio.Technician.ViewModels { await MachineOperator.StopMotorHoming(new MotorAbortHomingRequest() { - Code = item.TechMotor.Code, + Code = item.HardwareMotorType.Code, }); item.IsHoming = false; @@ -1130,7 +1129,7 @@ namespace Tango.MachineStudio.Technician.ViewModels { if (item is MotorGroupItem) { - (item as MotorGroupItem).TechMotors = ObservablesEntitiesAdapter.Instance.TechMotors.Where(x => (item as MotorGroupItem).ItemsGuids.Contains(x.Guid)).ToObservableCollection(); + (item as MotorGroupItem).TechMotors = ObservablesEntitiesAdapter.Instance.HardwareMotorTypes.Where(x => (item as MotorGroupItem).ItemsGuids.Contains(x.Guid)).ToObservableCollection(); } AddTechItem(item); 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 53fcafb8f..6d4f3aefd 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 @@ -206,7 +206,7 @@ </ListBox> </StackPanel> - <StackPanel HorizontalAlignment="Right" Orientation="Horizontal" Margin="0 0 255 10" VerticalAlignment="Bottom"> + <StackPanel HorizontalAlignment="Right" Orientation="Horizontal" Margin="0 0 335 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" /> @@ -216,24 +216,13 @@ </ListBoxItem> </ListBox> </StackPanel> - - <Border HorizontalAlignment="Right" Width="220" Margin="10 0 5 8" BorderBrush="Gainsboro" BorderThickness="1 0 1 1" Padding="5"> - <Grid> - <StackPanel TextElement.FontSize="10" VerticalAlignment="Center" TextElement.Foreground="Gray"> - <TextBlock HorizontalAlignment="Center"><Run FontWeight="SemiBold" FontStyle="Italic">Version Name:</Run> <Run Text="{Binding MachineOperator.DeviceInformation.Name,FallbackValue='N/A'}"></Run></TextBlock> - <TextBlock HorizontalAlignment="Center" Margin="0 2 0 0"><Run FontWeight="SemiBold" FontStyle="Italic">Version Number:</Run> <Run Text="{Binding MachineOperator.DeviceInformation.Version,FallbackValue='N/A'}"></Run></TextBlock> - <TextBlock HorizontalAlignment="Center" Margin="0 2 0 0"><Run FontWeight="SemiBold" FontStyle="Italic">Build Date:</Run> <Run Text="{Binding MachineOperator.DeviceInformation.BuildDate,FallbackValue='N/A'}"></Run></TextBlock> - <TextBlock HorizontalAlignment="Center" Margin="0 2 0 0"><Run FontWeight="SemiBold" FontStyle="Italic">Diagnostics Frame Size:</Run> <Run Text="{Binding CurrentDiagnosticsResponseSize,Converter={StaticResource NumberToFileSizeConverter},FallbackValue='N/A'}"></Run></TextBlock> - </StackPanel> - </Grid> - </Border> </Grid> </Grid> <Grid Grid.Row="1" Margin="5"> <Grid.ColumnDefinitions> <ColumnDefinition Width="1*"/> - <ColumnDefinition Width="220"/> + <ColumnDefinition Width="300"/> </Grid.ColumnDefinitions> <Grid> @@ -321,84 +310,88 @@ <Grid Grid.Column="1"> <DockPanel> <TextBlock DockPanel.Dock="Top" Margin="0 -30 0 0" DataContext="{Binding ElementName=editor,Path=SelectedElement.HostedElement}" Text="{Binding TechName}" FontSize="16" FontWeight="Bold" FontStyle="Italic"></TextBlock> - <GroupBox DockPanel.Dock="Top" Header="BOUNDS" Padding="5"> + + <ScrollViewer VerticalScrollBarVisibility="Auto"> <StackPanel> - <!--Position--> - <UniformGrid Columns="2" Margin="0 5 0 0"> - <StackPanel Margin="0 0 5 0"> - <TextBlock>Left</TextBlock> - <mahapps:NumericUpDown HasDecimals="False" HorizontalContentAlignment="Center" BorderBrush="Gainsboro" Foreground="Gray" Margin="0 5 0 0" Minimum="0" Maximum="{Binding ElementName=editor,Path=EditorWidth}" Value="{Binding ElementName=editor,Path=SelectedElement.Left}"></mahapps:NumericUpDown> - </StackPanel> - <StackPanel Margin="5 0 0 0"> - <TextBlock>Top</TextBlock> - <mahapps:NumericUpDown HasDecimals="False" HorizontalContentAlignment="Center" BorderBrush="Gainsboro" Foreground="Gray" Margin="0 5 0 0" Minimum="0" Maximum="{Binding ElementName=editor,Path=EditorHeight}" Value="{Binding ElementName=editor,Path=SelectedElement.Top}"></mahapps:NumericUpDown> - </StackPanel> - </UniformGrid> + <GroupBox DockPanel.Dock="Top" Header="BOUNDS" Padding="5"> + <StackPanel> + <!--Position--> + <UniformGrid Columns="2" Margin="0 5 0 0"> + <StackPanel Margin="0 0 5 0"> + <TextBlock>Left</TextBlock> + <mahapps:NumericUpDown HasDecimals="False" HorizontalContentAlignment="Center" BorderBrush="Gainsboro" Foreground="Gray" Margin="0 5 0 0" Minimum="0" Maximum="{Binding ElementName=editor,Path=EditorWidth}" Value="{Binding ElementName=editor,Path=SelectedElement.Left}"></mahapps:NumericUpDown> + </StackPanel> + <StackPanel Margin="5 0 0 0"> + <TextBlock>Top</TextBlock> + <mahapps:NumericUpDown HasDecimals="False" HorizontalContentAlignment="Center" BorderBrush="Gainsboro" Foreground="Gray" Margin="0 5 0 0" Minimum="0" Maximum="{Binding ElementName=editor,Path=EditorHeight}" Value="{Binding ElementName=editor,Path=SelectedElement.Top}"></mahapps:NumericUpDown> + </StackPanel> + </UniformGrid> - <!--Size--> - <UniformGrid Columns="2" Margin="0 20 0 0"> - <StackPanel Margin="0 0 5 0"> - <TextBlock>Width</TextBlock> - <mahapps:NumericUpDown HasDecimals="False" HorizontalContentAlignment="Center" BorderBrush="Gainsboro" Foreground="Gray" Margin="0 5 0 0" Minimum="10" Maximum="{Binding ElementName=editor,Path=EditorWidth}" Value="{Binding ElementName=editor,Path=SelectedElement.Width}"></mahapps:NumericUpDown> - </StackPanel> - <StackPanel Margin="5 0 0 0"> - <TextBlock>Height</TextBlock> - <mahapps:NumericUpDown HasDecimals="False" HorizontalContentAlignment="Center" BorderBrush="Gainsboro" Foreground="Gray" Margin="0 5 0 0" Minimum="10" Maximum="{Binding ElementName=editor,Path=EditorHeight}" Value="{Binding ElementName=editor,Path=SelectedElement.Height}"></mahapps:NumericUpDown> + <!--Size--> + <UniformGrid Columns="2" Margin="0 20 0 0"> + <StackPanel Margin="0 0 5 0"> + <TextBlock>Width</TextBlock> + <mahapps:NumericUpDown HasDecimals="False" HorizontalContentAlignment="Center" BorderBrush="Gainsboro" Foreground="Gray" Margin="0 5 0 0" Minimum="10" Maximum="{Binding ElementName=editor,Path=EditorWidth}" Value="{Binding ElementName=editor,Path=SelectedElement.Width}"></mahapps:NumericUpDown> + </StackPanel> + <StackPanel Margin="5 0 0 0"> + <TextBlock>Height</TextBlock> + <mahapps:NumericUpDown HasDecimals="False" HorizontalContentAlignment="Center" BorderBrush="Gainsboro" Foreground="Gray" Margin="0 5 0 0" Minimum="10" Maximum="{Binding ElementName=editor,Path=EditorHeight}" Value="{Binding ElementName=editor,Path=SelectedElement.Height}"></mahapps:NumericUpDown> + </StackPanel> + </UniformGrid> + + <!--<Angle--> + <Grid Margin="0 20 0 0"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="22*"></ColumnDefinition> + <ColumnDefinition Width="20*"></ColumnDefinition> + </Grid.ColumnDefinitions> + <TextBlock VerticalAlignment="Center" Margin="0 0 10 0" HorizontalAlignment="Left">Angle</TextBlock> + <mahapps:NumericUpDown Grid.Column="1" HorizontalContentAlignment="Center" BorderBrush="Gainsboro" Foreground="Gray" Maximum="360" Minimum="-360" HasDecimals="False" Margin="0 5 0 0" Value="{Binding ElementName=editor,Path=SelectedElement.Angle}"></mahapps:NumericUpDown> + </Grid> </StackPanel> - </UniformGrid> + </GroupBox> + <ContentControl Margin="0 10 0 0" DataContext="{Binding ElementName=editor,Path=SelectedElement.HostedElement}" Content="{Binding ElementName=editor,Path=SelectedElement.HostedElement}"> + <ContentControl.Resources> + <DataTemplate DataType="{x:Type sys:Nullable}"> - <!--<Angle--> - <Grid Margin="0 20 0 0"> - <Grid.ColumnDefinitions> - <ColumnDefinition Width="22*"></ColumnDefinition> - <ColumnDefinition Width="20*"></ColumnDefinition> - </Grid.ColumnDefinitions> - <TextBlock VerticalAlignment="Center" Margin="0 0 10 0" HorizontalAlignment="Left">Angle</TextBlock> - <mahapps:NumericUpDown Grid.Column="1" HorizontalContentAlignment="Center" BorderBrush="Gainsboro" Foreground="Gray" Maximum="360" Minimum="-360" HasDecimals="False" Margin="0 5 0 0" Value="{Binding ElementName=editor,Path=SelectedElement.Angle}"></mahapps:NumericUpDown> - </Grid> + </DataTemplate> + <DataTemplate DataType="{x:Type items:ControllerItem}"> + <templates:ControllerTemplate/> + </DataTemplate> + <DataTemplate DataType="{x:Type items:MonitorItem}"> + <templates:MonitorTemplate/> + </DataTemplate> + <DataTemplate DataType="{x:Type items:DigitalInItem}"> + <templates:DigitalInTemplate/> + </DataTemplate> + <DataTemplate DataType="{x:Type items:MotorGroupItem}"> + <templates:MotorGroupTemplate/> + </DataTemplate> + <DataTemplate DataType="{x:Type items:ThreadMotionItem}"> + <templates:ThreadMotionTemplate/> + </DataTemplate> + <DataTemplate DataType="{x:Type items:DigitalOutItem}"> + <templates:DigitalOutTemplate/> + </DataTemplate> + <DataTemplate DataType="{x:Type items:DispenserItem}"> + <templates:DispenserTemplate/> + </DataTemplate> + <DataTemplate DataType="{x:Type items:MotorItem}"> + <templates:MotorTemplate/> + </DataTemplate> + <DataTemplate DataType="{x:Type items:MeterItem}"> + <templates:MeterTemplate/> + </DataTemplate> + <DataTemplate DataType="{x:Type items:SingleGraphItem}"> + <templates:SingleGraphTemplate/> + </DataTemplate> + <DataTemplate DataType="{x:Type items:MultiGraphItem}"> + <templates:MultiGraphTemplate/> + </DataTemplate> + </ContentControl.Resources> + </ContentControl> </StackPanel> - </GroupBox> - - <ContentControl Margin="0 10 0 0" DataContext="{Binding ElementName=editor,Path=SelectedElement.HostedElement}" Content="{Binding ElementName=editor,Path=SelectedElement.HostedElement}"> - <ContentControl.Resources> - <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> - <DataTemplate DataType="{x:Type items:DigitalInItem}"> - <templates:DigitalInTemplate/> - </DataTemplate> - <DataTemplate DataType="{x:Type items:MotorGroupItem}"> - <templates:MotorGroupTemplate/> - </DataTemplate> - <DataTemplate DataType="{x:Type items:ThreadMotionItem}"> - <templates:ThreadMotionTemplate/> - </DataTemplate> - <DataTemplate DataType="{x:Type items:DigitalOutItem}"> - <templates:DigitalOutTemplate/> - </DataTemplate> - <DataTemplate DataType="{x:Type items:DispenserItem}"> - <templates:DispenserTemplate/> - </DataTemplate> - <DataTemplate DataType="{x:Type items:MotorItem}"> - <templates:MotorTemplate/> - </DataTemplate> - <DataTemplate DataType="{x:Type items:MeterItem}"> - <templates:MeterTemplate/> - </DataTemplate> - <DataTemplate DataType="{x:Type items:SingleGraphItem}"> - <templates:SingleGraphTemplate/> - </DataTemplate> - <DataTemplate DataType="{x:Type items:MultiGraphItem}"> - <templates:MultiGraphTemplate/> - </DataTemplate> - </ContentControl.Resources> - </ContentControl> + </ScrollViewer> </DockPanel> </Grid> </Grid> |
