diff options
| author | Roy <Roy.mail.net@gmail.com> | 2022-10-23 23:56:56 +0300 |
|---|---|---|
| committer | Roy <Roy.mail.net@gmail.com> | 2022-10-23 23:56:56 +0300 |
| commit | 5e02391d9f37336169a045b9f7d1328bd72a7aef (patch) | |
| tree | 158e519a9e10f5bde7eec62863922d0d18e087ad /Software/Visual_Studio/PPC | |
| parent | ddde7144515d7cb48a8f41d085aa738c6e4d36fa (diff) | |
| download | Tango-5e02391d9f37336169a045b9f7d1328bd72a7aef.tar.gz Tango-5e02391d9f37336169a045b9f7d1328bd72a7aef.zip | |
Total Dye Time & Meters on FSE.
Diffstat (limited to 'Software/Visual_Studio/PPC')
5 files changed, 63 insertions, 1 deletions
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" /> |
