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-18 18:30:55 +0200
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-03-18 18:30:55 +0200
commitb96d52dcf527339d4d1c43c06d49b375a5f42e0c (patch)
treec884cc3917a6b19dfeeba89536fd7e0634780116 /Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance
parent7ae0a7f52c656e5a9e4ddaf60a72d5aaaa00b0e5 (diff)
downloadTango-b96d52dcf527339d4d1c43c06d49b375a5f42e0c.tar.gz
Tango-b96d52dcf527339d4d1c43c06d49b375a5f42e0c.zip
Implemented machine counters on PPC maintenance.
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance')
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/ViewModels/MaintenanceViewVM.cs40
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Views/MaintenanceView.xaml15
2 files changed, 54 insertions, 1 deletions
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 8d221c3f3..759d43415 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
@@ -2,9 +2,11 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Tango.BL;
using Tango.Core.Commands;
using Tango.Explorer;
using Tango.Integration.Operation;
@@ -39,6 +41,20 @@ namespace Tango.PPC.Maintenance.ViewModels
set { _overallTemperature = value; RaisePropertyChangedAuto(); }
}
+ private String _totalDyeTime;
+ public String TotalDyeTime
+ {
+ get { return _totalDyeTime; }
+ set { _totalDyeTime = value; RaisePropertyChangedAuto(); }
+ }
+
+ private String _totalDyeMeters;
+ public String TotalDyeMeters
+ {
+ get { return _totalDyeMeters; }
+ set { _totalDyeMeters = value; RaisePropertyChangedAuto(); }
+ }
+
public RelayCommand ExportLogsCommand { get; set; }
public OpenCloseDyeingHeadCommand OpenCloseDyeingHeadCommand { get; set; }
@@ -167,5 +183,29 @@ namespace Tango.PPC.Maintenance.ViewModels
}
}
}
+
+ public async override void OnNavigatedTo()
+ {
+ base.OnNavigatedTo();
+
+ try
+ {
+ using (ObservablesContext db = ObservablesContext.CreateDefault())
+ {
+ var jobRuns = await db.JobRuns.Select(x => new { x.StartDate, x.EndDate, x.EndPosition }).ToListAsync();
+
+ TotalDyeTime = TimeSpan.FromHours(jobRuns.Select(x => x.EndDate - x.StartDate).Sum(x => x.TotalHours)).ToString(@"hh\:mm\:ss");
+
+ int meters = (int)jobRuns.Select(x => x.EndPosition).Sum();
+ TotalDyeMeters = $"{meters.ToString("N0")} meters";
+ }
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Error loading machine counters.");
+ TotalDyeTime = "error!";
+ TotalDyeMeters = "error!";
+ }
+ }
}
}
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 538d4e96d..11e2dc663 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
@@ -11,7 +11,7 @@
xmlns:localControls="clr-namespace:Tango.PPC.Maintenance.Controls"
xmlns:local="clr-namespace:Tango.PPC.Maintenance.Views"
mc:Ignorable="d"
- d:DesignHeight="1280" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:MaintenanceViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MaintenanceViewVM}">
+ d:DesignHeight="1380" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:MaintenanceViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MaintenanceViewVM}">
<UserControl.Resources>
@@ -224,6 +224,19 @@
</StackPanel>
</StackPanel>
</touch:TouchDropShadowBorder>
+
+ <!--JOB RUNS-->
+ <StackPanel Margin="0 20 0 20" TextElement.FontSize="{StaticResource TangoTitleFontSize}" TextElement.Foreground="{StaticResource TangoGrayTextBrush}">
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+ <TextBlock FontWeight="SemiBold">Total Dye Time:</TextBlock>
+ <TextBlock Margin="10 0 0 0" Text="{Binding TotalDyeTime,Mode=OneWay,FallbackValue=0}"></TextBlock>
+ </StackPanel>
+
+ <StackPanel Orientation="Horizontal" Margin="0 10 0 0" HorizontalAlignment="Center">
+ <TextBlock FontWeight="SemiBold">Total Dye Meters:</TextBlock>
+ <TextBlock Margin="10 0 0 0" Text="{Binding TotalDyeMeters,Mode=OneWay,FallbackValue=0}"></TextBlock>
+ </StackPanel>
+ </StackPanel>
</StackPanel>
</touch:LightTouchScrollViewer>
</Grid>