diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2018-08-06 11:36:05 +0300 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2018-08-06 11:36:05 +0300 |
| commit | c51a733edf3be17e796dc376b75948e324507a9d (patch) | |
| tree | 747af663cea63698ea703e31fbc7d589f8fdaf71 /Software/Visual_Studio/MachineStudio/Modules | |
| parent | a52f63d6b8478d2bf005e3c6b9188c5d0e7e056a (diff) | |
| parent | cd92ad2dc4a8df75c1b955757b07c796b064b7e2 (diff) | |
| download | Tango-c51a733edf3be17e796dc376b75948e324507a9d.tar.gz Tango-c51a733edf3be17e796dc376b75948e324507a9d.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules')
25 files changed, 1125 insertions, 17 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs index 569359066..85480a4b8 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs @@ -979,7 +979,7 @@ namespace Tango.MachineStudio.Developer.ViewModels if (SelectedGroupHistory != null) { LogManager.Log(String.Format("Parameters group {0} selected from history.", SelectedGroupHistory.Name)); - RmlProcessParametersTableGroup = SelectedGroupHistory.CloneGroup(); + RmlProcessParametersTableGroup = SelectedGroupHistory.Clone(); } } @@ -1329,7 +1329,7 @@ namespace Tango.MachineStudio.Developer.ViewModels if (RmlProcessParametersTableGroup != null) { - RmlProcessParametersTableGroup = RmlProcessParametersTableGroup.CloneGroup(); + RmlProcessParametersTableGroup = RmlProcessParametersTableGroup.Clone(); RmlProcessParametersTableGroup.ProcessParametersTables = RmlProcessParametersTableGroup.ProcessParametersTables.OrderBy(x => x.TableIndex).ToObservableCollection(); } @@ -1385,7 +1385,7 @@ namespace Tango.MachineStudio.Developer.ViewModels foreach (var table in RmlProcessParametersTableGroup.ProcessParametersTables) { - var newTable = table.CloneEntity(); + var newTable = table.Clone(); newTable.TableIndex = index++; newTable.ProcessParametersTablesGroup = group; tables.Add(newTable); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/blower.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/blower.png Binary files differnew file mode 100644 index 000000000..a3797b514 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/blower.png diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/break.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/break.png Binary files differnew file mode 100644 index 000000000..67bd5982e --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/break.png diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Tango.MachineStudio.HardwareDesigner.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Tango.MachineStudio.HardwareDesigner.csproj index 270915bd2..13f075684 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Tango.MachineStudio.HardwareDesigner.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Tango.MachineStudio.HardwareDesigner.csproj @@ -166,10 +166,16 @@ <ItemGroup> <Resource Include="Images\speed.png" /> </ItemGroup> + <ItemGroup> + <Resource Include="Images\break.png" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\blower.png" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> + <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs index f91badebe..3dd4e62a3 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs @@ -96,6 +96,34 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels set { _selectedSpeedSensorTypes = value; RaisePropertyChangedAuto(); } } + private SelectedObjectCollection<HardwareBlowerType> _blowerTypes; + public SelectedObjectCollection<HardwareBlowerType> BlowerTypes + { + get { return _blowerTypes; } + set { _blowerTypes = value; RaisePropertyChangedAuto(); } + } + + private ObservableCollection<HardwareBlowerType> _selectedBlowerTypes; + public ObservableCollection<HardwareBlowerType> SelectedBlowerTypes + { + get { return _selectedBlowerTypes; } + set { _selectedBlowerTypes = value; RaisePropertyChangedAuto(); } + } + + private SelectedObjectCollection<HardwareBreakSensorType> _breakSensorTypes; + public SelectedObjectCollection<HardwareBreakSensorType> BreakSensorTypes + { + get { return _breakSensorTypes; } + set { _breakSensorTypes = value; RaisePropertyChangedAuto(); } + } + + private ObservableCollection<HardwareBreakSensorType> _selectedBreakSensorTypes; + public ObservableCollection<HardwareBreakSensorType> SelectedBreakSensorTypes + { + get { return _selectedBreakSensorTypes; } + set { _selectedBreakSensorTypes = value; RaisePropertyChangedAuto(); } + } + private HardwareVersion _selectedVersion; public HardwareVersion SelectedVersion { @@ -159,7 +187,7 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels CurrentVersion = new HardwareVersion(); CreateTemplate(CurrentVersion); - CopyParametersCommand = new RelayCommand(CopyParameters,(x) => SelectedVersion != null && SelectedHardwareObjectType != null); + CopyParametersCommand = new RelayCommand(CopyParameters, (x) => SelectedVersion != null && SelectedHardwareObjectType != null); CloneCommand = new RelayCommand(CloneCurrentVersion, () => SelectedVersion != null); } @@ -188,6 +216,14 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels { target = CurrentVersion.HardwareSpeedSensors.SingleOrDefault(x => x.HardwareSpeedSensorType == source); } + else if (source is HardwareBlowerType) + { + target = CurrentVersion.HardwareBlowers.SingleOrDefault(x => x.HardwareBlowerType == source); + } + else if (source is HardwareBreakSensorType) + { + target = CurrentVersion.HardwareBreakSensors.SingleOrDefault(x => x.HardwareBreakSensorType == source); + } target.MapPrimitivesTo(SelectedHardwareObject); } @@ -276,6 +312,38 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels SelectedHardwareObject = hardwareObj; } } + else if (SelectedHardwareObjectType is SelectedObject<HardwareBlowerType>) + { + var type = (SelectedHardwareObjectType as SelectedObject<HardwareBlowerType>).Data; + var hardwareObj = CurrentVersion.HardwareBlowers.SingleOrDefault(x => x.HardwareBlowerType == type); + + if (hardwareObj != null) + { + SelectedHardwareObject = hardwareObj; + } + else + { + hardwareObj = new HardwareBlower() { HardwareBlowerType = type }; + CurrentVersion.HardwareBlowers.Add(hardwareObj); + SelectedHardwareObject = hardwareObj; + } + } + else if (SelectedHardwareObjectType is SelectedObject<HardwareBreakSensorType>) + { + var type = (SelectedHardwareObjectType as SelectedObject<HardwareBreakSensorType>).Data; + var hardwareObj = CurrentVersion.HardwareBreakSensors.SingleOrDefault(x => x.HardwareBreakSensorType == type); + + if (hardwareObj != null) + { + SelectedHardwareObject = hardwareObj; + } + else + { + hardwareObj = new HardwareBreakSensor() { HardwareBreakSensorType = type }; + CurrentVersion.HardwareBreakSensors.Add(hardwareObj); + SelectedHardwareObject = hardwareObj; + } + } } } @@ -288,6 +356,8 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels SelectedPidControlTypes = new ObservableCollection<HardwarePidControlType>(); SelectedWinderTypes = new ObservableCollection<HardwareWinderType>(); SelectedSpeedSensorTypes = new ObservableCollection<HardwareSpeedSensorType>(); + SelectedBlowerTypes = new ObservableCollection<HardwareBlowerType>(); + SelectedBreakSensorTypes = new ObservableCollection<HardwareBreakSensorType>(); } else { @@ -296,6 +366,8 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels SelectedPidControlTypes = version.HardwarePidControls.Select(x => x.HardwarePidControlType).ToObservableCollection(); SelectedWinderTypes = version.HardwareWinders.Select(x => x.HardwareWinderType).ToObservableCollection(); SelectedSpeedSensorTypes = version.HardwareSpeedSensors.Select(x => x.HardwareSpeedSensorType).ToObservableCollection(); + SelectedBlowerTypes = version.HardwareBlowers.Select(x => x.HardwareBlowerType).ToObservableCollection(); + SelectedBreakSensorTypes = version.HardwareBreakSensors.Select(x => x.HardwareBreakSensorType).ToObservableCollection(); } MotorTypes = new SelectedObjectCollection<HardwareMotorType>(Adapter.HardwareMotorTypes, SelectedMotorTypes); @@ -303,6 +375,8 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels PidControlTypes = new SelectedObjectCollection<HardwarePidControlType>(Adapter.HardwarePidControlTypes, SelectedPidControlTypes); WinderTypes = new SelectedObjectCollection<HardwareWinderType>(Adapter.HardwareWinderTypes, SelectedWinderTypes); SpeedSensorTypes = new SelectedObjectCollection<HardwareSpeedSensorType>(Adapter.HardwareSpeedSensorTypes, SelectedSpeedSensorTypes); + BlowerTypes = new SelectedObjectCollection<HardwareBlowerType>(Adapter.HardwareBlowerTypes, SelectedBlowerTypes); + BreakSensorTypes = new SelectedObjectCollection<HardwareBreakSensorType>(Adapter.HardwareBreakSensorTypes, SelectedBreakSensorTypes); } private void OnSelectedVersionChanged() @@ -363,6 +437,8 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels realVersion.HardwarePidControls.ToList().Where(x => !SelectedPidControlTypes.Contains(x.HardwarePidControlType)).ToList().ForEach(x => realVersion.HardwarePidControls.Remove(x)); realVersion.HardwareWinders.ToList().Where(x => !SelectedWinderTypes.Contains(x.HardwareWinderType)).ToList().ForEach(x => realVersion.HardwareWinders.Remove(x)); realVersion.HardwareSpeedSensors.ToList().Where(x => !SelectedSpeedSensorTypes.Contains(x.HardwareSpeedSensorType)).ToList().ForEach(x => realVersion.HardwareSpeedSensors.Remove(x)); + realVersion.HardwareBlowers.ToList().Where(x => !SelectedBlowerTypes.Contains(x.HardwareBlowerType)).ToList().ForEach(x => realVersion.HardwareBlowers.Remove(x)); + realVersion.HardwareBreakSensors.ToList().Where(x => !SelectedBreakSensorTypes.Contains(x.HardwareBreakSensorType)).ToList().ForEach(x => realVersion.HardwareBreakSensors.Remove(x)); } else { @@ -376,12 +452,16 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels realVersion.HardwarePidControls.ToList().ForEach(x => x.DefferedDelete(Adapter.Context)); realVersion.HardwareWinders.ToList().ForEach(x => x.DefferedDelete(Adapter.Context)); realVersion.HardwareSpeedSensors.ToList().ForEach(x => x.DefferedDelete(Adapter.Context)); + realVersion.HardwareBlowers.ToList().ForEach(x => x.DefferedDelete(Adapter.Context)); + realVersion.HardwareBreakSensors.ToList().ForEach(x => x.DefferedDelete(Adapter.Context)); realVersion.HardwareDancers.Clear(); realVersion.HardwareMotors.Clear(); realVersion.HardwarePidControls.Clear(); realVersion.HardwareWinders.Clear(); realVersion.HardwareSpeedSensors.Clear(); + realVersion.HardwareBlowers.Clear(); + realVersion.HardwareBreakSensors.Clear(); foreach (var type in SelectedDancerTypes) { @@ -472,6 +552,42 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels }); } } + + foreach (var type in SelectedBlowerTypes) + { + var item = CurrentVersion.HardwareBlowers.SingleOrDefault(x => x.HardwareBlowerType == type); + if (item != null) + { + item.HardwareVersionGuid = realVersion.Guid; + realVersion.HardwareBlowers.Add(item); + } + else + { + realVersion.HardwareBlowers.Add(new HardwareBlower() + { + HardwareVersionGuid = realVersion.Guid, + HardwareBlowerType = type + }); + } + } + + foreach (var type in SelectedBreakSensorTypes) + { + var item = CurrentVersion.HardwareBreakSensors.SingleOrDefault(x => x.HardwareBreakSensorType == type); + if (item != null) + { + item.HardwareVersionGuid = realVersion.Guid; + realVersion.HardwareBreakSensors.Add(item); + } + else + { + realVersion.HardwareBreakSensors.Add(new HardwareBreakSensor() + { + HardwareVersionGuid = realVersion.Guid, + HardwareBreakSensorType = type + }); + } + } } @@ -499,7 +615,7 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels { using (_notification.PushTaskItem("Cloning hardware configuration...")) { - await Task.Factory.StartNew(() => + await Task.Factory.StartNew(() => { var realVersion = CurrentVersion.Clone(); realVersion.Name = name; @@ -510,18 +626,24 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels realVersion.HardwarePidControls.ToList().Where(x => !SelectedPidControlTypes.Contains(x.HardwarePidControlType)).ToList().ForEach(x => realVersion.HardwarePidControls.Remove(x)); realVersion.HardwareWinders.ToList().Where(x => !SelectedWinderTypes.Contains(x.HardwareWinderType)).ToList().ForEach(x => realVersion.HardwareWinders.Remove(x)); realVersion.HardwareSpeedSensors.ToList().Where(x => !SelectedSpeedSensorTypes.Contains(x.HardwareSpeedSensorType)).ToList().ForEach(x => realVersion.HardwareSpeedSensors.Remove(x)); + realVersion.HardwareBlowers.ToList().Where(x => !SelectedBlowerTypes.Contains(x.HardwareBlowerType)).ToList().ForEach(x => realVersion.HardwareBlowers.Remove(x)); + realVersion.HardwareBreakSensors.ToList().Where(x => !SelectedBreakSensorTypes.Contains(x.HardwareBreakSensorType)).ToList().ForEach(x => realVersion.HardwareBreakSensors.Remove(x)); realVersion.HardwareMotors.ToList().ForEach(x => x.HardwareVersionGuid = realVersion.Guid); realVersion.HardwareDancers.ToList().ForEach(x => x.HardwareVersionGuid = realVersion.Guid); realVersion.HardwarePidControls.ToList().ForEach(x => x.HardwareVersionGuid = realVersion.Guid); realVersion.HardwareWinders.ToList().ForEach(x => x.HardwareVersionGuid = realVersion.Guid); realVersion.HardwareSpeedSensors.ToList().ForEach(x => x.HardwareVersionGuid = realVersion.Guid); + realVersion.HardwareBlowers.ToList().ForEach(x => x.HardwareVersionGuid = realVersion.Guid); + realVersion.HardwareBreakSensors.ToList().ForEach(x => x.HardwareVersionGuid = realVersion.Guid); realVersion.HardwareMotors.ToList().ForEach(x => x.HardwareVersion = realVersion); realVersion.HardwareDancers.ToList().ForEach(x => x.HardwareVersion = realVersion); realVersion.HardwarePidControls.ToList().ForEach(x => x.HardwareVersion = realVersion); realVersion.HardwareWinders.ToList().ForEach(x => x.HardwareVersion = realVersion); realVersion.HardwareSpeedSensors.ToList().ForEach(x => x.HardwareVersion = realVersion); + realVersion.HardwareBlowers.ToList().ForEach(x => x.HardwareVersion = realVersion); + realVersion.HardwareBreakSensors.ToList().ForEach(x => x.HardwareVersion = realVersion); Adapter.Context.HardwareVersions.Add(realVersion); realVersion.Save(Adapter.Context); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml index e22b0e71a..86e0da5b5 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml @@ -263,6 +263,82 @@ </DataTemplate> </ListBox.ItemTemplate> </ListBox> + + <StackPanel Orientation="Horizontal" Margin="0 20 0 0"> + <Image VerticalAlignment="Center" Source="../Images/blower.png" Width="32"></Image> + <TextBlock Margin="10 0 0 0" VerticalAlignment="Center" FontSize="18" FontWeight="SemiBold">BLOWERS</TextBlock> + </StackPanel> + <ListBox Style="{StaticResource typesList}" HorizontalContentAlignment="Stretch" ItemsSource="{Binding BlowerTypes}" Margin="60 15" SelectedItem="{Binding SelectedHardwareObjectType}"> + <ListBox.ItemTemplate> + <DataTemplate DataType="{x:Type entities:HardwareBlowerType}"> + <DockPanel> + <Button DockPanel.Dock="Right" Cursor="Hand" Foreground="DimGray" Height="20" FontSize="10" ToolTip="Copy this item parameters to the selected item" Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.CopyParametersCommand}" CommandParameter="{Binding}"> + <Button.Style> + <Style TargetType="Button" BasedOn="{StaticResource MaterialDesignFlatButton}"> + <Setter Property="Visibility" Value="Collapsed"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.SelectedHardwareObjectType.Data.ObjectType.BaseType}" Value="{x:Type entities:HardwareBlowerType}"> + <Setter Property="Visibility" Value="Visible"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=ListBoxItem},Path=IsSelected}" Value="True"> + <Setter Property="Visibility" Value="Collapsed"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </Button.Style> + <Button.Content> + <StackPanel Orientation="Horizontal"> + <TextBlock VerticalAlignment="Center">Copy Parameters</TextBlock> + <materialDesign:PackIcon Margin="10 0 0 0" VerticalAlignment="Center" Kind="ArrowRight" Width="16" Height="16" /> + </StackPanel> + </Button.Content> + </Button> + <StackPanel Orientation="Horizontal"> + <CheckBox VerticalAlignment="Center" IsChecked="{Binding IsSelected}"></CheckBox> + <TextBlock Margin="10 0 0 0" VerticalAlignment="Center" Text="{Binding Data.Description}"></TextBlock> + </StackPanel> + </DockPanel> + </DataTemplate> + </ListBox.ItemTemplate> + </ListBox> + + <StackPanel Orientation="Horizontal" Margin="0 20 0 0"> + <Image VerticalAlignment="Center" Source="../Images/break.png" Width="32"></Image> + <TextBlock Margin="10 0 0 0" VerticalAlignment="Center" FontSize="18" FontWeight="SemiBold">BREAK SENSORS</TextBlock> + </StackPanel> + <ListBox Style="{StaticResource typesList}" HorizontalContentAlignment="Stretch" ItemsSource="{Binding BreakSensorTypes}" Margin="60 15" SelectedItem="{Binding SelectedHardwareObjectType}"> + <ListBox.ItemTemplate> + <DataTemplate DataType="{x:Type entities:HardwareBreakSensorType}"> + <DockPanel> + <Button DockPanel.Dock="Right" Cursor="Hand" Foreground="DimGray" Height="20" FontSize="10" ToolTip="Copy this item parameters to the selected item" Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.CopyParametersCommand}" CommandParameter="{Binding}"> + <Button.Style> + <Style TargetType="Button" BasedOn="{StaticResource MaterialDesignFlatButton}"> + <Setter Property="Visibility" Value="Collapsed"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.SelectedHardwareObjectType.Data.ObjectType.BaseType}" Value="{x:Type entities:HardwareBreakSensorType}"> + <Setter Property="Visibility" Value="Visible"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=ListBoxItem},Path=IsSelected}" Value="True"> + <Setter Property="Visibility" Value="Collapsed"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </Button.Style> + <Button.Content> + <StackPanel Orientation="Horizontal"> + <TextBlock VerticalAlignment="Center">Copy Parameters</TextBlock> + <materialDesign:PackIcon Margin="10 0 0 0" VerticalAlignment="Center" Kind="ArrowRight" Width="16" Height="16" /> + </StackPanel> + </Button.Content> + </Button> + <StackPanel Orientation="Horizontal"> + <CheckBox VerticalAlignment="Center" IsChecked="{Binding IsSelected}"></CheckBox> + <TextBlock Margin="10 0 0 0" VerticalAlignment="Center" Text="{Binding Data.Description}"></TextBlock> + </StackPanel> + </DockPanel> + </DataTemplate> + </ListBox.ItemTemplate> + </ListBox> </StackPanel> </ScrollViewer> 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 3a0191be4..0bd8f8133 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 @@ -176,8 +176,8 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels { if (SelectedMachine != null) { - Machine = SelectedMachine.CloneEntity(); - Configuration = Machine.Configuration.CloneConfiguration(); + Machine = SelectedMachine.Clone(); + Configuration = Machine.Configuration.Clone(); History = SelectedMachine.MachinesConfigurations.Select(x => x.Configuration).ToObservableCollection(); } else @@ -193,7 +193,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels { if (SelectedHistoryConfiguration != null) { - Configuration = SelectedHistoryConfiguration.CloneConfiguration(); + Configuration = SelectedHistoryConfiguration.Clone(); } } @@ -552,7 +552,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels await Machine.SaveAsync(Adapter.Context); Machine = Adapter.Machines.SingleOrDefault(x => x.Guid == Machine.Guid); - Configuration = Machine.Configuration.CloneConfiguration(); + Configuration = Machine.Configuration.Clone(); } } else @@ -586,11 +586,11 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels await machine.SaveAsync(Adapter.Context); Machine = Adapter.Machines.SingleOrDefault(x => x.Guid == machine.Guid); - Configuration = Machine.Configuration.CloneConfiguration(); + Configuration = Machine.Configuration.Clone(); } SetHistory(Machine); - Machine = Machine.CloneEntity(); + Machine = Machine.Clone(); } } catch (Exception ex) @@ -621,7 +621,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels { if (Machine.MachineVersion != null) { - Configuration = Machine.MachineVersion.DefaultConfiguration.CloneConfiguration(); + Configuration = Machine.MachineVersion.DefaultConfiguration.Clone(); } else { @@ -642,7 +642,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels { if (vm.SelectedVersion != null) { - vm.SelectedVersion.DefaultConfiguration = Configuration.CloneConfiguration(); + vm.SelectedVersion.DefaultConfiguration = Configuration.Clone(); vm.SelectedVersion.DefaultConfigurationGuid = vm.SelectedVersion.DefaultConfiguration.Guid; await vm.SelectedVersion.SaveAsync(Adapter.Context); } @@ -652,7 +652,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels newVersion.Version = vm.Version; newVersion.Name = vm.VersionName; - newVersion.DefaultConfiguration = Configuration.CloneConfiguration(); + newVersion.DefaultConfiguration = Configuration.Clone(); newVersion.DefaultConfigurationGuid = newVersion.DefaultConfiguration.Guid; await newVersion.SaveAsync(Adapter.Context); } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/BlowerElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/BlowerElementEditor.xaml new file mode 100644 index 000000000..675571657 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/BlowerElementEditor.xaml @@ -0,0 +1,79 @@ +<local:ElementEditor x:Class="Tango.MachineStudio.Technician.Editors.BlowerElementEditor" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:sharedConverters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" + xmlns:items="clr-namespace:Tango.MachineStudio.Technician.TechItems" + xmlns:converters="clr-namespace:Tango.Editors.Converters;assembly=Tango.Editors" + xmlns:visuals="clr-namespace:Tango.Visuals;assembly=Tango.Visuals" + xmlns:local="clr-namespace:Tango.Editors;assembly=Tango.Editors" + mc:Ignorable="d" Background="Transparent" ClipToBounds="False" BorderThickness="0" MinWidth="1" MinHeight="1" RenderTransformOrigin="0.5,0.5" d:DataContext="{d:DesignInstance Type=items:BlowerItem, IsDesignTimeCreatable=False}" Height="99.188" Width="163.459"> + + <UserControl.Resources> + <converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"></converters:BoolToVisibilityConverter> + <sharedConverters:BooleanInverseConverter x:Key="BooleanInverseConverter" /> + + <!--Theme--> + <SolidColorBrush x:Key="BorderBrush" Color="Transparent"></SolidColorBrush> + <SolidColorBrush x:Key="CornersBrush" Color="Red"></SolidColorBrush> + </UserControl.Resources> + + <UserControl.RenderTransform> + <RotateTransform Angle="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=Angle}"></RotateTransform> + </UserControl.RenderTransform> + + <Grid> + + + <!--Content--> + <Grid IsHitTestVisible="{Binding RelativeSource={RelativeSource AncestorType=local:ElementsEditor},Path=IsEditable,Converter={StaticResource BooleanInverseConverter}}"> + + <Image Source="../Images/blower-big.png"></Image> + + <Border Margin="0 0 0 -23" VerticalAlignment="Bottom"> + <TextBlock Text="{Binding HardwareBlowerType.Description}" FontSize="14" Foreground="DimGray" HorizontalAlignment="Center"></TextBlock> + </Border> + </Grid> + <!--Content--> + + + <Border BorderThickness="1" BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=BorderBrush,TargetNullValue={StaticResource BorderBrush},FallbackValue={StaticResource BorderBrush}}" Visibility="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=(local:ElementsEditor.IsSelected),Converter={StaticResource BoolToVisibilityConverter}}"> + <Grid> + <ContentPresenter Content="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=InnerContent}"></ContentPresenter> + + <Thumb Opacity="0" DragDelta="MoveDrag" DragStarted="DragStarted" DragCompleted="OnDragEnded"></Thumb> + <Thumb HorizontalAlignment="Left" Cursor="SizeWE" Opacity="0" DragDelta="DragLeft" DragStarted="DragStarted" DragCompleted="OnDragEnded"></Thumb> + <Thumb HorizontalAlignment="Right" Cursor="SizeWE" Opacity="0" DragDelta="DragRight" DragStarted="DragStarted" DragCompleted="OnDragEnded"></Thumb> + <Thumb VerticalAlignment="Top" Cursor="SizeNS" Opacity="0" DragDelta="DragTop" DragStarted="DragStarted" DragCompleted="OnDragEnded"></Thumb> + <Thumb VerticalAlignment="Bottom" Cursor="SizeNS" Opacity="0" DragDelta="DragBottom" DragStarted="DragStarted" DragCompleted="OnDragEnded"></Thumb> + + <Grid ClipToBounds="False" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0 -20 0 0" Width="10" Height="10"> + <Ellipse Stroke="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=CornersBrush,TargetNullValue={StaticResource CornersBrush},FallbackValue={StaticResource CornersBrush}}" StrokeThickness="2"></Ellipse> + <Rectangle HorizontalAlignment="Center" VerticalAlignment="Stretch" Margin="0 10 0 -8" StrokeThickness="1" Stroke="Red"></Rectangle> + <Thumb Opacity="0" DragDelta="DragAngle" DragStarted="DragStarted" Cursor="Arrow" DragCompleted="OnDragEnded"></Thumb> + </Grid> + + <Grid Width="10" Height="10" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="-8 -8 0 0"> + <Border BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=CornersBrush,TargetNullValue={StaticResource CornersBrush},FallbackValue={StaticResource CornersBrush}}" BorderThickness="2 2 0 0"></Border> + <Thumb Opacity="0" DragDelta="DragTopLeft" DragStarted="DragStarted" Cursor="SizeNWSE" DragCompleted="OnDragEnded"></Thumb> + </Grid> + + <Grid Width="10" Height="10" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0 -8 -8 0"> + <Border BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=CornersBrush,TargetNullValue={StaticResource CornersBrush},FallbackValue={StaticResource CornersBrush}}" BorderThickness="0 2 2 0"></Border> + <Thumb Opacity="0" DragDelta="DragTopRight" DragStarted="DragStarted" Cursor="SizeNESW" DragCompleted="OnDragEnded"></Thumb> + </Grid> + + <Grid Width="10" Height="10" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0 0 -8 -8"> + <Border BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=CornersBrush,TargetNullValue={StaticResource CornersBrush},FallbackValue={StaticResource CornersBrush}}" BorderThickness="0 0 2 2"></Border> + <Thumb Opacity="0" DragDelta="DragBottomRight" DragStarted="DragStarted" Cursor="SizeNWSE" DragCompleted="OnDragEnded"></Thumb> + </Grid> + + <Grid Width="10" Height="10" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="-8 0 0 -8"> + <Border BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=CornersBrush,TargetNullValue={StaticResource CornersBrush},FallbackValue={StaticResource CornersBrush}}" BorderThickness="2 0 0 2"></Border> + <Thumb Opacity="0" DragDelta="DragBottomLeft" DragStarted="DragStarted" Cursor="SizeNESW" DragCompleted="OnDragEnded"></Thumb> + </Grid> + </Grid> + </Border> + </Grid> +</local:ElementEditor> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/BlowerElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/BlowerElementEditor.xaml.cs new file mode 100644 index 000000000..558cc6fcc --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/BlowerElementEditor.xaml.cs @@ -0,0 +1,103 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Markup; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.Editors; +using Tango.BL.Entities; +using Tango.MachineStudio.Technician.TechItems; +using Tango.Core; + +namespace Tango.MachineStudio.Technician.Editors +{ + [ContentProperty("InnerContent")] + public partial class BlowerElementEditor : ElementEditor + { + /// <summary> + /// Initializes a new instance of the <see cref="MonitorElementEditor"/> class. + /// </summary> + public BlowerElementEditor() + : base() + { + InitializeComponent(); + } + + /// <summary> + /// Initializes a new instance of the <see cref="MonitorElementEditor"/> class. + /// </summary> + /// <param name="frameworkElement">The framework element.</param> + public BlowerElementEditor(BlowerItem blowerItem) + : this() + { + BlowerItem = blowerItem; + DataContext = BlowerItem; + } + + /// <summary> + /// Initializes a new instance of the <see cref="MonitorElementEditor"/> class. + /// </summary> + /// <param name="frameworkElement">The framework element.</param> + /// <param name="bounds">The bounds.</param> + public BlowerElementEditor(BlowerItem blowerItem, Rect bounds) + : this(blowerItem) + { + Left = bounds.Left; + Top = bounds.Top; + Width = bounds.Width; + Height = bounds.Height; + } + + private BlowerItem _blowerItem; + + public BlowerItem BlowerItem + { + get { return _blowerItem; } + set { _blowerItem = value; RaisePropertyChanged(nameof(BlowerItem)); } + } + + + /// <summary> + /// Clones this instance. + /// </summary> + /// <returns></returns> + public override IElementEditor Clone() + { + try + { + var clonedItem = BlowerItem.Clone() as BlowerItem; + BlowerElementEditor cloned = new BlowerElementEditor(clonedItem); + cloned.Top = Top; + cloned.Left = Left; + cloned.Width = Width; + cloned.Height = Height; + cloned.Angle = Angle; + return cloned; + } + catch (Exception ex) + { + throw new InvalidOperationException("Could not clone this editor. You may have to create a custom editor and implement a custom Clone method.", ex); + } + } + + /// <summary> + /// Gets the hosted element. + /// </summary> + [ParameterIgnore] + public override Object HostedElement + { + get { return BlowerItem; } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/BreakSensorElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/BreakSensorElementEditor.xaml new file mode 100644 index 000000000..18c992193 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/BreakSensorElementEditor.xaml @@ -0,0 +1,79 @@ +<local:ElementEditor x:Class="Tango.MachineStudio.Technician.Editors.BreakSensorElementEditor" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:sharedConverters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" + xmlns:items="clr-namespace:Tango.MachineStudio.Technician.TechItems" + xmlns:converters="clr-namespace:Tango.Editors.Converters;assembly=Tango.Editors" + xmlns:visuals="clr-namespace:Tango.Visuals;assembly=Tango.Visuals" + xmlns:local="clr-namespace:Tango.Editors;assembly=Tango.Editors" + mc:Ignorable="d" Background="Transparent" ClipToBounds="False" BorderThickness="0" MinWidth="1" MinHeight="1" RenderTransformOrigin="0.5,0.5" d:DataContext="{d:DesignInstance Type=items:BreakSensorItem, IsDesignTimeCreatable=False}" Height="99.188" Width="163.459"> + + <UserControl.Resources> + <converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"></converters:BoolToVisibilityConverter> + <sharedConverters:BooleanInverseConverter x:Key="BooleanInverseConverter" /> + + <!--Theme--> + <SolidColorBrush x:Key="BorderBrush" Color="Transparent"></SolidColorBrush> + <SolidColorBrush x:Key="CornersBrush" Color="Red"></SolidColorBrush> + </UserControl.Resources> + + <UserControl.RenderTransform> + <RotateTransform Angle="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=Angle}"></RotateTransform> + </UserControl.RenderTransform> + + <Grid> + + + <!--Content--> + <Grid IsHitTestVisible="{Binding RelativeSource={RelativeSource AncestorType=local:ElementsEditor},Path=IsEditable,Converter={StaticResource BooleanInverseConverter}}"> + + <Image Source="../Images/break-big.png"></Image> + + <Border Margin="0 0 0 -23" VerticalAlignment="Bottom"> + <TextBlock Text="{Binding HardwareBreakSensorType.Description}" FontSize="14" Foreground="DimGray" HorizontalAlignment="Center"></TextBlock> + </Border> + </Grid> + <!--Content--> + + + <Border BorderThickness="1" BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=BorderBrush,TargetNullValue={StaticResource BorderBrush},FallbackValue={StaticResource BorderBrush}}" Visibility="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=(local:ElementsEditor.IsSelected),Converter={StaticResource BoolToVisibilityConverter}}"> + <Grid> + <ContentPresenter Content="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=InnerContent}"></ContentPresenter> + + <Thumb Opacity="0" DragDelta="MoveDrag" DragStarted="DragStarted" DragCompleted="OnDragEnded"></Thumb> + <Thumb HorizontalAlignment="Left" Cursor="SizeWE" Opacity="0" DragDelta="DragLeft" DragStarted="DragStarted" DragCompleted="OnDragEnded"></Thumb> + <Thumb HorizontalAlignment="Right" Cursor="SizeWE" Opacity="0" DragDelta="DragRight" DragStarted="DragStarted" DragCompleted="OnDragEnded"></Thumb> + <Thumb VerticalAlignment="Top" Cursor="SizeNS" Opacity="0" DragDelta="DragTop" DragStarted="DragStarted" DragCompleted="OnDragEnded"></Thumb> + <Thumb VerticalAlignment="Bottom" Cursor="SizeNS" Opacity="0" DragDelta="DragBottom" DragStarted="DragStarted" DragCompleted="OnDragEnded"></Thumb> + + <Grid ClipToBounds="False" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0 -20 0 0" Width="10" Height="10"> + <Ellipse Stroke="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=CornersBrush,TargetNullValue={StaticResource CornersBrush},FallbackValue={StaticResource CornersBrush}}" StrokeThickness="2"></Ellipse> + <Rectangle HorizontalAlignment="Center" VerticalAlignment="Stretch" Margin="0 10 0 -8" StrokeThickness="1" Stroke="Red"></Rectangle> + <Thumb Opacity="0" DragDelta="DragAngle" DragStarted="DragStarted" Cursor="Arrow" DragCompleted="OnDragEnded"></Thumb> + </Grid> + + <Grid Width="10" Height="10" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="-8 -8 0 0"> + <Border BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=CornersBrush,TargetNullValue={StaticResource CornersBrush},FallbackValue={StaticResource CornersBrush}}" BorderThickness="2 2 0 0"></Border> + <Thumb Opacity="0" DragDelta="DragTopLeft" DragStarted="DragStarted" Cursor="SizeNWSE" DragCompleted="OnDragEnded"></Thumb> + </Grid> + + <Grid Width="10" Height="10" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0 -8 -8 0"> + <Border BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=CornersBrush,TargetNullValue={StaticResource CornersBrush},FallbackValue={StaticResource CornersBrush}}" BorderThickness="0 2 2 0"></Border> + <Thumb Opacity="0" DragDelta="DragTopRight" DragStarted="DragStarted" Cursor="SizeNESW" DragCompleted="OnDragEnded"></Thumb> + </Grid> + + <Grid Width="10" Height="10" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0 0 -8 -8"> + <Border BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=CornersBrush,TargetNullValue={StaticResource CornersBrush},FallbackValue={StaticResource CornersBrush}}" BorderThickness="0 0 2 2"></Border> + <Thumb Opacity="0" DragDelta="DragBottomRight" DragStarted="DragStarted" Cursor="SizeNWSE" DragCompleted="OnDragEnded"></Thumb> + </Grid> + + <Grid Width="10" Height="10" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="-8 0 0 -8"> + <Border BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=CornersBrush,TargetNullValue={StaticResource CornersBrush},FallbackValue={StaticResource CornersBrush}}" BorderThickness="2 0 0 2"></Border> + <Thumb Opacity="0" DragDelta="DragBottomLeft" DragStarted="DragStarted" Cursor="SizeNESW" DragCompleted="OnDragEnded"></Thumb> + </Grid> + </Grid> + </Border> + </Grid> +</local:ElementEditor> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/BreakSensorElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/BreakSensorElementEditor.xaml.cs new file mode 100644 index 000000000..da4530e35 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/BreakSensorElementEditor.xaml.cs @@ -0,0 +1,103 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Markup; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.Editors; +using Tango.BL.Entities; +using Tango.MachineStudio.Technician.TechItems; +using Tango.Core; + +namespace Tango.MachineStudio.Technician.Editors +{ + [ContentProperty("InnerContent")] + public partial class BreakSensorElementEditor : ElementEditor + { + /// <summary> + /// Initializes a new instance of the <see cref="MonitorElementEditor"/> class. + /// </summary> + public BreakSensorElementEditor() + : base() + { + InitializeComponent(); + } + + /// <summary> + /// Initializes a new instance of the <see cref="MonitorElementEditor"/> class. + /// </summary> + /// <param name="frameworkElement">The framework element.</param> + public BreakSensorElementEditor(BreakSensorItem breakSensorItem) + : this() + { + BreakSensorItem = breakSensorItem; + DataContext = BreakSensorItem; + } + + /// <summary> + /// Initializes a new instance of the <see cref="MonitorElementEditor"/> class. + /// </summary> + /// <param name="frameworkElement">The framework element.</param> + /// <param name="bounds">The bounds.</param> + public BreakSensorElementEditor(BreakSensorItem breakSensorItem, Rect bounds) + : this(breakSensorItem) + { + Left = bounds.Left; + Top = bounds.Top; + Width = bounds.Width; + Height = bounds.Height; + } + + private BreakSensorItem _breakSensorItem; + + public BreakSensorItem BreakSensorItem + { + get { return _breakSensorItem; } + set { _breakSensorItem = value; RaisePropertyChanged(nameof(BreakSensorItem)); } + } + + + /// <summary> + /// Clones this instance. + /// </summary> + /// <returns></returns> + public override IElementEditor Clone() + { + try + { + var clonedItem = BreakSensorItem.Clone() as BreakSensorItem; + BreakSensorElementEditor cloned = new BreakSensorElementEditor(clonedItem); + cloned.Top = Top; + cloned.Left = Left; + cloned.Width = Width; + cloned.Height = Height; + cloned.Angle = Angle; + return cloned; + } + catch (Exception ex) + { + throw new InvalidOperationException("Could not clone this editor. You may have to create a custom editor and implement a custom Clone method.", ex); + } + } + + /// <summary> + /// Gets the hosted element. + /// </summary> + [ParameterIgnore] + public override Object HostedElement + { + get { return BreakSensorItem; } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/blower-big.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/blower-big.png Binary files differnew file mode 100644 index 000000000..c93daea65 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/blower-big.png diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/blower.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/blower.png Binary files differnew file mode 100644 index 000000000..a3797b514 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/blower.png diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/break-big.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/break-big.png Binary files differnew file mode 100644 index 000000000..363ee88a1 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/break-big.png diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/break.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/break.png Binary files differnew file mode 100644 index 000000000..67bd5982e --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/break.png diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/BlowerTemplate.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/BlowerTemplate.xaml new file mode 100644 index 000000000..16d270f01 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/BlowerTemplate.xaml @@ -0,0 +1,77 @@ +<UserControl x:Class="Tango.MachineStudio.Technician.PropertiesTemplates.BlowerTemplate" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:converters="clr-namespace:Tango.MachineStudio.Technician.Converters" + xmlns:sharedConverters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" + xmlns:items="clr-namespace:Tango.MachineStudio.Technician.TechItems" + xmlns:editors="clr-namespace:Tango.SharedUI.Editors;assembly=Tango.SharedUI" + xmlns:mahApps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:colorPicker="clr-namespace:Tango;assembly=Tango.ColorPicker" + xmlns:local="clr-namespace:Tango.MachineStudio.Technician.PropertiesTemplates" + mc:Ignorable="d" + d:DesignHeight="500" d:DesignWidth="200" d:DataContext="{d:DesignInstance Type=items:BlowerItem, IsDesignTimeCreatable=False}"> + + <UserControl.Resources> + <sharedConverters:DoubleToIntConverter x:Key="DoubleToIntConverter" /> + + <Style TargetType="{x:Type TabItem}" BasedOn="{StaticResource {x:Type TabItem}}"> + <Setter Property="mahApps:ControlsHelper.HeaderFontSize" Value="14" /> + <Setter Property="Margin" Value="2" /> + </Style> + </UserControl.Resources> + + <Grid> + <StackPanel> + <GroupBox Header="BLOWER"> + <StackPanel> + <TextBlock FontSize="10">Selected Blower</TextBlock> + <ComboBox Margin="0 5 0 0" ItemsSource="{Binding Adapter.HardwareBlowerTypes}" SelectedItem="{Binding HardwareBlowerType,Mode=TwoWay}" DisplayMemberPath="Description" /> + </StackPanel> + </GroupBox> + + <GroupBox Header="PARAMETERS" Margin="0 10 0 0"> + <editors:ParameterizedEditor ParameterizedObject="{Binding HardwareBlower}" Padding="10"> + <editors:ParameterizedEditor.ItemsPanel> + <ItemsPanelTemplate> + <StackPanel></StackPanel> + </ItemsPanelTemplate> + </editors:ParameterizedEditor.ItemsPanel> + <editors:ParameterizedEditor.DoubleTemplate> + <DataTemplate> + <DockPanel> + <mahApps:NumericUpDown DockPanel.Dock="Right" Background="Transparent" BorderThickness="0 0 0 0" Value="{Binding Value,UpdateSourceTrigger=PropertyChanged}" HasDecimals="True" HorizontalContentAlignment="Center" Width="100" /> + <TextBlock Text="{Binding Name}" VerticalAlignment="Center"></TextBlock> + </DockPanel> + </DataTemplate> + </editors:ParameterizedEditor.DoubleTemplate> + <editors:ParameterizedEditor.Int32Template> + <DataTemplate> + <DockPanel> + <mahApps:NumericUpDown DockPanel.Dock="Right" Background="Transparent" BorderThickness="0 0 0 0" Value="{Binding Value,Converter={StaticResource DoubleToIntConverter},UpdateSourceTrigger=PropertyChanged}" HasDecimals="False" HorizontalContentAlignment="Center" Width="100" /> + <TextBlock Text="{Binding Name}" VerticalAlignment="Center"></TextBlock> + </DockPanel> + </DataTemplate> + </editors:ParameterizedEditor.Int32Template> + <editors:ParameterizedEditor.BooleanTemplate> + <DataTemplate> + <DockPanel Margin="0 5 0 0"> + <ToggleButton DockPanel.Dock="Right" Width="100" IsChecked="{Binding Value}" HorizontalAlignment="Right" /> + <TextBlock Text="{Binding Name}" VerticalAlignment="Center"></TextBlock> + </DockPanel> + </DataTemplate> + </editors:ParameterizedEditor.BooleanTemplate> + </editors:ParameterizedEditor> + </GroupBox> + + <GroupBox Header="COLOR" Margin="0 10 0 0"> + <StackPanel> + <Viewbox Margin="0 5 0 0"> + <colorPicker:ColorCanvas SelectedColor="{Binding Color,Mode=TwoWay}" Background="Transparent" /> + </Viewbox> + </StackPanel> + </GroupBox> + </StackPanel> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/BlowerTemplate.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/BlowerTemplate.xaml.cs new file mode 100644 index 000000000..3622735d2 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/BlowerTemplate.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.Technician.PropertiesTemplates +{ + /// <summary> + /// Interaction logic for MonitorTemplate.xaml + /// </summary> + public partial class BlowerTemplate : UserControl + { + public BlowerTemplate() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/BreakSensorTemplate.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/BreakSensorTemplate.xaml new file mode 100644 index 000000000..7914c5a52 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/BreakSensorTemplate.xaml @@ -0,0 +1,77 @@ +<UserControl x:Class="Tango.MachineStudio.Technician.PropertiesTemplates.BreakSensorTemplate" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:converters="clr-namespace:Tango.MachineStudio.Technician.Converters" + xmlns:sharedConverters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" + xmlns:items="clr-namespace:Tango.MachineStudio.Technician.TechItems" + xmlns:editors="clr-namespace:Tango.SharedUI.Editors;assembly=Tango.SharedUI" + xmlns:mahApps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:colorPicker="clr-namespace:Tango;assembly=Tango.ColorPicker" + xmlns:local="clr-namespace:Tango.MachineStudio.Technician.PropertiesTemplates" + mc:Ignorable="d" + d:DesignHeight="500" d:DesignWidth="200" d:DataContext="{d:DesignInstance Type=items:BreakSensorItem, IsDesignTimeCreatable=False}"> + + <UserControl.Resources> + <sharedConverters:DoubleToIntConverter x:Key="DoubleToIntConverter" /> + + <Style TargetType="{x:Type TabItem}" BasedOn="{StaticResource {x:Type TabItem}}"> + <Setter Property="mahApps:ControlsHelper.HeaderFontSize" Value="14" /> + <Setter Property="Margin" Value="2" /> + </Style> + </UserControl.Resources> + + <Grid> + <StackPanel> + <GroupBox Header="SPEED SENSOR"> + <StackPanel> + <TextBlock FontSize="10">Selected Break Sensor</TextBlock> + <ComboBox Margin="0 5 0 0" ItemsSource="{Binding Adapter.HardwareBreakSensorTypes}" SelectedItem="{Binding HardwareBreakSensorType,Mode=TwoWay}" DisplayMemberPath="Description" /> + </StackPanel> + </GroupBox> + + <GroupBox Header="PARAMETERS" Margin="0 10 0 0"> + <editors:ParameterizedEditor ParameterizedObject="{Binding HardwareBreakSensor}" Padding="10"> + <editors:ParameterizedEditor.ItemsPanel> + <ItemsPanelTemplate> + <StackPanel></StackPanel> + </ItemsPanelTemplate> + </editors:ParameterizedEditor.ItemsPanel> + <editors:ParameterizedEditor.DoubleTemplate> + <DataTemplate> + <DockPanel> + <mahApps:NumericUpDown DockPanel.Dock="Right" Background="Transparent" BorderThickness="0 0 0 0" Value="{Binding Value,UpdateSourceTrigger=PropertyChanged}" HasDecimals="True" HorizontalContentAlignment="Center" Width="100" /> + <TextBlock Text="{Binding Name}" VerticalAlignment="Center"></TextBlock> + </DockPanel> + </DataTemplate> + </editors:ParameterizedEditor.DoubleTemplate> + <editors:ParameterizedEditor.Int32Template> + <DataTemplate> + <DockPanel> + <mahApps:NumericUpDown DockPanel.Dock="Right" Background="Transparent" BorderThickness="0 0 0 0" Value="{Binding Value,Converter={StaticResource DoubleToIntConverter},UpdateSourceTrigger=PropertyChanged}" HasDecimals="False" HorizontalContentAlignment="Center" Width="100" /> + <TextBlock Text="{Binding Name}" VerticalAlignment="Center"></TextBlock> + </DockPanel> + </DataTemplate> + </editors:ParameterizedEditor.Int32Template> + <editors:ParameterizedEditor.BooleanTemplate> + <DataTemplate> + <DockPanel Margin="0 5 0 0"> + <ToggleButton DockPanel.Dock="Right" Width="100" IsChecked="{Binding Value}" HorizontalAlignment="Right" /> + <TextBlock Text="{Binding Name}" VerticalAlignment="Center"></TextBlock> + </DockPanel> + </DataTemplate> + </editors:ParameterizedEditor.BooleanTemplate> + </editors:ParameterizedEditor> + </GroupBox> + + <GroupBox Header="COLOR" Margin="0 10 0 0"> + <StackPanel> + <Viewbox Margin="0 5 0 0"> + <colorPicker:ColorCanvas SelectedColor="{Binding Color,Mode=TwoWay}" Background="Transparent" /> + </Viewbox> + </StackPanel> + </GroupBox> + </StackPanel> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/BreakSensorTemplate.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/BreakSensorTemplate.xaml.cs new file mode 100644 index 000000000..7c9fc5ad0 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/BreakSensorTemplate.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.Technician.PropertiesTemplates +{ + /// <summary> + /// Interaction logic for MonitorTemplate.xaml + /// </summary> + public partial class BreakSensorTemplate : UserControl + { + public BreakSensorTemplate() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj index c9e30457e..14b88de03 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj @@ -114,6 +114,12 @@ <Compile Include="Editors\DancerElementEditor.xaml.cs"> <DependentUpon>DancerElementEditor.xaml</DependentUpon> </Compile> + <Compile Include="Editors\BlowerElementEditor.xaml.cs"> + <DependentUpon>BlowerElementEditor.xaml</DependentUpon> + </Compile> + <Compile Include="Editors\BreakSensorElementEditor.xaml.cs"> + <DependentUpon>BreakSensorElementEditor.xaml</DependentUpon> + </Compile> <Compile Include="Editors\SpeedSensorElementEditor.xaml.cs"> <DependentUpon>SpeedSensorElementEditor.xaml</DependentUpon> </Compile> @@ -179,6 +185,12 @@ <Compile Include="PropertiesTemplates\ProcessParametersTemplate.xaml.cs"> <DependentUpon>ProcessParametersTemplate.xaml</DependentUpon> </Compile> + <Compile Include="PropertiesTemplates\BlowerTemplate.xaml.cs"> + <DependentUpon>BlowerTemplate.xaml</DependentUpon> + </Compile> + <Compile Include="PropertiesTemplates\BreakSensorTemplate.xaml.cs"> + <DependentUpon>BreakSensorTemplate.xaml</DependentUpon> + </Compile> <Compile Include="PropertiesTemplates\SpeedSensorTemplate.xaml.cs"> <DependentUpon>SpeedSensorTemplate.xaml</DependentUpon> </Compile> @@ -203,6 +215,8 @@ <Compile Include="PropertiesTemplates\SingleGraphTemplate.xaml.cs"> <DependentUpon>SingleGraphTemplate.xaml</DependentUpon> </Compile> + <Compile Include="TechItems\BlowerItem.cs" /> + <Compile Include="TechItems\BreakSensorItem.cs" /> <Compile Include="TechItems\ControllerItem.cs" /> <Compile Include="TechItems\DigitalInItem.cs" /> <Compile Include="TechItems\DigitalOutItem.cs" /> @@ -258,6 +272,14 @@ <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </Page> + <Page Include="Editors\BlowerElementEditor.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> + <Page Include="Editors\BreakSensorElementEditor.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> <Page Include="Editors\SpeedSensorElementEditor.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> @@ -334,6 +356,14 @@ <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </Page> + <Page Include="PropertiesTemplates\BlowerTemplate.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> + <Page Include="PropertiesTemplates\BreakSensorTemplate.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> <Page Include="PropertiesTemplates\SpeedSensorTemplate.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> @@ -569,10 +599,20 @@ <ItemGroup> <Resource Include="Images\rgb-big.png" /> </ItemGroup> + <ItemGroup> + <Resource Include="Images\blower.png" /> + <Resource Include="Images\break.png" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\break-big.png" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\blower-big.png" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> + <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/BlowerItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/BlowerItem.cs new file mode 100644 index 000000000..59a96f107 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/BlowerItem.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; +using System.Xml.Serialization; +using Tango.BL.Entities; +using Tango.SharedUI.Helpers; + +namespace Tango.MachineStudio.Technician.TechItems +{ + /// <summary> + /// Represents a Blower controller item. + /// </summary> + /// <seealso cref="Tango.MachineStudio.Technician.TechItems.TechItem" /> + [TechItem(16)] + public class BlowerItem : TechItem + { + private static List<HardwareBlower> _BlowerConfigurations; + /// <summary> + /// Gets or sets the Blower configurations. + /// </summary> + public static List<HardwareBlower> BlowerConfigurations + { + get { return _BlowerConfigurations; } + set { _BlowerConfigurations = value; } + } + + static BlowerItem() + { + BlowerConfigurations = new List<HardwareBlower>(); + + foreach (var BlowerType in BL.ObservablesEntitiesAdapter.Instance.HardwareBlowerTypes) + { + BlowerConfigurations.Add(new HardwareBlower() { HardwareBlowerType = BlowerType }); + } + } + + private HardwareBlowerType _hardwareBlowerType; + /// <summary> + /// Gets or sets the type of the hardware Blower. + /// </summary> + [XmlIgnore] + public HardwareBlowerType HardwareBlowerType + { + get { return _hardwareBlowerType; } + set + { + _hardwareBlowerType = value; RaisePropertyChangedAuto(); TechName = _hardwareBlowerType != null ? _hardwareBlowerType.Description : null; ItemGuid = value != null ? value.Guid : null; + + if (_hardwareBlowerType != null) + { + HardwareBlower = BlowerConfigurations.SingleOrDefault(x => x.HardwareBlowerType == _hardwareBlowerType); + } + } + } + + private HardwareBlower _hardwareBlower; + /// <summary> + /// Gets or sets the hardware Blower. + /// </summary> + [XmlIgnore] + public HardwareBlower HardwareBlower + { + get { return _hardwareBlower; } + set { _hardwareBlower = value; RaisePropertyChangedAuto(); } + } + + /// <summary> + /// Initializes a new instance of the <see cref="BlowerItem"/> class. + /// </summary> + public BlowerItem() : base() + { + Name = "Blower"; + Description = "Blower Controller"; + Image = ResourceHelper.GetImageFromResources("Images/blower.png"); + Color = Colors.White; + HardwareBlower = new HardwareBlower(); + } + + /// <summary> + /// Initializes a new instance of the <see cref="BlowerItem"/> class. + /// </summary> + /// <param name="BlowerType">Type of the Blower.</param> + public BlowerItem(HardwareBlowerType BlowerType) : this() + { + HardwareBlowerType = BlowerType; + } + + /// <summary> + /// Clones this instance. + /// </summary> + /// <returns></returns> + public override TechItem Clone() + { + BlowerItem cloned = base.Clone() as BlowerItem; + cloned.HardwareBlowerType = HardwareBlowerType; + return cloned; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/BreakSensorItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/BreakSensorItem.cs new file mode 100644 index 000000000..cf1ed682e --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/BreakSensorItem.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; +using System.Xml.Serialization; +using Tango.BL.Entities; +using Tango.SharedUI.Helpers; + +namespace Tango.MachineStudio.Technician.TechItems +{ + /// <summary> + /// Represents a BreakSensor controller item. + /// </summary> + /// <seealso cref="Tango.MachineStudio.Technician.TechItems.TechItem" /> + [TechItem(17)] + public class BreakSensorItem : TechItem + { + private static List<HardwareBreakSensor> _BreakSensorConfigurations; + /// <summary> + /// Gets or sets the BreakSensor configurations. + /// </summary> + public static List<HardwareBreakSensor> BreakSensorConfigurations + { + get { return _BreakSensorConfigurations; } + set { _BreakSensorConfigurations = value; } + } + + static BreakSensorItem() + { + BreakSensorConfigurations = new List<HardwareBreakSensor>(); + + foreach (var BreakSensorType in BL.ObservablesEntitiesAdapter.Instance.HardwareBreakSensorTypes) + { + BreakSensorConfigurations.Add(new HardwareBreakSensor() { HardwareBreakSensorType = BreakSensorType }); + } + } + + private HardwareBreakSensorType _hardwareBreakSensorType; + /// <summary> + /// Gets or sets the type of the hardware BreakSensor. + /// </summary> + [XmlIgnore] + public HardwareBreakSensorType HardwareBreakSensorType + { + get { return _hardwareBreakSensorType; } + set + { + _hardwareBreakSensorType = value; RaisePropertyChangedAuto(); TechName = _hardwareBreakSensorType != null ? _hardwareBreakSensorType.Description : null; ItemGuid = value != null ? value.Guid : null; + + if (_hardwareBreakSensorType != null) + { + HardwareBreakSensor = BreakSensorConfigurations.SingleOrDefault(x => x.HardwareBreakSensorType == _hardwareBreakSensorType); + } + } + } + + private HardwareBreakSensor _hardwareBreakSensor; + /// <summary> + /// Gets or sets the hardware BreakSensor. + /// </summary> + [XmlIgnore] + public HardwareBreakSensor HardwareBreakSensor + { + get { return _hardwareBreakSensor; } + set { _hardwareBreakSensor = value; RaisePropertyChangedAuto(); } + } + + /// <summary> + /// Initializes a new instance of the <see cref="BreakSensorItem"/> class. + /// </summary> + public BreakSensorItem() : base() + { + Name = "Break Sensor"; + Description = "Break Sensor Controller"; + Image = ResourceHelper.GetImageFromResources("Images/break.png"); + Color = Colors.White; + HardwareBreakSensor = new HardwareBreakSensor(); + } + + /// <summary> + /// Initializes a new instance of the <see cref="BreakSensorItem"/> class. + /// </summary> + /// <param name="BreakSensorType">Type of the BreakSensor.</param> + public BreakSensorItem(HardwareBreakSensorType BreakSensorType) : this() + { + HardwareBreakSensorType = BreakSensorType; + } + + /// <summary> + /// Clones this instance. + /// </summary> + /// <returns></returns> + public override TechItem Clone() + { + BreakSensorItem cloned = base.Clone() as BreakSensorItem; + cloned.HardwareBreakSensorType = HardwareBreakSensorType; + return cloned; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/TechItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/TechItem.cs index a1aba597b..11188c69d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/TechItem.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/TechItem.cs @@ -34,6 +34,8 @@ namespace Tango.MachineStudio.Technician.TechItems [XmlInclude(typeof(WinderItem))] [XmlInclude(typeof(DancerItem))] [XmlInclude(typeof(SpeedSensorItem))] + [XmlInclude(typeof(BlowerItem))] + [XmlInclude(typeof(BreakSensorItem))] [XmlInclude(typeof(ProcessParametersItem))] [XmlInclude(typeof(JobRunnerItem))] public abstract class TechItem : ExtendedObject diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs index cd7582fe9..f79ebb29b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs @@ -617,6 +617,14 @@ namespace Tango.MachineStudio.Technician.ViewModels { CreateElement<SpeedSensorElementEditor, SpeedSensorItem, HardwareSpeedSensorType>(bounds, Adapter.HardwareSpeedSensorTypes.FirstOrDefault()); } + else if (item is BlowerItem) + { + CreateElement<BlowerElementEditor, BlowerItem, HardwareBlowerType>(bounds, Adapter.HardwareBlowerTypes.FirstOrDefault()); + } + else if (item is BreakSensorItem) + { + CreateElement<BreakSensorElementEditor, BreakSensorItem, HardwareBreakSensorType>(bounds, Adapter.HardwareBreakSensorTypes.FirstOrDefault()); + } else if (item is ProcessParametersItem) { var editor = CreateElement<ProcessParametersElementEditor, ProcessParametersItem, object>(bounds, null); @@ -746,6 +754,16 @@ namespace Tango.MachineStudio.Technician.ViewModels (item as SpeedSensorItem).HardwareSpeedSensorType = Adapter.HardwareSpeedSensorTypes.FirstOrDefault(x => x.Guid == item.ItemGuid); CreateElement<SpeedSensorElementEditor>(item); } + else if (item is BlowerItem) + { + (item as BlowerItem).HardwareBlowerType = Adapter.HardwareBlowerTypes.FirstOrDefault(x => x.Guid == item.ItemGuid); + CreateElement<BlowerElementEditor>(item); + } + else if (item is BreakSensorItem) + { + (item as BreakSensorItem).HardwareBreakSensorType = Adapter.HardwareBreakSensorTypes.FirstOrDefault(x => x.Guid == item.ItemGuid); + CreateElement<BreakSensorElementEditor>(item); + } else if (item is ProcessParametersItem) { var editor = CreateElement<ProcessParametersElementEditor>(item); @@ -1610,6 +1628,26 @@ namespace Tango.MachineStudio.Technician.ViewModels } } + foreach (var blowerConfig in config.Blowers) + { + var itemConfig = BlowerItem.BlowerConfigurations.SingleOrDefault(x => x.HardwareBlowerType.Code == blowerConfig.HardwareBlowerType.ToInt32()); + + if (itemConfig != null) + { + blowerConfig.MapPrimitivesTo(itemConfig); + } + } + + foreach (var breakSensorConfig in config.BreakSensors) + { + var itemConfig = BreakSensorItem.BreakSensorConfigurations.SingleOrDefault(x => x.HardwareBreakSensorType.Code == breakSensorConfig.HardwareBreakSensorType.ToInt32()); + + if (itemConfig != null) + { + breakSensorConfig.MapPrimitivesTo(itemConfig); + } + } + _notification.ShowInfo("Visual elements synced to the last uploaded hardware configuration."); } else @@ -1674,6 +1712,26 @@ namespace Tango.MachineStudio.Technician.ViewModels } } + foreach (var blowerConfig in hw.HardwareBlowers) + { + var itemConfig = BlowerItem.BlowerConfigurations.SingleOrDefault(x => x.HardwareBlowerType.Code == blowerConfig.HardwareBlowerType.Code); + + if (itemConfig != null) + { + itemConfig.MapPrimitivesTo(blowerConfig); + } + } + + foreach (var breakSensorConfig in hw.HardwareBreakSensors) + { + var itemConfig = BreakSensorItem.BreakSensorConfigurations.SingleOrDefault(x => x.HardwareBreakSensorType.Code == breakSensorConfig.HardwareBreakSensorType.Code); + + if (itemConfig != null) + { + itemConfig.MapPrimitivesTo(breakSensorConfig); + } + } + using (_notification.PushTaskItem("Uploading hardware configuration...")) { try @@ -1745,6 +1803,26 @@ namespace Tango.MachineStudio.Technician.ViewModels } } + foreach (var blowerSensorConfig in hw.HardwareBlowers) + { + var itemConfig = BlowerItem.BlowerConfigurations.SingleOrDefault(x => x.HardwareBlowerType.Code == blowerSensorConfig.HardwareBlowerType.Code); + + if (itemConfig != null) + { + blowerSensorConfig.MapPrimitivesTo(itemConfig); + } + } + + foreach (var breakSensorConfig in hw.HardwareBreakSensors) + { + var itemConfig = BreakSensorItem.BreakSensorConfigurations.SingleOrDefault(x => x.HardwareBreakSensorType.Code == breakSensorConfig.HardwareBreakSensorType.Code); + + if (itemConfig != null) + { + breakSensorConfig.MapPrimitivesTo(itemConfig); + } + } + if (showMessage) { _notification.ShowInfo("Visual elements synced to hardware version " + hw.Name + ", " + hw.Version + "."); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml index c11dbc525..cc6ade388 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml @@ -202,7 +202,7 @@ </ListBox.ItemsPanel> <ListBox.ItemTemplate> <DataTemplate DataType="{x:Type techItems:TechItem}"> - <Border Cursor="Hand" ToolTip="{Binding Description}" RenderTransformOrigin="0.5,0.5" Width="70" Padding="10" Margin="5" Height="70" BorderThickness="1" CornerRadius="100"> + <Border Cursor="Hand" ToolTip="{Binding Description}" RenderTransformOrigin="0.5,0.5" Width="60" Height="60" Padding="10" Margin="5" BorderThickness="1" CornerRadius="100"> <Border.Style> <Style TargetType="Border"> <Setter Property="RenderTransform"> @@ -400,6 +400,12 @@ <DataTemplate DataType="{x:Type items:ProcessParametersItem}"> <templates:ProcessParametersTemplate/> </DataTemplate> + <DataTemplate DataType="{x:Type items:BreakSensorItem}"> + <templates:BreakSensorTemplate/> + </DataTemplate> + <DataTemplate DataType="{x:Type items:BlowerItem}"> + <templates:BlowerTemplate/> + </DataTemplate> <DataTemplate DataType="{x:Type items:SpeedSensorItem}"> <templates:SpeedSensorTemplate/> </DataTemplate> |
