添加 MX-PD-盘古 项目文件
将 MX-PD-盘古 - new 目录下的所有文件添加到主仓库
This commit is contained in:
@@ -0,0 +1,363 @@
|
||||
using MainShell.Common;
|
||||
using MainShell.Filewritable;
|
||||
using MainShell.Hardware;
|
||||
using MainShell.Log;
|
||||
using MainShell.Models;
|
||||
using MainShell.ParaSetting.Model;
|
||||
using MwFramework.Device;
|
||||
using MwFramework.Device.Drivers;
|
||||
using MwFramework.Device.Motion;
|
||||
using Stylet;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
|
||||
namespace MainShell.ParaSetting.ViewModel
|
||||
{
|
||||
public class AxisSoftLimitSettingViewModel : BaseScreen
|
||||
{
|
||||
private const string AxisSoftLimitSettingFileName = "AxisSoftLimitSetting.json";
|
||||
|
||||
private readonly HardwareManager _hardwareManager;
|
||||
private readonly string _axisSoftLimitSettingFilePath;
|
||||
|
||||
private AxisSoftLimitSetting _axisSoftLimitSetting;
|
||||
|
||||
private ObservableCollection<AxisSoftLimitItemViewModel> _axisSoftLimitItems = new ObservableCollection<AxisSoftLimitItemViewModel>();
|
||||
public ObservableCollection<AxisSoftLimitItemViewModel> AxisSoftLimitItems
|
||||
{
|
||||
get
|
||||
{
|
||||
return _axisSoftLimitItems;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _axisSoftLimitItems, value);
|
||||
}
|
||||
}
|
||||
|
||||
private AxisSoftLimitItemViewModel _selectedAxisSoftLimitItem;
|
||||
public AxisSoftLimitItemViewModel SelectedAxisSoftLimitItem
|
||||
{
|
||||
get
|
||||
{
|
||||
return _selectedAxisSoftLimitItem;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _selectedAxisSoftLimitItem, value);
|
||||
}
|
||||
}
|
||||
|
||||
private string _parameterFilePath;
|
||||
public string ParameterFilePath
|
||||
{
|
||||
get
|
||||
{
|
||||
return _parameterFilePath;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _parameterFilePath, value);
|
||||
}
|
||||
}
|
||||
|
||||
public AxisSoftLimitSettingViewModel(HardwareManager hardwareManager)
|
||||
{
|
||||
_hardwareManager = hardwareManager ?? throw new ArgumentNullException(nameof(hardwareManager));
|
||||
_axisSoftLimitSettingFilePath = System.IO.Path.Combine(Paths.CalibSettingPath, AxisSoftLimitSettingFileName);
|
||||
ParameterFilePath = _axisSoftLimitSettingFilePath;
|
||||
}
|
||||
|
||||
protected override void OnViewLoaded()
|
||||
{
|
||||
base.OnViewLoaded();
|
||||
LoadAxisSoftLimitItems();
|
||||
}
|
||||
|
||||
public void BtnSave()
|
||||
{
|
||||
if (!ValidateAxisSoftLimitItems())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MessageBoxResult confirmResult = LocalizedMessageBox.Show(MessageKey.AxisSoftLimitSaveConfirm, MessageKey.TitleConfirm, MessageBoxButton.OKCancel, MessageBoxImage.Question);
|
||||
if (confirmResult != MessageBoxResult.OK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(Paths.CalibSettingPath);
|
||||
AxisSoftLimitSetting axisSoftLimitSetting = CreateAxisSoftLimitSetting();
|
||||
foreach (AxisSoftLimitItemViewModel axisSoftLimitItem in AxisSoftLimitItems)
|
||||
{
|
||||
AxisSoftLimitItem axisSoftLimitItemModel = new AxisSoftLimitItem();
|
||||
axisSoftLimitItemModel.AxisName = axisSoftLimitItem.AxisName;
|
||||
axisSoftLimitItemModel.CardName = axisSoftLimitItem.CardName;
|
||||
axisSoftLimitItemModel.CardNum = axisSoftLimitItem.CardNum;
|
||||
axisSoftLimitItemModel.AxisNum = axisSoftLimitItem.AxisNum;
|
||||
axisSoftLimitItemModel.NegativeSoftLimit = axisSoftLimitItem.NegativeSoftLimit;
|
||||
axisSoftLimitItemModel.PositiveSoftLimit = axisSoftLimitItem.PositiveSoftLimit;
|
||||
axisSoftLimitSetting.AxisSoftLimitItems.Add(axisSoftLimitItemModel);
|
||||
UpdateAxisCheckLimit(axisSoftLimitItem);
|
||||
}
|
||||
|
||||
axisSoftLimitSetting.Write(_axisSoftLimitSettingFilePath);
|
||||
_axisSoftLimitSetting = axisSoftLimitSetting;
|
||||
LocalizedMessageBox.Show(MessageKey.CommonSaveSucceeded, MessageKey.TitleInfo);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogManager.LogSysError(ex);
|
||||
LocalizedMessageBox.ShowFormat(MessageKey.AxisSoftLimitSaveFailedWithReason, MessageKey.TitleError, MessageBoxButton.OK, MessageBoxImage.Error, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void BtnApply()
|
||||
{
|
||||
if (!ValidateAxisSoftLimitItems())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AxisSoftLimitItemViewModel axisSoftLimitItem = SelectedAxisSoftLimitItem;
|
||||
if (axisSoftLimitItem == null)
|
||||
{
|
||||
LocalizedMessageBox.Show(MessageKey.AxisSoftLimitSelectedAxisRequired, MessageKey.TitleError);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
ApplyAxisSoftLimitToController(axisSoftLimitItem);
|
||||
LocalizedMessageBox.ShowFormat(MessageKey.AxisSoftLimitApplySucceeded, MessageKey.TitleInfo, MessageBoxButton.OK, MessageBoxImage.Information, axisSoftLimitItem.AxisName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogManager.LogSysError(ex);
|
||||
LocalizedMessageBox.ShowFormat(MessageKey.AxisSoftLimitApplyFailedWithReason, MessageKey.TitleError, MessageBoxButton.OK, MessageBoxImage.Error, axisSoftLimitItem.AxisName, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void BtnApplyAll()
|
||||
{
|
||||
if (!ValidateAxisSoftLimitItems())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (AxisSoftLimitItems == null || AxisSoftLimitItems.Count == 0)
|
||||
{
|
||||
LocalizedMessageBox.Show(MessageKey.AxisSoftLimitNoAxisData, MessageKey.TitleError);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
int appliedAxisCount = 0;
|
||||
foreach (AxisSoftLimitItemViewModel axisSoftLimitItem in AxisSoftLimitItems)
|
||||
{
|
||||
ApplyAxisSoftLimitToController(axisSoftLimitItem);
|
||||
appliedAxisCount++;
|
||||
}
|
||||
|
||||
LocalizedMessageBox.ShowFormat(MessageKey.AxisSoftLimitApplyAllSucceeded, MessageKey.TitleInfo, MessageBoxButton.OK, MessageBoxImage.Information, appliedAxisCount);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogManager.LogSysError(ex);
|
||||
LocalizedMessageBox.ShowFormat(MessageKey.AxisSoftLimitApplyAllFailedWithReason, MessageKey.TitleError, MessageBoxButton.OK, MessageBoxImage.Error, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadAxisSoftLimitItems()
|
||||
{
|
||||
try
|
||||
{
|
||||
AxisSoftLimitSetting axisSoftLimitSetting = CreateAxisSoftLimitSetting();
|
||||
if (System.IO.File.Exists(_axisSoftLimitSettingFilePath))
|
||||
{
|
||||
axisSoftLimitSetting.Read(_axisSoftLimitSettingFilePath);
|
||||
}
|
||||
|
||||
_axisSoftLimitSetting = axisSoftLimitSetting;
|
||||
AxisSoftLimitItems = BuildAxisSoftLimitItems(axisSoftLimitSetting);
|
||||
SelectedAxisSoftLimitItem = AxisSoftLimitItems.FirstOrDefault();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogManager.LogSysError(ex);
|
||||
_axisSoftLimitSetting = CreateAxisSoftLimitSetting();
|
||||
AxisSoftLimitItems = BuildAxisSoftLimitItems(_axisSoftLimitSetting);
|
||||
SelectedAxisSoftLimitItem = AxisSoftLimitItems.FirstOrDefault();
|
||||
LocalizedMessageBox.ShowFormat(MessageKey.AxisSoftLimitLoadFailedWithReason, MessageKey.TitleError, MessageBoxButton.OK, MessageBoxImage.Error, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private ObservableCollection<AxisSoftLimitItemViewModel> BuildAxisSoftLimitItems(AxisSoftLimitSetting axisSoftLimitSetting)
|
||||
{
|
||||
ObservableCollection<AxisSoftLimitItemViewModel> items = new ObservableCollection<AxisSoftLimitItemViewModel>();
|
||||
System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, IAxis>> axisPairs = Enumerable.Empty<System.Collections.Generic.KeyValuePair<string, IAxis>>();
|
||||
if (_hardwareManager.AxesDic != null)
|
||||
{
|
||||
axisPairs = _hardwareManager.AxesDic.OrderBy(item => item.Key);
|
||||
}
|
||||
|
||||
foreach (System.Collections.Generic.KeyValuePair<string, IAxis> axisPair in axisPairs)
|
||||
{
|
||||
IAxis axis = axisPair.Value;
|
||||
if (axis == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
AxisCardParaPO axisCardParaPo = axis.AxisPO as AxisCardParaPO;
|
||||
int cardNum = axisCardParaPo != null ? axisCardParaPo.AxisCardNum : -1;
|
||||
string cardName = axisCardParaPo != null ? axisCardParaPo.AxisCardName : string.Empty;
|
||||
AxisSoftLimitItem axisSoftLimitItem = FindAxisSoftLimitItem(axisSoftLimitSetting, cardNum, axis.AxisIndex);
|
||||
double negativeSoftLimit = axisSoftLimitItem != null ? axisSoftLimitItem.NegativeSoftLimit : 0d;
|
||||
double positiveSoftLimit = axisSoftLimitItem != null
|
||||
? axisSoftLimitItem.PositiveSoftLimit
|
||||
: axisCardParaPo != null ? axisCardParaPo.MaxCheckPos : 0d;
|
||||
|
||||
AxisSoftLimitItemViewModel item = new AxisSoftLimitItemViewModel(axis, axisPair.Key, cardName, cardNum, axis.AxisIndex, negativeSoftLimit, positiveSoftLimit);
|
||||
items.Add(item);
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
private static AxisSoftLimitItem FindAxisSoftLimitItem(AxisSoftLimitSetting axisSoftLimitSetting, int cardNum, int axisNum)
|
||||
{
|
||||
if (axisSoftLimitSetting == null || axisSoftLimitSetting.AxisSoftLimitItems == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return axisSoftLimitSetting.AxisSoftLimitItems.FirstOrDefault(item => item != null && item.CardNum == cardNum && item.AxisNum == axisNum);
|
||||
}
|
||||
|
||||
private static void UpdateAxisCheckLimit(AxisSoftLimitItemViewModel axisSoftLimitItem)
|
||||
{
|
||||
AxisCardParaPO axisCardParaPo = axisSoftLimitItem.Axis == null ? null : axisSoftLimitItem.Axis.AxisPO as AxisCardParaPO;
|
||||
if (axisCardParaPo != null)
|
||||
{
|
||||
axisCardParaPo.MaxCheckPos = axisSoftLimitItem.PositiveSoftLimit;
|
||||
}
|
||||
}
|
||||
|
||||
private static void ApplyAxisSoftLimitToController(AxisSoftLimitItemViewModel axisSoftLimitItem)
|
||||
{
|
||||
if (axisSoftLimitItem == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(axisSoftLimitItem));
|
||||
}
|
||||
|
||||
IAxis axis = axisSoftLimitItem.Axis;
|
||||
if (axis == null)
|
||||
{
|
||||
throw new InvalidOperationException("当前轴对象无效,无法下发软限位设置。");
|
||||
}
|
||||
|
||||
IAxisFunc axisFunc = axis as IAxisFunc;
|
||||
if (axisFunc == null)
|
||||
{
|
||||
throw new InvalidOperationException($"轴 {axisSoftLimitItem.AxisName} 不支持软限位设置接口。");
|
||||
}
|
||||
|
||||
IMotionController controller = axis.Parent;
|
||||
if (controller == null || !controller.IsOpen)
|
||||
{
|
||||
throw new InvalidOperationException($"轴 {axisSoftLimitItem.AxisName} 所属控制器未连接或未打开。");
|
||||
}
|
||||
|
||||
EnsureMotionCommandSucceeded(axisFunc.SetSoftMel(axisSoftLimitItem.NegativeSoftLimit), axisSoftLimitItem.AxisName, "负软限位");
|
||||
EnsureMotionCommandSucceeded(axisFunc.SetSoftPel(axisSoftLimitItem.PositiveSoftLimit), axisSoftLimitItem.AxisName, "正软限位");
|
||||
EnsureMotionCommandSucceeded(axisFunc.IssueParam(), axisSoftLimitItem.AxisName, "参数下发");
|
||||
UpdateAxisCheckLimit(axisSoftLimitItem);
|
||||
}
|
||||
|
||||
private static void EnsureMotionCommandSucceeded(MotionErrorCode motionErrorCode, string axisName, string actionName)
|
||||
{
|
||||
if (motionErrorCode != MotionErrorCode.NoError)
|
||||
{
|
||||
throw new InvalidOperationException($"轴 {axisName} {actionName}失败,错误码:{motionErrorCode}");
|
||||
}
|
||||
}
|
||||
|
||||
private bool ValidateAxisSoftLimitItems()
|
||||
{
|
||||
foreach (AxisSoftLimitItemViewModel axisSoftLimitItem in AxisSoftLimitItems)
|
||||
{
|
||||
if (axisSoftLimitItem.PositiveSoftLimit < axisSoftLimitItem.NegativeSoftLimit)
|
||||
{
|
||||
LocalizedMessageBox.ShowFormat(MessageKey.AxisSoftLimitRangeInvalid, MessageKey.TitleError, MessageBoxButton.OK, MessageBoxImage.Error, axisSoftLimitItem.AxisName);
|
||||
SelectedAxisSoftLimitItem = axisSoftLimitItem;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static AxisSoftLimitSetting CreateAxisSoftLimitSetting()
|
||||
{
|
||||
return new AxisSoftLimitSetting();
|
||||
}
|
||||
}
|
||||
|
||||
public class AxisSoftLimitItemViewModel : PropertyChangedBase
|
||||
{
|
||||
private double _negativeSoftLimit;
|
||||
private double _positiveSoftLimit;
|
||||
|
||||
public AxisSoftLimitItemViewModel(IAxis axis, string axisName, string cardName, int cardNum, int axisNum, double negativeSoftLimit, double positiveSoftLimit)
|
||||
{
|
||||
Axis = axis;
|
||||
AxisName = axisName;
|
||||
CardName = cardName;
|
||||
CardNum = cardNum;
|
||||
AxisNum = axisNum;
|
||||
_negativeSoftLimit = negativeSoftLimit;
|
||||
_positiveSoftLimit = positiveSoftLimit;
|
||||
}
|
||||
|
||||
public IAxis Axis { get; private set; }
|
||||
|
||||
public string AxisName { get; private set; }
|
||||
|
||||
public string CardName { get; private set; }
|
||||
|
||||
public int CardNum { get; private set; }
|
||||
|
||||
public int AxisNum { get; private set; }
|
||||
|
||||
public double NegativeSoftLimit
|
||||
{
|
||||
get
|
||||
{
|
||||
return _negativeSoftLimit;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _negativeSoftLimit, value);
|
||||
}
|
||||
}
|
||||
|
||||
public double PositiveSoftLimit
|
||||
{
|
||||
get
|
||||
{
|
||||
return _positiveSoftLimit;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _positiveSoftLimit, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
using MainShell.Common;
|
||||
using MainShell.Log;
|
||||
using MainShell.Models;
|
||||
using MainShell.ParaSetting.Model;
|
||||
using MaxwellFramework.Core.Interfaces;
|
||||
using MwFramework.ManagerService;
|
||||
using Stylet;
|
||||
using System;
|
||||
using System.Windows;
|
||||
|
||||
namespace MainShell.ParaSetting.ViewModel
|
||||
{
|
||||
public class CameraParameterViewModel : BaseScreen
|
||||
{
|
||||
private readonly IParamList _paramList;
|
||||
private DeviceFoundationSetting _deviceFoundationSetting;
|
||||
|
||||
public CameraParameterViewModel(IParameterManager parameterManager)
|
||||
{
|
||||
_paramList = parameterManager as IParamList;
|
||||
if (_paramList == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(parameterManager));
|
||||
}
|
||||
}
|
||||
|
||||
private DeviceCameraSettingItem _cameraSettingItem;
|
||||
|
||||
public DeviceCameraSettingItem CameraSettingItem
|
||||
{
|
||||
get
|
||||
{
|
||||
return _cameraSettingItem;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _cameraSettingItem, value);
|
||||
}
|
||||
}
|
||||
|
||||
private BindableCollection<CameraFovSettingItem> _cameraItems;
|
||||
|
||||
public BindableCollection<CameraFovSettingItem> CameraItems
|
||||
{
|
||||
get
|
||||
{
|
||||
return _cameraItems;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _cameraItems, value);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnViewLoaded()
|
||||
{
|
||||
base.OnViewLoaded();
|
||||
_deviceFoundationSetting = _paramList.GetParameter<DeviceFoundationSetting>();
|
||||
RefreshState();
|
||||
}
|
||||
|
||||
public void BtnSave()
|
||||
{
|
||||
try
|
||||
{
|
||||
_deviceFoundationSetting.Write();
|
||||
MwMessageBox.Show("保存完成", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogManager.LogSysError(ex.ToString());
|
||||
MwMessageBox.Show(ex.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshState()
|
||||
{
|
||||
if (_deviceFoundationSetting.CameraSettingItem == null)
|
||||
{
|
||||
_deviceFoundationSetting.CameraSettingItem = new DeviceCameraSettingItem();
|
||||
}
|
||||
|
||||
CameraSettingItem = _deviceFoundationSetting.CameraSettingItem;
|
||||
CameraSettingItem.EnsureDefaultCameras();
|
||||
|
||||
BindableCollection<CameraFovSettingItem> cameraItems = new BindableCollection<CameraFovSettingItem>();
|
||||
cameraItems.Add(CameraSettingItem.UpCamera);
|
||||
cameraItems.Add(CameraSettingItem.DownCamera);
|
||||
cameraItems.Add(CameraSettingItem.MapCamera);
|
||||
CameraItems = cameraItems;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
using MainShell.Models;
|
||||
using MaxwellFramework.Core.Interfaces;
|
||||
using MwFramework.Controls.UIControl.Axis;
|
||||
using StyletIoC;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MainShell.ParaSetting.ViewModel
|
||||
{
|
||||
public class DeviceFoundationViewModel : BaseScreen, IPage
|
||||
{
|
||||
private ProduceControlViewModel _produceControlViewModel;
|
||||
[Inject]
|
||||
public ProduceControlViewModel ProduceControlViewModel
|
||||
{
|
||||
get { return _produceControlViewModel; }
|
||||
set
|
||||
{
|
||||
_produceControlViewModel = value;
|
||||
OnPropertyChanged(nameof(ProduceControlViewModel));
|
||||
}
|
||||
}
|
||||
|
||||
private AxisSoftLimitSettingViewModel _axisSoftLimitSettingViewModel;
|
||||
[Inject]
|
||||
public AxisSoftLimitSettingViewModel AxisSoftLimitSettingViewModel
|
||||
{
|
||||
get { return _axisSoftLimitSettingViewModel; }
|
||||
set
|
||||
{
|
||||
_axisSoftLimitSettingViewModel = value;
|
||||
OnPropertyChanged(nameof(AxisSoftLimitSettingViewModel));
|
||||
}
|
||||
}
|
||||
|
||||
private AxisParameterSettingViewModel _axisParameterSettingViewModel;
|
||||
[Inject]
|
||||
public AxisParameterSettingViewModel AxisParameterSettingViewModel
|
||||
{
|
||||
get { return _axisParameterSettingViewModel; }
|
||||
set
|
||||
{
|
||||
_axisParameterSettingViewModel = value;
|
||||
OnPropertyChanged(nameof(AxisParameterSettingViewModel));
|
||||
}
|
||||
}
|
||||
|
||||
private SaveSettingViewModel _saveSettingViewModel;
|
||||
[Inject]
|
||||
public SaveSettingViewModel SaveSettingViewModel
|
||||
{
|
||||
get { return _saveSettingViewModel; }
|
||||
set
|
||||
{
|
||||
_saveSettingViewModel = value;
|
||||
OnPropertyChanged(nameof(SaveSettingViewModel));
|
||||
}
|
||||
}
|
||||
|
||||
private CameraParameterViewModel _cameraParameterViewModel;
|
||||
[Inject]
|
||||
public CameraParameterViewModel CameraParameterViewModel
|
||||
{
|
||||
get { return _cameraParameterViewModel; }
|
||||
set
|
||||
{
|
||||
_cameraParameterViewModel = value;
|
||||
OnPropertyChanged(nameof(CameraParameterViewModel));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using MainShell.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MainShell.ParaSetting.ViewModel
|
||||
{
|
||||
public class DevicePositionViewModel : BaseScreen
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using Stylet;
|
||||
using StyletIoC;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using MainShell.Models;
|
||||
|
||||
namespace MainShell.ParaSetting.ViewModel
|
||||
{
|
||||
public class DeviceRunSettingViewModel:BaseScreen
|
||||
{
|
||||
private ProcessParameterSettingViewModel _processParameterSettingViewModel;
|
||||
[Inject]
|
||||
public ProcessParameterSettingViewModel ProcessParameterSettingViewModel
|
||||
{
|
||||
get { return _processParameterSettingViewModel; }
|
||||
set { _processParameterSettingViewModel = value; }
|
||||
}
|
||||
|
||||
private SpeedSettingViewModel _speedSettingViewModel;
|
||||
[Inject]
|
||||
public SpeedSettingViewModel SpeedSettingViewModel
|
||||
{
|
||||
get { return _speedSettingViewModel; }
|
||||
set { _speedSettingViewModel = value; }
|
||||
}
|
||||
|
||||
|
||||
private ProduceControlViewModel _produceControlViewModel;
|
||||
[Inject]
|
||||
public ProduceControlViewModel ProduceControlViewModel
|
||||
{
|
||||
get { return _produceControlViewModel; }
|
||||
set { _produceControlViewModel = value; }
|
||||
}
|
||||
private OtherProduceViewModel _otherProduceViewModel;
|
||||
[Inject]
|
||||
public OtherProduceViewModel OtherProduceViewModel
|
||||
{
|
||||
get { return _otherProduceViewModel; }
|
||||
set { _otherProduceViewModel = value; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using MainShell.Models;
|
||||
using MainShell.ParaSetting.Model;
|
||||
using MaxwellFramework.Core.Interfaces;
|
||||
using MwFramework.ManagerService;
|
||||
using Stylet;
|
||||
using System;
|
||||
|
||||
namespace MainShell.ParaSetting.ViewModel
|
||||
{
|
||||
public class DeviceSafetyViewModel : BaseScreen
|
||||
{
|
||||
private readonly IParamList _paramList;
|
||||
|
||||
private EquipmentParaSysSetting _equipmentParaSysSetting;
|
||||
|
||||
public DeviceSafetyViewModel(IParameterManager parameterManager)
|
||||
{
|
||||
_paramList = parameterManager as IParamList;
|
||||
if (_paramList == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(parameterManager));
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnViewLoaded()
|
||||
{
|
||||
base.OnViewLoaded();
|
||||
_equipmentParaSysSetting = _paramList.GetParameter<EquipmentParaSysSetting>();
|
||||
if (_equipmentParaSysSetting != null)
|
||||
{
|
||||
SafeParaSysItem = _equipmentParaSysSetting.SafeParaSysItem;
|
||||
}
|
||||
}
|
||||
|
||||
private SafeParaSysItem _safeParaSysItem = new SafeParaSysItem();
|
||||
|
||||
public SafeParaSysItem SafeParaSysItem
|
||||
{
|
||||
get { return _safeParaSysItem; }
|
||||
set
|
||||
{
|
||||
_safeParaSysItem = value;
|
||||
OnPropertyChanged(nameof(SafeParaSysItem));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
using MainShell.Models;
|
||||
using MainShell.ParaSetting.Model;
|
||||
using MaxwellFramework.Core.Interfaces;
|
||||
using MwFramework.ManagerService;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MainShell.ParaSetting.ViewModel
|
||||
{
|
||||
public class OtherProduceViewModel:BaseScreen
|
||||
{
|
||||
private readonly IParamList _paramList;
|
||||
|
||||
private RunSetting _runSetting;
|
||||
|
||||
public RunSetting RunSetting
|
||||
{
|
||||
get => _runSetting;
|
||||
set
|
||||
{
|
||||
_runSetting = value;
|
||||
OnPropertyChanged("RunSetting");
|
||||
}
|
||||
}
|
||||
|
||||
private GlobalRunParameter _globalRunParameter;
|
||||
|
||||
public GlobalRunParameter GlobalRunParameter
|
||||
{
|
||||
get => _globalRunParameter;
|
||||
set
|
||||
{
|
||||
_globalRunParameter = value;
|
||||
OnPropertyChanged("GlobalRunParameter");
|
||||
}
|
||||
}
|
||||
|
||||
private BondingProcessParameter _bondingProcessParameter;
|
||||
|
||||
public BondingProcessParameter BondingProcessParameter
|
||||
{
|
||||
get => _bondingProcessParameter;
|
||||
set
|
||||
{
|
||||
_bondingProcessParameter = value;
|
||||
OnPropertyChanged("BondingProcessParameter");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public OtherProduceViewModel(IParameterManager parameterManager)
|
||||
{
|
||||
_paramList = parameterManager as IParamList;
|
||||
if (_paramList == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(parameterManager));
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnViewLoaded()
|
||||
{
|
||||
base.OnViewLoaded();
|
||||
RunSetting = _paramList.GetParameter<RunSetting>();
|
||||
GlobalRunParameter = RunSetting.GlobalRunParameter;
|
||||
BondingProcessParameter = RunSetting.BondingProcessParameter;
|
||||
}
|
||||
|
||||
public void BtnSave()
|
||||
{
|
||||
RunSetting.Write();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
using MainShell.HeightMeasure.ViewModel;
|
||||
using MainShell.Models;
|
||||
using MaxwellFramework.Core.Interfaces;
|
||||
using Stylet;
|
||||
using StyletIoC;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MainShell.ParaSetting.ViewModel
|
||||
{
|
||||
internal class ParaSettingViewModel : BaseScreen, IPage
|
||||
{
|
||||
public string Name => "PageSettings";
|
||||
private const string DEVICEPOSITION = "设备点位参数";
|
||||
private const string DEVICERUNSETTING = "设备运行参数";
|
||||
private const string DEVICESAFESETTING = "设备安全参数";
|
||||
private const string DEVICEBASESETTING = "设备基础参数";
|
||||
private readonly Dictionary<string, Screen> _viewModelDict = new Dictionary<string, Screen>();
|
||||
public ObservableCollection<MenuItemWrap> MenuItemWraps { get; private set; }
|
||||
|
||||
private MenuItemWrap _selectedMenuItem;
|
||||
|
||||
public MenuItemWrap SelectedMenuItem
|
||||
{
|
||||
get { return _selectedMenuItem; }
|
||||
set
|
||||
{
|
||||
if (SetAndNotify(ref _selectedMenuItem, value))
|
||||
{
|
||||
CurrentScreen = _viewModelDict[value.Header];
|
||||
}
|
||||
}
|
||||
}
|
||||
private Screen _currentScreen;
|
||||
|
||||
public Screen CurrentScreen
|
||||
{
|
||||
get { return _currentScreen; }
|
||||
set { SetAndNotify(ref _currentScreen, value); }
|
||||
}
|
||||
|
||||
private DeviceRunSettingViewModel _deviceRunSettingViewModel;
|
||||
[Inject]
|
||||
public DeviceRunSettingViewModel DeviceRunSettingViewModel
|
||||
{
|
||||
get { return _deviceRunSettingViewModel; }
|
||||
set { _deviceRunSettingViewModel = value; }
|
||||
}
|
||||
|
||||
private DevicePositionViewModel _devicePositionViewModel;
|
||||
[Inject]
|
||||
public DevicePositionViewModel DevicePositionViewModel
|
||||
{
|
||||
get { return _devicePositionViewModel; }
|
||||
set { _devicePositionViewModel = value; }
|
||||
}
|
||||
|
||||
private DeviceFoundationViewModel _deviceFoundationViewModel;
|
||||
[Inject]
|
||||
public DeviceFoundationViewModel DeviceFoundationViewModel
|
||||
{
|
||||
get { return _deviceFoundationViewModel; }
|
||||
set { _deviceFoundationViewModel = value; }
|
||||
}
|
||||
|
||||
private DeviceSafetyViewModel _deviceSafetyViewModel;
|
||||
[Inject]
|
||||
public DeviceSafetyViewModel DeviceSafetyViewModel
|
||||
{
|
||||
get { return _deviceSafetyViewModel; }
|
||||
set { _deviceSafetyViewModel = value; }
|
||||
}
|
||||
|
||||
public ParaSettingViewModel()
|
||||
{
|
||||
InitMenuItems();
|
||||
}
|
||||
|
||||
protected override void OnViewLoaded()
|
||||
{
|
||||
base.OnViewLoaded();
|
||||
if (_viewModelDict.Count == 0)
|
||||
{
|
||||
InitViewModelDict();
|
||||
}
|
||||
if (SelectedMenuItem == null)
|
||||
SelectedMenuItem = MenuItemWraps[0];
|
||||
}
|
||||
private void InitMenuItems()
|
||||
{
|
||||
MenuItemWraps = new ObservableCollection<MenuItemWrap>
|
||||
{
|
||||
new MenuItemWrap() { Header=DEVICEPOSITION,Tag=DEVICEPOSITION },
|
||||
|
||||
new MenuItemWrap() { Header=DEVICERUNSETTING,Tag=DEVICERUNSETTING },
|
||||
|
||||
new MenuItemWrap() { Header=DEVICESAFESETTING,Tag=DEVICESAFESETTING },
|
||||
|
||||
new MenuItemWrap() { Header=DEVICEBASESETTING,Tag=DEVICEBASESETTING },
|
||||
};
|
||||
}
|
||||
private void InitViewModelDict()
|
||||
{
|
||||
_viewModelDict.Clear();
|
||||
_viewModelDict.Add(DEVICEPOSITION, DevicePositionViewModel);
|
||||
_viewModelDict.Add(DEVICERUNSETTING, DeviceRunSettingViewModel);
|
||||
_viewModelDict.Add(DEVICESAFESETTING, DeviceSafetyViewModel);
|
||||
_viewModelDict.Add(DEVICEBASESETTING, DeviceFoundationViewModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,260 @@
|
||||
using MainShell.Models;
|
||||
using MainShell.ParaSetting.Model;
|
||||
using MaxwellFramework.Core.Interfaces;
|
||||
using MwFramework.ManagerService;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Windows;
|
||||
using StyletIoC;
|
||||
|
||||
namespace MainShell.ParaSetting.ViewModel
|
||||
{
|
||||
public class ProcessParameterSettingViewModel : BaseScreen
|
||||
{
|
||||
private readonly IParamList _paramList;
|
||||
private ObservableCollection<MenuItemWrap> _processMenuItemWraps;
|
||||
private MenuItemWrap _selectedProcessMenuItem;
|
||||
private object _currentScreen;
|
||||
|
||||
private ProductLoadProcessParameterViewModel _productLoadProcessParameterViewModel;
|
||||
[Inject]
|
||||
public ProductLoadProcessParameterViewModel ProductLoadProcessParameterViewModel
|
||||
{
|
||||
get { return _productLoadProcessParameterViewModel; }
|
||||
set { _productLoadProcessParameterViewModel = value; }
|
||||
}
|
||||
|
||||
private ProductUnloadProcessParameterViewModel _productUnloadProcessParameterViewModel;
|
||||
[Inject]
|
||||
public ProductUnloadProcessParameterViewModel ProductUnloadProcessParameterViewModel
|
||||
{
|
||||
get { return _productUnloadProcessParameterViewModel; }
|
||||
set { _productUnloadProcessParameterViewModel = value; }
|
||||
}
|
||||
|
||||
private ProductPositionProcessParameterViewModel _productPositionProcessParameterViewModel;
|
||||
[Inject]
|
||||
public ProductPositionProcessParameterViewModel ProductPositionProcessParameterViewModel
|
||||
{
|
||||
get { return _productPositionProcessParameterViewModel; }
|
||||
set { _productPositionProcessParameterViewModel = value; }
|
||||
}
|
||||
|
||||
private ProductHeightMeasureProcessParameterViewModel _productHeightMeasureProcessParameterViewModel;
|
||||
[Inject]
|
||||
public ProductHeightMeasureProcessParameterViewModel ProductHeightMeasureProcessParameterViewModel
|
||||
{
|
||||
get { return _productHeightMeasureProcessParameterViewModel; }
|
||||
set { _productHeightMeasureProcessParameterViewModel = value; }
|
||||
}
|
||||
|
||||
private WaferLoadProcessParameterViewModel _waferLoadProcessParameterViewModel;
|
||||
[Inject]
|
||||
public WaferLoadProcessParameterViewModel WaferLoadProcessParameterViewModel
|
||||
{
|
||||
get { return _waferLoadProcessParameterViewModel; }
|
||||
set { _waferLoadProcessParameterViewModel = value; }
|
||||
}
|
||||
|
||||
private WaferUnloadProcessParameterViewModel _waferUnloadProcessParameterViewModel;
|
||||
[Inject]
|
||||
public WaferUnloadProcessParameterViewModel WaferUnloadProcessParameterViewModel
|
||||
{
|
||||
get { return _waferUnloadProcessParameterViewModel; }
|
||||
set { _waferUnloadProcessParameterViewModel = value; }
|
||||
}
|
||||
|
||||
private WaferStraightenProcessParameterViewModel _waferStraightenProcessParameterViewModel;
|
||||
[Inject]
|
||||
public WaferStraightenProcessParameterViewModel WaferStraightenProcessParameterViewModel
|
||||
{
|
||||
get { return _waferStraightenProcessParameterViewModel; }
|
||||
set { _waferStraightenProcessParameterViewModel = value; }
|
||||
}
|
||||
|
||||
private DieRecognizeProcessParameterViewModel _dieRecognizeProcessParameterViewModel;
|
||||
[Inject]
|
||||
public DieRecognizeProcessParameterViewModel DieRecognizeProcessParameterViewModel
|
||||
{
|
||||
get { return _dieRecognizeProcessParameterViewModel; }
|
||||
set { _dieRecognizeProcessParameterViewModel = value; }
|
||||
}
|
||||
|
||||
private BondingProcessParameterViewModel _bondingProcessParameterViewModel;
|
||||
[Inject]
|
||||
public BondingProcessParameterViewModel BondingProcessParameterViewModel
|
||||
{
|
||||
get { return _bondingProcessParameterViewModel; }
|
||||
set { _bondingProcessParameterViewModel = value; }
|
||||
}
|
||||
|
||||
private RecheckProcessParameterViewModel _recheckProcessParameterViewModel;
|
||||
[Inject]
|
||||
public RecheckProcessParameterViewModel RecheckProcessParameterViewModel
|
||||
{
|
||||
get { return _recheckProcessParameterViewModel; }
|
||||
set { _recheckProcessParameterViewModel = value; }
|
||||
}
|
||||
|
||||
private RunSetting _runSetting;
|
||||
|
||||
public RunSetting RunSetting
|
||||
{
|
||||
get { return _runSetting; }
|
||||
set
|
||||
{
|
||||
_runSetting = value;
|
||||
OnPropertyChanged(nameof(RunSetting));
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<MenuItemWrap> ProcessMenuItemWraps
|
||||
{
|
||||
get { return _processMenuItemWraps; }
|
||||
private set
|
||||
{
|
||||
_processMenuItemWraps = value;
|
||||
OnPropertyChanged(nameof(ProcessMenuItemWraps));
|
||||
}
|
||||
}
|
||||
|
||||
public MenuItemWrap SelectedProcessMenuItem
|
||||
{
|
||||
get { return _selectedProcessMenuItem; }
|
||||
set
|
||||
{
|
||||
_selectedProcessMenuItem = value;
|
||||
CurrentScreen = value != null ? value.Tag : null;
|
||||
OnPropertyChanged(nameof(SelectedProcessMenuItem));
|
||||
OnPropertyChanged(nameof(CurrentProcessHeader));
|
||||
}
|
||||
}
|
||||
|
||||
public object CurrentScreen
|
||||
{
|
||||
get { return _currentScreen; }
|
||||
private set
|
||||
{
|
||||
_currentScreen = value;
|
||||
OnPropertyChanged(nameof(CurrentScreen));
|
||||
}
|
||||
}
|
||||
|
||||
public string CurrentProcessHeader
|
||||
{
|
||||
get { return SelectedProcessMenuItem != null ? SelectedProcessMenuItem.Header : string.Empty; }
|
||||
}
|
||||
|
||||
public ProcessParameterSettingViewModel(IParameterManager parameterManager)
|
||||
{
|
||||
_paramList = parameterManager as IParamList;
|
||||
if (_paramList == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(parameterManager));
|
||||
}
|
||||
|
||||
ProcessMenuItemWraps = new ObservableCollection<MenuItemWrap>();
|
||||
}
|
||||
|
||||
protected override void OnViewLoaded()
|
||||
{
|
||||
base.OnViewLoaded();
|
||||
RunSetting = _paramList.GetParameter<RunSetting>();
|
||||
BindSectionParameters();
|
||||
InitializeProcessMenuItems();
|
||||
}
|
||||
|
||||
private void BindSectionParameters()
|
||||
{
|
||||
if (RunSetting == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ProductLoadProcessParameterViewModel.SetParameter(RunSetting.ProductLoadProcessParameter);
|
||||
ProductUnloadProcessParameterViewModel.SetParameter(RunSetting.ProductUnloadProcessParameter);
|
||||
ProductPositionProcessParameterViewModel.SetParameter(RunSetting.ProductPositionProcessParameter);
|
||||
ProductHeightMeasureProcessParameterViewModel.SetParameter(RunSetting.ProductHeightMeasureProcessParameter);
|
||||
WaferLoadProcessParameterViewModel.SetParameter(RunSetting.WaferLoadProcessParameter);
|
||||
WaferUnloadProcessParameterViewModel.SetParameter(RunSetting.WaferUnloadProcessParameter);
|
||||
WaferStraightenProcessParameterViewModel.SetParameter(RunSetting.WaferStraightenProcessParameter);
|
||||
DieRecognizeProcessParameterViewModel.SetParameter(RunSetting.DieRecognizeProcessParameter);
|
||||
BondingProcessParameterViewModel.SetParameter(RunSetting.BondingProcessParameter);
|
||||
RecheckProcessParameterViewModel.SetParameter(RunSetting.RecheckProcessParameter);
|
||||
|
||||
RunSetting.WaferStraightenProcessParameter.PropertyChanged -= OnWaferStraightenProcessParameterChanged;
|
||||
RunSetting.WaferStraightenProcessParameter.PropertyChanged += OnWaferStraightenProcessParameterChanged;
|
||||
}
|
||||
|
||||
private void InitializeProcessMenuItems()
|
||||
{
|
||||
ProcessMenuItemWraps.Clear();
|
||||
ProcessMenuItemWraps.Add(CreateProcessMenuItem("ProcessTabProductLoad", ProductLoadProcessParameterViewModel));
|
||||
ProcessMenuItemWraps.Add(CreateProcessMenuItem("ProcessTabProductUnload", ProductUnloadProcessParameterViewModel));
|
||||
ProcessMenuItemWraps.Add(CreateProcessMenuItem("ProcessTabProductPosition", ProductPositionProcessParameterViewModel));
|
||||
ProcessMenuItemWraps.Add(CreateProcessMenuItem("ProcessTabProductHeightMeasure", ProductHeightMeasureProcessParameterViewModel));
|
||||
ProcessMenuItemWraps.Add(CreateProcessMenuItem("ProcessTabWaferLoad", WaferLoadProcessParameterViewModel));
|
||||
ProcessMenuItemWraps.Add(CreateProcessMenuItem("ProcessTabWaferUnload", WaferUnloadProcessParameterViewModel));
|
||||
ProcessMenuItemWraps.Add(CreateProcessMenuItem("ProcessTabWaferStraighten", WaferStraightenProcessParameterViewModel));
|
||||
ProcessMenuItemWraps.Add(CreateProcessMenuItem("ProcessTabDieRecognize", DieRecognizeProcessParameterViewModel));
|
||||
ProcessMenuItemWraps.Add(CreateProcessMenuItem("ProcessTabBonding", BondingProcessParameterViewModel));
|
||||
ProcessMenuItemWraps.Add(CreateProcessMenuItem("ProcessTabRecheck", RecheckProcessParameterViewModel));
|
||||
|
||||
if (ProcessMenuItemWraps.Count > 0)
|
||||
{
|
||||
SelectedProcessMenuItem = ProcessMenuItemWraps[0];
|
||||
}
|
||||
}
|
||||
|
||||
private MenuItemWrap CreateProcessMenuItem(string resourceKey, object screen)
|
||||
{
|
||||
MenuItemWrap menuItemWrap = new MenuItemWrap();
|
||||
menuItemWrap.Header = ResolveResourceText(resourceKey);
|
||||
menuItemWrap.Tag = screen;
|
||||
return menuItemWrap;
|
||||
}
|
||||
|
||||
private string ResolveResourceText(string resourceKey)
|
||||
{
|
||||
if (Application.Current == null)
|
||||
{
|
||||
return resourceKey;
|
||||
}
|
||||
|
||||
object resource = Application.Current.TryFindResource(resourceKey);
|
||||
string text = resource as string;
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
{
|
||||
return resourceKey;
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
private void OnWaferStraightenProcessParameterChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (RunSetting == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.PropertyName == nameof(WaferStraightenProcessParameter.UseSingleStraighten))
|
||||
{
|
||||
bool useSingleStraighten = RunSetting.WaferStraightenProcessParameter.UseSingleStraighten;
|
||||
if (RunSetting.DieRecognizeProcessParameter.UseSingleWaferPosition != useSingleStraighten)
|
||||
{
|
||||
RunSetting.DieRecognizeProcessParameter.UseSingleWaferPosition = useSingleStraighten;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void BtnSave()
|
||||
{
|
||||
if (RunSetting != null)
|
||||
{
|
||||
RunSetting.Write();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
using MainShell.Models;
|
||||
using MainShell.ParaSetting.Model;
|
||||
using MaxwellControl.Controls;
|
||||
using MaxwellFramework.Core.Interfaces;
|
||||
using MwFramework.ManagerService;
|
||||
using Stylet;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace MainShell.ParaSetting.ViewModel
|
||||
{
|
||||
public class ProduceControlViewModel : BaseScreen
|
||||
{
|
||||
private ObservableCollection<SubProcessItem> _subProcesses = new ObservableCollection<SubProcessItem>();
|
||||
|
||||
public ObservableCollection<SubProcessItem> SubProcesses
|
||||
{
|
||||
get => _subProcesses;
|
||||
set
|
||||
{
|
||||
_subProcesses = value;
|
||||
OnPropertyChanged("SubProcesses");
|
||||
}
|
||||
}
|
||||
|
||||
private RunSetting _runSetting;
|
||||
|
||||
public RunSetting RunSetting
|
||||
{
|
||||
get => _runSetting;
|
||||
set
|
||||
{
|
||||
_runSetting = value;
|
||||
OnPropertyChanged("RunSetting");
|
||||
}
|
||||
}
|
||||
|
||||
private IParamList _paramList;
|
||||
public ProduceControlViewModel(IParameterManager parameterManager)
|
||||
{
|
||||
_paramList = parameterManager as IParamList;
|
||||
if (_paramList == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(parameterManager));
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnViewLoaded()
|
||||
{
|
||||
base.OnViewLoaded();
|
||||
RunSetting = _paramList.GetParameter<RunSetting>();
|
||||
InitializeSubProcesses();
|
||||
}
|
||||
|
||||
private void InitializeSubProcesses()
|
||||
{
|
||||
if (SubProcesses.Count > 0) return;
|
||||
SubProcesses.Add(new SubProcessItem
|
||||
{
|
||||
ProcessName = "产品上料",
|
||||
IsEnabled = RunSetting.FlowControlItem.SubStrateLoadEnable,
|
||||
ToolTipText = "控制产品上料子流程的启用/禁用"
|
||||
});
|
||||
SubProcesses.Add(new SubProcessItem
|
||||
{
|
||||
ProcessName = "产品下料",
|
||||
IsEnabled = RunSetting.FlowControlItem.SubStrateUnLoadEnable,
|
||||
ToolTipText = "控制产品下料子流程的启用/禁用"
|
||||
});
|
||||
SubProcesses.Add(new SubProcessItem
|
||||
{
|
||||
ProcessName = "产品定位",
|
||||
IsEnabled = RunSetting.FlowControlItem.SubstratePositionEnable,
|
||||
ToolTipText = "控制产品高度测量子流程的启用/禁用"
|
||||
});
|
||||
SubProcesses.Add(new SubProcessItem
|
||||
{
|
||||
ProcessName = "产品高度测量",
|
||||
IsEnabled = RunSetting.FlowControlItem.SubstrateHeightMeasureEnable,
|
||||
ToolTipText = "控制产品高度测量子流程的启用/禁用"
|
||||
});
|
||||
SubProcesses.Add(new SubProcessItem
|
||||
{
|
||||
ProcessName = "方片上料",
|
||||
IsEnabled = RunSetting.FlowControlItem.WaferLoadEnable,
|
||||
ToolTipText = "控制方片下料子流程的启用/禁用"
|
||||
});
|
||||
SubProcesses.Add(new SubProcessItem
|
||||
{
|
||||
ProcessName = "方片下料",
|
||||
IsEnabled = RunSetting.FlowControlItem.WaferUnLoadEnable,
|
||||
ToolTipText = "控制方片下料子流程的启用/禁用"
|
||||
});
|
||||
SubProcesses.Add(new SubProcessItem
|
||||
{
|
||||
ProcessName = "方片拉直",
|
||||
IsEnabled = RunSetting.FlowControlItem.WaferStraightenEnable,
|
||||
ToolTipText = "控制方片拉直子流程的启用/禁用"
|
||||
});
|
||||
SubProcesses.Add(new SubProcessItem
|
||||
{
|
||||
ProcessName = "晶粒飞拍",
|
||||
IsEnabled = RunSetting.FlowControlItem.WaferPositionEnable,
|
||||
ToolTipText = "控制晶粒飞拍子流程的启用/禁用"
|
||||
});
|
||||
SubProcesses.Add(new SubProcessItem
|
||||
{
|
||||
ProcessName = "转移作业",
|
||||
IsEnabled = RunSetting.FlowControlItem.BondingEnable,
|
||||
ToolTipText = "控制转移作业子流程的启用/禁用"
|
||||
});
|
||||
SubProcesses.Add(new SubProcessItem
|
||||
{
|
||||
ProcessName = "复检",
|
||||
IsEnabled = RunSetting.FlowControlItem.SubstrateRecheckEnable,
|
||||
ToolTipText = "控制复检子流程的启用/禁用"
|
||||
});
|
||||
}
|
||||
|
||||
public void BtnSave()
|
||||
{
|
||||
RunSetting.FlowControlItem.SubStrateLoadEnable = SubProcesses.First(p => p.ProcessName == "产品上料").IsEnabled;
|
||||
RunSetting.FlowControlItem.SubStrateUnLoadEnable = SubProcesses.First(p => p.ProcessName == "产品下料").IsEnabled;
|
||||
RunSetting.FlowControlItem.WaferLoadEnable = SubProcesses.First(p => p.ProcessName == "方片上料").IsEnabled;
|
||||
RunSetting.FlowControlItem.WaferUnLoadEnable = SubProcesses.First(p => p.ProcessName == "方片下料").IsEnabled;
|
||||
RunSetting.FlowControlItem.SubstratePositionEnable = SubProcesses.First(p => p.ProcessName == "产品定位").IsEnabled;
|
||||
RunSetting.FlowControlItem.SubstrateHeightMeasureEnable = SubProcesses.First(p => p.ProcessName == "产品高度测量").IsEnabled;
|
||||
RunSetting.FlowControlItem.WaferStraightenEnable = SubProcesses.First(p => p.ProcessName == "方片拉直").IsEnabled;
|
||||
RunSetting.FlowControlItem.WaferPositionEnable = SubProcesses.First(p => p.ProcessName == "晶粒飞拍").IsEnabled;
|
||||
RunSetting.FlowControlItem.BondingEnable = SubProcesses.First(p => p.ProcessName == "转移作业").IsEnabled;
|
||||
RunSetting.FlowControlItem.SubstrateRecheckEnable = SubProcesses.First(p => p.ProcessName == "复检").IsEnabled;
|
||||
RunSetting.Write();
|
||||
MessageBox.Show("保存完成");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class SubProcessItem : PropertyChangedBase
|
||||
{
|
||||
private string _processName;
|
||||
public string ProcessName
|
||||
{
|
||||
get { return _processName; }
|
||||
set { SetAndNotify(ref _processName, value); }
|
||||
}
|
||||
|
||||
private bool _isEnabled;
|
||||
public bool IsEnabled
|
||||
{
|
||||
get { return _isEnabled; }
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _isEnabled, value);
|
||||
if (value) StatusText = "已启用";
|
||||
else StatusText = "已禁用";
|
||||
}
|
||||
}
|
||||
|
||||
private string _toolTipText;
|
||||
public string ToolTipText
|
||||
{
|
||||
get { return _toolTipText; }
|
||||
set { SetAndNotify(ref _toolTipText, value); }
|
||||
}
|
||||
|
||||
private string _statusText;
|
||||
public string StatusText
|
||||
{
|
||||
get { return _statusText; }
|
||||
set { SetAndNotify(ref _statusText, value); }
|
||||
}
|
||||
//public string StatusText => IsEnabled ? "已启用" : "已禁用";
|
||||
//public Brush StatusColor => IsEnabled ? Brushes.Green : Brushes.Gray;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
using MainShell.Common;
|
||||
using MainShell.Log;
|
||||
using MainShell.Models;
|
||||
using MainShell.ParaSetting.Model;
|
||||
using MaxwellFramework.Core.Interfaces;
|
||||
using MwFramework.ManagerService;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using Forms = System.Windows.Forms;
|
||||
|
||||
namespace MainShell.ParaSetting.ViewModel
|
||||
{
|
||||
public class SaveSettingViewModel : BaseScreen
|
||||
{
|
||||
private readonly IParamList _paramList;
|
||||
|
||||
private DeviceFoundationSetting _deviceFoundationSetting;
|
||||
|
||||
public SaveSettingViewModel(IParameterManager parameterManager)
|
||||
{
|
||||
_paramList = parameterManager as IParamList;
|
||||
if (_paramList == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(parameterManager));
|
||||
}
|
||||
}
|
||||
|
||||
private DeviceSaveSettingItem _saveSettingItem;
|
||||
|
||||
public DeviceSaveSettingItem SaveSettingItem
|
||||
{
|
||||
get
|
||||
{
|
||||
return _saveSettingItem;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _saveSettingItem, value);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnViewLoaded()
|
||||
{
|
||||
base.OnViewLoaded();
|
||||
_deviceFoundationSetting = _paramList.GetParameter<DeviceFoundationSetting>();
|
||||
RefreshState();
|
||||
}
|
||||
|
||||
public void BtnSave()
|
||||
{
|
||||
try
|
||||
{
|
||||
_deviceFoundationSetting.Write();
|
||||
MwMessageBox.Show("保存完成", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogManager.LogSysError(ex.ToString());
|
||||
MwMessageBox.Show(ex.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
public void BrowseFileSaveFolder()
|
||||
{
|
||||
string selectedPath = BrowseFolder(SaveSettingItem == null || SaveSettingItem.FileSaveSetting == null ? null : SaveSettingItem.FileSaveSetting.SaveFolder);
|
||||
if (string.IsNullOrWhiteSpace(selectedPath) || SaveSettingItem == null || SaveSettingItem.FileSaveSetting == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SaveSettingItem.FileSaveSetting.SaveFolder = selectedPath;
|
||||
}
|
||||
|
||||
public void BrowseImageSaveFolder()
|
||||
{
|
||||
string selectedPath = BrowseFolder(SaveSettingItem == null || SaveSettingItem.ImageSaveSetting == null ? null : SaveSettingItem.ImageSaveSetting.SaveFolder);
|
||||
if (string.IsNullOrWhiteSpace(selectedPath) || SaveSettingItem == null || SaveSettingItem.ImageSaveSetting == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SaveSettingItem.ImageSaveSetting.SaveFolder = selectedPath;
|
||||
}
|
||||
|
||||
private void RefreshState()
|
||||
{
|
||||
if (_deviceFoundationSetting.SaveSettingItem == null)
|
||||
{
|
||||
_deviceFoundationSetting.SaveSettingItem = new DeviceSaveSettingItem();
|
||||
}
|
||||
|
||||
SaveSettingItem = _deviceFoundationSetting.SaveSettingItem;
|
||||
}
|
||||
|
||||
private static string BrowseFolder(string currentPath)
|
||||
{
|
||||
using (Forms.FolderBrowserDialog dialog = new Forms.FolderBrowserDialog())
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(currentPath) && Directory.Exists(currentPath))
|
||||
{
|
||||
dialog.SelectedPath = currentPath;
|
||||
}
|
||||
|
||||
Forms.DialogResult result = dialog.ShowDialog();
|
||||
if (result != Forms.DialogResult.OK)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return dialog.SelectedPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
using MainShell.Hardware;
|
||||
using MaxwellControl.Tools;
|
||||
using MaxwellFramework.Core.Interfaces;
|
||||
using MwFramework.Device;
|
||||
using MwFramework.Controls.UIControl;
|
||||
using MwFramework.ManagerService;
|
||||
using Stylet;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using static MainShell.ParaSetting.Model.SpeedSetting;
|
||||
using MessageBox = MaxwellControl.Controls.MessageBox;
|
||||
|
||||
namespace MainShell.ParaSetting.ViewModel
|
||||
{
|
||||
public class SpeedSettingViewModel:Screen,IPage
|
||||
{
|
||||
public string Name { get; set; } = "SpeedParaSys";
|
||||
|
||||
private readonly IParamList _paramList;
|
||||
|
||||
private ParameterHelper _parameterHelper = new ParameterHelper();
|
||||
public ParameterHelper ParameterHelper
|
||||
{
|
||||
get
|
||||
{
|
||||
return _parameterHelper;
|
||||
}
|
||||
set
|
||||
{
|
||||
_parameterHelper = value;
|
||||
OnPropertyChanged(nameof(ParameterHelper));
|
||||
}
|
||||
}
|
||||
private SpeedParaSysSetting _speedParaSysSetting;
|
||||
public SpeedParaSysSetting SpeedParaSysSetting
|
||||
{
|
||||
get
|
||||
{
|
||||
return _speedParaSysSetting;
|
||||
}
|
||||
set
|
||||
{
|
||||
_speedParaSysSetting = value;
|
||||
OnPropertyChanged(nameof(SpeedParaSysSetting));
|
||||
}
|
||||
}
|
||||
private double _speed = 10;
|
||||
public double Speed
|
||||
{
|
||||
get
|
||||
{
|
||||
return _speed;
|
||||
}
|
||||
set
|
||||
{
|
||||
_speed = value;
|
||||
OnPropertyChanged(nameof(Speed));
|
||||
}
|
||||
}
|
||||
|
||||
private readonly HardwareManager _hardware;
|
||||
public SpeedSettingViewModel(IParameterManager parameterManager, HardwareManager hardware)
|
||||
{
|
||||
_paramList = parameterManager as IParamList;
|
||||
if (_paramList == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(parameterManager));
|
||||
}
|
||||
|
||||
_hardware = hardware ?? throw new ArgumentNullException(nameof(hardware));
|
||||
}
|
||||
|
||||
protected override void OnViewLoaded()
|
||||
{
|
||||
base.OnViewLoaded();
|
||||
SpeedParaSysSetting = _paramList.GetParameter<SpeedParaSysSetting>();
|
||||
InitializeAxisSpeedItems();
|
||||
}
|
||||
|
||||
private void InitializeAxisSpeedItems()
|
||||
{
|
||||
Dictionary<string, IAxis> axisNameDic = _hardware.AxesDic;
|
||||
if (SpeedParaSysSetting.SpeedTypeItemCollection.SpeedTypeItemList.Count != axisNameDic.Count)
|
||||
{
|
||||
SpeedParaSysSetting.SpeedTypeItemCollection.SpeedTypeItemList.Clear();
|
||||
foreach (var axisByIndex in axisNameDic)
|
||||
{
|
||||
SpeedParaSysSetting.SpeedTypeItemCollection.SpeedTypeItemList.Add(new SpeedTypeItem
|
||||
{
|
||||
AxisName = axisByIndex.Key,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void btnSet()
|
||||
{
|
||||
if (MessageBox.Show("是否保存", null, "确认保存", MessageBoxButton.OKCancel, MessageBoxImage.Question, MessageBoxResult.Cancel) == MessageBoxResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
SpeedParaSysSetting.Write();
|
||||
LogWatchValueManager.Save(SpeedParaSysSetting.SpeedTypeItemCollection, "SpeedPara_速度规划");
|
||||
ParameterHelper.RaiseValueAccept();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void btnRowData()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!Confirm("是否修改当前选中数据的速度")) return;
|
||||
|
||||
IList<SpeedTypeItem> items = SpeedParaSysSetting?.SpeedTypeItemCollection?.SpeedTypeItemList;
|
||||
SpeedTypeItem selected = SpeedParaSysSetting?.SpeedTypeItemCollection?.CurrentSelectSpeedTypeItemList;
|
||||
if (items == null || selected == null)
|
||||
{
|
||||
MessageBox.Show("未找到速度项或未选择项。");
|
||||
return;
|
||||
}
|
||||
|
||||
// 找到轴索引相同的项并更新
|
||||
SpeedTypeItem item = items.FirstOrDefault(x => x.AxisName == selected.AxisName);
|
||||
if (item != null)
|
||||
{
|
||||
UpdateItem(item, Speed);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void btnPageData()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!Confirm("是否修改当前界面的速度")) return;
|
||||
|
||||
var items = SpeedParaSysSetting?.SpeedTypeItemCollection?.SpeedTypeItemList;
|
||||
if (items == null)
|
||||
{
|
||||
MessageBox.Show("未找到速度项。");
|
||||
return;
|
||||
}
|
||||
|
||||
ApplyTo(items, Speed);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改当前界面的龙门速度
|
||||
/// </summary>
|
||||
public void btnPageGantryData()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!Confirm("是否修改当前界面的龙门速度")) return;
|
||||
|
||||
var items = SpeedParaSysSetting?.SpeedTypeItemCollection?.SpeedTypeItemList;
|
||||
if (items == null)
|
||||
{
|
||||
MessageBox.Show("未找到速度项。");
|
||||
return;
|
||||
}
|
||||
|
||||
// 假设龙门轴号为 0..3(按 AxisIndex 判断,避免直接按列表索引)
|
||||
//var gantryItems = items.Where(x => x.AxisIndex >= 0 && x.AxisIndex <= 3);
|
||||
//ApplyTo(gantryItems, Speed);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改当前界面的Z和TH轴速度
|
||||
/// </summary>
|
||||
public void btnPageZAndTHData()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!Confirm("是否修改当前界面的Z和TH轴速度")) return;
|
||||
|
||||
var items = SpeedParaSysSetting?.SpeedTypeItemCollection?.SpeedTypeItemList;
|
||||
if (items == null)
|
||||
{
|
||||
MessageBox.Show("未找到速度项。");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//var zthItems = items.Where(x => x.AxisIndex >= 4 && x.AxisIndex <= 6);
|
||||
//ApplyTo(zthItems, Speed);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
#region Helpers
|
||||
private bool Confirm(string message)
|
||||
{
|
||||
return MessageBox.Show(message, null, "确认修改", MessageBoxButton.OKCancel, MessageBoxImage.Question, MessageBoxResult.Cancel) == MessageBoxResult.OK;
|
||||
}
|
||||
|
||||
private void ApplyTo(IEnumerable<SpeedTypeItem> items, double speed)
|
||||
{
|
||||
if (items == null) return;
|
||||
foreach (var it in items)
|
||||
{
|
||||
UpdateItem(it, speed);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateItem(SpeedTypeItem item, double speed)
|
||||
{
|
||||
if (item == null) return;
|
||||
item.Speed = speed;
|
||||
item.Acc = 10 * speed;
|
||||
item.Dec = 10 * speed;
|
||||
item.Jerk = 100 * speed;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user