From 143b0c366038447fe9888ae107bfe9df39268cac Mon Sep 17 00:00:00 2001 From: lihanbo Date: Fri, 8 Nov 2024 08:34:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E7=94=B5=E7=BC=86=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=A4=84=E7=90=86=E5=92=8C=E6=A3=80=E6=9F=A5=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在 `CheckTest.cs` 文件中,添加了多个测试方法,包括 `DPETerminalCheckTest`、`DPETerminalCrossSectionCheckTest` 和 `TerminalCheckTest`,用于检查不同端子的测试逻辑。 在 `AssemblyInfo.cs` 文件中,更新了程序集版本号和文件版本号。 在 `StuffTest.cs` 文件中,注释掉了一些断言语句,并添加了一个新的测试方法 `StuffedNameTubeTest`,用于测试号码管处理逻辑。 在 `LectotypeWindow.xaml` 文件中,添加了 `util` 命名空间引用,并定义了多个 `ControlTemplate` 模板和一个 `LectotypeLengthDataTemplateSelector` 模板选择器,用于根据线材类型选择不同的显示模板。同时,将 `DataGrid` 控件替换为 `ListView` 控件,并添加了上下文菜单和样式触发器。 在 `LectotypeWindow.xaml.cs` 文件中,添加了 `ToSourceMenuItem_Click` 方法,用于处理上下文菜单项的点击事件。 在 `MainWindow.xaml.cs` 文件中,重构了 `AddToDesignerSelectSet` 方法,添加了异常处理逻辑。 在 `Sinvo.EplanHpD.Plugin.WPFUI.csproj` 文件中,添加了 `LectotypeLengthDataTemplateSelector.cs` 文件的编译项。 在 `ExcelHelper.cs` 文件中,修改了 `GetWireTerminalMappingTable` 方法的过滤逻辑。 新增了 `LectotypeLengthDataTemplateSelector.cs` 文件,定义了 `LectotypeLengthDataTemplateSelector` 类,用于根据线材类型选择不同的数据模板。 在 `LectotypeViewModel.cs` 文件中: * 添加了对 `EPLAN.Harness.ProjectCore.Occurrences` 命名空间的引用。 * 添加了 `StuffedWires` 属性及其对应的私有字段 `_stuffedWires`。 * 在 `LoadData` 方法中,添加了对 `StuffData` 方法的调用,并将结果赋值给 `Wires`。 * 添加了 `StuffData` 方法,用于整理和合并电缆数据。 * 在 `ToSource` 方法中,添加了根据电缆名称获取设计器并设置可见性的逻辑。 * 修改了 `CableType` 的默认值从 "位置类型" 改为 "未知类型"。 在 `MainViewModel.Check.cs` 文件中: * 添加了 `CheckDPETerminals` 方法,用于检查地排端子。 * 修改了 `CheckTerminals` 方法,移除了对 `D-PE` 前缀的特殊处理逻辑。 * 修改了 `GetD_PECanUsedTerminal` 方法,注释掉了获取不包含前缀的端子的逻辑。 在 `DesignPluginEntry.cs` 文件中: * 注释掉了 `DesignPluginEntry` 类实现的 `IHpDPlugin` 接口。 在 `AssemblyInfo.cs` 文件中: * 更新了程序集版本号,从 `1.0.0.6` 更新到 `1.0.0.14`。 --- Sinvo.EplanHpD.Plugin.Test/CheckTest.cs | 110 +++++++++++++ .../Properties/AssemblyInfo.cs | 4 +- Sinvo.EplanHpD.Plugin.Test/StuffTest.cs | 41 ++++- .../LectotypeWindow.xaml | 151 ++++++++++++++---- .../LectotypeWindow.xaml.cs | 14 +- .../MainWindow.xaml.cs | 40 +++-- .../Properties/AssemblyInfo.cs | 6 +- .../Sinvo.EplanHpD.Plugin.WPFUI.csproj | 1 + .../Utils/ExcelHelper.cs | 2 +- .../LectotypeLengthDataTemplateSelector.cs | 48 ++++++ .../ViewModel/LectotypeViewModel.cs | 94 ++++++++++- .../ViewModel/MainViewModel.Check.cs | 36 +++-- Sinvo.EplanHpD.Plugin/DesignPluginEntry.cs | 3 +- .../Properties/AssemblyInfo.cs | 6 +- 14 files changed, 476 insertions(+), 80 deletions(-) create mode 100644 Sinvo.EplanHpD.Plugin.WPFUI/Utils/LectotypeLengthDataTemplateSelector.cs diff --git a/Sinvo.EplanHpD.Plugin.Test/CheckTest.cs b/Sinvo.EplanHpD.Plugin.Test/CheckTest.cs index b5466e5..1662d0d 100644 --- a/Sinvo.EplanHpD.Plugin.Test/CheckTest.cs +++ b/Sinvo.EplanHpD.Plugin.Test/CheckTest.cs @@ -239,6 +239,116 @@ w_00196 BK 黑色RV1.5-CE/定制 42012300001005 C45-1.5-CE/定制 4202010000 } + [TestMethod("D-PE端子检查测试")] + public void DPETerminalCheckTest() + { + var vm = new MainViewModel(); + var result = new StuffedDataModel + { + WireName = "w_00196", + WireColor = "BK", + WireModel = "黄绿色RV2.5-CE/定制", + WireCode = "42012300001005", + FrontTerminalModel = "SNB2-4-CE/定制", + FrontTerminalMaterialCode = "42020100000427", + FrontStripLength = "8 mm", + RearTerminalModel = "RNB2-4-CE/定制", + RearTerminalMaterialCode = "42020100000803", + RearStripLength = "7.2 mm", + CrossSection = "1.5", + WireLength = "367", + WireNumber = "L1SSR527", + Imprint = "D-PESSR527", + Model = "RV-BK-1x1.5-367-16×N2-D-PESSR527", + Quantity = 1, + NumberTubeContent = "白色号码管φ3/定制", + NumberTubeMaterialNo = "42020100000003", + DiscolorationDesc = "V-1.5-CE(褐色)/定制", + Insulation = new InsulationModel() + { + Specification = "V-1.5-CE(褐色)/定制", + MaterialCode = "42013500000414" + }, + }; + + + vm.CheckDPETerminals(result); + Assert.IsTrue(result.IsError); + } + [TestMethod("D-PE端子线径检查测试")] + public void DPETerminalCrossSectionCheckTest() + { + + var vm = new MainViewModel(); + var result = new StuffedDataModel + { + WireName = "w_00196", + WireColor = "BK", + WireModel = "黄绿色RV16.0-CE/定制", + WireCode = "42020100000550", + FrontTerminalModel = "C45-16-CE/定制", + FrontTerminalMaterialCode = "42020100000607", + FrontStripLength = "8 mm", + RearTerminalModel = "SC16-10-CE/定制", + RearTerminalMaterialCode = "42020100000828", + RearStripLength = "7.2 mm", + CrossSection = "16", + WireLength = "367", + WireNumber = "L1SSR527", + Imprint = "D-PESSR527", + Model = "RV-BK-1x1.5-367-16×N2-D-PESSR527", + Quantity = 1, + NumberTubeContent = "白色号码管φ3/定制", + NumberTubeMaterialNo = "42020100000003", + DiscolorationDesc = "V-1.5-CE(褐色)/定制", + Insulation = new InsulationModel() + { + Specification = "V-1.5-CE(褐色)/定制", + MaterialCode = "42013500000414" + }, + }; + + + vm.CheckDPETerminals(result); + Assert.IsFalse(result.IsError); + } + [TestMethod("端子检查测试")] + public void TerminalCheckTest() + { + + var vm = new MainViewModel(); + var result = new StuffedDataModel + { + WireName = "w_00196", + WireColor = "BK", + WireModel = "黄绿色RV2.5-CE/定制", + WireCode = "42012300001005", + FrontTerminalModel = "SNB2-4-CE/定制", + FrontTerminalMaterialCode = "42020100000427", + FrontStripLength = "8 mm", + RearTerminalModel = "RNB2-4-CE/定制", + RearTerminalMaterialCode = "42020100000803", + RearStripLength = "7.2 mm", + CrossSection = "1.5", + WireLength = "367", + WireNumber = "L1SSR527", + Imprint = "L1SSR527", + Model = "RV-BK-1x1.5-367-16×N2-D-PESSR527", + Quantity = 1, + NumberTubeContent = "白色号码管φ3/定制", + NumberTubeMaterialNo = "42020100000003", + DiscolorationDesc = "V-1.5-CE(褐色)/定制", + Insulation = new InsulationModel() + { + Specification = "V-1.5-CE(褐色)/定制", + MaterialCode = "42013500000414" + }, + }; + + + vm.CheckDPETerminals(result); + Assert.IsFalse(result.IsError); + } } } diff --git a/Sinvo.EplanHpD.Plugin.Test/Properties/AssemblyInfo.cs b/Sinvo.EplanHpD.Plugin.Test/Properties/AssemblyInfo.cs index f8931e4..78d3e7d 100644 --- a/Sinvo.EplanHpD.Plugin.Test/Properties/AssemblyInfo.cs +++ b/Sinvo.EplanHpD.Plugin.Test/Properties/AssemblyInfo.cs @@ -16,5 +16,5 @@ using System.Runtime.InteropServices; [assembly: Guid("aec39474-528b-4da8-b650-99189acb7a2c")] // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.6")] -[assembly: AssemblyFileVersion("1.0.0.6")] +[assembly: AssemblyVersion("1.0.0.13")] +[assembly: AssemblyFileVersion("1.0.0.8")] diff --git a/Sinvo.EplanHpD.Plugin.Test/StuffTest.cs b/Sinvo.EplanHpD.Plugin.Test/StuffTest.cs index fee5191..64a4176 100644 --- a/Sinvo.EplanHpD.Plugin.Test/StuffTest.cs +++ b/Sinvo.EplanHpD.Plugin.Test/StuffTest.cs @@ -91,13 +91,50 @@ Project = "放卷2", ConnectorTo = "RNB8-8/定制", ConnectorToERPNr = "42020100000148", StripLengthTo = "8 mm" - } + }, + }).Result; - Assert.IsTrue(result.Count == 3); + //Assert.IsTrue(result.Count == 4); Assert.IsTrue(result.Where(it => it.Imprint == "EC5L1").First().WireColor == "LBU"); Assert.IsTrue(result.Where(it => it.Imprint == "EC5L2").First().WireColor == "BUWH"); Assert.IsTrue(result.Where(it => it.Imprint == "EC5L3").First().WireColor == "BK"); + //Assert.IsTrue(result.Where(it => it.Imprint == "D-PE").First().WireColor == "GNYE"); + //Assert.IsTrue(result.Where(it => it.Imprint == "D-PE").First().NumberTubeSpec == "黄绿色热缩管φ12/定制"); } + [TestMethod("号码管处理测试")] + public void StuffedNameTubeTest() + { + + var vm = new MainViewModel(); + var result = vm.StuffData(new List + { + /* +序号 项目 归属机构 电缆名称 规格型号 品牌 电线标码 长度(mm) 外径 截面积 物料编号 电线颜色 电线条颜色 导线名称 绞线 前端子型号 前端子物料编码 前端剥线长度 后端子型号 后端子物料编码 后端剥线长度 +1 放卷2 隔膜放卷_&G000111006-033_DQ 黑色RV10.0/定制 EC5L1 593.9 mm 6.7 mm 10 mm2 42020100000222 浅蓝色 电线 C45-10/定制 42020100000386 8 mm RNB8-8/定制 42020100000148 8 mm +2 放卷2 隔膜放卷_&G000111006-033_DQ 黑色RV10.0/定制 EC5L2 581.8 mm 6.7 mm 10 mm2 42020100000222 蓝色 白色 电线 RNB8-8/定制 42020100000148 8 mm C45-10/定制 42020100000386 8 mm +3 放卷2 隔膜放卷_&G000111006-033_DQ 黑色RV10.0/定制 EC5L3 584.1 mm 6.7 mm 10 mm2 42020100000222 黑色 电线 C45-10/定制 42020100000386 8 mm RNB8-8/定制 42020100000148 8 mm + + */ + new ReportModel + { + Imprint="D-PE", + PartNumber = "黑色RV10.0/定制", + CoreDiameter = "16 mm2", + Length = "5841.1 mm", + DisplayColor = "黄色", + DisplayStripeColor = "绿色" + } + + }).Result; + //Assert.IsTrue(result.Count == 4); + //Assert.IsTrue(result.Where(it => it.Imprint == "EC5L1").First().WireColor == "LBU"); + //Assert.IsTrue(result.Where(it => it.Imprint == "EC5L2").First().WireColor == "BUWH"); + //Assert.IsTrue(result.Where(it => it.Imprint == "EC5L3").First().WireColor == "BK"); + Assert.IsTrue(result.Where(it => it.Imprint == "D-PE").First().WireColor == "GNYE"); + Assert.IsTrue(result.Where(it => it.Imprint == "D-PE").First().NumberTubeSpec == "白色号码管φ8/定制"); + + } + } } diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/LectotypeWindow.xaml b/Sinvo.EplanHpD.Plugin.WPFUI/LectotypeWindow.xaml index 45245d1..607efe2 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/LectotypeWindow.xaml +++ b/Sinvo.EplanHpD.Plugin.WPFUI/LectotypeWindow.xaml @@ -6,6 +6,7 @@ xmlns:hc="https://handyorg.github.io/handycontrol" xmlns:local="clr-namespace:Sinvo.EplanHpD.Plugin.WPFUI" 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" @@ -24,6 +25,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -38,23 +98,35 @@ Content="Reload" /> - - - + + + + + + + + + @@ -64,11 +136,21 @@ + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/LectotypeWindow.xaml.cs b/Sinvo.EplanHpD.Plugin.WPFUI/LectotypeWindow.xaml.cs index 18dc8b1..0ee51f8 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/LectotypeWindow.xaml.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/LectotypeWindow.xaml.cs @@ -1,4 +1,5 @@ -using Sinvo.EplanHpD.Plugin.WPFUI.ViewModel; +using Sinvo.EplanHpD.Plugin.WPFUI.Models; +using Sinvo.EplanHpD.Plugin.WPFUI.ViewModel; using System.Windows; namespace Sinvo.EplanHpD.Plugin.WPFUI @@ -25,5 +26,16 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI { ViewModel.LoadData(); } + + + private void ToSourceMenuItem_Click(object sender, RoutedEventArgs e) + { + var selectItem = LettotypeListView.SelectedItem; + if (selectItem is LectotypeModel model) + { + + ViewModel.ToSource(model.CableName); + } + } } } diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/MainWindow.xaml.cs b/Sinvo.EplanHpD.Plugin.WPFUI/MainWindow.xaml.cs index 33d629d..d2cb340 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/MainWindow.xaml.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/MainWindow.xaml.cs @@ -411,26 +411,34 @@ public partial class MainWindow : Window private void AddToDesignerSelectSet(FlexDesigner designerDoc, List occurrences) { - List list = new List(); - foreach (BaseOccurrence baseOccurrence in occurrences) + try { - bool? flag; - if (baseOccurrence == null) + List list = new List(); + foreach (BaseOccurrence baseOccurrence in occurrences) { - flag = null; - } - else - { - FlexBaseOrganizer parentOrganizer = baseOccurrence.GetParentOrganizer(); - flag = ((parentOrganizer != null) ? new bool?(parentOrganizer.IsOccRegistered(baseOccurrence)) : null); - } - if (flag ?? false) - { - baseOccurrence.SetVisibility(true, null); - list.Add(baseOccurrence); + bool? flag; + if (baseOccurrence == null) + { + flag = null; + } + else + { + FlexBaseOrganizer parentOrganizer = baseOccurrence.GetParentOrganizer(); + flag = ((parentOrganizer != null) ? new bool?(parentOrganizer.IsOccRegistered(baseOccurrence)) : null); + } + if (flag ?? false) + { + baseOccurrence.SetVisibility(true, null); + list.Add(baseOccurrence); + } } + designerDoc.SelectSet.Add(list); + + } + catch (Exception ex) + { + FlexMessageBox.Error(ex.Message); } - designerDoc.SelectSet.Add(list); //designerDoc. } diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Properties/AssemblyInfo.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Properties/AssemblyInfo.cs index df6b0e2..7f7a920 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/Properties/AssemblyInfo.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Properties/AssemblyInfo.cs @@ -46,6 +46,6 @@ using System.Windows; // 生成号 // 修订号 // -[assembly: AssemblyVersion("1.0.0.6")] -[assembly: AssemblyFileVersion("1.0.0.6")] -[assembly: AssemblyInformationalVersion("1.0.0.6")] \ No newline at end of file +[assembly: AssemblyVersion("1.0.0.14")] +[assembly: AssemblyFileVersion("1.0.0.14")] +[assembly: AssemblyInformationalVersion("1.0.0.14")] \ No newline at end of file diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Sinvo.EplanHpD.Plugin.WPFUI.csproj b/Sinvo.EplanHpD.Plugin.WPFUI/Sinvo.EplanHpD.Plugin.WPFUI.csproj index b400570..0d8b6a7 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/Sinvo.EplanHpD.Plugin.WPFUI.csproj +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Sinvo.EplanHpD.Plugin.WPFUI.csproj @@ -135,6 +135,7 @@ + diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Utils/ExcelHelper.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/ExcelHelper.cs index bbc1d7c..7654a56 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/Utils/ExcelHelper.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/ExcelHelper.cs @@ -16,7 +16,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils public static IEnumerable GetWireTerminalMappingTable(string wireModel, string prefix = "") { CheckAndGetCache(); - return _terminalMappingCache.Where(item => item.WireModelSpecification == wireModel && (item.Prefix == prefix || item.Prefix == null)); + return _terminalMappingCache.Where(item => item.WireModelSpecification == wireModel && (item.Prefix == prefix || prefix == "")); } /// /// 获取线材信息 diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Utils/LectotypeLengthDataTemplateSelector.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/LectotypeLengthDataTemplateSelector.cs new file mode 100644 index 0000000..e702ecf --- /dev/null +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/LectotypeLengthDataTemplateSelector.cs @@ -0,0 +1,48 @@ +using System; +using System.Reflection; +using System.Windows; +using System.Windows.Controls; + +namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils +{ + internal class LectotypeLengthDataTemplateSelector : DataTemplateSelector + { + + public DataTemplate DefaultTemplate { get; set; } + public DataTemplate PowerLineTemplate { get; set; } + public DataTemplate EncoderLineTemplate { get; set; } + /// + /// 复合线模板 + /// + public DataTemplate ComplexLineTemplate { get; set; } + public LectotypeLengthDataTemplateSelector() + { + } + public override DataTemplate SelectTemplate(object item, DependencyObject container) + { + Type t = item.GetType(); + string cableType = null; + PropertyInfo[] properties = t.GetProperties(); + foreach (PropertyInfo pi in properties) + { + if (pi.Name == "CableType") + { + cableType = pi.GetValue(item, null).ToString(); + break; + } + } + switch (cableType) + { + case "动力线": + return PowerLineTemplate; + case "编码器线": + return EncoderLineTemplate; + case "动力线+编码器线": + return ComplexLineTemplate; + default: + return DefaultTemplate; + + } + } + } +} diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/LectotypeViewModel.cs b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/LectotypeViewModel.cs index 1857ab7..f5dd9bd 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/LectotypeViewModel.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/LectotypeViewModel.cs @@ -1,7 +1,9 @@ using EPLAN.Harness.Common.Extensions; using EPLAN.Harness.ProjectCore; +using EPLAN.Harness.ProjectCore.Occurrences; using EPLAN.Harness.ProjectCore.Occurrences.Designer; using Sinvo.EplanHpD.Plugin.WPFUI.Models; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; @@ -22,7 +24,16 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel OnPropertyChanged(); } } - + private List _stuffedWires; + public List StuffedWires + { + get => _stuffedWires; + set + { + _stuffedWires = value; + OnPropertyChanged(); + } + } public void LoadData() { if (string.IsNullOrEmpty(docId)) @@ -41,6 +52,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel it.GetType() == typeof(OccCableForked) //|| it.GetType() == typeof(OccWire) ) + //.Where(it => !string.IsNullOrEmpty(GetAxisNo((it.Children.First() as OccCablesInsulatorGraph).Imprint)) ) //.Where(it =>it.PartStatus == EPLAN.Harness.Core.LibEntities.Enums.PartStatus.Released) .Select(it => { @@ -52,6 +64,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel var encoderLength = 0d; var powerLength = 0d; if(double.TryParse(insulatorGraph.CableLength_VH?.StrVal ?? "0",out double length)){ + length = Math.Round(length,0); if(isEncoderLine){ encoderLength = length; }else{ @@ -69,11 +82,21 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel IsPowerLine = isPowerLine, PowerLineLength = powerLength, EncoderLineLength = encoderLength, - CableType = isEncoderLine ? "编码器线" : isPowerLine ? "动力线" : "位置类型", + CableType = isEncoderLine ? "编码器线" : isPowerLine ? "动力线" : "未知类型", }; }) .Where(it => it != null) + //.Where(it => !string.IsNullOrEmpty(it.AxisNo)) .OrderBy(it => it?.CableName ?? "")]; + + Wires = StuffData(cables); + } + + + public List StuffData(List cables) + { + List datas = []; + //1 整理数据 cables.ForEach(it => { var lineCount = 0; @@ -97,8 +120,57 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel { it.CableConnectionClass = "尾段"; } + if (string.IsNullOrEmpty(axisNo)) + { + it.IsError = true; + it.IsChecked = true; + it.ErrorCount += 1; + it.CheckedMsg += "轴号不能为空!\r\n"; + } + // 先把非第一行的数据添加到数据集合中 + if (it.CurrentLine != 1) + { + datas.Add(it); + } }); - Wires = cables; + //2 合并同轴号的第一条数据 + cables.Where(it => it.CurrentLine == 1).ForEach(it => + { + var existLine = datas.FirstOrDefault(data => data.AxisNo == it.AxisNo && data.CurrentLine == 1); + if (existLine != null) + { + if (existLine.CableType == it.CableType) return; + else + { + if (existLine.IsPowerLine) + { + existLine.EncoderLineLength = it.EncoderLineLength; + + } + else if (existLine.IsEncoderLine) + { + existLine.PowerLineLength = it.PowerLineLength; + } + } + existLine.CableType = "动力线+编码器线"; + if (datas.Any(i => i.AxisNo == it.AxisNo && i.CurrentLine != 1)) + { + + existLine.CableConnectionClass = "前段"; + } + else + { + existLine.CableConnectionClass = "直通"; + + } + } + else + { + datas.Add(it); + } + }); + + return datas.OrderBy(it => it.CurrentLine).ToList(); } /// /// L -> 动力线 N -> 编码器线 @@ -177,5 +249,21 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } + + 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) + { + doc.SelectSet.Clear(); + var oriOcc = SelfControler.FindInstance(cable.ID); + oriOcc.SetVisibility(true, null); + + doc.SelectSet.Add(oriOcc.Children.First()); + doc.FitToSelectSet(); + doc.SelectSet.OnSelectionChanged(); + } + } } } diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MainViewModel.Check.cs b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MainViewModel.Check.cs index 1f28921..720c17e 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MainViewModel.Check.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MainViewModel.Check.cs @@ -42,9 +42,27 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel CheckInsulation(item); CheckTerminals(item); + CheckDPETerminals(item); CheckDuplicateModel(item); } + public void CheckDPETerminals(StuffedDataModel item) + { + // 地排只检查4.0线径以下的 + if (double.TryParse(item.CrossSection, out double crossSection)) + if (item.Imprint.StartsWith("D-PE") && crossSection <= 4.0) + { + var D_PECanUsedTerminals = GetD_PECanUsedTerminal(item.WireModel); + if (D_PECanUsedTerminals.All(terminal => + terminal.TerminalSpec != item.FrontTerminalModel + && terminal.TerminalSpec != item.RearTerminalModel) + ) + { + SetItemError(item, "D-PE线未匹配到正确的端子!\r\n"); + } + } + } + public void CheckWireErpNr(StuffedDataModel item) { var wireInfos = ExcelHelper.GetWireInfo(item.WireModel); @@ -163,18 +181,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel /// public void CheckTerminals(StuffedDataModel item) { - var canUsedTerminals = new List(); - //if(item.) - if (item.Imprint.StartsWith("D-PE")) - { - canUsedTerminals = GetD_PECanUsedTerminal(item.WireModel); - } - else - { - - canUsedTerminals = GetCanUsedTerminal(item.WireModel); - - } + var canUsedTerminals = GetCanUsedTerminal(item.WireModel); if (canUsedTerminals != null && canUsedTerminals.Any()) { var terminals = canUsedTerminals.Where(it => !string.IsNullOrEmpty(it.TerminalSpec) && !string.IsNullOrEmpty(it.TerminalMaterialCode)); @@ -195,7 +202,6 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel if (terminals.All(it => it.TerminalMaterialCode != item.RearTerminalMaterialCode)) { SetItemError(item, "后端子料号不正确,不在可选列表中!\r\n"); - } } else if (!string.IsNullOrEmpty(item.FrontTerminalModel) || !string.IsNullOrEmpty(item.RearTerminalModel)) @@ -293,11 +299,11 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel // 获取D-PE前缀的可用端子 var resultWithPrefix = ExcelHelper.GetWireTerminalMappingTable(wireModel, "D-PE"); // 获取不包含前缀的端子 - var resultWithoutPrefix = ExcelHelper.GetWireTerminalMappingTable(wireModel); + //var resultWithoutPrefix = ExcelHelper.GetWireTerminalMappingTable(wireModel); var terminals = new List(); // 转换 var withPrefixExcelModels = resultWithPrefix as List ?? resultWithPrefix.ToList(); - var withoutPrefixExcelModels = resultWithoutPrefix as List ?? resultWithoutPrefix.ToList(); + List withoutPrefixExcelModels = [];//resultWithoutPrefix as List ?? resultWithoutPrefix.ToList(); // 合并 var excelModels = withPrefixExcelModels.Concat(withoutPrefixExcelModels); if (!excelModels.Any()) return terminals; diff --git a/Sinvo.EplanHpD.Plugin/DesignPluginEntry.cs b/Sinvo.EplanHpD.Plugin/DesignPluginEntry.cs index 440589b..22aca06 100644 --- a/Sinvo.EplanHpD.Plugin/DesignPluginEntry.cs +++ b/Sinvo.EplanHpD.Plugin/DesignPluginEntry.cs @@ -1,5 +1,4 @@ using EPLAN.Harness.API; -using EPLAN.Harness.API.Plugins; using EPLAN.Harness.API.Plugins.Core; using Sinvo.EplanHpD.Plugin.WPFUI; using System; @@ -9,7 +8,7 @@ using System.Reflection; namespace Sinvo.EplanHpD.Plugin { - public class DesignPluginEntry : IHpDPlugin + public class DesignPluginEntry //: IHpDPlugin { public string Name => "兴禾ProD插件-3D"; diff --git a/Sinvo.EplanHpD.Plugin/Properties/AssemblyInfo.cs b/Sinvo.EplanHpD.Plugin/Properties/AssemblyInfo.cs index f372369..5e17627 100644 --- a/Sinvo.EplanHpD.Plugin/Properties/AssemblyInfo.cs +++ b/Sinvo.EplanHpD.Plugin/Properties/AssemblyInfo.cs @@ -28,6 +28,6 @@ using System.Runtime.InteropServices; // 生成号 // 修订号 // -[assembly: AssemblyVersion("1.0.0.6")] -[assembly: AssemblyFileVersion("1.0.0.6")] -[assembly: AssemblyInformationalVersion("1.0.0.6")] \ No newline at end of file +[assembly: AssemblyVersion("1.0.0.14")] +[assembly: AssemblyFileVersion("1.0.0.14")] +[assembly: AssemblyInformationalVersion("1.0.0.14")] \ No newline at end of file