ProcessHistoryViewModel.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  1. using MECF.Framework.Common.DataCenter;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Windows.Media;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using CyberX8_Core;
  10. using Prism.Commands;
  11. using Prism.Mvvm;
  12. using CyberX8_MainPages.Unity;
  13. using CyberX8_MainPages.Views;
  14. using System.Collections.ObjectModel;
  15. using System.Windows.Threading;
  16. using System.Windows;
  17. using Aitex.Core.RT.Log;
  18. using Aitex.Core.UI.ControlDataContext;
  19. using WPF.Themes.UserControls;
  20. using System.IO;
  21. using System.Diagnostics;
  22. using Aitex.Core.RT.Routine;
  23. using System.Xml.Linq;
  24. using System.Windows.Forms;
  25. using ExcelLibrary.BinaryFileFormat;
  26. using Aitex.Core.UI.View.Common;
  27. using Aitex.Core.RT.DataCenter;
  28. using System.Xml;
  29. using System.Security.Cryptography.X509Certificates;
  30. using System.Reflection;
  31. using Newtonsoft.Json;
  32. using CyberX8_Themes.UserControls;
  33. using Aitex.Core.UI.Control;
  34. using System.Windows.Annotations;
  35. using System.Runtime.Serialization;
  36. namespace CyberX8_MainPages.ViewModels
  37. {
  38. public class ProcessHistoryViewModel : BindableBase
  39. {
  40. #region 私有字段
  41. private ProcessHistoryView view;
  42. List<string> keys = new List<string>();
  43. RealtimeProvider _provider = new RealtimeProvider();
  44. private ObservableCollection<ParameterNode> _ParameterNodes;
  45. DispatcherTimer timer = new DispatcherTimer();
  46. ObservableCollection<PdKeyData> _PdKeyDataObservation = new ObservableCollection<PdKeyData>();
  47. public List<string> RecipesAdd = new List<string>();
  48. public List<SolidColorBrush> solidColorBrushes = new List<SolidColorBrush>();
  49. //DateTime currentTime;
  50. private RecipeItem selectedRecipeItem;
  51. #endregion
  52. #region 属性
  53. public List<HistoryDataItem> ProcessData { get; set; }
  54. public List<Recipeslist> CheboxRecipes { get; set; }
  55. public ProcessDataChartDataItem ProcessChartData { get; set; }
  56. public DateTime StartDateTime { get; set; }
  57. public DateTime EndDateTime { get; set; }
  58. public string SelectedValuePM { get; set; }
  59. public string RecipeName { get; set; }
  60. public ObservableCollection<PdKeyData> OldPdKeyDataCollection { get; set; }
  61. public ObservableCollection<RecipeItem> Recipes { get; set; }
  62. public class Recipeslist
  63. {
  64. public string BoxName { get; set; }
  65. }
  66. public class RecipeAdd
  67. {
  68. public string Recipesname { get; set; }
  69. }
  70. public ObservableCollection<ParameterNode> ParameterNodes
  71. {
  72. get { return _ParameterNodes; }
  73. set { SetProperty(ref _ParameterNodes, value); }
  74. }
  75. public ObservableCollection<PdKeyData> PdKeyDataCollection
  76. {
  77. get { return _PdKeyDataObservation; }
  78. set { SetProperty(ref _PdKeyDataObservation, value); }
  79. }
  80. #endregion
  81. #region 命令
  82. private DelegateCommand<object> _LoadCommandPD;
  83. public DelegateCommand<object> LoadCommandPD =>
  84. _LoadCommandPD ?? (_LoadCommandPD = new DelegateCommand<object>(OnLoadPd));
  85. private DelegateCommand _SearchRecipeCommand;
  86. public DelegateCommand SearchRecipeCommand =>
  87. _SearchRecipeCommand ?? (_SearchRecipeCommand = new DelegateCommand(SearchRecipes));
  88. private DelegateCommand<object> _PdParameterCheckCommand;
  89. public DelegateCommand<object> PdParameterCheckCommand =>
  90. _PdParameterCheckCommand ?? (_PdParameterCheckCommand = new DelegateCommand<object>(OnParameterCheck));
  91. private DelegateCommand<object> _DataGridSelectionChangedCommand;
  92. public DelegateCommand<object> DataGridSelectionChangedCommand =>
  93. _DataGridSelectionChangedCommand ?? (_DataGridSelectionChangedCommand = new DelegateCommand<object>(OnDataGridSelectionChanged));
  94. private DelegateCommand _SearchDataCommand;
  95. public DelegateCommand SearchDataCommand =>
  96. _SearchDataCommand ?? (_SearchDataCommand = new DelegateCommand(OnSearchData));
  97. private DelegateCommand _ClearDataCommand;
  98. public DelegateCommand ClearDataCommand =>
  99. _ClearDataCommand ?? (_ClearDataCommand = new DelegateCommand(OnClearData));
  100. #endregion
  101. #region 构造函数
  102. public ProcessHistoryViewModel()
  103. {
  104. ProcessData = new List<HistoryDataItem>() { };
  105. ProcessChartData = new ProcessDataChartDataItem(60000);
  106. Recipes = new ObservableCollection<RecipeItem>();
  107. timer.Interval = TimeSpan.FromSeconds(0.5);
  108. OldPdKeyDataCollection = new ObservableCollection<PdKeyData>();
  109. CheboxRecipes = new List<Recipeslist>();
  110. solidColorBrushes.Add(new SolidColorBrush(Colors.Green));
  111. solidColorBrushes.Add(new SolidColorBrush(Colors.Red));
  112. solidColorBrushes.Add(new SolidColorBrush(Colors.Blue));
  113. solidColorBrushes.Add(new SolidColorBrush(Colors.Orange));
  114. solidColorBrushes.Add(new SolidColorBrush(Colors.Yellow));
  115. solidColorBrushes.Add(new SolidColorBrush(Colors.YellowGreen));
  116. solidColorBrushes.Add(new SolidColorBrush(Colors.AliceBlue));
  117. solidColorBrushes.Add(new SolidColorBrush(Colors.Chocolate));
  118. solidColorBrushes.Add(new SolidColorBrush(Colors.Cyan));
  119. solidColorBrushes.Add(new SolidColorBrush(Colors.DarkGreen));
  120. }
  121. #endregion
  122. #region 命令方法
  123. private void OnLoadPd(Object eventView)
  124. {
  125. this.view = (ProcessHistoryView)eventView;
  126. this.view.wfTimeFrom.Value = DateTime.Today;
  127. this.view.wfTimeTo.Value = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 23, 59, 59, 999);
  128. this.LoadRecipeCheckBox();
  129. }
  130. private void LoadRecipeCheckBox()
  131. {
  132. List<string> chamber = new List<string>() { "PMA", "PMB", "PMC", "PMD" };
  133. CheboxRecipes.Clear();
  134. foreach (string item in chamber)
  135. {
  136. string path = Path.Combine(QueryDataClient.Instance.Service.GetData("GetRTPath").ToString(), "Recipes", item);
  137. if (Directory.Exists(path))
  138. {
  139. string[] dir = Directory.GetFiles(path);
  140. for (int i = 0; i < dir.Length; i++)
  141. {
  142. CheboxRecipes.Add(new Recipeslist { BoxName = Path.GetFileName(dir[i]) });
  143. }
  144. }
  145. }
  146. }
  147. public void SearchRecipes()
  148. {
  149. SearchRecipe(this.view.wfTimeFrom.Value, this.view.wfTimeTo.Value);
  150. }
  151. public void searchlot(string id)
  152. {
  153. Recipes.Clear();
  154. try
  155. {
  156. string sql1 = string.Format($"SELECT * FROM \"lot_wafer_data\" where guid ='{id}'; ");
  157. DataTable dbData1 = QueryDataClient.Instance.Service.QueryData(sql1);
  158. string lot_data_guid = dbData1.Rows[0]["wafer_data_guid"].ToString();
  159. string sql = string.Format($"SELECT * FROM \"process_data\" where wafer_data_guid ='{lot_data_guid}'");
  160. if (!string.IsNullOrEmpty(SelectedValuePM))
  161. {
  162. string[] pms = SelectedValuePM.Split(',');
  163. if (pms.Length > 0)
  164. {
  165. sql += " and (FALSE ";
  166. foreach (var pm in pms)
  167. {
  168. sql += $" OR \"process_in\"='{pm}' ";
  169. }
  170. sql += " ) ";
  171. }
  172. }
  173. if (!string.IsNullOrEmpty(RecipeName))
  174. {
  175. sql += string.Format(" and lower(\"recipe_name\") like '%{0}%'", RecipeName.ToLower());
  176. }
  177. sql += " order by \"process_begin_time\" ASC;";
  178. DataTable dbData = QueryDataClient.Instance.Service.QueryData(sql);
  179. System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  180. {
  181. if (dbData == null || dbData.Rows.Count == 0) return;
  182. for (int i = 0; i < dbData.Rows.Count; i++)
  183. {
  184. RecipeItem item = new RecipeItem();
  185. item.Selected = false;
  186. item.Recipe = dbData.Rows[i]["recipe_name"].ToString();
  187. item.Guid = dbData.Rows[i]["guid"].ToString();
  188. item.RecipeRunGuid = dbData.Rows[i]["wafer_data_guid"].ToString();
  189. item.Chamber = dbData.Rows[i]["process_in"].ToString();
  190. item.Status = dbData.Rows[i]["process_status"].ToString();
  191. item.SlotID = dbData.Rows[i]["slot_id"].ToString();
  192. item.LotID = dbData.Rows[i]["lot_id"].ToString();
  193. if (!dbData.Rows[i]["process_begin_time"].Equals(DBNull.Value))
  194. item.StartTime = ((DateTime)dbData.Rows[i]["process_begin_time"]).ToString("yyyy-MM-dd HH:mm:ss");
  195. if (!dbData.Rows[i]["process_end_time"].Equals(DBNull.Value))
  196. item.EndTime = ((DateTime)dbData.Rows[i]["process_end_time"]).ToString("yyyy-MM-dd HH:mm:ss");
  197. Recipes.Add(item);
  198. }
  199. }));
  200. }
  201. catch (Exception e)
  202. {
  203. LOG.WriteExeption(e);
  204. }
  205. }
  206. public void SearchRecipe(DateTime start, DateTime end)
  207. {
  208. this.StartDateTime = start;
  209. this.EndDateTime = end;
  210. Recipes.Clear();
  211. try
  212. {
  213. string sql = $"SELECT * FROM \"process_data\" where \"process_begin_time\" >='{StartDateTime.ToString("yyyy/MM/dd HH:mm:ss.fff")}' and \"process_begin_time\" <='{EndDateTime.ToString("yyyy/MM/dd HH:mm:ss.fff")}' ";
  214. if (!string.IsNullOrEmpty(SelectedValuePM))
  215. {
  216. string[] pms = SelectedValuePM.Split(',');
  217. if (pms.Length > 0)
  218. {
  219. sql += " and (FALSE ";
  220. foreach (var pm in pms)
  221. {
  222. sql += $" OR \"process_in\"='{pm}' ";
  223. }
  224. sql += " ) ";
  225. }
  226. }
  227. if (!string.IsNullOrEmpty(RecipeName))
  228. {
  229. sql += string.Format(" and lower(\"recipe_name\") like '%{0}%'", RecipeName.ToLower());
  230. }
  231. sql += " order by \"process_begin_time\" ASC;";
  232. DataTable dbData = QueryDataClient.Instance.Service.QueryData(sql);
  233. System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  234. {
  235. if (dbData == null || dbData.Rows.Count == 0) return;
  236. for (int i = 0; i < dbData.Rows.Count; i++)
  237. {
  238. RecipeItem item = new RecipeItem();
  239. item.Selected = false;
  240. item.Recipe = dbData.Rows[i]["recipe_name"].ToString();
  241. item.Guid = dbData.Rows[i]["guid"].ToString();
  242. item.RecipeRunGuid = dbData.Rows[i]["wafer_data_guid"].ToString();
  243. item.Chamber = dbData.Rows[i]["process_in"].ToString();
  244. item.Status = dbData.Rows[i]["process_status"].ToString();
  245. item.SlotID = dbData.Rows[i]["slot_id"].ToString();
  246. item.LotID = dbData.Rows[i]["lot_id"].ToString();
  247. if (!dbData.Rows[i]["process_begin_time"].Equals(DBNull.Value))
  248. item.StartTime = ((DateTime)dbData.Rows[i]["process_begin_time"]).ToString("yyyy-MM-dd HH:mm:ss");
  249. if (!dbData.Rows[i]["process_end_time"].Equals(DBNull.Value))
  250. item.EndTime = ((DateTime)dbData.Rows[i]["process_end_time"]).ToString("yyyy-MM-dd HH:mm:ss");
  251. Recipes.Add(item);
  252. }
  253. }));
  254. }
  255. catch (Exception e)
  256. {
  257. LOG.WriteExeption(e);
  258. }
  259. }
  260. private void CalKeys(ParameterNode parameterNode)
  261. {
  262. if (parameterNode.ChildNodes.Count > 0)
  263. {
  264. foreach (var item in parameterNode.ChildNodes)
  265. {
  266. CalKeys(item);
  267. }
  268. }
  269. else
  270. {
  271. if (parameterNode.Selected == true)
  272. {
  273. keys.Add(parameterNode.Name);
  274. }
  275. }
  276. }
  277. private Dictionary<string, List<HistoryDataItem>> GetData(List<string> keys, DateTime from, DateTime to)
  278. {
  279. string sql = "select time AS InternalTimeStamp";
  280. foreach (var dataId in keys)
  281. {
  282. sql += "," + string.Format("\"{0}\"", dataId);
  283. }
  284. sql += string.Format(" from \"{0}\" where time > {1} and time <= {2} order by time asc",
  285. from.ToString("yyyyMMdd") + "." + "Data", from.Ticks, to.Ticks);
  286. DataTable dataTable = QueryDataClient.Instance.Service.QueryData(sql);
  287. Dictionary<string, List<HistoryDataItem>> historyData = new Dictionary<string, List<HistoryDataItem>>();
  288. if (dataTable == null || dataTable.Rows.Count == 0)
  289. return null;
  290. DateTime dt = new DateTime();
  291. Dictionary<int, string> colName = new Dictionary<int, string>();
  292. for (int colNo = 0; colNo < dataTable.Columns.Count; colNo++)
  293. {
  294. colName.Add(colNo, dataTable.Columns[colNo].ColumnName);
  295. historyData[dataTable.Columns[colNo].ColumnName] = new List<HistoryDataItem>();
  296. }
  297. for (int rowNo = 0; rowNo < dataTable.Rows.Count; rowNo++)
  298. {
  299. PointCollection points = new PointCollection();
  300. var row = dataTable.Rows[rowNo];
  301. for (int i = 0; i < dataTable.Columns.Count; i++)
  302. {
  303. HistoryDataItem data = new HistoryDataItem();
  304. if (i == 0)
  305. {
  306. long ticks = (long)row[i];
  307. dt = new DateTime(ticks);
  308. continue;
  309. }
  310. else
  311. {
  312. string dataId = colName[i];
  313. if (row[i] is DBNull || row[i] == null)
  314. {
  315. data.dateTime = dt;
  316. data.dbName = colName[i];
  317. data.value = 0;
  318. }
  319. else if (row[i] is bool)
  320. {
  321. data.dateTime = dt;
  322. data.dbName = colName[i];
  323. data.value = (bool)row[i] ? 1 : 0;
  324. }
  325. else
  326. {
  327. data.dateTime = dt;
  328. data.dbName = colName[i];
  329. data.value = float.Parse(row[i].ToString());
  330. }
  331. }
  332. historyData[data.dbName].Add(data);
  333. }
  334. }
  335. foreach (var item in historyData)
  336. {
  337. item.Value.Sort((x, y) => DateTime.Compare(x.dateTime, y.dateTime));
  338. }
  339. return historyData;
  340. }
  341. private bool RefreshTreeStatusToChild(ParameterNode node)
  342. {
  343. if (node.ChildNodes.Count > 0)
  344. {
  345. for (int i = 0; i < node.ChildNodes.Count; i++)
  346. {
  347. ParameterNode n = node.ChildNodes[i];
  348. n.Selected = node.Selected;
  349. if (!RefreshTreeStatusToChild(n))
  350. {
  351. //uncheck left node
  352. for (int j = i; j < node.ChildNodes.Count; j++)
  353. {
  354. node.ChildNodes[j].Selected = !node.Selected;
  355. }
  356. //node.Selected = !node.Selected;
  357. return false;
  358. }
  359. }
  360. }
  361. //else
  362. //{
  363. // if (node.Selected == true)
  364. // {
  365. // keys.Add(node.Name);
  366. // }
  367. // else
  368. // {
  369. // keys.Remove(node.Name);
  370. // }
  371. //}
  372. return true;
  373. }
  374. private void RefreshTreeStatusToParent(ParameterNode node)
  375. {
  376. if (node.ParentNode != null)
  377. {
  378. if (node.Selected)
  379. {
  380. bool flag = true;
  381. for (int i = 0; i < node.ParentNode.ChildNodes.Count; i++)
  382. {
  383. if (!node.ParentNode.ChildNodes[i].Selected)
  384. {
  385. flag = false; //as least one child is unselected
  386. break;
  387. }
  388. }
  389. if (flag)
  390. node.ParentNode.Selected = true;
  391. }
  392. else
  393. {
  394. node.ParentNode.Selected = false;
  395. }
  396. RefreshTreeStatusToParent(node.ParentNode);
  397. }
  398. }
  399. public static T DeepCopyJson<T>(T obj)
  400. {
  401. // 序列化
  402. string json = JsonConvert.SerializeObject(obj);
  403. // 反序列化
  404. return JsonConvert.DeserializeObject<T>(json);
  405. }
  406. private void OnParameterCheck(object obj)
  407. {
  408. ParameterNode node = obj as ParameterNode;
  409. if (!RefreshTreeStatusToChild(node))
  410. {
  411. node.Selected = !node.Selected;
  412. }
  413. else
  414. {
  415. RefreshTreeStatusToParent(node);
  416. }
  417. keys.Clear();
  418. for (int i = 0; i < ParameterNodes.Count; i++)
  419. {
  420. CalKeys(ParameterNodes[i]);
  421. }
  422. if (keys.Count > 10)
  423. {
  424. WPFMessageBox.ShowWarning("最多显示10个数据");
  425. return;
  426. }
  427. OldPdKeyDataCollection.Clear();
  428. OldPdKeyDataCollection = DeepCopyJson(PdKeyDataCollection);
  429. PdKeyDataCollection.Clear();
  430. for (int i = 0; i < keys.Count; i++)
  431. {
  432. if (i == 10)
  433. {
  434. break;
  435. }
  436. PdKeyDataCollection.Add(new PdKeyData() { Key = keys[i], Color = solidColorBrushes[i], UniqueId = i });
  437. }
  438. Compare(OldPdKeyDataCollection, PdKeyDataCollection);
  439. PdKeyDataCollection = DeepCopyJson(OldPdKeyDataCollection);
  440. }
  441. public void Compare(ObservableCollection<PdKeyData> olddata, ObservableCollection<PdKeyData> newdata)
  442. {
  443. if (newdata != null)
  444. {
  445. for (int i = 0; i < newdata.Count; i++)
  446. {
  447. var lists = olddata.ToList().Find(t => t.Key == newdata[i].Key);
  448. if (lists == null)
  449. {
  450. olddata.Add(new PdKeyData() { Key = newdata[i].Key, Color = solidColorBrushes[i], UniqueId = olddata.Count + 1 });
  451. }
  452. }
  453. for (int i = 0; i < olddata.Count; i++)
  454. {
  455. var lists = newdata.ToList().Find(t => t.Key == olddata[i].Key);
  456. if (lists == null)
  457. {
  458. olddata.Remove(olddata[i]);
  459. }
  460. }
  461. }
  462. }
  463. public void UpdateData(RecipeItem dataLog)
  464. {
  465. OnClearData();
  466. //CheckRecipe(dataLog.Guid);
  467. }
  468. public void CheckRecipe(string RecipeGuid)
  469. {
  470. string sql = $"SELECT * FROM \"recipe_step_data\" where \"process_data_guid\" = '{RecipeGuid}' order by step_number ASC;";
  471. var dbData = QueryDataClient.Instance.Service.QueryData(sql);
  472. List<StepData> steps = new List<StepData>();
  473. if (dbData != null && dbData.Rows.Count > 0)
  474. {
  475. for (int i = 0; i < dbData.Rows.Count; i++)
  476. {
  477. StepData item = new StepData();
  478. item.No = int.Parse(dbData.Rows[i]["step_number"].ToString());
  479. item.Name = dbData.Rows[i]["step_name"].ToString();
  480. if (!dbData.Rows[i]["step_begin_time"].Equals(DBNull.Value))
  481. item.StartTime = (DateTime)dbData.Rows[i]["step_begin_time"];
  482. if (!dbData.Rows[i]["step_end_time"].Equals(DBNull.Value))
  483. item.EndTime = (DateTime)dbData.Rows[i]["step_end_time"];
  484. item.ActualTime = item.EndTime.CompareTo(item.StartTime) <= 0 ? "" : item.EndTime.Subtract(item.StartTime).TotalSeconds.ToString();
  485. item.SettingTime = dbData.Rows[i]["step_time"].ToString();
  486. //annotation.Add(VerLine(Brushes.Blue, item.StartTime, Brushes.Blue, $"{item.No}:{item.Name}"));
  487. }
  488. }
  489. }
  490. public void OnDataGridSelectionChanged(object obj)
  491. {
  492. selectedRecipeItem = obj as RecipeItem;
  493. ParameterNodes = new ObservableCollection<ParameterNode>(_provider.GetParameters().Where(x => x.Name == selectedRecipeItem?.Chamber));
  494. }
  495. public void OnSearchData()
  496. {
  497. ProcessData.Clear();
  498. this.view.MyDrawGraphicsControl.ClearPlotPoints();
  499. var Keys = new List<string>();
  500. PdKeyDataCollection.ToList().ForEach(key =>
  501. {
  502. Keys.Add(key.Key);
  503. });
  504. if (keys.Count == 0)
  505. {
  506. return;
  507. }
  508. var result = GetData(Keys.Distinct().ToList(), Convert.ToDateTime(selectedRecipeItem?.StartTime), Convert.ToDateTime(selectedRecipeItem?.EndTime));
  509. if (result == null)
  510. {
  511. return;
  512. }
  513. List<PointCollection> cls = new List<PointCollection>();
  514. for (int i = 0; i < Keys.Count; i++)
  515. {
  516. PointCollection points = new PointCollection();
  517. int k = 1;
  518. result[Keys[i]].ForEach(point =>
  519. {
  520. ProcessData.Add(new HistoryDataItem() { dateTime= point.dateTime, dbName= Keys[i],value= point.value });
  521. points.Add(new Point() { X = point.dateTime.ToOADate(), Y = point.value });
  522. k += 1;
  523. });
  524. cls.Add(points);
  525. }
  526. for (int i = 0; i <PdKeyDataCollection.Count(); i++)
  527. {
  528. var _color = PdKeyDataCollection[i].Color.Color;
  529. view.MyDrawGraphicsControl.m_PenCollencteions[i] = new System.Drawing.Pen(System.Drawing.Color.FromArgb(_color.A, _color.R, _color.G, _color.B), 2);
  530. }
  531. this.view.MyDrawGraphicsControl.PointCollections = cls;
  532. this.view.MyDrawGraphicsControl.FitControl();
  533. this.view.MyDrawGraphicsControl.YPoints.Clear();
  534. var item = QueryDataClient.Instance.Service.GetHistorySteps(Convert.ToDateTime(selectedRecipeItem?.StartTime), Convert.ToDateTime(selectedRecipeItem?.EndTime));
  535. if (item!=null)
  536. {
  537. item.ForEach(x =>
  538. {
  539. this.view.MyDrawGraphicsControl.YPoints.Add(new CyberX8_Core.StepItem() { StartValue = x.StartTime.ToOADate(), Information = $"{x.RecipeId}:{x.StepNo}" });
  540. });
  541. }
  542. }
  543. private void CloseAll(ObservableCollection<ParameterNode> parameterNodes)
  544. {
  545. if (parameterNodes != null)
  546. {
  547. foreach (var item in parameterNodes)
  548. {
  549. item.Selected = false;
  550. if (item.ChildNodes.Count > 0)
  551. {
  552. CloseAll(item.ChildNodes);
  553. }
  554. }
  555. }
  556. }
  557. private void OnClearData()
  558. {
  559. this.view.MyDrawGraphicsControl.YPoints.Clear();
  560. PdKeyDataCollection.Clear();
  561. this.view.MyDrawGraphicsControl.ClearPlotPoints();
  562. CloseAll(ParameterNodes);
  563. }
  564. }
  565. #endregion
  566. #region 数据类
  567. public class RecipeItem : BindableBase
  568. {
  569. public bool Selected { get; set; }
  570. public string Recipe { get; set; }
  571. public string Guid { get; set; }
  572. public string RecipeRunGuid { get; set; }
  573. public string Chamber { get; set; }
  574. public string Status { get; set; }
  575. public string StartTime { get; set; }
  576. public string EndTime { get; set; }
  577. public string LotID { get; set; }
  578. public string SlotID { get; set; }
  579. }
  580. public class StepData
  581. {
  582. [DataMember]
  583. public int No { get; set; }
  584. [DataMember]
  585. public string Name { get; set; }
  586. [DataMember]
  587. public DateTime StartTime { get; set; }
  588. [DataMember]
  589. public DateTime EndTime { get; set; }
  590. [DataMember]
  591. public string ActualTime { get; set; }
  592. [DataMember]
  593. public string SettingTime { get; set; }
  594. }
  595. public class PdKeyData : BindableBase, ICloneable
  596. {
  597. public string Key { get; set; }
  598. public SolidColorBrush _Color;
  599. public SolidColorBrush Color
  600. {
  601. get { return _Color; }
  602. set { SetProperty(ref _Color, value); }
  603. }
  604. public int UniqueId { get; set; }
  605. public object Clone()
  606. {
  607. return MemberwiseClone();
  608. }
  609. }
  610. #endregion
  611. }