JZFLDRecipeXml.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. using Aitex.Core.Common;
  2. using Aitex.Core.RT.Log;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Collections.ObjectModel;
  6. using System.ComponentModel;
  7. using System.Linq;
  8. using System.Runtime.Serialization;
  9. using System.Text;
  10. using System.Xml;
  11. using System.Xml.Linq;
  12. using MECF.Framework.Common.Equipment;
  13. using System.IO;
  14. namespace Aitex.Sorter.Common
  15. {
  16. [DataContract]
  17. [Serializable]
  18. public class JZFLDRecipeXml : INotifyPropertyChanged
  19. {
  20. public event PropertyChangedEventHandler PropertyChanged;
  21. public void OnPropertyChanged(string propertyName)
  22. {
  23. if (PropertyChanged != null)
  24. {
  25. PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
  26. }
  27. }
  28. private string name;
  29. [DataMember]
  30. public string Name
  31. {
  32. get
  33. {
  34. return name;
  35. }
  36. set
  37. {
  38. name = value;
  39. OnPropertyChanged("Name");
  40. }
  41. }
  42. private string _subRecipeName;
  43. public string SubRecipeName
  44. {
  45. get { return _subRecipeName; }
  46. set
  47. {
  48. _subRecipeName = value;
  49. OnPropertyChanged("SubRecipeName");
  50. }
  51. }
  52. private int _unloaderSlotsNumber = 25;
  53. [DataMember]
  54. public int UnloaderSlotsNumber
  55. {
  56. get { return _unloaderSlotsNumber; }
  57. set
  58. {
  59. _unloaderSlotsNumber = value;
  60. OnPropertyChanged("UnloaderSlotsNumber");
  61. }
  62. }
  63. private bool _isLP1Loader;
  64. [DataMember]
  65. public bool IsLP1Loader
  66. {
  67. get { return _isLP1Loader; }
  68. set
  69. {
  70. _isLP1Loader = value;
  71. OnPropertyChanged("IsLP1Loader");
  72. }
  73. }
  74. private bool _isLP2Loader;
  75. [DataMember]
  76. public bool IsLP2Loader
  77. {
  78. get { return _isLP2Loader; }
  79. set
  80. {
  81. _isLP2Loader = value;
  82. OnPropertyChanged("IsLP2Loader");
  83. }
  84. }
  85. private bool _isLP3Loader;
  86. [DataMember]
  87. public bool IsLP3Loader
  88. {
  89. get { return _isLP3Loader; }
  90. set
  91. {
  92. _isLP3Loader = value;
  93. OnPropertyChanged("IsLP3Loader");
  94. }
  95. }
  96. private bool _isLP4Loader;
  97. [DataMember]
  98. public bool IsLP4Loader
  99. {
  100. get { return _isLP4Loader; }
  101. set
  102. {
  103. _isLP4Loader = value;
  104. OnPropertyChanged("IsLP4Loader");
  105. }
  106. }
  107. private bool _isLP5Loader;
  108. [DataMember]
  109. public bool IsLP5Loader
  110. {
  111. get { return _isLP5Loader; }
  112. set
  113. {
  114. _isLP5Loader = value;
  115. OnPropertyChanged("IsLP5Loader");
  116. }
  117. }
  118. private bool _isLP6Loader;
  119. [DataMember]
  120. public bool IsLP6Loader
  121. {
  122. get { return _isLP6Loader; }
  123. set
  124. {
  125. _isLP6Loader = value;
  126. OnPropertyChanged("IsLP6Loader");
  127. }
  128. }
  129. private bool _isLP7Loader;
  130. [DataMember]
  131. public bool IsLP7Loader
  132. {
  133. get { return _isLP7Loader; }
  134. set
  135. {
  136. _isLP7Loader = value;
  137. OnPropertyChanged("IsLP7Loader");
  138. }
  139. }
  140. private bool _isLP8Loader;
  141. [DataMember]
  142. public bool IsLP8Loader
  143. {
  144. get { return _isLP8Loader; }
  145. set
  146. {
  147. _isLP8Loader = value;
  148. OnPropertyChanged("IsLP8Loader");
  149. }
  150. }
  151. private bool _isLP1CollectErrorWafer;
  152. [DataMember]
  153. public bool IsLP1CollectErrorWafer
  154. {
  155. get { return _isLP1CollectErrorWafer; }
  156. set
  157. {
  158. _isLP1CollectErrorWafer = value;
  159. OnPropertyChanged("IsLP1CollectErrorWafer");
  160. }
  161. }
  162. private bool _isLP2CollectErrorWafer;
  163. [DataMember]
  164. public bool IsLP2CollectErrorWafer
  165. {
  166. get { return _isLP2CollectErrorWafer; }
  167. set
  168. {
  169. _isLP2CollectErrorWafer = value;
  170. OnPropertyChanged("IsLP2CollectErrorWafer");
  171. }
  172. }
  173. private bool _isLP3CollectErrorWafer;
  174. [DataMember]
  175. public bool IsLP3CollectErrorWafer
  176. {
  177. get { return _isLP3CollectErrorWafer; }
  178. set
  179. {
  180. _isLP3CollectErrorWafer = value;
  181. OnPropertyChanged("IsLP3CollectErrorWafer");
  182. }
  183. }
  184. private bool _isLP4CollectErrorWafer;
  185. [DataMember]
  186. public bool IsLP4CollectErrorWafer
  187. {
  188. get { return _isLP4CollectErrorWafer; }
  189. set
  190. {
  191. _isLP4CollectErrorWafer = value;
  192. OnPropertyChanged("IsLP4CollectErrorWafer");
  193. }
  194. }
  195. private bool _isLP5CollectErrorWafer;
  196. [DataMember]
  197. public bool IsLP5CollectErrorWafer
  198. {
  199. get { return _isLP5CollectErrorWafer; }
  200. set
  201. {
  202. _isLP5CollectErrorWafer = value;
  203. OnPropertyChanged("IsLP5CollectErrorWafer");
  204. }
  205. }
  206. private bool _isLP6CollectErrorWafer;
  207. [DataMember]
  208. public bool IsLP6CollectErrorWafer
  209. {
  210. get { return _isLP6CollectErrorWafer; }
  211. set
  212. {
  213. _isLP6CollectErrorWafer = value;
  214. OnPropertyChanged("IsLP6CollectErrorWafer");
  215. }
  216. }
  217. private bool _isLP7CollectErrorWafer;
  218. [DataMember]
  219. public bool IsLP7CollectErrorWafer
  220. {
  221. get { return _isLP7CollectErrorWafer; }
  222. set
  223. {
  224. _isLP7CollectErrorWafer = value;
  225. OnPropertyChanged("IsLP7CollectErrorWafer");
  226. }
  227. }
  228. private bool _isLP8CollectErrorWafer;
  229. [DataMember]
  230. public bool IsLP8CollectErrorWafer
  231. {
  232. get { return _isLP8CollectErrorWafer; }
  233. set
  234. {
  235. _isLP8CollectErrorWafer = value;
  236. OnPropertyChanged("IsLP8CollectErrorWafer");
  237. }
  238. }
  239. private string _unloader1Information;
  240. public string Unloader1Information
  241. {
  242. get { return _unloader1Information; }
  243. set
  244. {
  245. _unloader1Information = value;
  246. OnPropertyChanged("Unloader1Information");
  247. }
  248. }
  249. private string _unloader2Information;
  250. public string Unloader2Information
  251. {
  252. get { return _unloader2Information; }
  253. set
  254. {
  255. _unloader2Information = value;
  256. OnPropertyChanged("Unloader2Information");
  257. }
  258. }
  259. private string _unloader3Information;
  260. public string Unloader3Information
  261. {
  262. get { return _unloader3Information; }
  263. set
  264. {
  265. _unloader3Information = value;
  266. OnPropertyChanged("Unloader3Information");
  267. }
  268. }
  269. private string _unloader4Information;
  270. public string Unloader4Information
  271. {
  272. get { return _unloader4Information; }
  273. set
  274. {
  275. _unloader4Information = value;
  276. OnPropertyChanged("Unloader4Information");
  277. }
  278. }
  279. private string _unloader5Information;
  280. public string Unloader5Information
  281. {
  282. get { return _unloader5Information; }
  283. set
  284. {
  285. _unloader5Information = value;
  286. OnPropertyChanged("Unloader5Information");
  287. }
  288. }
  289. private string _unloader6Information;
  290. public string Unloader6Information
  291. {
  292. get { return _unloader6Information; }
  293. set
  294. {
  295. _unloader6Information = value;
  296. OnPropertyChanged("Unloader6Information");
  297. }
  298. }
  299. private string _unloader7Information;
  300. public string Unloader7Information
  301. {
  302. get { return _unloader7Information; }
  303. set
  304. {
  305. _unloader7Information = value;
  306. OnPropertyChanged("Unloader7Information");
  307. }
  308. }
  309. private string _unloader8Information;
  310. public string Unloader8Information
  311. {
  312. get { return _unloader8Information; }
  313. set
  314. {
  315. _unloader8Information = value;
  316. OnPropertyChanged("Unloader8Information");
  317. }
  318. }
  319. public JZFLDRecipeXml(string name = "")
  320. {
  321. Name = name;
  322. }
  323. public JZFLDRecipeXml(string content, string name = "")
  324. {
  325. Name = name;
  326. SetContent(content);
  327. }
  328. public bool SetContent(string content)
  329. {
  330. try
  331. {
  332. var doc = XDocument.Parse(content);
  333. ParseContent(doc);
  334. }
  335. catch (Exception e)
  336. {
  337. LOG.Write(e);
  338. return false;
  339. }
  340. return true;
  341. }
  342. public string GetContent()
  343. {
  344. var doc = new XDocument();
  345. var root = new XElement("Recipe");
  346. var element = new XElement("JZFLDRecipe"
  347. , new XAttribute("SubRecipeName", SubRecipeName??"")
  348. , new XAttribute("UnloaderSlotsNumber", UnloaderSlotsNumber)
  349. , new XAttribute("IsLP1Loader", IsLP1Loader.ToString())
  350. , new XAttribute("IsLP2Loader", IsLP2Loader.ToString())
  351. , new XAttribute("IsLP3Loader", IsLP3Loader.ToString())
  352. , new XAttribute("IsLP4Loader", IsLP4Loader.ToString())
  353. , new XAttribute("IsLP5Loader", IsLP5Loader.ToString())
  354. , new XAttribute("IsLP6Loader", IsLP6Loader.ToString())
  355. , new XAttribute("IsLP7Loader", IsLP7Loader.ToString())
  356. , new XAttribute("IsLP8Loader", IsLP8Loader.ToString())
  357. , new XAttribute("IsLP1CollectErrorWafer", IsLP1CollectErrorWafer.ToString())
  358. , new XAttribute("IsLP2CollectErrorWafer", IsLP2CollectErrorWafer.ToString())
  359. , new XAttribute("IsLP3CollectErrorWafer", IsLP3CollectErrorWafer.ToString())
  360. , new XAttribute("IsLP4CollectErrorWafer", IsLP4CollectErrorWafer.ToString())
  361. , new XAttribute("IsLP5CollectErrorWafer", IsLP5CollectErrorWafer.ToString())
  362. , new XAttribute("IsLP6CollectErrorWafer", IsLP6CollectErrorWafer.ToString())
  363. , new XAttribute("IsLP7CollectErrorWafer", IsLP7CollectErrorWafer.ToString())
  364. , new XAttribute("IsLP8CollectErrorWafer", IsLP8CollectErrorWafer.ToString())
  365. , new XAttribute("Unloader1Information", Unloader1Information?? ",,,,,,,,,")
  366. , new XAttribute("Unloader2Information", Unloader2Information?? ",,,,,,,,,")
  367. , new XAttribute("Unloader3Information", Unloader3Information?? ",,,,,,,,,")
  368. , new XAttribute("Unloader4Information", Unloader4Information?? ",,,,,,,,,")
  369. , new XAttribute("Unloader5Information", Unloader5Information?? ",,,,,,,,,")
  370. , new XAttribute("Unloader6Information", Unloader6Information?? ",,,,,,,,,")
  371. , new XAttribute("Unloader7Information", Unloader7Information?? ",,,,,,,,,")
  372. , new XAttribute("Unloader8Information", Unloader8Information?? ",,,,,,,,,")
  373. );
  374. root.Add(element);
  375. doc.Add(root);
  376. return doc.ToString();
  377. }
  378. private void ParseContent(XDocument doc)
  379. {
  380. try
  381. {
  382. var node = doc.Root.Element("JZFLDRecipe");
  383. if (node == null)
  384. {
  385. LOG.Write(string.Format("recipe not valid"));
  386. return;
  387. }
  388. string strValue;
  389. int intValue;
  390. bool bValue;
  391. SubRecipeName = (node.Attribute("SubRecipeName") == null? "": node.Attribute("SubRecipeName").Value);
  392. strValue = node.Attribute("UnloaderSlotsNumber").Value;
  393. int.TryParse(strValue, out intValue);
  394. UnloaderSlotsNumber = intValue;
  395. strValue = node.Attribute("IsLP1Loader").Value;
  396. bool.TryParse(strValue, out bValue);
  397. IsLP1Loader = bValue;
  398. strValue = node.Attribute("IsLP2Loader").Value;
  399. bool.TryParse(strValue, out bValue);
  400. IsLP2Loader = bValue;
  401. strValue = node.Attribute("IsLP3Loader").Value;
  402. bool.TryParse(strValue, out bValue);
  403. IsLP3Loader = bValue;
  404. strValue = node.Attribute("IsLP4Loader").Value;
  405. bool.TryParse(strValue, out bValue);
  406. IsLP4Loader = bValue;
  407. strValue = node.Attribute("IsLP5Loader").Value;
  408. bool.TryParse(strValue, out bValue);
  409. IsLP5Loader = bValue;
  410. strValue = node.Attribute("IsLP6Loader").Value;
  411. bool.TryParse(strValue, out bValue);
  412. IsLP6Loader = bValue;
  413. strValue = node.Attribute("IsLP7Loader").Value;
  414. bool.TryParse(strValue, out bValue);
  415. IsLP7Loader = bValue;
  416. strValue = node.Attribute("IsLP8Loader").Value;
  417. bool.TryParse(strValue, out bValue);
  418. IsLP8Loader = bValue;
  419. strValue = node.Attribute("IsLP8Loader").Value;
  420. bool.TryParse(strValue, out bValue);
  421. IsLP8Loader = bValue;
  422. if(node.Attribute("IsLP1CollectErrorWafer")!=null)
  423. {
  424. strValue = node.Attribute("IsLP1CollectErrorWafer").Value;
  425. bool.TryParse(strValue, out bValue);
  426. IsLP1CollectErrorWafer = bValue;
  427. }
  428. if (node.Attribute("IsLP2CollectErrorWafer") != null)
  429. {
  430. strValue = node.Attribute("IsLP2CollectErrorWafer").Value;
  431. bool.TryParse(strValue, out bValue);
  432. IsLP2CollectErrorWafer = bValue;
  433. }
  434. if (node.Attribute("IsLP3CollectErrorWafer") != null)
  435. {
  436. strValue = node.Attribute("IsLP3CollectErrorWafer").Value;
  437. bool.TryParse(strValue, out bValue);
  438. IsLP3CollectErrorWafer = bValue;
  439. }
  440. if (node.Attribute("IsLP4CollectErrorWafer") != null)
  441. {
  442. strValue = node.Attribute("IsLP4CollectErrorWafer").Value;
  443. bool.TryParse(strValue, out bValue);
  444. IsLP4CollectErrorWafer = bValue;
  445. }
  446. if (node.Attribute("IsLP5CollectErrorWafer") != null)
  447. {
  448. strValue = node.Attribute("IsLP5CollectErrorWafer").Value;
  449. bool.TryParse(strValue, out bValue);
  450. IsLP5CollectErrorWafer = bValue;
  451. }
  452. if (node.Attribute("IsLP6CollectErrorWafer") != null)
  453. {
  454. strValue = node.Attribute("IsLP6CollectErrorWafer").Value;
  455. bool.TryParse(strValue, out bValue);
  456. IsLP6CollectErrorWafer = bValue;
  457. }
  458. if (node.Attribute("IsLP7CollectErrorWafer") != null)
  459. {
  460. strValue = node.Attribute("IsLP7CollectErrorWafer").Value;
  461. bool.TryParse(strValue, out bValue);
  462. IsLP7CollectErrorWafer = bValue;
  463. }
  464. if (node.Attribute("IsLP8CollectErrorWafer") != null)
  465. {
  466. strValue = node.Attribute("IsLP8CollectErrorWafer").Value;
  467. bool.TryParse(strValue, out bValue);
  468. IsLP8CollectErrorWafer = bValue;
  469. }
  470. strValue = node.Attribute("IsLP8CollectErrorWafer").Value;
  471. bool.TryParse(strValue, out bValue);
  472. IsLP8CollectErrorWafer = bValue;
  473. Unloader1Information = node.Attribute("Unloader1Information").Value;
  474. Unloader2Information = node.Attribute("Unloader2Information").Value;
  475. Unloader3Information = node.Attribute("Unloader3Information").Value;
  476. Unloader4Information = node.Attribute("Unloader4Information").Value;
  477. Unloader5Information = node.Attribute("Unloader5Information").Value;
  478. Unloader6Information = node.Attribute("Unloader6Information").Value;
  479. Unloader7Information = node.Attribute("Unloader7Information").Value;
  480. Unloader8Information = node.Attribute("Unloader8Information").Value;
  481. }
  482. catch (Exception ex)
  483. {
  484. LOG.Write(ex);
  485. }
  486. }
  487. private T GetValue<T>(XElement element, string Name)
  488. {
  489. var attr = element.Attribute(Name);
  490. if (attr != null)
  491. {
  492. return (T)Convert.ChangeType(attr.Value, typeof(T));
  493. }
  494. return default(T);
  495. }
  496. }
  497. }