105040 Update 增加多芯线功能入口

This commit is contained in:
lihanbo 2025-04-10 10:20:53 +08:00
parent 042c93fcfe
commit 2fa8f8f8aa
14 changed files with 263 additions and 84 deletions

View File

@ -64,6 +64,7 @@ namespace Sinvo.EplanHpD.Plugin.DynaClient
public void LoginOut() public void LoginOut()
{ {
_client.logout(); _client.logout();
} }

View File

@ -44,7 +44,7 @@ namespace Sinvo.EplanHpD.Plugin.DynaClient
XmlNode msgNode = XMLMethod.GetXmlNode(xmlDoc, XTN_PDMOUT_MESSAGE); XmlNode msgNode = XMLMethod.GetXmlNode(xmlDoc, XTN_PDMOUT_MESSAGE);
if (msgNode == null) if (msgNode == null)
{ {
throw new Exception(); throw new Exception("无法解析XML请检查");
} }
string strFailedMsg = msgNode.InnerText; string strFailedMsg = msgNode.InnerText;
throw new Exception(strFailedMsg); throw new Exception(strFailedMsg);
@ -460,7 +460,6 @@ namespace Sinvo.EplanHpD.Plugin.DynaClient
resultList.Add(obj); resultList.Add(obj);
} }
// 如果只有一个结果,直接返回该对象
return resultList; return resultList;
} }
} }

View File

@ -11,7 +11,11 @@ namespace Sinvo.EplanHpD.Plugin.Service
public class PluginServices public class PluginServices
{ {
public static UserInfo user; public static UserInfo user;
#if DEBUG
public static bool IsLogin => user != null && !string.IsNullOrEmpty(user.GUID) && DynaServerClient.GetClient().IsLoginExpired(); public static bool IsLogin => user != null && !string.IsNullOrEmpty(user.GUID) && DynaServerClient.GetClient().IsLoginExpired();
#else
public static bool IsLogin => true;
#endif
} }
} }

View File

@ -219,6 +219,7 @@
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
@ -284,6 +285,7 @@
<Compile Include="ViewModel\CableLectotype\LayoutHelperViewModel.cs" /> <Compile Include="ViewModel\CableLectotype\LayoutHelperViewModel.cs" />
<Compile Include="ViewModel\CableLectotype\LectotypeViewModel.cs" /> <Compile Include="ViewModel\CableLectotype\LectotypeViewModel.cs" />
<Compile Include="ViewModel\LoginViewModel.cs" /> <Compile Include="ViewModel\LoginViewModel.cs" />
<Compile Include="ViewModel\MultiCoreWireViewModel\MultiCoreWireViewModel.cs" />
<Compile Include="ViewModel\WireCheck\MainViewModel.Check.cs" /> <Compile Include="ViewModel\WireCheck\MainViewModel.Check.cs" />
<Compile Include="ViewModel\WireCheck\MainViewModel.cs" /> <Compile Include="ViewModel\WireCheck\MainViewModel.cs" />
<Compile Include="ViewModel\Scanner\ScannerViewModel.cs" /> <Compile Include="ViewModel\Scanner\ScannerViewModel.cs" />
@ -303,6 +305,9 @@
<Compile Include="View\LoginWindow.xaml.cs"> <Compile Include="View\LoginWindow.xaml.cs">
<DependentUpon>LoginWindow.xaml</DependentUpon> <DependentUpon>LoginWindow.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="View\MultiCoreWire\MultiCoreWireWindow.xaml.cs">
<DependentUpon>MultiCoreWireWindow.xaml</DependentUpon>
</Compile>
<Compile Include="View\WireCheck\MainWindow.xaml.cs"> <Compile Include="View\WireCheck\MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon> <DependentUpon>MainWindow.xaml</DependentUpon>
</Compile> </Compile>
@ -340,6 +345,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="View\MultiCoreWire\MultiCoreWireWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="View\WireCheck\MainWindow.xaml"> <Page Include="View\WireCheck\MainWindow.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>

View File

