aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Integration/Diagnostics
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-04-08 16:55:37 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-04-08 16:55:37 +0300
commit17a77c30765fe8a0d3ca57a9ec60fb43b82432d2 (patch)
tree54881e3de14aaef3ad5e699f28d903a11a024b57 /Software/Visual_Studio/Tango.Integration/Diagnostics
parentb3bc15a29d8fff24edc5bcd4576e18c9141f76a6 (diff)
downloadTango-17a77c30765fe8a0d3ca57a9ec60fb43b82432d2.tar.gz
Tango-17a77c30765fe8a0d3ca57a9ec60fb43b82432d2.zip
Implemented timeline events !
Diffstat (limited to 'Software/Visual_Studio/Tango.Integration/Diagnostics')
-rw-r--r--Software/Visual_Studio/Tango.Integration/Diagnostics/DiagnosticsFileEvent.cs54
-rw-r--r--Software/Visual_Studio/Tango.Integration/Diagnostics/DiagnosticsFilePlayer.cs16
-rw-r--r--Software/Visual_Studio/Tango.Integration/Diagnostics/DiagnosticsFileRecorder.cs13
-rw-r--r--Software/Visual_Studio/Tango.Integration/Diagnostics/DiagnosticsTimeCodeChannel.cs4
4 files changed, 87 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.Integration/Diagnostics/DiagnosticsFileEvent.cs b/Software/Visual_Studio/Tango.Integration/Diagnostics/DiagnosticsFileEvent.cs
new file mode 100644
index 000000000..a6132c6d3
--- /dev/null
+++ b/Software/Visual_Studio/Tango.Integration/Diagnostics/DiagnosticsFileEvent.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.BL;
+using Tango.BL.Entities;
+
+namespace Tango.Integration.Diagnostics
+{
+ [Serializable]
+ public class DiagnosticsFileEvent
+ {
+ public DateTime DateTime { get; set; }
+
+ public String EventTypeGuid { get; set; }
+
+ public String HostName { get; set; }
+
+ public String UserGuid { get; set; }
+
+ public String MachineGuid { get; set; }
+
+ public String Description { get; set; }
+
+ public DiagnosticsFileEvent()
+ {
+
+ }
+
+ public DiagnosticsFileEvent(MachinesEvent ev) : this()
+ {
+ DateTime = ev.DateTime;
+ EventTypeGuid = ev.EventType.Guid;
+ HostName = ev.HostName;
+ UserGuid = ev.UserGuid;
+ MachineGuid = ev.MachineGuid;
+ Description = ev.Description;
+ }
+
+ public MachinesEvent ToMachineEvent()
+ {
+ MachinesEvent ev = new MachinesEvent();
+ ev.DateTime = DateTime;
+ ev.EventType = ObservablesEntitiesAdapter.Instance.EventTypes.SingleOrDefault(x => x.Guid == EventTypeGuid);
+ ev.Machine = ObservablesEntitiesAdapter.Instance.Machines.SingleOrDefault(x => x.Guid == MachineGuid);
+ ev.User = ObservablesEntitiesAdapter.Instance.Users.SingleOrDefault(x => x.Guid == UserGuid);
+ ev.Description = Description;
+ ev.HostName = HostName;
+
+ return ev;
+ }
+ }
+}
diff --git a/Software/Visual_Studio/Tango.Integration/Diagnostics/DiagnosticsFilePlayer.cs b/Software/Visual_Studio/Tango.Integration/Diagnostics/DiagnosticsFilePlayer.cs
index 1900e49e1..7b3cf9859 100644
--- a/Software/Visual_Studio/Tango.Integration/Diagnostics/DiagnosticsFilePlayer.cs
+++ b/Software/Visual_Studio/Tango.Integration/Diagnostics/DiagnosticsFilePlayer.cs
@@ -5,6 +5,7 @@ using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
+using Tango.BL.Entities;
using Tango.Core;
using Tango.Logging;
using Tango.PMR.Diagnostics;
@@ -113,6 +114,16 @@ namespace Tango.Integration.Diagnostics
private set { _totalFrames = value; RaisePropertyChangedAuto(); }
}
+ private List<MachinesEvent> _machineEvents;
+ /// <summary>
+ /// Gets or sets the machine events.
+ /// </summary>
+ public List<MachinesEvent> MachineEvents
+ {
+ get { return _machineEvents; }
+ set { _machineEvents = value; RaisePropertyChangedAuto(); }
+ }
+
#endregion
#region Public Methods
@@ -149,6 +160,11 @@ namespace Tango.Integration.Diagnostics
TotalFrames = _timeCodeChannel.Frames.Count;
TotalTime = TimeSpan.FromMilliseconds(_timeCodeChannel.Frames.Last().Milliseconds);
+ if (_timeCodeChannel.Events != null)
+ {
+ MachineEvents = _timeCodeChannel.Events.Select(x => x.ToMachineEvent()).ToList();
+ }
+
IsLoaded = true;
}
catch (Exception ex)
diff --git a/Software/Visual_Studio/Tango.Integration/Diagnostics/DiagnosticsFileRecorder.cs b/Software/Visual_Studio/Tango.Integration/Diagnostics/DiagnosticsFileRecorder.cs
index 5569cc227..f5c420217 100644
--- a/Software/Visual_Studio/Tango.Integration/Diagnostics/DiagnosticsFileRecorder.cs
+++ b/Software/Visual_Studio/Tango.Integration/Diagnostics/DiagnosticsFileRecorder.cs
@@ -9,6 +9,7 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Media.Imaging;
+using Tango.BL.Entities;
using Tango.Core;
using Tango.Core.Helpers;
using Tango.Logging;
@@ -31,6 +32,7 @@ namespace Tango.Integration.Diagnostics
private FileStream _dataFileStream; //Holds the temporary recording file stream.
private TaskCompletionSource<object> _stopCompletionSource; //Holds the "Stop" async method completion source.
private DiagnosticsTimeCodeChannel _timeCodeChannel; //Holds the diagnostics time code channel.
+ private List<DiagnosticsFileEvent> _events;
private Stopwatch _stopWatch; //Holds the stop watch for keeping tracks over frames time stamps.
private DateTime _lastVideoPush;
private List<BitmapSource> _videoFrames;
@@ -139,6 +141,7 @@ namespace Tango.Integration.Diagnostics
}
_tempDataFileName = PathHelper.GetTempFilePath();
_frames = new ConcurrentQueue<DataFileFrame>();
+ _events = new List<DiagnosticsFileEvent>();
_timeCodeChannel = new DiagnosticsTimeCodeChannel();
TotalDataBytesRecorded = 0;
TotalFramesRecorded = 0;
@@ -173,6 +176,15 @@ namespace Tango.Integration.Diagnostics
}
/// <summary>
+ /// Writes a machine event to the diagnostics file.
+ /// </summary>
+ /// <param name="data">The data.</param>
+ public void Write(MachinesEvent ev)
+ {
+ _events.Add(new DiagnosticsFileEvent(ev));
+ }
+
+ /// <summary>
/// Writes a diagnostics packet to the recording.
/// </summary>
/// <param name="data">The data.</param>
@@ -247,6 +259,7 @@ namespace Tango.Integration.Diagnostics
{
BinaryDataSerializer serializer = new BinaryDataSerializer();
+ _timeCodeChannel.Events = _events;
byte[] timeCodeData = serializer.SerializeToBytes(_timeCodeChannel);
using (FileStream fs = new FileStream(fileName, FileMode.Create))
diff --git a/Software/Visual_Studio/Tango.Integration/Diagnostics/DiagnosticsTimeCodeChannel.cs b/Software/Visual_Studio/Tango.Integration/Diagnostics/DiagnosticsTimeCodeChannel.cs
index 4006844ec..242a9709f 100644
--- a/Software/Visual_Studio/Tango.Integration/Diagnostics/DiagnosticsTimeCodeChannel.cs
+++ b/Software/Visual_Studio/Tango.Integration/Diagnostics/DiagnosticsTimeCodeChannel.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Tango.BL.Entities;
namespace Tango.Integration.Diagnostics
{
@@ -18,12 +19,15 @@ namespace Tango.Integration.Diagnostics
/// </summary>
public List<DiagnosticsTimeCodeChannelFrame> Frames { get; set; }
+ public List<DiagnosticsFileEvent> Events { get; set; }
+
/// <summary>
/// Initializes a new instance of the <see cref="DiagnosticsTimeCodeChannel"/> class.
/// </summary>
public DiagnosticsTimeCodeChannel()
{
Frames = new List<DiagnosticsTimeCodeChannelFrame>();
+ Events = new List<DiagnosticsFileEvent>();
}
}
}