105040 Update 增加第三种直通线选择,可选择的线材种类数量由配置表决定

增加 CableTypeThree 属性及相关处理

在 CableLectotype.cs 文件中增加了 CableTypeThree 属性,并设置了 SugarColumn(IsNullable = true)。
在 MotorLectotypeService.cs 文件中增加了对 CableTypeThree 属性的处理。
在 Sinvo.EplanHpD.Plugin.WPFUI.csproj 文件中增加了对 MotorPassthroughCable.cs 文件的编译包含。
在 MotorExcelHelper.cs 文件中增加了 GetPassthroughCableCount 方法。
在 CableLectotypeUserControl.xaml 文件中修改了 hc:SimpleStackPanel 的 Visibility 绑定属性。
在 CableLectotypeUserControl.xaml.cs 文件中增加了对 EPLAN.Harness.Core.Interfaces 的引用,并在 CableLectotypeViewModel 类中增加了一个实例。
在 CableLectotypeViewModel.cs 文件中增加了对 CableTypeThree 属性的处理,并增加了 _passthroughCableCount 和 IsEnableThreeCableType 属性及其相关逻辑。
在 MotorPassthroughCable.cs 文件中增加了 MotorPassthroughCable 类,用于表示电机直通线数量。
This commit is contained in:
lihanbo 2025-02-14 09:22:11 +08:00
parent 823f8998de
commit d7f61b0db3
8 changed files with 179 additions and 51 deletions

View File

@ -30,6 +30,8 @@ namespace Sinvo.EplanHpD.Plugin.Service.Model
[SugarColumn(IsNullable = true)] [SugarColumn(IsNullable = true)]
public string CableTypeSecond { get; set; } public string CableTypeSecond { get; set; }
[SugarColumn(IsNullable = true)]
public string CableTypeThree { get; set; }
[SugarColumn(IsNullable = true)] [SugarColumn(IsNullable = true)]
public int EncoderLineParagraph { get; set; } public int EncoderLineParagraph { get; set; }

View File

@ -0,0 +1,49 @@
using MiniExcelLibs.Attributes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
{
/// <summary>
/// 电机直通线数量
/// </summary>
public class MotorPassthroughCable
{
/*
线线 线 线 线
*/
/// <summary>
/// 电机型号
/// </summary>
[ExcelColumn(Name = "电机型号")]
public string MotorModel { get; set; }
/// <summary>
/// 动力线或动力刹车直通线数量
/// </summary>
[ExcelColumn(Name = "动力线或动力刹车直通线数量")]
public int PowerOrBrakeCableCount { get; set; }
/// <summary>
/// 编码器直通线数量
/// </summary>
[ExcelColumn(Name = "编码器直通线数量")]
public int EncoderCableCount { get; set; }
/// <summary>
/// 直通刹车线数量
/// </summary>
[ExcelColumn(Name = "直通刹车线数量")]
public int BrakeCableCount { get; set; }
/// <summary>
/// 直通线总数量
/// </summary>
[ExcelColumn(Name = "直通线总数量")]
public int TotalCableCount { get; set; }
}
}

View File

@ -105,6 +105,7 @@ namespace Sinvo.EplanHpD.Plugin.Service
AxisNo = cableLectotype.AxisNo, AxisNo = cableLectotype.AxisNo,
CableTypePrimary = cableLectotype.CableTypePrimary, CableTypePrimary = cableLectotype.CableTypePrimary,
CableTypeSecond = cableLectotype.CableTypeSecond, CableTypeSecond = cableLectotype.CableTypeSecond,
CableTypeThree = cableLectotype.CableTypeThree,
EncoderLineParagraph = cableLectotype.EncoderLineParagraph, EncoderLineParagraph = cableLectotype.EncoderLineParagraph,
PowerLineParagraph = cableLectotype.PowerLineParagraph, PowerLineParagraph = cableLectotype.PowerLineParagraph,
CableModelStr = cableLectotype.CableModelStr, CableModelStr = cableLectotype.CableModelStr,
@ -201,6 +202,7 @@ namespace Sinvo.EplanHpD.Plugin.Service
AxisNo = data.AxisNo, AxisNo = data.AxisNo,
CableTypePrimary = data.CableTypePrimary, CableTypePrimary = data.CableTypePrimary,
CableTypeSecond = data.CableTypeSecond, CableTypeSecond = data.CableTypeSecond,
CableTypeThree = data.CableTypeThree,
EncoderLineParagraph = data.EncoderLineParagraph, EncoderLineParagraph = data.EncoderLineParagraph,
PowerLineParagraph = data.PowerLineParagraph, PowerLineParagraph = data.PowerLineParagraph,
CableModelStr = data.CableModelStr, CableModelStr = data.CableModelStr,

