105040 测试版本,增加功能与优化,调整了数据源

This commit is contained in:
lihanbo 2024-11-26 10:34:31 +08:00
parent b7591e9cb2
commit 6818840420
17 changed files with 997 additions and 580 deletions

View File

@ -16,5 +16,5 @@ using System.Runtime.InteropServices;
[assembly: Guid("aec39474-528b-4da8-b650-99189acb7a2c")]
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.18")]
[assembly: AssemblyFileVersion("1.0.0.18")]
[assembly: AssemblyVersion("1.0.0.19")]
[assembly: AssemblyFileVersion("1.0.0.19")]

View File

@ -1,22 +0,0 @@
using System;
using System.Windows.Input;
namespace Sinvo.EplanHpD.Plugin.WPFUI.Commands
{
public class UICommand : ICommand
{
private readonly Action<object> _execute;
private readonly Func<object, bool> _canExecute;
public event EventHandler CanExecuteChanged;
public bool CanExecute(object parameter)
{
return _canExecute != null || _canExecute(parameter);
}
public void Execute(object parameter)
{
_execute.Invoke(parameter);
}
}
}

View File

@ -26,8 +26,16 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
}
}
public int SeqNo;
private int _seqNo;
public int SeqNo
{
get => _seqNo;
set
{
_seqNo = value;
OnPropertyChanged(nameof(SeqNo));
}
}
public bool IsComplexLine;
@ -94,6 +102,10 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
{
_drawingNo = value;
OnPropertyChanged(nameof(DrawingNo));
if (IsLectotype)
{
SubLines = GetSubLines(DrawingNo);
}
}
}
@ -159,6 +171,11 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
_isFlexibility = value;
OnPropertyChanged(nameof(IsFlexibility));
OnPropertyChanged(nameof(CableModelNo));
if (IsLectotype)
{
var drawNo = CableModelNo;
SubLines = GetSubLines(DrawingNo);
}
}
}
@ -342,7 +359,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
/// 获取线对应图纸编号
/// </summary>
/// <returns></returns>
private string GetCableDrawNo()
public string GetCableDrawNo()
{
var data = MotorExcelHelper.Instance.GetCableDatas();
//var data = Core.CoreService.GetService<LectotypeService>().GetCableDatas();
@ -401,5 +418,40 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
OnPropertyChanged(nameof(SubLines));
}
}
private string _cableModel;
public string CableModel
{
get => _cableModel;
set
{
_cableModel = value;
OnPropertyChanged(nameof(CableModel));
}
}
public bool IsLectotype = false;
private bool _isComplete;
public bool IsComplete
{
get => _isComplete;
set
{
_isComplete = value;
OnPropertyChanged(nameof(IsComplete));
}
}
private List<LectotypeLineModel> GetSubLines(string drawingNo)
{
return MotorExcelHelper.Instance.GetBomList(drawingNo).Where(it =>
{
return it.Name == "编码器线" || it.Name == "动力线";
}).Select(it => new LectotypeLineModel
{
SeqNo = 0,
CableModel = it.Spec,
CableType = it.Name
}).ToList();
}
}
}

View File

@ -53,7 +53,7 @@
}
}
/// <summary>
/// 电机系列
/// 电机型号
/// </summary>
private string _motorModel;
/// <summary>

View File

@ -46,6 +46,6 @@ using System.Windows;
// 生成号
// 修订号
//
[assembly: AssemblyVersion("1.0.0.18")]
[assembly: AssemblyFileVersion("1.0.0.18")]
[assembly: AssemblyInformationalVersion("1.0.0.18")]
[assembly: AssemblyVersion("1.0.0.19")]
[assembly: AssemblyFileVersion("1.0.0.19")]
[assembly: AssemblyInformationalVersion("1.0.0.19")]

View File

