From 5d198a137acaa2f2200b2b2203bc0ccfda237f1a Mon Sep 17 00:00:00 2001 From: lihanbo Date: Fri, 28 Mar 2025 16:50:08 +0800 Subject: [PATCH] =?UTF-8?q?105040=20Update=20=E6=8B=86=E5=88=86=E7=BA=BF?= =?UTF-8?q?=E6=9D=90=E5=9E=8B=E5=8F=B7=E7=94=9F=E6=88=90=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Utils/LectotypeLineModelExt.cs | 121 ++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 Sinvo.EplanHpD.Plugin.WPFUI/Utils/LectotypeLineModelExt.cs diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Utils/LectotypeLineModelExt.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/LectotypeLineModelExt.cs new file mode 100644 index 0000000..90b8f5d --- /dev/null +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/LectotypeLineModelExt.cs @@ -0,0 +1,121 @@ +using EPLAN.Harness.Core.LibEntities.Enums; +using Sinvo.EplanHpD.Plugin.Service.Model; +using Sinvo.EplanHpD.Plugin.WPFUI.Datas; +using Sinvo.EplanHpD.Plugin.WPFUI.Models; +using System.Diagnostics; +using System.Text; + +namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils +{ + public static class LectotypeLineModelExt + { + public static string GenCableModelNo(this LectotypeLineModel model) + { + Stopwatch stopwatch = new Stopwatch(); + stopwatch.Start(); + model.DrawingNo = ""; + if (model.Motor == null) + { + return ""; + } + var brandData = Brands.GetBrandData(model.Motor.Brand); + var ModelNo = new StringBuilder(); + if (brandData != null) + { + //ModelNo += brandData.Prefix; + ModelNo.Append(brandData.Prefix); + } + else + { + return ""; + } + var cableFlag = model.GetCableModelFlag(model.Motor?.MotorPower, model.CableType, model.CableConnectionClass, model.IsFlexibility); + if (string.IsNullOrWhiteSpace(cableFlag)) + { + + return ""; + } + else + { + //ModelNo += cableFlag + "-"; + ModelNo.Append(cableFlag); + ModelNo.Append("-"); + + } + //编码器线+动力线 编码器线+动力刹车线 + if (model.CableType is "编码器线+动力线" or "编码器线+动力刹车线") // 组合线 + ModelNo.Append("A1-"); + + //ModelNo += "A1-"; + + if (model.IsFlexibility) + { + //ModelNo += "H-"; + ModelNo.Append("H-"); + } + else + { + //ModelNo += "L-"; + ModelNo.Append("L-"); + + } + if (model.IsComplexLine) + { + //ModelNo += $"{model.EncoderLineLength}-{model.PowerLineLength}"; + ModelNo.Append(model.EncoderLineLength); + ModelNo.Append("-"); + ModelNo.Append(model.PowerLineLength); + } + else if (model.IsEncoderLine) + { + //ModelNo += $"{model.EncoderLineLength}"; + ModelNo.Append(model.EncoderLineLength); + } + else if (model.IsPowerLine) + { + //ModelNo += $"{model.PowerLineLength}"; + ModelNo.Append(model.PowerLineLength); + } + else + { + //ModelNo += $"{model.PowerLineLength}"; + ModelNo.Append(model.PowerLineLength); + } + if (!string.IsNullOrEmpty(model.AxisNo)) + { + ModelNo.Append(brandData.Suffix); + //if (model.Motor.Brand == Brands.SANLING_HK_KT) + { + //ModelNo += "("; + ModelNo.Append("("); + } + //if (model.Motor.Brand == Brands.ANCHUAN) + //{ + // //ModelNo += "-E("; + // ModelNo.Append("-E("); + //} + //ModelNo += $"{model.AxisNo}"; + ModelNo.Append(model.AxisNo); + if (model.CableConnectionClass != "直通") + { + //if (!(CableType is "编码器线+动力线" or "编码器线+动力刹车线")) + //ModelNo += $"-{model.CurrentLine}/{model.LineCount}"; + ModelNo.Append("-"); + ModelNo.Append(model.CurrentLine); + ModelNo.Append("/"); + ModelNo.Append(model.LineCount); + } + //ModelNo += ")/定制"; + ModelNo.Append(")/定制"); + } + //if (isUpdateDrawNo) + { + model.DrawingNo = model.GetCableDrawNo(); + } + stopwatch.Stop(); + Debug.Print($"CableModelNo {ModelNo} : {stopwatch.ElapsedMilliseconds}ms"); + + return ModelNo.ToString(); + } + } +}