aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio
diff options
context:
space:
mode:
authorRoy <Roy.mail.net@gmail.com>2022-10-23 23:56:56 +0300
committerRoy <Roy.mail.net@gmail.com>2022-10-23 23:56:56 +0300
commit5e02391d9f37336169a045b9f7d1328bd72a7aef (patch)
tree158e519a9e10f5bde7eec62863922d0d18e087ad /Software/Visual_Studio
parentddde7144515d7cb48a8f41d085aa738c6e4d36fa (diff)
downloadTango-5e02391d9f37336169a045b9f7d1328bd72a7aef.tar.gz
Tango-5e02391d9f37336169a045b9f7d1328bd72a7aef.zip
Total Dye Time & Meters on FSE.
Diffstat (limited to 'Software/Visual_Studio')
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.Common/Converters/TotalDyeTimeConverter.cs24
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.Common/Converters/TotalMetersConverter.cs23
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Converters.xaml2
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.Common/SystemInfo/ISystemInfoProvider.cs10
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj2
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.UI/Panes/ConnectedMachinePane.xaml4
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.UI/Panes/ConnectedMachinePaneVM.cs4
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.UI/SystemInfo/DefaultSystemInfoProvider.cs49
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Tango.PPC.Maintenance.csproj6
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/DefaultSystemInfoService.cs28
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Shared/Information/GetMachineCountersRequest.cs13
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Shared/Information/GetMachineCountersResponse.cs15
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Shared/Tango.PPC.Shared.csproj2
13 files changed, 181 insertions, 1 deletions
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Converters/TotalDyeTimeConverter.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/Converters/TotalDyeTimeConverter.cs
new file mode 100644
index 000000000..76f626121
--- /dev/null
+++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Converters/TotalDyeTimeConverter.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+
+namespace Tango.FSE.Common.Converters
+{
+ public class TotalDyeTimeConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ TimeSpan totalDyeTime = (TimeSpan)value;
+ return totalDyeTime.ToStringUnlimitedHours();
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Converters/TotalMetersConverter.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/Converters/TotalMetersConverter.cs
new file mode 100644
index 000000000..28e7821f2
--- /dev/null
+++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Converters/TotalMetersConverter.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+
+namespace Tango.FSE.Common.Converters
+{
+ public class TotalMetersConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return $"{((int)value).ToString("N0")} meters";
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Converters.xaml b/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Converters.xaml
index e37f48821..510327034 100644
--- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Converters.xaml
+++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Converters.xaml
@@ -52,4 +52,6 @@
<localConverters:EventTypeTitleConverter x:Key="EventTypeTitleConverter" />
<localConverters:EventTypeDescriptionConverter x:Key="EventTypeDescriptionConverter" />
<localConverters:EventTypeTechnicalDescriptionConverter x:Key="EventTypeTechnicalDescriptionConverter" />
+ <localConverters:TotalDyeTimeConverter x:Key="TotalDyeTimeConverter" />
+ <localConverters:TotalMetersConverter x:Key="TotalMetersConverter" />
</ResourceDictionary> \ No newline at end of file
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/SystemInfo/ISystemInfoProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/SystemInfo/ISystemInfoProvider.cs
index 53baab14e..f75c904f8 100644
--- a/Software/Visual_Studio/FSE/Tango.FSE.Common/SystemInfo/ISystemInfoProvider.cs
+++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/SystemInfo/ISystemInfoProvider.cs
@@ -13,6 +13,16 @@ namespace Tango.FSE.Common.SystemInfo
public interface ISystemInfoProvider
{
/// <summary>
+ /// Gets the machine total dye meters.
+ /// </summary>
+ int TotalDyeMeters { get; }
+
+ /// <summary>
+ /// Gets the machine total dye time.
+ /// </summary>
+ TimeSpan TotalDyeTime { get; }
+
+ /// <summary>
/// Gets the system information package from the remote machine.
/// </summary>
/// <returns></returns>
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj b/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj
index ce56e2daf..58e8136f0 100644
--- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj
+++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj
@@ -189,6 +189,8 @@
<Compile Include="Converters\JobProgressToPositionConverter.cs" />
<Compile Include="Converters\LiquidTypeToShortNameConverter.cs" />
<Compile Include="Converters\TimeSpanHumanizeConverter.cs" />
+ <Compile Include="Converters\TotalDyeTimeConverter.cs" />
+ <Compile Include="Converters\TotalMetersConverter.cs" />
<Compile Include="Core\FSEProgress.cs" />
<Compile Include="DashboardTile.cs" />
<Compile Include="DataStore\IDataStoreProvider.cs" />
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Panes/ConnectedMachinePane.xaml b/Software/Visual_Studio/FSE/Tango.FSE.UI/Panes/ConnectedMachinePane.xaml
index c0c54b1b6..7c7418514 100644
--- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Panes/ConnectedMachinePane.xaml
+++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Panes/ConnectedMachinePane.xaml
@@ -42,6 +42,10 @@
<TextBlock Text="{Binding MachineProvider.Machine.Name}" />
<TextBlock FontWeight="SemiBold" Text="Organization:" />
<TextBlock Text="{Binding MachineProvider.Machine.Organization.Name}" />
+ <TextBlock FontWeight="SemiBold" Text="Total Dye Length:" />
+ <TextBlock Text="{Binding SystemInfoProvider.TotalDyeMeters,Converter={StaticResource TotalMetersConverter}}" />
+ <TextBlock FontWeight="SemiBold" Text="Total Dye Time:" />
+ <TextBlock Text="{Binding SystemInfoProvider.TotalDyeTime,Converter={StaticResource TotalDyeTimeConverter}}" />
</controls:TableGrid>
</StackPanel>
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Panes/ConnectedMachinePaneVM.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/Panes/ConnectedMachinePaneVM.cs
index 9195ea03f..817a6626a 100644
--- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Panes/ConnectedMachinePaneVM.cs
+++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Panes/ConnectedMachinePaneVM.cs
@@ -7,6 +7,7 @@ using Tango.Core.Commands;
using Tango.Core.DI;
using Tango.FSE.Common.Connection;
using Tango.FSE.Common.Diagnostics;
+using Tango.FSE.Common.SystemInfo;
using Tango.Integration.ExternalBridge;
using Tango.SharedUI;
@@ -24,6 +25,9 @@ namespace Tango.FSE.UI.Panes
[TangoInject(Mode = TangoInjectMode.WhenAvailable)]
public IDiagnosticsProvider DiagnosticsProvider { get; set; }
+ [TangoInject(Mode = TangoInjectMode.WhenAvailable)]
+ public ISystemInfoProvider SystemInfoProvider { get; set; }
+
/// <summary>
/// Occurs when the user chose to close the current machine connection.
/// </summary>
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/SystemInfo/DefaultSystemInfoProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/SystemInfo/DefaultSystemInfoProvider.cs
index 6fc96d7ef..2b4aed648 100644
--- a/Software/Visual_Studio/FSE/Tango.FSE.UI/SystemInfo/DefaultSystemInfoProvider.cs
+++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/SystemInfo/DefaultSystemInfoProvider.cs
@@ -22,6 +22,26 @@ namespace Tango.FSE.UI.SystemInfo
private IMachineProvider MachineProvider { get; set; }
+ private int _totalDyeMeters;
+ /// <summary>
+ /// Gets the machine total dye meters.
+ /// </summary>
+ public int TotalDyeMeters
+ {
+ get { return _totalDyeMeters; }
+ set { _totalDyeMeters = value; RaisePropertyChangedAuto(); }
+ }
+
+ private TimeSpan _totalDyeTime;
+ /// <summary>
+ /// Gets the machine total dye time.
+ /// </summary>
+ public TimeSpan TotalDyeTime
+ {
+ get { return _totalDyeTime; }
+ set { _totalDyeTime = value; RaisePropertyChangedAuto(); }
+ }
+
/// <summary>
/// Initializes a new instance of the <see cref="DefaultSystemInfoProvider"/> class.
/// </summary>
@@ -29,6 +49,7 @@ namespace Tango.FSE.UI.SystemInfo
public DefaultSystemInfoProvider(IMachineProvider machineProvider)
{
MachineProvider = machineProvider;
+ MachineProvider.MachineConnected += MachineProvider_MachineConnected;
MachineProvider.MachineDisconnected += MachineProvider_MachineDisconnected;
}
@@ -63,9 +84,37 @@ namespace Tango.FSE.UI.SystemInfo
}
}
+ private async void MachineProvider_MachineConnected(object sender, MachineConnectedEventArgs e)
+ {
+ if (MachineProvider.ConnectionType.IsRemote())
+ {
+ try
+ {
+ TotalDyeMeters = 0;
+ TotalDyeTime = TimeSpan.Zero;
+
+ LogManager.Log("Retrieving remote machine counters...");
+
+ var response = await MachineProvider.MachineOperator.SendGenericRequest<GetMachineCountersRequest, GetMachineCountersResponse>(new GetMachineCountersRequest(), new Transport.TransportRequestConfig()
+ {
+ Timeout = TimeSpan.FromSeconds(10)
+ });
+
+ TotalDyeMeters = response.TotalDyeMeters;
+ TotalDyeTime = response.TotalDyeTime;
+ }
+ catch (Exception ex)
+ {
+ throw LogManager.Log(ex, "Error retrieving remote machine counters.");
+ }
+ }
+ }
+
private void MachineProvider_MachineDisconnected(object sender, MachineDisconnectedEventArgs e)
{
_package = null;
+ TotalDyeMeters = 0;
+ TotalDyeTime = TimeSpan.Zero;
}
}
}
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 9dd45add4..43a850289 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
@@ -232,6 +232,10 @@
<Project>{0be74eee-22cb-4dba-b896-793b9e1a3ac0}</Project>
<Name>Tango.PPC.Common</Name>
</ProjectReference>
+ <ProjectReference Include="..\..\Tango.PPC.Shared\Tango.PPC.Shared.csproj">
+ <Project>{208C8BD8-72C6-4E3C-ACAA-351091A2ACC7}</Project>
+ <Name>Tango.PPC.Shared</Name>
+ </ProjectReference>
<ProjectReference Include="..\Tango.PPC.Storage\Tango.PPC.Storage.csproj">
<Project>{04febb02-f782-4b96-b47d-f6902afa43be}</Project>
<Name>Tango.PPC.Storage</Name>
@@ -314,7 +318,7 @@
<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/Tango.PPC.Common/SystemInfo/DefaultSystemInfoService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/DefaultSystemInfoService.cs
index 0c818483c..3c3a0247b 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/DefaultSystemInfoService.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/DefaultSystemInfoService.cs
@@ -1,10 +1,12 @@
using Microsoft.WindowsAPICodePack.Net;
using System;
using System.Collections.Generic;
+using System.Data.Entity;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Tango.BL;
using Tango.Core;
using Tango.Core.DI;
using Tango.Integration.ExternalBridge;
@@ -130,6 +132,32 @@ namespace Tango.PPC.Common.SystemInfo
}, token);
}
+ [ExternalBridgeRequestHandlerMethod(typeof(GetMachineCountersRequest), RequestHandlerLoggingMode.LogRequestName)]
+ public async Task OnGetMachineCountersRequest(GetMachineCountersRequest request, String token, ExternalBridgeReceiver receiver)
+ {
+ var counters = await GetCounters();
+
+ var response = new GetMachineCountersResponse();
+ response.TotalDyeTime = counters.Item1;
+ response.TotalDyeMeters = counters.Item2;
+
+ await receiver.SendGenericResponse(response, token);
+ }
+
+ private async Task<Tuple<TimeSpan, int>> GetCounters()
+ {
+ using (ObservablesContext db = ObservablesContext.CreateDefault())
+ {
+ var jobRuns = await db.JobRuns.Select(x => new { x.StartDate, x.EndDate, x.EndPosition }).ToListAsync();
+
+ TimeSpan totalDyeTime = TimeSpan.FromHours(jobRuns.Select(x => x.EndDate - x.StartDate).Sum(x => x.TotalHours));
+
+ int meters = (int)jobRuns.Select(x => x.EndPosition).Sum();
+
+ return new Tuple<TimeSpan, int>(totalDyeTime, meters);
+ }
+ }
+
public void OnReceiverDisconnected(ExternalBridgeReceiver receiver)
{
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Information/GetMachineCountersRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Information/GetMachineCountersRequest.cs
new file mode 100644
index 000000000..120f85db0
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Information/GetMachineCountersRequest.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.PPC.Shared.Information
+{
+ public class GetMachineCountersRequest
+ {
+
+ }
+}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Information/GetMachineCountersResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Information/GetMachineCountersResponse.cs
new file mode 100644
index 000000000..622e083c3
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Information/GetMachineCountersResponse.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.PPC.Shared.Information
+{
+ public class GetMachineCountersResponse
+ {
+ public int TotalDyeMeters { get; set; }
+
+ public TimeSpan TotalDyeTime { get; set; }
+ }
+}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Tango.PPC.Shared.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Tango.PPC.Shared.csproj
index 3664a1835..8548aa9cc 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Tango.PPC.Shared.csproj
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Tango.PPC.Shared.csproj
@@ -64,6 +64,8 @@
</Compile>
<Compile Include="Events\PushEmulatedEventRequest.cs" />
<Compile Include="Events\PushEmulatedEventResponse.cs" />
+ <Compile Include="Information\GetMachineCountersResponse.cs" />
+ <Compile Include="Information\GetMachineCountersRequest.cs" />
<Compile Include="Information\GetMachineInformationRequest.cs" />
<Compile Include="Information\GetMachineInformationResponse.cs" />
<Compile Include="Information\InformationPackage.cs" />