using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Media; using Aitex.Core.Util; using MECF.Framework.Common.OperationCenter; using OpenSEMI.ClientBase; using FurnaceUI.Models; namespace FurnaceUI.Views.Jobs { public class JOBStatusViewModel : FurnaceUIViewModelBase { [Subscription("Rt.Status")] public string RtStatus { get; set; } [Subscription("System.Pause")] public bool IsPause { get; set; } [Subscription("System.Batch")] public string Batch { get; set; } [Subscription("System.JobName")] public string JobName { get; set; } [Subscription("System.RecipeName")] public string RecipeName { get; set; } [Subscription("System.ProcessJobStatus")] public string ProcessJobStatus { get; set; } private SolidColorBrush _whiteBk = new SolidColorBrush(Colors.White); private SolidColorBrush _greenBk = new SolidColorBrush(Colors.Green); #region TransferJob [Subscription("System.TransferJobStatus")] public string TransferJobStatus { get; set; } public SolidColorBrush LoadingBk { get { return TransferJobStatus == "Loading" ? _greenBk : _whiteBk; } } public SolidColorBrush UnloadingBk { get { return TransferJobStatus == "Unloading" ? _greenBk : _whiteBk; } } public bool TransferJobEnabledAbort { get { return TransferJobStatus != "Idle"; } } #endregion #region ProcessJob1 public SolidColorBrush ProcessJob1ChargingBk { get { return (ProcessJobStatus == "Charging" && Batch == "A") ? _greenBk : _whiteBk; } } public SolidColorBrush ProcessJob1ProcessingBk { get { return (ProcessJobStatus == "Processing" && Batch == "A") ? _greenBk : _whiteBk; } } public SolidColorBrush ProcessJob1CoolingBk { get { return (ProcessJobStatus == "Cooling" && Batch == "A") ? _greenBk : _whiteBk; } } public SolidColorBrush ProcessJob1DischargingBk { get { return (ProcessJobStatus == "Discharging" && Batch == "A") ? _greenBk : _whiteBk; } } public bool IsProcessJob1EnabledPause { get { return IsJobStatusEnable && Batch == "A" && !IsPause; } } public bool IsProcessJob1EnabledResume { get { return IsJobStatusEnable && Batch == "A" && IsPause; } } public bool IsProcessJob1EnabledAbort { get { return IsJobStatusEnable && Batch == "A"; } } public bool IsProcessJob1EnabledWithdraw { get { return RtStatus == "Idle"; } } public string Process1JobName { get { return Batch == "A" ? JobName : ""; } } public string Process1RcpName { get { return Batch == "A" ? RecipeName : ""; } } public string Process1BatchName { get { return Batch == "A" ? "A Batch" : ""; } } #endregion #region ProcessJob2 public SolidColorBrush ProcessJob2ChargingBk { get { return (ProcessJobStatus == "Charging" && Batch == "B") ? _greenBk : _whiteBk; } } public SolidColorBrush ProcessJob2ProcessingBk { get { return (ProcessJobStatus == "Processing" && Batch == "B") ? _greenBk : _whiteBk; } } public SolidColorBrush ProcessJob2CoolingBk { get { return (ProcessJobStatus == "Cooling" && Batch == "B") ? _greenBk : _whiteBk; } } public SolidColorBrush ProcessJob2DischargingBk { get { return (ProcessJobStatus == "Discharging" && Batch == "B") ? _greenBk : _whiteBk; } } public bool IsProcessJob2EnabledPause { get { return IsJobStatusEnable && Batch == "B" && !IsPause; } } public bool IsProcessJob2EnabledResume { get { return IsJobStatusEnable && Batch == "B" && IsPause; } } public bool IsProcessJob2EnabledAbort { get { return IsJobStatusEnable && Batch == "B"; } } public bool IsProcessJob2EnabledWithdraw { get { return RtStatus == "Idle"; } } public string Process2JobName { get { return Batch == "B" ? JobName : ""; } } public string Process2RcpName { get { return Batch == "B" ? RecipeName : ""; } } public string Process2BatchName { get { return Batch == "B" ? "B Batch" : ""; } } #endregion #region UI Logic public bool IsJobStatusEnable => RtStatus == "ChargeProcessDischarging" || RtStatus == "LoadProcessStockering" || RtStatus == "LoadProcessUnloading"; #endregion public void Pause() { InvokeClient.Instance.Service.DoOperation("System.Pause"); } public void Resume() { InvokeClient.Instance.Service.DoOperation("System.Resume"); } public void Abort() { if (!DialogBox.Confirm("Do you abort JOB ?")) return; InvokeClient.Instance.Service.DoOperation("System.Abort"); } public void Withdraw() { InvokeClient.Instance.Service.DoOperation("System.ReturnAllWafer"); } public void CloseCmd() { ((Window)GetView()).DialogResult = false; } } }