aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Azure
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2024-10-06 00:59:30 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2024-10-06 00:59:30 +0300
commitd278567561229b18bd68b4e02f8f841fc21ce3f1 (patch)
tree416e34443cbefcf4bab0d94c07b7ca351ce396bc /Software/Visual_Studio/Azure
parent12566937e99f64f3e9b97f1bcd11d941de443d05 (diff)
downloadTango-d278567561229b18bd68b4e02f8f841fc21ce3f1.tar.gz
Tango-d278567561229b18bd68b4e02f8f841fc21ce3f1.zip
Added support for azure utils X4 firmware injection.
Diffstat (limited to 'Software/Visual_Studio/Azure')
-rw-r--r--Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentFirmwareUpgradeViewVM.cs22
-rw-r--r--Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentFirmwareUpgradeView.xaml12
-rw-r--r--Software/Visual_Studio/Azure/Tango.AzureUtils/Firmware/FirmwareManager.cs29
-rw-r--r--Software/Visual_Studio/Azure/Tango.AzureUtils/Storage/StorageManager.cs49
4 files changed, 92 insertions, 20 deletions
diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentFirmwareUpgradeViewVM.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentFirmwareUpgradeViewVM.cs
index 931182c90..743561e8b 100644
--- a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentFirmwareUpgradeViewVM.cs
+++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentFirmwareUpgradeViewVM.cs
@@ -10,6 +10,7 @@ using System.Threading.Tasks;
using System.Windows;
using Tango.AzureUtils.Environment;
using Tango.AzureUtils.Firmware;
+using Tango.BL.Enumerations;
using Tango.Core.Commands;
namespace Tango.AzureUtils.UI.ViewModels
@@ -32,6 +33,21 @@ namespace Tango.AzureUtils.UI.ViewModels
set { _selectedDeploymentSlot = value; RaisePropertyChangedAuto(); }
}
+ private List<MachineTypes> _machineTypes;
+ public List<MachineTypes> MachineTypes
+ {
+ get { return _machineTypes; }
+ set { _machineTypes = value; RaisePropertyChangedAuto(); }
+ }
+
+ private MachineTypes _selectedMachineType;
+ public MachineTypes SelectedMachineType
+ {
+ get { return _selectedMachineType; }
+ set { _selectedMachineType = value; RaisePropertyChangedAuto(); }
+ }
+
+
private String _filePath;
public String FilePath
{
@@ -53,6 +69,8 @@ namespace Tango.AzureUtils.UI.ViewModels
{
UpgradeFirmwareCommand = new RelayCommand(UpgradeFirmware, () => FilePath != null);
BrowseFileCommand = new RelayCommand(BrowseFile);
+
+ MachineTypes = Enum.GetValues(typeof(MachineTypes)).Cast<MachineTypes>().ToList();
}
public override void OnAuthenticated(IAzure azure, List<IWebAppBase> apps)
@@ -68,7 +86,7 @@ namespace Tango.AzureUtils.UI.ViewModels
private async void BrowseFile()
{
OpenFileDialog dlg = new OpenFileDialog();
- dlg.Title = "Select Tango Firmware Package";
+ dlg.Title = "Select Firmware Package";
dlg.Filter = "Tango Firmware Package Files|*.tfp";
if (dlg.ShowDialog().Value)
{
@@ -93,7 +111,7 @@ namespace Tango.AzureUtils.UI.ViewModels
IsFree = false;
- await _firmwareManager.InjectFirmwarePackage(SelectedDeploymentSlot, FilePath, null);
+ await _firmwareManager.InjectFirmwarePackage(SelectedDeploymentSlot, SelectedMachineType, FilePath, null);
}
catch (Exception ex)
{
diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentFirmwareUpgradeView.xaml b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentFirmwareUpgradeView.xaml
index 330d6b3a4..0e7ffc7a0 100644
--- a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentFirmwareUpgradeView.xaml
+++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentFirmwareUpgradeView.xaml
@@ -31,7 +31,17 @@
<Grid Grid.Column="1">
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" MinWidth="300">
- <GroupBox Header="Firmware Package Selection" Padding="30" Width="500">
+
+ <GroupBox Header="Machine Type Selection" Padding="30" Width="500">
+ <StackPanel>
+ <TextBlock>Select Machine Type</TextBlock>
+ <DockPanel Margin="0 10 0 0">
+ <ComboBox ItemsSource="{Binding MachineTypes}" SelectedItem="{Binding SelectedMachineType}"></ComboBox>
+ </DockPanel>
+ </StackPanel>
+ </GroupBox>
+
+ <GroupBox Header="Firmware Package Selection" Padding="30" Width="500" Margin="0 20 0 0">
<StackPanel>
<TextBlock>Browse for .tfp file and press upgrade.</TextBlock>
<DockPanel Margin="0 10 0 0">
diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils/Firmware/FirmwareManager.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils/Firmware/FirmwareManager.cs
index ac8e52a65..6ab2c4544 100644
--- a/Software/Visual_Studio/Azure/Tango.AzureUtils/Firmware/FirmwareManager.cs
+++ b/Software/Visual_Studio/Azure/Tango.AzureUtils/Firmware/FirmwareManager.cs
@@ -12,6 +12,8 @@ using Microsoft.Azure.Management.Fluent;
using Tango.AzureUtils.Database;
using Tango.AzureUtils.Storage;
using Tango.BL;
+using Tango.BL.Entities;
+using Tango.BL.Enumerations;
using Tango.PMR.FirmwareUpgrade;
using Tango.PPC.Common.Publish;
@@ -30,7 +32,7 @@ namespace Tango.AzureUtils.Firmware
#region Firmware Injection
- public async Task InjectFirmwarePackage(IWebAppBase slot, String tfpFile, String versionTag)
+ public async Task InjectFirmwarePackage(IWebAppBase slot, MachineTypes machineType, String tfpFile, String versionTag)
{
OnProgress(AzureUtilsStage.Firmware, $"Validating TFP package...");
@@ -46,11 +48,24 @@ namespace Tango.AzureUtils.Firmware
throw new ValidationException($"The specified TFP package is invalid.\n{ex.FlattenMessage()}");
}
- var ppcVersion = await _databaseManager.GetLatestPPCVersion(slot, null);
+ TangoVersion version = null;
- if (Version.Parse(ppcVersion.FirmwareVersion) >= tfpPackage.GetMcuVersion())
+ if (machineType == MachineTypes.TS1800)
{
- await RequestConfirmation($"The specified firmware version is '{tfpPackage.GetMcuVersion()}' while latest version is '{ppcVersion.FirmwareVersion}'. Do you wish to continue?");
+ version = await _databaseManager.GetLatestPPCVersion(slot, null);
+ }
+ else if (machineType == MachineTypes.Eureka)
+ {
+ version = await _databaseManager.GetLatestEurekaVersion(slot, null);
+ }
+ else
+ {
+ throw new NotImplementedException("Machine type not supported for this action.");
+ }
+
+ if (Version.Parse(version.FirmwareVersion) >= tfpPackage.GetMcuVersion())
+ {
+ await RequestConfirmation($"The specified firmware version is '{tfpPackage.GetMcuVersion()}' while latest version is '{version.FirmwareVersion}'. Do you wish to continue?");
}
OnProgress(AzureUtilsStage.Firmware, $"Retrieving '{slot.Name}' settings...");
@@ -60,7 +75,7 @@ namespace Tango.AzureUtils.Firmware
var zipFile = TemporaryManager.CreateImaginaryFile(".zip");
- await _storageManager.DownloadLatestPPCVersion(slot, zipFile, versionTag);
+ await _storageManager.DownloadLatestVersion(slot, machineType, zipFile, versionTag);
OnProgress(AzureUtilsStage.Firmware, $"Replacing firmware_package.tfp...");
await Task.Factory.StartNew(() =>
@@ -84,12 +99,12 @@ namespace Tango.AzureUtils.Firmware
}
});
- await _storageManager.ReplaceLatestPPCVersion(slot, zipFile, versionTag);
+ await _storageManager.ReplaceLatestPPCVersion(slot, machineType, zipFile, versionTag);
OnProgress(AzureUtilsStage.Firmware, $"Updating firmware version on database...");
using (ObservablesContext db = ObservablesContext.CreateDefault(settings.ToDataSource()))
{
- var v = await db.TangoVersions.SingleOrDefaultAsync(x => x.Guid == ppcVersion.Guid);
+ var v = await db.TangoVersions.SingleOrDefaultAsync(x => x.Guid == version.Guid);
v.FirmwareVersion = tfpPackage.GetMcuVersion().ToString();
await db.SaveChangesAsync();
}
diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils/Storage/StorageManager.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils/Storage/StorageManager.cs
index d16a3f90b..cb442b6b4 100644
--- a/Software/Visual_Studio/Azure/Tango.AzureUtils/Storage/StorageManager.cs
+++ b/Software/Visual_Studio/Azure/Tango.AzureUtils/Storage/StorageManager.cs
@@ -10,6 +10,7 @@ using Microsoft.Azure.Management.Fluent;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
using Tango.AzureUtils.Database;
+using Tango.BL.Entities;
using Tango.BL.Enumerations;
using Tango.Core.IO;
@@ -355,54 +356,82 @@ namespace Tango.AzureUtils.Storage
}
}
- public async Task DownloadLatestPPCVersion(IWebAppBase app, String filePath, String versionTag)
+ public async Task DownloadLatestVersion(IWebAppBase app, MachineTypes machineType, String filePath, String versionTag)
{
OnProgress(AzureUtilsStage.Storage, $"Retrieving source and target settings...");
var settings = await app.GetMachineServiceSettingsAsync();
- var ppcVersion = await _databaseManager.GetLatestPPCVersion(app, versionTag);
- OnProgress(AzureUtilsStage.Storage, $"Downloading PPC version '{ppcVersion.Version}'...");
+ TangoVersion version = null;
+
+ if (machineType == MachineTypes.TS1800)
+ {
+ version = await _databaseManager.GetLatestPPCVersion(app, versionTag);
+ }
+ else if (machineType == MachineTypes.Eureka)
+ {
+ version = await _databaseManager.GetLatestEurekaVersion(app, versionTag);
+ }
+ else
+ {
+ throw new NotImplementedException("Machine type not supported for this action.");
+ }
+
+ OnProgress(AzureUtilsStage.Storage, $"Downloading {machineType.ToDescription()} version '{version.Version}'...");
var account = CloudStorageAccount.Parse(settings.STORAGE_ACCOUNT);
var client = account.CreateCloudBlobClient();
var container = client.GetContainerReference(settings.TANGO_VERSIONS_CONTAINER);
- var blob = container.GetBlockBlobReference(ppcVersion.BlobName);
+ var blob = container.GetBlockBlobReference(version.BlobName);
await blob.FetchAttributesAsync();
var length = blob.Properties.Length;
using (FileStreamWrapper st = new FileStreamWrapper(filePath, FileMode.Create, (progress) =>
{
- OnProgress(AzureUtilsStage.Storage, $"Downloading PPC version '{ppcVersion.VersionAndTag}'...", progress, length, false);
+ OnProgress(AzureUtilsStage.Storage, $"Downloading {machineType.ToDescription()} version '{version.VersionAndTag}'...", progress, length, false);
}))
{
await blob.DownloadToStreamAsync(st);
}
}
- public async Task ReplaceLatestPPCVersion(IWebAppBase app, String filePath, String versionTag)
+ public async Task ReplaceLatestPPCVersion(IWebAppBase app, MachineTypes machineType, String filePath, String versionTag)
{
OnProgress(AzureUtilsStage.Storage, $"Retrieving source and target settings...");
var settings = await app.GetMachineServiceSettingsAsync();
- var ppcVersion = await _databaseManager.GetLatestPPCVersion(app, versionTag);
- OnProgress(AzureUtilsStage.Storage, $"Uploading PPC version '{ppcVersion.VersionAndTag}'...");
+ TangoVersion version = null;
+
+ if (machineType == MachineTypes.TS1800)
+ {
+ version = await _databaseManager.GetLatestPPCVersion(app, versionTag);
+ }
+ else if (machineType == MachineTypes.Eureka)
+ {
+ version = await _databaseManager.GetLatestEurekaVersion(app, versionTag);
+ }
+ else
+ {
+ throw new NotImplementedException("Machine type not supported for this action.");
+ }
+
+ OnProgress(AzureUtilsStage.Storage, $"Uploading {machineType.ToDescription()} version '{version.VersionAndTag}'...");
var account = CloudStorageAccount.Parse(settings.STORAGE_ACCOUNT);
var client = account.CreateCloudBlobClient();
var container = client.GetContainerReference(settings.TANGO_VERSIONS_CONTAINER);
- var blob = container.GetBlockBlobReference(ppcVersion.BlobName);
+ var blob = container.GetBlockBlobReference(version.BlobName);
FileStreamWrapper st = null;
using (st = new FileStreamWrapper(filePath, FileMode.Open, (progress) =>
{
- OnProgress(AzureUtilsStage.Storage, $"Uploading PPC version '{ppcVersion.Version}'...", progress, st.Length, false);
+ OnProgress(AzureUtilsStage.Storage, $"Uploading {machineType.ToDescription()} version '{version.Version}'...", progress, st.Length, false);
}))
{
await blob.UploadFromStreamAsync(st);