diff --git a/Sinvo.EplanHpD.Plugin.Service/Model/MotorModel.cs b/Sinvo.EplanHpD.Plugin.Service/Model/MotorModel.cs
index 8b5b348..83add46 100644
--- a/Sinvo.EplanHpD.Plugin.Service/Model/MotorModel.cs
+++ b/Sinvo.EplanHpD.Plugin.Service/Model/MotorModel.cs
@@ -11,11 +11,10 @@ namespace Sinvo.EplanHpD.Plugin.Service.Model
[SugarTable("T_MOTOR")]
public class Motor
{
- //public string MotorId { get; set; }
- [SugarColumn(IsPrimaryKey = true)]
+ //public string MotorId { get; set; }
public string OccPartId { get; set; }
-
- [SugarColumn(IsNullable = true)]
+
+ [SugarColumn(IsPrimaryKey = true)]
public string MotorUniqueFlag { get; set; }
[SugarColumn(IsNullable = true)]
diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Models/MotorModel.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Models/MotorModel.cs
index 5dee40f..52ea5c0 100644
--- a/Sinvo.EplanHpD.Plugin.WPFUI/Models/MotorModel.cs
+++ b/Sinvo.EplanHpD.Plugin.WPFUI/Models/MotorModel.cs
@@ -109,5 +109,18 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
OnPropertyChanged(nameof(MotorUniqueFlag));
}
}
+
+ ///
+ /// 从其他对象复制属性
+ ///
+ public void CopyFrom(MotorModel motor)
+ {
+ this.MotorPower = motor.MotorPower;
+ this.Brand = motor.Brand;
+ this.MotorSerie = motor.MotorSerie;
+ this.MotorModelStr = motor.MotorModelStr;
+ this.AxisNo = motor.AxisNo;
+ //this.OccPartId = motor.OccPartId;
+ }
}
}
diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Service/MotorLectotypeService.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Service/MotorLectotypeService.cs
index 455b1c5..e17f4bd 100644
--- a/Sinvo.EplanHpD.Plugin.WPFUI/Service/MotorLectotypeService.cs
+++ b/Sinvo.EplanHpD.Plugin.WPFUI/Service/MotorLectotypeService.cs
@@ -254,7 +254,7 @@ namespace Sinvo.EplanHpD.Plugin.Service
}
}
- public int SetLineDone(string motorId,string lineId)
+ public int SetLineDone(string motorUniqueFlag,string lineId)
{
var db = DBHelper.DB;
@@ -263,7 +263,7 @@ namespace Sinvo.EplanHpD.Plugin.Service
db.BeginTran();
int changeCount = db.Updateable()
- .Where(mt => mt.MotorId == motorId && mt.LectotypeLineId == lineId)
+ .Where(mt => mt.MotorUniqueFlag == motorUniqueFlag && mt.LectotypeLineId == lineId)
.SetColumns(it => it.IsChecked == true)
.ExecuteCommand();
diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Utils/LectotypeManager.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/LectotypeManager.cs
index 35946ec..a9cee06 100644
--- a/Sinvo.EplanHpD.Plugin.WPFUI/Utils/LectotypeManager.cs
+++ b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/LectotypeManager.cs
@@ -40,6 +40,8 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
if (data != null)
{
viewModel = data;
+ // 更新电机ID数据,每次导入后可能会刷新这个ID,所以从抓取的数据中更新
+ viewModel.Motor.OccPartId = motor.OccPartId;
}
}).Wait();
diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/View/LayoutHelperWindow.xaml.cs b/Sinvo.EplanHpD.Plugin.WPFUI/View/LayoutHelperWindow.xaml.cs
index bfb9cff..073ce22 100644
--- a/Sinvo.EplanHpD.Plugin.WPFUI/View/LayoutHelperWindow.xaml.cs
+++ b/Sinvo.EplanHpD.Plugin.WPFUI/View/LayoutHelperWindow.xaml.cs
@@ -11,6 +11,7 @@ using EPLAN.Harness.ProjectCore;
using EPLAN.Harness.ProjectCore.Occurrences;
using EPLAN.Harness.ProjectCore.Occurrences.Designer;
using HandyControl.Controls;
+using Sinvo.EplanHpD.Plugin.WPFUI.Models;
using Sinvo.EplanHpD.Plugin.WPFUI.Utils;
using Sinvo.EplanHpD.Plugin.WPFUI.ViewModel;
using System;
@@ -37,10 +38,10 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
{
private FlexDesigner _currentFlexDesigner;
private LayoutHelperViewModel viewModel;
- public LayoutHelperWindow(List motorFlags)
+ public LayoutHelperWindow(List motors)
{
InitializeComponent();
- viewModel = new LayoutHelperViewModel(_currentFlexDesigner, motorFlags);
+ viewModel = new LayoutHelperViewModel(_currentFlexDesigner, motors);
this.DataContext = viewModel;
diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/LayoutHelperViewModel.cs b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/LayoutHelperViewModel.cs
index 33b27b1..922af0a 100644
--- a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/LayoutHelperViewModel.cs
+++ b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/LayoutHelperViewModel.cs
@@ -29,7 +29,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
public FlexDesigner _currentFlexDesigner;
private string _selectMotorModel;
private MotorLectotypeService service = new();
- private List _motorFlags;
+ private List _motors;
private MotorModel _motor;
private CableLectotypeViewModel cableLectotypeViewModel;
private HpdApi api;
@@ -47,10 +47,10 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
api = HpdApi.GetInstance();
api.Init();
}
- public LayoutHelperViewModel(FlexDesigner currentFlexDesigner, List motorFlags)
+ public LayoutHelperViewModel(FlexDesigner currentFlexDesigner, List motorFlags)
{
_currentFlexDesigner = currentFlexDesigner;
- _motorFlags = motorFlags;
+ _motors = motorFlags;
api = HpdApi.GetInstance();
api.Init();
@@ -101,13 +101,13 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
{
get
{
- if (_motorFlags == null) return false;
+ if (_motors == null) return false;
if (SelectedLines == null) return false;
if (CurrentMotorSelectLineIndex < SelectedLines.Count - 1)
{
return true;
}
- else if (CurrentMotorIndex < _motorFlags.Count - 1)
+ else if (CurrentMotorIndex < _motors.Count - 1)
{
return true;
}
@@ -204,13 +204,13 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
internal void GetMotorCables()
{
- if (_motorFlags != null && _motorFlags.Any())
+ if (_motors != null && _motors.Any())
{
Task.Factory.StartNew(() =>
{
var service = new MotorLectotypeService();
- var data = service.GetMotorLectotypeData(_motorFlags[CurrentMotorIndex]);
+ var data = service.GetMotorLectotypeData(_motors[CurrentMotorIndex]?.MotorUniqueFlag);
if (data != null)
{
cableLectotypeViewModel = data;
@@ -219,13 +219,13 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
SelectedLines = cableLectotypeViewModel.SelectedLines.OrderBy(it => it.CableType).ThenBy(it => it.CurrentLine).ToList();
SelectedLine = SelectedLines[CurrentMotorSelectLineIndex];
ReSetSubLines();
- Motor = cableLectotypeViewModel.Motor;
+ Motor = _motors[CurrentMotorIndex];
return;
}
}
CurrentMotorIndex++;
- if (CurrentMotorIndex < _motorFlags.Count)
+ if (CurrentMotorIndex < _motors.Count)
{
CurrentMotorSelectLineIndex = 0;
GetMotorCables();
@@ -375,7 +375,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
}
internal void ToNextMotor()
{
- if (CurrentMotorIndex < _motorFlags.Count)
+ if (CurrentMotorIndex < _motors.Count)
{
CurrentMotorIndex++;
CurrentMotorSelectLineIndex = 0;
@@ -388,9 +388,9 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
}
internal void SetSubLineAndSave(string lectotypeLineId)
{
- var motorId = Motor.OccPartId;
+ var motorUniqueFlag = Motor.MotorUniqueFlag;
var service = new MotorLectotypeService();
- service.SetLineDone(motorId, lectotypeLineId);
+ service.SetLineDone(motorUniqueFlag, lectotypeLineId);
}
}
}