123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410 |
- using Aitex.Core.UI.MVVM;
- using Aitex.Core.Util;
- using MECF.Framework.Common.CommonData;
- using MECF.Framework.Common.Jobs;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Runtime.Serialization;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Input;
- using FurnaceUI.Models;
- using MECF.Framework.Common.OperationCenter;
- using OpenSEMI.ClientBase;
- namespace FurnaceUI.Views.Status
- {
- class ControlJobStatusViewModel : FurnaceUIViewModelBase
- {
- public bool IsPermission { get => this.Permission == 3; }
- public class ControlJobData : NotifiableItem
- {
- [DataMember]
- public int Num { get; set; }
- [DataMember]
- public string Name { get; set; }
- [DataMember]
- public string State { get; set; }
- [DataMember]
- public bool Auto { get; set; }
- }
- public ObservableCollection<ControlJobData> ControlJobsData { get; set; }
- [Subscription("Rt.Status")]
- public string RtStatus { get; set; }
- public ICommand ControlJobsCommand { get; set; }
- [Subscription("Scheduler.ControlJobList")]
- public List<ControlJobInfo> ControlJobs
- {
- get;
- set;
- }
- [Subscription("Scheduler.CurrentProcessJob")]
- public ProcessJobInfo CurrentProcessJob
- {
- get;
- set;
- }
- public ControlJobStatusViewModel()/* : base("MonitorJobViewModel")*/
- {
- ControlJobsData = new ObservableCollection<ControlJobData>();
- }
- public ControlJobData SelectedControlJob { get; set; }
- public string SelectedControlJobsObjtID
- {
- get
- {
- return SelectedControlJob != null ? SelectedControlJob.Name : "";
- }
- }
- public string SelectedControlJobsState
- {
- get
- {
- if (SelectedControlJob == null)
- {
- return " ";
- }
- return SelectedControlJob.State.ToString();
- }
- }
- public bool IsEnablePause
- {
- get
- {
- if (SelectedControlJob == null)
- return false;
- return SelectedControlJob.State.ToString() == "Executing";
- }
- }
- public bool IsEnableCoolingSkip
- {
- get
- {
- if (CurrentProcessJob == null)
- return false;
- return CurrentProcessJob.ProcessingState.ToString() == "CoolingBeforeDischarge";
- }
- }
- public bool IsEnableResume
- {
- get
- {
- if (SelectedControlJob == null)
- return false;
- return SelectedControlJob.State.ToString() == "Paused";
- }
- }
- public int AllInitializeCount { get; set; }
- private bool _AllInitializeEnable = true;
- public bool AllInitializeEnable
- {
- get => _AllInitializeEnable;
- set
- {
- _AllInitializeEnable = value;
- NotifyOfPropertyChange("AllInitializeEnable");
- }
- }
- public bool IsEnableInitialize
- {
- get { return (RtStatus == "Init" || RtStatus == "Idle") && AllInitializeEnable; }
- }
- public bool IsEnableStop
- {
- get
- {
- if (SelectedControlJob == null)
- return false;
- return SelectedControlJob.State.ToString() == "Executing" ||
- SelectedControlJob.State.ToString() == "Paused" ||
- SelectedControlJob.State.ToString() == "WaitingForStart" ||
- SelectedControlJob.State.ToString() == "Queued";
- }
- }
- public string CurrentStartMode
- {
- get
- {
- if (SelectedControlJob == null)
- {
- return "Waiting For Start";
- }
- return ((SelectedControlJob.State.ToString() == "Queued") || (SelectedControlJob.State.ToString() == "Completed")) ? "Waiting For Start" : "Active";
- }
- }
- public string CurrentStateIsActive
- {
- get
- {
- if (SelectedControlJob == null)
- {
- return "Transparent";
- }
- return ((SelectedControlJob.State.ToString() == "Queued") || (SelectedControlJob.State.ToString() == "Completed")) ? "Transparent" : "Green";
- }
- }
- public string CurrentStateIsActiveForeground
- {
- get
- {
- if (CurrentStateIsActive == "Green")
- {
- return "White";
- }
- return "Black";
- }
- }
- public string CurrentStateIsQueued
- {
- get
- {
- if (SelectedControlJob == null)
- {
- return "Transparent";
- }
- return SelectedControlJob.State.ToString() == "Queued" ? "Green" : "Transparent";
- }
- }
- public string CurrentStateIsSelected
- {
- get
- {
- if (SelectedControlJob == null)
- {
- return "Transparent";
- }
- return SelectedControlJob.State.ToString() == "Selected" ? "Green" : "Transparent";
- }
- }
- public string CurrentStateIsWaitingForStart
- {
- get
- {
- if (SelectedControlJob == null)
- {
- return "Transparent";
- }
- return SelectedControlJob.State.ToString() == "WaitingForStart" ? "Green" : "Transparent";
- }
- }
- public string CurrentStateIsExecuting
- {
- get
- {
- if (SelectedControlJob == null)
- {
- return "Transparent";
- }
- return SelectedControlJob.State.ToString() == "Executing" ? "Green" : "Transparent";
- }
- }
- public string CurrentStateIsPaused
- {
- get
- {
- if (SelectedControlJob == null)
- {
- return "Transparent";
- }
- return SelectedControlJob.State.ToString() == "Paused" ? "Green" : "Transparent";
- }
- }
- public string CurrentStateIsCompleted
- {
- get
- {
- if (SelectedControlJob == null)
- {
- return "Transparent";
- }
- return SelectedControlJob.State.ToString() == "Completed" ? "Green" : "Transparent";
- }
- }
- [Subscription("ProcessFlow.Status")]
- public string ProcessFlowStatus { get; set; }
- public void BtnClick(string cmd)
- {
- switch (cmd)
- {
- case "HomeAll":
- InvokeClient.Instance.Service.DoOperation("System.HomeAll");
- break;
- case "ABORT":
- InvokeClient.Instance.Service.DoOperation("PM1.RecipeAbort");
- break;
- case "RESET":
- InvokeClient.Instance.Service.DoOperation("System.Reset");
- break;
- case "IDLE":
- InvokeClient.Instance.Service.DoOperation("PM1.RecipeIdle");
- break;
- default:
- break;
- }
- }
- public void Manual(string module)
- {
- switch (module)
- {
- case "All Initialize":
- AllInitializeCount++;
- if (AllInitializeCount % 2 == 0)
- AllInitializeEnable = false;
- else
- AllInitializeEnable = true;
- break;
- default:
- break;
- }
- }
- protected override void InvokeAfterUpdateProperty(Dictionary<string, object> data)
- {
- base.InvokeAfterUpdateProperty(data);
- if (ControlJobs == null || ControlJobs.Count == 0)
- {
- ControlJobsData.Clear();
- }
- else
- {
- int _Numcount = 1;
- foreach (var item in ControlJobs)
- {
- var match = ControlJobsData.ToList().Find(x => x.Name == item.Name);
- if (match == null)
- {
- ControlJobData cj = new ControlJobData();
- cj.Name = item.Name;
- cj.State = item.State.ToString();
- cj.Num = _Numcount;
- _Numcount++;
- ControlJobsData.Add(cj);
- }
- else
- {
- match.State = item.State.ToString();
- match.InvokePropertyChanged();
- }
- }
- List<ControlJobData> tobeRemove = new List<ControlJobData>();
- foreach (var cj in ControlJobsData)
- {
- if (ControlJobs.FirstOrDefault(x => x.Name == cj.Name) == null)
- tobeRemove.Add(cj);
- }
- foreach (var cj in tobeRemove)
- {
- ControlJobsData.Remove(cj);
- }
- _Numcount = 1;
- foreach (var item in ControlJobsData)
- {
- item.Num = _Numcount;
- _Numcount++;
- }
- }
- }
- public void ClosedCmd()
- {
- (GetView() as Window).Close();
- }
- public void CoolingSkip()
- {
- if (!DialogBox.Confirm("Are you sure to cooling skip"))
- {
- return;
- }
- InvokeClient.Instance.Service.DoOperation("System.CoolingSkip");
- }
- public void AbortJob()
- {
- if (string.IsNullOrEmpty(SelectedControlJobsObjtID))
- {
- DialogBox.ShowWarning("Control job is not selected");
- return;
- }
- if (!DialogBox.Confirm("Are you sure to abort the control job"))
- {
- return;
- }
- var param = new object[] { SelectedControlJobsObjtID };
- InvokeClient.Instance.Service.DoOperation("System.AbortJob", param);
- }
- public void Start()
- {
- if (string.IsNullOrEmpty(SelectedControlJobsObjtID))
- {
- DialogBox.ShowWarning("Control job is not selected");
- return;
- }
- var param = new object[] { SelectedControlJobsObjtID };
- InvokeClient.Instance.Service.DoOperation("System.StartJob", param);
- }
- public void Pause()
- {
- if (string.IsNullOrEmpty(SelectedControlJobsObjtID))
- {
- DialogBox.ShowWarning("Control job is not selected");
- return;
- }
- var param = new object[] { SelectedControlJobsObjtID };
- InvokeClient.Instance.Service.DoOperation("System.PauseJob", param);
- }
- public void Resume()
- {
- if (string.IsNullOrEmpty(SelectedControlJobsObjtID))
- {
- DialogBox.ShowWarning("Control job is not selected");
- return;
- }
- var param = new object[] { SelectedControlJobsObjtID };
- InvokeClient.Instance.Service.DoOperation("System.ResumeJob", param);
- }
- public void Stop()
- {
- if (string.IsNullOrEmpty(SelectedControlJobsObjtID))
- {
- DialogBox.ShowWarning("Control job is not selected");
- return;
- }
- var param = new object[] { SelectedControlJobsObjtID };
- InvokeClient.Instance.Service.DoOperation("System.StopJob", param);
- }
- }
- }
|