@ -22,10 +22,10 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
public static string TEMPLATE_FILE_NAME = @"下单模板.xlsx"; public static string TEMPLATE_FILE_NAME = @"下单模板.xlsx";
#if DEBUG #if DEBUG
public static string PLUGIN_DATA_FILE_PATH = @"D:\Desktop\EPLAN\汇川"; public static string PLUGIN_DATA_FILE_PATH = @"\\192.168.1.160\体系内部资料\李韩波\Eplan\测试用数据表";
#else #else
public static string PLUGIN_DATA_FILE_PATH = @"\\192.168.1.160\plm系统文档\线材选型";//@"D:\旧电脑文件\Desktop\EPlan\线材选型";// public static string PLUGIN_DATA_FILE_PATH = @"\\192.168.1.160\plm系统文档\线材选型";
#endif #endif
public static string PLUGIN_DATA_FILE_NAME = "线材选型数据表.xlsx"; public static string PLUGIN_DATA_FILE_NAME = "线材选型数据表.xlsx";
public static string PLUGIN_DATA_FILE_NAME_BOM = "BOM表.xlsx"; public static string PLUGIN_DATA_FILE_NAME_BOM = "BOM表.xlsx";

View File

@ -0,0 +1,30 @@
<Window
x:Class="Sinvo.EplanHpD.Plugin.WPFUI.View.MultiCoreWireWindow"
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:Sinvo.EplanHpD.Plugin.WPFUI.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="多芯线数据抓取"
Width="800"
Height="450"
Loaded="Window_Loaded"
mc:Ignorable="d">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="80" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0">
<StackPanel />
</StackPanel>
<TabControl Grid.Row="1">
<TabItem Header="多芯线选型">
<StackPanel />
</TabItem>
<TabItem Header="数据抓取">
<StackPanel />
</TabItem>
</TabControl>
</Grid>
</Window>

View File

@ -0,0 +1,36 @@
using EPLAN.Harness.Common.Extensions;
using Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Sinvo.EplanHpD.Plugin.WPFUI.View
{
/// <summary>
/// MultiCoreWireWindow.xaml 的交互逻辑
/// </summary>
public partial class MultiCoreWireWindow : Window
{
private MultiCoreWireViewModel viewModel;
public MultiCoreWireWindow(string docId)
{
InitializeComponent();
this.DataContext = viewModel = new MultiCoreWireViewModel(docId);
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
viewModel.LoadData();
}
}
}

View File

@ -26,8 +26,6 @@
</Style> </Style>
</Window.Resources> </Window.Resources>
<Grid x:Name="top" Margin="10"> <Grid x:Name="top" Margin="10">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition /> <RowDefinition />
<RowDefinition /> <RowDefinition />
@ -91,7 +89,8 @@
<Button <Button
Grid.Row="1" Grid.Row="1"
Grid.Column="2" Grid.Column="2"
Margin="50,0,0,0" Click="Button_Click_2"> Margin="50,0,0,0"
Click="Button_Click_2">
<TextBlock <TextBlock
Grid.Row="1" Grid.Row="1"
Grid.Column="2" Grid.Column="2"
@ -106,7 +105,8 @@
<Button <Button
Grid.Row="2" Grid.Row="2"
Grid.Column="2" Grid.Column="2"
Margin="50,0,0,0" Click="Button_Click_3"> Margin="50,0,0,0"
Click="Button_Click_3">
<TextBlock Text="{Binding E_pin}" /> <TextBlock Text="{Binding E_pin}" />
</Button> </Button>

View File

