|
@@ -1,12 +1,307 @@
|
|
|
-using System;
|
|
|
+using MECF.Framework.Common.DataCenter;
|
|
|
+using System;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.Data;
|
|
|
+using System.Windows.Media;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
+using Venus_Core;
|
|
|
+using Prism.Commands;
|
|
|
+using Prism.Mvvm;
|
|
|
+using Venus_MainPages.Unity;
|
|
|
+using Venus_MainPages.Views;
|
|
|
+using System.Collections.ObjectModel;
|
|
|
+using System.Windows.Threading;
|
|
|
+using System.Windows;
|
|
|
+using Aitex.Core.RT.Log;
|
|
|
+
|
|
|
+using Aitex.Core.UI.ControlDataContext;
|
|
|
+using WPF.Themes.UserControls;
|
|
|
+using System.Diagnostics;
|
|
|
+using Aitex.Core.RT.Routine;
|
|
|
|
|
|
namespace Venus_MainPages.ViewModels
|
|
|
{
|
|
|
- internal class ProcessHistoryViewModel
|
|
|
+ public class ProcessHistoryViewModel:BindableBase
|
|
|
{
|
|
|
+ private ProcessHistoryView view;
|
|
|
+ List<string> keys = new List<string>();
|
|
|
+ RealtimeProvider _provider = new RealtimeProvider();
|
|
|
+ private ObservableCollection<ParameterNode> _ParameterNodes;
|
|
|
+ DispatcherTimer timer = new DispatcherTimer();
|
|
|
+ DateTime currentTime;
|
|
|
+ private DelegateCommand<object> _LoadCommand;
|
|
|
+ public DelegateCommand<object> LoadCommand =>
|
|
|
+ _LoadCommand ?? (_LoadCommand = new DelegateCommand<object>(OnLoad));
|
|
|
+
|
|
|
+ //private string _starttime;
|
|
|
+ //public string starttime
|
|
|
+ //{ get { return _starttime; } set { SetProperty(ref _starttime, value); } }
|
|
|
+ // public string starttime { get; set; }
|
|
|
+
|
|
|
+ public List<HistoryDataItem> ProcessData { get; set; }
|
|
|
+ public ProcessHistoryViewModel()
|
|
|
+ {
|
|
|
+ ProcessChartData = new ProcessDataChartDataItem(60000);
|
|
|
+ ParameterNodes = _provider.GetParameters();
|
|
|
+ Recipes = new ObservableCollection<RecipeItem>();
|
|
|
+ timer.Interval = TimeSpan.FromSeconds(0.5);
|
|
|
+ //starttime = "1999-10-01";
|
|
|
+ }
|
|
|
+ public ProcessDataChartDataItem ProcessChartData
|
|
|
+ {
|
|
|
+ get;
|
|
|
+ set;
|
|
|
+ }
|
|
|
+ private void OnLoad(Object eventView)
|
|
|
+ {
|
|
|
+ this.view = (ProcessHistoryView)eventView;
|
|
|
+ this.view.wfTimeFrom.Value = DateTime.Today;
|
|
|
+ this.view.wfTimeTo.Value = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 23, 59, 59, 999);
|
|
|
+ //this.DataHistoryView.MyDrawGraphicsControl.PointCollections=new PointCollection(new Point[] {})
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public DateTime StartDateTime { get; set; }
|
|
|
+ public DateTime EndDateTime { get; set; }
|
|
|
+ public string SelectedValuePM { get; set; }
|
|
|
+ public string RecipeName { get; set; }
|
|
|
+ public class RecipeItem
|
|
|
+ {
|
|
|
+ public bool Selected { get; set; }
|
|
|
+ public string Recipe { get; set; }
|
|
|
+ public string Guid { get; set; }
|
|
|
+ public string RecipeRunGuid { get; set; }
|
|
|
+ public string Chamber { get; set; }
|
|
|
+ public string Status { get; set; }
|
|
|
+ public string StartTime { get; set; }
|
|
|
+ public string EndTime { get; set; }
|
|
|
+ public string LotID { get; set; }
|
|
|
+ public string SlotID { get; set; }
|
|
|
+ }
|
|
|
+ public ObservableCollection<RecipeItem> Recipes { get; set; }
|
|
|
+ public ObservableCollection<ParameterNode> ParameterNodes
|
|
|
+ {
|
|
|
+ get { return _ParameterNodes; }
|
|
|
+ set { SetProperty(ref _ParameterNodes, value); }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private DelegateCommand _SearchRecipeCommand;
|
|
|
+ public DelegateCommand SearchRecipeCommand =>
|
|
|
+ _SearchRecipeCommand ?? (_SearchRecipeCommand = new DelegateCommand(SearchRecipe));
|
|
|
+ public void SearchRecipe()
|
|
|
+ {
|
|
|
+ //if (MenuPermission != 3) return;
|
|
|
+ Console.WriteLine("er");
|
|
|
+ this.StartDateTime = this.view.wfTimeFrom.Value;
|
|
|
+ this.EndDateTime = this.view.wfTimeTo.Value;
|
|
|
+ Recipes.Clear();
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ 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")}' ";
|
|
|
+
|
|
|
+ if (!string.IsNullOrEmpty(SelectedValuePM))
|
|
|
+ {
|
|
|
+ string[] pms = SelectedValuePM.Split(',');
|
|
|
+ if (pms.Length > 0)
|
|
|
+ {
|
|
|
+ sql += " and (FALSE ";
|
|
|
+ foreach (var pm in pms)
|
|
|
+ {
|
|
|
+ sql += $" OR \"process_in\"='{pm}' ";
|
|
|
+ }
|
|
|
+ sql += " ) ";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!string.IsNullOrEmpty(RecipeName))
|
|
|
+ {
|
|
|
+ sql += string.Format(" and lower(\"recipe_name\") like '%{0}%'", RecipeName.ToLower());
|
|
|
+ }
|
|
|
+
|
|
|
+ sql += " order by \"process_begin_time\" ASC;";
|
|
|
+
|
|
|
+ DataTable dbData = QueryDataClient.Instance.Service.QueryData(sql);
|
|
|
+
|
|
|
+ Application.Current.Dispatcher.BeginInvoke(new Action(() =>
|
|
|
+ {
|
|
|
+ if (dbData == null || dbData.Rows.Count == 0) return;
|
|
|
+
|
|
|
+ for (int i = 0; i < dbData.Rows.Count; i++)
|
|
|
+ {
|
|
|
+ RecipeItem item = new RecipeItem();
|
|
|
+
|
|
|
+ item.Recipe = dbData.Rows[i]["recipe_name"].ToString();
|
|
|
+ item.Guid = dbData.Rows[i]["guid"].ToString();
|
|
|
+ item.RecipeRunGuid = dbData.Rows[i]["wafer_data_guid"].ToString();
|
|
|
+ item.Chamber = dbData.Rows[i]["process_in"].ToString();
|
|
|
+ item.Status = dbData.Rows[i]["process_status"].ToString();
|
|
|
+ item.SlotID = dbData.Rows[i]["slot_id"].ToString();
|
|
|
+ item.LotID = dbData.Rows[i]["lot_id"].ToString();
|
|
|
+ if (!dbData.Rows[i]["process_begin_time"].Equals(DBNull.Value))
|
|
|
+ item.StartTime = ((DateTime)dbData.Rows[i]["process_begin_time"]).ToString("yyyy-MM-dd HH:mm:ss.fff");
|
|
|
+ if (!dbData.Rows[i]["process_end_time"].Equals(DBNull.Value))
|
|
|
+ item.EndTime = ((DateTime)dbData.Rows[i]["process_end_time"]).ToString("yyyy-MM-dd HH:mm:ss.fff");
|
|
|
+ Recipes.Add(item);
|
|
|
+
|
|
|
+ }
|
|
|
+ }));
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ LOG.WriteExeption(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void CalKeys(ParameterNode parameterNode)
|
|
|
+ {
|
|
|
+
|
|
|
+ if (parameterNode.ChildNodes.Count > 0)
|
|
|
+ {
|
|
|
+ foreach (var item in parameterNode.ChildNodes)
|
|
|
+ {
|
|
|
+ CalKeys(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (parameterNode.Selected == true)
|
|
|
+ {
|
|
|
+ keys.Add(parameterNode.Name);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ private Dictionary<string, List<HistoryDataItem>> GetData(List<string> keys, DateTime from, DateTime to)
|
|
|
+ {
|
|
|
+ string sql = "select time AS InternalTimeStamp";
|
|
|
+ foreach (var dataId in keys)
|
|
|
+ {
|
|
|
+ sql += "," + string.Format("\"{0}\"", dataId);
|
|
|
+ }
|
|
|
+ sql += string.Format(" from \"{0}\" where time > {1} and time <= {2} order by time asc",
|
|
|
+ from.ToString("yyyyMMdd") + "." + "Data", 638205482713339617, 638205532409885237);
|
|
|
+ DataTable dataTable = QueryDataClient.Instance.Service.QueryData(sql);
|
|
|
+ Dictionary<string, List<HistoryDataItem>> historyData = new Dictionary<string, List<HistoryDataItem>>();
|
|
|
+ if (dataTable == null || dataTable.Rows.Count == 0)
|
|
|
+ return null;
|
|
|
+
|
|
|
+ DateTime dt = new DateTime();
|
|
|
+ Dictionary<int, string> colName = new Dictionary<int, string>();
|
|
|
+ for (int colNo = 0; colNo < dataTable.Columns.Count; colNo++)
|
|
|
+ {
|
|
|
+ colName.Add(colNo, dataTable.Columns[colNo].ColumnName);
|
|
|
+ historyData[dataTable.Columns[colNo].ColumnName] = new List<HistoryDataItem>();
|
|
|
+ }
|
|
|
+ for (int rowNo = 0; rowNo < dataTable.Rows.Count; rowNo++)
|
|
|
+ {
|
|
|
+ PointCollection points = new PointCollection();
|
|
|
+
|
|
|
+ var row = dataTable.Rows[rowNo];
|
|
|
+
|
|
|
+ for (int i = 0; i < dataTable.Columns.Count; i++)
|
|
|
+ {
|
|
|
+ HistoryDataItem data = new HistoryDataItem();
|
|
|
+ if (i == 0)
|
|
|
+ {
|
|
|
+ long ticks = (long)row[i];
|
|
|
+ dt = new DateTime(ticks);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ string dataId = colName[i];
|
|
|
+ if (row[i] is DBNull || row[i] == null)
|
|
|
+ {
|
|
|
+ data.dateTime = dt;
|
|
|
+ data.dbName = colName[i];
|
|
|
+ data.value = 0;
|
|
|
+ }
|
|
|
+ else if (row[i] is bool)
|
|
|
+ {
|
|
|
+ data.dateTime = dt;
|
|
|
+ data.dbName = colName[i];
|
|
|
+ data.value = (bool)row[i] ? 1 : 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ data.dateTime = dt;
|
|
|
+ data.dbName = colName[i];
|
|
|
+ data.value = float.Parse(row[i].ToString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ historyData[data.dbName].Add(data);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach (var item in historyData)
|
|
|
+ {
|
|
|
+ item.Value.Sort((x, y) => DateTime.Compare(x.dateTime, y.dateTime));
|
|
|
+ }
|
|
|
+ return historyData;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void UpdateData(RecipeItem dataLog)
|
|
|
+ {
|
|
|
+ if (dataLog == null)
|
|
|
+ {
|
|
|
+ this.view.MyDrawGraphicsControl.ClearPlotPoints();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<string> keys = new List<string>();
|
|
|
+
|
|
|
+ Application.Current.Dispatcher.Invoke(new Action(() =>
|
|
|
+ {
|
|
|
+ string type = "A";
|
|
|
+ string s = dataLog.Chamber;
|
|
|
+
|
|
|
+ if (dataLog.Chamber == "PMA")
|
|
|
+ {
|
|
|
+ keys = new List<string> { "IO.PMA.AI_Chamber_Pressure", "PMA.Rf.PowerSetPoint", "PMA.Rf.ForwardPower", "PMA.Rf.ReflectPower", "PMA.IoMfc.MfcGas1.FeedBack", "PMA.IoMfc.MfcGas1.SetPoint", "PMA.IoMfc.MfcGas2.FeedBack", "PMA.IoMfc.MfcGas2.SetPoint", "PMA.IoMfc.MfcGas3.FeedBack", "PMA.IoMfc.MfcGas3.SetPoint" };
|
|
|
+ if ((bool)QueryDataClient.Instance.Service.GetConfig($"PMA.BiasRf.EnableBiasRF"))
|
|
|
+ type = "A";
|
|
|
+ }
|
|
|
+ else if (dataLog.Chamber == "PMB")
|
|
|
+ {
|
|
|
+ keys = new List<string> { "IO.PMB.AI_Chamber_Pressure", "PMB.Rf.PowerSetPoint", "PMB.Rf.ForwardPower", "PMB.Rf.ReflectPower", "PMB.IoMfc.MfcGas1.FeedBack", "PMB.IoMfc.MfcGas1.SetPoint", "PMB.IoMfc.MfcGas2.FeedBack", "PMB.IoMfc.MfcGas2.SetPoint", "PMB.IoMfc.MfcGas3.FeedBack", "PMB.IoMfc.MfcGas3.SetPoint" };
|
|
|
+ if ((bool)QueryDataClient.Instance.Service.GetConfig($"PMB.BiasRf.EnableBiasRF"))
|
|
|
+ type = "B";
|
|
|
+ }
|
|
|
+ }));
|
|
|
+
|
|
|
+ //ProcessData = QueryDataClient.Instance.Service.GetHistoryData(keys, dataLog.Guid, "Data");
|
|
|
+ this.view.MyDrawGraphicsControl.ClearPlotPoints();
|
|
|
+ DateTime dtFrom = Convert.ToDateTime(dataLog.StartTime);
|
|
|
+ DateTime dtTo = dtFrom.AddMinutes(10);
|
|
|
+ if (!string.IsNullOrEmpty(dataLog.EndTime))
|
|
|
+ {
|
|
|
+ dtTo = Convert.ToDateTime(dataLog.EndTime);
|
|
|
+ }
|
|
|
+ var result = GetData(keys.Distinct().ToList(), dtFrom, dtTo);
|
|
|
+ //var result = GetData(keys.Distinct().ToList(), this.view.wfTimeFrom.Value, this.view.wfTimeTo.Value);
|
|
|
+ List<PointCollection> cls = new List<PointCollection>();
|
|
|
+ for (int i = 0; i < keys.Count; i++)
|
|
|
+ {
|
|
|
+ PointCollection points = new PointCollection();
|
|
|
+ int k = 1;
|
|
|
+ result[keys[i]].ForEach(point =>
|
|
|
+ {
|
|
|
+ points.Add(new Point() { X = point.dateTime.ToOADate(), Y = point.value });
|
|
|
+ k += 1;
|
|
|
+ });
|
|
|
+ cls.Add(points);
|
|
|
+ }
|
|
|
+ this.view.MyDrawGraphicsControl.PointCollections = cls;
|
|
|
+ this.view.MyDrawGraphicsControl.FitControl();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|