aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Integration/Upgrade
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-12-02 16:37:25 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-12-02 16:37:25 +0200
commita2d959a7777bf2387d0f50dbc1ecf69f53e2253d (patch)
tree8c6367189294d96ae074f386cdb4139dfeacb84a /Software/Visual_Studio/Tango.Integration/Upgrade
parentae614a63f593122cd28c644625db179f298dd640 (diff)
downloadTango-a2d959a7777bf2387d0f50dbc1ecf69f53e2253d.tar.gz
Tango-a2d959a7777bf2387d0f50dbc1ecf69f53e2253d.zip
Implemented machine studio storage module. firmware upgrade version/validate/activate.
Implemented firmware package generator utility.
Diffstat (limited to 'Software/Visual_Studio/Tango.Integration/Upgrade')
-rw-r--r--Software/Visual_Studio/Tango.Integration/Upgrade/FirmwareUpgradeHandler.cs108
-rw-r--r--Software/Visual_Studio/Tango.Integration/Upgrade/FirmwareUpgradeProgressEventArgs.cs16
-rw-r--r--Software/Visual_Studio/Tango.Integration/Upgrade/FirmwareUpgradeStatus.cs31
3 files changed, 155 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.Integration/Upgrade/FirmwareUpgradeHandler.cs b/Software/Visual_Studio/Tango.Integration/Upgrade/FirmwareUpgradeHandler.cs
new file mode 100644
index 000000000..774824b49
--- /dev/null
+++ b/Software/Visual_Studio/Tango.Integration/Upgrade/FirmwareUpgradeHandler.cs
@@ -0,0 +1,108 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.Core;
+using Tango.Integration.Storage;
+
+namespace Tango.Integration.Upgrade
+{
+ public class FirmwareUpgradeHandler : ExtendedObject
+ {
+ private Action _cancelAction;
+
+ public event EventHandler<FirmwareUpgradeProgressEventArgs> Progress;
+ public event EventHandler Completed;
+ public event EventHandler Canceled;
+ public event EventHandler<Exception> Failed;
+
+ internal FirmwareUpgradeHandler()
+ {
+ Message = "Initializing...";
+ }
+
+ internal FirmwareUpgradeHandler(Action cancelAction) : this()
+ {
+ _cancelAction = cancelAction;
+ }
+
+ private String _message;
+ public String Message
+ {
+ get { return _message; }
+ set { _message = value; RaisePropertyChangedAuto(); }
+ }
+
+ private FirmwareUpgradeStatus _status;
+ public FirmwareUpgradeStatus Status
+ {
+ get { return _status; }
+ private set { _status = value; RaisePropertyChangedAuto(); }
+ }
+
+ private long _current;
+ public long Current
+ {
+ get { return _current; }
+ internal set
+ {
+ _current = value; RaisePropertyChangedAuto();
+ }
+ }
+
+ private long _total;
+ public long Total
+ {
+ get { return _total; }
+ internal set { _total = value; RaisePropertyChangedAuto(); }
+ }
+
+ public Task Cancel()
+ {
+ return Task.Factory.StartNew(() =>
+ {
+ _cancelAction.Invoke();
+ Message = "Canceled.";
+ Status = FirmwareUpgradeStatus.Canceled;
+ Canceled?.Invoke(this, new EventArgs());
+ });
+ }
+
+ internal void RaiseCompleted()
+ {
+ Status = FirmwareUpgradeStatus.Completed;
+ Message = "Completed.";
+ Completed?.Invoke(this, new EventArgs());
+ }
+
+ internal void RaiseCanceled()
+ {
+ Status = FirmwareUpgradeStatus.Canceled;
+ Message = "Canceled.";
+ Canceled?.Invoke(this, new EventArgs());
+ }
+
+ internal void RaiseFailed(Exception ex)
+ {
+ Status = FirmwareUpgradeStatus.Failed;
+ Message = "Failed.";
+ Failed?.Invoke(this, ex);
+ }
+
+ internal void RaiseProgress(long current, FirmwareUpgradeStatus status, String message)
+ {
+ Current = current;
+ Status = status;
+ Message = message;
+
+ Progress?.Invoke(this, new FirmwareUpgradeProgressEventArgs()
+ {
+ Current = Current,
+ Status = Status,
+ Total = Total,
+ Message = Message,
+ });
+ }
+ }
+}
diff --git a/Software/Visual_Studio/Tango.Integration/Upgrade/FirmwareUpgradeProgressEventArgs.cs b/Software/Visual_Studio/Tango.Integration/Upgrade/FirmwareUpgradeProgressEventArgs.cs
new file mode 100644
index 000000000..fa4f4cc96
--- /dev/null
+++ b/Software/Visual_Studio/Tango.Integration/Upgrade/FirmwareUpgradeProgressEventArgs.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.Integration.Upgrade
+{
+ public class FirmwareUpgradeProgressEventArgs : EventArgs
+ {
+ public long Current { get; set; }
+ public long Total { get; set; }
+ public FirmwareUpgradeStatus Status { get; set; }
+ public String Message { get; set; }
+ }
+}
diff --git a/Software/Visual_Studio/Tango.Integration/Upgrade/FirmwareUpgradeStatus.cs b/Software/Visual_Studio/Tango.Integration/Upgrade/FirmwareUpgradeStatus.cs
new file mode 100644
index 000000000..0d8449ee9
--- /dev/null
+++ b/Software/Visual_Studio/Tango.Integration/Upgrade/FirmwareUpgradeStatus.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.Integration.Upgrade
+{
+ public enum FirmwareUpgradeStatus
+ {
+ [Description("Initializing...")]
+ Initializing,
+ [Description("Uploading files...")]
+ Uploading,
+ [Description("Validating version...")]
+ Validating,
+ [Description("Activating version...")]
+ Activating,
+ [Description("Waiting for device reboot...")]
+ WaitingForReboot,
+ [Description("Connecting...")]
+ Connecting,
+ [Description("Completed")]
+ Completed,
+ [Description("Aborted")]
+ Canceled,
+ [Description("Failed")]
+ Failed,
+ }
+}