TazmoAlignerView.xaml.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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.Robots;
  21. namespace MECF.Framework.Simulator.Core.LoadPorts
  22. {
  23. //public class WaferItem
  24. //{
  25. // public int index { get; set; }
  26. // public string Display { get; set; }
  27. // public int State { get; set; }
  28. //}
  29. /// <summary>
  30. /// TazmoAligner.xaml 的交互逻辑
  31. /// </summary>
  32. public partial class TazmoAlignerView : UserControl
  33. {
  34. public static readonly DependencyProperty PortNameProperty = DependencyProperty.Register(
  35. "PortName", typeof(string), typeof(TazmoAlignerView),
  36. new FrameworkPropertyMetadata("COM10", FrameworkPropertyMetadataOptions.AffectsRender));
  37. public string PortName
  38. {
  39. get
  40. {
  41. return (string)this.GetValue(PortNameProperty);
  42. }
  43. set
  44. {
  45. this.SetValue(PortNameProperty, value);
  46. }
  47. }
  48. public static readonly DependencyProperty PortNumberProperty = DependencyProperty.Register(
  49. "PortNumber", typeof(int), typeof(TazmoAlignerView),
  50. new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.AffectsRender));
  51. public int PortNumber
  52. {
  53. get
  54. {
  55. return (int)this.GetValue(PortNumberProperty);
  56. }
  57. set
  58. {
  59. this.SetValue(PortNumberProperty, value);
  60. }
  61. }
  62. public TazmoAlignerView()
  63. {
  64. InitializeComponent();
  65. this.Loaded += OnViewLoaded;
  66. }
  67. private void OnViewLoaded(object sender, RoutedEventArgs e)
  68. {
  69. if (DataContext == null)
  70. {
  71. DataContext = new TazmoAlignerViewModel(PortName, PortNumber);
  72. (DataContext as TimerViewModelBase).Start();
  73. }
  74. }
  75. }
  76. class TazmoAlignerViewModel : SerialPortDeviceViewModel
  77. {
  78. public string Title
  79. {
  80. get { return "Tazmo Aligner Simulator"; }
  81. }
  82. public string WaferMap
  83. {
  84. get { return _sim.SlotMap; }
  85. }
  86. public string InfoPadStatus
  87. {
  88. get { return _sim.InforPadState; }
  89. }
  90. [IgnorePropertyChange]
  91. public string InfoPadSet { get; set; }
  92. public ObservableCollection<WaferItem> WaferList { get; set; }
  93. public ICommand PlaceCommand { get; set; }
  94. public ICommand RemoveCommand { get; set; }
  95. public ICommand ClearCommand { get; set; }
  96. public ICommand SetAllCommand { get; set; }
  97. public ICommand RandomCommand { get; set; }
  98. public ICommand SetInfoPadCommand { get; set; }
  99. private TazmoAlignerSimulator _sim;
  100. public TazmoAlignerViewModel(string port, int index) : base("TazmoAlignerViewModel")
  101. {
  102. PlaceCommand = new DelegateCommand<string>(Place);
  103. RemoveCommand = new DelegateCommand<string>(Remove);
  104. ClearCommand = new DelegateCommand<string>(Clear);
  105. SetAllCommand = new DelegateCommand<string>(SetAll);
  106. RandomCommand = new DelegateCommand<string>(RandomGenerateWafer);
  107. SetInfoPadCommand = new DelegateCommand<string>(SetInfoPadStatus);
  108. _sim = new TazmoAlignerSimulator(port);
  109. Init(_sim);
  110. WaferList = new ObservableCollection<WaferItem>()
  111. {
  112. new WaferItem {Display = "1", Index = 2, State = 3}
  113. };
  114. if (index == 1)
  115. _sim.SetUpWafer();
  116. else
  117. {
  118. _sim.SetLowWafer();
  119. }
  120. }
  121. private void SetInfoPadStatus(string obj)
  122. {
  123. _sim.InforPadState = InfoPadSet;
  124. }
  125. private void RandomGenerateWafer(string obj)
  126. {
  127. _sim.RandomWafer();
  128. }
  129. private void SetAll(string obj)
  130. {
  131. _sim.SetAllWafer();
  132. }
  133. private void Clear(string obj)
  134. {
  135. _sim.ClearWafer();
  136. }
  137. private void Remove(string obj)
  138. {
  139. _sim.RemoveCarrier();
  140. }
  141. private void Place(string obj)
  142. {
  143. _sim.PlaceCarrier();
  144. }
  145. }
  146. }