using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Threading;
using MECF.Framework.Common.OperationCenter;
using Prism.Mvvm;
using Prism.Commands;
using MECF.Framework.Common.CommonData.SRD;
using MECF.Framework.Common.Persistent.SRD;
using Aitex.Core.RT.DataCenter;
using MECF.Framework.Common.CommonData.PUF;
using MECF.Framework.Common.DataCenter;
using MECF.Framework.Common.Utilities;
using MECF.Framework.Common.RecipeCenter;
using System.Collections.ObjectModel;
using CyberX8_MainPages.PMs;
using Aitex.Core.Utilities;
using CyberX8_Core;
using System.Windows.Documents;
using System.Windows;
using Aitex.Core.Common;
using Aitex.Core.Util;
using MECF.Framework.Common.WaferHolder;
using OpenSEMI.ClientBase;
using MECF.Framework.Common.Beckhoff.Station;
using CyberX8_MainPages.Unity;
using WaferInfo = OpenSEMI.ClientBase.WaferInfo;
using MECF.Framework.Common.Equipment;
namespace CyberX8_MainPages.ViewModels
{
internal class SRDHomePageViewModel:BindableBase
{
#region 常量
private const string COMMON_DATA = "CommonData";
private const string PERSISTENT_VALUE = "PersistentValue";
private const string WAFER_PRESENCE_STATUS = "WaferPresenceStatus";
private const string SRD = "srd";
private const string WAFER_HOLDER= "WaferHolder";
private const string LOADER_DI_ENABLE = "LoaderDiEnable";
private const string FACILITIES = "Facilities";
private const string MOTION_DATA = "MotionData";
private const double ARM_UI_HOME_POSITION = 25.682;
private const double ARM_UI_CENTER_POSITION = -15;
private const double ROTATION_UI_HOME_POSITION = 0;
#endregion
#region 内部变量
#region SRD
///
/// SRDRecipeContent
///
private string _recipeContent;
///
/// TimeRemaining
///
private double _timeRemaining;
///
/// OfTotalTime
///
private double _totalTime;
///
/// OperatingMode
///
private string _operatingMode;
///
/// State
///
private string _state;
///
/// RecipeMode
///
private string _recipeMode;
///
/// AchievedRunRecipeCycle
///
private int _achievedRunRecipeCycle;
///
/// Loader DI
///
private bool _loaderDiEnable;
#endregion
#region wafer
///
/// WaferID
///
private string _waferID = "";
///
/// SeqRecipe
///
private string _seqRecipe;
///
/// Wafer信息
///
private WaferInfo _waferInfo;
#endregion
#region SRD recipe
///
/// RecipeModuleName
///
private string _recipeModuleName;
///
/// RecipeType
///
private string _recipeType;
///
/// 当前选择Recipe节点
///
private RecipeNode _selectedRecipeNode;
///
/// Recipe节点
///
private ObservableCollection _recipeNodes;
//
/// 当前Recipe
///
private string _currentRecipe;
#endregion
#region Common
///
/// 模块名称
///
private string _module;
///
/// State Machine
///
private string _stateMachine;
///
/// Status
///
private string _status;
///
/// 数据
///
private SrdCommonData _sRDCommonData;
///
/// Threshold
///
private SRDPersistentValue _sRDPersistent;
///
/// WaferPresence
///
private string _waferPresence;
///
/// PresenceTest是否进行中
///
private bool _isPresenceTesting;
///
/// Test Without Wafers
///
private bool _isWaferPresence;
///
/// sRDArm运动数据
///
private CommandMotionData _sRDArmMotionData;
///
/// sRDRotation运动数据
///
private CommandMotionData _sRDRotationMotionData;
///
/// 页面功能启用
///
private bool _isEnabled;
///
/// AutoMode页面功能启用
///
private bool _isAutoEnabled;
#endregion
#region 系统数据
///
/// 定时器
///
DispatcherTimer _timer;
///
/// 查询后台数据集合
///
private List _rtDataKeys = new List();
///
/// rt查询key数值字典
///
private Dictionary _rtDataValueDic = new Dictionary();
///
/// UiRecipeManager
///
private UiRecipeManager _uiRecipeManager = new UiRecipeManager();
#endregion
#region UI related
///
/// SRD Arm UI位置
///
private double _srdArmUIPosition = ARM_UI_HOME_POSITION;
///
/// SRD Rotation UI位置
///
private double _srdRotationUIPosition = ROTATION_UI_HOME_POSITION;
///
/// Arm Axis位置数据
///
private BeckhoffStationAxis _armAxis;
///
/// Arm UI位置比例
///
private double _armUIRatio;
#endregion
#endregion
#region 属性
#region SRD
///
/// SRDRecipeContent
///
public string SRDRecipeContent
{
get { return _recipeContent; }
set { SetProperty(ref _recipeContent, value); }
}
///
/// TimeRemaining
///
public double TimeRemaining
{
get { return _timeRemaining; }
set { SetProperty(ref _timeRemaining, value); }
}
///
/// TotalTime
///
public double TotalTime
{
get { return _totalTime; }
set { SetProperty(ref _totalTime, value); }
}
///
/// OperatingMode
///
public string OperatingMode
{
get { return _operatingMode; }
set { SetProperty(ref _operatingMode, value); }
}
///
/// State
///
public string State
{
get { return _state; }
set { SetProperty(ref _state, value); }
}
///
/// RecipeMode
///
public string RecipeMode
{
get { return _recipeMode; }
set { SetProperty(ref _recipeMode, value); }
}
///
/// Run Recipe已经完成的次数
///
public int AchievedRunRecipeCycle
{
get { return _achievedRunRecipeCycle; }
set { SetProperty(ref _achievedRunRecipeCycle, value); }
}
///
/// Loader DI
///
public bool LoaderDiEnable
{
get { return _loaderDiEnable; }
set { SetProperty(ref _loaderDiEnable, value); }
}
#endregion
#region wafer
///
/// WaferID
///
public string WaferID
{
get { return _waferID; }
set { SetProperty(ref _waferID, value); }
}
///
/// SeqRecipe
///
public string SeqRecipe
{
get { return _seqRecipe; }
set { SetProperty(ref _seqRecipe, value); }
}
///
/// Wafer信息
///
public WaferInfo WaferInfo
{
get { return _waferInfo; }
set { SetProperty(ref _waferInfo, value); }
}
#endregion
#region SRD recipe
///
/// RecipeModuleName
///
public string RecipeModuleName
{
get { return _recipeModuleName; }
set { SetProperty(ref _recipeModuleName, value); }
}
///
/// RecipeType
///
public string RecipeType
{
get { return _recipeType; }
set { SetProperty(ref _recipeType, value); }
}
///
/// 当前运行的Recipe
///
public string CurrentRecipe
{
get { return _currentRecipe; }
set { SetProperty(ref _currentRecipe, value); }
}
#endregion
#region Common
///
/// 模块名称
///
public string Module { get { return _module; } set { SetProperty(ref _module, value); } }
///
/// StateMachine
///
public string StateMachine
{
get { return _stateMachine; }
set { SetProperty(ref _stateMachine, value); }
}
///
/// StateMachine
///
public string Status
{
get { return _status; }
set { SetProperty(ref _status, value); }
}
///
/// Commondata
///
public SrdCommonData SRDCommonData
{
get { return _sRDCommonData; }
set { SetProperty(ref _sRDCommonData, value); }
}
///
/// WaferPresence
///
public string WaferPresence
{
get { return _waferPresence; }
set { SetProperty(ref _waferPresence, value); }
}
///
/// Threshold
///
public SRDPersistentValue SRDPersistent
{
get { return _sRDPersistent; }
set { SetProperty(ref _sRDPersistent, value); }
}
///
/// Selected Recipe Node
///
public RecipeNode SelectedRecipeNode
{
get { return _selectedRecipeNode; }
set { SetProperty(ref _selectedRecipeNode, value); }
}
///
/// PresenceTest是否进行中
///
public bool IsPresenceTesting
{
get { return _isPresenceTesting; }
set { SetProperty(ref _isPresenceTesting, value); }
}
///
/// Test Without Wafers
///
public bool IsWaferPresence
{
get { return _isWaferPresence; }
set { SetProperty(ref _isWaferPresence, value); }
}
///
/// SRDArm运动数据
///
public CommandMotionData SRDArmMotionData
{
get { return _sRDArmMotionData; }
set { SetProperty(ref _sRDArmMotionData, value); }
}
///
/// SRDRotation运动数据
///
public CommandMotionData SRDRotationMotionData
{
get { return _sRDRotationMotionData; }
set { SetProperty(ref _sRDRotationMotionData, value); }
}
///
/// 页面功能启用
///
public bool IsEnabled
{
get { return _isEnabled; }
set { SetProperty(ref _isEnabled, value); }
}
///
/// AutoMode页面功能启用
///
public bool IsAutoEnabled
{
get { return _isAutoEnabled; }
set { SetProperty(ref _isAutoEnabled, value); }
}
#endregion
#region UI related
///
/// SRD ARM UI位置
///
public double SRDArmUIPosition
{
get { return _srdArmUIPosition; }
set { SetProperty(ref _srdArmUIPosition, value); }
}
///
/// SRD Rotation UI位置
///
public double SRDRotationUIPosition
{
get { return _srdRotationUIPosition; }
set { SetProperty(ref _srdRotationUIPosition, value); }
}
#endregion
#endregion
#region Command指令
///
/// Initialize Command
///
public ICommand InitializeCommand { get; set; }
///
/// SwitchOn Command
///
public ICommand SwitchOnCommand { get; set; }
///
/// SwitchOff Command
///
public ICommand SwitchOffCommand { get; set; }
#endregion
///
/// 构造函数
///
public SRDHomePageViewModel()
{
InitializeCommand = new DelegateCommand