using Aitex.Core.Util; using MECF.Framework.Common.OperationCenter; using MECF.Framework.UI.Client.ClientBase; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Windows; using FurnaceUI.Models; using FurnaceUI.Views.Recipes; namespace FurnaceUI.Views.Operations { public class WaferRobotWaferViewModel : FurnaceUIViewModelBase { private ObservableCollection _waferRobotWafers; public ObservableCollection WaferRobotWafers { get { return _waferRobotWafers; } set { _waferRobotWafers = value; NotifyOfPropertyChange("WaferRobotWafers"); } } private PeriodicJob RefreshBoatWafers; public WaferRobotWaferViewModel() { WaferRobotWafers = new ObservableCollection(); for (int i = 0; i < 5; i++) { BoatWaferItem item = new BoatWaferItem() { Slot = i + 1, Description = "" }; WaferRobotWafers.Add(item); } RefreshBoatWafers = new PeriodicJob(300, RefreshBoatWafersTask, "RefreshAlarmTask", true); } protected override void OnInitialize() { base.OnInitialize(); } protected override void OnActivate() { base.OnActivate(); } protected override void InvokeAfterUpdateProperty(Dictionary data) { base.InvokeAfterUpdateProperty(data); } private bool RefreshBoatWafersTask() { var wafers = ModuleManager.ModuleInfos["WaferRobot"].WaferManager.Wafers.ToList(); for (int i = 0; i < WaferRobotWafers.Count; i++) { if (ModuleManager.ModuleInfos["WaferRobot"].WaferManager.Wafers.Count > i) { var wafer = wafers[i]; if (wafer.WaferStatus == 0)//empty { WaferRobotWafers[i].Description = $""; WaferRobotWafers[i].HasWafer = false; WaferRobotWafers[i].NoWafer = true; } else { WaferRobotWafers[i].Description = $"{wafer.SourceName}--{wafer.WaferType }"; WaferRobotWafers[i].HasWafer = true; WaferRobotWafers[i].NoWafer = false; } } } return true; } public void CreateWafer(BoatWaferItem item) { InvokeClient.Instance.Service.DoOperation("CreateWafer", "WaferRobot", item.Slot - 1); } public void DeleteWafer(BoatWaferItem item) { InvokeClient.Instance.Service.DoOperation("DeleteWafer", "WaferRobot", item.Slot - 1); } public void CloseCmd() { ((Window)GetView()).Close(); } } }