WagoView.xaml.cs 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. using Aitex.Core.UI.MVVM;
  2. using Aitex.Core.Utilities;
  3. using CyberX8_Simulator.Devices;
  4. using MECF.Framework.Simulator.Core.Commons;
  5. using MECF.Framework.Simulator.Core.Driver;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Collections.ObjectModel;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using System.Windows;
  13. using System.Windows.Controls;
  14. using System.Windows.Data;
  15. using System.Windows.Documents;
  16. using System.Windows.Input;
  17. using System.Windows.Media;
  18. using System.Windows.Media.Imaging;
  19. using System.Windows.Navigation;
  20. using System.Windows.Shapes;
  21. namespace CyberX8_Simulator.Views
  22. {
  23. /// <summary>
  24. /// WagoView.xaml 的交互逻辑
  25. /// </summary>
  26. public partial class WagoView : UserControl
  27. {
  28. public WagoView()
  29. {
  30. InitializeComponent();
  31. this.Loaded += OnViewLoaded;
  32. }
  33. private void OnViewLoaded(object sender, RoutedEventArgs e)
  34. {
  35. (DataContext as TimerViewModelBase)?.Start();
  36. }
  37. }
  38. class WagoViewModel : SocketDeviceViewModel
  39. {
  40. #region 属性
  41. public string Title
  42. {
  43. get { return "Wago Simulator"; }
  44. }
  45. private string _DOSelectedItem;
  46. [IgnorePropertyChange]
  47. public string DOSelectedItem
  48. {
  49. get
  50. {
  51. return _DOSelectedItem;
  52. }
  53. set
  54. {
  55. _DOSelectedItem = value;
  56. }
  57. }
  58. private int _DOInputValue;
  59. [IgnorePropertyChange]
  60. public int DOInputValue
  61. {
  62. get
  63. {
  64. return _DOInputValue;
  65. }
  66. set
  67. {
  68. _DOInputValue = value;
  69. }
  70. }
  71. private string _DISelectedItem;
  72. [IgnorePropertyChange]
  73. public string DISelectedItem
  74. {
  75. get
  76. {
  77. return _DISelectedItem;
  78. }
  79. set
  80. {
  81. _DISelectedItem = value;
  82. }
  83. }
  84. private int _DIInputValue;
  85. [IgnorePropertyChange]
  86. public int DIInputValue
  87. {
  88. get
  89. {
  90. return _DIInputValue;
  91. }
  92. set
  93. {
  94. _DIInputValue = value;
  95. }
  96. }
  97. private string _AOSelectedItem;
  98. [IgnorePropertyChange]
  99. public string AOSelectedItem
  100. {
  101. get
  102. {
  103. return _AOSelectedItem;
  104. }
  105. set
  106. {
  107. _AOSelectedItem = value;
  108. }
  109. }
  110. private short _AOInputValue;
  111. [IgnorePropertyChange]
  112. public short AOInputValue
  113. {
  114. get
  115. {
  116. return _AOInputValue;
  117. }
  118. set
  119. {
  120. _AOInputValue = value;
  121. }
  122. }
  123. private string _AISelectedItem;
  124. [IgnorePropertyChange]
  125. public string AISelectedItem
  126. {
  127. get
  128. {
  129. return _AISelectedItem;
  130. }
  131. set
  132. {
  133. _AISelectedItem = value;
  134. }
  135. }
  136. private short _AIInputValue;
  137. [IgnorePropertyChange]
  138. public short AIInputValue
  139. {
  140. get
  141. {
  142. return _AIInputValue;
  143. }
  144. set
  145. {
  146. _AIInputValue = value;
  147. }
  148. }
  149. #endregion
  150. public ObservableCollection<string> DONameItems { get; set; }
  151. public ObservableCollection<string> DINameItems { get; set; }
  152. public ObservableCollection<string> AONameItems { get; set; }
  153. public ObservableCollection<string> AINameItems { get; set; }
  154. public ObservableCollection<int> DigitalInputSelected { get; set; }
  155. private WagoSocketSimulator _sim;
  156. public ICommand SetDICommand { get; set; }
  157. public ICommand SetDOCommand { get; set; }
  158. public ICommand SetAICommand { get; set; }
  159. public ICommand SetAOCommand { get; set; }
  160. public WagoViewModel(string str) : base("WagoViewModel")
  161. {
  162. SetDICommand = new DelegateCommand<object>(SetDIAction);
  163. SetDOCommand = new DelegateCommand<object>(SetDOAction);
  164. SetAICommand = new DelegateCommand<object>(SetAIAction);
  165. SetAOCommand = new DelegateCommand<object>(SetAOAction);
  166. int.TryParse(str, out int port);
  167. _sim = new WagoSocketSimulator(port);
  168. Init(_sim);
  169. InitData(port);
  170. }
  171. private void SetDIAction(object obj)
  172. {
  173. _sim.UpdataDIBytes(DISelectedItem, DIInputValue);
  174. }
  175. private void SetDOAction(object obj)
  176. {
  177. _sim.UpdataDOBytes(DOSelectedItem, DOInputValue);
  178. }
  179. private void SetAIAction(object obj)
  180. {
  181. _sim.UpdataAIShorts(AISelectedItem, AIInputValue);
  182. }
  183. private void SetAOAction(object obj)
  184. {
  185. _sim.UpdataAOShorts(AOSelectedItem, AOInputValue);
  186. }
  187. private void InitData(int port)
  188. {
  189. DigitalInputSelected = new ObservableCollection<int> { 0, 1 };
  190. DONameItems = new ObservableCollection<string>
  191. { "c_System_Alarm",
  192. "c_Pole_Red",
  193. "c_Pole_Amber",
  194. "c_Pole_Green",
  195. "c_Pole_Blue",
  196. "c_System_Alarm2",
  197. "c_BACKSIDE_PRESSURE_TEST",
  198. "c_VACUUM_TEST",
  199. "DO8",
  200. "DO9",
  201. "DO10",
  202. "DO11",
  203. "DO12",
  204. "DO13",
  205. "DO14",
  206. "DO15",
  207. "DO16",
  208. "DO17",
  209. "DO18",
  210. "DO19",
  211. "DO20",
  212. "DO21"};
  213. DINameItems = new ObservableCollection<string>
  214. { "r_Cassette_1_150",
  215. "r_Cassette_1_100",
  216. "r_Cassette_1_200",
  217. "r_Cassette_2_150",
  218. "r_Cassette_2_100",
  219. "r_Cassette_2_200",
  220. "r_Cassette_3_150",
  221. "r_Cassette_3_100",
  222. "r_Cassette_3_200",
  223. "r_Dummy_1_150",
  224. "r_Dummy_1_100",
  225. "r_Dummy_1_200",
  226. "r_Dummy_2_150",
  227. "r_Dummy_2_100",
  228. "r_Dummy_2_100",
  229. "D15",
  230. "r_LoaderA_Wafer_Present",
  231. "r_LoaderB_Wafer_Present",
  232. "r_Cathode_Present",
  233. "DI19",
  234. "DI20",
  235. "DI21",
  236. "DI22",
  237. "DI23",
  238. "DI24",
  239. "DI25",
  240. "r_LOADERA_CRS_CURTAIN_1",
  241. "r_LOADERA_CRS_CURTAIN_2",
  242. "r_LOADERA_CRS_CURTAIN_3",
  243. "r_LOADERA_CRS_CURTAIN_4",
  244. "r_LOADERA_CRS_CURTAIN_5",
  245. "r_LOADERA_CRS_CURTAIN_6",};
  246. AONameItems = new ObservableCollection<string>
  247. { "AO1",
  248. "AO2",
  249. "AO3",
  250. "AO4",
  251. "AO5",
  252. "AO6",
  253. "AO7",
  254. "AO8",
  255. "AO9",
  256. "AO10",
  257. "AO11",
  258. "AO12",
  259. "AO13",
  260. "AO14",
  261. "AO15",
  262. "AO16"};
  263. AINameItems = new ObservableCollection<string>
  264. { "AI1",
  265. "AI2",
  266. "AI3",
  267. "r_LoaderA_LS_Vacuum_anlg",
  268. "r_LoaderB_LS_Vacuum_anlg",
  269. "AI6",
  270. "r_LOADER_GasFlowSensor_FLOW",
  271. "r_LOADERA_BERNOULLI_PRESSURE",
  272. "r_LOADERB_BERNOULLI_PRESSURE",
  273. "r_LOADERA_CHUCK_BLADDER",
  274. "r_LOADERB_CHUCK_BLADDER",
  275. "r_LOADERA_WS_BLADDER_PRESSURE",
  276. "r_LOADERB_WS_BLADDER_PRESSURE",
  277. "r_SPUF_VAC",
  278. "r_LOADER_GasFlowSensor_VACUUM",};
  279. }
  280. }
  281. }