105040 Update 增加注释说明
This commit is contained in:
parent
4abd09dcc1
commit
6b23a07076
|
@ -7,7 +7,8 @@ using System.Threading.Tasks;
|
|||
namespace Sinvo.EplanHpD.Plugin.WPFUI.Datas
|
||||
{
|
||||
/// <summary>
|
||||
/// TODO: 品牌类型,线材逻辑不同应拆分为不同的服务实现
|
||||
/// TODO1: 品牌类型,线材逻辑不同应拆分为不同的服务实现
|
||||
/// TODO2: 从配置文件中读取品牌数据
|
||||
/// </summary>
|
||||
public static class Brands
|
||||
{
|
||||
|
@ -27,21 +28,18 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Datas
|
|||
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-";
|
||||
}
|
||||
*/
|
||||
安川电机
|
||||
1. 线缆型号前缀:JZSP-
|
||||
2. 电机型号前缀:SGMX
|
||||
3. 型号后缀:-E
|
||||
4. 电机带前段线的功率范围:0-750KW
|
||||
5. 数据表中Sheet名称: 安川
|
||||
*/
|
||||
{ANCHUAN,
|
||||
new BrandData{
|
||||
Name = ANCHUAN,
|
||||
|
@ -54,6 +52,14 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Datas
|
|||
MotorCablePowerRangeEnd = 750
|
||||
}
|
||||
},
|
||||
/*
|
||||
汇川电机
|
||||
1. 线缆型号前缀:S6-L-
|
||||
2. 电机型号前缀:MS1H
|
||||
3. 型号后缀:无
|
||||
4. 电机带前段线的功率范围:无
|
||||
5. 数据表中Sheet名称: 汇川
|
||||
*/
|
||||
{HUICHUAN,
|
||||
new BrandData{
|
||||
Name = HUICHUAN,
|
||||
|
@ -66,6 +72,14 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Datas
|
|||
MotorCablePowerRangeEnd = 0
|
||||
}
|
||||
},
|
||||
/*
|
||||
三菱电机
|
||||
1. 线缆型号前缀:MR-
|
||||
2. 电机型号前缀:HK-KT
|
||||
3. 型号后缀:无
|
||||
4. 电机带前段线的功率范围:无
|
||||
5. 数据表中Sheet名称: HK_KT
|
||||
*/
|
||||
{SANLING_HK_KT,
|
||||
new BrandData{
|
||||
Name = SANLING_HK_KT,
|
||||
|
|
|
@ -5,6 +5,12 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Extension
|
|||
{
|
||||
public static class ApplicationExt
|
||||
{
|
||||
/// <summary>
|
||||
/// 设置主窗口
|
||||
/// </summary>
|
||||
/// <param name="application"></param>
|
||||
/// <param name="window"></param>
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
public static void SetMainWindow(this Application application, Window window)
|
||||
{
|
||||
if (application == null)
|
||||
|
@ -17,6 +23,9 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Extension
|
|||
}
|
||||
application.MainWindow = window;
|
||||
}
|
||||
/// <summary>
|
||||
/// 初始化应用程序,修复在某些情况下,引用第三方UI控件库的时候出现的异常与卡顿
|
||||
/// </summary>
|
||||
public static void InitApplication()
|
||||
{
|
||||
if (Application.Current == null)
|
||||
|
|
|
@ -4,6 +4,11 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Extension
|
|||
{
|
||||
public static class CheckedModelExt
|
||||
{
|
||||
/// <summary>
|
||||
/// 设置检查状态
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <param name="errorMsg"></param>
|
||||
public static void SetError(this CheckedModel model, string errorMsg)
|
||||
{
|
||||
model.IsError = true;
|
||||
|
@ -11,8 +16,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Extension
|
|||
if (!string.IsNullOrEmpty(model.CheckedMsg))
|
||||
{
|
||||
model.CheckedMsg += "\r\n";
|
||||
}
|
||||
|
||||
}
|
||||
model.CheckedMsg += errorMsg;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,11 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Extension
|
|||
{
|
||||
public static class MotorModelUniqueFlagExt
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取电机唯一标识
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetUniqueFlag(this MotorModel model)
|
||||
{
|
||||
// 调整唯一标识生成规则,项目名称+轴号
|
||||
|
|
|
@ -5,6 +5,12 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Extension
|
|||
{
|
||||
public static class PropertyListExt
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否包含属性
|
||||
/// </summary>
|
||||
/// <param name="list"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsContarins(this PropertyList list, string value)
|
||||
{
|
||||
return list.Any(item =>
|
||||
|
|
|
@ -326,6 +326,14 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
|
|||
return "";
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取线材型号标识
|
||||
/// </summary>
|
||||
/// <param name="motorPower"></param>
|
||||
/// <param name="cableType"></param>
|
||||
/// <param name="cableConnectionType"></param>
|
||||
/// <param name="isFlexibility"></param>
|
||||
/// <returns></returns>
|
||||
public string GetCableModelFlag(string motorPower, string cableType, string cableConnectionType, bool isFlexibility)
|
||||
{
|
||||
var data = MotorExcelHelper.Instance.GetCableDatas(Motor.Brand);
|
||||
|
@ -391,6 +399,11 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
|
|||
|
||||
|
||||
public string LibraryName { get; set; }
|
||||
/// <summary>
|
||||
/// 获取线材可用的型号列表
|
||||
/// </summary>
|
||||
/// <param name="drawingNo"></param>
|
||||
/// <returns></returns>
|
||||
private List<LectotypeLineModel> GetSubLines(string drawingNo)
|
||||
{
|
||||
return MotorExcelHelper.Instance.GetBomList(drawingNo).Where(it =>
|
||||
|
|
|
@ -9,6 +9,11 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
|||
{
|
||||
public static class LectotypeLineModelExt
|
||||
{
|
||||
/// <summary>
|
||||
/// 生成电缆型号
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public static string GenCableModelNo(this LectotypeLineModel model)
|
||||
{
|
||||
Stopwatch stopwatch = new Stopwatch();
|
||||
|
|
|
@ -22,7 +22,11 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
|||
public class LectotypeViewModelFactory
|
||||
{
|
||||
private static readonly IDictionary<string, CableLectotypeViewModel> _motorViewModel = new Dictionary<string, CableLectotypeViewModel>();
|
||||
|
||||
/// <summary>
|
||||
/// 创建或获取电机的所有信息
|
||||
/// </summary>
|
||||
/// <param name="motor"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<CableLectotypeViewModel> CreateOrGetAsync(MotorModel motor)
|
||||
{
|
||||
if (motor == null || string.IsNullOrEmpty(motor.AxisNo))
|
||||
|
@ -61,14 +65,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
|||
return viewModel;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Register(MotorModel motor, CableLectotypeViewModel viewModel)
|
||||
{
|
||||
if (!_motorViewModel.ContainsKey(motor.OccPartId))
|
||||
{
|
||||
_motorViewModel.Add(motor.OccPartId, viewModel);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -146,10 +146,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
|||
MiniExcel.SaveAsByTemplate(
|
||||
$"{targetPath}\\{mechanismNo}线材下单_{DateTime.Now:yyyy_MM_dd}_{DateTime.Now.Ticks}.xlsx",
|
||||
templatePath,
|
||||
new
|
||||
{
|
||||
data
|
||||
},
|
||||
new { data },
|
||||
new MiniExcelLibs.OpenXml.OpenXmlConfiguration
|
||||
{
|
||||
FastMode = true
|
||||
|
|
|
@ -50,11 +50,13 @@
|
|||
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
|
||||
<Button
|
||||
Width="100"
|
||||
Margin="5"
|
||||
Click="btnOK_Click"
|
||||
Content="是"
|
||||
Style="{StaticResource ButtonDanger}" />
|
||||
<Button
|
||||
Width="100"
|
||||
Margin="5"
|
||||
Click="btnCancel_Click"
|
||||
Content="否"
|
||||
Style="{StaticResource ButtonInfo}" />
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
using EPLAN.Harness.Core.Controls;
|
||||
using EPLAN.Harness.Core.LibEntities.Enums;
|
||||
using HandyControl.Controls;
|
||||
using HandyControl.Controls;
|
||||
using Sinvo.EplanHpD.Plugin.Service;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Datas;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Enum;
|
||||
|
@ -65,25 +63,10 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
|
|||
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 = brandData.ComplexLine ? $"{CableTypePrimary}+{CableTypeSecond}" : CableTypePrimary,
|
||||
//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
|
||||
|
@ -94,12 +77,6 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
|
|||
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;
|
||||
//}
|
||||
|
||||
// 安川第一条线不合并,所以需要再次添加另一个类型的线
|
||||
if (!brandData.ComplexLine)
|
||||
{
|
||||
|
@ -115,18 +92,6 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
|
|||
startIndex = 2;
|
||||
// 第一条线为所选线
|
||||
LectotypeList.Add(line);
|
||||
//var index = CableTypeIndexs[CableTypePrimary];
|
||||
//var secLineCableType = "";
|
||||
//var flag = index.Keys.First() + index.Values.First();
|
||||
//if (CableTypePrimary.Contains("刹车") && flag != 1)
|
||||
//{
|
||||
// // 动力线 or 动力刹车线
|
||||
// flag = 0;
|
||||
//}
|
||||
////else
|
||||
//secLineCableType = CableTypeIndexs.Keys.ToList()[flag];
|
||||
|
||||
|
||||
var secLine = new LectotypeLineModel
|
||||
{
|
||||
AxisNo = AxisNo,
|
||||
|
@ -158,26 +123,13 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
|
|||
}
|
||||
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 = CableTypeSecond,
|
||||
LineCount = PowerLineParagraph,
|
||||
//PowerLineLength = PowerLineLength,
|
||||
//CurrentLineNumber = i,
|
||||
CurrentLine = i,
|
||||
Motor = Motor,
|
||||
IsLectotype = true
|
||||
//CableFlag = GetCableModelFlag(MotorPower, PowerLineName, cableConnectionType, false)
|
||||
IsLectotype = true
|
||||
};
|
||||
powerLine.DrawingNo = powerLine.GetCableDrawNo();
|
||||
powerLine.SubLines = GetSubLines(powerLine.DrawingNo);
|
||||
|
@ -209,10 +161,10 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
|
|||
else
|
||||
{
|
||||
LectotypeList.Add(line);
|
||||
// 安川电机,允许有两条直通线
|
||||
if (!string.IsNullOrEmpty(CableTypeSecond) && !brandData.ComplexLine)
|
||||
// 安川电机,允许有2~3条直通线
|
||||
if (!brandData.ComplexLine)
|
||||
{
|
||||
if (_passthroughCableCount >= 2)
|
||||
if (_passthroughCableCount >= 2 && !string.IsNullOrEmpty(CableTypeSecond))
|
||||
{
|
||||
var secLine = new LectotypeLineModel
|
||||
{
|
||||
|
@ -228,7 +180,7 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
|
|||
secLine.SubLines = GetSubLines(secLine.DrawingNo);
|
||||
LectotypeList.Add(secLine);
|
||||
}
|
||||
if (_passthroughCableCount >= 3)
|
||||
if (_passthroughCableCount >= 3 && !string.IsNullOrEmpty(CableTypeThree))
|
||||
{
|
||||
var secLine = new LectotypeLineModel
|
||||
{
|
||||
|
@ -255,12 +207,16 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
|
|||
});
|
||||
SelectedLines = sortedLines;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取可用线列表
|
||||
/// </summary>
|
||||
/// <param name="drawingNo"></param>
|
||||
/// <returns></returns>
|
||||
private List<LectotypeLineModel> GetSubLines(string drawingNo)
|
||||
{
|
||||
return [.. MotorExcelHelper.Instance.GetBomList(drawingNo).Where(it =>
|
||||
{
|
||||
// BOM表中只有 编码器线 和 动力线 不区分是不是带刹车
|
||||
// BOM表中只有 编码器线 和 动力线 和 刹车线 不区分是不是带刹车
|
||||
return it.Name == "编码器线" || it.Name == "动力线" || it.Name == "刹车线";
|
||||
}).Select(it => new LectotypeLineModel
|
||||
{
|
||||
|
|
|
@ -27,8 +27,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
{
|
||||
|
||||
public FlexDesigner _currentFlexDesigner;
|
||||
private string _selectMotorModel;
|
||||
private MotorLectotypeService service = new();
|
||||
private string _selectMotorModel;
|
||||
private List<MotorModel> _motors;
|
||||
private MotorModel _motor;
|
||||
private CableLectotypeViewModel cableLectotypeViewModel;
|
||||
|
@ -44,6 +43,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
}
|
||||
public LayoutHelperViewModel()
|
||||
{
|
||||
// 初始化HpdApi eplan内部会自行判断是否已初始化
|
||||
api = HpdApi.GetInstance();
|
||||
api.Init();
|
||||
}
|
||||
|
@ -51,10 +51,13 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
{
|
||||
_currentFlexDesigner = currentFlexDesigner;
|
||||
_motors = motorFlags;
|
||||
|
||||
// 初始化HpdApi eplan内部会自行判断是否已初始化
|
||||
api = HpdApi.GetInstance();
|
||||
api.Init();
|
||||
}
|
||||
/// <summary>
|
||||
/// 电机型号
|
||||
/// </summary>
|
||||
public string SelectMotorModel
|
||||
{
|
||||
get { return _selectMotorModel; }
|
||||
|
@ -171,7 +174,10 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
}
|
||||
}
|
||||
public List<LectotypeLineModel> SelectedLines;
|
||||
|
||||
/// <summary>
|
||||
/// EPLAN选中对象时触发的事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
public void OnSelectChange(object sender)
|
||||
{
|
||||
if (sender is OccSelectSet selectSet)
|
||||
|
@ -200,7 +206,9 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取电机对应的线信息
|
||||
/// </summary>
|
||||
internal void GetMotorCables()
|
||||
{
|
||||
if (_motors != null && _motors.Any())
|
||||
|
@ -266,7 +274,11 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查选中的线
|
||||
/// </summary>
|
||||
/// <param name="slient"></param>
|
||||
/// <returns></returns>
|
||||
private bool CheckSelLine(bool slient = false)
|
||||
{
|
||||
try
|
||||
|
@ -377,10 +389,17 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
GetMotorCables();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 重新设置可使用的线型号列表
|
||||
/// </summary>
|
||||
internal void ReSetSubLines()
|
||||
{
|
||||
SubLines = SelectedLine.SubLines.Distinct(it => it.CableModel).ToList();
|
||||
SubLines = [.. SelectedLine.SubLines.Distinct(it => it.CableModel)];
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置为布线完成并保存到数据库
|
||||
/// </summary>
|
||||
/// <param name="lectotypeLineId"></param>
|
||||
internal void SetSubLineAndSave(string lectotypeLineId)
|
||||
{
|
||||
var motorUniqueFlag = Motor.MotorUniqueFlag;
|
||||
|
|
|
@ -672,9 +672,10 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
|||
var parent = part.Parents.First();
|
||||
if (parent.Type == OCC_TYPE.wPART)
|
||||
{
|
||||
if ((parent.Name?.StartsWith("HK-KT") ?? false)
|
||||
|| (parent.Name?.StartsWith("SGMX") ?? false)
|
||||
|| (parent.Name?.StartsWith("MS1H") ?? false))
|
||||
//if ((parent.Name?.StartsWith("HK-KT") ?? false)
|
||||
//|| (parent.Name?.StartsWith("SGMX") ?? false)
|
||||
//|| (parent.Name?.StartsWith("MS1H") ?? false))
|
||||
if(IsMotor(parent.Name))
|
||||
{
|
||||
canAdd = false;
|
||||
}
|
||||
|
@ -699,7 +700,7 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
|||
if (!string.IsNullOrEmpty(partName))
|
||||
{
|
||||
var brandDatas = Brands.BrandDataList.Values.Select(b => b.MotorPrefix).ToList();
|
||||
isMotor = brandDatas.Any(it => partName.StartsWith(partName));
|
||||
isMotor = brandDatas.Any(partName.StartsWith);
|
||||
}
|
||||
|
||||
return isMotor;
|
||||
|
|
Loading…
Reference in New Issue