aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineCreationDialogVM.cs4
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs154
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/ConfigurationView.xaml7
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineCreationDialog.xaml5
4 files changed, 169 insertions, 1 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineCreationDialogVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineCreationDialogVM.cs
index 340f92edd..168ff62dd 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineCreationDialogVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineCreationDialogVM.cs
@@ -12,6 +12,10 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
{
public List<MachinePrototype> Prototypes { get; set; }
+ public List<HardwareVersion> HardwareVersions { get; set; }
+
+ public HardwareVersion SelectedHardwareVersion { get; set; }
+
public MachinePrototype SelectedPrototype { get; set; }
private bool _isNewMachine;
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs
index 6ddf86ddb..de7467e91 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs
@@ -29,6 +29,7 @@ using Tango.BL.ActionLogs;
using Tango.MachineStudio.Common.Authentication;
using Tango.BL.DTO;
using Tango.Core.Cryptography;
+using Tango.BL.Enumerations;
namespace Tango.MachineStudio.MachineDesigner.ViewModels
{
@@ -144,6 +145,12 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
set { _sites = value; RaisePropertyChangedAuto(); }
}
+ private bool _isGen1Machine;
+ public bool IsGen1Machine
+ {
+ get { return _isGen1Machine; }
+ set { _isGen1Machine = value; RaisePropertyChangedAuto(); }
+ }
private ColorCalibrationViewVM _colorCalibrationViewVM;
public ColorCalibrationViewVM ColorCalibrationViewVM
@@ -241,6 +248,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
/// </summary>
public RelayCommand MakePrototypeCommand { get; set; }
+ public RelayCommand UpgradeToGen2Command { get; set; }
#endregion
#region Constructors
@@ -278,6 +286,8 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
MachineUpdatesViewVM = new MachineUpdatesViewVM(_notification);
TupViewVM = new TupViewVM(_notification);
+
+ UpgradeToGen2Command = new RelayCommand(UpgradeToGEN2);
}
#endregion
@@ -288,6 +298,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
{
MachinesAdapter.MachineVersions = (await MachinesAdapter.Context.MachineVersions.ToListAsync()).ToObservableCollection();
MachinesAdapter.MachinePrototypes = (await MachinesAdapter.Context.MachinePrototypes.ToListAsync()).ToObservableCollection();
+ MachinesAdapter.HardwareVersions = (await MachinesAdapter.Context.HardwareVersions.ToListAsync()).ToObservableCollection();
}
#endregion
@@ -528,6 +539,12 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
initHwConfig = false;
ActiveMachine = machineCreationDialogVM.SelectedPrototype.CreateMachine(machineCreationDialogVM.SerialNumber, machineCreationDialogVM.Name);
ActiveMachine.MachineVersion = ActiveMachineAdapter.MachineVersions.FirstOrDefault(x => x.Guid == ActiveMachine.MachineVersionGuid);
+
+ if (machineCreationDialogVM.SelectedHardwareVersion != null)
+ {
+ ActiveMachine.Configuration.HardwareVersion = ActiveMachineAdapter.HardwareVersions.FirstOrDefault(x => x.Guid == machineCreationDialogVM.SelectedHardwareVersion.Guid);
+ }
+
ActiveMachineAdapter.Context.Machines.Add(ActiveMachine);
HardwareConfigurationViewVM = new HardwareConfigurationViewVM(_notification);
@@ -587,6 +604,8 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
ActiveMachine.ActivationKey = null;
}
+ IsGen1Machine = !ActiveMachine.Configuration.NoneEmptyIdsPacks.Any(x => x.LiquidType.Type == LiquidTypes.LightCyan);
+
View.NavigateTo(MachineDesignerNavigationView.MachineDetailsView);
}
catch (Exception ex)
@@ -796,6 +815,8 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
MachineCreationDialogVM vm = new MachineCreationDialogVM();
vm.IsNewMachine = true;
vm.Prototypes = MachinesAdapter.MachinePrototypes.ToList();
+ vm.HardwareVersions = MachinesAdapter.HardwareVersions.OrderByDescending(x => x.Version).ToList();
+ vm.SelectedHardwareVersion = vm.HardwareVersions.FirstOrDefault();
_notification.ShowModalDialog<MachineCreationDialogVM, Views.MachineCreationDialog>(vm, (x) =>
{
if (MachinesAdapter.Context.Machines.Any(y => y.SerialNumber == vm.SerialNumber || y.Name.ToLower() == vm.Name.ToLower()))
@@ -946,5 +967,138 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
SelectedSite = Sites.SingleOrDefault(x => x.Guid == ActiveMachine.SiteGuid);
}
+
+ private async void UpgradeToGEN2()
+ {
+ if (!_notification.ShowQuestion("Are you sure you want to upgrade this machine configuration to GEN 2 standards?")) return;
+
+ using (_notification.PushTaskItem("Upgrading this machine to GEN 2..."))
+ {
+ try
+ {
+ IsFree = false;
+
+ var configuration = ActiveMachine.Configuration;
+
+ InvalidOperationException noneGen1Exception = new InvalidOperationException("This machine configuration does not fit within the GEN 1 standard and cannot be upgraded.");
+
+ var orderedPacks = configuration.IdsPacks.OrderBy(x => x.PackIndex).ToList();
+
+ try
+ {
+ if (!ValidateIdsPack(orderedPacks[0], LiquidTypes.Black, MidTankTypes.StandardMidTank, DispenserTypes.StandardDispenser, IdsPackFormulas.StandardColor)) throw noneGen1Exception;
+ if (!ValidateIdsPack(orderedPacks[1], LiquidTypes.Cyan, MidTankTypes.StandardMidTank, DispenserTypes.StandardDispenser, IdsPackFormulas.StandardColor)) throw noneGen1Exception;
+ if (!ValidateIdsPack(orderedPacks[2], LiquidTypes.Magenta, MidTankTypes.StandardMidTank, DispenserTypes.StandardDispenser, IdsPackFormulas.StandardColor)) throw noneGen1Exception;
+ if (!ValidateIdsPack(orderedPacks[3], LiquidTypes.Yellow, MidTankTypes.StandardMidTank, DispenserTypes.StandardDispenser, IdsPackFormulas.StandardColor)) throw noneGen1Exception;
+ if (!ValidateIdsPack(orderedPacks[4], LiquidTypes.TransparentInk, MidTankTypes.StandardMidTank, DispenserTypes.StandardDispenser, IdsPackFormulas.TransparentLiquid)) throw noneGen1Exception;
+ if (!orderedPacks[5].IsEmpty) throw noneGen1Exception;
+ if (!ValidateIdsPack(orderedPacks[6], LiquidTypes.Cleaner, MidTankTypes.StandardMidTank, DispenserTypes.StandardDispenser, IdsPackFormulas.CleanerLiquid)) throw noneGen1Exception;
+ if (!ValidateIdsPack(orderedPacks[7], LiquidTypes.Lubricant, MidTankTypes.StandardMidTank, DispenserTypes.StandardDispenser, IdsPackFormulas.Lubricant)) throw noneGen1Exception;
+ }
+ catch
+ {
+ throw noneGen1Exception;
+ }
+
+ var cleanerPack = orderedPacks[6];
+ var lubricantPack = orderedPacks[7];
+ var emptyPack = orderedPacks[5];
+
+ cleanerPack.MidTankType = ActiveMachineAdapter.MidTankTypes.First(x => x.Type == MidTankTypes.NoMidTank);
+ cleanerPack.IdsPackFormula = ActiveMachineAdapter.IdsPackFormulas.First(x => x.Type == IdsPackFormulas.LightInksCleanerLiquid);
+ cleanerPack.Dispenser.DispenserType = ActiveMachineAdapter.DispenserTypes.First(x => x.Type == DispenserTypes.CleanerDispenser);
+ cleanerPack.PackIndex = 8;
+
+ lubricantPack.MidTankType = ActiveMachineAdapter.MidTankTypes.First(x => x.Type == MidTankTypes.LubricantMidTank);
+ lubricantPack.IdsPackFormula = ActiveMachineAdapter.IdsPackFormulas.First(x => x.Type == IdsPackFormulas.LightInksLubricantLiquid);
+ lubricantPack.Dispenser.DispenserType = ActiveMachineAdapter.DispenserTypes.First(x => x.Type == DispenserTypes.LubricantDispenser);
+ lubricantPack.PackIndex = 9;
+
+ var lightCyanDispenser = await ActiveMachineAdapter.Context.Dispensers.Include(x => x.IdsPacks).FirstOrDefaultAsync(x => x.SerialNumber.StartsWith(ActiveMachine.SerialNumber) && x.IdsPacks.Count == 0);
+
+ int newDispenserStartIndex = 9;
+
+ if (lightCyanDispenser == null)
+ {
+ lightCyanDispenser = new Dispenser();
+ lightCyanDispenser.NlPerPulse = orderedPacks[1].Dispenser.NlPerPulse;
+ lightCyanDispenser.SerialNumber = $"{ActiveMachine.SerialNumber}-{newDispenserStartIndex++}";
+ lightCyanDispenser.DispenserType = ActiveMachineAdapter.DispenserTypes.First(x => x.Type == DispenserTypes.StandardDispenser);
+ }
+
+ IdsPack lightCyanPack = new IdsPack();
+ lightCyanPack.PackIndex = 5;
+ lightCyanPack.LiquidType = ActiveMachineAdapter.LiquidTypes.First(x => x.Type == LiquidTypes.LightCyan);
+ lightCyanPack.MidTankType = ActiveMachineAdapter.MidTankTypes.First(x => x.Type == MidTankTypes.StandardMidTank);
+ lightCyanPack.IdsPackFormula = ActiveMachineAdapter.IdsPackFormulas.First(x => x.Type == IdsPackFormulas.LightColor);
+ lightCyanPack.CartridgeType = ActiveMachineAdapter.CartridgeTypes.First(x => x.Type == CartridgeTypes.StandardCartridge);
+ lightCyanPack.Dispenser = lightCyanDispenser;
+ configuration.IdsPacks.Add(lightCyanPack);
+
+ IdsPack lightMagentaPack = new IdsPack();
+ lightMagentaPack.PackIndex = 6;
+ lightMagentaPack.LiquidType = ActiveMachineAdapter.LiquidTypes.First(x => x.Type == LiquidTypes.LightMagenta);
+ lightMagentaPack.MidTankType = ActiveMachineAdapter.MidTankTypes.First(x => x.Type == MidTankTypes.StandardMidTank);
+ lightMagentaPack.IdsPackFormula = ActiveMachineAdapter.IdsPackFormulas.First(x => x.Type == IdsPackFormulas.LightColor);
+ lightMagentaPack.CartridgeType = ActiveMachineAdapter.CartridgeTypes.First(x => x.Type == CartridgeTypes.StandardCartridge);
+ lightMagentaPack.Dispenser = new Dispenser()
+ {
+ NlPerPulse = orderedPacks[2].Dispenser.NlPerPulse,
+ SerialNumber = $"{ActiveMachine.SerialNumber}-{newDispenserStartIndex++}",
+ DispenserType = ActiveMachineAdapter.DispenserTypes.First(x => x.Type == DispenserTypes.StandardDispenser)
+ };
+ configuration.IdsPacks.Add(lightMagentaPack);
+
+ IdsPack lightYellowPack = new IdsPack();
+ lightYellowPack.PackIndex = 7;
+ lightYellowPack.LiquidType = ActiveMachineAdapter.LiquidTypes.First(x => x.Type == LiquidTypes.LightYellow);
+ lightYellowPack.MidTankType = ActiveMachineAdapter.MidTankTypes.First(x => x.Type == MidTankTypes.StandardMidTank);
+ lightYellowPack.IdsPackFormula = ActiveMachineAdapter.IdsPackFormulas.First(x => x.Type == IdsPackFormulas.LightColor);
+ lightYellowPack.CartridgeType = ActiveMachineAdapter.CartridgeTypes.First(x => x.Type == CartridgeTypes.StandardCartridge);
+ lightYellowPack.Dispenser = new Dispenser()
+ {
+ NlPerPulse = orderedPacks[3].Dispenser.NlPerPulse,
+ SerialNumber = $"{ActiveMachine.SerialNumber}-{newDispenserStartIndex++}",
+ DispenserType = ActiveMachineAdapter.DispenserTypes.First(x => x.Type == DispenserTypes.StandardDispenser)
+ };
+ configuration.IdsPacks.Add(lightYellowPack);
+
+ configuration.IdsPacks.Remove(emptyPack);
+ ActiveMachineAdapter.Context.IdsPacks.Remove(emptyPack);
+
+ var packs = configuration.IdsPacks.ToList();
+ configuration.IdsPacks.Clear();
+
+ foreach (var pack in packs.OrderBy(x => x.PackIndex))
+ {
+ configuration.IdsPacks.Add(pack);
+ }
+
+ IsGen1Machine = false;
+ ActiveMachine.LightInksInstalled = true;
+
+ _notification.ShowInfo("Machine configuration successfully upgraded to GEN 2.");
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Error upgrading machine to GEN 2.");
+ _notification.ShowError($"Error upgrading this machine to GEN 2.\n{ex.FlattenMessage()}");
+ }
+ finally
+ {
+ IsFree = true;
+ }
+ }
+ }
+
+ private bool ValidateIdsPack(IdsPack pack, LiquidTypes liquidType, MidTankTypes midTankType, DispenserTypes dispenserType, IdsPackFormulas formula)
+ {
+ if (pack.LiquidType.Type != liquidType) return false;
+ if (pack.MidTankType.Type != midTankType) return false;
+ if (pack.Dispenser.DispenserType.Type != dispenserType) return false;
+ if (pack.IdsPackFormula.Type != formula) return false;
+
+ return true;
+ }
}
}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/ConfigurationView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/ConfigurationView.xaml
index 03043d04e..d1eaaaeff 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/ConfigurationView.xaml
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/ConfigurationView.xaml
@@ -83,7 +83,12 @@
</Grid.RowDefinitions>
<Grid ClipToBounds="False">
-
+ <Button Margin="200 40 0 0" Background="{StaticResource RedBrush300}" ToolTip="Upgrade this machine configuration to GEN 2" BorderBrush="{StaticResource RedBrush300}" Width="200" Height="45" VerticalAlignment="Top" HorizontalAlignment="Left" Command="{Binding UpgradeToGen2Command}" Visibility="{Binding IsGen1Machine,Converter={StaticResource BoolToVisConverter}}">
+ <StackPanel Orientation="Horizontal">
+ <materialDesign:PackIcon Kind="Beta" Width="24" Height="24" />
+ <TextBlock VerticalAlignment="Center" Margin="5 0 0 0">UPGRADE TO GEN 2</TextBlock>
+ </StackPanel>
+ </Button>
</Grid>
<Viewbox MaxWidth="1200" Grid.Row="1" >
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineCreationDialog.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineCreationDialog.xaml
index f69606e29..8b3851036 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineCreationDialog.xaml
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineCreationDialog.xaml
@@ -62,6 +62,11 @@
<TextBlock Margin="0 20 0 0" FontSize="10">Name</TextBlock>
<TextBox Margin="0 2 0 0" Text="{Binding Name,UpdateSourceTrigger=PropertyChanged}"></TextBox>
+
+ <StackPanel Margin="0 20 0 0" Visibility="{Binding IsNewMachine,Converter={StaticResource BooleanToVisibilityConverter}}">
+ <TextBlock FontSize="10">Hardware Version</TextBlock>
+ <ComboBox Margin="0 2 0 0" ItemsSource="{Binding HardwareVersions}" SelectedItem="{Binding SelectedHardwareVersion}" DisplayMemberPath="FullName"></ComboBox>
+ </StackPanel>
</StackPanel>
</Grid>
</DockPanel>