diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-07-15 17:58:46 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-07-15 17:58:46 +0300 |
| commit | b8566b704e0804239bcb58dfb90b32e5334ce446 (patch) | |
| tree | be58a5f0c37690b07a48db45e9b0fc498c680b58 /Software/Visual_Studio/MachineStudio/Modules | |
| parent | b90acacb7dbef7d088d57a200cc4d71148bffd1e (diff) | |
| download | Tango-b8566b704e0804239bcb58dfb90b32e5334ce446.tar.gz Tango-b8566b704e0804239bcb58dfb90b32e5334ce446.zip | |
Implemented JobRunner on Tech Board !.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules')
13 files changed, 769 insertions, 13 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/JobProgressToPositionConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/JobProgressToPositionConverter.cs index 4212c6908..93ede05c3 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/JobProgressToPositionConverter.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/JobProgressToPositionConverter.cs @@ -4,6 +4,7 @@ using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows; using System.Windows.Data; using Tango.BL.Entities; @@ -15,7 +16,7 @@ namespace Tango.MachineStudio.Developer.Converters { try { - if (values.Length == 3) + if (values.Length == 3 && values[1] != DependencyProperty.UnsetValue) { double length = System.Convert.ToDouble(values[0]); double progress = System.Convert.ToDouble(values[1]); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/JobRunnerElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/JobRunnerElementEditor.xaml new file mode 100644 index 000000000..c481f1e1b --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/JobRunnerElementEditor.xaml @@ -0,0 +1,280 @@ +<local:ElementEditor x:Class="Tango.MachineStudio.Technician.Editors.JobRunnerElementEditor" + 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:dispensing="clr-namespace:Tango.BL.Dispensing;assembly=Tango.BL" + xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:sys="clr-namespace:System;assembly=mscorlib" + 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" Background="Transparent" ClipToBounds="False" BorderThickness="0" MinWidth="200" MinHeight="200" RenderTransformOrigin="0.5,0.5" d:DataContext="{d:DesignInstance Type=items:JobRunnerItem, IsDesignTimeCreatable=False}" Height="100" Width="350"> + + <UserControl.Resources> + <converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"></converters:BoolToVisibilityConverter> + <sharedConverters:BooleanInverseConverter x:Key="BooleanInverseConverter" /> + <sharedConverters:ColorToIntegerConverter x:Key="ColorToIntegerConverter" /> + <sharedConverters:IsNotConverter x:Key="IsNotConverter" /> + <sharedConverters:EnumToItemsSourceConverter x:Key="EnumToItemsSourceConverter" /> + <sharedConverters:EnumToDescriptionConverter x:Key="EnumToDescriptionConverter" /> + + <Color x:Key="dummyColor">Transparent</Color> + + <ObjectDataProvider x:Key="dispenserDivisions" MethodName="GetValues" ObjectType="{x:Type sys:Enum}"> + <ObjectDataProvider.MethodParameters> + <x:Type TypeName="dispensing:DispenserStepDivisions"/> + </ObjectDataProvider.MethodParameters> + </ObjectDataProvider> + + <!--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}}"> + <Border Padding="10" BorderThickness="1" BorderBrush="#202020" Background="#88FFFFFF" CornerRadius="5"> + <DockPanel> + <TextBox Foreground="#202020" FontSize="14" DockPanel.Dock="Top" Text="{Binding Job.Name}"></TextBox> + <ItemsControl Margin="0 10 0 0" DockPanel.Dock="Top" ItemsSource="{Binding BrushStop.LiquidVolumes}" VerticalAlignment="Center"> + <ItemsControl.ItemsPanel> + <ItemsPanelTemplate> + <StackPanel VerticalAlignment="Center" Orientation="Horizontal" IsItemsHost="True"></StackPanel> + </ItemsPanelTemplate> + </ItemsControl.ItemsPanel> + <ItemsControl.ItemTemplate> + <DataTemplate> + <ContentControl Focusable="False" Width="60" Height="60" Margin="10 0 0 0" Style="{StaticResource numberBorder}"> + <ContentControl.Foreground> + <SolidColorBrush Color="{Binding IdsPack.LiquidType.Color,Converter={StaticResource ColorToIntegerConverter}}"></SolidColorBrush> + </ContentControl.Foreground> + <mahapps:NumericUpDown FontSize="16" FontFamily="{StaticResource digital-7}" HorizontalAlignment="Center" Value="{Binding Volume, Mode=TwoWay}" Background="Transparent" Width="40" StringFormat="0.00" HideUpDownButtons="True" Minimum="0" Maximum="1000" InterceptArrowKeys="True" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Center"> + + </mahapps:NumericUpDown> + </ContentControl> + </DataTemplate> + </ItemsControl.ItemTemplate> + </ItemsControl> + + <Grid DockPanel.Dock="Bottom"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="21*"/> + <ColumnDefinition Width="160"/> + </Grid.ColumnDefinitions> + + <ProgressBar Margin="0 0 10 0" VerticalAlignment="Bottom" Height="10" Minimum="0" Maximum="{Binding RunningJobStatus.TotalProgress}" Value="{Binding RunningJobStatus.Progress}"></ProgressBar> + + <TextBlock HorizontalAlignment="Right" VerticalAlignment="Top" Foreground="#202020" FontSize="14" Margin="0 0 10 0"> + <Run Text="{Binding RunningJobStatus.Progress,StringFormat=0.0}"></Run><Run Foreground="DodgerBlue" FontWeight="Bold">/</Run><Run Text="{Binding RunningJobStatus.TotalProgress,StringFormat=0.0}"></Run> + <Run Foreground="Gray">m</Run> + <Run></Run> + <Run Foreground="Gray">|</Run> + <Run></Run> + <Run Text="{Binding RunningJobStatus.RemainingTime,StringFormat='hh\\:mm\\:ss'}"></Run><Run Foreground="DodgerBlue" FontWeight="Bold">/</Run><Run Text="{Binding RunningJobStatus.TotalTime,StringFormat='hh\\:mm\\:ss'}"></Run> + </TextBlock> + + <Button Grid.Column="1" Height="40" Command="{Binding StartStopJobCommand}"> + <Button.Style> + <Style TargetType="Button" BasedOn="{StaticResource {x:Type Button}}"> + <Setter Property="Content" Value="START"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding IsJobStarted}" Value="True"> + <Setter Property="Content" Value="STOP"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </Button.Style> + </Button> + </Grid> + + <DataGrid Margin="0 10 0 0" ItemsSource="{Binding BrushStop.LiquidVolumes}" AutoGenerateColumns="False" IsSynchronizedWithCurrentItem="True" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="False" CanUserResizeColumns="False" CanUserResizeRows="False" CanUserSortColumns="False" Background="Transparent" SelectionUnit="FullRow"> + <DataGrid.CellStyle> + <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}"> + <Setter Property="BorderThickness" Value="0"/> + <Setter Property="FocusVisualStyle" Value="{x:Null}"/> + </Style> + </DataGrid.CellStyle> + <DataGrid.Columns> + <DataGridTemplateColumn Header="IDS PACK"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <Grid x:Name="t0"> + <Polygon x:Name="t1" Points="0,0 15,0 0,15 0,0" Margin="-15 -11 0 0"> + <Polygon.Fill> + <SolidColorBrush x:Name="t2" Color="{Binding IdsPack.LiquidType.Color,Converter={StaticResource ColorToIntegerConverter},FallbackValue={StaticResource dummyColor}}" /> + </Polygon.Fill> + </Polygon> + <TextBlock FontWeight="SemiBold" TextWrapping="Wrap" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding IdsPack.LiquidType.Name}"></TextBlock> + </Grid> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <DataGridTemplateColumn Header="D/F"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <TextBlock VerticalAlignment="Center"> + <Run Text="{Binding IdsPack.DispenserType.NlPerPulse,StringFormat='0.0'}"></Run> + <Run Text="(nl)" FontSize="9" Foreground="Gray"></Run> + </TextBlock> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <DataGridTemplateColumn Header="STEP"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <ComboBox ItemsSource="{Binding Source={StaticResource dispenserDivisions}}" SelectedItem="{Binding DispenserStepDivision,UpdateSourceTrigger=PropertyChanged}"> + <ComboBox.ItemContainerStyle> + <Style TargetType="ComboBoxItem" BasedOn="{StaticResource {x:Type ComboBoxItem}}"> + <Setter Property="Background" Value="#ECECEC"></Setter> + </Style> + </ComboBox.ItemContainerStyle> + <ComboBox.ItemTemplate> + <DataTemplate> + <TextBlock Text="{Binding Converter={StaticResource EnumToDescriptionConverter}}"></TextBlock> + </DataTemplate> + </ComboBox.ItemTemplate> + </ComboBox> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <DataGridTemplateColumn Header="MAX NL / CM"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <TextBlock VerticalAlignment="Center"> + <Run Text="{Binding LiquidMaxNanoliterPerCentimeter,Mode=OneWay,StringFormat='0.0'}"></Run> + <Run Text="(nl)" FontSize="9" Foreground="Gray"></Run> + </TextBlock> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <DataGridTemplateColumn Header="VOLUME"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <TextBlock VerticalAlignment="Center"> + <Run Text="{Binding Volume,StringFormat='0.0'}"></Run> + <Run Text="%" Foreground="Gray"></Run> + </TextBlock> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <DataGridTemplateColumn Header="FORMULA"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <TextBlock VerticalAlignment="Center"> + <Run Text="{Binding IdsPack.IdsPackFormula.Name}"></Run> + </TextBlock> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <DataGridTemplateColumn Header="NL / CM"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <TextBlock VerticalAlignment="Center"> + <Run Text="{Binding NanoliterPerCentimeter,Mode=OneWay,StringFormat='0.0'}"></Run> + <Run Text="(nl)" FontSize="9" Foreground="Gray"></Run> + </TextBlock> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <DataGridTemplateColumn Header="NL / SEC"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <TextBlock VerticalAlignment="Center"> + <Run Text="{Binding NanoliterPerSecond,Mode=OneWay,StringFormat='0.0'}"></Run> + <Run Text="(nl)" FontSize="9" Foreground="Gray"></Run> + </TextBlock> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <DataGridTemplateColumn Header="PULSE / SEC"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <Label VerticalAlignment="Center"> + <Label.Style> + <Style TargetType="Label"> + <Setter Property="Content"> + <Setter.Value> + <TextBlock> + <Run Text="{Binding PulsePerSecond,Mode=OneWay,StringFormat='0.0'}"></Run> + <Run Text="(pulse)" FontSize="9" Foreground="Gray"></Run> + </TextBlock> + </Setter.Value> + </Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding DispenserStepDivision}" Value="{x:Static dispensing:DispenserStepDivisions.Auto}"> + <Setter Property="Content" Value="Auto"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding DispenserStepDivision,Converter={StaticResource IsNotConverter},ConverterParameter={x:Static dispensing:DispenserStepDivisions.Auto}}" Value="True"> + <Setter Property="Content"> + <Setter.Value> + <TextBlock> + <Run Text="{Binding PulsePerSecond,Mode=OneWay,StringFormat='0.0'}"></Run> + <Run Text="(pulse)" FontSize="9" Foreground="Gray"></Run> + </TextBlock> + </Setter.Value> + </Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </Label.Style> + </Label> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + </DataGrid.Columns> + </DataGrid> + </DockPanel> + </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/JobRunnerElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/JobRunnerElementEditor.xaml.cs new file mode 100644 index 000000000..1daf2f6ca --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/JobRunnerElementEditor.xaml.cs @@ -0,0 +1,103 @@ +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; +using Tango.Core; + +namespace Tango.MachineStudio.Technician.Editors +{ + [ContentProperty("InnerContent")] + public partial class JobRunnerElementEditor : ElementEditor + { + /// <summary> + /// Initializes a new instance of the <see cref="JobRunnerElementEditor"/> class. + /// </summary> + public JobRunnerElementEditor() + : base() + { + InitializeComponent(); + } + + /// <summary> + /// Initializes a new instance of the <see cref="JobRunnerElementEditor"/> class. + /// </summary> + /// <param name="frameworkElement">The framework element.</param> + public JobRunnerElementEditor(JobRunnerItem jobRunnerItem) + : this() + { + JobRunnerItem = jobRunnerItem; + DataContext = JobRunnerItem; + } + + /// <summary> + /// Initializes a new instance of the <see cref="JobRunnerElementEditor"/> class. + /// </summary> + /// <param name="frameworkElement">The framework element.</param> + /// <param name="bounds">The bounds.</param> + public JobRunnerElementEditor(JobRunnerItem jobRunnerItem, Rect bounds) + : this(jobRunnerItem) + { + Left = bounds.Left; + Top = bounds.Top; + Width = bounds.Width; + Height = bounds.Height; + } + + private JobRunnerItem _jobRunnerItem; + + public JobRunnerItem JobRunnerItem + { + get { return _jobRunnerItem; } + set { _jobRunnerItem = value; RaisePropertyChanged(nameof(JobRunnerItem)); } + } + + + /// <summary> + /// Clones this instance. + /// </summary> + /// <returns></returns> + public override IElementEditor Clone() + { + try + { + var clonedItem = JobRunnerItem.Clone() as JobRunnerItem; + JobRunnerElementEditor cloned = new JobRunnerElementEditor(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 JobRunnerItem; } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ProcessParametersElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ProcessParametersElementEditor.xaml index c1a76fe8a..716ac0a2d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ProcessParametersElementEditor.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ProcessParametersElementEditor.xaml @@ -38,7 +38,7 @@ <SolidColorBrush Color="{Binding Color}"></SolidColorBrush> </Border.BorderBrush> <DockPanel> - <TextBox DockPanel.Dock="Top" FontSize="12" Foreground="#202020" Text="{Binding DisplayName}"></TextBox> + <TextBox DockPanel.Dock="Top" FontSize="12" Foreground="#202020" Text="{Binding ProcessParameters.Name}"></TextBox> <Button DockPanel.Dock="Bottom" Margin="0 10 0 0" Height="40" Command="{Binding PushParametersCommand}"> <StackPanel Orientation="Horizontal"> <TextBlock Margin="0 0 10 0">PUSH PARAMETERS</TextBlock> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/rgb-big.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/rgb-big.png Binary files differnew file mode 100644 index 000000000..cee14ae53 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/rgb-big.png diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/JobRunnerTemplate.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/JobRunnerTemplate.xaml new file mode 100644 index 000000000..4de0bff14 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/JobRunnerTemplate.xaml @@ -0,0 +1,78 @@ +<UserControl x:Class="Tango.MachineStudio.Technician.PropertiesTemplates.JobRunnerTemplate" + 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:sharedConverters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" + xmlns:items="clr-namespace:Tango.MachineStudio.Technician.TechItems" + xmlns:editors="clr-namespace:Tango.SharedUI.Editors;assembly=Tango.SharedUI" + xmlns:mahApps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" + 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:JobRunnerItem, IsDesignTimeCreatable=False}"> + + <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="Margin" Value="2" /> + </Style> + </UserControl.Resources> + + <Grid> + <StackPanel> + <GroupBox Header="JOB RUNNER"> + <StackPanel> + <TextBlock FontSize="10">Machine</TextBlock> + <ComboBox Margin="0 5 0 0" ItemsSource="{Binding Adapter.MachinesViewSource}" SelectedItem="{Binding Machine,Mode=TwoWay}"> + <ComboBox.ItemTemplate> + <DataTemplate> + <StackPanel Margin="0 5"> + <TextBlock Text="{Binding Name}"></TextBlock> + <TextBlock Margin="0 5 0 0" Text="{Binding SerialNumber}" Foreground="Gray"></TextBlock> + </StackPanel> + </DataTemplate> + </ComboBox.ItemTemplate> + </ComboBox> + + <TextBlock FontSize="10" Margin="0 10 0 0" >RML</TextBlock> + <ComboBox Margin="0 5 0 0" ItemsSource="{Binding Adapter.RmlsViewSource}" SelectedItem="{Binding Rml,Mode=TwoWay}" DisplayMemberPath="Name" /> + + <TextBlock Margin="0 10 0 0" FontSize="10">Process Parameters</TextBlock> + <ComboBox Margin="0 5 0 0" ItemsSource="{x:Static items:ProcessParametersItem.ProcessParametersTables}" SelectedItem="{Binding ProcessParameters,Mode=TwoWay}" DisplayMemberPath="Name" /> + </StackPanel> + </GroupBox> + + <GroupBox Header="JOB PROPERTIES" Margin="0 10 0 0"> + <controls:TableGrid RowHeight="40"> + + <TextBlock>Length</TextBlock> + <mahApps:NumericUpDown HasDecimals="True" HorizontalContentAlignment="Center" BorderBrush="Gainsboro" Foreground="Gray" Margin="0 5 0 0" Minimum="1" Maximum="1000" Value="{Binding Segment.Length}"></mahApps:NumericUpDown> + + <TextBlock>Winding Method</TextBlock> + <ComboBox ItemsSource="{Binding Adapter.WindingMethods}" SelectedValue="{Binding Job.WindingMethod}" DisplayMemberPath="Name"></ComboBox> + + <TextBlock>Spool Type</TextBlock> + <ComboBox ItemsSource="{Binding Adapter.SpoolTypes}" SelectedValue="{Binding Job.SpoolType}" DisplayMemberPath="Name"></ComboBox> + + <TextBlock>Enable Inter Segment</TextBlock> + <ToggleButton IsChecked="{Binding Job.EnableInterSegment}" HorizontalAlignment="Right" /> + + <TextBlock>Inter Segment Length</TextBlock> + <mahApps:NumericUpDown HasDecimals="True" HorizontalContentAlignment="Center" BorderBrush="Gainsboro" Foreground="Gray" Margin="0 5 0 0" Minimum="1" Maximum="1000" Value="{Binding Job.InterSegmentLength}"></mahApps:NumericUpDown> + + <TextBlock>Number of Units</TextBlock> + <mahApps:NumericUpDown HasDecimals="True" HorizontalContentAlignment="Center" BorderBrush="Gainsboro" Foreground="Gray" Margin="0 5 0 0" Minimum="1" Maximum="1000" Value="{Binding Job.NumberOfUnits}"></mahApps:NumericUpDown> + + <TextBlock>Enable Lubrication</TextBlock> + <ToggleButton IsChecked="{Binding Job.EnableLubrication}" HorizontalAlignment="Right" /> + </controls:TableGrid> + </GroupBox> + </StackPanel> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/JobRunnerTemplate.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/JobRunnerTemplate.xaml.cs new file mode 100644 index 000000000..36203fb54 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/JobRunnerTemplate.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 JobRunnerTemplate : UserControl + { + public JobRunnerTemplate() + { + 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 4c596e21e..d358edae8 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 @@ -96,6 +96,9 @@ <Compile Include="Editors\ControllerElementEditor.xaml.cs"> <DependentUpon>ControllerElementEditor.xaml</DependentUpon> </Compile> + <Compile Include="Editors\JobRunnerElementEditor.xaml.cs"> + <DependentUpon>JobRunnerElementEditor.xaml</DependentUpon> + </Compile> <Compile Include="Editors\ProcessParametersElementEditor.xaml.cs"> <DependentUpon>ProcessParametersElementEditor.xaml</DependentUpon> </Compile> @@ -143,6 +146,9 @@ </Compile> <Compile Include="Helpers\GraphsHelper.cs" /> <Compile Include="Project\MachineTechViewProject.cs" /> + <Compile Include="PropertiesTemplates\JobRunnerTemplate.xaml.cs"> + <DependentUpon>JobRunnerTemplate.xaml</DependentUpon> + </Compile> <Compile Include="PropertiesTemplates\DigitalInTemplate.xaml.cs"> <DependentUpon>DigitalInTemplate.xaml</DependentUpon> </Compile> @@ -194,6 +200,7 @@ <Compile Include="TechItems\ControllerItem.cs" /> <Compile Include="TechItems\DigitalInItem.cs" /> <Compile Include="TechItems\DigitalOutItem.cs" /> + <Compile Include="TechItems\JobRunnerItem.cs" /> <Compile Include="TechItems\MeterItem.cs" /> <Compile Include="TechItems\MotorActionType.cs" /> <Compile Include="TechItems\DispenserItem.cs" /> @@ -221,6 +228,10 @@ <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </Page> + <Page Include="Editors\JobRunnerElementEditor.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> <Page Include="Editors\ProcessParametersElementEditor.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> @@ -281,6 +292,10 @@ <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </Page> + <Page Include="PropertiesTemplates\JobRunnerTemplate.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> <Page Include="PropertiesTemplates\DigitalInTemplate.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> @@ -541,5 +556,8 @@ <ItemGroup> <Resource Include="Images\process-params.png" /> </ItemGroup> + <ItemGroup> + <Resource Include="Images\rgb-big.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/JobRunnerItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/JobRunnerItem.cs new file mode 100644 index 000000000..562491630 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/JobRunnerItem.cs @@ -0,0 +1,188 @@ +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.BL.Enumerations; +using Tango.Core.Commands; +using Tango.Integration.Operation; +using Tango.SharedUI.Helpers; + +namespace Tango.MachineStudio.Technician.TechItems +{ + [TechItem(21)] + public class JobRunnerItem : TechItem + { + public event Action StartJob; + public event Action StopJob; + + private Job _job; + /// <summary> + /// Gets or sets the job. + /// </summary> + [XmlIgnore] + public Job Job + { + get { return _job; } + set { _job = value; RaisePropertyChangedAuto(); } + } + + private Segment _segment; + /// <summary> + /// Gets or sets the segment. + /// </summary> + [XmlIgnore] + public Segment Segment + { + get { return _segment; } + set { _segment = value; RaisePropertyChangedAuto(); } + } + + private BrushStop _brushStop; + /// <summary> + /// Gets or sets the brush stop. + /// </summary> + [XmlIgnore] + public BrushStop BrushStop + { + get { return _brushStop; } + set { _brushStop = value; RaisePropertyChangedAuto(); } + } + + private Machine _machine; + /// <summary> + /// Gets or sets the machine. + /// </summary> + [XmlIgnore] + public Machine Machine + { + get { return _machine; } + set { _machine = value; RaisePropertyChangedAuto(); Init(); StartStopJobCommand.RaiseCanExecuteChanged(); } + } + + private ProcessParametersTable _processParameters; + /// <summary> + /// Gets or sets the process parameters. + /// </summary> + [XmlIgnore] + public ProcessParametersTable ProcessParameters + { + get { return _processParameters; } + set { _processParameters = value; RaisePropertyChangedAuto(); Init(); StartStopJobCommand.RaiseCanExecuteChanged(); } + } + + private Rml _rml; + /// <summary> + /// Gets or sets the RML. + /// </summary> + [XmlIgnore] + public Rml Rml + { + get { return _rml; } + set { _rml = value; RaisePropertyChangedAuto(); Init(); StartStopJobCommand.RaiseCanExecuteChanged(); } + } + + private RunningJobStatus _runningJobStatus; + /// <summary> + /// Gets or sets the running job status. + /// </summary> + [XmlIgnore] + public RunningJobStatus RunningJobStatus + { + get { return _runningJobStatus; } + set { _runningJobStatus = value; RaisePropertyChangedAuto(); } + } + + private bool _isJobStarted; + [XmlIgnore] + public bool IsJobStarted + { + get { return _isJobStarted; } + set { _isJobStarted = value; RaisePropertyChangedAuto(); } + } + + /// <summary> + /// Gets or sets the start stop job command. + /// </summary> + [XmlIgnore] + public RelayCommand StartStopJobCommand { get; set; } + + [XmlIgnore] + public JobHandler JobHandler { get; set; } + + /// <summary> + /// Initializes a new instance of the <see cref="JobRunnerItem"/> class. + /// </summary> + public JobRunnerItem() : base() + { + StartStopJobCommand = new RelayCommand(StartStopJob, (x) => Job != null && Segment != null && BrushStop != null && Machine != null && Rml != null && ProcessParameters != null); + + Job = new Job(); + Job.WindingMethod = Adapter.WindingMethods.FirstOrDefault(); + Job.SpoolType = Adapter.SpoolTypes.FirstOrDefault(); + Job.JobType = JobTypes.Sewing; + + Segment = Job.AddSolidSegment(); + BrushStop = Segment.AddBrushStop(); + BrushStop.ColorSpace = Adapter.ColorSpaces.SingleOrDefault(x => x.Code == ColorSpaces.Volume.ToInt32()); + + Name = "Job Runner"; + Description = "Job Runner"; + Image = ResourceHelper.GetImageFromResources("Images/rgb-big.png"); + } + + private void StartStopJob() + { + if (!IsJobStarted) + { + IsJobStarted = true; + StartJob?.Invoke(); + } + else + { + StopJob?.Invoke(); + } + } + + /// <summary> + /// Initializes the specified configuration. + /// </summary> + /// <param name="configuration">The configuration.</param> + /// <param name="rml">The RML.</param> + /// <param name="processParameters">The process parameters.</param> + public void Init() + { + if (Machine != null && Rml != null && ProcessParameters != null && BrushStop != null) + { + Job.Machine = Machine; + Job.Rml = Rml; + BrushStop.SetLiquidVolumes(Machine.Configuration, Rml, ProcessParameters); + } + } + + /// <summary> + /// Initializes a new instance of the <see cref="JobRunnerItem"/> class. + /// </summary> + /// <param name="job">The job.</param> + public JobRunnerItem(Job job) : this() + { + + } + + /// <summary> + /// Clones this instance. + /// </summary> + /// <returns></returns> + public override TechItem Clone() + { + JobRunnerItem cloned = base.Clone() as JobRunnerItem; + cloned.Job = Job.Clone(); + cloned.Segment = cloned.Job.Segments.First(); + cloned.BrushStop = cloned.Job.Segments.First().BrushStops.First(); + return cloned; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/ProcessParametersItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/ProcessParametersItem.cs index a6d3ae8f0..79aea7a0c 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/ProcessParametersItem.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/ProcessParametersItem.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -18,6 +19,13 @@ namespace Tango.MachineStudio.Technician.TechItems [TechItem(20)] public class ProcessParametersItem : TechItem { + public static ObservableCollection<ProcessParametersTable> ProcessParametersTables { get; set; } + + static ProcessParametersItem() + { + ProcessParametersTables = new ObservableCollection<ProcessParametersTable>(); + } + public class ParameterIndex { public String Name { get; set; } @@ -28,16 +36,6 @@ namespace Tango.MachineStudio.Technician.TechItems public event EventHandler<ProcessParametersTable> PushParametersPressed; - private String _displayName; - /// <summary> - /// Gets or sets the display name. - /// </summary> - public String DisplayName - { - get { return _displayName; } - set { _displayName = value; RaisePropertyChangedAuto(); } - } - private ProcessParametersTable _processParameters; /// <summary> /// Gets or sets the process parameters. @@ -83,15 +81,20 @@ namespace Tango.MachineStudio.Technician.TechItems public ProcessParametersItem() : base() { ParametersIndices = new List<ParameterIndex>(); - DisplayName = "Process parameters " + _counter++; Name = "Process Parameters"; Description = "Process parameters table"; Image = ResourceHelper.GetImageFromResources("Images/process-params.png"); ProcessParameters = new ProcessParametersTable(); + ProcessParameters.Name = "Process parameters " + _counter++; Color = Colors.DodgerBlue; PushParametersCommand = new RelayCommand(() => PushParametersPressed?.Invoke(this, ProcessParameters)); ResetToRMLCommand = new RelayCommand(ResetToRml, () => SelectedResetRML != null); + + if (_counter > 1) + { + ProcessParametersTables.Add(ProcessParameters); + } } private void ResetToRml() 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 ff75c1644..a1aba597b 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 @@ -35,6 +35,7 @@ namespace Tango.MachineStudio.Technician.TechItems [XmlInclude(typeof(DancerItem))] [XmlInclude(typeof(SpeedSensorItem))] [XmlInclude(typeof(ProcessParametersItem))] + [XmlInclude(typeof(JobRunnerItem))] 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 41fff94d9..7c2acfdbb 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 @@ -540,6 +540,11 @@ namespace Tango.MachineStudio.Technician.ViewModels var editor = CreateElement<ProcessParametersElementEditor, ProcessParametersItem, object>(bounds, null); InitProcessParameterItem(editor.ProcessParametersItem); } + else if (item is JobRunnerItem) + { + var editor = CreateElement<JobRunnerElementEditor, JobRunnerItem, object>(bounds, null); + InitJobRunnerItem(editor.JobRunnerItem); + } } /// <summary> @@ -664,6 +669,11 @@ namespace Tango.MachineStudio.Technician.ViewModels var editor = CreateElement<ProcessParametersElementEditor>(item); InitProcessParameterItem(editor.ProcessParametersItem); } + else if (item is JobRunnerItem) + { + var editor = CreateElement<JobRunnerElementEditor>(item); + InitJobRunnerItem(editor.JobRunnerItem); + } } /// <summary> @@ -1183,6 +1193,49 @@ namespace Tango.MachineStudio.Technician.ViewModels } /// <summary> + /// Initializes the job runner item. + /// </summary> + /// <param name="item">The item.</param> + /// <exception cref="NotImplementedException"></exception> + private void InitJobRunnerItem(JobRunnerItem item) + { + item.StartJob += () => + { + try + { + CheckMachineOperator(); + + var handler = MachineOperator.Print(item.Job, item.ProcessParameters); + + item.JobHandler = handler; + + handler.StatusChanged += (x, status) => + { + item.RunningJobStatus = status; + }; + + handler.Stopped += (x,e) => + { + item.IsJobStarted = false; + }; + } + catch (Exception ex) + { + _notification.ShowError(ex.Message); + } + }; + + item.StopJob += () => + { + if (item.JobHandler != null) + { + item.JobHandler.Cancel(); + item.JobHandler = null; + } + }; + } + + /// <summary> /// Checks the machine operator. /// </summary> /// <exception cref="InvalidOperationException">No machine connected.</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 5807341b7..29ba98cd3 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 @@ -377,6 +377,9 @@ <DataTemplate DataType="{x:Type sys:Nullable}"> </DataTemplate> + <DataTemplate DataType="{x:Type items:JobRunnerItem}"> + <templates:JobRunnerTemplate/> + </DataTemplate> <DataTemplate DataType="{x:Type items:ProcessParametersItem}"> <templates:ProcessParametersTemplate/> </DataTemplate> |
