aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2025-07-29 02:29:02 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2025-07-29 02:29:02 +0300
commit72c6399ec345ec26bd7f79651667ffa585474919 (patch)
tree687a6c9bb850b4568d1718aa51add12327737a7d /Software/Visual_Studio
parent3f86a214b4459e619a5a767369b996e56cd17564 (diff)
downloadTango-72c6399ec345ec26bd7f79651667ffa585474919.tar.gz
Tango-72c6399ec345ec26bd7f79651667ffa585474919.zip
Telemetry
Diffstat (limited to 'Software/Visual_Studio')
-rw-r--r--Software/Visual_Studio/Tango.Telemetry/Destinations/MqttTelemetryDestination.cs4
-rw-r--r--Software/Visual_Studio/Tango.Telemetry/Tango.Telemetry.csproj4
-rw-r--r--Software/Visual_Studio/Tango.Telemetry/TelemetryObjects/TelemetryDiagnosticsFrame.cs (renamed from Software/Visual_Studio/Tango.Telemetry/TelemetryDiagnosticsFrame.cs)2
-rw-r--r--Software/Visual_Studio/Tango.Telemetry/TelemetryObjects/TelemetryJobRun.cs (renamed from Software/Visual_Studio/Tango.Telemetry/TelemetryJobRun.cs)2
-rw-r--r--Software/Visual_Studio/Tango.Telemetry/TelemetryPublisher.cs10
-rw-r--r--Software/Visual_Studio/Tango.Telemetry/TelemetryPublisherAdvanced.cs2
-rw-r--r--Software/Visual_Studio/Tango.Telemetry/TelemetryPublisherConfiguration.cs28
7 files changed, 42 insertions, 10 deletions
diff --git a/Software/Visual_Studio/Tango.Telemetry/Destinations/MqttTelemetryDestination.cs b/Software/Visual_Studio/Tango.Telemetry/Destinations/MqttTelemetryDestination.cs
index 2a4d3a297..08412446c 100644
--- a/Software/Visual_Studio/Tango.Telemetry/Destinations/MqttTelemetryDestination.cs
+++ b/Software/Visual_Studio/Tango.Telemetry/Destinations/MqttTelemetryDestination.cs
@@ -23,14 +23,14 @@ namespace Tango.Telemetry.Destinations
public bool Enable { get; set; } = true;
public String Address { get; private set; }
public int Port { get; private set; }
- public String Topic { get; set; }
+ public String Topic { get; private set; }
public IReadOnlyList<TelemetrySource> SupportedSources { get; private set; }
/// <summary>
///
/// </summary>
- /// <param name="topic">example machie/telemetry/serial number</param>
+ /// <param name="topic">e.g machie/telemetry/serial number</param>
/// <param name="address">Default localhost</param>
/// <param name="port">Default 1883</param>
public MqttTelemetryDestination(String topic, String address = "localhost", int port = 1883)
diff --git a/Software/Visual_Studio/Tango.Telemetry/Tango.Telemetry.csproj b/Software/Visual_Studio/Tango.Telemetry/Tango.Telemetry.csproj
index 0cd4c9106..98df17cb8 100644
--- a/Software/Visual_Studio/Tango.Telemetry/Tango.Telemetry.csproj
+++ b/Software/Visual_Studio/Tango.Telemetry/Tango.Telemetry.csproj
@@ -217,8 +217,8 @@
<Compile Include="JsonFlattener.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TelemetryBase.cs" />
- <Compile Include="TelemetryDiagnosticsFrame.cs" />
- <Compile Include="TelemetryJobRun.cs" />
+ <Compile Include="TelemetryObjects\TelemetryDiagnosticsFrame.cs" />
+ <Compile Include="TelemetryObjects\TelemetryJobRun.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
diff --git a/Software/Visual_Studio/Tango.Telemetry/TelemetryDiagnosticsFrame.cs b/Software/Visual_Studio/Tango.Telemetry/TelemetryObjects/TelemetryDiagnosticsFrame.cs
index 89fe910b6..86762596e 100644
--- a/Software/Visual_Studio/Tango.Telemetry/TelemetryDiagnosticsFrame.cs
+++ b/Software/Visual_Studio/Tango.Telemetry/TelemetryObjects/TelemetryDiagnosticsFrame.cs
@@ -8,7 +8,7 @@ using System.Text;
using System.Threading.Tasks;
using Tango.PMR.Insights;
-namespace Tango.Telemetry
+namespace Tango.Telemetry.TelemetryObjects
{
[TelemetryName("Diagnostics")]
public class TelemetryDiagnosticsFrame : TelemetryBase
diff --git a/Software/Visual_Studio/Tango.Telemetry/TelemetryJobRun.cs b/Software/Visual_Studio/Tango.Telemetry/TelemetryObjects/TelemetryJobRun.cs
index 091306089..828f61360 100644
--- a/Software/Visual_Studio/Tango.Telemetry/TelemetryJobRun.cs
+++ b/Software/Visual_Studio/Tango.Telemetry/TelemetryObjects/TelemetryJobRun.cs
@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace Tango.Telemetry
+namespace Tango.Telemetry.TelemetryObjects
{
[TelemetryName("JobRuns")]
public class TelemetryJobRun : TelemetryBase
diff --git a/Software/Visual_Studio/Tango.Telemetry/TelemetryPublisher.cs b/Software/Visual_Studio/Tango.Telemetry/TelemetryPublisher.cs
index 662df9bae..8891a6cc4 100644
--- a/Software/Visual_Studio/Tango.Telemetry/TelemetryPublisher.cs
+++ b/Software/Visual_Studio/Tango.Telemetry/TelemetryPublisher.cs
@@ -12,6 +12,7 @@ using Tango.Insights;
using Tango.Integration.Operation;
using Tango.PMR.Diagnostics;
using Tango.PMR.Insights;
+using Tango.Telemetry.TelemetryObjects;
namespace Tango.Telemetry
{
@@ -150,6 +151,8 @@ namespace Tango.Telemetry
try
{
+ _diagnosticsSamplingTimer.Stop();
+
_writing = true;
if (_diagnosticsQueue.Count > 0)
@@ -186,17 +189,22 @@ namespace Tango.Telemetry
finally
{
_writing = false;
+ _diagnosticsSamplingTimer.Start();
}
}
private void PendingStorageCheckTimer_Elapsed(object sender, ElapsedEventArgs e)
{
+ _pendingStorageCheckTimer.Stop();
+
var telemetryAll = PendingStorageManager.GetTelemetryAll();
foreach (var t in telemetryAll)
{
PushTelemetryPackage(t, TelemetrySource.PendingStorage);
}
+
+ _pendingStorageCheckTimer.Start();
}
#endregion
@@ -326,7 +334,7 @@ namespace Tango.Telemetry
{
try
{
- PublishingPackage?.Invoke(this, new TelemetryPackagePublishingEventArgs() { Package = package, Destination = destination });
+ PackagePublished?.Invoke(this, new TelemetryPackagePublishedEventArgs() { Package = package, Destination = destination });
}
catch { }
}
diff --git a/Software/Visual_Studio/Tango.Telemetry/TelemetryPublisherAdvanced.cs b/Software/Visual_Studio/Tango.Telemetry/TelemetryPublisherAdvanced.cs
index 9ea817535..2d0f48126 100644
--- a/Software/Visual_Studio/Tango.Telemetry/TelemetryPublisherAdvanced.cs
+++ b/Software/Visual_Studio/Tango.Telemetry/TelemetryPublisherAdvanced.cs
@@ -15,7 +15,7 @@ namespace Tango.Telemetry
/// </summary>
public TimeSpan MaxExponentialBackoff { get; set; } = TimeSpan.FromHours(1);
- public TelemetryPublisherAdvanced(IMachineOperator machineOperator, TelemetryLiteDbPendingStorageManager storageManager, TelemetryPublisherConfiguration config) : base(machineOperator, storageManager, config)
+ public TelemetryPublisherAdvanced(IMachineOperator machineOperator, ITelemetryPendingStorageManager storageManager, TelemetryPublisherConfiguration config) : base(machineOperator, storageManager, config)
{
}
diff --git a/Software/Visual_Studio/Tango.Telemetry/TelemetryPublisherConfiguration.cs b/Software/Visual_Studio/Tango.Telemetry/TelemetryPublisherConfiguration.cs
index 56f826591..da5856848 100644
--- a/Software/Visual_Studio/Tango.Telemetry/TelemetryPublisherConfiguration.cs
+++ b/Software/Visual_Studio/Tango.Telemetry/TelemetryPublisherConfiguration.cs
@@ -26,8 +26,32 @@ namespace Tango.Telemetry
public void Validate()
{
- if (!MachineID.IsNotNullOrEmpty()) throw new ArgumentNullException($"{nameof(MachineID)} is not set.");
- if (!Environment.IsNotNullOrEmpty()) throw new ArgumentNullException($"{nameof(Environment)} is not set.");
+ if (!MachineID.IsNotNullOrEmpty())
+ throw new ArgumentNullException(nameof(MachineID), "MachineID is not set or empty.");
+
+ if (!Environment.IsNotNullOrEmpty())
+ throw new ArgumentNullException(nameof(Environment), "Environment is not set or empty.");
+
+ if (!Enum.IsDefined(typeof(MachineTypes), MachineType))
+ throw new ArgumentOutOfRangeException(nameof(MachineType), "MachineType is not a valid enum value.");
+
+ if (DiagnosticsSamplingInterval.TotalSeconds < 1)
+ throw new ArgumentOutOfRangeException(nameof(DiagnosticsSamplingInterval), "DiagnosticsSamplingInterval must be at least 1 second.");
+
+ if (PendingStorageCheckInterval.TotalSeconds < 5)
+ throw new ArgumentOutOfRangeException(nameof(PendingStorageCheckInterval), "PendingStorageCheckInterval must be at least 5 seconds.");
+
+ if (TelemetryDestinations == null || TelemetryDestinations.Count == 0)
+ throw new InvalidOperationException("At least one telemetry destination must be provided.");
+
+ foreach (var destination in TelemetryDestinations)
+ {
+ if (destination == null)
+ throw new InvalidOperationException("Telemetry destination list contains a null entry.");
+
+ if (destination.SupportedSources == null || destination.SupportedSources.Count == 0)
+ throw new InvalidOperationException($"Telemetry destination '{destination.Name}' has no supported sources defined.");
+ }
}
}
}