@ -5,7 +5,7 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{2DBCD22A-650D-4797-9908-9C4D5D6665FE}</ProjectGuid>
<OutputType>Exe</OutputType>
<OutputType>Library</OutputType>
<RootNamespace>Sinvo.EplanHpD.Plugin.WPFUI</RootNamespace>
<AssemblyName>Sinvo.EplanHpD.Plugin.WPFUI</AssemblyName>
<TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
@ -56,7 +56,8 @@
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<StartupObject>Sinvo.EplanHpD.Plugin.WPFUI.TestWindow</StartupObject>
<StartupObject>
</StartupObject>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
@ -131,9 +132,9 @@
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="WindowsFormsIntegration" />
</ItemGroup>
<ItemGroup>
<Compile Include="Commands\UICommand.cs" />
<Compile Include="Models\CheckedModel.cs" />
<Compile Include="Models\ConfigItemModel.cs" />
<Compile Include="Models\ExcelModel.cs" />
@ -153,6 +154,8 @@
<Compile Include="Utils\ApplicationExt.cs" />
<Compile Include="Utils\BaseAppExt.cs" />
<Compile Include="Utils\CheckedModelExt.cs" />
<Compile Include="Utils\ConnectionType.cs" />
<Compile Include="Utils\ConnectionTypeConverter.cs" />
<Compile Include="Utils\Consts.cs" />
<Compile Include="Utils\DataGridType.cs" />
<Compile Include="Utils\DrawPDFHelper.cs" />
@ -165,6 +168,7 @@
<Compile Include="Utils\NameTypeConverter.cs" />
<Compile Include="Utils\PropertyListExt.cs" />
<Compile Include="Utils\WireFlagType.cs" />
<Compile Include="ViewModel\CableLectotypeViewModel.cs" />
<Compile Include="ViewModel\LectotypeViewModel.cs" />
<Compile Include="ViewModel\MainViewModel.Check.cs" />
<Compile Include="ViewModel\MainViewModel.cs" />
@ -247,6 +251,7 @@
</PackageReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Commands\" />
<Folder Include="Common\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

View File

@ -40,7 +40,13 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI
[STAThread]
public static void Main()
{
var window = new CableLectotypeWindow();
var window = new CableLectotypeWindow(new Models.MotorModel
{
AxisNo = "MRJ001",
MotorPower = "1000W220V",
MotorModelStr = "HK-KT103WJK",
MotorSerie = "HK-KT"
});
window.ShowDialog();
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
{
public enum ConnectionType
{
[Description("直通")]
Passthrough,
[Description("全段")]
FullParagraph
}
}

View File

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
{
public class ConnectionTypeConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var flag = (ConnectionType)value;
if (!Enum.IsDefined(typeof(ConnectionType), flag))
{
return false;
}
return flag == (ConnectionType)parameter;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is not bool isChecked)
{
throw new InvalidOperationException("The value must be a bool");
}
return isChecked ? (ConnectionType)parameter : Binding.DoNothing;
}
}
}

View File

@ -22,5 +22,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
/// 变色套平方规格匹配
/// </summary>
public static readonly Regex dRegex = new("V-[\\d]+\\.?[\\d]*", RegexOptions.Compiled);
public static readonly Regex regexParenthesesContent = new(@"(?<=\()[^)]*(?=\))", RegexOptions.Compiled);
}
}

View File

