diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2021-03-10 03:59:31 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2021-03-10 03:59:31 +0200 |
| commit | d1d28d68564d0a76021944ba1e2993ffb3eaba61 (patch) | |
| tree | c0068878c600b48edccca9e824d6b9c41674cbee /Software/Visual_Studio/Tango.Integration | |
| parent | dff40538d054551a74034b473f9f0e0c3590bcd0 (diff) | |
| download | Tango-d1d28d68564d0a76021944ba1e2993ffb3eaba61.tar.gz Tango-d1d28d68564d0a76021944ba1e2993ffb3eaba61.zip | |
Bit completed except updated BIT types.
Diffstat (limited to 'Software/Visual_Studio/Tango.Integration')
4 files changed, 92 insertions, 1 deletions
diff --git a/Software/Visual_Studio/Tango.Integration/Operation/BitResultComposition.cs b/Software/Visual_Studio/Tango.Integration/Operation/BitResultComposition.cs new file mode 100644 index 000000000..cbe6e5fa3 --- /dev/null +++ b/Software/Visual_Studio/Tango.Integration/Operation/BitResultComposition.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using Tango.PMR.Diagnostics; + +namespace Tango.Integration.Operation +{ + public class BitResultComposition + { + public BL.Entities.BitType BitType { get; set; } + public BitResult BitResult { get; set; } + + public int Priority + { + get { return GetBitStatusPriority(BitResult.Status); } + } + + public static int GetBitStatusPriority(BitResultStatus status) + { + switch (status) + { + case BitResultStatus.Passed: + return 3; + case BitResultStatus.Pending: + return 2; + case BitResultStatus.Warning: + return 1; + case BitResultStatus.Failed: + return 0; + } + + return 0; + } + } +} diff --git a/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs index 5ac394ade..ac7bc75c5 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs @@ -558,5 +558,11 @@ namespace Tango.Integration.Operation /// <param name="ev">Type of the event.</param> /// <param name="timeout">The timeout.</param> void PushEmulatedEvent(Event ev, TimeSpan timeout); + + /// <summary> + /// Gets the last machine built-in test results. + /// </summary> + /// <returns></returns> + Task<List<BitResultComposition>> GetBitResults(List<BL.Entities.BitType> bitTypes); } } diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index 740fcb3c0..3bbbd2efe 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -86,6 +86,7 @@ namespace Tango.Integration.Operation private DateTime? _jobHeatingStartDate; private DateTime? _jobActualStartDate; private List<Event> _emulatedEvents; + private List<BitResultComposition> _bitResults; public static String EmbeddedLogsFolder { get; private set; } public static String EmbeddedLogsTag { get; private set; } @@ -135,6 +136,7 @@ namespace Tango.Integration.Operation /// </summary> public MachineOperator() : base() { + _bitResults = new List<BitResultComposition>(); _emulatedEvents = new List<Event>(); ComponentName = $"Machine Operator {_component_counter++}"; DeviceInformation = new DeviceInformation(); @@ -1478,6 +1480,8 @@ namespace Tango.Integration.Operation _debugSent = false; _machineStatusSent = false; + _bitResults = null; + OnEnableDiagnosticsChanged(EnableDiagnostics); OnEnableEmbeddedDebuggingChanged(EnableEmbeddedDebugging); OnEnableEventsNotification(EnableEventsNotification); @@ -4178,6 +4182,48 @@ namespace Tango.Integration.Operation } } + /// <summary> + /// Gets the last machine built-in test results. + /// </summary> + /// <returns></returns> + public async Task<List<BitResultComposition>> GetBitResults(List<BL.Entities.BitType> bitTypes) + { + if (_bitResults == null) + { + var response = await SendRequest<BitResultsRequest, BitResultsResponse>(new BitResultsRequest(), new TransportRequestConfig() + { + ShouldLog = true, + Timeout = TimeSpan.FromMinutes(1.5) + }); + + var compositions = new List<BitResultComposition>(); + + foreach (var bitType in bitTypes) + { + BitResultComposition composition = new BitResultComposition(); + composition.BitType = bitType; + composition.BitResult = new BitResult() { BitType = (PMR.Diagnostics.BitType)bitType.Code }; + compositions.Add(composition); + } + + foreach (var bitResult in response.Message.Results) + { + var composition = compositions.SingleOrDefault(x => x.BitType.Code == bitResult.BitType.ToInt32()); + + if (composition != null) + { + composition.BitResult = bitResult; + } + } + + compositions = compositions.OrderBy(x => x.Priority).ToList(); + + _bitResults = compositions; + } + + return _bitResults; + } + #endregion } } diff --git a/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj b/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj index c8771416a..7769a0433 100644 --- a/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj +++ b/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj @@ -113,6 +113,7 @@ <Compile Include="JobRuns\IJobRunsLogger.cs" /> <Compile Include="Logging\EmbeddedLogFileParser.cs" /> <Compile Include="Operation\AdditionalJobConfiguration.cs" /> + <Compile Include="Operation\BitResultComposition.cs" /> <Compile Include="Operation\CachedJobOperation.cs" /> <Compile Include="Operation\CartridgeValidationEventArgs.cs" /> <Compile Include="Operation\DefaultMachineEventsStateProvider.cs" /> @@ -222,7 +223,7 @@ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> + <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file |
