DepRecipeViewModel.cs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793
  1. using Aitex.Core.RT.DataCenter;
  2. using Aitex.Core.RT.Log;
  3. using Aitex.Core.UI.Dialog;
  4. using Aitex.Core.UI.MVVM;
  5. using Aitex.Core.Utilities;
  6. using Caliburn.Micro.Core;
  7. using CyberX8_Core;
  8. using CyberX8_MainPages.PMs;
  9. using CyberX8_Themes.UserControls;
  10. using MECF.Framework.Common.DataCenter;
  11. using MECF.Framework.Common.RecipeCenter;
  12. using MECF.Framework.Common.Utilities;
  13. using Prism.Mvvm;
  14. using System;
  15. using System.Collections.Generic;
  16. using System.Collections.ObjectModel;
  17. using System.ComponentModel;
  18. using System.Linq;
  19. using System.Reflection;
  20. using System.Text;
  21. using System.Threading.Tasks;
  22. using System.Windows;
  23. using System.Windows.Controls;
  24. using System.Windows.Input;
  25. namespace CyberX8_MainPages.ViewModels
  26. {
  27. public class DepRecipeViewModel : BindableBase
  28. {
  29. #region 常量
  30. private const string ENGINEERING = "Engineering";
  31. private const string DEP = "dep";
  32. #endregion
  33. #region 内部变量
  34. /// <summary>
  35. /// Recipe节点字典
  36. /// </summary>
  37. private Dictionary<string, RecipeNode> _recipeNodeDic = new Dictionary<string, RecipeNode>();
  38. /// <summary>
  39. /// 属性检验结果字典
  40. /// </summary>
  41. private Dictionary<string, bool> _propertyValidResultDic = new Dictionary<string, bool>();
  42. /// <summary>
  43. /// Recipe节点集合
  44. /// </summary>
  45. private ObservableCollection<RecipeNode> _recipeNodes;
  46. /// <summary>
  47. /// uiRecipeManager
  48. /// </summary>
  49. private UiRecipeManager _uiRecipeManager = new UiRecipeManager();
  50. /// <summary>
  51. /// recipe
  52. /// </summary>
  53. private DepRecipe _recipe;
  54. /// <summary>
  55. /// 编辑可用性
  56. /// </summary>
  57. private bool _editEnable;
  58. /// <summary>
  59. /// 创建可用性
  60. /// </summary>
  61. private bool _createEnable;
  62. /// <summary>
  63. /// 当前节点
  64. /// </summary>
  65. private RecipeNode _currentNode;
  66. /// <summary>
  67. /// 是否可用
  68. /// </summary>
  69. private bool _enable = false;
  70. /// <summary>
  71. /// 是否为编辑(true-Edit,false-add)
  72. /// </summary>
  73. private bool _isEdit = false;
  74. /// <summary>
  75. /// 化学液集合
  76. /// </summary>
  77. private List<string> _chemistryLst = new List<string>();
  78. /// <summary>
  79. /// 显示MultiZone列
  80. /// </summary>
  81. private bool _multiZoneShow = false;
  82. /// <summary>
  83. /// 显示SingleZone列
  84. /// </summary>
  85. private bool _singleZoneShow = false;
  86. /// <summary>
  87. /// 选择AnodeType
  88. /// </summary>
  89. private string _selectAnodeType;
  90. /// <summary>
  91. /// Ramp DataGrid选择索引
  92. /// </summary>
  93. private int _selectedRampIndex = -1;
  94. /// <summary>
  95. /// Pulse DataGrid选择索引
  96. /// </summary>
  97. private int _selectedPulseIndex = -1;
  98. /// <summary>
  99. /// Pulse类型集合
  100. /// </summary>
  101. private List<string> _pulseTypeList = new List<string>();
  102. #endregion
  103. #region 属性
  104. public ObservableCollection<RecipeNode> RecipeNodes
  105. {
  106. get { return _recipeNodes; }
  107. set { SetProperty(ref _recipeNodes, value); }
  108. }
  109. /// <summary>
  110. /// Recipe
  111. /// </summary>
  112. public DepRecipe Recipe
  113. {
  114. get { return _recipe; }
  115. set { SetProperty(ref _recipe, value); }
  116. }
  117. /// <summary>
  118. /// 创建可用性
  119. /// </summary>
  120. public bool CreateEnable
  121. {
  122. get { return _createEnable; }
  123. set { SetProperty(ref _createEnable, value);}
  124. }
  125. /// <summary>
  126. /// 编辑可用性
  127. /// </summary>
  128. public bool EditEnable
  129. {
  130. get { return _editEnable; }
  131. set { SetProperty(ref _editEnable, value);}
  132. }
  133. /// <summary>
  134. /// 当前节点
  135. /// </summary>
  136. public RecipeNode CurrentNode
  137. {
  138. get { return _currentNode; }
  139. set { SetProperty(ref _currentNode, value);}
  140. }
  141. /// <summary>
  142. /// 可用性
  143. /// </summary>
  144. public bool Enable
  145. {
  146. get { return _enable; }
  147. set { SetProperty(ref _enable, value); }
  148. }
  149. /// <summary>
  150. /// 属性数据检验结果
  151. /// </summary>
  152. public Dictionary<string, bool> PropertyValidResultDic
  153. {
  154. get { return _propertyValidResultDic; }
  155. set { SetProperty(ref _propertyValidResultDic, value); }
  156. }
  157. /// <summary>
  158. /// 化学液集合
  159. /// </summary>
  160. public List<string> ChemistryLst
  161. {
  162. get { return _chemistryLst; }
  163. set { SetProperty(ref _chemistryLst, value); }
  164. }
  165. /// <summary>
  166. /// MultiZone 显示
  167. /// </summary>
  168. public bool MultiZoneShow
  169. {
  170. get { return _multiZoneShow; }
  171. set
  172. {
  173. SetProperty(ref _multiZoneShow, value);
  174. SingleZoneShow = !value;
  175. }
  176. }
  177. /// <summary>
  178. /// SingleZone显示列
  179. /// </summary>
  180. public bool SingleZoneShow
  181. {
  182. get { return _singleZoneShow; }
  183. set { SetProperty(ref _singleZoneShow, value);}
  184. }
  185. /// <summary>
  186. /// 选择Anode Type
  187. /// </summary>
  188. public string SelectedAnodeType
  189. {
  190. get { return _selectAnodeType; }
  191. set
  192. {
  193. SetProperty(ref _selectAnodeType, value);
  194. UpdateDataGridShow();
  195. }
  196. }
  197. /// <summary>
  198. /// DataGrid 索引
  199. /// </summary>
  200. public int SelectedRampIndex
  201. {
  202. get { return _selectedRampIndex; }
  203. set { SetProperty(ref _selectedRampIndex, value);}
  204. }
  205. /// <summary>
  206. /// Pulse Datagrid选择索引
  207. /// </summary>
  208. public int SelectedPulseIndex
  209. {
  210. get { return _selectedPulseIndex; }
  211. set { SetProperty(ref _selectedPulseIndex, value); }
  212. }
  213. public List<string> PulseTypeList
  214. {
  215. get { return _pulseTypeList; }
  216. set { SetProperty(ref _pulseTypeList, value); }
  217. }
  218. #endregion
  219. #region 指令
  220. [IgnorePropertyChange]
  221. public ICommand OperationCommand
  222. {
  223. get;
  224. private set;
  225. }
  226. [IgnorePropertyChange]
  227. public ICommand CreateCommand { get; private set; }
  228. [IgnorePropertyChange]
  229. public ICommand EditCommand { get; private set; }
  230. [IgnorePropertyChange]
  231. public ICommand SaveRecipeCommand { get; private set; }
  232. [IgnorePropertyChange]
  233. public ICommand SaveAsRecipeCommand { get; private set; }
  234. [IgnorePropertyChange]
  235. public ICommand AddBelowCommand { get;private set; }
  236. [IgnorePropertyChange]
  237. public ICommand AddAboveCommand { get; private set; }
  238. [IgnorePropertyChange]
  239. public ICommand MoveUpCommand { get; private set; }
  240. [IgnorePropertyChange]
  241. public ICommand MoveDownCommand { get; private set; }
  242. [IgnorePropertyChange]
  243. public ICommand DeleteCommand { get;private set; }
  244. [IgnorePropertyChange]
  245. public ICommand AddBelowPulseCommand { get; private set; }
  246. [IgnorePropertyChange]
  247. public ICommand AddAbovePulseCommand { get; private set; }
  248. [IgnorePropertyChange]
  249. public ICommand MoveUpPulseCommand { get; private set; }
  250. [IgnorePropertyChange]
  251. public ICommand MoveDownPulseCommand { get; private set; }
  252. [IgnorePropertyChange]
  253. public ICommand DeletePulseCommand { get; private set; }
  254. #endregion
  255. /// <summary>
  256. /// 构造函数
  257. /// </summary>
  258. public DepRecipeViewModel()
  259. {
  260. OperationCommand = new DelegateCommand<object>(SelectionChangedAction);
  261. CreateCommand = new DelegateCommand<object>(CreateAction);
  262. EditCommand = new DelegateCommand<object>(EditAction);
  263. SaveRecipeCommand = new DelegateCommand<object>(SaveAction);
  264. SaveAsRecipeCommand = new DelegateCommand<object>(SaveAsAction);
  265. AddBelowCommand = new DelegateCommand<object>(AddBelowAction);
  266. AddAboveCommand = new DelegateCommand<object>(AddAboveAction);
  267. MoveUpCommand=new DelegateCommand<object>(MoveUpAction);
  268. MoveDownCommand=new DelegateCommand<object>(MoveDownAction);
  269. DeleteCommand=new DelegateCommand<object>(DeleteAction);
  270. AddBelowPulseCommand = new DelegateCommand<object>(AddBelowPulseAction);
  271. AddAbovePulseCommand = new DelegateCommand<object>(AddAbovePulseAction);
  272. MoveUpPulseCommand=new DelegateCommand<object>(MoveUpPulseAction);
  273. MoveDownPulseCommand = new DelegateCommand<object>(MoveDownPulseAction);
  274. DeletePulseCommand =new DelegateCommand<object>(DeletePulseAction);
  275. string chemistryContent = QueryDataClient.Instance.Service.GetConfig($"System.ChemistryList").ToString();
  276. if (!string.IsNullOrEmpty(chemistryContent))
  277. {
  278. ChemistryLst = chemistryContent.Split(',').ToList();
  279. }
  280. PulseTypeList.Add("Plus");
  281. PulseTypeList.Add("Minus");
  282. PulseTypeList.Add("Off");
  283. InitializeProprtyValidResultDictionary();
  284. }
  285. /// <summary>
  286. /// 初始化属性数据检验结果字典
  287. /// </summary>
  288. private void InitializeProprtyValidResultDictionary()
  289. {
  290. PropertyValidResultDic["CurrentWarningLevel"] = false;
  291. PropertyValidResultDic["FaultPercent"] = false;
  292. PropertyValidResultDic["VolatageLimitMin"] = false;
  293. PropertyValidResultDic["VolatageLimitMax"] = false;
  294. PropertyValidResultDic["VoltageWarningLevel"] = false;
  295. PropertyValidResultDic["PlatingDelaySeconds"] = false;
  296. }
  297. /// <summary>
  298. /// 加载数据
  299. /// </summary>
  300. public void LoadRecipeData()
  301. {
  302. RecipeNodes = _uiRecipeManager.GetRecipesByType(DEP);
  303. _recipeNodeDic.Clear();
  304. InitializeDictionary(RecipeNodes);
  305. }
  306. /// <summary>
  307. /// 初始化字典
  308. /// </summary>
  309. /// <param name="nodes"></param>
  310. private void InitializeDictionary(ObservableCollection<RecipeNode> nodes)
  311. {
  312. if (nodes != null)
  313. {
  314. foreach (var node in nodes)
  315. {
  316. if (node.NodeType == RecipeNodeType.File)
  317. {
  318. _recipeNodeDic[node.Name] = node;
  319. }
  320. InitializeDictionary(node.Children);
  321. }
  322. }
  323. }
  324. /// <summary>
  325. /// 操作
  326. /// </summary>
  327. /// <param name="param"></param>
  328. private void SelectionChangedAction(object param)
  329. {
  330. if(_recipeNodeDic.ContainsKey(param.ToString()))
  331. {
  332. CurrentNode = _recipeNodeDic[param.ToString()];
  333. if(CurrentNode.NodeType==RecipeNodeType.File)
  334. {
  335. if (CurrentNode.RecipeLocation == ENGINEERING)
  336. {
  337. EditEnable = true;
  338. CreateEnable = true;
  339. }
  340. else
  341. {
  342. EditEnable= false;
  343. CreateEnable = false;
  344. }
  345. }
  346. Recipe = _uiRecipeManager.LoadRecipe<DepRecipe>(CurrentNode.RecipeFullFileName);
  347. if(Recipe==null)
  348. {
  349. MessageBox.Show("Invalid Recipe", "Load Recipe", MessageBoxButton.OK, MessageBoxImage.Error);
  350. EditEnable = false;
  351. CreateEnable = false;
  352. }
  353. Enable = false;
  354. }
  355. else
  356. {
  357. if(param.ToString()==ENGINEERING)
  358. {
  359. CreateEnable= true;
  360. }
  361. else
  362. {
  363. CreateEnable = false;
  364. }
  365. CurrentNode = null;
  366. Recipe = null;
  367. EditEnable = false;
  368. Enable = false;
  369. }
  370. }
  371. #region Action
  372. /// <summary>
  373. /// 创建
  374. /// </summary>
  375. /// <param name="param"></param>
  376. private void CreateAction(object param)
  377. {
  378. RecipeNameDialog recipeNameDialog = new RecipeNameDialog();
  379. if (recipeNameDialog.ShowDialog().Value)
  380. {
  381. Recipe = new DepRecipe();
  382. Recipe.CreateDate = DateTime.Now;
  383. Recipe.Ppid = recipeNameDialog.RecipeName;
  384. Recipe.Description=recipeNameDialog.RecipeDescription;
  385. Recipe.CurrentRampProfileSteps = new ObservableCollection<CurrentRampProfile>();
  386. Recipe.PulsePowerSupplySteps = new ObservableCollection<PulsePowerSupplyStep>();
  387. Enable = true;
  388. _isEdit = false;
  389. }
  390. }
  391. /// <summary>
  392. /// 编辑
  393. /// </summary>
  394. /// <param name="param"></param>
  395. private void EditAction(object param)
  396. {
  397. Enable = true;
  398. _isEdit= false;
  399. }
  400. /// <summary>
  401. /// 保存
  402. /// </summary>
  403. /// <param name="param"></param>
  404. private void SaveAction(object param)
  405. {
  406. if (CheckValid(_isEdit))
  407. {
  408. Recipe.SaveDate = DateTime.Now;
  409. int platingsteps = 0;
  410. int totaltime = 0;
  411. double totalcurrent = 0;
  412. foreach(var obj in Recipe.CurrentRampProfileSteps)
  413. {
  414. totaltime += obj.CurrentRampDurartionSeconds;
  415. totalcurrent += (obj.CurrentRampDurartionSeconds * obj.ForwardAmps);
  416. platingsteps++;
  417. }
  418. //计算Deposition PlatingSteps
  419. Recipe.DepositionPlatingSteps = platingsteps;
  420. //计算Deposition Totaltimes
  421. string date = string.Empty;
  422. var seconds = (int)(totaltime % 60);
  423. var minutes = (int)(totaltime / 60) % 60;
  424. var hours = (int)(totaltime / 3600) % 60;
  425. date = string.Format("{0:00}:{1:00}:{2:00}", hours + "h", minutes + "m", seconds + "s");
  426. Recipe.DepositionTotalTime = date;
  427. //计算Deposition TotalCurrent
  428. Recipe.DepositionTotalCurrent = totalcurrent / 3600;
  429. //计算TotalTime
  430. Recipe.TotalTime = totaltime + Recipe.PlatingDelaySeconds;
  431. try
  432. {
  433. _uiRecipeManager.SaveRecipe<DepRecipe>(ENGINEERING, Recipe.Ppid,"dep", Recipe);
  434. LoadRecipeData();
  435. MessageBox.Show("Save Recipe Success", "Save Recipe", MessageBoxButton.OK, MessageBoxImage.Information);
  436. Enable = false;
  437. }
  438. catch (Exception ex)
  439. {
  440. MessageBox.Show(ex.Message, "Save Recipe", MessageBoxButton.OK, MessageBoxImage.Error);
  441. }
  442. }
  443. }
  444. /// <summary>
  445. /// 另存为
  446. /// </summary>
  447. /// <param name="param"></param>
  448. private void SaveAsAction(object param)
  449. {
  450. if (Recipe == null)
  451. {
  452. MessageBox.Show("Select a Recipe first", "SaveAs Recipe", MessageBoxButton.OK, MessageBoxImage.Error);
  453. return;
  454. }
  455. DepRecipe recipe = new DepRecipe();
  456. if (CheckValid(_isEdit))
  457. {
  458. RecipeNameDialog recipeNameDialog = new RecipeNameDialog();
  459. if (recipeNameDialog.ShowDialog().Value)
  460. {
  461. if (!CheckNameExist(recipeNameDialog.RecipeName))
  462. {
  463. recipe = new DepRecipe();
  464. //复制属性
  465. //recipe.Chemistry = Recipe.Chemistry;
  466. //recipe.AnodeType = Recipe.AnodeType;
  467. //recipe.CurrentWarningLevel = Recipe.CurrentWarningLevel;
  468. //recipe.CycleClampsMaxTries = Recipe.CycleClampsMaxTries;
  469. //recipe.FaultPercent = Recipe.FaultPercent;
  470. //recipe.PlatingDelaySeconds = Recipe.PlatingDelaySeconds;
  471. //recipe.VolatageLimitMax = Recipe.VolatageLimitMax;
  472. //recipe.VolatageLimitMin = Recipe.VolatageLimitMin;
  473. //recipe.VoltageWarningLevel = Recipe.VoltageWarningLevel;
  474. //recipe.CycleClampsEnable = Recipe.CycleClampsEnable;
  475. //recipe.HotPlatingCurrentOn = Recipe.HotPlatingCurrentOn;
  476. //recipe.MultiAnodeType = Recipe.MultiAnodeType;
  477. //recipe.DepositionPlatingSteps = Recipe.DepositionPlatingSteps;
  478. //recipe.DepositionTotalTime = Recipe.DepositionTotalTime;
  479. //recipe.DepositionTotalCurrent = Recipe.DepositionTotalCurrent;
  480. //recipe.TotalTime = Recipe.TotalTime;
  481. //recipe.CurrentRampProfileSteps = new ObservableCollection<CurrentRampProfile>();
  482. //foreach(var item in Recipe.CurrentRampProfileSteps)
  483. //{
  484. // CurrentRampProfile currentRampProfile = new CurrentRampProfile();
  485. // currentRampProfile.CurrentRampDurartionSeconds = item.CurrentRampDurartionSeconds;
  486. // currentRampProfile.ForwardAmps = item.ForwardAmps;
  487. // currentRampProfile.ForwardAmps2 = item.ForwardAmps2;
  488. // currentRampProfile.ForwardAmps3 = item.ForwardAmps3;
  489. // currentRampProfile.ForwardAmps4 = item.ForwardAmps4;
  490. // currentRampProfile.ForwardAmps5 = item.ForwardAmps5;
  491. // currentRampProfile.ForwardAmps6 = item.ForwardAmps6;
  492. // currentRampProfile.PulseEnabled = item.PulseEnabled;
  493. // currentRampProfile.ReversedAmps = item.ReversedAmps;
  494. // currentRampProfile.ShearPlateSpeed = item.ShearPlateSpeed;
  495. // recipe.CurrentRampProfileSteps.Add(currentRampProfile);
  496. //}
  497. //recipe.PulsePowerSupplySteps = new ObservableCollection<PulsePowerSupplyStep>();
  498. //foreach (var item in Recipe.PulsePowerSupplySteps)
  499. //{
  500. // PulsePowerSupplyStep pulsePowerSupplyStep = new PulsePowerSupplyStep();
  501. // pulsePowerSupplyStep.DurationHundredsMicroSeconds = item.DurationHundredsMicroSeconds;
  502. // pulsePowerSupplyStep.Type = item.Type;
  503. // recipe.PulsePowerSupplySteps.Add(pulsePowerSupplyStep);
  504. //}
  505. recipe = (DepRecipe)PropertyUtil.Clone(Recipe);
  506. recipe.CreateDate = DateTime.Now;
  507. recipe.Ppid = recipeNameDialog.RecipeName;
  508. recipe.Description = recipeNameDialog.RecipeDescription;
  509. }
  510. else if (recipeNameDialog.RecipeName != null)
  511. {
  512. MessageBox.Show("Name can not be Null", "Create Recipe", MessageBoxButton.OK, MessageBoxImage.Error);
  513. return;
  514. }
  515. else
  516. {
  517. return;
  518. }
  519. }
  520. try
  521. {
  522. _uiRecipeManager.SaveRecipe<DepRecipe>(ENGINEERING, recipe.Ppid, "dep", recipe);
  523. LoadRecipeData();
  524. MessageBox.Show("Save As Recipe Success", "SaveAs Recipe", MessageBoxButton.OK, MessageBoxImage.Information);
  525. Enable = false;
  526. }
  527. catch (Exception ex)
  528. {
  529. MessageBox.Show(ex.Message, "Save As Recipe", MessageBoxButton.OK, MessageBoxImage.Error);
  530. }
  531. }
  532. }
  533. /// <summary>
  534. /// 检验名称是否已经存在
  535. /// </summary>
  536. /// <param name="name"></param>
  537. /// <returns></returns>
  538. private bool CheckNameExist(string name)
  539. {
  540. foreach (string item in _recipeNodeDic.Keys)
  541. {
  542. if (item == name)
  543. {
  544. MessageBox.Show($"{name} is exsit", "Save Recipe", MessageBoxButton.OK, MessageBoxImage.Error);
  545. return true;
  546. }
  547. }
  548. return false;
  549. }
  550. /// <summary>
  551. /// 检验合法性
  552. /// </summary>
  553. /// <param name="editType"></param>
  554. /// <returns></returns>
  555. private bool CheckValid(bool editType)
  556. {
  557. foreach(string key in _propertyValidResultDic.Keys)
  558. {
  559. bool valid = _propertyValidResultDic[key];
  560. if(!valid)
  561. {
  562. MessageBox.Show($"{key} data invalid", "Save Recipe", MessageBoxButton.OK, MessageBoxImage.Error);
  563. return false;
  564. }
  565. }
  566. return true;
  567. }
  568. /// <summary>
  569. /// 更新表格显示
  570. /// </summary>
  571. private void UpdateDataGridShow()
  572. {
  573. if(Recipe!=null)
  574. {
  575. if(Recipe.AnodeType==0)
  576. {
  577. MultiZoneShow = true;
  578. }
  579. else
  580. {
  581. MultiZoneShow = false;
  582. }
  583. }
  584. }
  585. #region Ramp按钮
  586. /// <summary>
  587. /// 增加
  588. /// </summary>
  589. /// <param name="param"></param>
  590. private void AddBelowAction(object param)
  591. {
  592. if (Recipe != null)
  593. {
  594. CurrentRampProfile currentRampProfile = new CurrentRampProfile();
  595. Recipe.CurrentRampProfileSteps.Insert(SelectedRampIndex + 1, currentRampProfile);
  596. SelectedRampIndex++;
  597. }
  598. }
  599. /// <summary>
  600. /// 增加
  601. /// </summary>
  602. /// <param name="param"></param>
  603. private void AddAboveAction(object param)
  604. {
  605. if (Recipe != null)
  606. {
  607. CurrentRampProfile currentRampProfile = new CurrentRampProfile();
  608. if (SelectedRampIndex == -1)
  609. {
  610. Recipe.CurrentRampProfileSteps.Add(currentRampProfile);
  611. SelectedRampIndex = 0;
  612. }
  613. else
  614. {
  615. Recipe.CurrentRampProfileSteps.Insert(SelectedRampIndex, currentRampProfile);
  616. SelectedRampIndex--;
  617. }
  618. }
  619. }
  620. /// <summary>
  621. /// 上移
  622. /// </summary>
  623. /// <param name="param"></param>
  624. private void MoveUpAction(object param)
  625. {
  626. if (Recipe != null)
  627. {
  628. if(SelectedRampIndex>0)
  629. {
  630. int currentIndex = SelectedRampIndex;
  631. CurrentRampProfile currentRampProfile = Recipe.CurrentRampProfileSteps[SelectedRampIndex];
  632. Recipe.CurrentRampProfileSteps.RemoveAt(SelectedRampIndex);
  633. Recipe.CurrentRampProfileSteps.Insert(currentIndex - 1,currentRampProfile);
  634. SelectedRampIndex = currentIndex - 1;
  635. }
  636. }
  637. }
  638. /// <summary>
  639. /// 下移
  640. /// </summary>
  641. /// <param name="param"></param>
  642. private void MoveDownAction(object param)
  643. {
  644. if (Recipe != null)
  645. {
  646. if (SelectedRampIndex>=0&&SelectedRampIndex <Recipe.CurrentRampProfileSteps.Count-1 &&Recipe.CurrentRampProfileSteps.Count>1)
  647. {
  648. int currentIndex = SelectedRampIndex;
  649. CurrentRampProfile currentRampProfile = Recipe.CurrentRampProfileSteps[SelectedRampIndex];
  650. Recipe.CurrentRampProfileSteps.RemoveAt(SelectedRampIndex);
  651. Recipe.CurrentRampProfileSteps.Insert(currentIndex + 1, currentRampProfile);
  652. SelectedRampIndex = currentIndex + 1;
  653. }
  654. }
  655. }
  656. /// <summary>
  657. /// 删除
  658. /// </summary>
  659. /// <param name="param"></param>
  660. private void DeleteAction(object param)
  661. {
  662. if (SelectedRampIndex != -1)
  663. {
  664. if (Recipe != null && Recipe.CurrentRampProfileSteps.Count > SelectedRampIndex)
  665. {
  666. Recipe.CurrentRampProfileSteps.RemoveAt(SelectedRampIndex);
  667. }
  668. }
  669. }
  670. #endregion
  671. #region Pulse按钮
  672. /// <summary>
  673. /// 增加
  674. /// </summary>
  675. /// <param name="param"></param>
  676. private void AddBelowPulseAction(object param)
  677. {
  678. if (Recipe != null)
  679. {
  680. if (Recipe.PulsePowerSupplySteps.Count < 4)
  681. {
  682. PulsePowerSupplyStep pulsePowerSupplyStep = new PulsePowerSupplyStep();
  683. Recipe.PulsePowerSupplySteps.Insert(SelectedPulseIndex + 1, pulsePowerSupplyStep);
  684. SelectedPulseIndex++;
  685. }
  686. }
  687. }
  688. /// <summary>
  689. /// 增加
  690. /// </summary>
  691. /// <param name="param"></param>
  692. private void AddAbovePulseAction(object param)
  693. {
  694. if (Recipe != null)
  695. {
  696. if (Recipe.PulsePowerSupplySteps.Count < 4)
  697. {
  698. PulsePowerSupplyStep pulsePowerSupplyStep = new PulsePowerSupplyStep();
  699. if (SelectedPulseIndex == -1)
  700. {
  701. Recipe.PulsePowerSupplySteps.Add(pulsePowerSupplyStep);
  702. SelectedPulseIndex = 0;
  703. }
  704. else
  705. {
  706. Recipe.PulsePowerSupplySteps.Insert(SelectedPulseIndex, pulsePowerSupplyStep);
  707. SelectedPulseIndex--;
  708. }
  709. }
  710. }
  711. }
  712. /// <summary>
  713. /// 上移
  714. /// </summary>
  715. /// <param name="param"></param>
  716. private void MoveUpPulseAction(object param)
  717. {
  718. if (Recipe != null)
  719. {
  720. if (SelectedPulseIndex > 0)
  721. {
  722. int currentIndex = SelectedPulseIndex;
  723. PulsePowerSupplyStep pulsePowerSupplyStep = Recipe.PulsePowerSupplySteps[currentIndex];
  724. Recipe.PulsePowerSupplySteps.RemoveAt(currentIndex);
  725. Recipe.PulsePowerSupplySteps.Insert(currentIndex - 1, pulsePowerSupplyStep);
  726. SelectedPulseIndex = currentIndex - 1;
  727. }
  728. }
  729. }
  730. /// <summary>
  731. /// 下移
  732. /// </summary>
  733. /// <param name="param"></param>
  734. private void MoveDownPulseAction(object param)
  735. {
  736. if (Recipe != null)
  737. {
  738. if (SelectedPulseIndex >= 0 && SelectedPulseIndex < Recipe.PulsePowerSupplySteps.Count - 1 && Recipe.PulsePowerSupplySteps.Count > 1)
  739. {
  740. int currentIndex = SelectedPulseIndex;
  741. PulsePowerSupplyStep pulsePowerSupplyStep = Recipe.PulsePowerSupplySteps[currentIndex];
  742. Recipe.PulsePowerSupplySteps.RemoveAt(currentIndex);
  743. Recipe.PulsePowerSupplySteps.Insert(currentIndex + 1, pulsePowerSupplyStep);
  744. SelectedPulseIndex = currentIndex + 1;
  745. }
  746. }
  747. }
  748. /// <summary>
  749. /// 删除
  750. /// </summary>
  751. /// <param name="param"></param>
  752. private void DeletePulseAction(object param)
  753. {
  754. if (Recipe != null)
  755. {
  756. if(SelectedPulseIndex!=-1&&Recipe.PulsePowerSupplySteps.Count>SelectedPulseIndex)
  757. {
  758. Recipe.PulsePowerSupplySteps.RemoveAt(SelectedPulseIndex);
  759. }
  760. }
  761. }
  762. #endregion
  763. #endregion
  764. }
  765. }