aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-03-30 19:31:46 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-03-30 19:31:46 +0300
commitdcfafe05ed0276274c30f40595decb19b05c284d (patch)
tree0cb718b6795da5c3d8a291826990f878ab9c5b82 /Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance
parent19683a5a6047e822395f56412d263dc765df82fa (diff)
downloadTango-dcfafe05ed0276274c30f40595decb19b05c284d.tar.gz
Tango-dcfafe05ed0276274c30f40595decb19b05c284d.zip
Implemented PPC head cleaning.
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance')
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Dialogs/HeadCleaningView.xaml56
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Dialogs/HeadCleaningView.xaml.cs28
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Dialogs/HeadCleaningViewVM.cs150
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Images/head_cleaning.pngbin0 -> 44260 bytes
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Tango.PPC.Maintenance.csproj14
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/ViewModels/MaintenanceViewVM.cs10
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Views/MaintenanceView.xaml2
7 files changed, 258 insertions, 2 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Dialogs/HeadCleaningView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Dialogs/HeadCleaningView.xaml
new file mode 100644
index 000000000..f640d5cec
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Dialogs/HeadCleaningView.xaml
@@ -0,0 +1,56 @@
+<UserControl x:Class="Tango.PPC.Maintenance.Dialogs.HeadCleaningView"
+ 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:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch"
+ xmlns:local="clr-namespace:Tango.PPC.Maintenance.Dialogs"
+ mc:Ignorable="d"
+ Background="{StaticResource TangoPrimaryBackgroundBrush}" d:DesignHeight="555" d:DesignWidth="560" Width="600" Height="800" d:DataContext="{d:DesignInstance Type=local:HeadCleaningViewVM, IsDesignTimeCreatable=False}">
+ <Grid>
+ <StackPanel Margin="0 50 0 0" HorizontalAlignment="Center">
+ <Image Source="../Images/head_cleaning.png" RenderOptions.BitmapScalingMode="Fant" Stretch="Uniform" Height="120"></Image>
+ <TextBlock HorizontalAlignment="Center" FontSize="{StaticResource TangoTitleFontSize}" Margin="0 30 0 0">Head Cleaning</TextBlock>
+
+ <TextBlock Margin="20 10" HorizontalAlignment="Center" TextWrapping="Wrap" TextAlignment="Center">
+ <TextBlock.Style>
+ <Style TargetType="TextBlock">
+ <Setter Property="Text" Value="Press 'START' to start the head cleaning sequence"></Setter>
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding IsStarted}" Value="True">
+ <Setter Property="Text" Value="Head cleaning in progress"></Setter>
+ </DataTrigger>
+ <DataTrigger Binding="{Binding IsAborting}" Value="True">
+ <Setter Property="Text" Value="Aborting head cleaning"></Setter>
+ </DataTrigger>
+ <DataTrigger Binding="{Binding IsCompleted}" Value="True">
+ <Setter Property="Text" Value="Head cleaning completed"></Setter>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </TextBlock.Style>
+ </TextBlock>
+
+ <Grid>
+ <touch:TouchButton Visibility="{Binding IsStarted,Converter={StaticResource BooleanToVisibilityInverseConverter}}" Command="{Binding StartCommand}" Margin="0 100 0 0" Style="{StaticResource TangoHollowButton}" HorizontalAlignment="Center" Padding="80 15" CornerRadius="25">START</touch:TouchButton>
+ <touch:TouchButton Visibility="{Binding IsStarted,Converter={StaticResource BooleanToVisibilityConverter}}" IsEnabled="{Binding IsAborting,Converter={StaticResource BooleanInverseConverter}}" Command="{Binding AbortCommand}" Margin="0 100 0 0" Style="{StaticResource TangoHollowButton}" HorizontalAlignment="Center" Padding="80 15" CornerRadius="25">ABORT</touch:TouchButton>
+ </Grid>
+
+ <StackPanel Margin="40">
+ <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding Status.Status}"></TextBlock>
+ <touch:TouchProgressBar Margin="0 20 0 0" VerticalAlignment="Bottom" Width="500" Height="10" Minimum="0" Maximum="{Binding Status.Total}" Value="{Binding Status.Progress}">
+ <touch:TouchProgressBar.Style>
+ <Style TargetType="touch:TouchProgressBar" BasedOn="{StaticResource {x:Type touch:TouchProgressBar}}">
+ <Setter Property="IsIndeterminate" Value="False"></Setter>
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding Status.Progress}" Value="0">
+ <Setter Property="IsIndeterminate" Value="True"></Setter>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </touch:TouchProgressBar.Style>
+ </touch:TouchProgressBar>
+ </StackPanel>
+ </StackPanel>
+ </Grid>
+</UserControl>
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Dialogs/HeadCleaningView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Dialogs/HeadCleaningView.xaml.cs
new file mode 100644
index 000000000..c715bf5cf
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Dialogs/HeadCleaningView.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.PPC.Maintenance.Dialogs
+{
+ /// <summary>
+ /// Interaction logic for PowerUpView.xaml
+ /// </summary>
+ public partial class HeadCleaningView : UserControl
+ {
+ public HeadCleaningView()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Dialogs/HeadCleaningViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Dialogs/HeadCleaningViewVM.cs
new file mode 100644
index 000000000..59d119f21
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Dialogs/HeadCleaningViewVM.cs
@@ -0,0 +1,150 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Timers;
+using Tango.BL.Entities;
+using Tango.Core.Commands;
+using Tango.Core.DI;
+using Tango.Integration.Operation;
+using Tango.PMR.Printing;
+using Tango.PPC.Common;
+using Tango.PPC.Common.Connection;
+using Tango.PPC.Common.Notifications;
+using Tango.Settings;
+using Tango.SharedUI;
+
+namespace Tango.PPC.Maintenance.Dialogs
+{
+ public class HeadCleaningViewVM : DialogViewVM
+ {
+ private HeadCleaningHandler _handler;
+
+ [TangoInject]
+ private IMachineProvider MachineProvider { get; set; }
+
+ [TangoInject]
+ private INotificationProvider NotificationProvider { get; set; }
+
+ private bool _isStarted;
+ public bool IsStarted
+ {
+ get { return _isStarted; }
+ set { _isStarted = value; RaisePropertyChangedAuto(); }
+ }
+
+ private bool _isCompleted;
+ public bool IsCompleted
+ {
+ get { return _isCompleted; }
+ set { _isCompleted = value; RaisePropertyChangedAuto(); }
+ }
+
+ private bool _isAborting;
+ public bool IsAborting
+ {
+ get { return _isAborting; }
+ set { _isAborting = value; RaisePropertyChangedAuto(); }
+ }
+
+ private bool _isFailed;
+ public bool IsFailed
+ {
+ get { return _isFailed; }
+ set { _isFailed = value; RaisePropertyChangedAuto(); }
+ }
+
+ private StartHeadCleaningResponse _status;
+ public StartHeadCleaningResponse Status
+ {
+ get { return _status; }
+ set { _status = value; RaisePropertyChangedAuto(); }
+ }
+
+ public RelayCommand StartCommand { get; set; }
+ public RelayCommand AbortCommand { get; set; }
+
+ public HeadCleaningViewVM()
+ {
+ CanClose = true;
+ TangoIOC.Default.Inject(this);
+ StartCommand = new RelayCommand(Start);
+ AbortCommand = new RelayCommand(Abort);
+ }
+
+ private async void Start()
+ {
+ try
+ {
+ CanClose = false;
+ IsStarted = true;
+ _handler = await MachineProvider.MachineOperator.PerformHeadCleaning();
+ _handler.Completed += _handler_Completed;
+ _handler.Failed += _handler_Failed;
+ _handler.StatusChanged += _handler_StatusChanged;
+ }
+ catch (Exception ex)
+ {
+ _handler_Failed(this, ex);
+ }
+ }
+
+ private void _handler_StatusChanged(object sender, HeadCleaningStatusChangedEventArgs e)
+ {
+ Status = e.Status;
+ }
+
+ private void _handler_Failed(object sender, Exception e)
+ {
+ IsStarted = false;
+ IsFailed = true;
+ InvokeUI(() =>
+ {
+ CanClose = true;
+ Cancel();
+ NotificationProvider.ShowError($"Error occurred while trying to perform the head cleaning.\n{e.FlattenMessage()}");
+ });
+ }
+
+ private void _handler_Completed(object sender, EventArgs e)
+ {
+ IsStarted = false;
+ IsCompleted = true;
+ InvokeUI(() =>
+ {
+ Accept();
+ NotificationProvider.ShowSuccess("Head cleaning completed successfully.");
+ });
+ }
+
+ protected override void Cancel()
+ {
+ if (CanClose)
+ {
+ base.Cancel();
+ }
+ }
+
+ private async void Abort()
+ {
+ IsAborting = true;
+ try
+ {
+ await _handler.Abort();
+ CanClose = true;
+ Cancel();
+ await NotificationProvider.ShowInfo("Head cleaning aborted.");
+ }
+ catch (Exception ex)
+ {
+ if (!IsCompleted)
+ {
+ CanClose = true;
+ IsAborting = false;
+ await NotificationProvider.ShowError($"Error occurred while trying to abort the head cleaning.\n{ex.FlattenMessage()}");
+ }
+ }
+ }
+ }
+}
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Images/head_cleaning.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Images/head_cleaning.png
new file mode 100644
index 000000000..373cb78c1
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Images/head_cleaning.png
Binary files differ
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Tango.PPC.Maintenance.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Tango.PPC.Maintenance.csproj
index 42d4a396e..94dcf8247 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Tango.PPC.Maintenance.csproj
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Tango.PPC.Maintenance.csproj
@@ -81,6 +81,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
+ <Page Include="Dialogs\HeadCleaningView.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </Page>
<Page Include="Resources\Guides.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -116,6 +120,10 @@
<Compile Include="Converters\LiquidTypeToBrushConverter.cs" />
<Compile Include="Converters\MidTankLevelToElementHeightConverter.cs" />
<Compile Include="Converters\StringToFirstLetterConverter.cs" />
+ <Compile Include="Dialogs\HeadCleaningView.xaml.cs">
+ <DependentUpon>HeadCleaningView.xaml</DependentUpon>
+ </Compile>
+ <Compile Include="Dialogs\HeadCleaningViewVM.cs" />
<Compile Include="GuideBase.cs" />
<Compile Include="GuideStep.cs" />
<Compile Include="Guides\LoadInkCartridgeGuide.cs" />
@@ -277,11 +285,13 @@
<Resource Include="Images\cone-full.png" />
<Resource Include="Images\l-full.png" />
</ItemGroup>
- <ItemGroup />
+ <ItemGroup>
+ <Resource Include="Images\head_cleaning.png" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
<VisualStudio>
- <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" />
+ <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" />
</VisualStudio>
</ProjectExtensions>
</Project> \ No newline at end of file
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/ViewModels/MaintenanceViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/ViewModels/MaintenanceViewVM.cs
index 759d43415..4bd63e9a6 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/ViewModels/MaintenanceViewVM.cs
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/ViewModels/MaintenanceViewVM.cs
@@ -14,6 +14,7 @@ using Tango.Logging;
using Tango.PMR.MachineStatus;
using Tango.PPC.Common;
using Tango.PPC.Maintenance.Commands;
+using Tango.PPC.Maintenance.Dialogs;
using Tango.PPC.Maintenance.Helpers;
using Tango.PPC.Maintenance.Models;
using Tango.PPC.Maintenance.Views;
@@ -65,6 +66,8 @@ namespace Tango.PPC.Maintenance.ViewModels
public ResetThreadLoadingCommand ResetThreadLoadingCommand { get; set; }
+ public RelayCommand HeadCleaningCommand { get; set; }
+
public MaintenanceViewVM()
{
Guides = new ObservableCollection<GuideBase>(GuideHelper.CreateAllGuides());
@@ -77,6 +80,7 @@ namespace Tango.PPC.Maintenance.ViewModels
OpenCloseLeftLeadingWheelsCommand = new OpenCloseLeftLeadingWheelsCommand();
OpenCloseRightLeadingWheelsCommand = new OpenCloseRightLeadingWheelsCommand();
ResetThreadLoadingCommand = new ResetThreadLoadingCommand();
+ HeadCleaningCommand = new RelayCommand(PerformHeadCleaning,() => MachineProvider.MachineOperator.CanPrint);
}
public override void OnApplicationStarted()
@@ -101,6 +105,7 @@ namespace Tango.PPC.Maintenance.ViewModels
{
UpdateMidTankLevels(status);
OverallTemperature.Temperature = status.OverallTemperature;
+ InvalidateRelayCommands();
}
public async void OpenGuide(GuideBase guide)
@@ -207,5 +212,10 @@ namespace Tango.PPC.Maintenance.ViewModels
TotalDyeMeters = "error!";
}
}
+
+ private async void PerformHeadCleaning()
+ {
+ await NotificationProvider.ShowDialog<HeadCleaningViewVM>();
+ }
}
}
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Views/MaintenanceView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Views/MaintenanceView.xaml
index 11e2dc663..cf8511ee3 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Views/MaintenanceView.xaml
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Views/MaintenanceView.xaml
@@ -192,6 +192,8 @@
<touch:TouchButton Margin="20" CornerRadius="25" Height="50" FontSize="18" Style="{StaticResource TangoHollowButton}" Command="{Binding ResetThreadLoadingCommand.Command}">RESET THREAD LOADING</touch:TouchButton>
+ <touch:TouchButton Margin="20" CornerRadius="25" Height="50" FontSize="18" Style="{StaticResource TangoHollowButton}" Command="{Binding HeadCleaningCommand}">RUN HEAD CLEANING</touch:TouchButton>
+
<touch:TouchButton Margin="20" CornerRadius="25" Height="50" FontSize="18" Style="{StaticResource TangoHollowButton}" Command="{Binding ExportLogsCommand}" Visibility="{Binding ApplicationManager.IsInTechnicianMode,Converter={StaticResource BooleanToVisibilityConverter}}">EXPORT SYSTEM LOGS</touch:TouchButton>
</UniformGrid>
</StackPanel>