ProcessHistoryViewModel.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  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 Venus_Core;
  10. using Prism.Commands;
  11. using Prism.Mvvm;
  12. using Venus_MainPages.Unity;
  13. using Venus_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 Venus_Themes.UserControls;
  33. using Aitex.Core.UI.Control;
  34. using System.Windows.Annotations;
  35. using System.Runtime.Serialization;
  36. namespace Venus_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. item.RecipeType= dbData.Rows[i]["recipe_type"].ToString();
  194. if (!dbData.Rows[i]["process_begin_time"].Equals(DBNull.Value))
  195. item.StartTime = ((DateTime)dbData.Rows[i]["process_begin_time"]).ToString("yyyy-MM-dd HH:mm:ss");
  196. if (!dbData.Rows[i]["process_end_time"].Equals(DBNull.Value))
  197. item.EndTime = ((DateTime)dbData.Rows[i]["process_end_time"]).ToString("yyyy-MM-dd HH:mm:ss");
  198. Recipes.Add(item);
  199. }
  200. }));
  201. }
  202. catch (Exception e)
  203. {
  204. LOG.WriteExeption(e);
  205. }
  206. }
  207. public void SearchRecipe(DateTime start, DateTime end)
  208. {
  209. this.StartDateTime = start;
  210. this.EndDateTime = end;
  211. Recipes.Clear();
  212. try
  213. {
  214. 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")}' ";
  215. if (!string.IsNullOrEmpty(SelectedValuePM))
  216. {
  217. string[] pms = SelectedValuePM.Split(',');
  218. if (pms.Length > 0)
  219. {
  220. sql += " and (FALSE ";
  221. foreach (var pm in pms)
  222. {
  223. sql += $" OR \"process_in\"='{pm}' ";
  224. }
  225. sql += " ) ";
  226. }
  227. }
  228. if (!string.IsNullOrEmpty(RecipeName))
  229. {
  230. sql += string.Format(" and lower(\"recipe_name\") like '%{0}%'", RecipeName.ToLower());
  231. }
  232. sql += " order by \"process_begin_time\" ASC;";
  233. DataTable dbData = QueryDataClient.Instance.Service.QueryData(sql);
  234. System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  235. {
  236. if (dbData == null || dbData.Rows.Count == 0) return;
  237. for (int i = 0; i < dbData.Rows.Count; i++)
  238. {
  239. RecipeItem item = new RecipeItem();
  240. item.Selected = false;
  241. item.Recipe = dbData.Rows[i]["recipe_name"].ToString();
  242. item.Guid = dbData.Rows[i]["guid"].ToString();
  243. item.RecipeRunGuid = dbData.Rows[i]["wafer_data_guid"].ToString();
  244. item.Chamber = dbData.Rows[i]["process_in"].ToString();
  245. item.Status = dbData.Rows[i]["process_status"].ToString();
  246. item.SlotID = dbData.Rows[i]["slot_id"].ToString();
  247. item.RecipeType = dbData.Rows[i]["recipe_type"].ToString();
  248. item.LotID = dbData.Rows[i]["lot_id"].ToString();
  249. if (!dbData.Rows[i]["process_begin_time"].Equals(DBNull.Value))
  250. item.StartTime = ((DateTime)dbData.Rows[i]["process_begin_time"]).ToString("yyyy-MM-dd HH:mm:ss");
  251. if (!dbData.Rows[i]["process_end_time"].Equals(DBNull.Value))
  252. item.EndTime = ((DateTime)dbData.Rows[i]["process_end_time"]).ToString("yyyy-MM-dd HH:mm:ss");
  253. Recipes.Add(item);
  254. }
  255. }));
  256. }
  257. catch (Exception e)
  258. {
  259. LOG.WriteExeption(e);
  260. }
  261. }
  262. private void CalKeys(ParameterNode parameterNode)
  263. {
  264. if (parameterNode.ChildNodes.Count > 0)
  265. {
  266. foreach (var item in parameterNode.ChildNodes)
  267. {
  268. CalKeys(item);
  269. }
  270. }
  271. else
  272. {
  273. if (parameterNode.Selected == true)
  274. {
  275. keys.Add(parameterNode.Name);
  276. }
  277. }
  278. }
  279. private Dictionary<string, List<HistoryDataItem>> GetData(List<string> keys, DateTime from, DateTime to)
  280. {
  281. string sql = "select time AS InternalTimeStamp";
  282. foreach (var dataId in keys)
  283. {
  284. sql += "," + string.Format("\"{0}\"", dataId);
  285. }
  286. sql += string.Format(" from \"{0}\" where time > {1} and time <= {2} order by time asc",
  287. from.ToString("yyyyMMdd") + "." + "Data", from.Ticks, to.Ticks);
  288. DataTable dataTable = QueryDataClient.Instance.Service.QueryData(sql);
  289. Dictionary<string, List<HistoryDataItem>> historyData = new Dictionary<string, List<HistoryDataItem>>();
  290. if (dataTable == null || dataTable.Rows.Count == 0)
  291. return null;
  292. DateTime dt = new DateTime();
  293. Dictionary<int, string> colName = new Dictionary<int, string>();
  294. for (int colNo = 0; colNo < dataTable.Columns.Count; colNo++)
  295. {
  296. colName.Add(colNo, dataTable.Columns[colNo].ColumnName);
  297. historyData[dataTable.Columns[colNo].ColumnName] = new List<HistoryDataItem>();
  298. }
  299. for (int rowNo = 0; rowNo < dataTable.Rows.Count; rowNo++)
  300. {
  301. PointCollection points = new PointCollection();
  302. var row = dataTable.Rows[rowNo];
  303. for (int i = 0; i < dataTable.Columns.Count; i++)
  304. {
  305. HistoryDataItem data = new HistoryDataItem();
  306. if (i == 0)
  307. {
  308. long ticks = (long)row[i];
  309. dt = new DateTime(ticks);
  310. continue;
  311. }
  312. else
  313. {
  314. string dataId = colName[i];
  315. if (row[i] is DBNull || row[i] == null)
  316. {
  317. data.dateTime = dt;
  318. data.dbName = colName[i];
  319. data.value = 0;
  320. }
  321. else if (row[i] is bool)
  322. {
  323. data.dateTime = dt;
  324. data.dbName = colName[i];
  325. data.value = (bool)row[i] ? 1 : 0;
  326. }
  327. else
  328. {
  329. data.dateTime = dt;
  330. data.dbName = colName[i];
  331. data.value = float.Parse(row[i].ToString());
  332. }
  333. }
  334. historyData[data.dbName].Add(data);
  335. }
  336. }
  337. foreach (var item in historyData)
  338. {
  339. item.Value.Sort((x, y) => DateTime.Compare(x.dateTime, y.dateTime));
  340. }
  341. return historyData;
  342. }
  343. private bool RefreshTreeStatusToChild(ParameterNode node)
  344. {
  345. if (node.ChildNodes.Count > 0)
  346. {
  347. for (int i = 0; i < node.ChildNodes.Count; i++)
  348. {
  349. ParameterNode n = node.ChildNodes[i];
  350. n.Selected = node.Selected;
  351. if (!RefreshTreeStatusToChild(n))
  352. {
  353. //uncheck left node
  354. for (int j = i; j < node.ChildNodes.Count; j++)
  355. {
  356. node.ChildNodes[j].Selected = !node.Selected;
  357. }
  358. //node.Selected = !node.Selected;
  359. return false;
  360. }
  361. }
  362. }
  363. //else
  364. //{
  365. // if (node.Selected == true)
  366. // {
  367. // keys.Add(node.Name);
  368. // }
  369. // else
  370. // {
  371. // keys.Remove(node.Name);
  372. // }
  373. //}
  374. return true;
  375. }
  376. private void RefreshTreeStatusToParent(ParameterNode node)
  377. {
  378. if (node.ParentNode != null)
  379. {
  380. if (node.Selected)
  381. {
  382. bool flag = true;
  383. for (int i = 0; i < node.ParentNode.ChildNodes.Count; i++)
  384. {
  385. if (!node.ParentNode.ChildNodes[i].Selected)
  386. {
  387. flag = false; //as least one child is unselected
  388. break;
  389. }
  390. }
  391. if (flag)
  392. node.ParentNode.Selected = true;
  393. }
  394. else
  395. {
  396. node.ParentNode.Selected = false;
  397. }
  398. RefreshTreeStatusToParent(node.ParentNode);
  399. }
  400. }
  401. public static T DeepCopyJson<T>(T obj)
  402. {
  403. // 序列化
  404. string json = JsonConvert.SerializeObject(obj);
  405. // 反序列化
  406. return JsonConvert.DeserializeObject<T>(json);
  407. }
  408. private void OnParameterCheck(object obj)
  409. {
  410. ParameterNode node = obj as ParameterNode;
  411. if (!RefreshTreeStatusToChild(node))
  412. {
  413. node.Selected = !node.Selected;
  414. }
  415. else
  416. {
  417. RefreshTreeStatusToParent(node);
  418. }
  419. keys.Clear();
  420. for (int i = 0; i < ParameterNodes.Count; i++)
  421. {
  422. CalKeys(ParameterNodes[i]);
  423. }
  424. if (keys.Count > 10)
  425. {
  426. WPFMessageBox.ShowWarning("最多显示10个数据");
  427. return;
  428. }
  429. OldPdKeyDataCollection.Clear();
  430. OldPdKeyDataCollection = DeepCopyJson(PdKeyDataCollection);
  431. PdKeyDataCollection.Clear();
  432. for (int i = 0; i < keys.Count; i++)
  433. {
  434. if (i == 10)
  435. {
  436. break;
  437. }
  438. PdKeyDataCollection.Add(new PdKeyData() { Key = keys[i], Color = solidColorBrushes[i], UniqueId = i });
  439. }
  440. Compare(OldPdKeyDataCollection, PdKeyDataCollection);
  441. PdKeyDataCollection = DeepCopyJson(OldPdKeyDataCollection);
  442. }
  443. public void Compare(ObservableCollection<PdKeyData> olddata, ObservableCollection<PdKeyData> newdata)
  444. {
  445. if (newdata != null)
  446. {
  447. for (int i = 0; i < newdata.Count; i++)
  448. {
  449. var lists = olddata.ToList().Find(t => t.Key == newdata[i].Key);
  450. if (lists == null)
  451. {
  452. olddata.Add(new PdKeyData() { Key = newdata[i].Key, Color = solidColorBrushes[i], UniqueId = olddata.Count + 1 });
  453. }
  454. }
  455. for (int i = 0; i < olddata.Count; i++)
  456. {
  457. var lists = newdata.ToList().Find(t => t.Key == olddata[i].Key);
  458. if (lists == null)
  459. {
  460. olddata.Remove(olddata[i]);
  461. }
  462. }
  463. }
  464. }
  465. public void UpdateData(RecipeItem dataLog)
  466. {
  467. OnClearData();
  468. //CheckRecipe(dataLog.Guid);
  469. }
  470. public void CheckRecipe(string RecipeGuid)
  471. {
  472. string sql = $"SELECT * FROM \"recipe_step_data\" where \"process_data_guid\" = '{RecipeGuid}' order by step_number ASC;";
  473. var dbData = QueryDataClient.Instance.Service.QueryData(sql);
  474. List<StepData> steps = new List<StepData>();
  475. if (dbData != null && dbData.Rows.Count > 0)
  476. {
  477. for (int i = 0; i < dbData.Rows.Count; i++)
  478. {
  479. StepData item = new StepData();
  480. item.No = int.Parse(dbData.Rows[i]["step_number"].ToString());
  481. item.Name = dbData.Rows[i]["step_name"].ToString();
  482. if (!dbData.Rows[i]["step_begin_time"].Equals(DBNull.Value))
  483. item.StartTime = (DateTime)dbData.Rows[i]["step_begin_time"];
  484. if (!dbData.Rows[i]["step_end_time"].Equals(DBNull.Value))
  485. item.EndTime = (DateTime)dbData.Rows[i]["step_end_time"];
  486. item.ActualTime = item.EndTime.CompareTo(item.StartTime) <= 0 ? "" : item.EndTime.Subtract(item.StartTime).TotalSeconds.ToString();
  487. item.SettingTime = dbData.Rows[i]["step_time"].ToString();
  488. //annotation.Add(VerLine(Brushes.Blue, item.StartTime, Brushes.Blue, $"{item.No}:{item.Name}"));
  489. }
  490. }
  491. }
  492. public void OnDataGridSelectionChanged(object obj)
  493. {
  494. selectedRecipeItem = obj as RecipeItem;
  495. ParameterNodes = new ObservableCollection<ParameterNode>(_provider.GetParameters().Where(x => x.Name == selectedRecipeItem?.Chamber));
  496. }
  497. public void OnSearchData()
  498. {
  499. ProcessData.Clear();
  500. this.view.MyDrawGraphicsControl.ClearPlotPoints();
  501. var Keys = new List<string>();
  502. PdKeyDataCollection.ToList().ForEach(key =>
  503. {
  504. Keys.Add(key.Key);
  505. });
  506. if (keys.Count == 0)
  507. {
  508. return;
  509. }
  510. var result = GetData(Keys.Distinct().ToList(), Convert.ToDateTime(selectedRecipeItem?.StartTime), Convert.ToDateTime(selectedRecipeItem?.EndTime));
  511. if (result == null)
  512. {
  513. return;
  514. }
  515. List<PointCollection> cls = new List<PointCollection>();
  516. for (int i = 0; i < Keys.Count; i++)
  517. {
  518. PointCollection points = new PointCollection();
  519. int k = 1;
  520. result[Keys[i]].ForEach(point =>
  521. {
  522. ProcessData.Add(new HistoryDataItem() { dateTime= point.dateTime, dbName= Keys[i],value= point.value });
  523. points.Add(new Point() { X = point.dateTime.ToOADate(), Y = point.value });
  524. k += 1;
  525. });
  526. cls.Add(points);
  527. }
  528. for (int i = 0; i <PdKeyDataCollection.Count(); i++)
  529. {
  530. var _color = PdKeyDataCollection[i].Color.Color;
  531. view.MyDrawGraphicsControl.m_PenCollencteions[i] = new System.Drawing.Pen(System.Drawing.Color.FromArgb(_color.A, _color.R, _color.G, _color.B), 2);
  532. }
  533. this.view.MyDrawGraphicsControl.PointCollections = cls;
  534. this.view.MyDrawGraphicsControl.FitControl();
  535. this.view.MyDrawGraphicsControl.YPoints.Clear();
  536. var item = QueryDataClient.Instance.Service.GetHistorySteps(Convert.ToDateTime(selectedRecipeItem?.StartTime), Convert.ToDateTime(selectedRecipeItem?.EndTime));
  537. if (item!=null)
  538. {
  539. item.ForEach(x =>
  540. {
  541. this.view.MyDrawGraphicsControl.YPoints.Add(new Venus_Core.StepItem() { StartValue = x.StartTime.ToOADate(), Information = $"{x.RecipeId}:{x.StepNo}" });
  542. });
  543. }
  544. }
  545. private void CloseAll(ObservableCollection<ParameterNode> parameterNodes)
  546. {
  547. if (parameterNodes != null)
  548. {
  549. foreach (var item in parameterNodes)
  550. {
  551. item.Selected = false;
  552. if (item.ChildNodes.Count > 0)
  553. {
  554. CloseAll(item.ChildNodes);
  555. }
  556. }
  557. }
  558. }
  559. private void OnClearData()
  560. {
  561. this.view.MyDrawGraphicsControl.YPoints.Clear();
  562. PdKeyDataCollection.Clear();
  563. this.view.MyDrawGraphicsControl.ClearPlotPoints();
  564. CloseAll(ParameterNodes);
  565. }
  566. }
  567. #endregion
  568. #region 数据类
  569. public class RecipeItem : BindableBase
  570. {
  571. public bool Selected { get; set; }
  572. public string Recipe { get; set; }
  573. public string Guid { get; set; }
  574. public string RecipeRunGuid { get; set; }
  575. public string Chamber { get; set; }
  576. public string Status { get; set; }
  577. public string StartTime { get; set; }
  578. public string EndTime { get; set; }
  579. public string LotID { get; set; }
  580. public string SlotID { get; set; }
  581. public string RecipeType { get; set; }
  582. }
  583. public class StepData
  584. {
  585. [DataMember]
  586. public int No { get; set; }
  587. [DataMember]
  588. public string Name { get; set; }
  589. [DataMember]
  590. public DateTime StartTime { get; set; }
  591. [DataMember]
  592. public DateTime EndTime { get; set; }
  593. [DataMember]
  594. public string ActualTime { get; set; }
  595. [DataMember]
  596. public string SettingTime { get; set; }
  597. }
  598. public class PdKeyData : BindableBase, ICloneable
  599. {
  600. public string Key { get; set; }
  601. public SolidColorBrush _Color;
  602. public SolidColorBrush Color
  603. {
  604. get { return _Color; }
  605. set { SetProperty(ref _Color, value); }
  606. }
  607. public int UniqueId { get; set; }
  608. public object Clone()
  609. {
  610. return MemberwiseClone();
  611. }
  612. }
  613. #endregion
  614. }