105040 Update 增加汇川电机信息,优化多品牌识别逻辑
This commit is contained in:
parent
6b02c0fa68
commit
cde4bc41de
|
@ -0,0 +1,39 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.Datas
|
||||
{
|
||||
public class BrandData
|
||||
{
|
||||
/// <summary>
|
||||
/// 品牌名称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
/// <summary>
|
||||
/// 是否使用复合线
|
||||
/// </summary>
|
||||
public bool ComplexLine { get; set; }
|
||||
/// <summary>
|
||||
/// 使用的数据表
|
||||
/// </summary>
|
||||
public string SheetName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 型号前缀
|
||||
/// </summary>
|
||||
public string Prefix { get; set; }
|
||||
/// <summary>
|
||||
/// 电机型号前缀
|
||||
/// </summary>
|
||||
public string MotorPrefix { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 型号后缀
|
||||
/// </summary>
|
||||
public string Suffix { get; set; }
|
||||
}
|
||||
}
|
|
@ -13,7 +13,65 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Datas
|
|||
{
|
||||
public const string UNKNOWN = "未知";
|
||||
public const string ANCHUAN = "安川";
|
||||
public const string HUICHUAN = "汇川";
|
||||
public const string SANLING = "三菱";
|
||||
public const string SANLING_HK_KT = "HK-KT";
|
||||
|
||||
|
||||
public static BrandData GetBrandData(string brandName)
|
||||
{
|
||||
if(!BrandDataList.ContainsKey(brandName))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return BrandDataList[brandName];
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static Dictionary<string, BrandData> BrandDataList = new Dictionary<string, BrandData>
|
||||
{
|
||||
/*
|
||||
string ModelNo = "MR-";
|
||||
if (model.Motor.Brand == Brands.ANCHUAN)
|
||||
{
|
||||
ModelNo = "JZSP-";
|
||||
}
|
||||
else if((model.Motor.Brand == Brands.HUICHUAN))
|
||||
{
|
||||
ModelNo = "S6-L-";
|
||||
}
|
||||
*/
|
||||
{ANCHUAN,
|
||||
new BrandData{
|
||||
Name = ANCHUAN,
|
||||
ComplexLine = false,
|
||||
SheetName = ANCHUAN,
|
||||
Prefix = "JZSP-",
|
||||
MotorPrefix = "SGMX",
|
||||
Suffix = "-E"
|
||||
}
|
||||
},
|
||||
{HUICHUAN,
|
||||
new BrandData{
|
||||
Name = HUICHUAN,
|
||||
ComplexLine = false,
|
||||
SheetName = HUICHUAN,
|
||||
Prefix = "S6-L-",
|
||||
MotorPrefix = "MS1H",
|
||||
Suffix = ""
|
||||
}
|
||||
},
|
||||
{SANLING_HK_KT,
|
||||
new BrandData{
|
||||
Name = SANLING_HK_KT,
|
||||
ComplexLine = true,
|
||||
SheetName = SANLING_HK_KT,
|
||||
Prefix = "MR-",
|
||||
MotorPrefix = "HK-KT",
|
||||
Suffix = ""
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -293,83 +293,8 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
|
|||
{
|
||||
get
|
||||
{
|
||||
Stopwatch stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
DrawingNo = "";
|
||||
if (Motor == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
string ModelNo = "MR-";
|
||||
if(Motor.Brand == Brands.ANCHUAN)
|
||||
{
|
||||
ModelNo = "JZSP-";
|
||||
}
|
||||
var cableFlag = GetCableModelFlag(Motor?.MotorPower, CableType, CableConnectionClass, IsFlexibility);
|
||||
if (string.IsNullOrWhiteSpace(cableFlag))
|
||||
{
|
||||
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
ModelNo += cableFlag + "-";
|
||||
}
|
||||
//编码器线+动力线 编码器线+动力刹车线
|
||||
if (CableType is "编码器线+动力线" or "编码器线+动力刹车线") // 组合线
|
||||
ModelNo += "A1-";
|
||||
|
||||
if (IsFlexibility)
|
||||
{
|
||||
ModelNo += "H-";
|
||||
}
|
||||
else
|
||||
{
|
||||
ModelNo += "L-";
|
||||
|
||||
}
|
||||
if (IsComplexLine)
|
||||
{
|
||||
ModelNo += $"{EncoderLineLength}-{PowerLineLength}";
|
||||
}
|
||||
else if (IsEncoderLine)
|
||||
{
|
||||
ModelNo += $"{EncoderLineLength}";
|
||||
}
|
||||
else if (IsPowerLine)
|
||||
{
|
||||
ModelNo += $"{PowerLineLength}";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
ModelNo += $"{PowerLineLength}";
|
||||
|
||||
}
|
||||
if (!string.IsNullOrEmpty(AxisNo))
|
||||
{
|
||||
if(Motor.Brand == Brands.SANLING_HK_KT)
|
||||
{
|
||||
|
||||
ModelNo += "(";
|
||||
}
|
||||
if(Motor.Brand == Brands.ANCHUAN)
|
||||
{
|
||||
ModelNo += "-E(";
|
||||
}
|
||||
ModelNo += $"{AxisNo}";
|
||||
if (CableConnectionClass != "直通")
|
||||
//if (!(CableType is "编码器线+动力线" or "编码器线+动力刹车线"))
|
||||
ModelNo += $"-{CurrentLine}/{LineCount}";
|
||||
ModelNo += ")/定制";
|
||||
}
|
||||
//if (isUpdateDrawNo)
|
||||
{
|
||||
DrawingNo = GetCableDrawNo();
|
||||
}
|
||||
stopwatch.Stop();
|
||||
Debug.Print($"CableModelNo {ModelNo} : {stopwatch.ElapsedMilliseconds}ms");
|
||||
return ModelNo;
|
||||
return this.GenCableModelNo();
|
||||
//return ModelNo;
|
||||
}
|
||||
set
|
||||
{
|
||||
|
@ -401,7 +326,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
|
|||
return "";
|
||||
}
|
||||
}
|
||||
private string GetCableModelFlag(string motorPower, string cableType, string cableConnectionType, bool isFlexibility)
|
||||
public string GetCableModelFlag(string motorPower, string cableType, string cableConnectionType, bool isFlexibility)
|
||||
{
|
||||
var data = MotorExcelHelper.Instance.GetCableDatas(Motor.Brand);
|
||||
//var data = Core.CoreService.GetService<LectotypeService>().GetCableDatas();
|
||||
|
|
|
@ -238,7 +238,7 @@
|
|||
<!-- 使用 Grid 定义列布局 -->
|
||||
<Grid MinHeight="50">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="160" MinWidth="160" />
|
||||
<ColumnDefinition Width="200" MinWidth="160" />
|
||||
<ColumnDefinition Width="160" MinWidth="160" />
|
||||
<ColumnDefinition Width="160" MinWidth="160" />
|
||||
<ColumnDefinition Width="*" MinWidth="300" />
|
||||
|
|
|
@ -160,11 +160,9 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI
|
|||
}
|
||||
else
|
||||
{
|
||||
|
||||
ViewModel.ToSource(cableName);
|
||||
}
|
||||
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -98,8 +98,11 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
|
|||
// WPFUISession.Instance.snackbarService.Show("相同轴号已经添加过数据,禁止重复添加!", "请检查是否添加错误", appearance: ControlAppearance.Danger, timeout: TimeSpan.FromSeconds(3));
|
||||
// return;
|
||||
//}
|
||||
|
||||
var brandData = Brands.GetBrandData(Motor.Brand);
|
||||
|
||||
// 安川第一条线不合并,所以需要再次添加另一个类型的线
|
||||
if (Motor.Brand == Brands.ANCHUAN)
|
||||
if (!brandData.ComplexLine)
|
||||
{
|
||||
var motorPower = MotorExcelHelper.Instance.GetMotorPower(Motor.MotorModelStr);
|
||||
// 功率750W以下的电机,不需要前段线
|
||||
|
@ -160,7 +163,7 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
|
|||
LectotypeList.Add(line);
|
||||
}
|
||||
|
||||
for (global::System.Int32 i = startIndex; i <= PowerLineParagraph; i++)
|
||||
for (var i = startIndex; i <= PowerLineParagraph; i++)
|
||||
{
|
||||
//seqNo++;
|
||||
var cableConnectionType = "中段";
|
||||
|
@ -195,7 +198,7 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
|
|||
powerLine.SubLines = GetSubLines(powerLine.DrawingNo);
|
||||
LectotypeList.Add(powerLine);
|
||||
}
|
||||
for (global::System.Int32 i = startIndex; i <= EncoderLineParagraph; i++)
|
||||
for (var i = startIndex; i <= EncoderLineParagraph; i++)
|
||||
{
|
||||
//seqNo++;
|
||||
var cableConnectionType = "中段";
|
||||
|
@ -408,7 +411,7 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
|
|||
_cableConnectionType = value;
|
||||
OnPropertyChanged(nameof(CableConnectionType));
|
||||
|
||||
IsEnableParagraph = !(_cableConnectionType == ConnectionType.Passthrough);
|
||||
IsEnableParagraph = _cableConnectionType != ConnectionType.Passthrough;
|
||||
PowerLineParagraph = 0;
|
||||
EncoderLineParagraph = 0;
|
||||
if (!IsEnableParagraph)
|
||||
|
|
|
@ -7,6 +7,7 @@ using EPLAN.Harness.ProjectCore.Occurrences;
|
|||
using EPLAN.Harness.ProjectCore.Occurrences.Designer;
|
||||
using HandyControl.Tools.Extension;
|
||||
using Sinvo.EplanHpD.Plugin.Service;
|
||||
using Sinvo.EplanHpD.Plugin.Service.Model;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Datas;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Extension;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
|
||||
|
@ -209,6 +210,7 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
|||
var isPowerLine = GetLineType(occCable.LibraryName,"动力线");
|
||||
var isBrakePowerLine = GetLineType(occCable.LibraryName,"动力刹车线");
|
||||
var isBrakeLine = GetLineType(occCable.LibraryName,"刹车线");
|
||||
//GetLineType(occCable,"刹车线");
|
||||
|
||||
var encoderLength = 0d;
|
||||
var powerLength = 0d;
|
||||
|
@ -324,6 +326,46 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
|||
it.CableConnectionClass = "直通";
|
||||
}
|
||||
}
|
||||
//CableLectotype lecData = null;
|
||||
try
|
||||
{
|
||||
if (it.Motor != null)
|
||||
{
|
||||
var lecData = service.GetCableLectotypeData(it.Motor.MotorUniqueFlag);
|
||||
if (lecData != null)
|
||||
{
|
||||
var linesData = service.GetLectotypeLines(lecData?.CableLectotypeId);
|
||||
if (linesData != null && linesData.Any())
|
||||
{
|
||||
var line = linesData.FirstOrDefault(line =>
|
||||
line.MotorUniqueFlag == it.Motor.MotorUniqueFlag
|
||||
&& line.CableType == it.CableType
|
||||
&& line.CurrentLine == it.CurrentLine
|
||||
);
|
||||
if (line != null)
|
||||
{
|
||||
it.CableConnectionClass = line.CableConnectionClass;
|
||||
}
|
||||
else
|
||||
{
|
||||
it.IsError = true;
|
||||
it.IsChecked = true;
|
||||
it.ErrorCount += 1;
|
||||
it.CheckedMsg += "选型数据中不存在该线材类型!";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
it.CableConnectionClass = "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (string.IsNullOrEmpty(it.CableConnectionClass))
|
||||
{
|
||||
if (it.CurrentLine == 1 && it.CurrentLine != lineCount)
|
||||
|
@ -371,7 +413,8 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
|||
//2 合并同轴号的第一条数据
|
||||
cables.Where(it => it.CurrentLine == 1).ForEach(it =>
|
||||
{
|
||||
if (it.Motor?.Brand != Brands.ANCHUAN)
|
||||
var brandData = Brands.GetBrandData(it.Motor.Brand);
|
||||
if (brandData.ComplexLine)
|
||||
{
|
||||
|
||||
var existLine = datas.FirstOrDefault(data => data.AxisNo == it.AxisNo && data.CurrentLine == 1);
|
||||
|
@ -599,6 +642,7 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
|||
.Where(occ =>
|
||||
(occ.Name?.StartsWith("HK-KT") ?? false)
|
||||
|| (occ.Name?.StartsWith("SGMX") ?? false)
|
||||
|| (occ.Name?.StartsWith("MS1H") ?? false)
|
||||
)
|
||||
.ToList();
|
||||
var motorPowerDatas = MotorExcelHelper.Instance.GetMotorPowers();
|
||||
|
@ -635,7 +679,8 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
|||
if (parent.Type == OCC_TYPE.wPART)
|
||||
{
|
||||
if ((parent.Name?.StartsWith("HK-KT") ?? false)
|
||||
|| (parent.Name?.StartsWith("SGMX") ?? false))
|
||||
|| (parent.Name?.StartsWith("SGMX") ?? false)
|
||||
|| (parent.Name?.StartsWith("MS1H") ?? false))
|
||||
{
|
||||
canAdd = false;
|
||||
}
|
||||
|
@ -656,15 +701,17 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
|||
/// <returns></returns>
|
||||
private string GetMotorBrand(string motorName)
|
||||
{
|
||||
switch (motorName)
|
||||
{
|
||||
case string name when name.StartsWith("HK-KT"):
|
||||
return Brands.SANLING_HK_KT;
|
||||
case string name when name.StartsWith("SGMX"):
|
||||
return Brands.ANCHUAN;
|
||||
default:
|
||||
return Brands.UNKNOWN;
|
||||
}
|
||||
//switch (motorName)
|
||||
//{
|
||||
// case string name when name.StartsWith("HK-KT"):
|
||||
// return Brands.SANLING_HK_KT;
|
||||
// case string name when name.StartsWith("SGMX"):
|
||||
// return Brands.ANCHUAN;
|
||||
// default:
|
||||
// return Brands.UNKNOWN;
|
||||
//}
|
||||
var brandData = Brands.BrandDataList.Where(it => motorName.StartsWith(it.Value.MotorPrefix)).FirstOrDefault();
|
||||
return brandData.Value.Name;
|
||||
}
|
||||
/// <summary>
|
||||
/// 去除电机型号中的多余信息
|
||||
|
|
Loading…
Reference in New Issue