@ -37,11 +37,13 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
return; return;
} }
if(IsEnableParagraph) if(IsEnableParagraph)
{
if (EncoderLineParagraph == 0 || PowerLineParagraph == 0) if (EncoderLineParagraph == 0 || PowerLineParagraph == 0)
{ {
ShowWarning("段数不能为零!"); ShowWarning("段数不能为零!");
return; return;
} }
}
if (string.IsNullOrEmpty(AxisNo)) if (string.IsNullOrEmpty(AxisNo))
{ {

View File

@ -351,17 +351,12 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
} }
} }
} }
} }
} }
catch (Exception) catch (Exception)
{ {
it.CableConnectionClass = ""; it.CableConnectionClass = "";
} }
if (string.IsNullOrEmpty(it.CableConnectionClass)) if (string.IsNullOrEmpty(it.CableConnectionClass))
{ {
if (it.CurrentLine == 1 && it.CurrentLine != lineCount) if (it.CurrentLine == 1 && it.CurrentLine != lineCount)
@ -412,7 +407,6 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
var brandData = Brands.GetBrandData(it.Motor?.Brand); var brandData = Brands.GetBrandData(it.Motor?.Brand);
if (brandData?.ComplexLine ?? false) if (brandData?.ComplexLine ?? false)
{ {
var existLine = datas.FirstOrDefault(data => data.AxisNo == it.AxisNo && data.CurrentLine == 1); var existLine = datas.FirstOrDefault(data => data.AxisNo == it.AxisNo && data.CurrentLine == 1);
if (existLine != null) if (existLine != null)
{ {
@ -428,7 +422,6 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
else if (existLine.IsEncoderLine) else if (existLine.IsEncoderLine)
{ {
existLine.SeqNo = 2; existLine.SeqNo = 2;
existLine.PowerLineLength = it.PowerLineLength; existLine.PowerLineLength = it.PowerLineLength;
} }
} }
@ -436,7 +429,6 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
existLine.CableType = "编码器线+动力线"; existLine.CableType = "编码器线+动力线";
if (datas.Any(i => i.AxisNo == it.AxisNo && i.CurrentLine != 1)) if (datas.Any(i => i.AxisNo == it.AxisNo && i.CurrentLine != 1))
{ {
existLine.CableConnectionClass = "前段"; existLine.CableConnectionClass = "前段";
} }
else else
@ -462,7 +454,6 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
{ {
existLine.SetError("请检查是否使用正确的高柔线"); existLine.SetError("请检查是否使用正确的高柔线");
} }
} }
else else
{ {
@ -474,7 +465,6 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
{ {
datas.Add(it); datas.Add(it);
} }
}); });
CheckLines(datas); CheckLines(datas);
return [.. datas.OrderBy(it => it.AxisNo).ThenBy(it => it.CableType).ThenBy(it => it.CurrentLine)]; return [.. datas.OrderBy(it => it.AxisNo).ThenBy(it => it.CableType).ThenBy(it => it.CurrentLine)];

View File

