aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Telemetry/Sources/TelemetryJobRunsStreamingSource.cs
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2025-08-04 01:09:55 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2025-08-04 01:09:55 +0300
commit8bbeffb422e8535c399f1eb76a55fdee5a1c65b6 (patch)
treef200faa0e11c23f9105c3f12e0a6a2ea51832214 /Software/Visual_Studio/Tango.Telemetry/Sources/TelemetryJobRunsStreamingSource.cs
parent0df9f37075dd697ac34f4ed2a2749f62aa27a654 (diff)
downloadTango-8bbeffb422e8535c399f1eb76a55fdee5a1c65b6.tar.gz
Tango-8bbeffb422e8535c399f1eb76a55fdee5a1c65b6.zip
Telemetry JobRuns.
Diffstat (limited to 'Software/Visual_Studio/Tango.Telemetry/Sources/TelemetryJobRunsStreamingSource.cs')
-rw-r--r--Software/Visual_Studio/Tango.Telemetry/Sources/TelemetryJobRunsStreamingSource.cs63
1 files changed, 63 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.Telemetry/Sources/TelemetryJobRunsStreamingSource.cs b/Software/Visual_Studio/Tango.Telemetry/Sources/TelemetryJobRunsStreamingSource.cs
new file mode 100644
index 000000000..b3199eb36
--- /dev/null
+++ b/Software/Visual_Studio/Tango.Telemetry/Sources/TelemetryJobRunsStreamingSource.cs
@@ -0,0 +1,63 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.Core;
+using Tango.Integration.Operation;
+using Tango.Telemetry.Mappers;
+
+namespace Tango.Telemetry.Sources
+{
+ public class TelemetryJobRunsStreamingSource : ExtendedObject, ITelemetryStreamingSource
+ {
+ private IMachineOperator _machineOperator;
+
+ public string Name { get; } = "JobRuns Streaming";
+
+ public bool RequiresTelemetryDuplicationTracking { get; } = true;
+ public bool IsStarted { get; private set; }
+
+ public event EventHandler<TelemetryAvailableEventArgs> TelemetryAvailable;
+
+ public TelemetryJobRunsStreamingSource(IMachineOperator machineOperator)
+ {
+ _machineOperator = machineOperator;
+ }
+
+ private void JobRunsLogger_JobRunAvailable(object sender, Integration.JobRuns.JobRunAvailableEventArgs e)
+ {
+ Task.Factory.StartNew(() =>
+ {
+ if (IsStarted)
+ {
+ var tRun = JobRunMapper.MapJobRun(e.JobRun);
+ TelemetryAvailable?.Invoke(this, new TelemetryAvailableEventArgs() { TelemetryObject = tRun });
+ }
+ });
+ }
+
+ public void Dispose()
+ {
+ Stop();
+ }
+
+ public void Start()
+ {
+ if (!IsStarted)
+ {
+ _machineOperator.JobRunsLogger.JobRunAvailable += JobRunsLogger_JobRunAvailable;
+ IsStarted = true;
+ }
+ }
+
+ public void Stop()
+ {
+ if (IsStarted)
+ {
+ _machineOperator.JobRunsLogger.JobRunAvailable -= JobRunsLogger_JobRunAvailable;
+ IsStarted = false;
+ }
+ }
+ }
+}