Recipe.cs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.ComponentModel;
  5. using System.Diagnostics;
  6. using System.IO;
  7. using System.Linq;
  8. using Newtonsoft.Json;
  9. using Newtonsoft.Json.Converters;
  10. using Newtonsoft.Json.Linq;
  11. using Venus_Core.Attributes;
  12. namespace Venus_Core
  13. {
  14. public enum RecipeType
  15. {
  16. Chuck,
  17. DeChuck,
  18. Process,
  19. Clean,
  20. }
  21. public enum StepType
  22. {
  23. Time,
  24. Stable,
  25. EndPoint,
  26. OverEtch,
  27. }
  28. public enum ProcessModule
  29. {
  30. Pressure,
  31. TCP, // Transformer Coupled Plasma (转换耦合等离子)
  32. Bias,
  33. Gas,
  34. ESC,
  35. Process,
  36. Compound,
  37. }
  38. public enum GeneratorMode
  39. {
  40. CW,
  41. Pulsing,
  42. }
  43. public enum PressureUnitMode
  44. {
  45. Pressure,
  46. Valve
  47. }
  48. public enum Suspect
  49. {
  50. Origin,
  51. Position1,
  52. Position2,
  53. Position3,
  54. Position4,
  55. Position5
  56. }
  57. public enum TargetMode
  58. {
  59. Step,
  60. Cycle
  61. }
  62. public enum ToleranceMode
  63. {
  64. None,
  65. Value,
  66. Percent
  67. }
  68. public enum MatchWorkMode
  69. {
  70. Auto,
  71. Manual
  72. }
  73. public class RecipeHead : INotifyPropertyChanged
  74. {
  75. private string m_name;
  76. [IsOnlyRead]
  77. public string Name
  78. {
  79. get { return m_name; }
  80. set { m_name = value; InvokePropertyChanged("Name"); }
  81. }
  82. private string _Version = "TestVersion";
  83. public string Version
  84. {
  85. get { return _Version; }
  86. set { _Version = value; InvokePropertyChanged("Version"); }
  87. }
  88. private JetChamber _ChamberType = JetChamber.None;
  89. [JsonConverter(typeof(StringEnumConverter))]
  90. [IsOnlyRead]
  91. public JetChamber ChamberType
  92. {
  93. get { return _ChamberType; }
  94. set { _ChamberType = value; InvokePropertyChanged("ChamberType"); }
  95. }
  96. private RecipeType m_Type;
  97. [JsonConverter(typeof(StringEnumConverter))]
  98. [IsOnlyRead]
  99. public RecipeType Type
  100. {
  101. get { return m_Type; }
  102. set { m_Type = value; InvokePropertyChanged("Type"); }
  103. }
  104. private string m_ChunckRecipe;
  105. [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
  106. public string ChuckRecipe
  107. {
  108. get { return m_ChunckRecipe; }
  109. set { m_ChunckRecipe = value; InvokePropertyChanged("ChuckRecipe"); }
  110. }
  111. private string m_DechuckRecipe;
  112. [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
  113. public string DechuckRecipe
  114. {
  115. get { return m_DechuckRecipe; }
  116. set { m_DechuckRecipe = value; InvokePropertyChanged("DechuckRecipe"); }
  117. }
  118. private bool m_IsShowTolerance;
  119. public bool IsShowTolerance
  120. {
  121. get { return m_IsShowTolerance; }
  122. set { m_IsShowTolerance = value; InvokePropertyChanged("IsShowTolerance"); }
  123. }
  124. private string m_CreateTime;
  125. [IsOnlyRead]
  126. public string CreateTime
  127. {
  128. get { return m_CreateTime; }
  129. set { m_CreateTime = value; InvokePropertyChanged("CreateTime"); }
  130. }
  131. private string m_EditTime;
  132. [IsOnlyRead]
  133. public string EditTime
  134. {
  135. get { return m_EditTime; }
  136. set { m_EditTime = value; InvokePropertyChanged("EditTime"); }
  137. }
  138. private string m_LastModifiedBy;
  139. [IsOnlyRead]
  140. public string LastModifiedBy
  141. {
  142. get { return m_LastModifiedBy; }
  143. set { m_LastModifiedBy = value; InvokePropertyChanged("LastModifiedBy"); }
  144. }
  145. private string m_Barcode;
  146. public string Barcode
  147. {
  148. get { return m_Barcode; }
  149. set { m_Barcode = value; InvokePropertyChanged("Barcode"); }
  150. }
  151. private string m_BasePressure;
  152. public string BasePressure
  153. {
  154. get { return m_BasePressure; }
  155. set { m_BasePressure = value; InvokePropertyChanged("BasePressure"); }
  156. }
  157. private string m_WallTemperature;
  158. [DefaultValue(null)]
  159. [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
  160. public string WallTemperature
  161. {
  162. get { return m_WallTemperature; }
  163. set { m_WallTemperature = value; InvokePropertyChanged("WallTemperature"); }
  164. }
  165. private string m_Temperature;
  166. public string Temperature
  167. {
  168. get { return m_Temperature; }
  169. set { m_Temperature = value; InvokePropertyChanged("Temperature"); }
  170. }
  171. private int m_RFHoldTime = 1000;
  172. [CustomName("RF HoldTime(s)")]
  173. public int RFHoldTime
  174. {
  175. get { return m_RFHoldTime; }
  176. set { m_RFHoldTime = value; InvokePropertyChanged("RFHoldTime"); }
  177. }
  178. private int? m_BiasRFHoldTime;
  179. [CustomName("BiasRF HoldTime(s)")]
  180. [DefaultValue(null)]
  181. [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
  182. public int? BiasRFHoldTime
  183. {
  184. get { return m_BiasRFHoldTime; }
  185. set { m_BiasRFHoldTime = value; InvokePropertyChanged("BiasRFHoldTime"); }
  186. }
  187. private string m_Comment;
  188. public string Comment
  189. {
  190. get { return m_Comment; }
  191. set { m_Comment = value; InvokePropertyChanged("Comment"); }
  192. }
  193. public event PropertyChangedEventHandler PropertyChanged;
  194. public void InvokePropertyChanged(string propertyName)
  195. {
  196. if (PropertyChanged != null)
  197. {
  198. PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
  199. }
  200. }
  201. public RecipeHead()
  202. {
  203. //WallTemperature = null;
  204. }
  205. }
  206. public abstract class ProcessUnitBase
  207. {
  208. [JsonIgnore]
  209. public Func<ProcessUnitBase, RecipeStep, RState> checker;
  210. [JsonIgnore]
  211. public Func<ProcessUnitBase, RecipeStep, RState> starter;
  212. [JsonIgnore]
  213. public Action<ProcessUnitBase, RecipeStep> end;
  214. //[JsonIgnore]
  215. //public string Name { get; set; }
  216. //[JsonIgnore]
  217. //public ProcessModule Moudle { get; set; }
  218. public RState Start(RecipeStep step)
  219. {
  220. if (starter != null)
  221. return starter(this, step);
  222. return RState.Running;
  223. }
  224. public RState Run(RecipeStep step)
  225. {
  226. if (checker != null)
  227. return checker(this, step);
  228. return RState.Running;
  229. }
  230. public void End(RecipeStep step)
  231. {
  232. if (end != null)
  233. end(this, step);
  234. }
  235. //public virtual Dictionary<string,float> GetFDCItems()
  236. //{
  237. // return null;
  238. //}
  239. }
  240. [Serializable]
  241. public class RecipeStep : INotifyPropertyChanged
  242. {
  243. [JsonIgnore]
  244. public Func<RecipeStep, RState> checker;
  245. [JsonIgnore]
  246. public Func<RecipeStep, RState> starter;
  247. [JsonIgnore]
  248. public Func<RecipeStep, RState> ender;
  249. private int m_StepNo = 1;
  250. [IsOnlyRead]
  251. public int StepNo
  252. {
  253. get { return m_StepNo; }
  254. set { m_StepNo = value; InvokePropertyChanged("StepNo"); }
  255. }
  256. private StepType m_StepType;
  257. [JsonConverter(typeof(StringEnumConverter))]
  258. public StepType Type
  259. {
  260. get { return m_StepType; }
  261. set { m_StepType = value; InvokePropertyChanged("Type"); }
  262. }
  263. private int m_Time;
  264. [CustomName("Time(s)")]
  265. public int Time
  266. {
  267. get { return m_Time; }
  268. set { m_Time = value; InvokePropertyChanged("Time"); }
  269. }
  270. private string m_Description;
  271. public string Description
  272. {
  273. get { return m_Description; }
  274. set { m_Description = value; InvokePropertyChanged("Description"); }
  275. }
  276. private string m_EPDConfigName;
  277. [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
  278. public string EPDConfig
  279. {
  280. get { return m_EPDConfigName; }
  281. set { m_EPDConfigName = value; InvokePropertyChanged("EPDConfig"); }
  282. }
  283. private int? m_MinEndPointTime;
  284. [CustomName("MinEndPointTime(s)")]
  285. [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
  286. public int? MinEndPointTime
  287. {
  288. get { return m_MinEndPointTime; }
  289. set { m_MinEndPointTime = value; InvokePropertyChanged("MinEndPointTime"); }
  290. }
  291. private int? m_MaxEndPointTime;
  292. [CustomName("MaxEndPointTime(s)")]
  293. [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
  294. public int? MaxEndPointTime
  295. {
  296. get { return m_MaxEndPointTime; }
  297. set { m_MaxEndPointTime = value; InvokePropertyChanged("MaxEndPointTime"); }
  298. }
  299. private int? m_OverEtchPercent;
  300. [CustomName("OverEtchPercent(%)")]
  301. [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
  302. public int? OverEtchPercent
  303. {
  304. get { return m_OverEtchPercent; }
  305. set { m_OverEtchPercent = value; InvokePropertyChanged("OverEtchPercent"); }
  306. }
  307. private bool m_CycleStart;
  308. public bool CycleStart
  309. {
  310. get { return m_CycleStart; }
  311. set { m_CycleStart = value; InvokePropertyChanged("CycleStart"); }
  312. }
  313. private bool m_CycleEnd;
  314. public bool CycleEnd
  315. {
  316. get { return m_CycleEnd; }
  317. set { m_CycleEnd = value; InvokePropertyChanged("CycleEnd"); }
  318. }
  319. private int m_CycleNumber;
  320. public int CycleNumber
  321. {
  322. get { return m_CycleNumber; }
  323. set { m_CycleNumber = value; InvokePropertyChanged("CycleNumber"); }
  324. }
  325. private ObservableCollection<object> lstUnit = new ObservableCollection<object>();
  326. public ObservableCollection<object> LstUnit
  327. {
  328. get { return lstUnit; }
  329. set { lstUnit = value; InvokePropertyChanged("LstUnit"); }
  330. }
  331. private Stopwatch _stepTimer = new Stopwatch();
  332. public long ElapsedTime()
  333. {
  334. return _stepTimer.ElapsedMilliseconds;
  335. }
  336. public void StartStepTimer()
  337. {
  338. _stepTimer.Restart();
  339. }
  340. //private long _lastEPDStepTime = 0;
  341. //public void RecordEPDStepTime()
  342. //{
  343. // _lastEPDStepTime = _stepTimer.ElapsedMilliseconds;
  344. //}
  345. //public long GetLastEPDStepTime()
  346. //{
  347. // return _lastEPDStepTime;
  348. //}
  349. public RState Start()
  350. {
  351. starter(this);
  352. foreach (var unit in lstUnit)
  353. {
  354. var processUnit = unit as ProcessUnitBase;
  355. if (processUnit != null)
  356. {
  357. var state = processUnit.Start(this);
  358. if (state != RState.Running)
  359. return state;
  360. }
  361. else
  362. return RState.Failed;
  363. }
  364. return RState.Running;
  365. }
  366. public RState Start(int steps, int currentstep)
  367. {
  368. starter(this);
  369. foreach (var unit in lstUnit)
  370. {
  371. var processUnit = unit as ProcessUnitBase;
  372. if (processUnit != null)
  373. {
  374. var state = processUnit.Start(this);
  375. if (state != RState.Running)
  376. return state;
  377. }
  378. else
  379. return RState.Failed;
  380. }
  381. return RState.Running;
  382. }
  383. public RState Run()
  384. {
  385. var checkerState= checker(this);
  386. if (checkerState == RState.End)
  387. {
  388. return RState.End;
  389. }
  390. else if (checkerState == RState.Failed)
  391. {
  392. return RState.Failed;
  393. }
  394. bool bStable = true;
  395. foreach (var unit in lstUnit)
  396. {
  397. var processUnit = unit as ProcessUnitBase;
  398. if (processUnit != null)
  399. {
  400. var state = processUnit.Run(this);
  401. if (Type == StepType.Stable)
  402. {
  403. if (state != RState.Running && state != RState.End)
  404. return state;
  405. if (state == RState.Running)
  406. bStable = false;
  407. }
  408. else
  409. {
  410. if (state != RState.Running)
  411. return state;
  412. }
  413. }
  414. else
  415. return RState.Failed;
  416. }
  417. return (Type == StepType.Stable && bStable) ? RState.End : RState.Running;
  418. }
  419. public void End()
  420. {
  421. foreach (var unit in lstUnit)
  422. {
  423. var processUnit = unit as ProcessUnitBase;
  424. if (processUnit != null)
  425. {
  426. processUnit.End(this);
  427. }
  428. }
  429. ender(this);
  430. }
  431. public double RampFactor()
  432. {
  433. return _stepTimer.ElapsedMilliseconds / (Time * 1000.0);
  434. }
  435. public void AppendUnit(ProcessUnitBase unit)
  436. {
  437. lstUnit.Append(unit);
  438. }
  439. public event PropertyChangedEventHandler PropertyChanged;
  440. public void InvokePropertyChanged(string propertyName)
  441. {
  442. if (PropertyChanged != null)
  443. {
  444. PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
  445. }
  446. }
  447. }
  448. public class Recipe : INotifyPropertyChanged
  449. {
  450. private RecipeHead m_Header = new RecipeHead();
  451. public RecipeHead Header
  452. {
  453. get { return m_Header; }
  454. set { m_Header = value; InvokePropertyChanged("Header"); }
  455. }
  456. private ObservableCollection<RecipeStep> m_Steps;
  457. public ObservableCollection<RecipeStep> Steps
  458. {
  459. get { return m_Steps; }
  460. set { m_Steps = value; InvokePropertyChanged("Steps"); }
  461. }
  462. public static Recipe Load(string recipeFile)
  463. {
  464. var recipe = JsonConvert.DeserializeObject<Recipe>(recipeFile);
  465. if (recipe == null)
  466. {
  467. return null;
  468. }
  469. foreach (var step in recipe.Steps)
  470. {
  471. ObservableCollection<object> unit = new ObservableCollection<object>();
  472. for (int i = 0; i < step.LstUnit.Count; i++)
  473. {
  474. string value = step.LstUnit[i].ToString();
  475. string[] striparr = value.Split(new string[] { "\r\n" }, StringSplitOptions.None);
  476. string item1 = striparr[1].Remove(0, 15);
  477. string item2 = item1.Remove(item1.Length - 2, 2);
  478. if (recipe.Header.ChamberType == JetChamber.VenusSE || recipe.Header.ChamberType == JetChamber.VenusDE || recipe.Header.ChamberType == JetChamber.Kepler2300)
  479. {
  480. switch (item2)
  481. {
  482. case "PressureModeUnit":
  483. unit.Add(JsonConvert.DeserializeObject<PressureByPressureModeUnit>(step.LstUnit[i].ToString()));
  484. break;
  485. case "ControlPressureUnit":
  486. unit.Add(JsonConvert.DeserializeObject<Kepler2200PressureByPressureModeUnit>(step.LstUnit[i].ToString()));
  487. break;
  488. //case "PressureByValveModeUnit":
  489. // unit.Add(JsonConvert.DeserializeObject<PressureByValveModeUnit>(step.LstUnit[i].ToString()));
  490. // break;
  491. case "TCPUnit":
  492. unit.Add(JsonConvert.DeserializeObject<TCPUnit>(step.LstUnit[i].ToString()));
  493. break;
  494. case "RFUnit":
  495. unit.Add(JsonConvert.DeserializeObject<RFUnit>(step.LstUnit[i].ToString()));
  496. break;
  497. case "BiasUnit":
  498. unit.Add(JsonConvert.DeserializeObject<BiasUnit>(step.LstUnit[i].ToString()));
  499. break;
  500. case "GasControlUnit":
  501. unit.Add(JsonConvert.DeserializeObject<GasControlUnit>(step.LstUnit[i].ToString()));
  502. break;
  503. case "ESCHVUnit":
  504. unit.Add(JsonConvert.DeserializeObject<ESCHVUnit>(step.LstUnit[i].ToString()));
  505. break;
  506. case "ProcessKitUnit":
  507. unit.Add(JsonConvert.DeserializeObject<ProcessKitUnit>(step.LstUnit[i].ToString()));
  508. break;
  509. case "HeliumPumpUnit":
  510. unit.Add(JsonConvert.DeserializeObject<HeliumPumpUnit>(step.LstUnit[i].ToString()));
  511. break;
  512. case "HeaterUnit":
  513. unit.Add(JsonConvert.DeserializeObject<HeaterUnit>(step.LstUnit[i].ToString()));
  514. break;
  515. case "RFBoxUnit":
  516. unit.Add(JsonConvert.DeserializeObject<RFBoxUnit>(step.LstUnit[i].ToString()));
  517. break;
  518. case "GasUnit":
  519. unit.Add(JsonConvert.DeserializeObject<Kepler2200GasControlUnit>(step.LstUnit[i].ToString()));
  520. break;
  521. case "SEGasControlUnit":
  522. unit.Add(JsonConvert.DeserializeObject<VenusSEGasControlUnit>(step.LstUnit[i].ToString()));
  523. break;
  524. case "DEGasControlUnit":
  525. unit.Add(JsonConvert.DeserializeObject<VenusDEGasControlUnit>(step.LstUnit[i].ToString()));
  526. break;
  527. case "Magnet":
  528. unit.Add(JsonConvert.DeserializeObject<MagnetUnit>(step.LstUnit[i].ToString()));
  529. break;
  530. }
  531. }
  532. else
  533. {
  534. switch (item2)
  535. {
  536. //case "PressureModeUnit":
  537. // unit.Add(JsonConvert.DeserializeObject<PressureByPressureModeUnit>(step.LstUnit[i].ToString()));
  538. // break;
  539. case "ControlPressureUnit":
  540. case "PressureModeUnit":
  541. unit.Add(JsonConvert.DeserializeObject<Kepler2200PressureByPressureModeUnit>(step.LstUnit[i].ToString()));
  542. break;
  543. case "RFUnit":
  544. case "TCPUnit":
  545. unit.Add(JsonConvert.DeserializeObject<RFUnit>(step.LstUnit[i].ToString()));
  546. break;
  547. case "HeaterUnit":
  548. unit.Add(JsonConvert.DeserializeObject<HeaterUnit>(step.LstUnit[i].ToString()));
  549. break;
  550. case "RFBoxUnit":
  551. unit.Add(JsonConvert.DeserializeObject<RFBoxUnit>(step.LstUnit[i].ToString()));
  552. break;
  553. case "GasUnit":
  554. unit.Add(JsonConvert.DeserializeObject<Kepler2200GasControlUnit>(step.LstUnit[i].ToString()));
  555. break;
  556. }
  557. }
  558. }
  559. step.LstUnit.Clear();
  560. unit.ToList().ForEach(x =>
  561. {
  562. step.LstUnit.Add(x);
  563. });
  564. }
  565. return recipe;
  566. }
  567. public static string ShowEAPRecipe(string recipeContent, ObservableCollection<RecipeStep> Steps)
  568. {
  569. JObject jobject = JObject.Parse(recipeContent);
  570. JArray Firsttokenselect = jobject.SelectToken("Steps") as JArray;
  571. if (Firsttokenselect != null)
  572. {
  573. foreach (JObject firstItem in Firsttokenselect)
  574. {
  575. JArray Secondtokenselect = firstItem.SelectToken("LstUnit") as JArray;
  576. foreach (JObject secondItem in Secondtokenselect)
  577. {
  578. for (int i = 0; i < Steps.Count; i++)
  579. {
  580. for (int j = 0; j < Steps[i].LstUnit.Count; j++)
  581. {
  582. Type type = Steps[i].LstUnit[j].GetType();
  583. foreach (var propertyInfo in type.GetProperties())
  584. {
  585. object[] toleranceAttrs = propertyInfo.GetCustomAttributes(typeof(IsTolerance), true);
  586. if (toleranceAttrs.Length > 0)
  587. {
  588. secondItem.Remove(propertyInfo.Name);
  589. }
  590. }
  591. }
  592. }
  593. }
  594. }
  595. }
  596. return jobject.ToString();
  597. }
  598. public static string ShowToleranceRecipe(string recipeContent, ObservableCollection<RecipeStep> Steps)
  599. {
  600. JObject jobject = JObject.Parse(recipeContent);
  601. JArray Firsttokenselect = jobject.SelectToken("Steps") as JArray;
  602. if (Firsttokenselect != null)
  603. {
  604. foreach (JObject firstItem in Firsttokenselect)
  605. {
  606. JArray Secondtokenselect = firstItem.SelectToken("LstUnit") as JArray;
  607. foreach (JObject secondItem in Secondtokenselect)
  608. {
  609. for (int i = 0; i < Steps.Count; i++)
  610. {
  611. for (int j = 0; j < Steps[i].LstUnit.Count; j++)
  612. {
  613. Type type = Steps[i].LstUnit[j].GetType();
  614. foreach (var propertyInfo in type.GetProperties())
  615. {
  616. object[] toleranceAttrs = propertyInfo.GetCustomAttributes(typeof(IsTolerance), true);
  617. if (toleranceAttrs.Length == 0)
  618. {
  619. secondItem.Remove(propertyInfo.Name);
  620. }
  621. }
  622. }
  623. }
  624. }
  625. }
  626. }
  627. return jobject.ToString();
  628. }
  629. public bool Validate()
  630. {
  631. return true;
  632. }
  633. public bool Save(string recipeFile)
  634. {
  635. return true;
  636. }
  637. public event PropertyChangedEventHandler PropertyChanged;
  638. public void InvokePropertyChanged(string propertyName)
  639. {
  640. if (PropertyChanged != null)
  641. {
  642. PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
  643. }
  644. }
  645. }
  646. public class RecipeUnity
  647. {
  648. public static string ConvertJsonString(string str)
  649. {
  650. JsonSerializer serializer = new JsonSerializer();
  651. TextReader tr = new StringReader(str);
  652. JsonTextReader jtr = new JsonTextReader(tr);
  653. object obj = serializer.Deserialize(jtr);
  654. if (obj != null)
  655. {
  656. StringWriter textWriter = new StringWriter();
  657. JsonTextWriter jsonWriter = new JsonTextWriter(textWriter)
  658. {
  659. Formatting = Newtonsoft.Json.Formatting.Indented,
  660. Indentation = 4,
  661. IndentChar = ' '
  662. };
  663. serializer.Serialize(jsonWriter, obj);
  664. return textWriter.ToString();
  665. }
  666. else
  667. {
  668. return str;
  669. }
  670. }
  671. public static string RecipeToString(Recipe recipe)
  672. {
  673. return JsonConvert.SerializeObject(recipe);
  674. }
  675. public static String CreateRecipe(JetChamber currentChamber, RecipeType recipeType, string recipeName,string userName, int wafersize = 0)
  676. {
  677. Recipe recipe = new Recipe();
  678. recipe.Header = new RecipeHead();
  679. recipe.Header.CreateTime = DateTime.Now.ToString();
  680. recipe.Header.EditTime = DateTime.Now.ToString();
  681. recipe.Header.Type = recipeType;
  682. recipe.Header.ChamberType = currentChamber;
  683. recipe.Header.Name = recipeName;
  684. recipe.Header.LastModifiedBy =userName;
  685. recipe.Steps = new ObservableCollection<RecipeStep>();
  686. RecipeStep recipeStep = new RecipeStep();
  687. recipeStep.LstUnit = GetAllUnits(currentChamber, recipeType, wafersize);
  688. recipe.Steps.Add(recipeStep);
  689. var recipeString = JsonConvert.SerializeObject(recipe);
  690. return recipeString;
  691. }
  692. public static ObservableCollection<object> GetAllUnits(JetChamber jetChamber, RecipeType recipeType, int waferSize = 0)
  693. {
  694. ObservableCollection<object> LstUnit = new ObservableCollection<object>();
  695. switch (jetChamber)
  696. {
  697. //case JetChamber.Venus:
  698. // if (recipeType == RecipeType.Clean)
  699. // {
  700. // foreach (var item in Enum.GetValues(typeof(VenusCleanRecipeUnits)))
  701. // {
  702. // Type t = Type.GetType($"Venus_Core.{item.ToString()}");
  703. // var obj = System.Activator.CreateInstance(t);
  704. // LstUnit.Add(obj);
  705. // }
  706. // }
  707. // else
  708. // {
  709. // foreach (var item in Enum.GetValues(typeof(VenusUnits)))
  710. // {
  711. // Type t = Type.GetType($"Venus_Core.{item.ToString()}");
  712. // var obj = System.Activator.CreateInstance(t);
  713. // LstUnit.Add(obj);
  714. // }
  715. // }
  716. // break;
  717. case JetChamber.Kepler2300:
  718. if (recipeType == RecipeType.Clean)
  719. {
  720. foreach (var item in Enum.GetValues(typeof(Kepler2300CleanRecipeUints)))
  721. {
  722. Type t = Type.GetType($"Venus_Core.{item.ToString()}");
  723. var obj = System.Activator.CreateInstance(t);
  724. LstUnit.Add(obj as ProcessUnitBase);
  725. }
  726. }
  727. else
  728. {
  729. foreach (var item in Enum.GetValues(typeof(Kepler2300Uints)))
  730. {
  731. Type t = Type.GetType($"Venus_Core.{item.ToString()}");
  732. var obj = System.Activator.CreateInstance(t);
  733. LstUnit.Add(obj as ProcessUnitBase);
  734. }
  735. }
  736. break;
  737. case JetChamber.Kepler2200A:
  738. foreach (var item in Enum.GetValues(typeof(Kepler2200AUnits)))
  739. {
  740. Type t = Type.GetType($"Venus_Core.{item.ToString()}");
  741. var obj = System.Activator.CreateInstance(t);
  742. LstUnit.Add(obj as ProcessUnitBase);
  743. }
  744. break;
  745. case JetChamber.Kepler2200B:
  746. foreach (var item in Enum.GetValues(typeof(Kepler2200BUnits)))
  747. {
  748. Type t = Type.GetType($"Venus_Core.{item.ToString()}");
  749. var obj = System.Activator.CreateInstance(t);
  750. LstUnit.Add(obj as ProcessUnitBase);
  751. }
  752. break;
  753. case JetChamber.VenusSE:
  754. foreach (var item in Enum.GetValues(typeof(VenusSEUnits)))
  755. {
  756. Type t = Type.GetType($"Venus_Core.{item.ToString()}");
  757. var obj = System.Activator.CreateInstance(t);
  758. LstUnit.Add(obj as ProcessUnitBase);
  759. }
  760. break;
  761. case JetChamber.VenusDE:
  762. if (waferSize == 8)
  763. {
  764. foreach (var item in Enum.GetValues(typeof(VenusDE8InchUnits)))
  765. {
  766. Type t = Type.GetType($"Venus_Core.{item.ToString()}");
  767. var obj = System.Activator.CreateInstance(t);
  768. LstUnit.Add(obj as ProcessUnitBase);
  769. }
  770. break;
  771. }
  772. else
  773. {
  774. foreach (var item in Enum.GetValues(typeof(VenusDEUnits)))
  775. {
  776. Type t = Type.GetType($"Venus_Core.{item.ToString()}");
  777. var obj = System.Activator.CreateInstance(t);
  778. LstUnit.Add(obj as ProcessUnitBase);
  779. }
  780. break;
  781. }
  782. }
  783. return LstUnit;
  784. }
  785. }
  786. }