aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2025-08-16 15:06:07 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2025-08-16 15:06:07 +0300
commite9f317178f6454836d488cf1e65d04b20b02d334 (patch)
tree1347ae729401d2c5a136afb14a8b6ae8b74d0d9b /Software/Visual_Studio
parent25933e3fd940dbf89b1924383feabb3a5619846d (diff)
downloadTango-e9f317178f6454836d488cf1e65d04b20b02d334.tar.gz
Tango-e9f317178f6454836d488cf1e65d04b20b02d334.zip
Telemetry Logs.
Diffstat (limited to 'Software/Visual_Studio')
-rw-r--r--Software/Visual_Studio/Tango.Telemetry/Sources/TelemetryDiagnosticsStreamingSource.cs (renamed from Software/Visual_Studio/Tango.Telemetry/Sources/TelemetryDiagnosticsSource.cs)6
-rw-r--r--Software/Visual_Studio/Tango.Telemetry/Sources/TelemetryDiagnosticsStreamingSourceConfig.cs (renamed from Software/Visual_Studio/Tango.Telemetry/Sources/TelemetryDiagnosticsSourceConfig.cs)4
-rw-r--r--Software/Visual_Studio/Tango.Telemetry/Sources/TelemetryLogsStreamingSource.cs99
-rw-r--r--Software/Visual_Studio/Tango.Telemetry/Sources/TelemetryLogsStreamingSourceConfig.cs20
-rw-r--r--Software/Visual_Studio/Tango.Telemetry/Tango.Telemetry.csproj7
-rw-r--r--Software/Visual_Studio/Tango.Telemetry/Telemetries/TelemetryLog.cs21
-rw-r--r--Software/Visual_Studio/Utilities/Tango.Telemetry.Tester.IOT.CLI/Program.cs105
-rw-r--r--Software/Visual_Studio/Utilities/Tango.Telemetry.Tester.IOT.CLI/Tango.Telemetry.Tester.IOT.CLI.csproj11
-rw-r--r--Software/Visual_Studio/Utilities/Tango.Telemetry.Tester.IOT.CLI/sample.insightsbin0 -> 43601 bytes
9 files changed, 236 insertions, 37 deletions
diff --git a/Software/Visual_Studio/Tango.Telemetry/Sources/TelemetryDiagnosticsSource.cs b/Software/Visual_Studio/Tango.Telemetry/Sources/TelemetryDiagnosticsStreamingSource.cs
index 37a8d224d..657fa83e8 100644
--- a/Software/Visual_Studio/Tango.Telemetry/Sources/TelemetryDiagnosticsSource.cs
+++ b/Software/Visual_Studio/Tango.Telemetry/Sources/TelemetryDiagnosticsStreamingSource.cs
@@ -14,7 +14,7 @@ using Tango.Telemetry.Telemetries;
namespace Tango.Telemetry.Sources
{
- public class TelemetryDiagnosticsSource : TelemetryConfigurableSource<TelemetryDiagnosticsSourceConfig>, ITelemetryStreamingSource
+ public class TelemetryDiagnosticsStreamingSource : TelemetryConfigurableSource<TelemetryDiagnosticsStreamingSourceConfig>, ITelemetryStreamingSource
{
public const int MIN_SAMPLING_INTERVAL_SECONDS = 1;
@@ -32,12 +32,12 @@ namespace Tango.Telemetry.Sources
public bool RequiresTelemetryDuplicationTracking { get => false; }
public bool IsStarted { get; private set; }
- private TelemetryDiagnosticsSource() : base()
+ private TelemetryDiagnosticsStreamingSource() : base()
{
_diagnosticsQueue = new List<StartDiagnosticsResponse>();
}
- public TelemetryDiagnosticsSource(IMachineOperator machineOperator) : base()
+ public TelemetryDiagnosticsStreamingSource(IMachineOperator machineOperator) : base()
{
_machineOperator = machineOperator;
_machineOperator.DiagnosticsDataAvailable += DiagnosticsDataAvailable;
diff --git a/Software/Visual_Studio/Tango.Telemetry/Sources/TelemetryDiagnosticsSourceConfig.cs b/Software/Visual_Studio/Tango.Telemetry/Sources/TelemetryDiagnosticsStreamingSourceConfig.cs
index 806277d5b..c161ed680 100644
--- a/Software/Visual_Studio/Tango.Telemetry/Sources/TelemetryDiagnosticsSourceConfig.cs
+++ b/Software/Visual_Studio/Tango.Telemetry/Sources/TelemetryDiagnosticsStreamingSourceConfig.cs
@@ -7,11 +7,11 @@ using Tango.Settings;
namespace Tango.Telemetry.Sources
{
- public class TelemetryDiagnosticsSourceConfig : SettingsBase
+ public class TelemetryDiagnosticsStreamingSourceConfig : SettingsBase
{
public TimeSpan DiagnosticsSamplingInterval { get; set; }
- public TelemetryDiagnosticsSourceConfig()
+ public TelemetryDiagnosticsStreamingSourceConfig()
{
DiagnosticsSamplingInterval = TimeSpan.FromSeconds(10);
}
diff --git a/Software/Visual_Studio/Tango.Telemetry/Sources/TelemetryLogsStreamingSource.cs b/Software/Visual_Studio/Tango.Telemetry/Sources/TelemetryLogsStreamingSource.cs
new file mode 100644
index 000000000..8001caac8
--- /dev/null
+++ b/Software/Visual_Studio/Tango.Telemetry/Sources/TelemetryLogsStreamingSource.cs
@@ -0,0 +1,99 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.Integration.Operation;
+using Tango.Logging;
+using Tango.Telemetry.Telemetries;
+
+namespace Tango.Telemetry.Sources
+{
+ public class TelemetryLogsStreamingSource : TelemetryConfigurableSource<TelemetryLogsStreamingSourceConfig>, ITelemetryStreamingSource
+ {
+ private KeyValuePair<DateTime, String> _lastFirmwareMessage;
+
+ public IMachineOperator MachineOperator { get; }
+
+ public bool IsStarted { get; private set; }
+
+ public string Name { get; } = "Logs";
+
+ public bool RequiresTelemetryDuplicationTracking { get; }
+
+ public event EventHandler<TelemetryAvailableEventArgs> TelemetryAvailable;
+
+ public TelemetryLogsStreamingSource()
+ {
+ _lastFirmwareMessage = new KeyValuePair<DateTime, string>(DateTime.MinValue, String.Empty);
+ }
+
+ public TelemetryLogsStreamingSource(IMachineOperator machineOperator)
+ {
+ MachineOperator = machineOperator;
+ }
+
+ public void Start()
+ {
+ if (!IsStarted)
+ {
+ IsStarted = true;
+ LogManager.NewLog += LogManager_NewLog;
+ if (MachineOperator != null) MachineOperator.DebugLogAvailable += MachineOperator_DebugLogAvailable;
+ }
+ }
+
+ private void MachineOperator_DebugLogAvailable(object sender, PMR.Debugging.StartDebugLogResponse log)
+ {
+ if (IsStarted)
+ {
+ if (Config.Categories.Contains((LogCategory)log.Category)) return;
+
+ if (log.Message == _lastFirmwareMessage.Value && DateTime.UtcNow < _lastFirmwareMessage.Key.AddSeconds(1)) return;
+
+ _lastFirmwareMessage = new KeyValuePair<DateTime, string>(DateTime.UtcNow, log.Message);
+
+ TelemetryLog tLog = new TelemetryLog();
+ tLog.Time = DateTime.UtcNow;
+ tLog.Category = log.Category.ToString();
+ tLog.Class = log.FileName;
+ tLog.Method = $"[{log.ModuleId}] [{log.Filter}] [{log.Parameter}]";
+ tLog.Line = log.LineNumber;
+ tLog.Message = log.Message;
+ TelemetryAvailable?.Invoke(this, new TelemetryAvailableEventArgs() { TelemetryObject = tLog });
+ }
+ }
+
+ private void LogManager_NewLog(object sender, Logging.LogItemBase log)
+ {
+ if (IsStarted)
+ {
+ if (Config.Categories.Contains(log.Category)) return;
+
+ TelemetryLog tLog = new TelemetryLog();
+ tLog.Time = log.TimeStamp.ToUniversalTime();
+ tLog.Category = log.Category.ToString();
+ tLog.Class = log.ClassName;
+ tLog.Method = log.CallerMethodName;
+ tLog.Line = log.CallerLineNumber;
+ tLog.Message = log.Message;
+ TelemetryAvailable?.Invoke(this, new TelemetryAvailableEventArgs() { TelemetryObject = tLog });
+ }
+ }
+
+ public void Stop()
+ {
+ if (IsStarted)
+ {
+ IsStarted = false;
+ LogManager.NewLog -= LogManager_NewLog;
+ if (MachineOperator != null) MachineOperator.DebugLogAvailable -= MachineOperator_DebugLogAvailable;
+ }
+ }
+
+ public void Dispose()
+ {
+ Stop();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/Tango.Telemetry/Sources/TelemetryLogsStreamingSourceConfig.cs b/Software/Visual_Studio/Tango.Telemetry/Sources/TelemetryLogsStreamingSourceConfig.cs
new file mode 100644
index 000000000..1de30976a
--- /dev/null
+++ b/Software/Visual_Studio/Tango.Telemetry/Sources/TelemetryLogsStreamingSourceConfig.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.Logging;
+using Tango.Settings;
+
+namespace Tango.Telemetry.Sources
+{
+ public class TelemetryLogsStreamingSourceConfig : SettingsBase
+ {
+ public List<LogCategory> Categories { get; set; }
+
+ public TelemetryLogsStreamingSourceConfig()
+ {
+ Categories = new List<LogCategory>() { LogCategory.Error, LogCategory.Critical, LogCategory.Warning };
+ }
+ }
+}
diff --git a/Software/Visual_Studio/Tango.Telemetry/Tango.Telemetry.csproj b/Software/Visual_Studio/Tango.Telemetry/Tango.Telemetry.csproj
index ff1fcb43e..b04b0654d 100644
--- a/Software/Visual_Studio/Tango.Telemetry/Tango.Telemetry.csproj
+++ b/Software/Visual_Studio/Tango.Telemetry/Tango.Telemetry.csproj
@@ -255,12 +255,15 @@
<Compile Include="Reporting\SourceSummary.cs" />
<Compile Include="Reporting\SourceTypeSummary.cs" />
<Compile Include="Reporting\TelemetryReport.cs" />
- <Compile Include="Sources\TelemetryDiagnosticsSource.cs" />
- <Compile Include="Sources\TelemetryDiagnosticsSourceConfig.cs" />
+ <Compile Include="Sources\TelemetryDiagnosticsStreamingSource.cs" />
+ <Compile Include="Sources\TelemetryDiagnosticsStreamingSourceConfig.cs" />
<Compile Include="Sources\TelemetryJobRunsHistorySource.cs" />
<Compile Include="Sources\TelemetryJobRunsHistorySourceConfig.cs" />
<Compile Include="PendingTelemetry.cs" />
<Compile Include="Sources\TelemetryJobRunsStreamingSource.cs" />
+ <Compile Include="Sources\TelemetryLogsStreamingSource.cs" />
+ <Compile Include="Sources\TelemetryLogsStreamingSourceConfig.cs" />
+ <Compile Include="Telemetries\TelemetryLog.cs" />
<Compile Include="TelemetryConfigurableSource.cs" />
<Compile Include="TelemetryHistorySourceCheckPoint.cs" />
<Compile Include="TelemetryHistorySourceDirection.cs" />
diff --git a/Software/Visual_Studio/Tango.Telemetry/Telemetries/TelemetryLog.cs b/Software/Visual_Studio/Tango.Telemetry/Telemetries/TelemetryLog.cs
new file mode 100644
index 000000000..c37f6fd29
--- /dev/null
+++ b/Software/Visual_Studio/Tango.Telemetry/Telemetries/TelemetryLog.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.Telemetry.Telemetries
+{
+ public class TelemetryLog : TelemetryBase
+ {
+ public String Category { get; set; }
+
+ public String Class { get; set; }
+
+ public String Method { get; set; }
+
+ public int Line { get; set; }
+
+ public String Message { get; set; }
+ }
+}
diff --git a/Software/Visual_Studio/Utilities/Tango.Telemetry.Tester.IOT.CLI/Program.cs b/Software/Visual_Studio/Utilities/Tango.Telemetry.Tester.IOT.CLI/Program.cs
index fee2fe346..0b90f0de4 100644
--- a/Software/Visual_Studio/Utilities/Tango.Telemetry.Tester.IOT.CLI/Program.cs
+++ b/Software/Visual_Studio/Utilities/Tango.Telemetry.Tester.IOT.CLI/Program.cs
@@ -12,6 +12,8 @@ using Tango.Telemetry.Sources;
using Tango.Telemetry.Telemetries;
using System.Data.Entity;
using Tango.BL.Entities;
+using Tango.Insights;
+using System.Threading;
namespace Tango.Telemetry.Tester.IOT.CLI
{
@@ -37,7 +39,8 @@ namespace Tango.Telemetry.Tester.IOT.CLI
(publisher.StorageManager as TelemetryLiteDBStorageManager).EnableCheckPointsRecovery = false;
- publisher.RegisterSource(new JobRunsTestSource());
+ //publisher.RegisterSource(new JobRunsTestSource());
+ publisher.RegisterSource(new DiagnosticsTestSource());
publisher.RegisterDestination(new TelemetryAzureHubDestination("HostName=iot-twine-dev-weu.azure-devices.net;DeviceId=telemetry-dev-01;SharedAccessKey=cZhCMhiVL+TF7p13fpX+lFmyxoy8ZqCkbxUwumWw18Q="));
publisher.PublishResultAvailable += Publisher_PublishResultAvailable;
@@ -58,38 +61,38 @@ namespace Tango.Telemetry.Tester.IOT.CLI
private static void Publisher_PublishingPackage(object sender, TelemetryPackagePublishingEventArgs e)
{
- TelemetryJobRun tRun = e.Package.PendingTelemetry.TelemetryObject as TelemetryJobRun;
+ //TelemetryJobRun tRun = e.Package.PendingTelemetry.TelemetryObject as TelemetryJobRun;
- if (_machineInfos == null)
- {
- using (ObservablesContext db = ObservablesContext.CreateDefault())
- {
- _machineInfos = new List<MachineExtendedInfo>();
- var machinesOrganizations = db.Machines.Include(x => x.Organization).Select(x => new { x, x.Organization.Name, x.SiteGuid }).ToList();
- foreach (var item in machinesOrganizations)
- {
- MachineExtendedInfo info = new MachineExtendedInfo();
- info.Machine = item.x;
- info.Organization = item.Name;
- info.Site = db.Sites.FirstOrDefault(x => x.Guid == item.SiteGuid)?.Name;
- _machineInfos.Add(info);
- }
- }
- }
+ //if (_machineInfos == null)
+ //{
+ // using (ObservablesContext db = ObservablesContext.CreateDefault())
+ // {
+ // _machineInfos = new List<MachineExtendedInfo>();
+ // var machinesOrganizations = db.Machines.Include(x => x.Organization).Select(x => new { x, x.Organization.Name, x.SiteGuid }).ToList();
+ // foreach (var item in machinesOrganizations)
+ // {
+ // MachineExtendedInfo info = new MachineExtendedInfo();
+ // info.Machine = item.x;
+ // info.Organization = item.Name;
+ // info.Site = db.Sites.FirstOrDefault(x => x.Guid == item.SiteGuid)?.Name;
+ // _machineInfos.Add(info);
+ // }
+ // }
+ //}
- var machineInfo = _machineInfos.FirstOrDefault(x => x.Machine.Guid == tRun.MachineGuid);
+ //var machineInfo = _machineInfos.FirstOrDefault(x => x.Machine.Guid == tRun.MachineGuid);
- if (machineInfo == null)
- {
- e.Cancel = true;
- }
- else
- {
- e.Package.Organization = machineInfo.Organization;
- e.Package.Site = machineInfo.Site;
- e.Package.SerialNumber = machineInfo.Machine.SerialNumber;
- e.Package.MachineType = machineInfo.Machine.Type.ToShortName();
- }
+ //if (machineInfo == null)
+ //{
+ // e.Cancel = true;
+ //}
+ //else
+ //{
+ // e.Package.Organization = machineInfo.Organization;
+ // e.Package.Site = machineInfo.Site;
+ // e.Package.SerialNumber = machineInfo.Machine.SerialNumber;
+ // e.Package.MachineType = machineInfo.Machine.Type.ToShortName();
+ //}
}
private static void Publisher_PublishResultAvailable(object sender, TelemetryPublishResultAvailableEventArgs e)
@@ -163,4 +166,46 @@ namespace Tango.Telemetry.Tester.IOT.CLI
}
}
}
+
+ public class DiagnosticsTestSource : ITelemetryStreamingSource
+ {
+ public bool IsStarted { get; private set; }
+ public string Name { get; } = "Diagnostics Test";
+ public bool RequiresTelemetryDuplicationTracking { get; }
+
+ public event EventHandler<TelemetryAvailableEventArgs> TelemetryAvailable;
+
+ public void Dispose()
+ {
+ Stop();
+ }
+
+ public void Start()
+ {
+ IsStarted = true;
+
+ Task.Factory.StartNew(() =>
+ {
+ InsightsFile file = InsightsFile.FromFile("sample.insights");
+ foreach (var rawFrame in file.Frames.Where(x => !x.IsEmpty))
+ {
+ var monitors = rawFrame.ToInsightsMonitors();
+
+ TelemetryDiagnosticsFrame frame = new TelemetryDiagnosticsFrame();
+ frame.ID = Guid.NewGuid().ToString();
+ frame.Time = DateTime.UtcNow;
+ frame.Monitors = monitors;
+
+ TelemetryAvailable?.Invoke(this, new TelemetryAvailableEventArgs() { TelemetryObject = frame });
+
+ Thread.Sleep(500);
+ }
+ });
+ }
+
+ public void Stop()
+ {
+ IsStarted = false;
+ }
+ }
}
diff --git a/Software/Visual_Studio/Utilities/Tango.Telemetry.Tester.IOT.CLI/Tango.Telemetry.Tester.IOT.CLI.csproj b/Software/Visual_Studio/Utilities/Tango.Telemetry.Tester.IOT.CLI/Tango.Telemetry.Tester.IOT.CLI.csproj
index 4b047b3dd..4ca84f3b0 100644
--- a/Software/Visual_Studio/Utilities/Tango.Telemetry.Tester.IOT.CLI/Tango.Telemetry.Tester.IOT.CLI.csproj
+++ b/Software/Visual_Studio/Utilities/Tango.Telemetry.Tester.IOT.CLI/Tango.Telemetry.Tester.IOT.CLI.csproj
@@ -188,6 +188,9 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
+ <None Include="sample.insights">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
@@ -200,10 +203,18 @@
<Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project>
<Name>Tango.Core</Name>
</ProjectReference>
+ <ProjectReference Include="..\..\Tango.Insights\Tango.Insights.csproj">
+ <Project>{4a55c185-3f8d-41b0-8815-c15f6213a14a}</Project>
+ <Name>Tango.Insights</Name>
+ </ProjectReference>
<ProjectReference Include="..\..\Tango.Logging\Tango.Logging.csproj">
<Project>{BC932DBD-7CDB-488C-99E4-F02CF441F55E}</Project>
<Name>Tango.Logging</Name>
</ProjectReference>
+ <ProjectReference Include="..\..\Tango.PMR\Tango.PMR.csproj">
+ <Project>{e4927038-348d-4295-aaf4-861c58cb3943}</Project>
+ <Name>Tango.PMR</Name>
+ </ProjectReference>
<ProjectReference Include="..\..\Tango.Telemetry\Tango.Telemetry.csproj">
<Project>{af593663-d4e9-4a14-a3f2-fea57f30e9e6}</Project>
<Name>Tango.Telemetry</Name>
diff --git a/Software/Visual_Studio/Utilities/Tango.Telemetry.Tester.IOT.CLI/sample.insights b/Software/Visual_Studio/Utilities/Tango.Telemetry.Tester.IOT.CLI/sample.insights
new file mode 100644
index 000000000..9caa7ce31
--- /dev/null
+++ b/Software/Visual_Studio/Utilities/Tango.Telemetry.Tester.IOT.CLI/sample.insights
Binary files differ