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