aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/FSE/Tango.FSE.Common/Logging
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-04-10 15:06:42 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-04-10 15:06:42 +0300
commitb4682a3abfe299c19b24752b2fb1ce2477611ec3 (patch)
tree1d7c87eb5c3eba0d4bf7103fa8717ba62faaccc2 /Software/Visual_Studio/FSE/Tango.FSE.Common/Logging
parentd03741164872fc4d849407ed877b6ea00220cc67 (diff)
downloadTango-b4682a3abfe299c19b24752b2fb1ce2477611ec3.tar.gz
Tango-b4682a3abfe299c19b24752b2fb1ce2477611ec3.zip
Implemented FSE/PPC Logs.
Diffstat (limited to 'Software/Visual_Studio/FSE/Tango.FSE.Common/Logging')
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.Common/Logging/ILoggingProvider.cs37
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.Common/Logging/RemoteLogFileModel.cs128
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.Common/Logging/RemoteLogFileStatus.cs19
3 files changed, 182 insertions, 2 deletions
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Logging/ILoggingProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/Logging/ILoggingProvider.cs
index d49f8b21d..68c288e60 100644
--- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Logging/ILoggingProvider.cs
+++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Logging/ILoggingProvider.cs
@@ -1,10 +1,13 @@
using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Tango.FSE.Common.FileSystem;
using Tango.Integration.Logging;
using Tango.Logging;
+using Tango.PPC.Shared.Logs;
namespace Tango.FSE.Common.Logging
{
@@ -14,13 +17,43 @@ namespace Tango.FSE.Common.Logging
public interface ILoggingProvider
{
/// <summary>
+ /// Gets the last retrieved history of the application log files.
+ /// </summary>
+ ObservableCollection<RemoteLogFile> ApplicationLogFiles { get; }
+
+ /// <summary>
+ /// Gets the last retrieved history of the embedded firmware log files.
+ /// </summary>
+ ObservableCollection<RemoteLogFile> FirmwareLogFiles { get; }
+
+ /// <summary>
+ /// Gets the history of application log files.
+ /// </summary>
+ /// <returns></returns>
+ Task<List<RemoteLogFile>> GetApplicationLogFiles();
+
+ /// <summary>
+ /// Gets the history of the embedded firmware log files.
+ /// </summary>
+ /// <returns></returns>
+ Task<List<RemoteLogFile>> GetFirmwareLogFiles();
+
+ /// <summary>
+ /// Downloads the specified remote log file.
+ /// </summary>
+ /// <param name="logFile">The log file.</param>
+ /// <param name="targetFolder">Target folder.</param>
+ /// <returns></returns>
+ Task<FileSystemHandler> DownloadLogFile(RemoteLogFile logFile, String targetFolder);
+
+ /// <summary>
/// Occurs when a new PPC application log is available.
/// </summary>
event EventHandler<LogItemBase> ApplicationLogAvailable;
/// <summary>
- /// Occurs when a new embedded log is available.
+ /// Occurs when a new embedded firmware log is available.
/// </summary>
- event EventHandler<EmbeddedLogItem> EmbeddedLogAvailable;
+ event EventHandler<EmbeddedLogItem> FirmwareLogAvailable;
}
}
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Logging/RemoteLogFileModel.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/Logging/RemoteLogFileModel.cs
new file mode 100644
index 000000000..cf71ed270
--- /dev/null
+++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Logging/RemoteLogFileModel.cs
@@ -0,0 +1,128 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+using Tango.Core;
+using Tango.Core.Commands;
+using Tango.Core.DI;
+using Tango.FSE.Common.FileSystem;
+using Tango.Logging;
+using Tango.PPC.Shared.Logs;
+using Tango.SharedUI.Components;
+
+namespace Tango.FSE.Common.Logging
+{
+ /// <summary>
+ /// Represents a remote log file model.
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <seealso cref="Tango.Core.ExtendedObject" />
+ public class RemoteLogFileModel<T> : ExtendedObject where T : LogItemBase
+ {
+ private ILogFileParser<T> _parser;
+
+ /// <summary>
+ /// Occurs when the remote log file has downloaded successfully.
+ /// </summary>
+ public event EventHandler DownloadCompleted;
+
+ [TangoInject]
+ private ILoggingProvider LoggingProvider { get; set; }
+
+ /// <summary>
+ /// Gets or sets the remote log file.
+ /// </summary>
+ public RemoteLogFile RemoteLogFile { get; set; }
+
+ /// <summary>
+ /// Gets the duration of the remote log file.
+ /// </summary>
+ public TimeSpan Duration
+ {
+ get { return RemoteLogFile.DateModified - RemoteLogFile.DateCreated; }
+ }
+
+ private RemoteLogFileStatus _status;
+ /// <summary>
+ /// Gets or sets the remote log file status.
+ /// </summary>
+ public RemoteLogFileStatus Status
+ {
+ get { return _status; }
+ set { _status = value; RaisePropertyChangedAuto(); }
+ }
+
+ private FileSystemHandler _handler;
+ /// <summary>
+ /// Gets or sets the remote log file download handler.
+ /// </summary>
+ public FileSystemHandler Handler
+ {
+ get { return _handler; }
+ set { _handler = value; RaisePropertyChangedAuto(); }
+ }
+
+ /// <summary>
+ /// Gets or sets the temporary file (where the actual log file is stored locally).
+ /// </summary>
+ public String TemporaryFile { get; set; }
+
+ private ObservableCollection<LogItemBase> _logItems;
+ /// <summary>
+ /// Gets or sets the log items.
+ /// </summary>
+ public ObservableCollection<LogItemBase> LogItems
+ {
+ get { return _logItems; }
+ set { _logItems = value; RaisePropertyChangedAuto(); }
+ }
+
+ /// <summary>
+ /// Gets or sets the download command.
+ /// </summary>
+ public RelayCommand DownloadCommand { get; set; }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="RemoteLogFileModel{T}"/> class.
+ /// </summary>
+ /// <param name="parser">The parser.</param>
+ public RemoteLogFileModel(ILogFileParser<T> parser)
+ {
+ TangoIOC.Default.Inject(this);
+ _parser = parser;
+ LogItems = new ObservableCollection<LogItemBase>();
+ DownloadCommand = new RelayCommand(DownloadLogFile);
+ }
+
+ /// <summary>
+ /// Downloads the log file.
+ /// </summary>
+ public async void DownloadLogFile()
+ {
+ if (Status == RemoteLogFileStatus.None || Status == RemoteLogFileStatus.Failed)
+ {
+ Status = RemoteLogFileStatus.Downloading;
+ String tempLogFile = TemporaryManager.CreateImaginaryFile(".log");
+ Handler = await LoggingProvider.DownloadLogFile(RemoteLogFile, tempLogFile);
+ Handler.StatusChanged += (x, status) =>
+ {
+ if (status == FileSystemHandlerStatus.Completed)
+ {
+ TemporaryFile = tempLogFile;
+ LogItems = new ObservableCollection<LogItemBase>(_parser.Parse(tempLogFile, RemoteLogFile.DateCreated.ToLocalTime()));
+ Status = RemoteLogFileStatus.Downloaded;
+ DownloadCompleted?.Invoke(this, new EventArgs());
+ }
+ else if (status == FileSystemHandlerStatus.Failed)
+ {
+ Status = RemoteLogFileStatus.Failed;
+ }
+ };
+ }
+ }
+ }
+}
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Logging/RemoteLogFileStatus.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/Logging/RemoteLogFileStatus.cs
new file mode 100644
index 000000000..25f3f4eac
--- /dev/null
+++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Logging/RemoteLogFileStatus.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.FSE.Common.Logging
+{
+ /// <summary>
+ /// Represents the remote log file statuses.
+ /// </summary>
+ public enum RemoteLogFileStatus
+ {
+ None,
+ Downloading,
+ Downloaded,
+ Failed,
+ }
+}