aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs')
-rw-r--r--Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs60
1 files changed, 56 insertions, 4 deletions
diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs
index a96693bdf..bae0ec55e 100644
--- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs
+++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs
@@ -1753,10 +1753,14 @@ namespace Tango.Integration.Operation
liquidVolume.Volume = stop.ColorCatalogsItem.Black;
}
}
- else
+ else if (!stop.IsTransparent)
{
throw new InvalidOperationException($"No catalog item specified for segment color.");
}
+ else
+ {
+ stop.SetLiquidVolumes(job.Machine.Configuration, job.Rml, processParameters);
+ }
}
else if (stop.BrushColorSpace == ColorSpaces.Volume)
{
@@ -2911,33 +2915,46 @@ namespace Tango.Integration.Operation
try
{
+ LogManager.Log("Starting firmware upgrade...");
+ LogManager.Log($"Firmware upgrade flags: {String.Join(", ", FirmwareUpgradeMode.GetFlags<FirmwareUpgradeModes>().Select(x => x.ToString()))}");
+
if (Status != MachineStatuses.ReadyToDye)
{
throw LogManager.Log(new InvalidOperationException($"Could not perform firmware upgrade while operator status is '{Status}'."));
}
+ LogManager.Log("Extracting tfp package...");
var package_info = await GetFirmwarePackageInfo(tfpStream);
tfpStream.Position = 0;
+ LogManager.Log("Reading zip stream...");
zip = ZipFile.Read(tfpStream);
+ LogManager.Log("Creating storage manager...");
var storage = CreateStorageManager();
+ LogManager.Log("Getting storage drive information...");
var drive = await storage.GetStorageDrive();
+ LogManager.Log($"Storage drive info:\n{drive.ToJsonString()}");
+ LogManager.Log("Getting root folder...");
var root = await storage.GetRootFolder();
+ LogManager.Log($"Root folder: '{root.Path}'");
var existing_folder = root.Items.SingleOrDefault(x => x.Name == FIRMWARE_UPGRADE_FOLDER_NAME);
if (existing_folder != null)
{
+ LogManager.Log("Root folder exists. Deleting...");
await storage.DeleteItem(existing_folder);
}
String package_folder = Path.Combine(drive.Root, FIRMWARE_UPGRADE_FOLDER_NAME);
+ LogManager.Log($"Creating new folder: '{package_folder}'.");
await storage.CreateFolder(package_folder);
List<StorageFileHandler> handlers = new List<StorageFileHandler>();
List<ZipEntry> entries = zip.Entries.ToList();
List<Stream> streams = new List<Stream>();
+ LogManager.Log("Disabling keep alive...");
var keepAlive = UseKeepAlive;
UseKeepAlive = false;
@@ -2960,7 +2977,19 @@ namespace Tango.Integration.Operation
{
if (FirmwareUpgradeMode.HasFlag(FirmwareUpgradeModes.DFU))
{
- var mcuEntry = zip.Entries.Single(x => x.FileName == package_info.FileDescriptors.Single(y => y.Destination == VersionFileDestination.Mcu).FileName);
+ LogManager.Log("DFU enabled. Starting upgrade via DFU...");
+ LogManager.Log("Extracting MCU file...");
+ ZipEntry mcuEntry = null;
+ try
+ {
+ mcuEntry = zip.Entries.Single(x => x.FileName == package_info.FileDescriptors.Single(y => y.Destination == VersionFileDestination.Mcu).FileName);
+ }
+ catch (Exception ex)
+ {
+ upgradeHandler.RaiseFailed(new IOException("Firmware upgrade via DFU is enabled but no MCU file was found in the package.", ex));
+ return;
+ }
+
MemoryStream ms = new MemoryStream();
mcuEntry.Extract(ms);
ms.Position = 0;
@@ -2974,35 +3003,52 @@ namespace Tango.Integration.Operation
upgradeHandler.RaiseProgress((long)e.Progress, FirmwareUpgradeStatus.Upgrading, e.State.ToDescription());
};
+ LogManager.Log("Disconnecting adapter...");
Adapter.Disconnect().Wait();
if (MachineEventsStateProvider != null)
{
+ LogManager.Log("Resetting active events...");
MachineEventsStateProvider.Reset();
}
+ LogManager.Log("Upgrading...");
upgradeManager.PerformUpgrade(data).Wait();
+ LogManager.Log("Waiting for the device...");
upgradeHandler.RaiseProgress(100, FirmwareUpgradeStatus.Upgrading, "Waiting for the device...");
Thread.Sleep(5000);
+ LogManager.Log("Reconnecting adapter...");
upgradeHandler.RaiseProgress(100, FirmwareUpgradeStatus.Upgrading, "Connecting...");
Adapter.Connect().Wait();
Connect().Wait();
+ LogManager.Log("Connected...");
upgradeHandler.RaiseProgress(100, FirmwareUpgradeStatus.Upgrading, "Connected.");
Thread.Sleep(2000);
+ LogManager.Log("Waiting...");
upgradeHandler.RaiseProgress(100, FirmwareUpgradeStatus.Upgrading, "Waiting...");
Thread.Sleep(2000);
Status = MachineStatuses.Upgrading;
}
+ //Upload tfp package only if specified in flag && package info contains more files other than the mcu bin file.
if (FirmwareUpgradeMode.HasFlag(FirmwareUpgradeModes.TFP_PACKAGE))
{
- upgradeHandler.Total = zip.Entries.Sum(x => x.UncompressedSize);
- uploadNext();
+ if (package_info.FileDescriptors.Where(x => x.Destination != VersionFileDestination.Mcu).Count() > 0)
+ {
+ LogManager.Log("TFP package is enabled. Starting upload...");
+ upgradeHandler.Total = zip.Entries.Sum(x => x.UncompressedSize);
+ uploadNext();
+ }
+ else
+ {
+ LogManager.Log("TFP package is enabled but no other files other than the MCU file were found on the package. Skipping...");
+ postActivation();
+ }
}
else
{
@@ -3026,6 +3072,8 @@ namespace Tango.Integration.Operation
var entry = entries.First();
entries.Remove(entry);
+ LogManager.Log($"Uploading file '{entry.FileName}'...");
+
var reader = entry.OpenReader();
streams.Add(reader);
@@ -3061,6 +3109,7 @@ namespace Tango.Integration.Operation
{
try
{
+ LogManager.Log("Validating version...");
streams.ForEach(x => x.Dispose());
upgradeHandler.RaiseProgress(upgradeHandler.Total, FirmwareUpgradeStatus.Validating, "Validating version...");
var validateRequest = new ValidateVersionRequest();
@@ -3078,6 +3127,7 @@ namespace Tango.Integration.Operation
{
try
{
+ LogManager.Log("Activating version...");
upgradeHandler.RaiseProgress(upgradeHandler.Total, FirmwareUpgradeStatus.Activating, "Activating version...");
var activateRequest = new ActivateVersionRequest();
activateRequest.Path = package_folder;
@@ -3092,8 +3142,10 @@ namespace Tango.Integration.Operation
postActivation = new Action(() =>
{
+ LogManager.Log("Firmware upgrade completed.");
upgradeHandler.RaiseCompleted();
Status = MachineStatuses.ReadyToDye;
+ LogManager.Log("Enabling keep alive...");
UseKeepAlive = keepAlive;
});