diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-02-27 14:25:58 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-02-27 14:25:58 +0200 |
| commit | 7d61c30b400b62069d1e69893ebe196412b2df2b (patch) | |
| tree | e0a0655f153972f7db3efb5821d04926f020d489 /Software/Visual_Studio/MachineStudio/Modules | |
| parent | 0157053d3ab06d5fbf2777150bb12a9a35bd7368 (diff) | |
| download | Tango-7d61c30b400b62069d1e69893ebe196412b2df2b.tar.gz Tango-7d61c30b400b62069d1e69893ebe196412b2df2b.zip | |
Added PID Control.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules')
12 files changed, 440 insertions, 27 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj index 189c7ee0d..fa567697d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj @@ -134,6 +134,7 @@ <Compile Include="ViewModels\MultiComboVM.cs" /> <Compile Include="ViewModels\OrganizationsViewVM.cs" /> <Compile Include="ViewModels\PermissionsViewVM.cs" /> + <Compile Include="ViewModels\PidControlsViewVM.cs" /> <Compile Include="ViewModels\ProcessParametersTablesViewVM.cs" /> <Compile Include="ViewModels\ProcessParametersTablesGroupsViewVM.cs" /> <Compile Include="ViewModels\RmlsViewVM.cs" /> @@ -148,9 +149,15 @@ <Compile Include="Views\DBViews\ActionTypeView.xaml.cs"> <DependentUpon>ActionTypeView.xaml</DependentUpon> </Compile> + <Compile Include="Views\DBViews\PidControlsView.xaml.cs"> + <DependentUpon>PidControlsView.xaml</DependentUpon> + </Compile> <Compile Include="Views\DBViews\DancerTypesView.xaml.cs"> <DependentUpon>DancerTypesView.xaml</DependentUpon> </Compile> + <Compile Include="Views\DBViews\PidControlView.xaml.cs"> + <DependentUpon>PidControlView.xaml</DependentUpon> + </Compile> <Compile Include="Views\DBViews\DancerTypeView.xaml.cs"> <DependentUpon>DancerTypeView.xaml</DependentUpon> </Compile> @@ -402,10 +409,18 @@ <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </Page> + <Page Include="Views\DBViews\PidControlsView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> <Page Include="Views\DBViews\DancerTypesView.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </Page> + <Page Include="Views\DBViews\PidControlView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> <Page Include="Views\DBViews\DancerTypeView.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs index 13fd85122..0889be54e 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs @@ -67,6 +67,8 @@ namespace Tango.MachineStudio.DB SimpleIoc.Default.Register<DancerTypesViewVM>(); SimpleIoc.Default.Register<HardwareVersionsDancerTypeViewVM>(); SimpleIoc.Default.Register<HardwareVersionsMotorTypesViewVM>(); + + SimpleIoc.Default.Register<PidControlsViewVM>(); } public static MainViewVM MainViewVM @@ -404,5 +406,13 @@ namespace Tango.MachineStudio.DB return ServiceLocator.Current.GetInstance<HardwareVersionsMotorTypesViewVM>(); } } + + public static PidControlsViewVM PidControlsViewVM + { + get + { + return ServiceLocator.Current.GetInstance<PidControlsViewVM>(); + } + } } }
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/PidControlsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/PidControlsViewVM.cs new file mode 100644 index 000000000..7fe342da5 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/PidControlsViewVM.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Integration.Observables; +using Tango.MachineStudio.Common.Notifications; +using Tango.SharedUI; + +namespace Tango.MachineStudio.DB.ViewModels +{ + public class PidControlsViewVM : DbTableViewModel<PidControl> + { + public PidControlsViewVM(INotificationProvider notification) : base(notification) + { + + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PidControlView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PidControlView.xaml new file mode 100644 index 000000000..5459fbbff --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PidControlView.xaml @@ -0,0 +1,73 @@ +<UserControl x:Class="Tango.MachineStudio.DB.Views.DBViews.PidControlView" + 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:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:controls="clr-namespace:Tango.MachineStudio.DB.Controls" + xmlns:colorPicker="clr-namespace:Tango;assembly=Tango.ColorPicker" + xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" + xmlns:vm="clr-namespace:Tango.MachineStudio.DB.ViewModels" + xmlns:local="clr-namespace:Tango.MachineStudio.DB.Views.DBViews" + mc:Ignorable="d" + d:DesignHeight="400" d:DesignWidth="300" d:DataContext="{d:DesignInstance Type=vm:PidControlsViewVM, IsDesignTimeCreatable=False}"> + + <Grid> + <controls:TableGrid> + <TextBlock Text="ID:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.ID}" IsReadOnly="True"></TextBox> + <TextBlock Text="GUID:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.Guid}" IsReadOnly="True"></TextBox> + <TextBlock Text="Last Updated:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.LastUpdated}" IsReadOnly="True"></TextBox> + <TextBlock Text="Code:" FontWeight="Bold"></TextBlock> + <mahapps:NumericUpDown Minimum="0" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Left" Value="{Binding EditEntity.Code,Mode=TwoWay}"></mahapps:NumericUpDown> + <TextBlock Text="Name:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.Name,Mode=TwoWay}"></TextBox> + <TextBlock Text="Description:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.Description,Mode=TwoWay}"></TextBox> + + <TextBlock Text="Output Proportional Power Limit:" FontWeight="Bold"></TextBlock> + <mahapps:NumericUpDown Minimum="0" Maximum="10000" Value="{Binding EditEntity.OutputProportionalPowerLimit,Mode=TwoWay}" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Left"></mahapps:NumericUpDown> + + <TextBlock Text="Output Proportional Band:" FontWeight="Bold"></TextBlock> + <mahapps:NumericUpDown Minimum="0" Maximum="10000" Value="{Binding EditEntity.OutputProportionalBand,Mode=TwoWay}" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Left"></mahapps:NumericUpDown> + + <TextBlock Text="Integral Time:" FontWeight="Bold"></TextBlock> + <mahapps:NumericUpDown Minimum="0" Maximum="10000" Value="{Binding EditEntity.IntegralTime,Mode=TwoWay}" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Left"></mahapps:NumericUpDown> + + <TextBlock Text="Derivative Time:" FontWeight="Bold"></TextBlock> + <mahapps:NumericUpDown Minimum="0" Maximum="10000" Value="{Binding EditEntity.DerivativeTime,Mode=TwoWay}" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Left"></mahapps:NumericUpDown> + + <TextBlock Text="Sensor Correction Adjustment:" FontWeight="Bold"></TextBlock> + <mahapps:NumericUpDown Minimum="0" Maximum="10000" Value="{Binding EditEntity.SensorCorrectionAdjustment,Mode=TwoWay}" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Left"></mahapps:NumericUpDown> + + <TextBlock Text="Sensor Min Value:" FontWeight="Bold"></TextBlock> + <mahapps:NumericUpDown Minimum="0" Maximum="10000" Value="{Binding EditEntity.SensorMinValue,Mode=TwoWay}" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Left"></mahapps:NumericUpDown> + + <TextBlock Text="Sensor Max Value:" FontWeight="Bold"></TextBlock> + <mahapps:NumericUpDown Minimum="0" Maximum="10000" Value="{Binding EditEntity.SensorMaxValue,Mode=TwoWay}" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Left"></mahapps:NumericUpDown> + + <TextBlock Text="SetPoint Ramp Rateor Soft Start Ramp:" FontWeight="Bold"></TextBlock> + <mahapps:NumericUpDown Minimum="0" Maximum="10000" Value="{Binding EditEntity.SetPointRampRateorSoftStartRamp,Mode=TwoWay}" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Left"></mahapps:NumericUpDown> + + <TextBlock Text="Set Point Control Output Rate:" FontWeight="Bold"></TextBlock> + <mahapps:NumericUpDown Minimum="0" Maximum="10000" Value="{Binding EditEntity.SetPointControlOutputRate,Mode=TwoWay}" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Left"></mahapps:NumericUpDown> + + <TextBlock Text="Control Output Type:" FontWeight="Bold"></TextBlock> + <mahapps:NumericUpDown Minimum="0" Maximum="10000" Value="{Binding EditEntity.ControlOutputType,Mode=TwoWay}" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Left"></mahapps:NumericUpDown> + + <TextBlock Text="SSR Control Output Type:" FontWeight="Bold"></TextBlock> + <mahapps:NumericUpDown Minimum="0" Maximum="10000" Value="{Binding EditEntity.SsrControlOutputType,Mode=TwoWay}" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Left"></mahapps:NumericUpDown> + + <TextBlock Text="Output On/Off Hysteresis Value:" FontWeight="Bold"></TextBlock> + <mahapps:NumericUpDown Minimum="0" Maximum="10000" Value="{Binding EditEntity.OutputOnOffHysteresisValue,Mode=TwoWay}" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Left"></mahapps:NumericUpDown> + + <TextBlock Text="Process Variable Sampling Rate:" FontWeight="Bold"></TextBlock> + <mahapps:NumericUpDown Minimum="0" Maximum="10000" Value="{Binding EditEntity.ProcessVariableSamplingRate,Mode=TwoWay}" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Left"></mahapps:NumericUpDown> + + <TextBlock Text="PV Input Filter Factor Mode:" FontWeight="Bold"></TextBlock> + <mahapps:NumericUpDown Minimum="0" Maximum="10000" Value="{Binding EditEntity.PvInputFilterFactorMode,Mode=TwoWay}" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Left"></mahapps:NumericUpDown> + </controls:TableGrid> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PidControlView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PidControlView.xaml.cs new file mode 100644 index 000000000..df45fb1ff --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PidControlView.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.DB.Views.DBViews +{ + /// <summary> + /// Interaction logic for MachineView.xaml + /// </summary> + public partial class PidControlView : UserControl + { + public PidControlView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PidControlsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PidControlsView.xaml new file mode 100644 index 000000000..0a7d6d4df --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PidControlsView.xaml @@ -0,0 +1,48 @@ +<UserControl x:Class="Tango.MachineStudio.DB.Views.DBViews.PidControlsView" + 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:global="clr-namespace:Tango.MachineStudio.DB" + xmlns:controls="clr-namespace:Tango.MachineStudio.DB.Controls" + xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" + xmlns:observables="clr-namespace:Tango.Integration.Observables;assembly=Tango.Integration" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + mc:Ignorable="d" + d:DesignHeight="720" d:DesignWidth="1280" Background="White" d:DataContext="{d:DesignInstance Type=observables:PidControl, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.PidControlsViewVM}"> + + <UserControl.Resources> + <converters:BooleanToYesNoConverter x:Key="BooleanToYesNoConverter" /> + </UserControl.Resources> + + <Grid> + <controls:DbTableView> + <DataGrid Background="Transparent" ItemsSource="{Binding Adapter.PidControlsViewSource}" SelectedItem="{Binding SelectedEntity}" AutoGenerateColumns="False" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" IsReadOnly="True"> + <DataGrid.Columns> + <DataGridTextColumn Header="ID" Binding="{Binding ID}"></DataGridTextColumn> + <DataGridTextColumn Header="GUID" Binding="{Binding Guid}"></DataGridTextColumn> + <DataGridTextColumn Header="Code" Binding="{Binding Code}"></DataGridTextColumn> + <DataGridTextColumn Header="Name" Binding="{Binding Name}"></DataGridTextColumn> + + <DataGridTextColumn Header="Description" Binding="{Binding Description}"></DataGridTextColumn> + <DataGridTextColumn Header="Output Proportional Power Limit" Binding="{Binding OutputProportionalPowerLimit}"></DataGridTextColumn> + <DataGridTextColumn Header="Output Proportional Band" Binding="{Binding OutputProportionalBand}"></DataGridTextColumn> + + <DataGridTextColumn Header="Integral Time" Binding="{Binding IntegralTime}"></DataGridTextColumn> + <DataGridTextColumn Header="Derivative Time" Binding="{Binding DerivativeTime}"></DataGridTextColumn> + <DataGridTextColumn Header="Sensor Correction Adjustment" Binding="{Binding SensorCorrectionAdjustment}"></DataGridTextColumn> + <DataGridTextColumn Header="Sensor Min Value" Binding="{Binding SensorMinValue}"></DataGridTextColumn> + <DataGridTextColumn Header="Sensor Max Value" Binding="{Binding SensorMaxValue}"></DataGridTextColumn> + <DataGridTextColumn Header="SetPoint Ramp Rateor Soft Start Ramp" Binding="{Binding SetPointRampRateorSoftStartRamp}"></DataGridTextColumn> + <DataGridTextColumn Header="Set Point Control Output Rate" Binding="{Binding SetPointControlOutputRate}"></DataGridTextColumn> + <DataGridTextColumn Header="Control Output Type" Binding="{Binding ControlOutputType}"></DataGridTextColumn> + + <DataGridTextColumn Header="SSR Control Output Type" Binding="{Binding SsrControlOutputType}"></DataGridTextColumn> + <DataGridTextColumn Header="Output On/Off Hysteresis Value" Binding="{Binding OutputOnOffHysteresisValue}"></DataGridTextColumn> + <DataGridTextColumn Header="Process Variable Sampling Rate" Binding="{Binding ProcessVariableSamplingRate}"></DataGridTextColumn> + <DataGridTextColumn Header="PV Input Filter Factor Mode" Binding="{Binding PvInputFilterFactorMode}"></DataGridTextColumn> + </DataGrid.Columns> + </DataGrid> + </controls:DbTableView> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PidControlsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PidControlsView.xaml.cs new file mode 100644 index 000000000..9ac44d396 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PidControlsView.xaml.cs @@ -0,0 +1,32 @@ +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; +using Tango.MachineStudio.DB.CustomAttributes; +using Tango.MachineStudio.DB.Managers; +using Tango.SharedUI.Controls; + +namespace Tango.MachineStudio.DB.Views.DBViews +{ + /// <summary> + /// Interaction logic for MachinesView.xaml + /// </summary> + [DBView] + public partial class PidControlsView : UserControl + { + public PidControlsView() : base() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/balance.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/balance.png Binary files differnew file mode 100644 index 000000000..46255b3ed --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/balance.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 15186d65b..12c32df08 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 @@ -155,5 +155,8 @@ <ItemGroup> <Resource Include="Images\compass.png" /> </ItemGroup> + <ItemGroup> + <Resource Include="Images\balance.png" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> </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 4becc0b04..0da894aba 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 @@ -4,6 +4,7 @@ using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.Core.Commands; using Tango.Integration.Observables; using Tango.SharedUI; @@ -46,10 +47,20 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels set { _currentVersionDancerTypes = value; RaisePropertyChangedAuto(); } } + private ObservableCollection<PidControl> _currentVersionPidControls; + public ObservableCollection<PidControl> CurrentVersionPidControls + { + get { return _currentVersionPidControls; } + set { _currentVersionPidControls = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand SaveCommand { get; set; } public MainViewVM() { Adapter = ObservablesEntitiesAdapter.Instance; + + SaveCommand = new RelayCommand(Save); } private void OnSelectedVersionChanged() @@ -57,6 +68,7 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels CurrentVersion = SelectedVersion.Clone(); CurrentVersionDancerTypes = CurrentVersion.HardwareVersionsDancerTypes.Select(x => x.DancerType).ToObservableCollection(); CurrentVersionMotorTypes = CurrentVersion.HardwareVersionsMotorTypes.Select(x => x.MotorType).ToObservableCollection(); + CurrentVersionPidControls = CurrentVersion.HardwareVersionsPidControls.Select(x => x.PidControl).ToObservableCollection(); } public void OnRemoveDancer(DancerType dancerType) @@ -69,14 +81,41 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels CurrentVersionMotorTypes.Remove(motorType); } + public void OnRemovePidControl(PidControl pidControl) + { + CurrentVersionPidControls.Remove(pidControl); + } + public void OnMotorDrop(MotorType motorType) { - CurrentVersionMotorTypes.Add(motorType); + if (!CurrentVersionMotorTypes.Contains(motorType)) + { + CurrentVersionMotorTypes.Add(motorType); + } } public void OnDropDancer(DancerType dancerType) { - CurrentVersionDancerTypes.Add(dancerType); + if (!CurrentVersionDancerTypes.Contains(dancerType)) + { + CurrentVersionDancerTypes.Add(dancerType); + } + } + + public void OnDropPidControl(PidControl pidControl) + { + if (!CurrentVersionPidControls.Contains(pidControl)) + { + CurrentVersionPidControls.Add(pidControl); + } + } + + private void Save() + { + if (CurrentVersion != null) + { + + } } } } 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 77ace3e63..e73ba2a1f 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 @@ -60,10 +60,10 @@ </Image> <Canvas ClipToBounds="False" x:Name="canvas"> - <Border BorderThickness="2" BorderBrush="Gray" CornerRadius="0 0 20 20" Width="707" Height="132" Canvas.Left="50" Canvas.Top="378" Background="#ABFFFFFF"> + <Border BorderThickness="1" BorderBrush="Gray" CornerRadius="0 0 20 20" Width="707" Height="132" Canvas.Left="50" Canvas.Top="378" Background="#ABFFFFFF"> <Grid Style="{StaticResource droppableGrid}" dragAndDrop:DragAndDropService.Drop="OnDancerDrop"> <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Silver" FontSize="20">DRAG & DROP DANCERS</TextBlock> - <ListBox x:Name="listDancers" ItemsSource="{Binding CurrentVersionDancerTypes}" Margin="0 5 0 0" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled"> + <ListBox x:Name="listDancers" ItemContainerStyle="{StaticResource basicListBoxItem}" ItemsSource="{Binding CurrentVersionDancerTypes}" Margin="0 5 0 0" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled"> <ListBox.ItemsPanel> <ItemsPanelTemplate> <WrapPanel Orientation="Horizontal" /> @@ -72,22 +72,23 @@ <ListBox.ItemTemplate> <DataTemplate DataType="{x:Type observables:DancerType}"> <Grid Style="{StaticResource draggableGrid}"> - <Grid.ToolTip> - <Border Padding="2"> - <ItemsControl ItemsSource="{Binding Parameters}"> - <ItemsControl.ItemTemplate> - <DataTemplate> - <TextBlock Margin="2"> - <Run Text="{Binding Name}" FontWeight="SemiBold"></Run> - : - <Run Text="{Binding Value}" FontStyle="Italic"></Run> - </TextBlock> - </DataTemplate> - </ItemsControl.ItemTemplate> - </ItemsControl> - </Border> - </Grid.ToolTip> - <Border BorderBrush="Gray" Width="100" Height="100" BorderThickness="1" Background="White" Padding="2" IsHitTestVisible="False"> + <Border Margin="5" CornerRadius="5" Width="100" Height="100" BorderThickness="1" Padding="2" IsHitTestVisible="False"> + <Border.Style> + <Style TargetType="Border"> + <Setter Property="BorderBrush" Value="Silver"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=ListBoxItem},Path=IsSelected}" Value="True"> + <Setter Property="BorderBrush" Value="{StaticResource AccentColorBrush}"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </Border.Style> + <Border.Background> + <LinearGradientBrush> + <GradientStop Color="White"/> + <GradientStop Color="#FFD6D6D6" Offset="1"/> + </LinearGradientBrush> + </Border.Background> <Grid> <StackPanel> <Image Source="../Images/compass.png" Width="32" Margin="5" /> @@ -102,10 +103,10 @@ </Grid> </Border> - <Border BorderThickness="2 2 2 0" BorderBrush="Gray" Width="576" Height="157" Canvas.Left="114" Canvas.Top="224" Background="#ABFFFFFF"> + <Border BorderThickness="1 1 1 0" BorderBrush="Gray" Width="576" Height="157" Canvas.Left="114" Canvas.Top="224" Background="#ABFFFFFF"> <Grid Style="{StaticResource droppableGrid}" dragAndDrop:DragAndDropService.Drop="OnMotorsDrop"> <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Silver" FontSize="20">DRAG & DROP MOTORS</TextBlock> - <ListBox x:Name="listMotors" ItemsSource="{Binding CurrentVersionMotorTypes}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled"> + <ListBox x:Name="listMotors" ItemContainerStyle="{StaticResource basicListBoxItem}" ItemsSource="{Binding CurrentVersionMotorTypes}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled"> <ListBox.ItemsPanel> <ItemsPanelTemplate> <WrapPanel Orientation="Horizontal" /> @@ -129,7 +130,23 @@ </ItemsControl> </Border> </Grid.ToolTip> - <Border BorderBrush="Gray" Height="25" IsHitTestVisible="False" MaxWidth="100" BorderThickness="1" Background="White" Padding="2"> + <Border Margin="4" CornerRadius="3" Height="25" IsHitTestVisible="False" MaxWidth="100" BorderThickness="1" Padding="5 2 9 2"> + <Border.Style> + <Style TargetType="Border"> + <Setter Property="BorderBrush" Value="Silver"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=ListBoxItem},Path=IsSelected}" Value="True"> + <Setter Property="BorderBrush" Value="{StaticResource AccentColorBrush}"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </Border.Style> + <Border.Background> + <LinearGradientBrush> + <GradientStop Color="White"/> + <GradientStop Color="#FFD6D6D6" Offset="1"/> + </LinearGradientBrush> + </Border.Background> <Grid> <StackPanel Orientation="Horizontal"> <Image Source="../Images/engine.png" Width="16" /> @@ -143,6 +160,49 @@ </ListBox> </Grid> </Border> + + <Border BorderThickness="1 1 1 0" BorderBrush="Gray" Width="545" Height="120" Canvas.Left="130" Canvas.Top="105" Background="#ABFFFFFF" CornerRadius="20 20 0 0" Padding="5"> + <Grid Style="{StaticResource droppableGrid}" dragAndDrop:DragAndDropService.Drop="OnPidControlDrop"> + <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Silver" FontSize="20">DRAG & DROP PID CONTROLS</TextBlock> + <ListBox x:Name="listPid" ItemContainerStyle="{StaticResource basicListBoxItem}" ItemsSource="{Binding CurrentVersionPidControls}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled"> + <ListBox.ItemsPanel> + <ItemsPanelTemplate> + <WrapPanel Orientation="Horizontal" /> + </ItemsPanelTemplate> + </ListBox.ItemsPanel> + <ListBox.ItemTemplate> + <DataTemplate DataType="{x:Type observables:PidControl}"> + <Grid Style="{StaticResource draggableGrid}"> + <Border Margin="4" CornerRadius="3" Height="25" IsHitTestVisible="False" MaxWidth="100" BorderThickness="1" Padding="5 2 9 2"> + <Border.Style> + <Style TargetType="Border"> + <Setter Property="BorderBrush" Value="Silver"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=ListBoxItem},Path=IsSelected}" Value="True"> + <Setter Property="BorderBrush" Value="{StaticResource AccentColorBrush}"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </Border.Style> + <Border.Background> + <LinearGradientBrush> + <GradientStop Color="White"/> + <GradientStop Color="#FFD6D6D6" Offset="1"/> + </LinearGradientBrush> + </Border.Background> + <Grid> + <StackPanel Orientation="Horizontal"> + <Image Source="../Images/balance.png" Width="16" /> + <TextBlock FontSize="8" Margin="5 0 0 0" TextTrimming="CharacterEllipsis" Text="{Binding Name}" VerticalAlignment="Center"></TextBlock> + </StackPanel> + </Grid> + </Border> + </Grid> + </DataTemplate> + </ListBox.ItemTemplate> + </ListBox> + </Grid> + </Border> </Canvas> </Grid> </Viewbox> @@ -209,7 +269,11 @@ </ListBox.ItemTemplate> </ListBox> </Expander> - <Border Height="1" HorizontalAlignment="Stretch" Background="{DynamicResource MaterialDesignDivider}" SnapsToDevicePixels="True" /> + </StackPanel> + </materialDesign:Card> + + <materialDesign:Card Margin="5,10,5,0" Background="{DynamicResource MaterialDesignBackground}"> + <StackPanel> <Expander HorizontalAlignment="Stretch" Header="Dancers"> <ListBox ItemsSource="{Binding Adapter.DancerTypes}" HorizontalContentAlignment="Stretch"> <ListBox.ItemContainerStyle> @@ -240,8 +304,38 @@ <materialDesign:Card Margin="5,10,5,0" Background="{DynamicResource MaterialDesignBackground}"> <StackPanel> + <Expander HorizontalAlignment="Stretch" Header="PID Controls"> + <ListBox ItemsSource="{Binding Adapter.PidControls}" HorizontalContentAlignment="Stretch"> + <ListBox.ItemContainerStyle> + <Style TargetType="ListBoxItem" BasedOn="{StaticResource {x:Type ListBoxItem}}"> + <Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter> + <Setter Property="VerticalContentAlignment" Value="Stretch"></Setter> + <Setter Property="Padding" Value="1"></Setter> + </Style> + </ListBox.ItemContainerStyle> + <ListBox.ItemTemplate> + <DataTemplate> + <Grid Background="Transparent" IsHitTestVisible="True" dragAndDrop:DragAndDropService.DraggableBorderBrush="{StaticResource AccentColorBrush}" dragAndDrop:DragAndDropService.Draggable="True" dragAndDrop:DragAndDropService.DraggingSurface="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DraggingSurface}"> + <StackPanel Orientation="Horizontal" Margin="2 8"> + <Image IsHitTestVisible="False" Width="24" Height="24" Source="../Images/balance.png" Stretch="Fill" RenderOptions.BitmapScalingMode="Fant"></Image> + <StackPanel Margin="5 0 0 0" IsHitTestVisible="False" VerticalAlignment="Center"> + <TextBlock IsHitTestVisible="False" FontSize="10" Foreground="DimGray"><Run Text="{Binding Name}"></Run></TextBlock> + </StackPanel> + </StackPanel> + + <Rectangle Margin="0 10 0 0" VerticalAlignment="Bottom" Stroke="Gainsboro" StrokeThickness="1"></Rectangle> + </Grid> + </DataTemplate> + </ListBox.ItemTemplate> + </ListBox> + </Expander> + </StackPanel> + </materialDesign:Card> + + <materialDesign:Card Margin="5,10,5,0" Background="{DynamicResource MaterialDesignBackground}"> + <StackPanel> <Grid> - <Expander HorizontalAlignment="Stretch" Header="Selected Motor Properties"> + <Expander HorizontalAlignment="Stretch" Header="Motor Properties"> <editors:ParameterizedEditor ParameterizedObject="{Binding ElementName=listMotors,Path=SelectedItem}" Padding="10"> <editors:ParameterizedEditor.ItemsPanel> <ItemsPanelTemplate> @@ -281,7 +375,7 @@ <materialDesign:Card Margin="5,10,5,0" Background="{DynamicResource MaterialDesignBackground}"> <StackPanel> <Grid> - <Expander HorizontalAlignment="Stretch" Header="Selected Dancer Properties"> + <Expander HorizontalAlignment="Stretch" Header="Dancer Properties"> <editors:ParameterizedEditor ParameterizedObject="{Binding ElementName=listDancers,Path=SelectedItem}" Padding="10"> <editors:ParameterizedEditor.ItemsPanel> <ItemsPanelTemplate> @@ -317,11 +411,51 @@ </Grid> </StackPanel> </materialDesign:Card> + + <materialDesign:Card Margin="5,10,5,0" Background="{DynamicResource MaterialDesignBackground}"> + <StackPanel> + <Grid> + <Expander HorizontalAlignment="Stretch" Header="PID Control Properties"> + <editors:ParameterizedEditor ParameterizedObject="{Binding ElementName=listPid,Path=SelectedItem}" 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> + </Expander> + </Grid> + </StackPanel> + </materialDesign:Card> </StackPanel> </Grid> </ScrollViewer> - <Grid Grid.Row="1" Margin="10"> + <Grid Grid.Row="1" Margin="10 0 10 10"> <Button Height="Auto" Command="{Binding SaveCommand}" Margin="0 0 0 0"> <StackPanel Orientation="Horizontal"> <materialDesign:PackIcon Width="20" Height="20" VerticalAlignment="Center" Kind="ContentSaveSettings"></materialDesign:PackIcon> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml.cs index b06d3bd27..d18a8ac71 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml.cs @@ -57,6 +57,14 @@ namespace Tango.MachineStudio.HardwareDesigner.Views } } + private void OnPidControlDrop(object sender, DropEventArgs e) + { + if (e.Draggable.DataContext is PidControl) + { + _vm.OnDropPidControl(e.Draggable.DataContext as PidControl); + } + } + private void OnTrashDrop(object sender, DropEventArgs e) { if (e.Draggable.DataContext is MotorType) @@ -67,6 +75,10 @@ namespace Tango.MachineStudio.HardwareDesigner.Views { _vm.OnRemoveDancer(e.Draggable.DataContext as DancerType); } + else if (e.Draggable.DataContext is PidControl) + { + _vm.OnRemovePidControl(e.Draggable.DataContext as PidControl); + } } } } |
