Dage4300View.xaml.cs 4.6 KB

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