aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-09-20 17:35:49 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-09-20 17:35:49 +0300
commit1e5d6d1b458aa963e6ddcd9b15d692a274acd561 (patch)
treee529e531c8b3a8b37bbc9c1a2edb4a8b50572323 /Software/Visual_Studio/MachineStudio/Modules
parent7a113fa2131b107c644c07fc0a2e7f4bc17b218f (diff)
downloadTango-1e5d6d1b458aa963e6ddcd9b15d692a274acd561.tar.gz
Tango-1e5d6d1b458aa963e6ddcd9b15d692a274acd561.zip
Implemented Heater widget on tech board!
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/HeaterElementEditor.xaml148
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/HeaterElementEditor.xaml.cs8
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/temperature.pngbin0 -> 1827 bytes
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj3
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/HeaterItem.cs22
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs42
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml2
7 files changed, 220 insertions, 5 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/HeaterElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/HeaterElementEditor.xaml
index f72c5ad08..ca9f6140c 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/HeaterElementEditor.xaml
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/HeaterElementEditor.xaml
@@ -3,12 +3,13 @@
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:mahapps="http://metro.mahapps.com/winfx/xaml/controls"
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="1" MinHeight="1" RenderTransformOrigin="0.5,0.5" d:DataContext="{d:DesignInstance Type=items:HeaterItem, IsDesignTimeCreatable=False}" Height="99.188" Width="163.459">
+ mc:Ignorable="d" Background="Transparent" ClipToBounds="False" BorderThickness="0" MinWidth="1" MinHeight="1" RenderTransformOrigin="0.5,0.5" d:DataContext="{d:DesignInstance Type=items:HeaterItem, IsDesignTimeCreatable=False}" Height="284.188" Width="243.459">
<UserControl.Resources>
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"></converters:BoolToVisibilityConverter>
@@ -29,10 +30,151 @@
<!--Content-->
<Grid>
- <Image Source="../Images/blower-big.png"></Image>
+ <Viewbox>
+ <Border CornerRadius="5" Background="#151515" BorderBrush="#3B3B3B" BorderThickness="1" Padding="15">
+ <Grid>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="16"/>
+ <RowDefinition Height="74"/>
+ <RowDefinition Height="63"/>
+ <RowDefinition Height="37"/>
+ <RowDefinition/>
+ </Grid.RowDefinitions>
+
+ <Grid>
+ <TextBlock FontFamily="digital-7" Text="Heater Controller" FontSize="16" Foreground="#7CC924" HorizontalAlignment="Left" Width="123"></TextBlock>
+ <TextBlock HorizontalAlignment="Right" Text="TEMPERATURE" FontSize="9" VerticalAlignment="Bottom" Foreground="Gainsboro" Height="12" Width="58"></TextBlock>
+ </Grid>
+
+ <Grid Grid.Row="1">
+ <Border Background="#202020" Margin="0 3 0 0" CornerRadius="3" Padding="5">
+ <Grid>
+ <TextBlock Text="{Binding HeaterState.CurrentValue,StringFormat=0.0,FallbackValue='0.0'}" HorizontalAlignment="Right" VerticalAlignment="Center" FontSize="80" FontFamily="digital-7" Margin="0 0 12 0">
+ <TextBlock.Style>
+ <Style TargetType="TextBlock">
+ <Setter Property="Foreground" Value="#FF6F78"></Setter>
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding HeaterState.IsInSetPoint}" Value="True">
+ <Setter Property="Foreground" Value="#7CC924"></Setter>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </TextBlock.Style>
+ </TextBlock>
+ <TextBlock HorizontalAlignment="Right" VerticalAlignment="Bottom" FontSize="9" Foreground="Gainsboro">PV</TextBlock>
+ </Grid>
+ </Border>
+ </Grid>
+
+ <Grid Grid.Row="2" Margin="0 5 0 0">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="49"/>
+ <ColumnDefinition Width="162"/>
+ </Grid.ColumnDefinitions>
+
+ <Image Source="../Images/temperature.png" Margin="0 10 20 10" RenderOptions.BitmapScalingMode="Fant"></Image>
+
+ <Border Background="#202020" Margin="0 3 0 0" CornerRadius="3" Padding="5" Grid.Column="1">
+ <Grid>
+ <mahapps:NumericUpDown Style="{x:Null}" InterceptMouseWheel="True" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" HorizontalContentAlignment="Right" HideUpDownButtons="True" ScrollViewer.VerticalScrollBarVisibility="Disabled" ScrollViewer.HorizontalScrollBarVisibility="Disabled" HasDecimals="True" Minimum="0" Maximum="400" Padding="0" Value="{Binding SetPoint,FallbackValue='0.0',Mode=TwoWay}" VerticalAlignment="Center" FontSize="44" FontFamily="digital-7" Foreground="#FFD400" Margin="0 0 12 0">
+ <mahapps:NumericUpDown.Resources>
+ <Style TargetType="TextBox">
+
+ </Style>
+ </mahapps:NumericUpDown.Resources>
+ </mahapps:NumericUpDown>
+ <TextBlock HorizontalAlignment="Right" VerticalAlignment="Bottom" FontSize="9" Foreground="Gainsboro">SV</TextBlock>
+ </Grid>
+ </Border>
+ </Grid>
+
+ <Grid Grid.Row="3" Margin="0 5 0 0">
+ <StackPanel Orientation="Horizontal" TextElement.Foreground="Gray" TextElement.FontSize="9">
+ <StackPanel>
+ <TextBlock>ACTIVE</TextBlock>
+ <Ellipse Width="12" Height="12" Margin="0 4 0 0" Fill="#FF6262" Stroke="#526744">
+ <Ellipse.Style>
+ <Style TargetType="Ellipse">
+ <Setter Property="Opacity" Value="0.2"></Setter>
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding HeaterState.IsActive}" Value="True">
+ <Setter Property="Opacity" Value="1"></Setter>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </Ellipse.Style>
+ </Ellipse>
+ </StackPanel>
+
+ <StackPanel Margin="10 0 0 0">
+ <TextBlock>RAMP UP</TextBlock>
+ <Ellipse Width="12" Height="12" Margin="0 4 0 0" Fill="#FF8608" Stroke="#526744">
+ <Ellipse.Style>
+ <Style TargetType="Ellipse">
+ <Setter Property="Opacity" Value="0.2"></Setter>
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding HeaterState.IsRampingUp}" Value="True">
+ <Setter Property="Opacity" Value="1"></Setter>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </Ellipse.Style>
+ </Ellipse>
+ </StackPanel>
+
+ <StackPanel Margin="10 0 0 0">
+ <TextBlock>IN POINT</TextBlock>
+ <Ellipse Width="12" Height="12" Margin="0 4 0 0" Fill="#00C600" Stroke="#526744">
+ <Ellipse.Style>
+ <Style TargetType="Ellipse">
+ <Setter Property="Opacity" Value="0.2"></Setter>
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding HeaterState.IsInSetPoint}" Value="True">
+ <Setter Property="Opacity" Value="1"></Setter>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </Ellipse.Style>
+ </Ellipse>
+ </StackPanel>
+ </StackPanel>
+ </Grid>
+
+ <Grid Grid.Row="4">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="36"/>
+ <ColumnDefinition Width="175"/>
+ </Grid.ColumnDefinitions>
+
+ <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Gray" FontSize="16" FontWeight="SemiBold">ITC</TextBlock>
+
+ <Grid Grid.Column="1">
+ <Button Style="{x:Null}" Width="60" Height="60" HorizontalAlignment="Right" Cursor="Hand" Command="{Binding SetCommand}">
+ <Button.Template>
+ <ControlTemplate TargetType="Button">
+ <Grid>
+ <Ellipse Stroke="#7C7C7C" Fill="#383838"></Ellipse>
+ <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Gainsboro" FontSize="16" FontWeight="SemiBold">SET</TextBlock>
+ </Grid>
+ <ControlTemplate.Triggers>
+ <Trigger Property="IsPressed" Value="True">
+ <Setter Property="Opacity" Value="0.7"></Setter>
+ </Trigger>
+ <Trigger Property="IsEnabled" Value="False">
+ <Setter Property="Opacity" Value="0.5"></Setter>
+ </Trigger>
+ </ControlTemplate.Triggers>
+ </ControlTemplate>
+ </Button.Template>
+ </Button>
+ </Grid>
+ </Grid>
+ </Grid>
+ </Border>
+ </Viewbox>
<Border Margin="0 0 0 -23" VerticalAlignment="Bottom">
- <TextBlock Text="{Binding HardwareBlowerType.Description}" FontSize="14" Foreground="DimGray" HorizontalAlignment="Center"></TextBlock>
+ <TextBlock Text="{Binding TechHeater.Description}" FontSize="14" Foreground="DimGray" HorizontalAlignment="Center"></TextBlock>
</Border>
</Grid>
<!--Content-->
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/HeaterElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/HeaterElementEditor.xaml.cs
index b0b28454a..37d0defe5 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/HeaterElementEditor.xaml.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/HeaterElementEditor.xaml.cs
@@ -60,6 +60,9 @@ namespace Tango.MachineStudio.Technician.Editors
}
private HeaterItem _heaterItem;
+ /// <summary>
+ /// Gets or sets the heater item.
+ /// </summary>
public HeaterItem HeaterItem
{
get { return _heaterItem; }
@@ -98,5 +101,10 @@ namespace Tango.MachineStudio.Technician.Editors
{
get { return HeaterItem; }
}
+
+ private void Ellipse_GiveFeedback(object sender, GiveFeedbackEventArgs e)
+ {
+
+ }
}
}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/temperature.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/temperature.png
new file mode 100644
index 000000000..0bd30c002
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/temperature.png
Binary files differ
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 21fcf3e24..2a1660bcc 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
@@ -645,6 +645,9 @@
<ItemGroup>
<Resource Include="Images\heater-controller.png" />
</ItemGroup>
+ <ItemGroup>
+ <Resource Include="Images\temperature.png" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
<VisualStudio>
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/HeaterItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/HeaterItem.cs
index e1221e1f2..c1b876e9b 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/HeaterItem.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/HeaterItem.cs
@@ -6,6 +6,7 @@ using System.Threading.Tasks;
using System.Windows.Media;
using System.Xml.Serialization;
using Tango.BL.Entities;
+using Tango.Core.Commands;
using Tango.PMR.Diagnostics;
using Tango.SharedUI.Helpers;
@@ -18,6 +19,8 @@ namespace Tango.MachineStudio.Technician.TechItems
[TechItem(10)]
public class HeaterItem : TechItem
{
+ public event Action SetCommandClicked;
+
private TechHeater _techHeater;
/// <summary>
/// Gets or sets the db tech monitor.
@@ -28,6 +31,12 @@ namespace Tango.MachineStudio.Technician.TechItems
get { return _techHeater; }
set { _techHeater = value; RaisePropertyChangedAuto(); TechName = _techHeater != null ? _techHeater.Description : null; ItemGuid = value != null ? value.Guid : null; }
}
+
+ /// <summary>
+ /// Gets or sets the set command.
+ /// </summary>
+ public RelayCommand SetCommand { get; set; }
+
/// <summary>
/// Initializes a new instance of the <see cref="HeaterItem"/> class.
/// </summary>
@@ -37,6 +46,8 @@ namespace Tango.MachineStudio.Technician.TechItems
Color = Colors.White;
Description = "Heater Controller";
Image = ResourceHelper.GetImageFromResources("Images/heater-controller.png");
+ SetCommand = new RelayCommand(() => { SetCommandClicked?.Invoke(); }, (x) => HeaterState.CurrentValue != SetPoint);
+ HeaterState = new HeaterState();
}
/// <summary>
@@ -55,7 +66,16 @@ namespace Tango.MachineStudio.Technician.TechItems
public HeaterState HeaterState
{
get { return _heaterState; }
- set { _heaterState = value; RaisePropertyChangedAuto(); }
+ set
+ {
+ _heaterState = value;
+ RaisePropertyChangedAuto();
+
+ InvokeUI(() =>
+ {
+ SetCommand.RaiseCanExecuteChanged();
+ });
+ }
}
private double _setPoint;
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 6575bd53c..5f439e1ca 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
@@ -444,6 +444,17 @@ namespace Tango.MachineStudio.Technician.ViewModels
digitalInItem.Value = digitalPin.Value;
}
}
+ else if (item.GetType() == typeof(HeaterItem))
+ {
+ HeaterItem heaterItem = item as HeaterItem;
+
+ var heaterState = data.HeatersStates.SingleOrDefault(x => x.HeaterType == (HeaterType)heaterItem.TechHeater.Code);
+
+ if (heaterState != null)
+ {
+ heaterItem.HeaterState = heaterState;
+ }
+ }
else if (item.GetType() == typeof(ControllerItem))
{
ControllerItem controllerItem = item as ControllerItem;
@@ -557,6 +568,11 @@ namespace Tango.MachineStudio.Technician.ViewModels
{
CreateElement<MeterElementEditor, MeterItem, TechMonitor>(bounds, Adapter.TechMonitors.Where(x => !x.MultiChannel).FirstOrDefault());
}
+ else if (item is HeaterItem)
+ {
+ var editor = CreateElement<HeaterElementEditor, HeaterItem, TechHeater>(bounds, Adapter.TechHeaters.FirstOrDefault());
+ InitTechHeater(editor.HeaterItem);
+ }
else if (item is SingleGraphItem)
{
var editor = CreateElement<SingleGraphElementEditor, SingleGraphItem, TechMonitor>(bounds, Adapter.TechMonitors.Where(x => !x.MultiChannel).FirstOrDefault());
@@ -682,6 +698,11 @@ namespace Tango.MachineStudio.Technician.ViewModels
(item as MonitorItem).TechMonitor = Adapter.TechMonitors.Where(x => !x.MultiChannel).FirstOrDefault(x => x.Guid == item.ItemGuid);
CreateElement<MonitorElementEditor>(item);
}
+ else if (item is HeaterItem)
+ {
+ (item as HeaterItem).TechHeater = Adapter.TechHeaters.FirstOrDefault(x => x.Guid == item.ItemGuid);
+ CreateElement<HeaterElementEditor>(item);
+ }
else if (item is MeterItem)
{
(item as MeterItem).TechMonitor = Adapter.TechMonitors.Where(x => !x.MultiChannel).FirstOrDefault(x => x.Guid == item.ItemGuid);
@@ -895,6 +916,27 @@ namespace Tango.MachineStudio.Technician.ViewModels
#region Init Tech Items
/// <summary>
+ /// Initializes the tech heater.
+ /// </summary>
+ /// <param name="item">The item.</param>
+ private void InitTechHeater(HeaterItem item)
+ {
+ item.SetCommandClicked += async () =>
+ {
+ try
+ {
+ CheckMachineOperator();
+ await MachineOperator.SetHeaterState((HeaterType)item.TechHeater.Code, item.SetPoint);
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, $"Error executing SetHeaterState command for heater {item.TechHeater.Name}.");
+ _eventLogger.Log(ex, $"Error executing SetHeaterState command for heater {item.TechHeater.Name}.");
+ }
+ };
+ }
+
+ /// <summary>
/// Initializes the motor item.
/// </summary>
/// <param name="item">The item.</param>
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 3fe82944c..cbc296e32 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
@@ -202,7 +202,7 @@
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type techItems:TechItem}">
- <Border Cursor="Hand" ToolTip="{Binding Description}" RenderTransformOrigin="0.5,0.5" Width="60" Height="60" Padding="10" Margin="5" BorderThickness="1" CornerRadius="100">
+ <Border Cursor="Hand" ToolTip="{Binding Description}" RenderTransformOrigin="0.5,0.5" Width="55" Height="55" Padding="10" Margin="5" BorderThickness="1" CornerRadius="100">
<Border.Style>
<Style TargetType="Border">
<Setter Property="RenderTransform">