JelAlignerView.xaml.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Navigation;
  15. using System.Windows.Shapes;
  16. using Aitex.Core.UI.MVVM;
  17. using Aitex.Core.Utilities;
  18. using MECF.Framework.Simulator.Core.Commons;
  19. using MECF.Framework.Simulator.Core.Driver;
  20. using MECF.Framework.Simulator.Core.LoadPorts;
  21. using MECF.Framework.Simulator.Core.LoadPorts.Hirata;
  22. using MECF.Framework.Simulator.Core.Robots;
  23. namespace MECF.Framework.Simulator.Core.LoadPorts
  24. {
  25. //public class WaferItem
  26. //{
  27. // public int index { get; set; }
  28. // public string Display { get; set; }
  29. // public int State { get; set; }
  30. //}
  31. /// <summary>
  32. /// TDKLoadPort.xaml 的交互逻辑
  33. /// </summary>
  34. public partial class JelAlignerView : UserControl
  35. {
  36. public static readonly DependencyProperty PortNameProperty = DependencyProperty.Register(
  37. "PortName", typeof(string), typeof(JelAlignerView),
  38. new FrameworkPropertyMetadata("COM30", FrameworkPropertyMetadataOptions.AffectsRender));
  39. public string PortName
  40. {
  41. get
  42. {
  43. return (string)this.GetValue(PortNameProperty);
  44. }
  45. set
  46. {
  47. this.SetValue(PortNameProperty, value);
  48. }
  49. }
  50. public static readonly DependencyProperty PortNumberProperty = DependencyProperty.Register(
  51. "PortNumber", typeof(int), typeof(JelAlignerView),
  52. new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.AffectsRender));
  53. public int PortNumber
  54. {
  55. get
  56. {
  57. return (int)this.GetValue(PortNumberProperty);
  58. }
  59. set
  60. {
  61. this.SetValue(PortNumberProperty, value);
  62. }
  63. }
  64. public JelAlignerView()
  65. {
  66. InitializeComponent();
  67. this.Loaded += OnViewLoaded;
  68. }
  69. private void OnViewLoaded(object sender, RoutedEventArgs e)
  70. {
  71. if (DataContext == null)
  72. {
  73. DataContext = new JelAlignerViewModel(PortName, PortNumber);
  74. (DataContext as TimerViewModelBase).Start();
  75. }
  76. }
  77. }
  78. class JelAlignerViewModel : SerialPortDeviceViewModel
  79. {
  80. public string Title
  81. {
  82. get { return "JEL Aligner Simulator"; }
  83. }
  84. public string WaferMap
  85. {
  86. get { return _sim.SlotMap; }
  87. }
  88. public string InfoPadStatus
  89. {
  90. get { return _sim.InforPadState; }
  91. }
  92. [IgnorePropertyChange]
  93. public string InfoPadSet { get; set; }
  94. public ObservableCollection<WaferItem> WaferList { get; set; }
  95. public ICommand PlaceCommand { get; set; }
  96. public ICommand RemoveCommand { get; set; }
  97. public ICommand ClearCommand { get; set; }
  98. public ICommand SetAllCommand { get; set; }
  99. public ICommand RandomCommand { get; set; }
  100. public ICommand SetInfoPadCommand { get; set; }
  101. private JelAlignerSimulator _sim;
  102. public JelAlignerViewModel(string port, int index) : base("JelAlignerViewModel")
  103. {
  104. PlaceCommand = new DelegateCommand<string>(Place);
  105. RemoveCommand = new DelegateCommand<string>(Remove);
  106. ClearCommand = new DelegateCommand<string>(Clear);
  107. SetAllCommand = new DelegateCommand<string>(SetAll);
  108. RandomCommand = new DelegateCommand<string>(RandomGenerateWafer);
  109. SetInfoPadCommand = new DelegateCommand<string>(SetInfoPadStatus);
  110. _sim = new JelAlignerSimulator(port);
  111. Init(_sim);
  112. WaferList = new ObservableCollection<WaferItem>()
  113. {
  114. new WaferItem {Display = "1", Index = 2, State = 3}
  115. };
  116. if (index == 1)
  117. _sim.SetUpWafer();
  118. else
  119. {
  120. _sim.SetLowWafer();
  121. }
  122. }
  123. private void SetInfoPadStatus(string obj)
  124. {
  125. _sim.InforPadState = InfoPadSet;
  126. }
  127. private void RandomGenerateWafer(string obj)
  128. {
  129. _sim.RandomWafer();
  130. }
  131. private void SetAll(string obj)
  132. {
  133. _sim.SetAllWafer();
  134. }
  135. private void Clear(string obj)
  136. {
  137. _sim.ClearWafer();
  138. }
  139. private void Remove(string obj)
  140. {
  141. _sim.RemoveCarrier();
  142. }
  143. private void Place(string obj)
  144. {
  145. _sim.PlaceCarrier();
  146. }
  147. }
  148. }