aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner
diff options
context:
space:
mode:
authorRoy Ben Shabat <roy.mail.net@gmail.com>2025-09-09 12:34:54 +0300
committerRoy Ben Shabat <roy.mail.net@gmail.com>2025-09-09 12:34:54 +0300
commitf87208b19e183d309a3bcacd26ecc74c4da728d4 (patch)
treeba3eba566ff125160fd162dce0de1929df08edcd /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner
parentf8876913ac534f6ec6b122ce64a49d6937b4ba3c (diff)
downloadTango-f87208b19e183d309a3bcacd26ecc74c4da728d4.tar.gz
Tango-f87208b19e183d309a3bcacd26ecc74c4da728d4.zip
Changed PPC CMYK color space label to Volume.
Re-implemented machine designer clone.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner')
-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.cs52
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml2
3 files changed, 48 insertions, 10 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 9d203b76d..93c7490fb 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
@@ -17,7 +17,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
public List<HardwareVersion> HardwareVersionsFiltered
{
- get { return HardwareVersions.Where(x => x.MachineType == (int)MachineType).ToList(); }
+ get { return HardwareVersions != null ? HardwareVersions.Where(x => x.MachineType == (int)MachineType).ToList() : null; }
}
private HardwareVersion _selectedHardwareVersion;
@@ -64,7 +64,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
protected override bool CanOK()
{
- return base.CanOK() && !String.IsNullOrWhiteSpace(SerialNumber) && !String.IsNullOrWhiteSpace(Name) && SelectedHardwareVersion != null;
+ return base.CanOK() && !String.IsNullOrWhiteSpace(SerialNumber) && !String.IsNullOrWhiteSpace(Name) && (SelectedHardwareVersion != null || HardwareVersions == null);
}
}
}
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 c928af0c7..06d702ca0 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
@@ -537,13 +537,51 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
machineConfigBeforeClone = ActiveMachine.Configuration;
IsNewMachine = true;
- ActiveMachine = ActiveMachine.Clone();
- ActiveMachine.Name = machineCreationDialogVM.Name;
- ActiveMachine.SerialNumber = machineCreationDialogVM.SerialNumber;
- ActiveMachine.IsDeviceRegistered = false;
- ActiveMachine.DeviceId = null;
- ActiveMachine.DeviceName = null;
- ActiveMachine.ActivationKey = null;
+ var cloned = ActiveMachine.Clone();
+ cloned.Name = machineCreationDialogVM.Name;
+ cloned.SerialNumber = machineCreationDialogVM.SerialNumber;
+ cloned.IsDeviceRegistered = false;
+ cloned.DeviceId = null;
+ cloned.DeviceName = null;
+ cloned.ActivationKey = null;
+ cloned.Organization = null;
+ cloned.SiteGuid = null;
+ cloned.OrganizationGuid = null;
+
+ while (cloned.ActivationKey == null) //Generate a random password and make sure no machine matches it.
+ {
+ cloned.ActivationKey = PasswordGenerator.Generate(8, PasswordGenerator.PasswordType.Alpha, PasswordGenerator.PasswordCasing.Upper);
+ if (await ActiveMachineAdapter.Context.Machines.Where(x => x.ActivationKey == cloned.ActivationKey).CountAsync() == 0)
+ {
+ break;
+ }
+
+ cloned.ActivationKey = null;
+ }
+
+
+ for (int i = 0; i < ActiveMachine.Configuration.IdsPacks.Count; i++)
+ {
+ var dispenser = ActiveMachine.Configuration.IdsPacks[i].Dispenser;
+
+ if (dispenser != null)
+ {
+ var clonedDispenser = new Dispenser();
+ clonedDispenser.CalibrationData = dispenser.CalibrationData;
+ clonedDispenser.DispenserType = dispenser.DispenserType;
+ clonedDispenser.DispenserTypeGuid = dispenser.DispenserTypeGuid;
+ clonedDispenser.NlPerPulse = dispenser.NlPerPulse;
+ clonedDispenser.PartNumber = dispenser.PartNumber;
+ clonedDispenser.PcbSerial = dispenser.PcbSerial;
+ clonedDispenser.PcbVersion = dispenser.PcbVersion;
+ clonedDispenser.ProductionDate = dispenser.ProductionDate;
+ clonedDispenser.SerialNumber = cloned.SerialNumber + "_D" + (i + 1);
+
+ cloned.Configuration.IdsPacks[i].Dispenser = clonedDispenser;
+ }
+ }
+
+ ActiveMachine = cloned;
ActiveMachineAdapter.Context.Machines.Add(ActiveMachine);
}
}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml
index 2ef48f9b3..96b5e0ee1 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml
@@ -69,7 +69,7 @@
<TextBox Text="{Binding ActiveMachine.OsKey}"></TextBox>
</controls:TableGrid>
- <Button Margin="0 20 0 0" Background="{StaticResource RedBrush300}" ToolTip="Make this machine configuration as a prototype for the selected machine version" BorderBrush="{StaticResource RedBrush300}" Width="200" Height="45" VerticalAlignment="Bottom" Command="{Binding MakePrototypeCommand}">
+ <Button Visibility="Collapsed" Margin="0 20 0 0" Background="{StaticResource RedBrush300}" ToolTip="Make this machine configuration as a prototype for the selected machine version" BorderBrush="{StaticResource RedBrush300}" Width="200" Height="45" VerticalAlignment="Bottom" Command="{Binding MakePrototypeCommand}">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Copyright" Width="24" Height="24" />
<TextBlock VerticalAlignment="Center" Margin="10 0 0 0">MAKE PROTOTYPE</TextBlock>