105040 从3D中抓取多芯线数据
This commit is contained in:
parent
5bc1533d9b
commit
1d394780a7
|
@ -234,12 +234,14 @@ namespace Sinvo.EplanHpD.Plugin.Test
|
|||
var stuffedData = new StuffedDataModel
|
||||
{
|
||||
Imprint = "D-PE1231231",
|
||||
WireModel = "黄绿色RV0.5-CE/定制",
|
||||
FrontTerminalModel = "C45-1.5-CE/定制",
|
||||
WireModel = "黄绿色RV1.0-CE/定制",
|
||||
FrontTerminalModel = "RNB1.25-4-CE/定制",
|
||||
FrontTerminalMaterialCode = "42020100000792",
|
||||
RearTerminalModel = "RNB2-5-CE/定制",
|
||||
RearTerminalMaterialCode = "42013500000756"
|
||||
};
|
||||
vm.CheckTerminals(stuffedData);
|
||||
Assert.IsFalse(!stuffedData.IsError);
|
||||
Assert.IsFalse(stuffedData.IsError);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -8,11 +8,13 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:util="clr-namespace:Sinvo.EplanHpD.Plugin.WPFUI.Utils"
|
||||
xmlns:viewmodel="clr-namespace:Sinvo.EplanHpD.Plugin.WPFUI.ViewModel"
|
||||
Title="LectotypeWindow"
|
||||
Width="800"
|
||||
Height="450"
|
||||
Title="多芯线数据抓取"
|
||||
Width="1600"
|
||||
Height="800"
|
||||
d:DataContext="{d:DesignInstance Type=viewmodel:LectotypeViewModel}"
|
||||
Closed="Window_Closed"
|
||||
Loaded="Window_Loaded"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
mc:Ignorable="d">
|
||||
<Window.Resources>
|
||||
<ResourceDictionary>
|
||||
|
@ -20,7 +22,7 @@
|
|||
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<CollectionViewSource x:Key="LettotypeData" Source="{Binding Wires}">
|
||||
<CollectionViewSource x:Key="LettotypeData" Source="{Binding Wires, IsAsync=True}">
|
||||
<CollectionViewSource.GroupDescriptions>
|
||||
<PropertyGroupDescription PropertyName="AxisNo" />
|
||||
</CollectionViewSource.GroupDescriptions>
|
||||
|
@ -84,36 +86,85 @@
|
|||
</DataTemplate>
|
||||
</util:LectotypeLengthDataTemplateSelector.ComplexLineTemplate>
|
||||
</util:LectotypeLengthDataTemplateSelector>
|
||||
<DataTemplate x:Key="LoadingMask">
|
||||
<Grid Background="#66424242">
|
||||
<StackPanel
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Orientation="Vertical">
|
||||
<TextBlock
|
||||
HorizontalAlignment="Center"
|
||||
FontSize="16"
|
||||
Text="加载中..." />
|
||||
<ProgressBar
|
||||
Width="200"
|
||||
Height="10"
|
||||
IsIndeterminate="True" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ResourceDictionary>
|
||||
</Window.Resources>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="50" />
|
||||
<RowDefinition Height="80" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Button
|
||||
<ContentPresenter
|
||||
x:Name="LoadingMask"
|
||||
Grid.Row="0"
|
||||
Height="100"
|
||||
Click="Button_Click"
|
||||
Content="Reload" />
|
||||
<hc:TabControl Grid.Row="1">
|
||||
<hc:TabItem Header="整理后的数据">
|
||||
<ListView
|
||||
Grid.RowSpan="2"
|
||||
Panel.ZIndex="99"
|
||||
Content="{Binding}"
|
||||
ContentTemplate="{StaticResource LoadingMask}" />
|
||||
<hc:Card Grid.Row="0">
|
||||
<hc:SimpleStackPanel Orientation="Horizontal">
|
||||
<Button
|
||||
Margin="5"
|
||||
Click="Button_Click"
|
||||
Content="刷新数据"
|
||||
Style="{StaticResource ButtonPrimary}" />
|
||||
<Button
|
||||
Margin="5"
|
||||
Click="Button_Click"
|
||||
Content="导出下单表"
|
||||
Style="{StaticResource ButtonPrimary}" />
|
||||
</hc:SimpleStackPanel>
|
||||
</hc:Card>
|
||||
<TabControl Grid.Row="1">
|
||||
<TabItem Header="整理后的数据">
|
||||
<DataGrid
|
||||
x:Name="LettotypeListView"
|
||||
hc:DataGridAttach.ShowRowNumber="True"
|
||||
ItemsSource="{Binding Source={StaticResource LettotypeData}}"
|
||||
ScrollViewer.CanContentScroll="True"
|
||||
AutoGenerateColumns="False"
|
||||
ItemsSource="{Binding Source={StaticResource LettotypeData}, IsAsync=True}"
|
||||
RowDetailsVisibilityChanged="LettotypeListView_RowDetailsVisibilityChanged"
|
||||
RowDetailsVisibilityMode="{Binding DetailsShowMode}"
|
||||
ScrollViewer.CanContentScroll="False"
|
||||
SelectedItem="{Binding SelectedItem}"
|
||||
SelectionMode="Single"
|
||||
VirtualizingPanel.IsContainerVirtualizable="True"
|
||||
VirtualizingPanel.IsVirtualizing="True"
|
||||
VirtualizingPanel.ScrollUnit="Pixel"
|
||||
VirtualizingPanel.VirtualizationMode="Recycling">
|
||||
<ListView.ContextMenu>
|
||||
<DataGrid.Resources>
|
||||
<Style BasedOn="{StaticResource DataGridCellStyle}" TargetType="DataGridCell">
|
||||
<Setter Property="Height" Value="Auto" />
|
||||
<Setter Property="MaxHeight" Value="9999" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</DataGrid.Resources>
|
||||
<DataGrid.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Click="ToSourceMenuItem_Click" Header="在3D中查看(转至源)" />
|
||||
</ContextMenu>
|
||||
</ListView.ContextMenu>
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style BasedOn="{StaticResource ListViewItemBaseStyle}" TargetType="ListViewItem">
|
||||
</DataGrid.ContextMenu>
|
||||
<DataGrid.RowStyle>
|
||||
<Style BasedOn="{StaticResource DataGridRowStyle}" TargetType="DataGridRow">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsError}" Value="True">
|
||||
<Setter Property="Background" Value="#dc4d41" />
|
||||
|
@ -123,11 +174,53 @@
|
|||
<Setter Property="Foreground" Value="White" />
|
||||
<Setter Property="Background" Value="#326cf3" />
|
||||
</Trigger>
|
||||
<DataTrigger Binding="{Binding CurrentLine}" Value="1">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="DataGridRow">
|
||||
<SelectiveScrollingGrid>
|
||||
<SelectiveScrollingGrid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</SelectiveScrollingGrid.ColumnDefinitions>
|
||||
<SelectiveScrollingGrid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</SelectiveScrollingGrid.RowDefinitions>
|
||||
<Border
|
||||
x:Name="DGR_Border"
|
||||
Grid.ColumnSpan="2"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="0,0,4,4"
|
||||
SnapsToDevicePixels="True" />
|
||||
<DataGridCellsPresenter
|
||||
Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
MinHeight="{TemplateBinding MinHeight}"
|
||||
VerticalContentAlignment="Center"
|
||||
ItemsPanel="{TemplateBinding ItemsPanel}"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
||||
<DataGridDetailsPresenter
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
SelectiveScrollingGrid.SelectiveScrollingOrientation="{Binding AreRowDetailsFrozen, ConverterParameter={x:Static SelectiveScrollingOrientation.Vertical}, Converter={x:Static DataGrid.RowDetailsScrollingConverter}, RelativeSource={RelativeSource AncestorType=DataGrid}}"
|
||||
Visibility="{TemplateBinding DetailsVisibility}" />
|
||||
<DataGridRowHeader
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical"
|
||||
Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Row}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType=DataGrid}}" />
|
||||
</SelectiveScrollingGrid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>
|
||||
<ListView.GroupStyle>
|
||||
<!-- Style for groups at top level. -->
|
||||
</DataGrid.RowStyle>
|
||||
<DataGrid.GroupStyle>
|
||||
<GroupStyle>
|
||||
<GroupStyle.ContainerStyle>
|
||||
<Style TargetType="{x:Type GroupItem}">
|
||||
|
@ -141,27 +234,24 @@
|
|||
BorderThickness="1,1,1,5"
|
||||
Foreground="#FFEEEEEE"
|
||||
IsExpanded="True">
|
||||
<Expander.Resources>
|
||||
<Style BasedOn="{StaticResource {x:Type Expander}}" TargetType="Expander">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding Path=Name}" Value="{x:Null}">
|
||||
<Setter Property="Background" Value="#dc4d41" />
|
||||
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Expander.Resources>
|
||||
<Expander.Header>
|
||||
<DockPanel>
|
||||
<TextBlock
|
||||
Width="100"
|
||||
Margin="5,0,0,0"
|
||||
FontWeight="Bold"
|
||||
Text="{Binding Path=Name}" />
|
||||
<TextBlock FontWeight="Bold" Text="{Binding Path=ItemCount}" />
|
||||
Text="{Binding Path=Name, StringFormat=轴号:{0}}" />
|
||||
<TextBlock FontWeight="Bold" Text="{Binding Path=ItemCount, StringFormat=线总数量:{0}}" />
|
||||
</DockPanel>
|
||||
</Expander.Header>
|
||||
<ItemsPresenter />
|
||||
<Grid>
|
||||
<Border
|
||||
Padding="5,0,0,0"
|
||||
BorderBrush="Gray"
|
||||
BorderThickness="2,0,0,0">
|
||||
<ItemsPresenter />
|
||||
</Border>
|
||||
</Grid>
|
||||
</Expander>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
|
@ -169,32 +259,182 @@
|
|||
</Style>
|
||||
</GroupStyle.ContainerStyle>
|
||||
</GroupStyle>
|
||||
</ListView.GroupStyle>
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn DisplayMemberBinding="{Binding Name}" Header="名称" />
|
||||
<GridViewColumn DisplayMemberBinding="{Binding CableName}" Header="线材名称" />
|
||||
<GridViewColumn DisplayMemberBinding="{Binding AxisNo}" Header="轴号" />
|
||||
<GridViewColumn DisplayMemberBinding="{Binding DrawingNo}" Header="图号" />
|
||||
<GridViewColumn DisplayMemberBinding="{Binding CurrentLine}" Header="当前段号" />
|
||||
<GridViewColumn DisplayMemberBinding="{Binding LineCount}" Header="总段数" />
|
||||
<GridViewColumn CellTemplateSelector="{StaticResource LectotypeLengthDataTemplateSelector}" Header="长度" />
|
||||
<GridViewColumn Header="是否高柔">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<CheckBox IsChecked="{Binding IsFlexibility}" IsEnabled="False" />
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
<GridViewColumn DisplayMemberBinding="{Binding CableType}" Header="线材类型" />
|
||||
<GridViewColumn DisplayMemberBinding="{Binding CableConnectionClass}" Header="线材连接方式" />
|
||||
<GridViewColumn DisplayMemberBinding="{Binding CheckedMsg}" Header="异常信息" />
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
</DataGrid.GroupStyle>
|
||||
<DataGrid.Columns>
|
||||
<DataGridTemplateColumn MaxWidth="230" Header="名称">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Name}" TextWrapping="Wrap" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTextColumn Binding="{Binding CableName}" Header="线材名称" />
|
||||
<DataGridTextColumn Binding="{Binding AxisNo}" Header="轴号" />
|
||||
<DataGridTextColumn Binding="{Binding Motor.MotorModelStr}" Header="电机型号" />
|
||||
<!--<DataGridComboBoxColumn MinWidth="200" Header="驱动器">
|
||||
<DataGridComboBoxColumn.EditingElementStyle>
|
||||
<Style BasedOn="{StaticResource {x:Type ComboBox}}" TargetType="ComboBox">
|
||||
<Setter Property="ItemsSource" Value="{Binding Path=DataContext.Drivers}" />
|
||||
<Setter Property="DisplayMemberPath" Value="." />
|
||||
<Setter Property="SelectedValuePath" Value="." />
|
||||
<Setter Property="MinWidth" Value="200" />
|
||||
</Style>
|
||||
</DataGridComboBoxColumn.EditingElementStyle>
|
||||
</DataGridComboBoxColumn>-->
|
||||
<DataGridTextColumn Binding="{Binding CableModelNo}" Header="图号" />
|
||||
<DataGridTextColumn
|
||||
MinWidth="200"
|
||||
Binding="{Binding DrawingNo}"
|
||||
Header="线材型号" />
|
||||
<DataGridTextColumn Binding="{Binding CurrentLine}" Header="当前段号" />
|
||||
<DataGridTextColumn Binding="{Binding LineCount}" Header="总段数" />
|
||||
<DataGridTemplateColumn CellTemplateSelector="{StaticResource LectotypeLengthDataTemplateSelector}" Header="长度" />
|
||||
<DataGridTemplateColumn Header="是否高柔">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<CheckBox
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Checked="CheckBox_Checked"
|
||||
Click="CheckBox_Click"
|
||||
IsChecked="{Binding IsFlexibility, UpdateSourceTrigger=PropertyChanged}"
|
||||
IsEnabled="True"
|
||||
Unchecked="CheckBox_Unchecked" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTextColumn Binding="{Binding CableType}" Header="线材类型" />
|
||||
<DataGridTextColumn Binding="{Binding CableConnectionClass}" Header="线材连接方式" />
|
||||
<DataGridTextColumn Binding="{Binding CheckedMsg}" Header="异常信息" />
|
||||
<DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Button
|
||||
Margin="10"
|
||||
Content="查看图纸"
|
||||
Style="{StaticResource ButtonPrimary}"
|
||||
Tag="{Binding DrawingNo}" />
|
||||
<Button
|
||||
Margin="10"
|
||||
Content="查看BOM"
|
||||
Style="{StaticResource ButtonPrimary}"
|
||||
Tag="{Binding DrawingNo}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
</DataGrid.Columns>
|
||||
<DataGrid.RowDetailsTemplate>
|
||||
<DataTemplate>
|
||||
<DataGrid
|
||||
Width="Auto"
|
||||
Height="Auto"
|
||||
MinHeight="100"
|
||||
Margin="40,0,0,0"
|
||||
AutoGenerateColumns="False"
|
||||
BorderBrush="Gray"
|
||||
BorderThickness="2,0,0,0"
|
||||
HeadersVisibility="Column"
|
||||
IsReadOnly="True"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
SelectionChanged="SubDetailsDataGrid_SelectionChanged"
|
||||
SelectionUnit="FullRow">
|
||||
<DataGrid.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Click="SubToSourceMenuItem_Click" Header="在3D中查看(转至源)" />
|
||||
</ContextMenu>
|
||||
</DataGrid.ContextMenu>
|
||||
<DataGrid.Resources>
|
||||
<Style
|
||||
x:Key="DataGridCheckBoxCellStyle"
|
||||
BasedOn="{StaticResource {x:Type DataGridCell}}"
|
||||
TargetType="DataGridCell">
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="HorizontalAlignment" Value="Center" />
|
||||
<Setter Property="Foreground" Value="Black" />
|
||||
</Style>
|
||||
</DataGrid.Resources>
|
||||
<DataGrid.RowStyle>
|
||||
<Style BasedOn="{StaticResource DataGridRowStyle}" TargetType="DataGridRow">
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Background" Value="#aa326cf3" />
|
||||
<Setter Property="Foreground" Value="Black" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</DataGrid.RowStyle>
|
||||
<DataGrid.ColumnHeaderStyle>
|
||||
<Style BasedOn="{StaticResource DataGridColumnHeaderStyle}" TargetType="DataGridColumnHeader">
|
||||
<Setter Property="MinHeight" Value="35" />
|
||||
<Setter Property="Margin" Value="0" />
|
||||
</Style>
|
||||
</DataGrid.ColumnHeaderStyle>
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Binding="{Binding Name}" Header="名称" />
|
||||
<DataGridTextColumn Binding="{Binding CableName}" Header="线材名称" />
|
||||
<DataGridTextColumn Binding="{Binding AxisNo}" Header="轴号" />
|
||||
<DataGridTextColumn Binding="{Binding Length}" Header="长度" />
|
||||
<DataGridTextColumn Binding="{Binding CableType}" Header="线材类型" />
|
||||
<DataGridTextColumn Binding="{Binding CableConnectionClass}" Header="线材连接方式" />
|
||||
|
||||
</hc:TabItem>
|
||||
</hc:TabControl>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</DataTemplate>
|
||||
</DataGrid.RowDetailsTemplate>
|
||||
</DataGrid>
|
||||
</TabItem>
|
||||
<TabItem Header="电机数据">
|
||||
<DataGrid
|
||||
x:Name="MotorDataGrid"
|
||||
AutoGenerateColumns="False"
|
||||
IsReadOnly="False"
|
||||
ItemsSource="{Binding Motors}">
|
||||
<DataGrid.Resources>
|
||||
<Style BasedOn="{StaticResource DataGridCellStyle}" TargetType="DataGridCell">
|
||||
<Setter Property="Height" Value="Auto" />
|
||||
<Setter Property="MaxHeight" Value="9999" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</DataGrid.Resources>
|
||||
<DataGrid.RowStyle>
|
||||
<Style BasedOn="{StaticResource DataGridRowStyle}" TargetType="DataGridRow">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsError}" Value="True">
|
||||
<Setter Property="Background" Value="#dc4d41" />
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
</DataTrigger>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
<Setter Property="Background" Value="#326cf3" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</DataGrid.RowStyle>
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn
|
||||
Width="160"
|
||||
Binding="{Binding MotorModelStr}"
|
||||
Header="电机型号" />
|
||||
<DataGridTextColumn
|
||||
Width="160"
|
||||
Binding="{Binding MotorPower}"
|
||||
Header="电机功率" />
|
||||
<DataGridTextColumn
|
||||
Width="160"
|
||||
Binding="{Binding AxisNo}"
|
||||
Header="轴号" />
|
||||
<DataGridTextColumn Binding="{Binding CheckedMsg}" Header="异常信息" />
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
|
||||
using EPLAN.Harness.Core.Controls;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Utils;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.ViewModel;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Sinvo.EplanHpD.Plugin.WPFUI
|
||||
{
|
||||
|
@ -19,23 +23,131 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI
|
|||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ViewModel.LoadData();
|
||||
try
|
||||
{
|
||||
MotorExcelHelper.Instance.ReadDataToStream();
|
||||
LoadData();
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
FlexMessageBox.Error(ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ViewModel.LoadData();
|
||||
try
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
FlexMessageBox.Error(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
LoadingMask.Visibility = Visibility.Visible;
|
||||
ViewModel.GetMotors().ContinueWith(x =>
|
||||
{
|
||||
ViewModel.LoadData()
|
||||
.ContinueWith(x =>
|
||||
{
|
||||
this.Dispatcher.BeginInvoke(delegate ()
|
||||
{
|
||||
LoadingMask.Visibility = Visibility.Collapsed;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
private void ToSourceMenuItem_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var selectItem = LettotypeListView.SelectedItem;
|
||||
if (selectItem is LectotypeModel model)
|
||||
{
|
||||
|
||||
ViewModel.ToSource(model.CableName);
|
||||
var selectItem = LettotypeListView.SelectedItem;
|
||||
if (selectItem is LectotypeLineModel model)
|
||||
{
|
||||
var cableName = model.CableName;
|
||||
//if (model.IsComplexLine)
|
||||
//{
|
||||
// FlexMessageBox.ShowText(FlexMessageBox.Type.INFO, "组合线请选择子项进行跳转");
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
if (model.IsComplexLine)
|
||||
{
|
||||
if (ViewModel.SelectedSubItem != null)
|
||||
{
|
||||
cableName = ViewModel.SelectedSubItem.FirstOrDefault()?.CableName;
|
||||
}
|
||||
}
|
||||
if (string.IsNullOrEmpty(cableName))
|
||||
{
|
||||
FlexMessageBox.ShowText(FlexMessageBox.Type.INFO, "未获取到线材名称");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
ViewModel.ToSource(cableName);
|
||||
}
|
||||
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
private void LettotypeListView_RowDetailsVisibilityChanged(object sender, System.Windows.Controls.DataGridRowDetailsEventArgs e)
|
||||
{
|
||||
var datagrid = sender as DataGrid;
|
||||
if (datagrid != null)
|
||||
{
|
||||
var DetailsDataGrid = e.DetailsElement as DataGrid;
|
||||
if (DetailsDataGrid != null)
|
||||
{
|
||||
DetailsDataGrid.ItemsSource = ViewModel.SelectedSubItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SubToSourceMenuItem_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (SubDetailsDataGridSelectedItem != null)
|
||||
{
|
||||
if (SubDetailsDataGridSelectedItem is LectotypeLineModel model)
|
||||
{
|
||||
ViewModel.ToSource(model.CableName);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
private object SubDetailsDataGridSelectedItem;
|
||||
private void SubDetailsDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
DataGrid dataGrid = sender as DataGrid;
|
||||
if (dataGrid != null && dataGrid.SelectedItem != null)
|
||||
{
|
||||
SubDetailsDataGridSelectedItem = dataGrid.SelectedItem;
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_Closed(object sender, System.EventArgs e)
|
||||
{
|
||||
MotorExcelHelper.Instance.CloseStream();
|
||||
}
|
||||
|
||||
private void CheckBox_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void CheckBox_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -193,7 +193,22 @@
|
|||
<DataGrid.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Click="IgnoreSelectedError_Click" Header="忽略选中项的异常" />
|
||||
<MenuItem Click="GoToSource_Click" Header="转至源" />
|
||||
<MenuItem Click="GoToSource_Click">
|
||||
<MenuItem.Header>
|
||||
<StackPanel VerticalAlignment="Center" Orientation="Horizontal">
|
||||
<TextBlock VerticalAlignment="Center" Text="转至源" />
|
||||
<Border
|
||||
Margin="10,0,0,0"
|
||||
BorderBrush="Gray"
|
||||
BorderThickness="0,0,0,1">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<CheckBox VerticalAlignment="Center" IsChecked="{Binding ToSourceAndMinSelf}" />
|
||||
<TextBlock VerticalAlignment="Center" Text="最小化窗口" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</MenuItem.Header>
|
||||
</MenuItem>
|
||||
<MenuItem Click="UnIgnoreSelectedError_Click" Header="取消忽略选中项的异常" />
|
||||
<MenuItem
|
||||
Click="Copy_Click"
|
||||
|
|
|
@ -464,6 +464,10 @@ public partial class MainWindow : Window
|
|||
try
|
||||
{
|
||||
GoToSource();
|
||||
if (ViewModel.ToSourceAndMinSelf)
|
||||
{
|
||||
this.WindowState = WindowState.Minimized;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
|
||||
{
|
||||
public class ConfigItemModel
|
||||
{
|
||||
public string ItemName { get; set; }
|
||||
public string ItemValue { get; set; }
|
||||
|
||||
public string ItemFlag { get; set; }
|
||||
}
|
||||
}
|
|
@ -23,8 +23,6 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
|
|||
[ExcelColumn(Name = "印记前缀")]
|
||||
public string Prefix { get; set; }
|
||||
|
||||
///
|
||||
|
||||
/// <summary>
|
||||
/// 线材型号规格
|
||||
/// </summary>
|
||||
|
|
|
@ -0,0 +1,365 @@
|
|||
using Sinvo.EplanHpD.Plugin.WPFUI.Utils;
|
||||
using System.Linq;
|
||||
|
||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
|
||||
{
|
||||
public class LectotypeLineModel : CheckedModel
|
||||
{
|
||||
|
||||
public int SeqNo;
|
||||
|
||||
public bool IsComplexLine;
|
||||
|
||||
private string _name;
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
set
|
||||
{
|
||||
_name = value;
|
||||
OnPropertyChanged(nameof(Name));
|
||||
}
|
||||
}
|
||||
private string _cableName;
|
||||
/// <summary>
|
||||
/// 线材名称 -> eg:ca_000120
|
||||
/// </summary>
|
||||
public string CableName
|
||||
{
|
||||
get => _cableName;
|
||||
set
|
||||
{
|
||||
_cableName = value;
|
||||
OnPropertyChanged(nameof(CableName));
|
||||
}
|
||||
}
|
||||
private string _motorModel;
|
||||
/// <summary>
|
||||
/// 电机型号
|
||||
/// </summary>
|
||||
public string MotorModel
|
||||
{
|
||||
get => _motorModel;
|
||||
set
|
||||
{
|
||||
_motorModel = value;
|
||||
OnPropertyChanged(nameof(MotorModel));
|
||||
}
|
||||
}
|
||||
|
||||
private string _axisNo;
|
||||
/// <summary>
|
||||
/// 轴号
|
||||
/// </summary>
|
||||
public string AxisNo
|
||||
{
|
||||
get => _axisNo;
|
||||
set
|
||||
{
|
||||
_axisNo = value;
|
||||
OnPropertyChanged(nameof(AxisNo));
|
||||
OnPropertyChanged(nameof(CableModelNo));
|
||||
}
|
||||
}
|
||||
|
||||
private string _drawingNo;
|
||||
/// <summary>
|
||||
/// 图号
|
||||
/// </summary>
|
||||
public string DrawingNo
|
||||
{
|
||||
get => _drawingNo;
|
||||
set
|
||||
{
|
||||
_drawingNo = value;
|
||||
OnPropertyChanged(nameof(DrawingNo));
|
||||
}
|
||||
}
|
||||
|
||||
private int _currentLine;
|
||||
/// <summary>
|
||||
/// 当前段号
|
||||
/// </summary>
|
||||
public int CurrentLine
|
||||
{
|
||||
get => _currentLine;
|
||||
set
|
||||
{
|
||||
_currentLine = value;
|
||||
OnPropertyChanged(nameof(CurrentLine));
|
||||
}
|
||||
}
|
||||
private int _lineCount;
|
||||
/// <summary>
|
||||
/// 总段数
|
||||
/// </summary>
|
||||
public int LineCount
|
||||
{
|
||||
get => _lineCount;
|
||||
set
|
||||
{
|
||||
_lineCount = value;
|
||||
OnPropertyChanged(nameof(LineCount));
|
||||
}
|
||||
}
|
||||
|
||||
private double _length;
|
||||
/// <summary>
|
||||
/// 长度
|
||||
/// </summary>
|
||||
public double Length
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsPowerLine)
|
||||
{
|
||||
return PowerLineLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
return EncoderLineLength;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
_length = value;
|
||||
OnPropertyChanged(nameof(Length));
|
||||
}
|
||||
}
|
||||
private bool _isFlexibility;
|
||||
/// <summary>
|
||||
/// 是否高柔
|
||||
/// </summary>
|
||||
public bool IsFlexibility
|
||||
{
|
||||
get => _isFlexibility;
|
||||
set
|
||||
{
|
||||
_isFlexibility = value;
|
||||
OnPropertyChanged(nameof(IsFlexibility));
|
||||
OnPropertyChanged(nameof(CableModelNo));
|
||||
}
|
||||
}
|
||||
|
||||
private double _powerLineLength;
|
||||
/// <summary>
|
||||
/// 动力线长度
|
||||
/// </summary>
|
||||
public double PowerLineLength
|
||||
{
|
||||
get { return _powerLineLength; }
|
||||
set
|
||||
{
|
||||
_powerLineLength = value;
|
||||
OnPropertyChanged(nameof(PowerLineLength));
|
||||
OnPropertyChanged(nameof(CableModelNo));
|
||||
}
|
||||
}
|
||||
private double _encoderLineLength;
|
||||
/// <summary>
|
||||
/// 编码器线长度
|
||||
/// </summary>
|
||||
public double EncoderLineLength
|
||||
{
|
||||
get { return _encoderLineLength; }
|
||||
set
|
||||
{
|
||||
_encoderLineLength = value;
|
||||
OnPropertyChanged(nameof(EncoderLineLength));
|
||||
OnPropertyChanged(nameof(CableModelNo));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private string _cableFlag;
|
||||
/// <summary>
|
||||
/// 线材标识
|
||||
/// </summary>
|
||||
public string CableFlag
|
||||
{
|
||||
get
|
||||
{
|
||||
return _cableFlag;
|
||||
}
|
||||
set
|
||||
{
|
||||
_cableFlag = value;
|
||||
OnPropertyChanged(nameof(CableFlag));
|
||||
}
|
||||
}
|
||||
private string _cableType;
|
||||
/// <summary>
|
||||
/// 线材类型
|
||||
/// </summary>
|
||||
public string CableType
|
||||
{
|
||||
get { return _cableType; }
|
||||
set
|
||||
{
|
||||
_cableType = value;
|
||||
OnPropertyChanged(nameof(CableType));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 线材连接方式
|
||||
/// </summary>
|
||||
private string _cableConnectionClass;
|
||||
/// <summary>
|
||||
/// <inheritdoc cref="_cableConnectionClass"/>
|
||||
/// </summary>
|
||||
public string CableConnectionClass
|
||||
{
|
||||
get { return _cableConnectionClass; }
|
||||
set
|
||||
{
|
||||
_cableConnectionClass = value;
|
||||
OnPropertyChanged(nameof(CableConnectionClass));
|
||||
|
||||
}
|
||||
}
|
||||
private bool _isEncoderLine;
|
||||
/// <summary>
|
||||
/// 是否编码器线
|
||||
/// </summary>
|
||||
public bool IsEncoderLine
|
||||
{
|
||||
get => _isEncoderLine;
|
||||
set
|
||||
{
|
||||
_isEncoderLine = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
private bool _isPowerLine;
|
||||
/// <summary>
|
||||
/// 是否动力线
|
||||
/// </summary>
|
||||
public bool IsPowerLine
|
||||
{
|
||||
get => _isPowerLine;
|
||||
set
|
||||
{
|
||||
_isPowerLine = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private string _cableModelNo;
|
||||
public string CableModelNo
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Motor == null) return "";
|
||||
string drawNo = "MR-";
|
||||
var cableFlag = GetCableModelFlag(Motor?.MotorPower, CableType, CableConnectionClass, IsFlexibility);
|
||||
if (string.IsNullOrWhiteSpace(cableFlag))
|
||||
{
|
||||
DrawingNo = "";
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
drawNo += cableFlag + "-";
|
||||
}
|
||||
//编码器线+动力线 编码器线+动力刹车线
|
||||
if (CableType is "编码器线+动力线" or "编码器线+动力刹车线") // 组合线
|
||||
drawNo += "A1-";
|
||||
|
||||
if (IsFlexibility)
|
||||
{
|
||||
drawNo += "H-";
|
||||
}
|
||||
else
|
||||
{
|
||||
drawNo += "L-";
|
||||
|
||||
}
|
||||
if (IsComplexLine)
|
||||
{
|
||||
drawNo += $"{EncoderLineLength}-{PowerLineLength}";
|
||||
}
|
||||
else if (IsEncoderLine)
|
||||
{
|
||||
drawNo += $"{EncoderLineLength}";
|
||||
}
|
||||
else if (IsPowerLine)
|
||||
{
|
||||
drawNo += $"{PowerLineLength}";
|
||||
|
||||
}
|
||||
if (!string.IsNullOrEmpty(AxisNo))
|
||||
{
|
||||
drawNo += "(";
|
||||
drawNo += $"{AxisNo}";
|
||||
if (CableConnectionClass != "直通")
|
||||
//if (!(CableType is "编码器线+动力线" or "编码器线+动力刹车线"))
|
||||
drawNo += $"-{CurrentLine} / {LineCount}";
|
||||
drawNo += ")";
|
||||
|
||||
}
|
||||
//if (isUpdateDrawNo)
|
||||
{
|
||||
DrawingNo = GetCableDrawNo();
|
||||
}
|
||||
return drawNo;
|
||||
}
|
||||
set
|
||||
{
|
||||
//_cableModelNo = value;
|
||||
OnPropertyChanged(nameof(CableModelNo));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取线对应图纸编号
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private string GetCableDrawNo()
|
||||
{
|
||||
var data = MotorExcelHelper.Instance.GetCableDatas();
|
||||
//var data = Core.CoreService.GetService<LectotypeService>().GetCableDatas();
|
||||
var cableData = data.FirstOrDefault(it =>
|
||||
it.MotorPower == Motor.MotorPower
|
||||
&& it.LineType == CableType
|
||||
&& it.Type == CableConnectionClass.Replace("全段", "前段")
|
||||
&& it.IsHighFlexibility == (IsFlexibility ? "是" : "否")
|
||||
);
|
||||
if (cableData != null)
|
||||
{
|
||||
return cableData.DrawingNo;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
private string GetCableModelFlag(string motorPower, string cableType, string cableConnectionType, bool isFlexibility)
|
||||
{
|
||||
var data = MotorExcelHelper.Instance.GetCableDatas();
|
||||
//var data = Core.CoreService.GetService<LectotypeService>().GetCableDatas();
|
||||
var cableData = data?.FirstOrDefault(it =>
|
||||
it.MotorPower == motorPower
|
||||
&& it.LineType == cableType
|
||||
&& it.Type == cableConnectionType.Replace("全段", "前段")
|
||||
&& it.IsHighFlexibility == (isFlexibility ? "是" : "否"));
|
||||
if (cableData != null)
|
||||
{
|
||||
CableFlag = cableData.LineModelIdentifier;
|
||||
return CableFlag;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
private MotorModel _motor;
|
||||
public MotorModel Motor
|
||||
{
|
||||
get => _motor;
|
||||
set
|
||||
{
|
||||
_motor = value;
|
||||
OnPropertyChanged(nameof(Motor));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,225 +1,27 @@
|
|||
namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
|
||||
using MiniExcelLibs.Attributes;
|
||||
|
||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
|
||||
{
|
||||
public class LectotypeModel : CheckedModel
|
||||
public class LectotypeModel
|
||||
{
|
||||
private string _name;
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
set
|
||||
{
|
||||
_name = value;
|
||||
OnPropertyChanged(nameof(Name));
|
||||
}
|
||||
}
|
||||
private string _cableName;
|
||||
/// <summary>
|
||||
/// 线材名称 -> eg:ca_000120
|
||||
/// </summary>
|
||||
public string CableName
|
||||
{
|
||||
get => _cableName;
|
||||
set
|
||||
{
|
||||
_cableName = value;
|
||||
OnPropertyChanged(nameof(CableName));
|
||||
}
|
||||
}
|
||||
|
||||
private string _axisNo;
|
||||
/// <summary>
|
||||
/// 轴号
|
||||
/// </summary>
|
||||
public string AxisNo
|
||||
{
|
||||
get => _axisNo;
|
||||
set
|
||||
{
|
||||
_axisNo = value;
|
||||
OnPropertyChanged(nameof(AxisNo));
|
||||
}
|
||||
}
|
||||
|
||||
private string _drawingNo;
|
||||
/// <summary>
|
||||
/// 图号
|
||||
/// </summary>
|
||||
public string DrawingNo
|
||||
{
|
||||
get => _drawingNo;
|
||||
set
|
||||
{
|
||||
_drawingNo = value;
|
||||
OnPropertyChanged(nameof(DrawingNo));
|
||||
}
|
||||
}
|
||||
|
||||
private int _currentLine;
|
||||
/// <summary>
|
||||
/// 当前段号
|
||||
/// </summary>
|
||||
public int CurrentLine
|
||||
{
|
||||
get => _currentLine;
|
||||
set
|
||||
{
|
||||
_currentLine = value;
|
||||
OnPropertyChanged(nameof(CurrentLine));
|
||||
}
|
||||
}
|
||||
private int _lineCount;
|
||||
/// <summary>
|
||||
/// 总段数
|
||||
/// </summary>
|
||||
public int LineCount
|
||||
{
|
||||
get => _lineCount;
|
||||
set
|
||||
{
|
||||
_lineCount = value;
|
||||
OnPropertyChanged(nameof(LineCount));
|
||||
}
|
||||
}
|
||||
|
||||
private double _length;
|
||||
/// <summary>
|
||||
/// 长度
|
||||
/// </summary>
|
||||
public double Length
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsPowerLine)
|
||||
{
|
||||
return PowerLineLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
return EncoderLineLength;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
_length = value;
|
||||
OnPropertyChanged(nameof(Length));
|
||||
}
|
||||
}
|
||||
private bool _isFlexibility;
|
||||
/// <summary>
|
||||
/// 是否高柔
|
||||
/// </summary>
|
||||
public bool IsFlexibility
|
||||
{
|
||||
get => _isFlexibility;
|
||||
set
|
||||
{
|
||||
_isFlexibility = value;
|
||||
OnPropertyChanged(nameof(IsFlexibility));
|
||||
}
|
||||
}
|
||||
|
||||
private double _powerLineLength;
|
||||
/// <summary>
|
||||
/// 动力线长度
|
||||
/// </summary>
|
||||
public double PowerLineLength
|
||||
{
|
||||
get { return _powerLineLength; }
|
||||
set
|
||||
{
|
||||
_powerLineLength = value;
|
||||
OnPropertyChanged(nameof(PowerLineLength));
|
||||
}
|
||||
}
|
||||
private double _encoderLineLength;
|
||||
/// <summary>
|
||||
/// 编码器线长度
|
||||
/// </summary>
|
||||
public double EncoderLineLength
|
||||
{
|
||||
get { return _encoderLineLength; }
|
||||
set
|
||||
{
|
||||
_encoderLineLength = value;
|
||||
OnPropertyChanged(nameof(EncoderLineLength));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private string _cableFlag;
|
||||
/// <summary>
|
||||
/// 线材标识
|
||||
/// </summary>
|
||||
public string CableFlag
|
||||
{
|
||||
get
|
||||
{
|
||||
return _cableFlag;
|
||||
}
|
||||
set
|
||||
{
|
||||
_cableFlag = value;
|
||||
OnPropertyChanged(nameof(CableFlag));
|
||||
}
|
||||
}
|
||||
private string _cableType;
|
||||
/// <summary>
|
||||
/// 线材类型
|
||||
/// </summary>
|
||||
public string CableType
|
||||
{
|
||||
get { return _cableType; }
|
||||
set
|
||||
{
|
||||
_cableType = value;
|
||||
OnPropertyChanged(nameof(CableType));
|
||||
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 线材连接方式
|
||||
/// </summary>
|
||||
private string _cableConnectionClass;
|
||||
/// <summary>
|
||||
/// <inheritdoc cref="_cableConnectionClass"/>
|
||||
/// </summary>
|
||||
public string CableConnectionClass
|
||||
{
|
||||
get { return _cableConnectionClass; }
|
||||
set
|
||||
{
|
||||
_cableConnectionClass = value;
|
||||
OnPropertyChanged(nameof(CableConnectionClass));
|
||||
|
||||
}
|
||||
}
|
||||
private bool _isEncoderLine;
|
||||
/// <summary>
|
||||
/// 是否编码器线
|
||||
/// </summary>
|
||||
public bool IsEncoderLine
|
||||
{
|
||||
get => _isEncoderLine;
|
||||
set
|
||||
{
|
||||
_isEncoderLine = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
private bool _isPowerLine;
|
||||
/// <summary>
|
||||
/// 是否动力线
|
||||
/// </summary>
|
||||
public bool IsPowerLine
|
||||
{
|
||||
get => _isPowerLine;
|
||||
set
|
||||
{
|
||||
_isPowerLine = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
电机功率 电机型号 线材类型 类型 是否高柔 线材型号标识 线材型号 图纸编号
|
||||
*/
|
||||
[ExcelColumnName("电机功率")]
|
||||
public string MotorPower { get; set; }
|
||||
[ExcelColumnName("电机型号")]
|
||||
public string MotorModel { get; set; }
|
||||
[ExcelColumnName("线材类型")]
|
||||
public string LineType { get; set; }
|
||||
[ExcelColumnName("类型")]
|
||||
public string Type { get; set; }
|
||||
[ExcelColumnName("是否高柔")]
|
||||
public string IsHighFlexibility { get; set; }
|
||||
[ExcelColumnName("线材型号标识")]
|
||||
public string LineModelIdentifier { get; set; }
|
||||
[ExcelColumnName("线材型号")]
|
||||
public string LineModel { get; set; }
|
||||
[ExcelColumnName("图纸编号")]
|
||||
public string DrawingNo { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
|
||||
{
|
||||
public class MotorModel : CheckedModel
|
||||
{
|
||||
/// <summary>
|
||||
/// 电机功率
|
||||
/// </summary>
|
||||
private string _motorPower;
|
||||
/// <summary>
|
||||
/// <inheritdoc cref="_motorPower"/>
|
||||
/// </summary>
|
||||
public string MotorPower
|
||||
{
|
||||
get { return _motorPower; }
|
||||
set
|
||||
{
|
||||
_motorPower = value;
|
||||
OnPropertyChanged(nameof(MotorPower));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 品牌
|
||||
/// </summary>
|
||||
private string _brand;
|
||||
/// <summary>
|
||||
/// <inheritdoc cref="_brand"/>
|
||||
/// </summary>
|
||||
public string Brand
|
||||
{
|
||||
get { return _brand; }
|
||||
set
|
||||
{
|
||||
_brand = value;
|
||||
OnPropertyChanged(nameof(Brand));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 电机系列
|
||||
/// </summary>
|
||||
private string _motorSerie;
|
||||
/// <summary>
|
||||
/// <inheritdoc cref="_motorSerie"/>
|
||||
/// </summary>
|
||||
public string MotorSerie
|
||||
{
|
||||
get { return _motorSerie; }
|
||||
set
|
||||
{
|
||||
_motorSerie = value;
|
||||
OnPropertyChanged(nameof(MotorSerie));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 电机系列
|
||||
/// </summary>
|
||||
private string _motorModel;
|
||||
/// <summary>
|
||||
/// <inheritdoc cref="_motorModel"/>
|
||||
/// </summary>
|
||||
public string MotorModelStr
|
||||
{
|
||||
get { return _motorModel; }
|
||||
set
|
||||
{
|
||||
_motorModel = value;
|
||||
OnPropertyChanged(nameof(MotorModelStr));
|
||||
}
|
||||
}
|
||||
private string _axisNo;
|
||||
/// <summary>
|
||||
/// 轴号
|
||||
/// </summary>
|
||||
public string AxisNo
|
||||
{
|
||||
get => _axisNo;
|
||||
set
|
||||
{
|
||||
_axisNo = value;
|
||||
OnPropertyChanged(nameof(AxisNo));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -46,6 +46,6 @@ using System.Windows;
|
|||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
[assembly: AssemblyVersion("1.0.0.16")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.16")]
|
||||
[assembly: AssemblyInformationalVersion("1.0.0.16")]
|
||||
[assembly: AssemblyVersion("1.0.0.17")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.17")]
|
||||
[assembly: AssemblyInformationalVersion("1.0.0.17")]
|
|
@ -120,22 +120,29 @@
|
|||
<DependentUpon>LectotypeWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Models\CheckedModel.cs" />
|
||||
<Compile Include="Models\ConfigItemModel.cs" />
|
||||
<Compile Include="Models\ExcelModel.cs" />
|
||||
<Compile Include="Models\ExportModel.cs" />
|
||||
<Compile Include="Models\InsulationModel.cs" />
|
||||
<Compile Include="Models\LectotypeLineModel.cs" />
|
||||
<Compile Include="Models\LectotypeModel.cs" />
|
||||
<Compile Include="Models\LineSegmentModel.cs" />
|
||||
<Compile Include="Models\MotorModel.cs" />
|
||||
<Compile Include="Models\ReportModel.cs" />
|
||||
<Compile Include="Models\StuffedDataModel.cs" />
|
||||
<Compile Include="Models\TerminalModel.cs" />
|
||||
<Compile Include="TestWindow.xaml.cs">
|
||||
<DependentUpon>TestWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Utils\CheckedModelExt.cs" />
|
||||
<Compile Include="Utils\Consts.cs" />
|
||||
<Compile Include="Utils\DataGridType.cs" />
|
||||
<Compile Include="Utils\ExcelHelper.cs" />
|
||||
<Compile Include="Utils\FlagEnumConverter.cs" />
|
||||
<Compile Include="Utils\LambdaComparer.cs" />
|
||||
<Compile Include="Utils\LectotypeLengthDataTemplateSelector.cs" />
|
||||
<Compile Include="Utils\MotorExcelHelper.cs" />
|
||||
<Compile Include="Utils\PropertyListExt.cs" />
|
||||
<Compile Include="Utils\WireFlagType.cs" />
|
||||
<Compile Include="ViewModel\LectotypeViewModel.cs" />
|
||||
<Compile Include="ViewModel\MainViewModel.Check.cs" />
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
|
||||
|
||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
||||
{
|
||||
public static class CheckedModelExt
|
||||
{
|
||||
public static void SetError(this CheckedModel model, string errorMsg)
|
||||
{
|
||||
model.IsError = true;
|
||||
model.ErrorCount += 1;
|
||||
if (!string.IsNullOrEmpty(model.CheckedMsg))
|
||||
{
|
||||
model.CheckedMsg += "\r\n";
|
||||
}
|
||||
|
||||
model.CheckedMsg += errorMsg;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
||||
{
|
||||
public class LambdaComparer<T> : IEqualityComparer<T>
|
||||
{
|
||||
private readonly Func<T, T, bool> _lambdaComparer;
|
||||
private readonly Func<T, int> _lambdaHash;
|
||||
public LambdaComparer(Func<T, T, bool> lambdaComparer)
|
||||
: this(lambdaComparer, EqualityComparer<T>.Default.GetHashCode)
|
||||
{
|
||||
}
|
||||
public LambdaComparer(Func<T, T, bool> lambdaComparer, Func<T, int> lambdaHash)
|
||||
{
|
||||
if (lambdaComparer == null)
|
||||
throw new ArgumentNullException("lambdaComparer");
|
||||
if (lambdaHash == null)
|
||||
throw new ArgumentNullException("lambdaHash");
|
||||
_lambdaComparer = lambdaComparer;
|
||||
_lambdaHash = lambdaHash;
|
||||
}
|
||||
|
||||
public bool Equals(T x, T y)
|
||||
{
|
||||
return _lambdaComparer(x, y);
|
||||
}
|
||||
|
||||
public int GetHashCode(T obj)
|
||||
{
|
||||
return _lambdaHash(obj);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -20,8 +20,12 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
|||
}
|
||||
public override DataTemplate SelectTemplate(object item, DependencyObject container)
|
||||
{
|
||||
Type t = item.GetType();
|
||||
Type t = item?.GetType();
|
||||
string cableType = null;
|
||||
if (t == null)
|
||||
{
|
||||
return DefaultTemplate;
|
||||
}
|
||||
PropertyInfo[] properties = t.GetProperties();
|
||||
foreach (PropertyInfo pi in properties)
|
||||
{
|
||||
|
@ -37,11 +41,10 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
|||
return PowerLineTemplate;
|
||||
case "编码器线":
|
||||
return EncoderLineTemplate;
|
||||
case "动力线+编码器线":
|
||||
case "编码器线+动力线":
|
||||
return ComplexLineTemplate;
|
||||
default:
|
||||
return DefaultTemplate;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
using MiniExcelLibs;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
||||
{
|
||||
public class MotorExcelHelper
|
||||
{
|
||||
public static MotorExcelHelper Instance = new();
|
||||
|
||||
private Stream dataFileStream;
|
||||
public const string DATA_FILE_PATH = @"D:\Desktop\EPlan\线材选型";//@"\\192.168.1.160\plm系统文档\线材选型";
|
||||
private const string DATA_FILE_NAME = "线材选型数据表.xlsx";
|
||||
private const string DATA_FILE_NAME_BOM = "BOM表.xlsx";
|
||||
private const string TEMPLATE_FILE_NAME = "下单定制线模板.xlsx";
|
||||
public void ReadDataToStream()
|
||||
{
|
||||
var file = Path.Combine(DATA_FILE_PATH, DATA_FILE_NAME);
|
||||
if (File.Exists(file))
|
||||
{
|
||||
var bytes = File.ReadAllBytes(file);
|
||||
dataFileStream = new MemoryStream(bytes);
|
||||
}
|
||||
}
|
||||
public List<LectotypeModel> GetCableDatas()
|
||||
{
|
||||
if (dataFileStream == null) return null;
|
||||
//var filePath = "D:\\Desktop\\Data\\三菱伺服HK-KT线材选型BOM表_按程序格式整理后.xlsx";
|
||||
var data = MiniExcel.Query<LectotypeModel>(dataFileStream, "HK-KT").ToList();
|
||||
//MiniExcel.Query()
|
||||
return data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 1. 100W,
|
||||
/// 2. 100W带刹车,
|
||||
/// 3. 200W,
|
||||
/// 4. 200W带刹车,
|
||||
/// 5. 400W低惯量,
|
||||
/// 6. 400W低惯量带刹车,
|
||||
/// 7. 750W低惯量,
|
||||
/// 8. 750W低惯量带刹车,
|
||||
/// 9. 1000W(220V),
|
||||
/// 10.1000W带刹车(220V),
|
||||
/// 11.1500W(220V),
|
||||
/// 12.1500带刹车(220V),
|
||||
/// </summary>
|
||||
public List<ConfigItemModel> GetMotorPowers()
|
||||
{
|
||||
//return new List<ConfigItemModel>
|
||||
//{
|
||||
// new(){ ItemName = "100W", ItemValue = "100W"},
|
||||
// new(){ ItemName = "100W带刹车", ItemValue = "100W带刹车"},
|
||||
// new(){ ItemName = "200W", ItemValue = "200W"},
|
||||
// new(){ ItemName = "200W带刹车", ItemValue = "200W带刹车"},
|
||||
// new(){ ItemName = "400W低惯量", ItemValue = "400W低惯量"},
|
||||
// new(){ ItemName = "400W低惯量带刹车", ItemValue = "400W低惯量带刹车"},
|
||||
// new(){ ItemName = "750W低惯量", ItemValue = "750W低惯量"},
|
||||
// new(){ ItemName = "750W低惯量带刹车", ItemValue = "750W低惯量带刹车"},
|
||||
// new(){ ItemName = "1000W(220V)", ItemValue = "1000W(220V)"},
|
||||
// new(){ ItemName = "1000W带刹车(220V)", ItemValue = "1000W带刹车(220V)"},
|
||||
// new(){ ItemName = "1500W(220V)", ItemValue = "1500W(220V)"},
|
||||
// new(){ ItemName = "1500带刹车(220V)", ItemValue = "1500带刹车(220V)"},
|
||||
//};
|
||||
var data = MiniExcel.Query(dataFileStream, sheetName: "电机驱动器", startCell: "A2", useHeaderRow: true).OrderBy(it => it.序号).Select(it => new ConfigItemModel
|
||||
{
|
||||
ItemName = it.功率,
|
||||
ItemValue = it.功率,
|
||||
ItemFlag = it.型号
|
||||
}).ToList();
|
||||
|
||||
return data.Distinct(new LambdaComparer<ConfigItemModel>(
|
||||
(a, b) => a.ItemName == b.ItemName && a.ItemValue == b.ItemValue && b.ItemFlag == a.ItemFlag,
|
||||
obj => obj.ToString().GetHashCode()
|
||||
)).ToList();
|
||||
}
|
||||
|
||||
|
||||
public void CloseStream()
|
||||
{
|
||||
dataFileStream.Close();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
using EPLAN.Harness.Core.Props.Collections;
|
||||
using System.Linq;
|
||||
|
||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
||||
{
|
||||
public static class PropertyListExt
|
||||
{
|
||||
public static bool IsContarins(this PropertyList list, string value)
|
||||
{
|
||||
return list.Any(item =>
|
||||
{
|
||||
if (item.ValueHolder.IsStrValEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return item.PropertyName?.Equals(value) ?? false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,21 +1,27 @@
|
|||
using EPLAN.Harness.Common.Extensions;
|
||||
using EPLAN.Harness.Core.Controls;
|
||||
using EPLAN.Harness.Core.Utils;
|
||||
using EPLAN.Harness.ProjectCore;
|
||||
using EPLAN.Harness.ProjectCore.Occurrences;
|
||||
using EPLAN.Harness.ProjectCore.Occurrences.Designer;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
||||
{
|
||||
public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
||||
{
|
||||
private List<LectotypeModel> _wires;
|
||||
public List<LectotypeModel> Wires
|
||||
private List<LectotypeLineModel> _wires;
|
||||
public List<LectotypeLineModel> Wires
|
||||
{
|
||||
get => _wires;
|
||||
set
|
||||
|
@ -24,8 +30,64 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
private List<LectotypeModel> _stuffedWires;
|
||||
public List<LectotypeModel> StuffedWires
|
||||
|
||||
private List<LectotypeLineModel> _oriWires = [];
|
||||
public List<LectotypeLineModel> OriWires
|
||||
{
|
||||
get => _oriWires;
|
||||
set
|
||||
{
|
||||
_oriWires = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
private LectotypeLineModel _selectedItem;
|
||||
public LectotypeLineModel SelectedItem
|
||||
{
|
||||
get => _selectedItem;
|
||||
set
|
||||
{
|
||||
_selectedItem = value;
|
||||
OnPropertyChanged();
|
||||
OnSelectedItemChange();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private ObservableCollection<LectotypeLineModel> _selectedSubItem = [];
|
||||
public ObservableCollection<LectotypeLineModel> SelectedSubItem
|
||||
{
|
||||
get => _selectedSubItem;
|
||||
set
|
||||
{
|
||||
_selectedSubItem = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private DataGridRowDetailsVisibilityMode _detailsShowMode = DataGridRowDetailsVisibilityMode.Collapsed;
|
||||
public DataGridRowDetailsVisibilityMode DetailsShowMode
|
||||
{
|
||||
get => _detailsShowMode;
|
||||
set
|
||||
{
|
||||
_detailsShowMode = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
private List<MotorModel> _motors = [];
|
||||
public List<MotorModel> Motors
|
||||
{
|
||||
get => _motors;
|
||||
set
|
||||
{
|
||||
_motors = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
private List<LectotypeLineModel> _stuffedWires;
|
||||
public List<LectotypeLineModel> StuffedWires
|
||||
{
|
||||
get => _stuffedWires;
|
||||
set
|
||||
|
@ -34,11 +96,19 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
public void LoadData()
|
||||
|
||||
public List<string> Drivers { get; set; } = [
|
||||
"脉冲型驱动器",
|
||||
"总线型驱动器(CCLINK IE TSN)",
|
||||
"总线型驱动器(SSCNET III/H)",
|
||||
"总线型驱动器(EtherCAT)"
|
||||
];
|
||||
|
||||
public Task LoadData()
|
||||
{
|
||||
if (string.IsNullOrEmpty(docId))
|
||||
{
|
||||
return;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
var doc = FlexProject.CurrentProject.GetDesigners().FirstOrDefault(designer => designer.ID == docId);
|
||||
// 获取所有存在的
|
||||
|
@ -47,12 +117,12 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
// 所有的线材
|
||||
// OccCableForked 多芯线? 对应设计器中Cables(电缆)下的内容
|
||||
// OccWire 导线 对应设计器中Wires(导线)下的内容
|
||||
List<LectotypeModel> cables = [.. wires
|
||||
List<LectotypeLineModel> cables = [.. wires
|
||||
.Where(it =>
|
||||
it.GetType() == typeof(OccCableForked)
|
||||
//|| it.GetType() == typeof(OccWire)
|
||||
)
|
||||
//.Where(it => !string.IsNullOrEmpty(GetAxisNo((it.Children.First() as OccCablesInsulatorGraph).Imprint)) )
|
||||
.Where(it => !string.IsNullOrEmpty(GetAxisNo((it.Children.First() as OccCablesInsulatorGraph).Imprint)) )
|
||||
//.Where(it =>it.PartStatus == EPLAN.Harness.Core.LibEntities.Enums.PartStatus.Released)
|
||||
.Select(it =>
|
||||
{
|
||||
|
@ -72,9 +142,9 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
}
|
||||
}
|
||||
|
||||
return new LectotypeModel
|
||||
return new LectotypeLineModel
|
||||
{
|
||||
Name= occCable.LibraryName,
|
||||
Name= GetLectotypeName(occCable.LibraryName),
|
||||
CableName = occCable.Name,
|
||||
AxisNo = GetAxisNo(insulatorGraph.Imprint),
|
||||
CurrentLine = GetCableLine(insulatorGraph.Imprint),
|
||||
|
@ -90,12 +160,24 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
.OrderBy(it => it?.CableName ?? "")];
|
||||
|
||||
Wires = StuffData(cables);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
public string GetLectotypeName(string libraryName)
|
||||
{
|
||||
if (libraryName.Contains("&"))
|
||||
{
|
||||
return libraryName.Split('&')[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
return libraryName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<LectotypeModel> StuffData(List<LectotypeModel> cables)
|
||||
public List<LectotypeLineModel> StuffData(List<LectotypeLineModel> cables)
|
||||
{
|
||||
List<LectotypeModel> datas = [];
|
||||
List<LectotypeLineModel> datas = [];
|
||||
OriWires.Clear();
|
||||
//1 整理数据
|
||||
cables.ForEach(it =>
|
||||
{
|
||||
|
@ -109,6 +191,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
it.LineCount = lineCount;
|
||||
if (it.CurrentLine == 1)
|
||||
{
|
||||
|
||||
it.CableConnectionClass = "前段";
|
||||
}
|
||||
else if (it.CurrentLine > 1 && it.CurrentLine < lineCount)
|
||||
|
@ -118,6 +201,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
}
|
||||
else if (it.CurrentLine == lineCount)
|
||||
{
|
||||
|
||||
it.CableConnectionClass = "尾段";
|
||||
}
|
||||
if (string.IsNullOrEmpty(axisNo))
|
||||
|
@ -127,11 +211,37 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
it.ErrorCount += 1;
|
||||
it.CheckedMsg += "轴号不能为空!\r\n";
|
||||
}
|
||||
if (datas.Any(i => i.AxisNo == it.AxisNo && it.CableType == i.CableType && it.CurrentLine == i.CurrentLine))
|
||||
{
|
||||
it.IsError = true;
|
||||
it.CheckedMsg = "线段重复!";
|
||||
}
|
||||
|
||||
if (Motors != null && Motors.Any())
|
||||
{
|
||||
var motor = Motors.FirstOrDefault(motor => motor.AxisNo == it.AxisNo);
|
||||
if (motor != null)
|
||||
{
|
||||
it.Motor = motor;
|
||||
}
|
||||
else
|
||||
{
|
||||
it.IsError = true;
|
||||
it.ErrorCount = 1;
|
||||
it.CheckedMsg = "未匹配到电机";
|
||||
}
|
||||
}
|
||||
if (it.Name.StartsWith("T"))
|
||||
{
|
||||
it.IsFlexibility = true;
|
||||
}
|
||||
|
||||
// 先把非第一行的数据添加到数据集合中
|
||||
if (it.CurrentLine != 1)
|
||||
{
|
||||
datas.Add(it);
|
||||
}
|
||||
OriWires.Add(it.MemoryClone());
|
||||
});
|
||||
//2 合并同轴号的第一条数据
|
||||
cables.Where(it => it.CurrentLine == 1).ForEach(it =>
|
||||
|
@ -144,15 +254,19 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
{
|
||||
if (existLine.IsPowerLine)
|
||||
{
|
||||
existLine.SeqNo = 3;
|
||||
existLine.EncoderLineLength = it.EncoderLineLength;
|
||||
|
||||
}
|
||||
else if (existLine.IsEncoderLine)
|
||||
{
|
||||
existLine.SeqNo = 2;
|
||||
|
||||
existLine.PowerLineLength = it.PowerLineLength;
|
||||
}
|
||||
}
|
||||
existLine.CableType = "动力线+编码器线";
|
||||
existLine.IsComplexLine = true;
|
||||
existLine.CableType = "编码器线+动力线";
|
||||
if (datas.Any(i => i.AxisNo == it.AxisNo && i.CurrentLine != 1))
|
||||
{
|
||||
|
||||
|
@ -161,16 +275,34 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
else
|
||||
{
|
||||
existLine.CableConnectionClass = "直通";
|
||||
}
|
||||
// 多端线时,第一条线取最大段数
|
||||
var lineCount = datas.Where(data => data.AxisNo == existLine.AxisNo).Max(data => data.LineCount);
|
||||
existLine.LineCount = lineCount;
|
||||
|
||||
if (existLine.IsComplexLine)
|
||||
{
|
||||
existLine.SeqNo = 1;
|
||||
existLine.Name = "";
|
||||
existLine.CableName = OriWires
|
||||
.Where(data => data.AxisNo == existLine.AxisNo && data.CurrentLine == 1)
|
||||
.Select(data => data.CableName)
|
||||
.Aggregate("/");
|
||||
}
|
||||
|
||||
if ((it.IsFlexibility || existLine.IsFlexibility) && it.IsFlexibility != existLine.IsFlexibility)
|
||||
{
|
||||
existLine.SetError("请检查是否使用正确的高柔线");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
it.IsComplexLine = true;
|
||||
datas.Add(it);
|
||||
}
|
||||
});
|
||||
|
||||
return datas.OrderBy(it => it.CurrentLine).ToList();
|
||||
return [.. datas.OrderByDescending(it => it.SeqNo)];
|
||||
}
|
||||
/// <summary>
|
||||
/// L -> 动力线 N -> 编码器线
|
||||
|
@ -252,17 +384,86 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
|
||||
public void ToSource(string cableName)
|
||||
{
|
||||
var doc = FlexProject.CurrentProject.GetDesigners().FirstOrDefault(designer => designer.ID == docId);
|
||||
var cable = doc.GetOccurrenceByName(cableName, typeof(OccCableForked));
|
||||
if (cable != null)
|
||||
try
|
||||
{
|
||||
doc.SelectSet.Clear();
|
||||
var oriOcc = SelfControler<BaseOccurrence>.FindInstance(cable.ID);
|
||||
oriOcc.SetVisibility(true, null);
|
||||
var doc = FlexProject.CurrentProject.GetDesigners().FirstOrDefault(designer => designer.ID == docId);
|
||||
var cable = doc.GetOccurrenceByName(cableName, typeof(OccCableForked));
|
||||
if (cable != null)
|
||||
{
|
||||
doc.SelectSet.Clear();
|
||||
var oriOcc = SelfControler<BaseOccurrence>.FindInstance(cable.ID);
|
||||
oriOcc.SetVisibility(true, null);
|
||||
doc.SelectSet.Add(oriOcc.Children.First());
|
||||
doc.FitToSelectSet();
|
||||
doc.SelectSet.OnSelectionChanged();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FlexMessageBox.Error(ex.Message);
|
||||
}
|
||||
}
|
||||
public Task GetMotors()
|
||||
{
|
||||
var motorsData = new List<MotorModel>();
|
||||
var doc = FlexProject.CurrentProject.GetDesigners().FirstOrDefault(designer => designer.ID == docId);
|
||||
var parts = doc.GetOrganizerOccurrences(docId)
|
||||
.Where(occ => occ.Type == OCC_TYPE.wPART)
|
||||
.Where(occ => occ.Name?.StartsWith("HK-KT") ?? false)
|
||||
//.Where(occ => occ.Properties?.IsContarins("轴号") ?? false)
|
||||
.ToList();
|
||||
var motorPowerDatas = MotorExcelHelper.Instance.GetMotorPowers();
|
||||
parts.ForEach(part =>
|
||||
{
|
||||
var motorPowerData = motorPowerDatas.FirstOrDefault(it => it.ItemFlag == part.Name);
|
||||
var axisNo = part.Properties.IsContarins("轴号") ? part.Properties.FirstOrDefault(it => it.PropertyName == "轴号").GetDisplayValue() : "";
|
||||
|
||||
doc.SelectSet.Add(oriOcc.Children.First());
|
||||
doc.FitToSelectSet();
|
||||
doc.SelectSet.OnSelectionChanged();
|
||||
var motor = new MotorModel
|
||||
{
|
||||
MotorModelStr = part.Name,
|
||||
AxisNo = axisNo,
|
||||
IsError = string.IsNullOrEmpty(axisNo)
|
||||
};
|
||||
if (motorPowerData != null)
|
||||
{
|
||||
motor.MotorPower = motorPowerData.ItemValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
motor.SetError("电机型号不存在于资料表中");
|
||||
}
|
||||
if (string.IsNullOrEmpty(axisNo))
|
||||
{
|
||||
motor.SetError("未填写轴号信息!");
|
||||
}
|
||||
motorsData?.Add(motor);
|
||||
});
|
||||
Motors = motorsData;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private void OnSelectedItemChange()
|
||||
{
|
||||
if (this.SelectedItem != null)
|
||||
{
|
||||
SelectedSubItem.Clear();
|
||||
DetailsShowMode = DataGridRowDetailsVisibilityMode.Collapsed;
|
||||
|
||||
var subItems = OriWires.Where(it => it.AxisNo == SelectedItem.AxisNo && it.CurrentLine == SelectedItem.CurrentLine && it.CurrentLine == 1).ToList();
|
||||
if (subItems.Count > 1)
|
||||
{
|
||||
subItems.ForEach(SelectedSubItem.Add);
|
||||
DetailsShowMode = DataGridRowDetailsVisibilityMode.VisibleWhenSelected;
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectedSubItem.Clear();
|
||||
DetailsShowMode = DataGridRowDetailsVisibilityMode.Collapsed;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectedSubItem.Clear();
|
||||
DetailsShowMode = DataGridRowDetailsVisibilityMode.Collapsed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -164,6 +164,17 @@ public partial class MainViewModel : INotifyPropertyChanged
|
|||
FormUISettings.Instance.SaveSingleton();
|
||||
}
|
||||
}
|
||||
|
||||
private bool _toSourceAndMinSelf;
|
||||
public bool ToSourceAndMinSelf
|
||||
{
|
||||
get => _toSourceAndMinSelf;
|
||||
set
|
||||
{
|
||||
_toSourceAndMinSelf = value;
|
||||
OnPropertyChanged(nameof(ToSourceAndMinSelf));
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public Task<List<DataGridTextColumn>> GetColumns(List<ReportColumn> columns)
|
||||
|
|
|
@ -8,7 +8,7 @@ using System.Reflection;
|
|||
|
||||
namespace Sinvo.EplanHpD.Plugin
|
||||
{
|
||||
public class DesignPluginEntry //: IHpDPlugin
|
||||
public class DesignPluginEntry : EPLAN.Harness.API.Plugins.IHpDPlugin
|
||||
{
|
||||
public string Name => "兴禾ProD插件-3D";
|
||||
|
||||
|
@ -57,7 +57,7 @@ namespace Sinvo.EplanHpD.Plugin
|
|||
|
||||
public void Terminate()
|
||||
{
|
||||
//throw new NotImplementedException();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue