diff options
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner')
6 files changed, 59 insertions, 12 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Models/MachineModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Models/MachineModel.cs index 8a2f5dd9f..38430e197 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Models/MachineModel.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Models/MachineModel.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.BL.Entities; +using Tango.BL.Enumerations; using Tango.Core; namespace Tango.MachineStudio.MachineDesigner.Models @@ -12,6 +13,8 @@ namespace Tango.MachineStudio.MachineDesigner.Models { public String Guid { get; set; } + public MachineTypes MachineType { get; set; } + public String SerialNumber { get; set; } public String Name { get; set; } 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 168ff62dd..9d203b76d 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 @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.BL.Entities; +using Tango.BL.Enumerations; using Tango.SharedUI; namespace Tango.MachineStudio.MachineDesigner.ViewModels @@ -14,9 +15,24 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels public List<HardwareVersion> HardwareVersions { get; set; } - public HardwareVersion SelectedHardwareVersion { get; set; } + public List<HardwareVersion> HardwareVersionsFiltered + { + get { return HardwareVersions.Where(x => x.MachineType == (int)MachineType).ToList(); } + } + + private HardwareVersion _selectedHardwareVersion; + public HardwareVersion SelectedHardwareVersion + { + get { return _selectedHardwareVersion; } + set { _selectedHardwareVersion = value; RaisePropertyChangedAuto(); } + } - public MachinePrototype SelectedPrototype { get; set; } + private MachinePrototype _selectedProtoType; + public MachinePrototype SelectedPrototype + { + get { return _selectedProtoType; } + set { _selectedProtoType = value; MachineType = (MachineTypes)value.MachineType; } + } private bool _isNewMachine; public bool IsNewMachine @@ -32,6 +48,13 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels set { _serialNumber = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } } + private MachineTypes _machineType; + public MachineTypes MachineType + { + get { return _machineType; } + set { _machineType = value; RaisePropertyChanged(nameof(HardwareVersionsFiltered)); SelectedHardwareVersion = HardwareVersionsFiltered.FirstOrDefault(); } + } + private String _name; public String Name { @@ -41,7 +64,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels protected override bool CanOK() { - return base.CanOK() && !String.IsNullOrWhiteSpace(SerialNumber) && !String.IsNullOrWhiteSpace(Name); + return base.CanOK() && !String.IsNullOrWhiteSpace(SerialNumber) && !String.IsNullOrWhiteSpace(Name) && SelectedHardwareVersion != 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 c31ea0a53..cad54c848 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 @@ -540,6 +540,8 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels ActiveMachine.Configuration = new Configuration(); ActiveMachine.SerialNumber = machineCreationDialogVM.SerialNumber; ActiveMachine.Name = machineCreationDialogVM.Name; + ActiveMachine.Type = machineCreationDialogVM.MachineType; + ActiveMachine.MachineVersion = ActiveMachineAdapter.MachineVersions.First(x => x.MachineType == machineCreationDialogVM.MachineType); ActiveMachineAdapter.Context.Machines.Add(ActiveMachine); } else @@ -548,7 +550,7 @@ 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); + ActiveMachine.MachineVersion = ActiveMachineAdapter.MachineVersions.First(x => x.MachineType == machineCreationDialogVM.MachineType); if (machineCreationDialogVM.SelectedHardwareVersion != null) { @@ -713,6 +715,14 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels errors.Add("Hardware version is required."); } + if (ActiveMachine.Configuration.HardwareVersion != null) + { + if (ActiveMachine.Configuration.HardwareVersion.ForMachineType != ActiveMachine.Type) + { + errors.Add($"Hardware version '{ActiveMachine.Configuration.HardwareVersion.Name}' is intended only for {ActiveMachine.Configuration.HardwareVersion.ForMachineType} machines."); + } + } + foreach (var pack in ActiveMachine.Configuration.IdsPacks) { if (pack.LiquidType != null || pack.CartridgeType != null || pack.Dispenser != null || pack.IdsPackFormula != null || pack.MidTankType != null) @@ -853,7 +863,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels vm.IsNewMachine = true; vm.Prototypes = prototypes.ToList(); vm.HardwareVersions = hardwareVersions.OrderByDescending(x => x.Version).ToList(); - vm.SelectedHardwareVersion = vm.HardwareVersions.FirstOrDefault(); + vm.SelectedHardwareVersion = vm.HardwareVersions.Where(x => x.ForMachineType == MachineTypes.TS1800).FirstOrDefault(); _notification.ShowModalDialog<MachineCreationDialogVM, Views.MachineCreationDialog>(vm, (x) => { using (ObservablesContext db = ObservablesContext.CreateDefault()) @@ -1013,6 +1023,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels { x.Guid, x.SerialNumber, + x.MachineType, x.Name, Organization = x.Organization.Name, MachineVersion = x.MachineVersion.Name, @@ -1030,6 +1041,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels MachineModel model = new MachineModel(); model.Guid = machine.Guid; model.SerialNumber = machine.SerialNumber; + model.MachineType = (MachineTypes)machine.MachineType; model.Name = machine.Name; model.Organization = machine.Organization; model.HardwareVersion = machine.HardwareVersionName + " v" + machine.HardwareVersionVersion; 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 8b3851036..8a4a9161b 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 @@ -8,11 +8,14 @@ xmlns:vm="clr-namespace:Tango.MachineStudio.MachineDesigner.ViewModels" xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:local="clr-namespace:Tango.MachineStudio.MachineDesigner.Views" + xmlns:enumerations="clr-namespace:Tango.BL.Enumerations;assembly=Tango.BL" mc:Ignorable="d" d:DesignHeight="400" d:DesignWidth="700" Height="460" Width="750" Background="{StaticResource Dialog.Background}" d:DataContext="{d:DesignInstance Type=vm:MachineCreationDialogVM, IsDesignTimeCreatable=False}" Foreground="{StaticResource Dialog.Foreground}"> <UserControl.Resources> <converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"></converters:BooleanToVisibilityConverter> + <converters:EnumToItemsSourceConverter x:Key="EnumToItemsSourceConverter" /> + <converters:IsNullToVisibilityInverseConverter x:Key="IsNullToVisibilityInverseConverter" /> </UserControl.Resources> <Grid Margin="10"> @@ -20,7 +23,7 @@ <Grid DockPanel.Dock="Top"> <StackPanel Orientation="Horizontal"> <Grid> - <Image Source="../Images/machine-full-fx.png" Width="120" RenderOptions.BitmapScalingMode="Fant"></Image> + <Image Source="{StaticResource Machines}" Width="120" RenderOptions.BitmapScalingMode="Fant"></Image> <materialDesign:PackIcon HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0 0 -10 -10" Kind="PlusCircle" Foreground="#15C315" Width="42" Height="42" /> </Grid> <TextBlock Margin="30 0 0 0" VerticalAlignment="Bottom" FontSize="22"> @@ -52,11 +55,16 @@ <Grid> <StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Margin="20 20 0 0" Width="400"> <TextBlock TextWrapping="Wrap" Visibility="{Binding IsNewMachine,Converter={StaticResource BooleanToVisibilityConverter}}"> - <Run>Specify a machine prototype to create the new machine with default settings and configuration.</Run> + <Run>Specify a machine prototype and machine type to create the new machine with default settings and configuration.</Run> </TextBlock> - <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> - + <DockPanel Visibility="{Binding IsNewMachine,Converter={StaticResource BooleanToVisibilityConverter}}" Margin="0 10 0 0"> + <ComboBox x:Name="comboProto" Width="200" ItemsSource="{Binding Prototypes}" SelectedItem="{Binding SelectedPrototype}" DisplayMemberPath="Name" FontSize="16" materialDesign:HintAssist.Hint="NONE"></ComboBox> + <ComboBox Visibility="{Binding ElementName=comboProto,Path=SelectedItem,Converter={StaticResource IsNullToVisibilityInverseConverter}}" Margin="30 0 0 0" ItemsSource="{Binding Source={x:Type enumerations:MachineTypes},Converter={StaticResource EnumToItemsSourceConverter}}" FontSize="16" SelectedValue="{Binding MachineType,Mode=TwoWay}" SelectedValuePath="Value" DisplayMemberPath="DisplayName"> + + </ComboBox> + </DockPanel> + <TextBlock Margin="0 20 0 0" FontSize="10">Serial Number</TextBlock> <TextBox Margin="0 2 0 0" Text="{Binding SerialNumber,UpdateSourceTrigger=PropertyChanged}"></TextBox> @@ -65,7 +73,7 @@ <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> + <ComboBox Margin="0 2 0 0" ItemsSource="{Binding HardwareVersionsFiltered}" SelectedItem="{Binding SelectedHardwareVersion}" DisplayMemberPath="FullName"></ComboBox> </StackPanel> </StackPanel> </Grid> 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 4ba79d3f5..852e60d0f 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 @@ -54,7 +54,7 @@ <ComboBox ItemsSource="{Binding Source={x:Type enumerations:HeadTypes},Converter={StaticResource EnumToItemsSourceConverter}}" SelectedValue="{Binding ActiveMachine.MachineHeadType}" SelectedValuePath="Value" DisplayMemberPath="DisplayName" Style="{StaticResource TransparentComboBoxStyle}"></ComboBox> <TextBlock FontWeight="SemiBold">Machine Version</TextBlock> - <ComboBox Background="Transparent" ItemsSource="{Binding ActiveMachineAdapter.MachineVersions}" SelectedItem="{Binding ActiveMachine.MachineVersion}" DisplayMemberPath="Name" Style="{StaticResource TransparentComboBoxStyle}" ></ComboBox> + <ComboBox IsEnabled="False" Background="Transparent" ItemsSource="{Binding ActiveMachineAdapter.MachineVersions}" SelectedItem="{Binding ActiveMachine.MachineVersion}" DisplayMemberPath="Name" Style="{StaticResource TransparentComboBoxStyle}" ></ComboBox> <TextBlock FontWeight="SemiBold">Version Tag</TextBlock> <ComboBox Background="Transparent" ItemsSource="{Binding Tags}" SelectedItem="{Binding ActiveMachine.VersionTag}" Style="{StaticResource TransparentComboBoxStyle}" ></ComboBox> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachinesView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachinesView.xaml index 5fda6dbfa..3c73ecc2b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachinesView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachinesView.xaml @@ -22,7 +22,7 @@ <DockPanel Margin="100" MaxWidth="1200"> <Grid DockPanel.Dock="Top"> <StackPanel Orientation="Horizontal"> - <Image Source="../Images/machine-full-fx.png" Width="350" RenderOptions.BitmapScalingMode="Fant" Margin="10" /> + <Image Source="{StaticResource Machines}" Width="350" RenderOptions.BitmapScalingMode="Fant" Margin="10" /> <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" Margin="0 0 0 10"> <materialDesign:PackIcon VerticalAlignment="Center" Kind="BarcodeScan" Width="32" Height="32" /> @@ -70,6 +70,7 @@ </Style> </DataGrid.CellStyle> <DataGrid.Columns> + <DataGridTextColumn Header="TYPE" Binding="{Binding MachineType}" Width="Auto" /> <DataGridTextColumn Header="SERIAL NUMBER" Binding="{Binding SerialNumber}" Width="Auto" /> <DataGridTextColumn Header="NAME" Binding="{Binding Name}" Width="Auto" /> <DataGridTextColumn Header="ORGANIZATION" Binding="{Binding Organization}" Width="Auto" /> |
