WaferRobotWaferViewModel.cs 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. using Aitex.Core.Util;
  2. using MECF.Framework.Common.OperationCenter;
  3. using MECF.Framework.UI.Client.ClientBase;
  4. using System.Collections.Generic;
  5. using System.Collections.ObjectModel;
  6. using System.Linq;
  7. using System.Windows;
  8. using FurnaceUI.Models;
  9. using FurnaceUI.Views.Recipes;
  10. namespace FurnaceUI.Views.Operations
  11. {
  12. public class WaferRobotWaferViewModel : FurnaceUIViewModelBase
  13. {
  14. private ObservableCollection<BoatWaferItem> _waferRobotWafers;
  15. public ObservableCollection<BoatWaferItem> WaferRobotWafers
  16. {
  17. get { return _waferRobotWafers; }
  18. set
  19. {
  20. _waferRobotWafers = value;
  21. NotifyOfPropertyChange("WaferRobotWafers");
  22. }
  23. }
  24. private PeriodicJob RefreshBoatWafers;
  25. public WaferRobotWaferViewModel()
  26. {
  27. WaferRobotWafers = new ObservableCollection<BoatWaferItem>();
  28. for (int i = 0; i < 5; i++)
  29. {
  30. BoatWaferItem item = new BoatWaferItem() { Slot = i + 1, Description = "" };
  31. WaferRobotWafers.Add(item);
  32. }
  33. RefreshBoatWafers = new PeriodicJob(300, RefreshBoatWafersTask, "RefreshAlarmTask", true);
  34. }
  35. protected override void OnInitialize()
  36. {
  37. base.OnInitialize();
  38. }
  39. protected override void OnActivate()
  40. {
  41. base.OnActivate();
  42. }
  43. protected override void InvokeAfterUpdateProperty(Dictionary<string, object> data)
  44. {
  45. base.InvokeAfterUpdateProperty(data);
  46. }
  47. private bool RefreshBoatWafersTask()
  48. {
  49. var wafers = ModuleManager.ModuleInfos["WaferRobot"].WaferManager.Wafers.ToList();
  50. for (int i = 0; i < WaferRobotWafers.Count; i++)
  51. {
  52. if (ModuleManager.ModuleInfos["WaferRobot"].WaferManager.Wafers.Count > i)
  53. {
  54. var wafer = wafers[i];
  55. if (wafer.WaferStatus == 0)//empty
  56. {
  57. WaferRobotWafers[i].Description = $"";
  58. WaferRobotWafers[i].HasWafer = false;
  59. WaferRobotWafers[i].NoWafer = true;
  60. }
  61. else
  62. {
  63. WaferRobotWafers[i].Description = $"{wafer.SourceName}--{wafer.WaferType }";
  64. WaferRobotWafers[i].HasWafer = true;
  65. WaferRobotWafers[i].NoWafer = false;
  66. }
  67. }
  68. }
  69. return true;
  70. }
  71. public void CreateWafer(BoatWaferItem item)
  72. {
  73. InvokeClient.Instance.Service.DoOperation("CreateWafer", "WaferRobot", item.Slot - 1);
  74. }
  75. public void DeleteWafer(BoatWaferItem item)
  76. {
  77. InvokeClient.Instance.Service.DoOperation("DeleteWafer", "WaferRobot", item.Slot - 1);
  78. }
  79. public void CloseCmd()
  80. {
  81. ((Window)GetView()).Close();
  82. }
  83. }
  84. }