From 509f4d36702bf3a975fddd962d10f0e304beec66 Mon Sep 17 00:00:00 2001 From: lihanbo Date: Wed, 2 Apr 2025 17:24:34 +0800 Subject: [PATCH] =?UTF-8?q?105040=20Update=20=E6=9B=B4=E6=96=B0=E7=94=B5?= =?UTF-8?q?=E6=9C=BA=E6=97=A0=E5=89=8D=E6=AE=B5=E7=BA=BF=E7=9A=84=E5=8A=9F?= =?UTF-8?q?=E7=8E=87=E8=8C=83=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Datas/BrandData.cs | 9 ++ Sinvo.EplanHpD.Plugin.WPFUI/Datas/Brands.cs | 12 +- .../ViewModel/CableLectotypeViewModel.cs | 133 ++++++------------ 3 files changed, 60 insertions(+), 94 deletions(-) diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Datas/BrandData.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Datas/BrandData.cs index e8dc3c8..0879350 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/Datas/BrandData.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Datas/BrandData.cs @@ -35,5 +35,14 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Datas /// 型号后缀 /// public string Suffix { get; set; } + + /// + /// 电机带前段线的功率范围,起始(>) + /// + public double MotorCablePowerRangeStart { get; set; } + /// + /// 电机带前段线的功率范围,结束(<=) + /// + public double MotorCablePowerRangeEnd { get; set; } } } diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Datas/Brands.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Datas/Brands.cs index bf2cfb1..8e6d580 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/Datas/Brands.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Datas/Brands.cs @@ -49,7 +49,9 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Datas SheetName = ANCHUAN, Prefix = "JZSP-", MotorPrefix = "SGMX", - Suffix = "-E" + Suffix = "-E", + MotorCablePowerRangeStart = 0, + MotorCablePowerRangeEnd = 750 } }, {HUICHUAN, @@ -59,7 +61,9 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Datas SheetName = HUICHUAN, Prefix = "S6-L-", MotorPrefix = "MS1H", - Suffix = "" + Suffix = "", + MotorCablePowerRangeStart = 0, + MotorCablePowerRangeEnd = 0 } }, {SANLING_HK_KT, @@ -69,7 +73,9 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Datas SheetName = SANLING_HK_KT, Prefix = "MR-", MotorPrefix = "HK-KT", - Suffix = "" + Suffix = "", + MotorCablePowerRangeStart = 0, + MotorCablePowerRangeEnd = 0 } }, }; diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/CableLectotypeViewModel.cs b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/CableLectotypeViewModel.cs index 998b16d..2233491 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/CableLectotypeViewModel.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/CableLectotypeViewModel.cs @@ -1,4 +1,5 @@ using EPLAN.Harness.Core.Controls; +using EPLAN.Harness.Core.LibEntities.Enums; using HandyControl.Controls; using Sinvo.EplanHpD.Plugin.Service; using Sinvo.EplanHpD.Plugin.WPFUI.Datas; @@ -89,7 +90,7 @@ public class CableLectotypeViewModel : INotifyPropertyChanged }; line.DrawingNo = line.GetCableDrawNo(); line.SubLines = GetSubLines(line.DrawingNo); - var startIndex = 0; + var startIndex = 1; if (CableConnectionType == ConnectionType.FullParagraph) { LectotypeList.Clear(); @@ -104,7 +105,7 @@ public class CableLectotypeViewModel : INotifyPropertyChanged { var motorPower = MotorExcelHelper.Instance.GetMotorPower(Motor.MotorModelStr); // 功率750W以下的电机,不需要前段线 - if (motorPower <= 750) + if (motorPower > brandData.MotorCablePowerRangeStart && motorPower <= brandData.MotorCablePowerRangeEnd) { seqNo = 1; startIndex = 1; @@ -127,26 +128,11 @@ public class CableLectotypeViewModel : INotifyPropertyChanged var secLine = new LectotypeLineModel - { - //SeqNo = seqNo, - //MechanicalNo = MechanicalNo, - //MechanicalName = MechanicalName, - AxisNo = AxisNo, - //MotorSerie = MotorSerie, - //MotorPower = Motor.MotorPower, - //DriverInterface = DriverInterface, - //DriverModel = DriverModel, + { + AxisNo = AxisNo, CableConnectionClass = CableConnectionType == ConnectionType.FullParagraph ? "前段" : "直通", - CableType = CableTypeSecond, - //IsFlexibility = IsFlexibility, - //PowerLineLength = PowerLineLength, - //EncoderLineLength = EncoderLineLength, - //PowerBrakeLineLength = PowerBrakeLineLength, - //DrawingNo = LineModelStr, - CableModelNo = CableModelStr, - //LineCount = Math.Max(PowerLineCount, EncoderLineCount), - //CurrentLineNumber = 1, - //BomList = GenBomListByCurrent(DrawingNo) + CableType = CableTypeSecond, + CableModelNo = CableModelStr, IsLectotype = true, CurrentLine = 1, Motor = Motor @@ -158,6 +144,7 @@ public class CableLectotypeViewModel : INotifyPropertyChanged } else { + startIndex = 2; LectotypeList.Add(line); } @@ -206,24 +193,11 @@ public class CableLectotypeViewModel : INotifyPropertyChanged } 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 = CableTypePrimary, LineCount = EncoderLineParagraph, - //PowerLineLength = PowerLineLength, - //CurrentLineNumber = i, CurrentLine = i, - //CableFlag = GetCableModelFlag(MotorPower, PowerLineName, cableConnectionType, false) Motor = Motor, IsLectotype = true }; @@ -241,26 +215,11 @@ public class CableLectotypeViewModel : INotifyPropertyChanged if (_passthroughCableCount >= 2) { var secLine = new LectotypeLineModel - { - //SeqNo = seqNo, - //MechanicalNo = MechanicalNo, - //MechanicalName = MechanicalName, - AxisNo = AxisNo, - //MotorSerie = MotorSerie, - //MotorPower = Motor.MotorPower, - //DriverInterface = DriverInterface, - //DriverModel = DriverModel, + { + AxisNo = AxisNo, CableConnectionClass = "直通", - CableType = CableTypeSecond, - //IsFlexibility = IsFlexibility, - //PowerLineLength = PowerLineLength, - //EncoderLineLength = EncoderLineLength, - //PowerBrakeLineLength = PowerBrakeLineLength, - //DrawingNo = LineModelStr, - CableModelNo = CableModelStr, - //LineCount = Math.Max(PowerLineCount, EncoderLineCount), - //CurrentLineNumber = 1, - //BomList = GenBomListByCurrent(DrawingNo) + CableType = CableTypeSecond, + CableModelNo = CableModelStr, IsLectotype = true, CurrentLine = 1, Motor = Motor @@ -272,26 +231,11 @@ public class CableLectotypeViewModel : INotifyPropertyChanged if (_passthroughCableCount >= 3) { var secLine = new LectotypeLineModel - { - //SeqNo = seqNo, - //MechanicalNo = MechanicalNo, - //MechanicalName = MechanicalName, - AxisNo = AxisNo, - //MotorSerie = MotorSerie, - //MotorPower = Motor.MotorPower, - //DriverInterface = DriverInterface, - //DriverModel = DriverModel, + { + AxisNo = AxisNo, 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) + CableType = CableTypeThree, + CableModelNo = CableModelStr, IsLectotype = true, CurrentLine = 1, Motor = Motor @@ -314,7 +258,7 @@ public class CableLectotypeViewModel : INotifyPropertyChanged private List GetSubLines(string drawingNo) { - return MotorExcelHelper.Instance.GetBomList(drawingNo).Where(it => + return [.. MotorExcelHelper.Instance.GetBomList(drawingNo).Where(it => { // BOM表中只有 编码器线 和 动力线 不区分是不是带刹车 return it.Name == "编码器线" || it.Name == "动力线" || it.Name == "刹车线"; @@ -323,7 +267,7 @@ public class CableLectotypeViewModel : INotifyPropertyChanged SeqNo = 0, CableModel = it.Spec, CableType = it.Name - }).ToList(); + })]; } private void ShowError(string msg) { @@ -339,17 +283,9 @@ public class CableLectotypeViewModel : INotifyPropertyChanged { get { - var brandData = Brands.GetBrandData(Motor.Brand); - var isCombo = brandData.ComplexLine; + // 三菱电机选两种线之后再进行合并 var types = motorExcelHelper.GetCableTypes(); - if(isCombo) - { - return [.. types.Where(it => it.ItemFlag == "是")]; - } - else - { - return [.. types.Where(it => it.ItemFlag == "否")]; - } + return [.. types.Where(it => it.ItemFlag == "否")]; } set { @@ -475,13 +411,13 @@ public class CableLectotypeViewModel : INotifyPropertyChanged } - private string _axison; + private string _axisNo; public string AxisNo { - get { return _axison; } + get { return _axisNo; } set { - _axison = value; + _axisNo = value; OnPropertyChanged(nameof(AxisNo)); } } @@ -600,7 +536,7 @@ public class CableLectotypeViewModel : INotifyPropertyChanged CableModelStr = viewModel.CableModelStr; SelectedLines = []; // 深拷贝 SelectedLines - SelectedLines.AddRange(viewModel.SelectedLines.Select(line => new LectotypeLineModel + SelectedLines.AddRange([.. viewModel.SelectedLines.Select(line => new LectotypeLineModel { SeqNo = line.SeqNo, MechanicalNo = line.MechanicalNo, @@ -618,17 +554,32 @@ public class CableLectotypeViewModel : INotifyPropertyChanged Motor = line.Motor, IsLectotype = line.IsLectotype, IsComplete = line.IsComplete, - SubLines = line.SubLines.Select(subLine => new LectotypeLineModel + SubLines = [.. line.SubLines.Select(subLine => new LectotypeLineModel { SeqNo = subLine.SeqNo, CableModel = subLine.CableModel, CableType = subLine.CableType, IsChecked = subLine.IsChecked, LectotypeLineId = subLine.LectotypeLineId - }).ToList() - }).ToList()); + })] + }).OrderBy(it => it.CurrentLine).ThenBy(it => it.CableType)]); OnPropertyChanged(nameof(SelectedLines)); } + + //public void OnChange() + //{ + // if(Motor != null) + // { + // var motorData = Brands.GetBrandData(Motor.Brand); + // if(motorData != null) + // { + // if (motorData.ComplexLine) + // { + // IsEnableSecCableType = false; + // } + // } + // } + //} #endregion }