矩阵
This commit is contained in:
parent
83d23aa95b
commit
5e804f7c3c
@ -1,4 +1,4 @@
|
||||
using DryIoc;
|
||||
using DryIoc;
|
||||
using Newtonsoft.Json;
|
||||
using PLCSharp.Core.Prism;
|
||||
using PLCSharp.Models;
|
||||
@ -40,6 +40,7 @@ namespace PLCSharp
|
||||
}
|
||||
//数据库
|
||||
_ = containerRegistry.RegisterSingleton<DatasContext>();
|
||||
_ = Container.Resolve<DatasContext>();
|
||||
|
||||
RegisterEvents(); // 捕获全局异常
|
||||
LoadConfig();
|
||||
|
||||
@ -77,6 +77,12 @@ namespace PLCSharp.Models
|
||||
/// 轴Points
|
||||
/// </summary>
|
||||
public DbSet<AxisPoint> AxisPoints { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轴Points
|
||||
/// </summary>
|
||||
public DbSet<Matrix> Matrices { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 插补Groups
|
||||
/// </summary>
|
||||
|
||||
@ -1147,6 +1147,7 @@ namespace PLCSharp.Models
|
||||
VisionsModel.VisionFunctions.Add(itemcopy);
|
||||
}
|
||||
//加载当前配方的点位列表
|
||||
ControllersModel.Stop();
|
||||
ControllersModel.AxisPoints.Clear();
|
||||
var currRecipeAxisPoints = _DatasContext.AxisPoints.Where(c => c.RecipeID == CurrentRecipe.ID);
|
||||
foreach (var item in currRecipeAxisPoints)
|
||||
@ -1166,6 +1167,19 @@ namespace PLCSharp.Models
|
||||
if (axisU != null)
|
||||
axisPoint.AxisU = axisU;
|
||||
}
|
||||
//加载当前西方的矩阵列表
|
||||
ControllersModel.Matrices.Clear();
|
||||
var currRecipeMatrices = _DatasContext.Matrices.Where(c => c.RecipeID == CurrentRecipe.ID);
|
||||
foreach (var item in currRecipeMatrices)
|
||||
{
|
||||
var matrix = item.DeepCopy();
|
||||
ControllersModel.Matrices.Add(matrix);
|
||||
|
||||
ControllersModel.Create(matrix);
|
||||
|
||||
|
||||
}
|
||||
|
||||
//加载当前配方的插补列表
|
||||
|
||||
ControllersModel.InterpolationGroups.Clear();
|
||||
@ -1181,6 +1195,8 @@ namespace PLCSharp.Models
|
||||
if (axisY != null)
|
||||
itemcopy.AxisY = axisY;
|
||||
}
|
||||
ControllersModel.Start();
|
||||
|
||||
//加载当前配方的任务列表
|
||||
WorkflowsModel.Workflows.Clear();
|
||||
var currRecipeWorkflows = _DatasContext.Workflows.Where(c => c.RecipeID == CurrentRecipe.ID);
|
||||
|
||||
@ -15,9 +15,9 @@
|
||||
</UserControl.Resources>
|
||||
<prism:Dialog.WindowStyle>
|
||||
<Style TargetType="Window">
|
||||
<Setter Property="Height" Value="450" />
|
||||
<Setter Property="SizeToContent" Value="Manual" />
|
||||
<Setter Property="Width" Value="600" />
|
||||
<Setter Property="Height" Value="450" />
|
||||
</Style>
|
||||
</prism:Dialog.WindowStyle>
|
||||
<Grid>
|
||||
@ -27,17 +27,17 @@
|
||||
<RowDefinition Height="50" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- 标题 -->
|
||||
<TextBlock Grid.Row="0" Margin="10"
|
||||
FontSize="16" FontWeight="Bold"
|
||||
Text="{Binding SelectedCustomControl.Name, StringFormat='配置: {0}'}" />
|
||||
<!-- 标题 -->
|
||||
<TextBlock Grid.Row="0"
|
||||
Margin="10"
|
||||
Text="{Binding SelectedCustomControl.Name, StringFormat='配置: {0}'}"
|
||||
FontSize="16" FontWeight="Bold" />
|
||||
|
||||
<!-- 布局方式 (仅 State 类型) -->
|
||||
<StackPanel Grid.Row="0" Margin="10,40,10,0"
|
||||
Visibility="{Binding IsStateType, Converter={StaticResource BoolToVis}}">
|
||||
<!-- 布局方式 (仅 State 类型) -->
|
||||
<StackPanel Grid.Row="0" Margin="10,40,10,0" Visibility="{Binding IsStateType, Converter={StaticResource BoolToVis}}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Width="60" Text="布局方式:" VerticalAlignment="Center" />
|
||||
<ComboBox SelectedIndex="{Binding SelectedCustomControl.Params.Layout}" Width="200">
|
||||
<ComboBox Width="200" SelectedIndex="{Binding SelectedCustomControl.Params.Layout}">
|
||||
<ComboBoxItem Content=" 左 -> 右 上 -> 下 " />
|
||||
<ComboBoxItem Content=" 左 -> 右 下 -> 上 " />
|
||||
<ComboBoxItem Content=" 右 -> 左 上 -> 下 " />
|
||||
@ -50,19 +50,18 @@
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
||||
<!-- RangeValue 编辑区 (仅 RangeValueTalbe 类型) -->
|
||||
<Grid Grid.Row="1" Margin="10"
|
||||
Visibility="{Binding IsRangeValueTalbeType, Converter={StaticResource BoolToVis}}">
|
||||
<!-- RangeValue 编辑区 (仅 RangeValueTalbe 类型) -->
|
||||
<Grid Grid.Row="1" Margin="10" Visibility="{Binding IsRangeValueTalbeType, Converter={StaticResource BoolToVis}}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel Grid.Row="0" Orientation="Horizontal" Margin="0,0,0,5">
|
||||
<StackPanel Grid.Row="0" Margin="0,0,0,5" Orientation="Horizontal">
|
||||
<Button Width="80" Height="28" Margin="0,0,5,0"
|
||||
Command="{Binding AddRangeValueCommand}" Content="新增行" />
|
||||
<Button Width="80" Height="28"
|
||||
Command="{Binding RemoveRangeValueCommand}" Content="删除行" />
|
||||
Command="{Binding AddRangeValueCommand}"
|
||||
Content="新增行" />
|
||||
<Button Width="80" Height="28" Command="{Binding RemoveRangeValueCommand}" Content="删除行" />
|
||||
</StackPanel>
|
||||
|
||||
<DataGrid Grid.Row="1"
|
||||
@ -80,12 +79,14 @@
|
||||
</DataGrid>
|
||||
</Grid>
|
||||
|
||||
<!-- 按钮区 -->
|
||||
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="10">
|
||||
<!-- 按钮区 -->
|
||||
<StackPanel Grid.Row="2" Margin="10" HorizontalAlignment="Right" Orientation="Horizontal">
|
||||
<Button Width="80" Height="30" Margin="5"
|
||||
Command="{Binding CloseDialogCommand}" CommandParameter="ok" Content="确定" />
|
||||
Command="{Binding CloseDialogCommand}"
|
||||
CommandParameter="ok" Content="确定" />
|
||||
<Button Width="80" Height="30" Margin="5"
|
||||
Command="{Binding CloseDialogCommand}" CommandParameter="cancel" Content="取消" />
|
||||
Command="{Binding CloseDialogCommand}"
|
||||
CommandParameter="cancel" Content="取消" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@ -20,13 +20,13 @@
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
Unloaded="DataGrid_Unloaded">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn MinWidth="50" Binding="{Binding Name, UpdateSourceTrigger=LostFocus}" Header="名称" />
|
||||
<DataGridTextColumn MinWidth="50" Binding="{Binding MinValue, Mode=OneWay}" Header="最小值" IsReadOnly="True" />
|
||||
<DataGridTextColumn MinWidth="50" Binding="{Binding MaxValue, Mode=OneWay}" Header="最大值" IsReadOnly="True" />
|
||||
<DataGridTextColumn MinWidth="50" Binding="{Binding BaseValue, Mode=OneWay}" Header="标准值" IsReadOnly="True" />
|
||||
<DataGridTextColumn MinWidth="50" Binding="{Binding ShowValue, UpdateSourceTrigger=LostFocus}" Header="检测值" />
|
||||
<DataGridTextColumn MinWidth="50" Binding="{Binding Offs, Mode=OneWay}" Header="偏差" IsReadOnly="True" />
|
||||
<DataGridTextColumn MinWidth="50" Binding="{Binding ResultStr, Mode=OneWay}" Header="结果" IsReadOnly="True">
|
||||
<DataGridTextColumn MinWidth="50" IsReadOnly="True" Binding="{Binding Name}" Header="名称" />
|
||||
<DataGridTextColumn MinWidth="50" IsReadOnly="True" Binding="{Binding MinValue}" Header="最小值" />
|
||||
<DataGridTextColumn MinWidth="50" IsReadOnly="True" Binding="{Binding MaxValue}" Header="最大值" />
|
||||
<DataGridTextColumn MinWidth="50" IsReadOnly="True" Binding="{Binding BaseValue}" Header="标准值" />
|
||||
<DataGridTextColumn MinWidth="50" IsReadOnly="True" Binding="{Binding ShowValue, UpdateSourceTrigger=LostFocus}" Header="检测值" />
|
||||
<DataGridTextColumn MinWidth="50" IsReadOnly="True" Binding="{Binding Offs}" Header="偏差" />
|
||||
<DataGridTextColumn MinWidth="50" IsReadOnly="True" Binding="{Binding ResultStr}" Header="结果">
|
||||
<DataGridTextColumn.ElementStyle>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="TextAlignment" Value="Center" />
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json;
|
||||
using PLCSharp.Core.Common;
|
||||
using Prism.Mvvm;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
@ -303,9 +303,6 @@ namespace PLCSharp.VVMs.MotionController
|
||||
/// 参数集合
|
||||
/// </summary>
|
||||
[NotMapped]
|
||||
/// <summary>
|
||||
/// 配置项
|
||||
/// </summary>
|
||||
public AxisPointParams Params
|
||||
{
|
||||
get
|
||||
@ -319,6 +316,17 @@ namespace PLCSharp.VVMs.MotionController
|
||||
SetProperty(ref _Params, value);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 在矩阵中的X索引
|
||||
/// </summary>
|
||||
[NotMapped]
|
||||
public int XIndex { get; internal set; }
|
||||
/// <summary>
|
||||
/// 在矩阵中的Y索引
|
||||
/// </summary>
|
||||
[NotMapped]
|
||||
public int YIndex { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轴点位Params
|
||||
/// </summary>
|
||||
|
||||
@ -1,210 +0,0 @@
|
||||
<UserControl x:Class="PLCSharp.VVMs.MotionController.AxisPointsConfig"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:PLCSharp.VVMs.MotionController"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
d:Background="AliceBlue"
|
||||
d:DataContext="{d:DesignInstance Type=local:ControllersModel}"
|
||||
d:DesignHeight="800" d:DesignWidth="1000"
|
||||
mc:Ignorable="d">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="3*" />
|
||||
<RowDefinition Height="1*" />
|
||||
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Tag="数据">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid Grid.ColumnSpan="2" Tag="表">
|
||||
<DataGrid Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}, AncestorLevel=1}, Path=ActualWidth}"
|
||||
Height="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}, AncestorLevel=1}, Path=ActualHeight}"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
AutoGenerateColumns="False" CanUserAddRows="False"
|
||||
CanUserDeleteRows="False"
|
||||
CanUserSortColumns="False"
|
||||
ItemsSource="{Binding AxisPoints}"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
SelectedItem="{Binding SelectedAxisPoint}"
|
||||
Unloaded="DataGrid_Unloaded">
|
||||
<DataGrid.ContextMenu>
|
||||
<ContextMenu IsEnabled="True" StaysOpen="False">
|
||||
<MenuItem Command="{Binding AxisPointsManage}" CommandParameter="New" Header="新增" />
|
||||
<MenuItem Command="{Binding AxisPointsManage}" CommandParameter="Remove" Header="删除" />
|
||||
<MenuItem Command="{Binding AxisPointsManage}" CommandParameter="Save" Header="保存" />
|
||||
<MenuItem Command="{Binding AxisPointsManage}" CommandParameter="Go" Header="Go" />
|
||||
<MenuItem Command="{Binding AxisPointsManage}" CommandParameter="Jump" Header="Jump" />
|
||||
</ContextMenu>
|
||||
</DataGrid.ContextMenu>
|
||||
<DataGrid.Columns>
|
||||
|
||||
<DataGridTextColumn MinWidth="100" Binding="{Binding Name, UpdateSourceTrigger=LostFocus}" Header="名称" />
|
||||
<DataGridTextColumn MinWidth="100" Binding="{Binding X, UpdateSourceTrigger=LostFocus}" Header="X" />
|
||||
<DataGridTextColumn MinWidth="100" Binding="{Binding Y, UpdateSourceTrigger=LostFocus}" Header="Y" />
|
||||
<DataGridTextColumn MinWidth="100" Binding="{Binding Z, UpdateSourceTrigger=LostFocus}" Header="Z" />
|
||||
<DataGridTextColumn MinWidth="100" Binding="{Binding U, UpdateSourceTrigger=LostFocus}" Header="U" />
|
||||
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</Grid>
|
||||
<Grid Grid.Column="2" Grid.ColumnSpan="2">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="1*" />
|
||||
<RowDefinition Height="1*" />
|
||||
<RowDefinition Height="1*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid MinHeight="500" Tag="设置">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="1*" />
|
||||
<RowDefinition Height="1*" />
|
||||
<RowDefinition Height="1*" />
|
||||
</Grid.RowDefinitions>
|
||||
<GroupBox Header="速率">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="2*" />
|
||||
<RowDefinition Height="2*" />
|
||||
<RowDefinition Height="2*" />
|
||||
<RowDefinition Height="2*" />
|
||||
<RowDefinition Height="3*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="2*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="5*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<!-- X轴 -->
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Text="X轴:" />
|
||||
<ComboBox Grid.Row="0" Grid.Column="1" DisplayMemberPath="Name" ItemsSource="{Binding Axes}" SelectedItem="{Binding SelectedAxisPoint.AxisX, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<TextBlock Grid.Row="0" Grid.Column="2" Text="速率:" />
|
||||
<Slider Grid.Row="0" Grid.Column="3" Maximum="100" Minimum="1" SmallChange="1" Value="{Binding SelectedAxisPoint.XRate}" />
|
||||
<TextBlock Grid.Row="0" Grid.Column="4" Text="{Binding SelectedAxisPoint.XRate, StringFormat={}{0:F0}}" />
|
||||
<!-- Y轴 -->
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" Text="Y轴:" />
|
||||
<ComboBox Grid.Row="1" Grid.Column="1" DisplayMemberPath="Name" ItemsSource="{Binding Axes}" SelectedItem="{Binding SelectedAxisPoint.AxisY, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
<TextBlock Grid.Row="1" Grid.Column="2" Text="速率:" />
|
||||
<Slider Grid.Row="1" Grid.Column="3" Maximum="100" Minimum="1" SmallChange="1" Value="{Binding SelectedAxisPoint.YRate}" />
|
||||
<TextBlock Grid.Row="1" Grid.Column="4" Text="{Binding SelectedAxisPoint.YRate, StringFormat={}{0:F0}}" />
|
||||
<!-- Z轴 -->
|
||||
|
||||
<TextBlock Grid.Row="2" Grid.Column="0" Text="Z轴:" />
|
||||
<ComboBox Grid.Row="2" Grid.Column="1" DisplayMemberPath="Name" ItemsSource="{Binding Axes}" SelectedItem="{Binding SelectedAxisPoint.AxisZ, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
<TextBlock Grid.Row="2" Grid.Column="2" Text="速率:" />
|
||||
<Slider Grid.Row="2" Grid.Column="3" Maximum="100" Minimum="1" SmallChange="1" Value="{Binding SelectedAxisPoint.ZRate}" />
|
||||
<TextBlock Grid.Row="2" Grid.Column="4" Text="{Binding SelectedAxisPoint.ZRate, StringFormat={}{0:F0}}" />
|
||||
<!-- U轴 -->
|
||||
|
||||
<TextBlock Grid.Row="3" Grid.Column="0" Text="U轴:" />
|
||||
<ComboBox Grid.Row="3" Grid.Column="1" DisplayMemberPath="Name" ItemsSource="{Binding Axes}" SelectedItem="{Binding SelectedAxisPoint.AxisU, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<TextBlock Grid.Row="3" Grid.Column="2" Text="速率:" />
|
||||
<Slider Grid.Row="3" Grid.Column="3" Maximum="100" Minimum="1" SmallChange="1" Value="{Binding SelectedAxisPoint.URate}" />
|
||||
<TextBlock Grid.Row="3" Grid.Column="4" Text="{Binding SelectedAxisPoint.URate, StringFormat={}{0:F0}}" />
|
||||
<TextBlock Grid.Row="4" Grid.Column="0" Text="总速率:" Margin="0,10" />
|
||||
<Slider Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="3" Margin="10" Maximum="100" Minimum="1" SmallChange="1" Value="{Binding Rate}" />
|
||||
<TextBlock Grid.Row="4" Grid.Column="4" Text="{Binding Rate, StringFormat={}{0:F0}}" Margin="0,10" />
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
|
||||
</Grid>
|
||||
<StackPanel Grid.Row="1" VerticalAlignment="Top" Orientation="Horizontal">
|
||||
|
||||
<TextBlock Text="Z轴安全位:" />
|
||||
<TextBox Width="50" Text="{Binding SelectedAxisPoint.ZSafe}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
|
||||
<Grid Grid.Row="1" Tag="操作">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="2*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="4*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<GroupBox Header="点动">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Grid.Row="1" Grid.Column="2" Margin="5,0" Command="{Binding AxisPointCommand}" CommandParameter="X+" Content="X+" />
|
||||
<Button Grid.Row="1" Grid.Column="0" Margin="5,0" Command="{Binding AxisPointCommand}" CommandParameter="X-" Content="X-" />
|
||||
|
||||
<Button Grid.Row="0" Grid.Column="1" Margin="10,0" Command="{Binding AxisPointCommand}" CommandParameter="Y+" Content="Y+" />
|
||||
<Button Grid.Row="2" Grid.Column="1" Margin="10,0" Command="{Binding AxisPointCommand}" CommandParameter="Y-" Content="Y-" />
|
||||
<Button Grid.Row="2" Grid.Column="2" Width="50" Margin="10,5" Command="{Binding AxisPointCommand}" CommandParameter="Z+" Content="Z+" />
|
||||
<Button Grid.Row="0" Grid.Column="2" Width="50" Margin="10,5" Command="{Binding AxisPointCommand}" CommandParameter="Z-" Content="Z-" />
|
||||
<Button Grid.Row="2" Grid.Column="0" Width="50" Margin="10,5" Command="{Binding AxisPointCommand}" CommandParameter="U+" Content="U+" />
|
||||
<Button Grid.Row="0" Grid.Column="0" Width="50" Margin="10,5" Command="{Binding AxisPointCommand}" CommandParameter="U-" Content="U-" />
|
||||
|
||||
<Button Grid.Row="1" Grid.Column="1"
|
||||
Margin="3" Padding="15,3"
|
||||
Background="Red"
|
||||
Command="{Binding AxisPointCommand}"
|
||||
CommandParameter="Stop" Content="STOP"
|
||||
FontSize="14" FontWeight="Bold" />
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
|
||||
<GroupBox Grid.Column="1" Header="当前位置">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="*" />
|
||||
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Text="X轴:" />
|
||||
<TextBlock Grid.Row="0" Grid.Column="3" Text="{Binding SelectedAxisPoint.AxisX.CommandPosition}" />
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" Text="Y轴:" />
|
||||
<TextBlock Grid.Row="1" Grid.Column="3" Text="{Binding SelectedAxisPoint.AxisY.CommandPosition}" />
|
||||
<TextBlock Grid.Row="2" Grid.Column="0" Text="Z轴:" />
|
||||
<TextBlock Grid.Row="2" Grid.Column="3" Text="{Binding SelectedAxisPoint.AxisZ.CommandPosition}" />
|
||||
<TextBlock Grid.Row="3" Grid.Column="0" Text="U轴:" />
|
||||
<TextBlock Grid.Row="3" Grid.Column="3" Text="{Binding SelectedAxisPoint.AxisU.CommandPosition}" />
|
||||
<Button Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" Command="{Binding AxisPointCommand}" CommandParameter="Save" Content="保存到选中点" />
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
<GroupBox Grid.Column="2" Header="点动距离">
|
||||
<UniformGrid Grid.Column="2" Columns="2">
|
||||
<TextBlock Text="寸动距离" Margin="3" VerticalAlignment="Center" FontSize="14" FontWeight="Bold" />
|
||||
<TextBox Height="30" Text="{Binding RelativeDistance}" Margin="3" FontSize="14" FontWeight="Bold" />
|
||||
|
||||
<Button Width="50" Margin="3" Command="{Binding DistanceSet}" CommandParameter="Jog0.01" Content="0.01" FontSize="14" FontWeight="Bold" />
|
||||
<Button Width="50" Margin="3" Command="{Binding DistanceSet}" CommandParameter="Jog0.1" Content="0.1" FontSize="14" FontWeight="Bold" />
|
||||
<Button Width="50" Margin="3" Command="{Binding DistanceSet}" CommandParameter="Jog1" Content="1" FontSize="14" FontWeight="Bold" />
|
||||
<Button Width="50" Margin="3" Command="{Binding DistanceSet}" CommandParameter="Jog5" Content="5" FontSize="14" FontWeight="Bold" />
|
||||
<Button Width="50" Margin="3" Command="{Binding DistanceSet}" CommandParameter="Jog10" Content="10" FontSize="14" FontWeight="Bold" />
|
||||
<Button Width="50" Margin="3" Command="{Binding DistanceSet}" CommandParameter="Jog20" Content="20" FontSize="14" FontWeight="Bold" />
|
||||
|
||||
</UniformGrid>
|
||||
</GroupBox>
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
314
PLCSharpWpf/VVMs/MotionController/Config/AxisPointsConfig.xaml
Normal file
314
PLCSharpWpf/VVMs/MotionController/Config/AxisPointsConfig.xaml
Normal file
@ -0,0 +1,314 @@
|
||||
<UserControl x:Class="PLCSharp.VVMs.MotionController.Config.AxisPointsConfig"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:PLCSharp.VVMs.MotionController"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" d:Background="AliceBlue"
|
||||
d:DataContext="{d:DesignInstance Type=local:ControllersModel}"
|
||||
d:DesignHeight="800" d:DesignWidth="1200">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="3*" />
|
||||
<RowDefinition Height="1*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Tag="数据表">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<GroupBox Grid.Column="0" Header="点位表">
|
||||
<Grid>
|
||||
<DataGrid Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}, AncestorLevel=1}, Path=ActualWidth}"
|
||||
Height="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}, AncestorLevel=1}, Path=ActualHeight}"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||
AutoGenerateColumns="False" CanUserAddRows="False"
|
||||
CanUserDeleteRows="False" CanUserSortColumns="False"
|
||||
ItemsSource="{Binding AxisPoints}"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
SelectedItem="{Binding SelectedAxisPoint}"
|
||||
Unloaded="DataGrid_Unloaded">
|
||||
<DataGrid.ContextMenu>
|
||||
<ContextMenu IsEnabled="True" StaysOpen="False">
|
||||
<MenuItem Command="{Binding AxisPointsManage}" CommandParameter="New" Header="新增" />
|
||||
<MenuItem Command="{Binding AxisPointsManage}" CommandParameter="Save" Header="保存" />
|
||||
<MenuItem Command="{Binding AxisPointsManage}" CommandParameter="Remove" Header="删除" />
|
||||
<MenuItem Command="{Binding AxisPointsManage}" CommandParameter="Go" Header="Go" />
|
||||
<MenuItem Command="{Binding AxisPointsManage}" CommandParameter="Jump" Header="Jump" />
|
||||
</ContextMenu>
|
||||
</DataGrid.ContextMenu>
|
||||
<DataGrid.Columns>
|
||||
|
||||
<DataGridTextColumn MinWidth="100" Binding="{Binding Name, UpdateSourceTrigger=LostFocus}" Header="名称" />
|
||||
<DataGridTextColumn MinWidth="100" Binding="{Binding X, UpdateSourceTrigger=LostFocus}" Header="X" />
|
||||
<DataGridTextColumn MinWidth="100" Binding="{Binding Y, UpdateSourceTrigger=LostFocus}" Header="Y" />
|
||||
<DataGridTextColumn MinWidth="100" Binding="{Binding Z, UpdateSourceTrigger=LostFocus}" Header="Z" />
|
||||
<DataGridTextColumn MinWidth="100" Binding="{Binding U, UpdateSourceTrigger=LostFocus}" Header="U" />
|
||||
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
<GroupBox Grid.Column="1" Header="矩阵表">
|
||||
<Grid>
|
||||
<DataGrid Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}, AncestorLevel=1}, Path=ActualWidth}"
|
||||
Height="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}, AncestorLevel=1}, Path=ActualHeight}"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||
AutoGenerateColumns="False" CanUserAddRows="False"
|
||||
CanUserDeleteRows="False" CanUserSortColumns="False"
|
||||
ItemsSource="{Binding Matrices}"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
SelectedItem="{Binding SelectedMatrix}"
|
||||
Unloaded="DataGrid_Unloaded">
|
||||
<DataGrid.ContextMenu>
|
||||
<ContextMenu IsEnabled="True" StaysOpen="False">
|
||||
<MenuItem Command="{Binding MatricesManage}" CommandParameter="New" Header="新增" />
|
||||
<MenuItem Command="{Binding MatricesManage}" CommandParameter="Create" Header="计算矩阵" />
|
||||
<MenuItem Command="{Binding MatricesManage}" CommandParameter="Save" Header="保存" />
|
||||
<MenuItem Command="{Binding MatricesManage}" CommandParameter="Remove" Header="删除" />
|
||||
<MenuItem Command="{Binding MatricesManage}" CommandParameter="Go" Header="Go" />
|
||||
<MenuItem Command="{Binding MatricesManage}" CommandParameter="Jump" Header="Jump" />
|
||||
</ContextMenu>
|
||||
</DataGrid.ContextMenu>
|
||||
<DataGrid.Columns>
|
||||
|
||||
<DataGridTextColumn MinWidth="100" Binding="{Binding Name, UpdateSourceTrigger=LostFocus}" Header="名称" />
|
||||
<DataGridTextColumn MinWidth="100" Binding="{Binding StartName, UpdateSourceTrigger=LostFocus}" Header="首点" />
|
||||
<DataGridTextColumn MinWidth="100" Binding="{Binding XEndName, UpdateSourceTrigger=LostFocus}" Header="X尾点" />
|
||||
<DataGridTextColumn MinWidth="100" Binding="{Binding YEndName, UpdateSourceTrigger=LostFocus}" Header="Y尾点" />
|
||||
<DataGridTextColumn MinWidth="50" Binding="{Binding XCount, UpdateSourceTrigger=LostFocus}" Header="X方向点数" />
|
||||
<DataGridTextColumn MinWidth="50" Binding="{Binding YCount, UpdateSourceTrigger=LostFocus}" Header="Y方向点数" />
|
||||
<DataGridTextColumn MinWidth="50" Binding="{Binding XTarget, UpdateSourceTrigger=LostFocus}" Header="目标X序号" />
|
||||
<DataGridTextColumn MinWidth="50" Binding="{Binding YTarget, UpdateSourceTrigger=LostFocus}" Header="目标Y序号" />
|
||||
|
||||
|
||||
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
</Grid>
|
||||
|
||||
|
||||
<Grid Grid.Row="1" Tag="操作">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="2*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="3*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<GroupBox Header="点动">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Grid.Row="1" Grid.Column="2"
|
||||
Margin="5,0"
|
||||
Command="{Binding AxisPointCommand}"
|
||||
CommandParameter="X+" Content="X+" />
|
||||
<Button Grid.Row="1" Grid.Column="0"
|
||||
Margin="5,0"
|
||||
Command="{Binding AxisPointCommand}"
|
||||
CommandParameter="X-" Content="X-" />
|
||||
|
||||
<Button Grid.Row="0" Grid.Column="1"
|
||||
Margin="10,0"
|
||||
Command="{Binding AxisPointCommand}"
|
||||
CommandParameter="Y+" Content="Y+" />
|
||||
<Button Grid.Row="2" Grid.Column="1"
|
||||
Margin="10,0"
|
||||
Command="{Binding AxisPointCommand}"
|
||||
CommandParameter="Y-" Content="Y-" />
|
||||
<Button Grid.Row="2" Grid.Column="2"
|
||||
Width="50" Margin="10,5"
|
||||
Command="{Binding AxisPointCommand}"
|
||||
CommandParameter="Z+" Content="Z+" />
|
||||
<Button Grid.Row="0" Grid.Column="2"
|
||||
Width="50" Margin="10,5"
|
||||
Command="{Binding AxisPointCommand}"
|
||||
CommandParameter="Z-" Content="Z-" />
|
||||
<Button Grid.Row="2" Grid.Column="0"
|
||||
Width="50" Margin="10,5"
|
||||
Command="{Binding AxisPointCommand}"
|
||||
CommandParameter="U+" Content="U+" />
|
||||
<Button Grid.Row="0" Grid.Column="0"
|
||||
Width="50" Margin="10,5"
|
||||
Command="{Binding AxisPointCommand}"
|
||||
CommandParameter="U-" Content="U-" />
|
||||
|
||||
<Button Grid.Row="1" Grid.Column="1"
|
||||
Margin="3" Padding="15,3"
|
||||
FontSize="14" FontWeight="Bold"
|
||||
Background="Red"
|
||||
Command="{Binding AxisPointCommand}"
|
||||
CommandParameter="Stop" Content="STOP" />
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
|
||||
<GroupBox Grid.Column="1" Header="当前位置">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="*" />
|
||||
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Text="X轴:" />
|
||||
<TextBlock Grid.Row="0" Grid.Column="3" Text="{Binding SelectedAxisPoint.AxisX.CommandPosition}" />
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" Text="Y轴:" />
|
||||
<TextBlock Grid.Row="1" Grid.Column="3" Text="{Binding SelectedAxisPoint.AxisY.CommandPosition}" />
|
||||
<TextBlock Grid.Row="2" Grid.Column="0" Text="Z轴:" />
|
||||
<TextBlock Grid.Row="2" Grid.Column="3" Text="{Binding SelectedAxisPoint.AxisZ.CommandPosition}" />
|
||||
<TextBlock Grid.Row="3" Grid.Column="0" Text="U轴:" />
|
||||
<TextBlock Grid.Row="3" Grid.Column="3" Text="{Binding SelectedAxisPoint.AxisU.CommandPosition}" />
|
||||
<Button Grid.Row="4" Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Command="{Binding AxisPointCommand}"
|
||||
CommandParameter="Save" Content="保存到选中点" />
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
<GroupBox Grid.Column="2" Header="点动距离">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
|
||||
<RowDefinition Height="3*" />
|
||||
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBox Height="30" Margin="3"
|
||||
Text="{Binding RelativeDistance}"
|
||||
FontSize="14" FontWeight="Bold" />
|
||||
|
||||
<UniformGrid Grid.Row="1" Columns="2">
|
||||
|
||||
|
||||
|
||||
<Button Width="50" Margin="3"
|
||||
FontSize="14" FontWeight="Bold"
|
||||
Command="{Binding DistanceSet}"
|
||||
CommandParameter="Jog0.01" Content="0.01" />
|
||||
<Button Width="50" Margin="3"
|
||||
FontSize="14" FontWeight="Bold"
|
||||
Command="{Binding DistanceSet}"
|
||||
CommandParameter="Jog0.1" Content="0.1" />
|
||||
<Button Width="50" Margin="3"
|
||||
FontSize="14" FontWeight="Bold"
|
||||
Command="{Binding DistanceSet}"
|
||||
CommandParameter="Jog1" Content="1" />
|
||||
<Button Width="50" Margin="3"
|
||||
FontSize="14" FontWeight="Bold"
|
||||
Command="{Binding DistanceSet}"
|
||||
CommandParameter="Jog5" Content="5" />
|
||||
<Button Width="50" Margin="3"
|
||||
FontSize="14" FontWeight="Bold"
|
||||
Command="{Binding DistanceSet}"
|
||||
CommandParameter="Jog10" Content="10" />
|
||||
<Button Width="50" Margin="3"
|
||||
FontSize="14" FontWeight="Bold"
|
||||
Command="{Binding DistanceSet}"
|
||||
CommandParameter="Jog20" Content="20" />
|
||||
|
||||
</UniformGrid>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
|
||||
<GroupBox Grid.Row="1" Grid.Column="3" Header="速率">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="2*" />
|
||||
<RowDefinition Height="2*" />
|
||||
<RowDefinition Height="2*" />
|
||||
<RowDefinition Height="2*" />
|
||||
<RowDefinition Height="3*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="2*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="5*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<!-- X轴 -->
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Text="X轴:" />
|
||||
<ComboBox Grid.Row="0" Grid.Column="1"
|
||||
DisplayMemberPath="Name"
|
||||
ItemsSource="{Binding Axes}"
|
||||
SelectedItem="{Binding SelectedAxisPoint.AxisX, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<TextBlock Grid.Row="0" Grid.Column="2" Text="速率:" />
|
||||
<Slider Grid.Row="0" Grid.Column="3"
|
||||
Maximum="100" Minimum="1" SmallChange="1"
|
||||
Value="{Binding SelectedAxisPoint.XRate}" />
|
||||
<TextBlock Grid.Row="0" Grid.Column="4" Text="{Binding SelectedAxisPoint.XRate, StringFormat={}{0:F0}}" />
|
||||
<!-- Y轴 -->
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" Text="Y轴:" />
|
||||
<ComboBox Grid.Row="1" Grid.Column="1"
|
||||
DisplayMemberPath="Name"
|
||||
ItemsSource="{Binding Axes}"
|
||||
SelectedItem="{Binding SelectedAxisPoint.AxisY, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
<TextBlock Grid.Row="1" Grid.Column="2" Text="速率:" />
|
||||
<Slider Grid.Row="1" Grid.Column="3"
|
||||
Maximum="100" Minimum="1" SmallChange="1"
|
||||
Value="{Binding SelectedAxisPoint.YRate}" />
|
||||
<TextBlock Grid.Row="1" Grid.Column="4" Text="{Binding SelectedAxisPoint.YRate, StringFormat={}{0:F0}}" />
|
||||
<!-- Z轴 -->
|
||||
|
||||
<TextBlock Grid.Row="2" Grid.Column="0" Text="Z轴:" />
|
||||
<ComboBox Grid.Row="2" Grid.Column="1"
|
||||
DisplayMemberPath="Name"
|
||||
ItemsSource="{Binding Axes}"
|
||||
SelectedItem="{Binding SelectedAxisPoint.AxisZ, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
<TextBlock Grid.Row="2" Grid.Column="2" Text="速率:" />
|
||||
<Slider Grid.Row="2" Grid.Column="3"
|
||||
Maximum="100" Minimum="1" SmallChange="1"
|
||||
Value="{Binding SelectedAxisPoint.ZRate}" />
|
||||
<TextBlock Grid.Row="2" Grid.Column="4" Text="{Binding SelectedAxisPoint.ZRate, StringFormat={}{0:F0}}" />
|
||||
<!-- U轴 -->
|
||||
|
||||
<TextBlock Grid.Row="3" Grid.Column="0" Text="U轴:" />
|
||||
<ComboBox Grid.Row="3" Grid.Column="1"
|
||||
DisplayMemberPath="Name"
|
||||
ItemsSource="{Binding Axes}"
|
||||
SelectedItem="{Binding SelectedAxisPoint.AxisU, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<TextBlock Grid.Row="3" Grid.Column="2" Text="速率:" />
|
||||
<Slider Grid.Row="3" Grid.Column="3"
|
||||
Maximum="100" Minimum="1" SmallChange="1"
|
||||
Value="{Binding SelectedAxisPoint.URate}" />
|
||||
<TextBlock Grid.Row="3" Grid.Column="4" Text="{Binding SelectedAxisPoint.URate, StringFormat={}{0:F0}}" />
|
||||
<TextBlock Grid.Row="4" Grid.Column="0" Margin="0,10" Text="总速率:" />
|
||||
<Slider Grid.Row="4" Grid.Column="1"
|
||||
Grid.ColumnSpan="3"
|
||||
Margin="10"
|
||||
Maximum="100" Minimum="1" SmallChange="1"
|
||||
Value="{Binding Rate}" />
|
||||
<TextBlock Grid.Row="4" Grid.Column="4" Margin="0,10" Text="{Binding Rate, StringFormat={}{0:F0}}" />
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
<GroupBox Grid.Column="4">
|
||||
<StackPanel Grid.Row="1" VerticalAlignment="Top" Orientation="Horizontal">
|
||||
|
||||
<TextBlock Text="Z轴安全位:" />
|
||||
<TextBox Width="50" Text="{Binding SelectedAxisPoint.ZSafe}" />
|
||||
</StackPanel>
|
||||
</GroupBox>
|
||||
</Grid>
|
||||
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@ -1,7 +1,7 @@
|
||||
using System.Windows;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace PLCSharp.VVMs.MotionController
|
||||
namespace PLCSharp.VVMs.MotionController.Config
|
||||
{
|
||||
/// <summary>
|
||||
/// AxisPointsConfig.xaml 的交互逻辑
|
||||
@ -1,4 +1,4 @@
|
||||
<UserControl x:Class="PLCSharp.VVMs.MotionController.InterpolationConfig"
|
||||
<UserControl x:Class="PLCSharp.VVMs.MotionController.Config.InterpolationConfig"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
@ -1,7 +1,7 @@
|
||||
using System.Windows;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace PLCSharp.VVMs.MotionController
|
||||
namespace PLCSharp.VVMs.MotionController.Config
|
||||
{
|
||||
/// <summary>
|
||||
/// InterpolationConfig.xaml 的交互逻辑
|
||||
@ -38,11 +38,28 @@ namespace PLCSharp.VVMs.MotionController
|
||||
};
|
||||
bkgWorker = new BackgroundWorker { WorkerSupportsCancellation = true };
|
||||
bkgWorker.DoWork += BackgroundWork;
|
||||
}
|
||||
#region BackgroundWork
|
||||
public void Start()
|
||||
{
|
||||
|
||||
if (!bkgWorker.IsBusy)
|
||||
bkgWorker.RunWorkerAsync();
|
||||
|
||||
}
|
||||
private readonly BackgroundWorker bkgWorker;
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
|
||||
bkgWorker.CancelAsync();
|
||||
|
||||
while (bkgWorker.IsBusy)
|
||||
{
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
|
||||
}
|
||||
private BackgroundWorker bkgWorker;
|
||||
|
||||
/// <summary>
|
||||
/// OnExit
|
||||
@ -70,13 +87,26 @@ namespace PLCSharp.VVMs.MotionController
|
||||
AxisPoints[i].Run();
|
||||
}
|
||||
|
||||
for (int i = 0; i < Matrices.Count; i++)
|
||||
{
|
||||
for (int j = 0; j < Matrices[i].Points.Count; j++)
|
||||
{
|
||||
Matrices[i].Points[j].Run();
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < InterpolationGroups.Count; i++)
|
||||
{
|
||||
InterpolationGroups[i].Run();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
e.Cancel = true; // 标记任务已被取消
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Controller
|
||||
/// <summary>
|
||||
/// 初始化
|
||||
/// </summary>
|
||||
@ -155,30 +185,8 @@ namespace PLCSharp.VVMs.MotionController
|
||||
}
|
||||
|
||||
}
|
||||
private double _Rate = 100;
|
||||
/// <summary>
|
||||
/// 速率 1-100
|
||||
/// </summary>
|
||||
public double Rate
|
||||
{
|
||||
get { return _Rate; }
|
||||
set
|
||||
{
|
||||
if (value > 100)
|
||||
value = 100;
|
||||
else if (value < 1)
|
||||
value = 1;
|
||||
SetProperty(ref _Rate, value);
|
||||
foreach (var item in AxisPoints)
|
||||
{
|
||||
item.Rate = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Axes
|
||||
/// </summary>
|
||||
public ObservableCollection<Axis> Axes { get; set; } = [];
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// DI
|
||||
/// </summary>
|
||||
@ -191,7 +199,6 @@ namespace PLCSharp.VVMs.MotionController
|
||||
/// 全局模型
|
||||
/// </summary>
|
||||
public GlobalModel GlobalModel { get; set; }
|
||||
#region Controller
|
||||
|
||||
private ObservableCollection<Controller> _Controllers = [];
|
||||
|
||||
@ -592,7 +599,13 @@ namespace PLCSharp.VVMs.MotionController
|
||||
set { SetProperty(ref _InterpolationConfig, value); }
|
||||
}
|
||||
#endregion Controller
|
||||
|
||||
#region Axis
|
||||
|
||||
/// <summary>
|
||||
/// Axes
|
||||
/// </summary>
|
||||
public ObservableCollection<Axis> Axes { get; set; } = [];
|
||||
private DelegateCommand<object> _AxisCommand;
|
||||
/// <summary>
|
||||
/// 轴Command
|
||||
@ -901,6 +914,7 @@ namespace PLCSharp.VVMs.MotionController
|
||||
}
|
||||
}
|
||||
#endregion Axis
|
||||
|
||||
#region AxisPoint
|
||||
private ObservableCollection<AxisPoint> _AxisPoints = [];
|
||||
/// <summary>
|
||||
@ -1110,6 +1124,237 @@ namespace PLCSharp.VVMs.MotionController
|
||||
}
|
||||
#endregion Point
|
||||
|
||||
#region Matrix
|
||||
private ObservableCollection<Matrix> _Matrices = [];
|
||||
/// <summary>
|
||||
/// 矩阵列表
|
||||
/// </summary>
|
||||
public ObservableCollection<Matrix> Matrices
|
||||
{
|
||||
get { return _Matrices; }
|
||||
set { SetProperty(ref _Matrices, value); }
|
||||
}
|
||||
|
||||
private Matrix _SelectedMatrix;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public Matrix SelectedMatrix
|
||||
{
|
||||
get { return _SelectedMatrix; }
|
||||
set { SetProperty(ref _SelectedMatrix, value); }
|
||||
}
|
||||
|
||||
|
||||
private DelegateCommand<object> _MatricesManage;
|
||||
public DelegateCommand<object> MatricesManage =>
|
||||
_MatricesManage ??= new DelegateCommand<object>(ExecuteMatricesManage);
|
||||
void ExecuteMatricesManage(object param)
|
||||
{
|
||||
var cmd = param as string;
|
||||
switch (cmd)
|
||||
{
|
||||
case "New":
|
||||
{
|
||||
var matrix = new Matrix
|
||||
{
|
||||
RecipeID = GlobalModel.CurrentRecipe.ID,
|
||||
};
|
||||
Matrices.Add(matrix);
|
||||
}
|
||||
break;
|
||||
case "Create":
|
||||
if (SelectedMatrix != null)
|
||||
{
|
||||
Create(SelectedMatrix);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case "Save":
|
||||
var names = new List<string>();
|
||||
|
||||
foreach (var item in Matrices)
|
||||
{
|
||||
if (string.IsNullOrEmpty(item.Name))
|
||||
{
|
||||
SendInfoDialog($"保存失败,名称{item.Name}不合适!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (names.Contains(item.Name))
|
||||
{
|
||||
SendInfoDialog($"保存失败,重复的名称{item.Name}!");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
names.Add(item.Name);
|
||||
}
|
||||
}
|
||||
foreach (var item in Matrices)
|
||||
{
|
||||
if (!_DatasContext.Matrices.Any(h => h.ID == item.ID))
|
||||
{
|
||||
_DatasContext.Matrices.Add(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
var matrix = _DatasContext.Matrices.Where(c => c.ID == item.ID).FirstOrDefault();
|
||||
matrix.Name = item.Name;
|
||||
matrix.StartName = item.StartName;
|
||||
matrix.XEndName = item.XEndName;
|
||||
matrix.YEndName = item.YEndName;
|
||||
matrix.XCount = item.XCount;
|
||||
matrix.YCount = item.YCount;
|
||||
matrix.MatrixType = item.MatrixType;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
_DatasContext.Save();
|
||||
break;
|
||||
|
||||
case "Remove":
|
||||
if (SelectedMatrix != null)
|
||||
{
|
||||
if (System.Windows.MessageBox.Show($"确认删除矩阵 [{SelectedMatrix.Name}]?", "确认删除", MessageBoxButton.YesNo, MessageBoxImage.Warning) != MessageBoxResult.Yes)
|
||||
break;
|
||||
|
||||
var removedb = _DatasContext.Matrices.Where(h => h.ID == SelectedMatrix.ID).FirstOrDefault();
|
||||
if (removedb != null)
|
||||
{
|
||||
_DatasContext.Matrices.Remove(removedb);
|
||||
_DatasContext.Save();
|
||||
}
|
||||
var remove = Matrices.Where(h => h.ID == SelectedMatrix.ID).FirstOrDefault();
|
||||
|
||||
if (remove != null)
|
||||
{
|
||||
Matrices.Remove(remove);
|
||||
var name = remove.Name;
|
||||
SendInfoDialog($"已删除矩阵:{name}");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case "Jump":
|
||||
var pointJump = SelectedMatrix.GetPoint(SelectedMatrix.XTarget, SelectedMatrix.YTarget);
|
||||
|
||||
if (pointJump == null)
|
||||
{
|
||||
|
||||
SendInfoDialog("目标点不存在,请检查目标设置");
|
||||
return;
|
||||
|
||||
}
|
||||
pointJump.Jump();
|
||||
|
||||
break;
|
||||
case "Go":
|
||||
if (SelectedMatrix == null) return;
|
||||
|
||||
var point = SelectedMatrix.GetPoint(SelectedMatrix.XTarget, SelectedMatrix.YTarget);
|
||||
|
||||
if (point == null)
|
||||
{
|
||||
|
||||
SendInfoDialog("目标点不存在,请检查目标设置");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
_dialogService.Show("AlertDialog", new DialogParameters($"message=choose:直接运行至此点吗?"), r =>
|
||||
{
|
||||
if (r.Result == ButtonResult.Yes)
|
||||
{
|
||||
|
||||
point.Go();
|
||||
}
|
||||
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
internal void Create(Matrix matrix)
|
||||
{
|
||||
matrix.Points.Clear();
|
||||
matrix.XCount = matrix.XCount > 0 ? matrix.XCount : 1;
|
||||
matrix.YCount = matrix.YCount > 0 ? matrix.YCount : 1;
|
||||
int xCount = matrix.XCount;
|
||||
int yCount = matrix.YCount;
|
||||
int total = xCount * yCount;
|
||||
|
||||
// 从 AxisPoints 中查找三个角点
|
||||
var startPoint = AxisPoints.FirstOrDefault(p => p.Name == matrix.StartName);
|
||||
var xEndPoint = AxisPoints.FirstOrDefault(p => p.Name == matrix.XEndName);
|
||||
var yEndPoint = AxisPoints.FirstOrDefault(p => p.Name == matrix.YEndName);
|
||||
|
||||
if (startPoint == null || xEndPoint == null || yEndPoint == null)
|
||||
{
|
||||
|
||||
SendErr("基准点位名称错误,创建失败!");
|
||||
return;
|
||||
}
|
||||
|
||||
// 计算 X/Y 方向基向量(当 XCount/YCount 为 1 时间距为 0)
|
||||
double xBasisX = xCount > 1 ? (xEndPoint.X - startPoint.X) / (xCount - 1) : 0;
|
||||
double xBasisY = xCount > 1 ? (xEndPoint.Y - startPoint.Y) / (xCount - 1) : 0;
|
||||
double yBasisX = yCount > 1 ? (yEndPoint.X - startPoint.X) / (yCount - 1) : 0;
|
||||
double yBasisY = yCount > 1 ? (yEndPoint.Y - startPoint.Y) / (yCount - 1) : 0;
|
||||
double zBasisX = xCount > 1 ? (xEndPoint.Z - startPoint.Z) / (xCount - 1) : 0;
|
||||
double zBasisY = yCount > 1 ? (yEndPoint.Z - startPoint.Z) / (yCount - 1) : 0;
|
||||
|
||||
double originX = startPoint.X;
|
||||
double originY = startPoint.Y;
|
||||
double originZ = startPoint.Z;
|
||||
|
||||
// 按 MatrixType 确定遍历顺序
|
||||
// 0 = 先X后Y (外层Y, 内层X); 1 = 先Y后X (外层X, 内层Y)
|
||||
for (int i = 0; i < total; i++)
|
||||
{
|
||||
int x, y;
|
||||
if (matrix.MatrixType == 0)
|
||||
{
|
||||
// 先X后Y: X变快, Y变慢
|
||||
x = i % xCount;
|
||||
y = i / xCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 先Y后X: Y变快, X变慢
|
||||
y = i % yCount;
|
||||
x = i / yCount;
|
||||
}
|
||||
|
||||
// 平行四边形插值坐标:P = start + x*xBasis + y*yBasis
|
||||
double px = originX + x * xBasisX + y * yBasisX;
|
||||
double py = originY + x * xBasisY + y * yBasisY;
|
||||
double pz = originZ + x * zBasisX + y * zBasisY;
|
||||
|
||||
var point = new AxisPoint
|
||||
{
|
||||
XIndex = x,
|
||||
YIndex = y,
|
||||
X = px,
|
||||
Y = py,
|
||||
Z = pz,
|
||||
// 复制起始点的轴配置
|
||||
AxisX = startPoint.AxisX,
|
||||
AxisY = startPoint.AxisY,
|
||||
AxisZ = startPoint.AxisZ,
|
||||
AxisU = startPoint.AxisU,
|
||||
U = startPoint.U
|
||||
};
|
||||
|
||||
matrix.Points.Add(point);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Interpolation
|
||||
|
||||
/// <summary>
|
||||
@ -1175,7 +1420,7 @@ namespace PLCSharp.VVMs.MotionController
|
||||
|
||||
if (names.Contains(item.Name))
|
||||
{
|
||||
SendInfoDialog($"保存失败,重复的名称{item.Name}!" );
|
||||
SendInfoDialog($"保存失败,重复的名称{item.Name}!");
|
||||
return;
|
||||
}
|
||||
else
|
||||
@ -1406,6 +1651,8 @@ namespace PLCSharp.VVMs.MotionController
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
124
PLCSharpWpf/VVMs/MotionController/Matrix.cs
Normal file
124
PLCSharpWpf/VVMs/MotionController/Matrix.cs
Normal file
@ -0,0 +1,124 @@
|
||||
using Newtonsoft.Json;
|
||||
using Prism.Mvvm;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace PLCSharp.VVMs.MotionController
|
||||
{
|
||||
public class Matrix : BindableBase
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 唯一标识
|
||||
/// </summary>
|
||||
[Key]
|
||||
public Guid ID { get; set; } = Guid.NewGuid();
|
||||
/// <summary>
|
||||
/// 配方标识
|
||||
/// </summary>
|
||||
public Guid RecipeID { get; set; }
|
||||
private string _Name;
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get { return _Name; }
|
||||
set { SetProperty(ref _Name, value); }
|
||||
}
|
||||
|
||||
private string _StartName;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string StartName
|
||||
{
|
||||
get { return _StartName; }
|
||||
set { SetProperty(ref _StartName, value); }
|
||||
}
|
||||
|
||||
private string _XEndName;
|
||||
/// <summary>
|
||||
/// X方向尾点名
|
||||
/// </summary>
|
||||
public string XEndName
|
||||
{
|
||||
get { return _XEndName; }
|
||||
set { SetProperty(ref _XEndName, value); }
|
||||
}
|
||||
|
||||
private string _YEndName;
|
||||
/// <summary>
|
||||
/// Y方向尾点名
|
||||
/// </summary>
|
||||
public string YEndName
|
||||
{
|
||||
get { return _YEndName; }
|
||||
set { SetProperty(ref _YEndName, value); }
|
||||
}
|
||||
|
||||
private int _XCount;
|
||||
/// <summary>
|
||||
/// X方向点数
|
||||
/// </summary>
|
||||
public int XCount
|
||||
{
|
||||
get { return _XCount; }
|
||||
set { SetProperty(ref _XCount, value); }
|
||||
}
|
||||
|
||||
private int _YCount;
|
||||
/// <summary>
|
||||
/// Y方向点数
|
||||
/// </summary>
|
||||
public int YCount
|
||||
{
|
||||
get { return _YCount; }
|
||||
set { SetProperty(ref _YCount, value); }
|
||||
}
|
||||
|
||||
private int _MatrixType;
|
||||
/// <summary>
|
||||
/// 矩阵元素顺序 0先X后Y,1先Y后X
|
||||
/// </summary>
|
||||
public int MatrixType
|
||||
{
|
||||
get { return _MatrixType; }
|
||||
set { SetProperty(ref _MatrixType, value); }
|
||||
}
|
||||
|
||||
|
||||
private int _XTarget;
|
||||
|
||||
/// <summary>
|
||||
/// 手动运行时输入的X目标
|
||||
/// </summary>
|
||||
[NotMapped]
|
||||
public int XTarget
|
||||
{
|
||||
get { return _XTarget; }
|
||||
set { SetProperty(ref _XTarget, value); }
|
||||
}
|
||||
|
||||
private int _YTarget;
|
||||
/// <summary>
|
||||
/// 手动运行时输入的Y目标
|
||||
/// </summary>
|
||||
[NotMapped]
|
||||
public int YTarget
|
||||
{
|
||||
get { return _YTarget; }
|
||||
set { SetProperty(ref _YTarget, value); }
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public List<AxisPoint> Points { get; set; } = [];
|
||||
|
||||
public AxisPoint GetPoint(int x, int y)
|
||||
{
|
||||
|
||||
return Points.FirstOrDefault(p => p.XIndex == x && p.YIndex == y);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user