@ -0,0 +1,59 @@
using EPLAN.Harness.Common.Extensions;
using EPLAN.Harness.MathLib.Styling;
using EPLAN.Harness.ProjectCore;
using EPLAN.Harness.ProjectCore.Occurrences.Designer;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
{
public class MultiCoreWireViewModel(string docId) : INotifyPropertyChanged
{
public string _docId = docId;
public Task LoadData()
{
var des = FlexProject.CurrentProject.GetDesigners().FirstOrDefault(it => it.ID == _docId);
if (des == null)
{
throw new Exception("设计器不存在");
}
var cables = des.GetOrganizerOccurrences(_docId, typeof(OccCableForked));
cables.Where(it => it.Name?.StartsWith("信号线") ?? false).ForEach(it =>
{
Debug.WriteLine($"{it.Name} - {it.LibraryName}");
if (it.Children?.Any() ?? false)
{
it.Children.ForEach(c =>
{
Debug.WriteLine($"\t{c.Name} - {c.LibraryName}");
if (c.Children?.Any() ?? false)
{
c.Children.Where(ccc => ccc is OccWire).ForEach(cc =>
{
if(cc is OccWire wire)
{
Debug.WriteLine($"\t\t{wire.Name} - {wire.LibraryName} - {wire.Color.Major.Color.Name} - {wire.Color.GetType()}");
}
});
}
});
}
});
return Task.CompletedTask;
}
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}

View File

@ -18,9 +18,6 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
{ {
public class ScannerViewModel : INotifyPropertyChanged, INotifyDataErrorInfo public class ScannerViewModel : INotifyPropertyChanged, INotifyDataErrorInfo
{ {
private FlexDesigner _currentFlexDesigner; private FlexDesigner _currentFlexDesigner;
private bool _othersWireShow = true; private bool _othersWireShow = true;
private bool _continueScan = true; private bool _continueScan = true;
@ -185,9 +182,6 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
{ {
} }
public void GetAllCables() public void GetAllCables()
{ {
ScanCableModels.Clear(); ScanCableModels.Clear();
@ -207,8 +201,6 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
s_pinid = wire_pin[0].Substring(1, 32); s_pinid = wire_pin[0].Substring(1, 32);
e_pinid = wire_pin[1].Trim().Substring(1, 32); e_pinid = wire_pin[1].Trim().Substring(1, 32);
} }
//保存线材基础属性 //保存线材基础属性
ScanCableModels.Add(new ScanCableModel() ScanCableModels.Add(new ScanCableModel()
{ {
@ -268,8 +260,6 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
scanCableModel.E_part = grandparent.Name; scanCableModel.E_part = grandparent.Name;
E_part = scanCableModel.E_part; E_part = scanCableModel.E_part;
} }
//}
} }
); );
@ -303,8 +293,6 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
FlexMessageBox.Error(ex.Message); FlexMessageBox.Error(ex.Message);
} }
} }
private void DebounceTimer_Tick(object sender, EventArgs e) private void DebounceTimer_Tick(object sender, EventArgs e)
{ {
_debounceTimer.Stop(); _debounceTimer.Stop();
@ -321,7 +309,6 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
ClearErrors(nameof(InputCode)); ClearErrors(nameof(InputCode));
var cable = ScanCableModels.FirstOrDefault(c => c.Code.Equals(searchText, StringComparison.OrdinalIgnoreCase) || c.Imprint.StartsWith(searchText, StringComparison.OrdinalIgnoreCase)); var cable = ScanCableModels.FirstOrDefault(c => c.Code.Equals(searchText, StringComparison.OrdinalIgnoreCase) || c.Imprint.StartsWith(searchText, StringComparison.OrdinalIgnoreCase));
if (cable != null) if (cable != null)
{ {
// 处理其他线是否隐藏 // 处理其他线是否隐藏
@ -339,12 +326,10 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
cable.IsChecked = true; cable.IsChecked = true;
_ScanCableModels.Remove(cable); _ScanCableModels.Remove(cable);
_ScanCableModels.Insert(0, cable); _ScanCableModels.Insert(0, cable);
} }
GetWireConnectPart(cable); GetWireConnectPart(cable);
ScanedIndex = 0;//Math.Max(cable.Index - 1, 0); ScanedIndex = 0;//Math.Max(cable.Index - 1, 0);
ToSourceById(cable); ToSourceById(cable);
} }
else else
{ {
@ -352,25 +337,6 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
AddError(nameof(InputCode), "该条码不存在于列表中"); AddError(nameof(InputCode), "该条码不存在于列表中");
} }
} }
//public void sethightlight()
//{
// ClearHighlights();
// var selectedObjects = HarnessApp.Selection.GetSelectedObjects();
// foreach (var obj in selectedObjects)
// {
// obj.SetHighlight(true); // 高亮选中部件
// }
//}
//private void ClearHighlights()
//{
// var allObjects = HarnessApp.GetAllObjects();
// foreach (var obj in allObjects)
// {
// obj.SetHighlight(false); // 清除高亮
// }
//}
private void ToSourceByName(string wireName) private void ToSourceByName(string wireName)
{ {
var occWire = _currentFlexDesigner.GetOccurrenceByName(wireName, typeof(OccWire)); var occWire = _currentFlexDesigner.GetOccurrenceByName(wireName, typeof(OccWire));
@ -424,20 +390,6 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
_currentFlexDesigner.FitToSelectSet(); _currentFlexDesigner.FitToSelectSet();
_currentFlexDesigner.SelectSet.OnSelectionChanged(); _currentFlexDesigner.SelectSet.OnSelectionChanged();
//_currentFlexDesigner.Camera.GraphicControl._HighlightNode()
/*
List<DatTreeNodeEx<BaseOccurrence>> nodeByEntity = this._occTreeView.GetNodeByEntity(baseOccurrence);
if (nodeByEntity != null)
{
foreach (DatTreeNodeEx<BaseOccurrence> datTreeNodeEx in nodeByEntity)
{
if (!this._occTreeView.SelectedNodes.Contains(datTreeNodeEx))
{
this._occTreeView.SelectedNodes.Add(datTreeNodeEx);
}
}
}
*/
} }
} }
/// <summary> /// <summary>
@ -461,21 +413,6 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
// 缩放设计器且触发选中事件 // 缩放设计器且触发选中事件
_currentFlexDesigner.FitToSelectSet(); _currentFlexDesigner.FitToSelectSet();
_currentFlexDesigner.SelectSet.OnSelectionChanged(); _currentFlexDesigner.SelectSet.OnSelectionChanged();
//_currentFlexDesigner.Camera.GraphicControl._HighlightNode()
/*
List<DatTreeNodeEx<BaseOccurrence>> nodeByEntity = this._occTreeView.GetNodeByEntity(baseOccurrence);
if (nodeByEntity != null)
{
foreach (DatTreeNodeEx<BaseOccurrence> datTreeNodeEx in nodeByEntity)
{
if (!this._occTreeView.SelectedNodes.Contains(datTreeNodeEx))
{
this._occTreeView.SelectedNodes.Add(datTreeNodeEx);
}
}
}
*/
} }
} }