@ -12,7 +12,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
public static MotorExcelHelper Instance = new();
private Stream dataFileStream;
public const string DATA_FILE_PATH = @"\\192.168.1.160\plm系统文档\线材选型";//@"\\192.168.1.160\plm系统文档\线材选型";
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";
@ -28,7 +28,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
public List<LectotypeModel> GetCableDatas()
{
if (dataFileStream == null) return null;
//var filePath = "D:\\Desktop\\Data\\三菱伺服HK-KT线材选型BOM表_按程序格式整理后.xlsx";
//var filePath = "D:\\旧电脑文件\\Desktop\\Data\\三菱伺服HK-KT线材选型BOM表_按程序格式整理后.xlsx";
var data = MiniExcel.Query<LectotypeModel>(dataFileStream, "HK-KT").ToList();
//MiniExcel.Query()
return data;

View File

@ -0,0 +1,322 @@
using HandyControl.Controls;
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
using Sinvo.EplanHpD.Plugin.WPFUI.Utils;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Security.Cryptography.X509Certificates;
using System.Windows.Shapes;
namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel;
public class CableLectotypeViewModel : INotifyPropertyChanged
{
private const string MESSAGE_KEY = "CableLectotypeMessage";
/// <summary>
/// 生成线列表
/// </summary>
public void Cablerator()
{
if (EncoderLineParagraph == 0 || PowerLineParagraph == 0)
{
ShowError("段数不能为零!");
return;
}
if (string.IsNullOrEmpty(AxisNo))
{
ShowError("轴号不能为空!");
return;
}
if (string.IsNullOrEmpty(CableType))
{
ShowError("请选择线材类型!");
return;
}
int seqNo = 1;
var LectotypeList = new List<LectotypeLineModel>();
var line = new LectotypeLineModel
{
SeqNo = seqNo,
//MechanicalNo = MechanicalNo,
//MechanicalName = MechanicalName,
AxisNo = AxisNo,
//MotorSerie = MotorSerie,
//MotorPower = Motor.MotorPower,
//DriverInterface = DriverInterface,
//DriverModel = DriverModel,
CableConnectionClass = CableConnectionType == ConnectionType.FullParagraph ? "前段" : "直通",
CableType = CableType,
//IsFlexibility = IsFlexibility,
//PowerLineLength = PowerLineLength,
//EncoderLineLength = EncoderLineLength,
//PowerBrakeLineLength = PowerBrakeLineLength,
//DrawingNo = LineModelStr,
CableModelNo = CableModelStr,
//LineCount = Math.Max(PowerLineCount, EncoderLineCount),
//CurrentLineNumber = 1,
//BomList = GenBomListByCurrent(DrawingNo)
IsLectotype = true,
CurrentLine = 1,
Motor = Motor
};
line.DrawingNo = line.GetCableDrawNo();
line.SubLines = GetSubLines(line.DrawingNo);
if (CableConnectionType == ConnectionType.FullParagraph)
{
LectotypeList.Clear();
//if (SelectedLines.Any(it => it.AxisNo == AxisNo))
//{
// WPFUISession.Instance.snackbarService.Show("相同轴号已经添加过数据,禁止重复添加!", "请检查是否添加错误", appearance: ControlAppearance.Danger, timeout: TimeSpan.FromSeconds(3));
// return;
//}
// 第一条线为所选线
LectotypeList.Add(line);
for (global::System.Int32 i = 2; i <= PowerLineParagraph; i++)
{
seqNo++;
var cableConnectionType = "中段";
if (i >= PowerLineParagraph)
{
cableConnectionType = "尾段";
}
var powerLine = new LectotypeLineModel
{
SeqNo = seqNo,
//MechanicalNo = MechanicalNo,
//MechanicalName = MechanicalName,
AxisNo = AxisNo,
//MotorSerie = MotorSerie,
//MotorPower = MotorPower,
//DriverInterface = DriverInterface,
//DriverModel = DriverModel,
//PowerBrakeLineLength = PowerBrakeLineLength,
//DrawingNo = DrawingNo,
//CableModelNo = CableModelNo,
CableConnectionClass = cableConnectionType,
CableType = "动力线",
LineCount = PowerLineParagraph,
//PowerLineLength = PowerLineLength,
//CurrentLineNumber = i,
CurrentLine = i,
Motor = Motor,
IsLectotype = true
//CableFlag = GetCableModelFlag(MotorPower, PowerLineName, cableConnectionType, false)
};
powerLine.DrawingNo = powerLine.GetCableDrawNo();
powerLine.SubLines = GetSubLines(powerLine.DrawingNo);
LectotypeList.Add(powerLine);
}
for (global::System.Int32 i = 2; i <= EncoderLineParagraph; i++)
{
seqNo++;
var cableConnectionType = "中段";
if (i >= EncoderLineParagraph)
{
cableConnectionType = "尾段";
}
var encoderLine = new LectotypeLineModel
{
SeqNo = seqNo,
//MechanicalNo = MechanicalNo,
//MechanicalName = MechanicalName,
AxisNo = AxisNo,
//MotorSerie = MotorSerie,
//MotorPower = MotorPower,
//DriverInterface = DriverInterface,
//DriverModel = DriverModel,
//PowerBrakeLineLength = PowerBrakeLineLength,
//DrawingNo = DrawingNo,
//CableModelNo = CableModelNo,
CableConnectionClass = cableConnectionType,
CableType = "编码器线",
LineCount = EncoderLineParagraph,
//PowerLineLength = PowerLineLength,
//CurrentLineNumber = i,
CurrentLine = i,
//CableFlag = GetCableModelFlag(MotorPower, PowerLineName, cableConnectionType, false)
Motor = Motor,
IsLectotype = true
};
encoderLine.DrawingNo = encoderLine.GetCableDrawNo();
encoderLine.SubLines = GetSubLines(encoderLine.DrawingNo);
LectotypeList.Add(encoderLine);
}
}
else
{
LectotypeList.Add(line);
}
SelectedLines = LectotypeList;
}
private List<LectotypeLineModel> GetSubLines(string drawingNo)
{
return MotorExcelHelper.Instance.GetBomList(drawingNo).Where(it =>
{
return it.Name == "编码器线" || it.Name == "动力线";
}).Select(it => new LectotypeLineModel
{
SeqNo = 0,
CableModel = it.Spec,
CableType = it.Name
}).ToList();
}
private void ShowError(string msg)
{
Growl.Error(msg, MESSAGE_KEY);
}
#region Props
public List<ConfigItemModel> CableTypes
{
get
{
return [
new ConfigItemModel{
ItemName = "编码器线+动力线",
ItemValue = "编码器线+动力线"
},
new ConfigItemModel{
ItemName = "编码器线+动力刹车线",
ItemValue = "编码器线+动力刹车线"
},
];
}
set
{
OnPropertyChanged(nameof(CableTypes));
}
}
private List<LectotypeLineModel> _selectedLines = [];
public List<LectotypeLineModel> SelectedLines
{
get => _selectedLines;
set
{
_selectedLines = value;
OnPropertyChanged(nameof(SelectedLines));
}
}
public CableLectotypeViewModel(MotorModel motor)
{
Motor = motor;
if (motor != null && !string.IsNullOrEmpty(motor.AxisNo))
{
AxisNo = motor.AxisNo;
}
}
private MotorModel _motor;
public MotorModel Motor
{
get { return _motor; }
set
{
_motor = value;
OnPropertyChanged(nameof(Motor));
}
}
private ConnectionType _cableConnectionType = ConnectionType.FullParagraph;
public ConnectionType CableConnectionType
{
get { return _cableConnectionType; }
set
{
_cableConnectionType = value;
OnPropertyChanged(nameof(CableConnectionType));
if (_cableConnectionType == ConnectionType.Passthrough)
{
IsEnableParagraph = false;
PowerLineParagraph = 1;
EncoderLineParagraph = 1;
}
else
{
IsEnableParagraph = true;
PowerLineParagraph = 3;
EncoderLineParagraph = 3;
}
}
}
private string _axison;
public string AxisNo
{
get { return _axison; }
set
{
_axison = value;
OnPropertyChanged(nameof(AxisNo));
}
}
private string _cableType;
public string CableType
{
get { return _cableType; }
set
{
_cableType = value;
OnPropertyChanged(nameof(CableType));
}
}
private int _encoderLineParagraph;
public int EncoderLineParagraph
{
get { return _encoderLineParagraph; }
set
{
_encoderLineParagraph = value;
OnPropertyChanged(nameof(EncoderLineParagraph));
}
}
private int _powerLineParagraph;
public int PowerLineParagraph
{
get { return _powerLineParagraph; }
set
{
_powerLineParagraph = value;
OnPropertyChanged(nameof(PowerLineParagraph));
}
}
private string _cableModelStr;
public string CableModelStr
{
get { return _cableModelStr; }
set
{
_cableModelStr = value;
OnPropertyChanged(nameof(CableModelStr));
}
}
private bool _isEnableParagraph = true;
public bool IsEnableParagraph
{
get => _isEnableParagraph;
set
{
_isEnableParagraph = value;
OnPropertyChanged(nameof(IsEnableParagraph));
}
}
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
#endregion
}

File diff suppressed because it is too large Load Diff

View File

@ -42,7 +42,7 @@ namespace Sinvo.EplanHpD.Plugin
.FirstOrDefault(a => a.FullName == assemblyName.FullName);
if (loadedAssembly != null)
{
Debug.WriteLine($"Dll is loaded -> {loadedAssembly.FullName}");
Debug.WriteLine($"DLL is loaded -> {loadedAssembly.FullName}");
return loadedAssembly;
}

View File

@ -48,6 +48,8 @@ namespace Sinvo.EplanHpD.Plugin
public HpDModule Module => HpDModule.WorkSpace;
public string ToolbarTooltip => "伺服电机线缆抓取";
public void Execute(HpdApi api)
{
var doc = api.CurrentProject.GetActiveDocument();
@ -63,7 +65,6 @@ namespace Sinvo.EplanHpD.Plugin
{
AppDomainDllLoader.SetLaoder();
ApplicationExt.InitApplication();
}

View File

@ -28,6 +28,6 @@ using System.Runtime.InteropServices;
// 生成号
// 修订号
//
[assembly: AssemblyVersion("1.0.0.18")]
[assembly: AssemblyFileVersion("1.0.0.18")]
[assembly: AssemblyInformationalVersion("1.0.0.16")]
[assembly: AssemblyVersion("1.0.0.19")]
[assembly: AssemblyFileVersion("1.0.0.19")]
[assembly: AssemblyInformationalVersion("1.0.0.19")]

View File

@ -81,7 +81,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>RefDLL\EPLAN.Harness.AppCore.dll</HintPath>
</Reference>
<Reference Include="EPLAN.Harness.Common, Version=2.9.2.903, Culture=neutral, PublicKeyToken=57aaa27e22f7b107" />
<Reference Include="EPLAN.Harness.Common">
<HintPath>RefDLL\EPLAN.Harness.Common.dll</HintPath>
</Reference>
<Reference Include="EPLAN.Harness.Core, Version=2.9.2.903, Culture=neutral, PublicKeyToken=57aaa27e22f7b107, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>RefDLL\EPLAN.Harness.Core.dll</HintPath>