diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2021-02-15 15:29:13 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2021-02-15 15:29:13 +0200 |
| commit | 8a4a7818428d7b203cb28082c720c74831b2165f (patch) | |
| tree | a36bc4d90eb0cf418dd69c00af73863edc63998e /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner | |
| parent | 1ee675bdcc0d0234f452c58fddd4024bbb0c2d8e (diff) | |
| parent | a27ffb17e0ab28c994234346d2bc93e85da710d2 (diff) | |
| download | Tango-8a4a7818428d7b203cb28082c720c74831b2165f.tar.gz Tango-8a4a7818428d7b203cb28082c720c74831b2165f.zip | |
Merged Light Inks To software !
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner')
6 files changed, 42 insertions, 147 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 4584d3508..340f92edd 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 @@ -10,9 +10,9 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels { public class MachineCreationDialogVM : DialogViewVM { - public List<MachineVersion> MachineVersions { get; set; } + public List<MachinePrototype> Prototypes { get; set; } - public MachineVersion SelectedMachineVersion { get; set; } + public MachinePrototype SelectedPrototype { get; set; } private bool _isNewMachine; public bool IsNewMachine @@ -35,25 +35,6 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels set { _name = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } } - private bool _generateDispensers; - public bool GenerateDispensers - { - get { return _generateDispensers; } - set { _generateDispensers = value; RaisePropertyChangedAuto(); } - } - - private double _dispenserFactor; - public double DispenserFactor - { - get { return _dispenserFactor; } - set { _dispenserFactor = value; RaisePropertyChangedAuto(); } - } - - public MachineCreationDialogVM() : base() - { - DispenserFactor = 2.34; - } - protected override bool CanOK() { return base.CanOK() && !String.IsNullOrWhiteSpace(SerialNumber) && !String.IsNullOrWhiteSpace(Name); 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 e3547c568..6ddf86ddb 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 @@ -263,7 +263,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels _machines_action_timer = new ActionTimer(TimeSpan.FromMilliseconds(200)); _dispensers_action_timer = new ActionTimer(TimeSpan.FromMilliseconds(200)); - AddIdsCommand = new RelayCommand(AddIds, (x) => ActiveMachine != null && ActiveMachine.Configuration != null && ActiveMachine.Configuration.IdsPacks.Count < 8); + AddIdsCommand = new RelayCommand(AddIds, (x) => ActiveMachine != null && ActiveMachine.Configuration != null && ActiveMachine.Configuration.IdsPacks.Count < 10); RemoveIdsCommand = new RelayCommand(RemoveIds, (x) => SelectedIds != null); EditMachineCommand = new RelayCommand(() => LoadSelectedMachine(), () => SelectedMachine != null); BackToMachinesCommand = new RelayCommand(() => View.NavigateTo(MachineDesignerNavigationView.MachinesView)); @@ -287,7 +287,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels public override async void OnApplicationReady() { MachinesAdapter.MachineVersions = (await MachinesAdapter.Context.MachineVersions.ToListAsync()).ToObservableCollection(); - + MachinesAdapter.MachinePrototypes = (await MachinesAdapter.Context.MachinePrototypes.ToListAsync()).ToObservableCollection(); } #endregion @@ -513,7 +513,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels { IsNewMachine = true; - if (machineCreationDialogVM.SelectedMachineVersion == null) + if (machineCreationDialogVM.SelectedPrototype == null) { ActiveMachine = new Machine(); ActiveMachine.Configuration = new Configuration(); @@ -526,9 +526,8 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels try { initHwConfig = false; - ActiveMachine = await machineCreationDialogVM.SelectedMachineVersion.CreatePrototypeMachine(ActiveMachineAdapter.Context); - ActiveMachine.SerialNumber = machineCreationDialogVM.SerialNumber; - ActiveMachine.Name = machineCreationDialogVM.Name; + ActiveMachine = machineCreationDialogVM.SelectedPrototype.CreateMachine(machineCreationDialogVM.SerialNumber, machineCreationDialogVM.Name); + ActiveMachine.MachineVersion = ActiveMachineAdapter.MachineVersions.FirstOrDefault(x => x.Guid == ActiveMachine.MachineVersionGuid); ActiveMachineAdapter.Context.Machines.Add(ActiveMachine); HardwareConfigurationViewVM = new HardwareConfigurationViewVM(_notification); @@ -537,81 +536,13 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels } catch (Exception ex) { - _notification.ShowError($"Invalid machine version prototype.\n{ex.FlattenMessage()}"); + _notification.ShowError($"Invalid machine prototype.\n{ex.FlattenMessage()}"); View.NavigateTo(MachineDesignerNavigationView.MachinesView); return; } } } - if ((newMachine || clone) && machineCreationDialogVM.GenerateDispensers) - { - for (int i = 0; i < 8; i++) - { - var serial = machineCreationDialogVM.SerialNumber + "-" + (i + 1); - - var existingDispenser = await ActiveMachineAdapter.Context.Dispensers.Include(x => x.IdsPacks).SingleOrDefaultAsync(x => x.SerialNumber == serial); - - if (existingDispenser != null) - { - if (existingDispenser.IsInstalled) - { - _notification.ShowError($"Dispenser '{serial}' already exists. Cannot create machine."); - return; - } - else - { - if (!_notification.ShowErrorQuestion($"Dispenser '{serial}' already exists and is not installed. Do you wish to assign the existing dispenser to this machine?")) - { - return; - } - } - } - - Dispenser dispenser = new Dispenser(); - - if (existingDispenser == null) - { - dispenser.SerialNumber = serial; - - if (newMachine) - { - dispenser.NlPerPulse = machineCreationDialogVM.DispenserFactor; - dispenser.DispenserTypeGuid = ActiveMachineAdapter.DispenserTypes.First().Guid; - } - else - { - var packBefore = machineConfigBeforeClone.NoneEmptyIdsPacks.SingleOrDefault(x => x.PackIndex == i); - - if (packBefore != null) - { - dispenser.NlPerPulse = packBefore.Dispenser.NlPerPulse; - dispenser.DispenserTypeGuid = packBefore.Dispenser.DispenserType.Guid; - } - else - { - continue; - } - } - - dispenser.ProductionDate = DateTime.UtcNow; - - ActiveMachineAdapter.Context.Dispensers.Add(dispenser); - } - else - { - dispenser = existingDispenser; - } - - var idsPack = ActiveMachine.Configuration.NoneEmptyIdsPacks.SingleOrDefault(x => x.PackIndex == i); - - if (idsPack != null) - { - idsPack.Dispenser = dispenser; - idsPack.DispenserGuid = dispenser.Guid; - } - } - } ActiveMachine.OrganizationChanged -= ActiveMachine_OrganizationChanged; ActiveMachine.OrganizationChanged += ActiveMachine_OrganizationChanged; @@ -864,7 +795,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels { MachineCreationDialogVM vm = new MachineCreationDialogVM(); vm.IsNewMachine = true; - vm.MachineVersions = MachinesAdapter.MachineVersions.ToList(); + vm.Prototypes = MachinesAdapter.MachinePrototypes.ToList(); _notification.ShowModalDialog<MachineCreationDialogVM, Views.MachineCreationDialog>(vm, (x) => { if (MachinesAdapter.Context.Machines.Any(y => y.SerialNumber == vm.SerialNumber || y.Name.ToLower() == vm.Name.ToLower())) @@ -873,12 +804,6 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels return; } - if (vm.SelectedMachineVersion != null && String.IsNullOrWhiteSpace(vm.SelectedMachineVersion.PrototypeMachineData)) - { - _notification.ShowError("The selected version does not contain any prototype machine data."); - return; - } - LoadSelectedMachine(true, false, vm); }, () => { }); } @@ -922,36 +847,32 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels private async void MakePrototype() { - if (ActiveMachine.MachineVersion == null) - { - _notification.ShowError("Machine version must be selected in order to make a prototype."); - return; - } + String protoName = _notification.ShowTextInput("Enter prototype name", "name"); + + if (!protoName.IsNotNullOrWhiteSpace()) return; - if (_notification.ShowQuestion($"Are you sure you wish to make this machine configuration as a prototype for version '{ActiveMachine.MachineVersion.Name}' ?")) + using (_notification.PushTaskItem($"Saving machine prototype '{protoName}'...")) { - using (_notification.PushTaskItem($"Making prototype machine for '{ActiveMachine.MachineVersion.Name}'...")) + try { - try - { - IsFree = false; + IsFree = false; - using (var db = ObservablesContext.CreateDefault()) - { - var machineVersion = await db.MachineVersions.SingleOrDefaultAsync(x => x.Guid == ActiveMachine.MachineVersionGuid); - await machineVersion.ApplyPrototypeMachine(ActiveMachine, db); - await db.SaveChangesAsync(); - } - } - catch (Exception ex) + using (var db = ObservablesContext.CreateDefault()) { - _notification.ShowError($"Error making machine version prototype\n{ex.FlattenMessage()}"); - } - finally - { - IsFree = true; + MachinePrototype prototype = MachinePrototype.CreateNew(ActiveMachine, protoName, protoName); + db.MachinePrototypes.Add(prototype); + await db.SaveChangesAsync(); + MachinesAdapter.MachinePrototypes = (await MachinesAdapter.Context.MachinePrototypes.ToListAsync()).ToObservableCollection(); } } + catch (Exception ex) + { + _notification.ShowError($"Error creating machine prototype\n{ex.FlattenMessage()}"); + } + finally + { + IsFree = true; + } } } @@ -961,7 +882,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels { MachineCreationDialogVM vm = new MachineCreationDialogVM(); vm.IsNewMachine = false; - vm.MachineVersions = MachinesAdapter.MachineVersions.ToList(); + vm.Prototypes = MachinesAdapter.MachinePrototypes.ToList(); _notification.ShowModalDialog<MachineCreationDialogVM, Views.MachineCreationDialog>(vm, (x) => { if (MachinesAdapter.Context.Machines.Any(y => y.SerialNumber == vm.SerialNumber || y.Name.ToLower() == vm.Name.ToLower())) 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 b13ffb87b..03043d04e 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 @@ -134,7 +134,7 @@ <materialDesign:PackIcon Kind="Minus" Width="24" Height="24"></materialDesign:PackIcon> </Button> - <UniformGrid Width="310" Canvas.Top="295" Canvas.Left="420" Rows="1" Columns="8" TextElement.FontSize="9"> + <UniformGrid Width="310" Canvas.Top="295" Canvas.Left="420" Rows="1" Columns="10" TextElement.FontSize="9"> <TextBlock HorizontalAlignment="Center">1</TextBlock> <TextBlock HorizontalAlignment="Center">2</TextBlock> <TextBlock HorizontalAlignment="Center">3</TextBlock> @@ -143,6 +143,8 @@ <TextBlock HorizontalAlignment="Center">6</TextBlock> <TextBlock HorizontalAlignment="Center">7</TextBlock> <TextBlock HorizontalAlignment="Center">8</TextBlock> + <TextBlock HorizontalAlignment="Center">9</TextBlock> + <TextBlock HorizontalAlignment="Center">10</TextBlock> </UniformGrid> <Grid x:Name="gridIds" Width="310" Height="195" Canvas.Top="314" Canvas.Left="420"> <ListBox ItemsSource="{Binding ActiveMachine.Configuration.IdsPacks}" SelectedItem="{Binding SelectedIds}" ScrollViewer.VerticalScrollBarVisibility="Disabled" ScrollViewer.HorizontalScrollBarVisibility="Disabled"> @@ -155,7 +157,7 @@ </ListBox.ItemContainerStyle> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> - <UniformGrid Columns="8"></UniformGrid> + <UniformGrid Columns="10"></UniformGrid> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> @@ -439,6 +441,7 @@ <Image IsHitTestVisible="False" Width="24" Height="24" Source="../Images/injection.png" Stretch="Fill" RenderOptions.BitmapScalingMode="Fant"></Image> <StackPanel Margin="5 0 0 0" IsHitTestVisible="False"> <TextBlock IsHitTestVisible="False" FontSize="10" Foreground="DimGray"><Run Text="{Binding SerialNumber}"></Run></TextBlock> + <TextBlock IsHitTestVisible="False" FontSize="9" Margin="0 2 0 0" Foreground="Gray"><Run Text="{Binding DispenserType.Name}"></Run></TextBlock> </StackPanel> </StackPanel> 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 0640b846e..f69606e29 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 @@ -52,28 +52,16 @@ <Grid> <StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Margin="20 20 0 0" Width="400"> <TextBlock TextWrapping="Wrap" Visibility="{Binding IsNewMachine,Converter={StaticResource BooleanToVisibilityConverter}}"> - <Run>Please specify the machine version in order to prototype the new machine with default machine settings and configuration.</Run> + <Run>Specify a machine prototype to create the new machine with default settings and configuration.</Run> </TextBlock> - <ComboBox Visibility="{Binding IsNewMachine,Converter={StaticResource BooleanToVisibilityConverter}}" ItemsSource="{Binding MachineVersions}" SelectedItem="{Binding SelectedMachineVersion}" DisplayMemberPath="Name" Margin="0 10 0 0" FontSize="16" materialDesign:HintAssist.Hint="NONE"></ComboBox> + <ComboBox Visibility="{Binding IsNewMachine,Converter={StaticResource BooleanToVisibilityConverter}}" ItemsSource="{Binding Prototypes}" SelectedItem="{Binding SelectedPrototype}" DisplayMemberPath="Name" Margin="0 10 0 0" FontSize="16" materialDesign:HintAssist.Hint="NONE"></ComboBox> <TextBlock Margin="0 20 0 0" FontSize="10">Serial Number</TextBlock> <TextBox Margin="0 2 0 0" Text="{Binding SerialNumber,UpdateSourceTrigger=PropertyChanged}"></TextBox> <TextBlock Margin="0 20 0 0" FontSize="10">Name</TextBlock> <TextBox Margin="0 2 0 0" Text="{Binding Name,UpdateSourceTrigger=PropertyChanged}"></TextBox> - - <CheckBox Margin="0 30 0 0" IsChecked="{Binding GenerateDispensers}"> - <TextBlock> - <Run>Automatically generate 8 dispensers for this machine</Run> - <Run>(</Run><Run Foreground="{StaticResource GrayBrush}" FontSize="10" Text="{Binding SerialNumber}"></Run><Run Foreground="{StaticResource GrayBrush}" FontSize="10">-1-8</Run><Run>)</Run> - </TextBlock> - </CheckBox> - - <StackPanel Margin="20 10 0 0" Visibility="{Binding IsNewMachine,Converter={StaticResource BooleanToVisibilityConverter}}"> - <TextBlock FontSize="10">Dispenser max nl/cm</TextBlock> - <mahapps:NumericUpDown Minimum="0" StringFormat="0.00" Maximum="10" InterceptMouseWheel="True" Value="{Binding DispenserFactor,Mode=TwoWay}" HorizontalContentAlignment="Left" Width="95" HorizontalAlignment="Left" BorderThickness="0 0 0 1" Margin="0 2 0 0" HideUpDownButtons="True" HasDecimals="True" Background="Transparent"></mahapps:NumericUpDown> - </StackPanel> </StackPanel> </Grid> </DockPanel> 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 76517ec37..9b50de49c 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 @@ -109,8 +109,8 @@ <TextBlock FontWeight="SemiBold">Force Version Update</TextBlock> <ToggleButton HorizontalAlignment="Left" IsChecked="{Binding ActiveMachine.ForceVersionUpdate}"></ToggleButton> - <TextBlock FontWeight="SemiBold">Update Schema on Update</TextBlock> - <ToggleButton HorizontalAlignment="Left" IsChecked="{Binding ActiveMachine.PerformSchemaUpdateOnDataUpdate}"></ToggleButton> + <TextBlock FontWeight="SemiBold">Light Inks Installed</TextBlock> + <ToggleButton HorizontalAlignment="Left" IsChecked="{Binding ActiveMachine.LightInksInstalled}"></ToggleButton> </controls:TableGrid> </Grid> </Border> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineView.xaml index f72344905..54e47c0d4 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineView.xaml @@ -69,7 +69,7 @@ <Rectangle Stroke="Gray" HorizontalAlignment="Left" StrokeThickness="1" StrokeDashArray="5" RenderTransformOrigin="0.5,0.5"/> </Grid> - <UniformGrid Width="310" Canvas.Top="295" Canvas.Left="420" Rows="1" Columns="8" TextElement.FontSize="9"> + <UniformGrid Width="310" Canvas.Top="295" Canvas.Left="420" Rows="1" Columns="10" TextElement.FontSize="9"> <TextBlock HorizontalAlignment="Center">1</TextBlock> <TextBlock HorizontalAlignment="Center">2</TextBlock> <TextBlock HorizontalAlignment="Center">3</TextBlock> @@ -78,6 +78,8 @@ <TextBlock HorizontalAlignment="Center">6</TextBlock> <TextBlock HorizontalAlignment="Center">7</TextBlock> <TextBlock HorizontalAlignment="Center">8</TextBlock> + <TextBlock HorizontalAlignment="Center">9</TextBlock> + <TextBlock HorizontalAlignment="Center">10</TextBlock> </UniformGrid> <Grid x:Name="gridIds" Width="310" Height="195" Canvas.Top="314" Canvas.Left="420"> @@ -91,7 +93,7 @@ </ListBox.ItemContainerStyle> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> - <UniformGrid Columns="8"></UniformGrid> + <UniformGrid Columns="10"></UniformGrid> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> |