View File

@ -261,6 +261,7 @@
<Compile Include="Models\LineBomItemModel.cs" /> <Compile Include="Models\LineBomItemModel.cs" />
<Compile Include="Models\LineBomModel.cs" /> <Compile Include="Models\LineBomModel.cs" />
<Compile Include="Models\MotorModel.cs" /> <Compile Include="Models\MotorModel.cs" />
<Compile Include="Models\MotorPassthroughCable.cs" />
<Compile Include="Models\ReportModel.cs" /> <Compile Include="Models\ReportModel.cs" />
<Compile Include="Models\ScanCableModel.cs" /> <Compile Include="Models\ScanCableModel.cs" />
<Compile Include="Models\StuffedDataModel.cs" /> <Compile Include="Models\StuffedDataModel.cs" />

View File

@ -14,7 +14,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
private Stream dataFileStream; private Stream dataFileStream;
#if DEBUG #if DEBUG
public const string DATA_FILE_PATH = @"D:\旧电脑文件\Desktop\EPlan\线材选型"; public const string DATA_FILE_PATH = @"D:\Desktop\EPlan\线材选型";
#else #else
public const string DATA_FILE_PATH = @"\\192.168.1.160\plm系统文档\线材选型\插件";//@"D:\旧电脑文件\Desktop\EPlan\线材选型";// public const string DATA_FILE_PATH = @"\\192.168.1.160\plm系统文档\线材选型\插件";//@"D:\旧电脑文件\Desktop\EPlan\线材选型";//
@ -118,7 +118,20 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
obj => obj.ToString().GetHashCode() obj => obj.ToString().GetHashCode()
)).OrderBy(it => it.ItemValue).ToList(); )).OrderBy(it => it.ItemValue).ToList();
} }
/// <summary>
/// 获取直通线数量
/// </summary>
/// <param name="motorModel"></param>
/// <returns></returns>
public List<MotorPassthroughCable> GetPassthroughCableCount(string motorModel)
{
if (dataFileStream == null || !dataFileStream.CanRead)
{
// 未初始化或是无法读取时,重试一次
ReadDataToStream();
}
return MiniExcel.Query<MotorPassthroughCable>(dataFileStream, sheetName: "直通线数量").Where(it => it.MotorModel == motorModel).ToList();
}
public List<LineBomModel> GetBomList(string drawNo) public List<LineBomModel> GetBomList(string drawNo)
{ {
//var filePath = "D:\\Desktop\\Data\\BOM表.xlsx"; //var filePath = "D:\\Desktop\\Data\\BOM表.xlsx";

View File

@ -170,7 +170,7 @@
IsReadOnly="False" IsReadOnly="False"
Text="{Binding EncoderLineParagraph, Mode=TwoWay}" /> Text="{Binding EncoderLineParagraph, Mode=TwoWay}" />
</hc:SimpleStackPanel> </hc:SimpleStackPanel>
<hc:SimpleStackPanel Orientation="Horizontal"> <hc:SimpleStackPanel Orientation="Horizontal" Visibility="{Binding IsEnableSecCableType, Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}">
<hc:SimpleStackPanel <hc:SimpleStackPanel
Width="200" Width="200"
VerticalAlignment="Center" VerticalAlignment="Center"
@ -193,7 +193,7 @@
IsReadOnly="False" IsReadOnly="False"
Text="{Binding PowerLineParagraph, Mode=TwoWay}" /> Text="{Binding PowerLineParagraph, Mode=TwoWay}" />
</hc:SimpleStackPanel> </hc:SimpleStackPanel>
<hc:SimpleStackPanel Orientation="Horizontal" Visibility="{Binding IsShowThreeCableType, Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}"> <hc:SimpleStackPanel Orientation="Horizontal" Visibility="{Binding IsEnableThreeCableType, Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}">
<hc:SimpleStackPanel <hc:SimpleStackPanel
Width="200" Width="200"
VerticalAlignment="Center" VerticalAlignment="Center"
@ -202,7 +202,7 @@
Width="153" Width="153"
hc:InfoElement.ShowClearButton="True" hc:InfoElement.ShowClearButton="True"
DisplayMemberPath="ItemName" DisplayMemberPath="ItemName"
IsEnabled="{Binding IsEnableSecCableType}" IsEnabled="{Binding IsEnableThreeCableType}"
ItemsSource="{Binding CableTypes}" ItemsSource="{Binding CableTypes}"
SelectedIndex="0" SelectedIndex="0"
SelectedValue="{Binding CableTypeThree}" SelectedValue="{Binding CableTypeThree}"

View File

@ -22,6 +22,7 @@ using System.Linq;
using EPLAN.Harness.ProjectCore.Occurrences; using EPLAN.Harness.ProjectCore.Occurrences;
using Sinvo.EplanHpD.Plugin.WPFUI.Extension; using Sinvo.EplanHpD.Plugin.WPFUI.Extension;
using Sinvo.EplanHpD.Plugin.Service.Model; using Sinvo.EplanHpD.Plugin.Service.Model;
using EPLAN.Harness.Core.Interfaces;
namespace Sinvo.EplanHpD.Plugin.WPFUI.View namespace Sinvo.EplanHpD.Plugin.WPFUI.View
{ {
@ -47,6 +48,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
} }
} }
private CableLectotypeViewModel ViewModel = new CableLectotypeViewModel(); private CableLectotypeViewModel ViewModel = new CableLectotypeViewModel();
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;