View File

@ -0,0 +1,111 @@
using EPLAN.Harness.API;
using EPLAN.Harness.API.Plugins.Core;
using EPLAN.Harness.AppCore;
using Sinvo.EplanHpD.Plugin.DynaClient;
using Sinvo.EplanHpD.Plugin.Service;
using Sinvo.EplanHpD.Plugin.WPFUI;
using Sinvo.EplanHpD.Plugin.WPFUI.Extension;
using Sinvo.EplanHpD.Plugin.WPFUI.Utils;
using Sinvo.EplanHpD.Plugin.WPFUI.View;
using System;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Runtime.Remoting;
using System.Windows.Forms.Integration;
namespace Sinvo.EplanHpD.Plugin
{
#if Release_WireAndCable || DEBUG
public class MultiCoreWirePluginEntry : EPLAN.Harness.API.Plugins.IHpDPlugin
#else
public class MultiCoreWirePluginEntry
#endif
{
public string Name => "兴禾ProD插件-3D";
public string Author => "Sinvo";
public string Description => "兴禾EPLAN Harness proD 2.9 Studio插件,提供多芯线数据抓取功能";
/// <summary>
/// 获取DLL版本
/// </summary>
public Version Version => Assembly.GetAssembly(this.GetType()).GetName().Version;
public System.Drawing.Image ToolbarIcon
{
get
{
var imageBytes = Resource.Sinvo;
if (imageBytes != null)
{
using (var ms = new MemoryStream(imageBytes))
{
return Image.FromStream(ms);
}
}
return null;
}
}
public string ToolbarText => "多芯线数据抓取";
public HpDModule Module => HpDModule.WorkSpace;
public string ToolbarTooltip => "多芯线数据抓取";
MultiCoreWireWindow window;
public void Execute(HpdApi api)
{
bool isLogin = PluginServices.IsLogin;
if (!isLogin)
{
var LoginWindow = new LoginWindow();
if(LoginWindow.ShowDialog() == true)
{
isLogin = PluginServices.IsLogin;
}
}
if (isLogin)
{
new DBHelper().CodeFirst();
var doc = api.CurrentProject.GetActiveDocument();
if (window == null)
{
window = new MultiCoreWireWindow(doc.ID);
// 获取版本号并显示到窗口标题
window.Title += $" V{Version} - {doc.Name}";
ElementHost.EnableModelessKeyboardInterop(window);
var mainApp = BaseApp.ActiveApplication;
var helper = new System.Windows.Interop.WindowInteropHelper(window);
helper.Owner = mainApp.Handle;
window.Closed += delegate
{
window = null;
};
window.Show();
}
else
{
window.WindowState = System.Windows.WindowState.Normal;
window.Activate();
}
}
}
public void Initialize()
{
if (!AppDomainDllLoader.isLoaded)
{
AppDomainDllLoader.SetLaoder();
ApplicationExt.InitApplication();
Consts.InitConfigs();
}
}
public void Terminate()
{
}
}
}

View File

@ -200,6 +200,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="AppDomainDllLoader.cs" /> <Compile Include="AppDomainDllLoader.cs" />
<Compile Include="MultiCoreWirePluginEntry.cs" />
<Compile Include="DesignPluginEntry.cs" /> <Compile Include="DesignPluginEntry.cs" />
<Compile Include="PluginEntry.cs" /> <Compile Include="PluginEntry.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />