using Aitex.Core.UI.MVVM;
using Aitex.Sorter.Common;
using MECF.Framework.Common.CommonData;
using MECF.Framework.Common.ControlDataContext;
using MECF.Framework.Common.DataCenter;
using MECF.Framework.Common.Equipment;
using MECF.Framework.Common.OperationCenter;
using MECF.Framework.Common.Utilities;
using Newtonsoft.Json;
using OpenSEMI.ClientBase.Command;
using Prism.Mvvm;
using PunkHPX8_Core;
using PunkHPX8_MainPages.Roles;
using PunkHPX8_MainPages.Views;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
using System.Windows.Input;
using System.Windows.Threading;
namespace PunkHPX8_MainPages.ViewModels
{
public class RobotCycleViewModel : BindableBase
{
#region 内部变量
///
/// 输入的Cycle次数
///
private int _inPutCycleTimes = 1;
///
/// Aligner旋转的角度
///
private int _alignerAngle = 0;
///
/// 当前正在执行第几次Cycle
///
private int _currentCycle;
///
/// 是否可以输入参数
///
private bool _isInputParameterEnable;
#region 系统数据
///
/// 定时器
///
DispatcherTimer _timer;
///
/// 查询后台数据集合
///
private List _rtDataKeys = new List();
///
/// rt查询key数值字典
///
private Dictionary _rtDataValueDic = new Dictionary();
#endregion
#endregion
#region 属性
public int InPutCycleTimes
{
get { return _inPutCycleTimes; }
set { SetProperty(ref _inPutCycleTimes, value); }
}
public int AlignerAngle
{
get { return _alignerAngle; }
set { SetProperty(ref _alignerAngle, value); }
}
public int CurrentCycle
{
get { return _currentCycle; }
set { SetProperty(ref _currentCycle, value); }
}
public bool IsInputParameterEnable
{
get { return _isInputParameterEnable; }
set { SetProperty(ref _isInputParameterEnable, value); }
}
#endregion
public class PositionItem : INotifyPropertyChanged
{
private string _destination;
public string ModuleType { get; set; }
public ModuleName ModuleName { get; set; }
public string Parameter { get; set; }
public Hand RobotHand { get; set; }
public Flip PickRobotFlip { get; set; }
public Flip PlaceRobotFlip { get; set; }
public string Destination {
get => _destination;
set
{
_destination = value;
OnPropertyChanged(nameof(Destination)); // 触发通知
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
private ObservableCollection _positions = new ObservableCollection();
public ObservableCollection Positions
{
get { return _positions; }
set { SetProperty(ref _positions, value); }
}
public ObservableCollection PositionTypes { get; } = new ObservableCollection
{
"LP", "Aligner", "Dummy", "SRD", "VPW","PlatingCell"
};
public ObservableCollection HandsTypes { get; } = new ObservableCollection
{
"Blade1", "Blade2"
};
public ObservableCollection FlipTypes { get; } = new ObservableCollection
{
"Upper", "Down"
};
private string _selectedPositionType;
public string SelectedPositionType
{
get { return _selectedPositionType; }
set
{
SetProperty(ref _selectedPositionType, value);
UpdateAvailableSelections();
}
}
public ObservableCollection AvailableSelections { get; } = new ObservableCollection();
private ModuleName _selectedSelection;
public ModuleName SelectedSelection
{
get { return _selectedSelection; }
set { SetProperty(ref _selectedSelection, value); }
}
private string _parameter;
public string Parameter
{
get { return _parameter; }
set { SetProperty(ref _parameter, value); }
}
private Hand _robotHand;
public Hand RobotHand
{
get { return _robotHand; }
set { SetProperty(ref _robotHand, value); }
}
private Flip _pickRobotFlip;
public Flip PickRobotFlip
{
get { return _pickRobotFlip; }
set { SetProperty(ref _pickRobotFlip, value); }
}
private Flip _placeRobotFlip;
public Flip PlaceRobotFlip
{
get { return _placeRobotFlip; }
set { SetProperty(ref _placeRobotFlip, value); }
}
#region 命令
public ICommand RobotCycleConfirmCommand { get; set; }
public ICommand RobotCycleStartCommand { get; set; }
public ICommand RobotCycleAbortCommand { get; set; }
public ICommand AddPositionCommand { get; set; }
public ICommand MoveUpCommand { get; set; }
public ICommand MoveDownCommand { get; set; }
public ICommand RemoveCommand { get; set; }
#endregion
///
/// 构造器
///
public RobotCycleViewModel()
{
RobotCycleConfirmCommand = new DelegateCommand