View File

@ -59,7 +59,7 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
ShowWarning("请选择线材类型!"); ShowWarning("请选择线材类型!");
return; return;
} }
if (CableTypePrimary.Equals(CableTypeSecond)) if (CableTypePrimary.Equals(CableTypeSecond) || CableTypePrimary.Equals(CableTypeThree) || CableTypeThree.Equals(CableTypeSecond))
{ {
ShowWarning("不能选择同样的线段类型!"); ShowWarning("不能选择同样的线段类型!");
return; return;
@ -225,36 +225,70 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
{ {
LectotypeList.Add(line); LectotypeList.Add(line);
// 安川电机,允许有两条直通线 // 安川电机,允许有两条直通线
if ( !string.IsNullOrEmpty(CableTypeSecond) && Motor.Brand == Brands.ANCHUAN) if (!string.IsNullOrEmpty(CableTypeSecond) && Motor.Brand == Brands.ANCHUAN)
{ {
var secLine = new LectotypeLineModel if (_passthroughCableCount >= 2)
{ {
SeqNo = seqNo, var secLine = new LectotypeLineModel
//MechanicalNo = MechanicalNo, {
//MechanicalName = MechanicalName, SeqNo = seqNo,
AxisNo = AxisNo, //MechanicalNo = MechanicalNo,
//MotorSerie = MotorSerie, //MechanicalName = MechanicalName,
//MotorPower = Motor.MotorPower, AxisNo = AxisNo,
//DriverInterface = DriverInterface, //MotorSerie = MotorSerie,
//DriverModel = DriverModel, //MotorPower = Motor.MotorPower,
CableConnectionClass = "直通", //DriverInterface = DriverInterface,
CableType = CableTypeSecond, //DriverModel = DriverModel,
//IsFlexibility = IsFlexibility, CableConnectionClass = "直通",
//PowerLineLength = PowerLineLength, CableType = CableTypeSecond,
//EncoderLineLength = EncoderLineLength, //IsFlexibility = IsFlexibility,
//PowerBrakeLineLength = PowerBrakeLineLength, //PowerLineLength = PowerLineLength,
//DrawingNo = LineModelStr, //EncoderLineLength = EncoderLineLength,
CableModelNo = CableModelStr, //PowerBrakeLineLength = PowerBrakeLineLength,
//LineCount = Math.Max(PowerLineCount, EncoderLineCount), //DrawingNo = LineModelStr,
//CurrentLineNumber = 1, CableModelNo = CableModelStr,
//BomList = GenBomListByCurrent(DrawingNo) //LineCount = Math.Max(PowerLineCount, EncoderLineCount),
IsLectotype = true, //CurrentLineNumber = 1,
CurrentLine = 1, //BomList = GenBomListByCurrent(DrawingNo)
Motor = Motor IsLectotype = true,
}; CurrentLine = 1,
secLine.DrawingNo = secLine.GetCableDrawNo(); Motor = Motor
secLine.SubLines = GetSubLines(secLine.DrawingNo); };
LectotypeList.Add(secLine); secLine.DrawingNo = secLine.GetCableDrawNo();
secLine.SubLines = GetSubLines(secLine.DrawingNo);
LectotypeList.Add(secLine);
}
if (_passthroughCableCount >= 3)
{
var secLine = new LectotypeLineModel
{
SeqNo = seqNo,
//MechanicalNo = MechanicalNo,
//MechanicalName = MechanicalName,
AxisNo = AxisNo,
//MotorSerie = MotorSerie,
//MotorPower = Motor.MotorPower,
//DriverInterface = DriverInterface,
//DriverModel = DriverModel,
CableConnectionClass = "直通",
CableType = CableTypeThree,
//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
};
secLine.DrawingNo = secLine.GetCableDrawNo();
secLine.SubLines = GetSubLines(secLine.DrawingNo);
LectotypeList.Add(secLine);
}
} }
} }
@ -344,6 +378,7 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
{ {
_motor = value; _motor = value;
OnPropertyChanged(nameof(Motor)); OnPropertyChanged(nameof(Motor));
UpdatePassthroughCableCount();
} }
} }
@ -360,13 +395,50 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
IsEnableParagraph = !(_cableConnectionType == ConnectionType.Passthrough); IsEnableParagraph = !(_cableConnectionType == ConnectionType.Passthrough);
PowerLineParagraph = 0; PowerLineParagraph = 0;
EncoderLineParagraph = 0; EncoderLineParagraph = 0;
if (!IsEnableParagraph && Motor.Brand != Brands.ANCHUAN) if (!IsEnableParagraph)
{ {
IsEnableSecCableType = false; UpdatePassthroughCableCount();
} }
else else
{
IsEnableThreeCableType = false;
}
}
}
public int _passthroughCableCount = 0;
private bool _isEnableThreeCableType = false;
public bool IsEnableThreeCableType
{
get { return _isEnableThreeCableType; }
set
{
_isEnableThreeCableType = value;
OnPropertyChanged(nameof(IsEnableThreeCableType));
}
}
public void UpdatePassthroughCableCount()
{
if (_motor != null)
{
var passthroughCables = MotorExcelHelper.Instance.GetPassthroughCableCount(_motor.MotorModelStr).FirstOrDefault();
_passthroughCableCount = passthroughCables.TotalCableCount;
if (_passthroughCableCount == 2)
{ {
IsEnableSecCableType = true; IsEnableSecCableType = true;
IsEnableThreeCableType = false;
}
if (_passthroughCableCount == 3)
{
IsEnableSecCableType = true;
IsEnableThreeCableType = true;
}
if (_passthroughCableCount == 1)
{
IsEnableSecCableType = false;
IsEnableThreeCableType = false;
} }
} }
} }
@ -464,20 +536,6 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
OnPropertyChanged(nameof(IsEnableSecCableType)); OnPropertyChanged(nameof(IsEnableSecCableType));
} }
} }
/// <summary>
/// 是否显示第三种线材类型
/// </summary>
private bool _isShowThreeCableType = false;
public bool IsShowThreeCableType
{
get => _isShowThreeCableType;
set
{
_isShowThreeCableType = value;
OnPropertyChanged(nameof(IsShowThreeCableType));
}
}
public bool SaveToDb() public bool SaveToDb()
{ {
//var service = new MotorLectotypeService(); //var service = new MotorLectotypeService();
@ -504,6 +562,7 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
AxisNo = viewModel.AxisNo; AxisNo = viewModel.AxisNo;
CableTypePrimary = viewModel.CableTypePrimary; CableTypePrimary = viewModel.CableTypePrimary;
CableTypeSecond = viewModel.CableTypeSecond; CableTypeSecond = viewModel.CableTypeSecond;
CableTypeThree = viewModel.CableTypeThree;
EncoderLineParagraph = viewModel.EncoderLineParagraph; EncoderLineParagraph = viewModel.EncoderLineParagraph;
PowerLineParagraph = viewModel.PowerLineParagraph; PowerLineParagraph = viewModel.PowerLineParagraph;
CableModelStr = viewModel.CableModelStr; CableModelStr = viewModel.CableModelStr;