| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573 | 
							- using System;
 
- using System.Collections.Generic;
 
- using System.Collections.ObjectModel;
 
- using System.ComponentModel;
 
- using System.Diagnostics;
 
- using System.IO;
 
- using System.Linq;
 
- using System.Reflection;
 
- using System.Text;
 
- using System.Threading.Tasks;
 
- using Newtonsoft.Json;
 
- using Newtonsoft.Json.Converters;
 
- using Venus_Core.Attributes;
 
- namespace Venus_Core
 
- {
 
-     public enum RecipeType
 
-     {
 
-         Chuck,
 
-         DeChuck,
 
-         Process,
 
-         Clean,
 
-     }
 
-     public enum StepType
 
-     {
 
-         Time,
 
-         Stable,
 
-         EndPoint,
 
-         OverEtch,
 
-     }
 
-     public enum ProcessModule
 
-     {
 
-         Pressure,
 
-         TCP,            // Transformer Coupled Plasma (转换耦合等离子)
 
-         Bias,
 
-         Gas,
 
-         ESC,
 
-         Process,
 
-         Compound,
 
-     }
 
-     public enum GeneratorMode
 
-     {
 
-         Pulsing,
 
-         CW,
 
-     }
 
-     public enum PressureUnitMode
 
-     {
 
-         Pressure,
 
-         Valve
 
-     }
 
-     public class RecipeHead: INotifyPropertyChanged
 
-     {
 
-         private string m_name;
 
-         [IsOnlyRead]
 
-         public string Name
 
-         {
 
-             get { return m_name; }
 
-             set { m_name = value; InvokePropertyChanged("Name"); }
 
-         }
 
-         private string _Version = "TestVersion";
 
-         public string Version
 
-         {
 
-             get { return _Version; }
 
-             set { _Version = value; InvokePropertyChanged("Version"); }
 
-         }
 
-         private RecipeType m_Type;
 
-         [JsonConverter(typeof(StringEnumConverter))]
 
-         public RecipeType Type
 
-         {
 
-             get { return m_Type; }
 
-             set { m_Type = value; InvokePropertyChanged("Type"); }
 
-         }
 
-         private string m_ChunckRecipe;
 
-         public string ChuckRecipe
 
-         {
 
-             get { return m_ChunckRecipe;}
 
-             set { m_ChunckRecipe = value; InvokePropertyChanged("ChuckRecipe"); }
 
-         }
 
-         private string m_DechuckRecipe;
 
-         public string DechuckRecipe
 
-         {
 
-             get { return m_DechuckRecipe;}
 
-             set{ m_DechuckRecipe = value;InvokePropertyChanged("DechuckRecipe");}
 
-         }
 
-         private string m_CreateTime;
 
-         [IsOnlyRead]
 
-         public string CreateTime
 
-         {
 
-             get { return m_CreateTime;}
 
-             set { m_CreateTime = value; InvokePropertyChanged("CreateTime"); }
 
-         }
 
-         private string m_LastModifiedBy;
 
-         [IsOnlyRead]
 
-         public string LastModifiedBy
 
-         {
 
-             get {  return m_LastModifiedBy;}
 
-             set { m_LastModifiedBy = value; InvokePropertyChanged("CreateTime"); }
 
-         }
 
-         private string m_Barcode;
 
-         public string Barcode
 
-         {
 
-             get { return m_Barcode;}
 
-             set { m_Barcode = value; InvokePropertyChanged("Barcode"); }
 
-         }
 
-         private string m_BasePressure;
 
-         public string BasePressure
 
-         {
 
-             get { return m_BasePressure;}
 
-             set { m_BasePressure = value; InvokePropertyChanged("BasePressure"); }
 
-         }
 
-         private string m_ChillerTemp;
 
-         public string ChillerTemp
 
-         {
 
-             get { return m_ChillerTemp;}
 
-             set { m_ChillerTemp = value; InvokePropertyChanged("ChillerTemp"); }
 
-         }
 
-         //private string m_ChillerTemp1;
 
-         //public string ChillerTemp1
 
-         //{
 
-         //    get { return m_ChillerTemp1; }
 
-         //    set { m_ChillerTemp1 = value; InvokePropertyChanged("ChillerTemp1"); }
 
-         //}
 
-         //private string m_ChillerTemp2;
 
-         //public string ChillerTemp2
 
-         //{
 
-         //    get { return m_ChillerTemp2; }
 
-         //    set { m_ChillerTemp2 = value; InvokePropertyChanged("ChillerTemp2"); }
 
-         //}
 
-         //private string m_ChillerTemp3;
 
-         //public string ChillerTemp3
 
-         //{
 
-         //    get { return m_ChillerTemp3; }
 
-         //    set { m_ChillerTemp3 = value; InvokePropertyChanged("ChillerTemp3"); }
 
-         //}
 
-         //private string m_ChillerTemp4;
 
-         //public string ChillerTemp4
 
-         //{
 
-         //    get { return m_ChillerTemp4; }
 
-         //    set { m_ChillerTemp4 = value; InvokePropertyChanged("ChillerTemp4"); }
 
-         //}
 
-         public event PropertyChangedEventHandler PropertyChanged;
 
-         public void InvokePropertyChanged(string propertyName)
 
-         {
 
-             if (PropertyChanged != null)
 
-             {
 
-                 PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
 
-             }
 
-         }
 
-     }
 
-     public class ProcessUnitBase
 
-     {
 
-         [JsonIgnore]
 
-         public Func<ProcessUnitBase, RecipeStep, RState> checker;
 
-         [JsonIgnore]
 
-         public Func<ProcessUnitBase, RecipeStep, RState> starter;
 
-         [JsonIgnore]
 
-         public Action<ProcessUnitBase, RecipeStep> end;
 
-         //[JsonIgnore]
 
-         //public string Name { get; set; }
 
-         //[JsonIgnore]
 
-         //public ProcessModule Moudle { get; set; }
 
-         public RState Start(RecipeStep step)
 
-         {
 
-             if (starter != null)
 
-                 return starter(this, step);
 
-             return RState.Running;
 
-         }
 
-         public RState Run(RecipeStep step)
 
-         {
 
-             if (checker != null)
 
-                 return checker(this, step);
 
-             return RState.Running;
 
-         }
 
-         public void End(RecipeStep step)
 
-         {
 
-             if (end != null)
 
-                 end(this, step);
 
-         }
 
-     }
 
-     public class RecipeStep:INotifyPropertyChanged
 
-     {
 
-         //public string m_UnitName="StepDescriptionUnit";
 
-         //public string UnitName
 
-         //{
 
-         //    get { return m_UnitName;}
 
-         //    set { m_UnitName = value; InvokePropertyChanged("UnitName"); }
 
-         //}
 
-         [JsonIgnore]
 
-         public Func<RecipeStep, RState> checker;
 
-         [JsonIgnore]
 
-         public Func<RecipeStep, RState> starter;
 
-         [JsonIgnore]
 
-         public Func<RecipeStep, RState> ender;
 
-         //private int m_StepNo;
 
-         //public int StepNo
 
-         //{
 
-         //    get { return m_StepNo; }
 
-         //    set { m_StepNo = value; InvokePropertyChanged("StepNo"); }
 
-         //}
 
-         private int m_StepNo;
 
-         [IsOnlyRead]
 
-         public int StepNo
 
-         {
 
-             get { return m_StepNo; }
 
-             set { m_StepNo = value; InvokePropertyChanged("StepNo"); }
 
-         }
 
-         private StepType m_StepType;
 
-         [JsonConverter(typeof(StringEnumConverter))]
 
-         public StepType Type
 
-         {
 
-             get { return m_StepType;}
 
-             set { m_StepType = value; InvokePropertyChanged("Type"); }
 
-         }
 
-         private int m_Time;
 
-         public int Time
 
-         {
 
-             get { return m_Time;}
 
-             set { m_Time = value; InvokePropertyChanged("Time"); }
 
-         }
 
-         private string m_EPDConfigName;
 
-         public string EPDConfigName
 
-         {
 
-             get { return m_EPDConfigName; }
 
-             set { m_EPDConfigName = value; InvokePropertyChanged("EPDConfigName"); }
 
-         }
 
-         private int m_MinEndPointTime;
 
-         public int MinEndPointTime
 
-         {
 
-             get { return m_MinEndPointTime;}
 
-             set { m_MinEndPointTime = value; InvokePropertyChanged("MinEndPointTime"); }
 
-         }
 
-         private int m_MaxEndPointTime;
 
-         public int MaxEndPointTime
 
-         {
 
-             get { return m_MaxEndPointTime; }
 
-             set { m_MaxEndPointTime = value; InvokePropertyChanged("MaxEndPointTime"); }
 
-         }
 
-         private int m_OverEtchPercent;
 
-         public int OverEtchPercent
 
-         {
 
-             get { return m_OverEtchPercent; }
 
-             set { m_OverEtchPercent = value;InvokePropertyChanged("OverEtchPercent"); }
 
-         }
 
-         private bool m_CycleStart;
 
-         public bool CycleStart
 
-         {
 
-             get { return m_CycleStart;}
 
-             set { m_CycleStart = value; InvokePropertyChanged("CycleStart"); }
 
-         }
 
-         private bool m_CycleEnd;
 
-         public bool CycleEnd
 
-         {
 
-             get { return m_CycleEnd;}
 
-             set { m_CycleEnd = value; InvokePropertyChanged("CycleEnd"); }
 
-         }
 
-         private int m_CycleNumber;
 
-         public int CycleNumber
 
-         {
 
-             get { return m_CycleNumber;}
 
-             set { m_CycleNumber = value; InvokePropertyChanged("CycleNumber"); }
 
-         }
 
-         public PressureUnitMode PressureUnitMode { get; set; }
 
-         private ObservableCollection<Object> lstUnit = new ObservableCollection<Object>();
 
-         public ObservableCollection<Object> LstUnit
 
-         {
 
-             get { return lstUnit; }
 
-             set { lstUnit = value; InvokePropertyChanged("LstUnit"); }
 
-         }
 
-         private Stopwatch _stepTimer = new Stopwatch();
 
-         public long ElapsedTime()
 
-         {
 
-             return _stepTimer.ElapsedMilliseconds; 
 
-         }
 
-         public void StartStepTimer()
 
-         {
 
-             _stepTimer.Restart();
 
-         }
 
-         private long _lastEPDStepTimne = 0;
 
-         public void RecordEPDStepTime()
 
-         {
 
-             _lastEPDStepTimne = _stepTimer.ElapsedMilliseconds;
 
-         }
 
-         public long GetLastEPDStepTime()
 
-         {
 
-             return _lastEPDStepTimne;
 
-         }
 
-         public RState Start()
 
-         {
 
-             starter(this);
 
-             foreach (var unit in lstUnit)
 
-             {
 
-                 var processUnit = unit as ProcessUnitBase;
 
-                 if (processUnit != null)
 
-                 {
 
-                     var state = processUnit.Start(this);
 
-                     if (state != RState.Running)
 
-                         return state;
 
-                 }
 
-                 else
 
-                     return RState.Failed;
 
-                 
 
-             }
 
-             return RState.Running;
 
-         }
 
-         public RState Run()
 
-         {
 
-             if (checker(this) == RState.End)
 
-                 return RState.End;
 
-             bool bStable = true;
 
-             foreach (var unit in lstUnit)
 
-             {
 
-                 var processUnit = unit as ProcessUnitBase;
 
-                 if (processUnit != null)
 
-                 {
 
-                     var state = processUnit.Run(this);
 
-                     if(Type == StepType.Stable)
 
-                     {
 
-                         if (state != RState.Running && state != RState.End)
 
-                             return state;
 
-                         if (state == RState.Running)
 
-                             bStable = false;
 
-                     }
 
-                     else
 
-                     {
 
-                         if (state != RState.Running)
 
-                             return state;
 
-                     }
 
-                 }
 
-                 else
 
-                     return RState.Failed;
 
-             }
 
-             return (Type == StepType.Stable && bStable) ? RState.End : RState.Running;
 
-         }
 
-         public void End()
 
-         {
 
-             foreach (var unit in lstUnit)
 
-             {
 
-                 var processUnit = unit as ProcessUnitBase;
 
-                 if (processUnit != null)
 
-                 {
 
-                     processUnit.End(this);
 
-                 }
 
-             }
 
-             ender(this);
 
-         }
 
-         public double RampFactor()
 
-         {
 
-             return _stepTimer.ElapsedMilliseconds / (Time * 1000.0);
 
-         }
 
-         public void AppendUnit(ProcessUnitBase unit)
 
-         {
 
-             lstUnit.Append(unit);
 
-         }
 
-         public event PropertyChangedEventHandler PropertyChanged;
 
-         public void InvokePropertyChanged(string propertyName)
 
-         {
 
-             if (PropertyChanged != null)
 
-             {
 
-                 PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
 
-             }
 
-         }
 
-     }
 
-     public class Recipe: INotifyPropertyChanged
 
-     {
 
-         private RecipeHead m_Header = new RecipeHead();
 
-         public RecipeHead Header
 
-         {
 
-             get { return m_Header; }
 
-             set { m_Header = value; InvokePropertyChanged("Header"); }
 
-         }
 
-         private ObservableCollection<RecipeStep> m_Steps;
 
-         public ObservableCollection<RecipeStep> Steps
 
-         {
 
-             get { return m_Steps; }
 
-             set { m_Steps = value; InvokePropertyChanged("Steps"); }
 
-         }
 
-         public static Recipe Load(string recipeFile)
 
-         {
 
-            var recipe= JsonConvert.DeserializeObject<Recipe>(recipeFile);
 
-             foreach (var step in recipe.Steps)
 
-             {
 
-                 ObservableCollection<ProcessUnitBase> unit = new ObservableCollection<ProcessUnitBase>();
 
-                 //int count = step.LstUnit.Count / 2;
 
-                 //for (int i = 0; i < count; i++)
 
-                 //{
 
-                 //    Type t = Type.GetType(step.LstUnit[i].ToString());
 
-                 //    //unit.Add(JsonConvert.DeserializeObject<t>(step.LstUnit[i+count].ToString()));
 
-                 //    unit.Add(JsonConvert.DeserializeObject<ProcessUnitBase>(step.LstUnit[i + count].ToString()));
 
-                 //}
 
-                 //var item = step.LstUnit[0];
 
-                 for (int i=0;i< step.LstUnit.Count; i++)
 
-                 {
 
-                     //object item=step.LstUnit[i];
 
-                     //step.LstUnit[i].
 
-                     string value = step.LstUnit[i].ToString();
 
-                     string[] striparr = value.Split(new string[] { "\r\n" }, StringSplitOptions.None);
 
-                     string item1= striparr[1].Remove(0, 15);
 
-                     string item2 = item1.Remove(item1.Length - 2, 2);
 
-                     //var item= value.Substring(value.IndexOf("UnitName"));
 
-                     //Type t = Type.GetType(value);
 
-                     
 
-                     switch (item2)
 
-                     {
 
-                         case "PressureByPressureModeUnit":
 
-                             unit.Add(JsonConvert.DeserializeObject<PressureByPressureModeUnit>(step.LstUnit[i].ToString()));
 
-                             break;
 
-                         case "PressureByValveModeUnit":
 
-                             unit.Add(JsonConvert.DeserializeObject<PressureByValveModeUnit>(step.LstUnit[i].ToString()));
 
-                             break;
 
-                         case "TCPUnit":
 
-                             unit.Add(JsonConvert.DeserializeObject<TCPUnit>(step.LstUnit[i].ToString()));
 
-                             break;
 
-                         case "BiasUnit":
 
-                             unit.Add(JsonConvert.DeserializeObject<BiasUnit>(step.LstUnit[i].ToString()));
 
-                             break;
 
-                         case "GasControlUnit":
 
-                             unit.Add(JsonConvert.DeserializeObject<GasControlUnit>(step.LstUnit[i].ToString()));
 
-                             break;
 
-                         case "ESCHVUnit":
 
-                             unit.Add(JsonConvert.DeserializeObject<ESCHVUnit>(step.LstUnit[i].ToString()));
 
-                             break;
 
-                         case "ProcessKitUnit":
 
-                             unit.Add(JsonConvert.DeserializeObject<ProcessKitUnit>(step.LstUnit[i].ToString()));
 
-                             break;
 
-                     }
 
-                 }
 
-                 step.LstUnit.Clear();
 
-                 unit.ToList().ForEach(x => 
 
-                 {
 
-                     step.LstUnit.Add(x);
 
-                 });
 
-                
 
-                 
 
-             }
 
-             return recipe;
 
-         }
 
-         public bool Validate()
 
-         {
 
-             return true;
 
-         }
 
-         public bool Save(string recipeFile)
 
-         {
 
-             return true;
 
-         }
 
-         public event PropertyChangedEventHandler PropertyChanged;
 
-         public void InvokePropertyChanged(string propertyName)
 
-         {
 
-             if (PropertyChanged != null)
 
-             {
 
-                 PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
 
-             }
 
-         }
 
-     }
 
-     public class RecipeUnity
 
-     {
 
-         public static string ConvertJsonString(string str)
 
-         {
 
-             JsonSerializer serializer = new JsonSerializer();
 
-             TextReader tr = new StringReader(str);
 
-             JsonTextReader jtr = new JsonTextReader(tr);
 
-             object obj = serializer.Deserialize(jtr);
 
-             if (obj != null)
 
-             {
 
-                 StringWriter textWriter = new StringWriter();
 
-                 JsonTextWriter jsonWriter = new JsonTextWriter(textWriter)
 
-                 {
 
-                     Formatting = Newtonsoft.Json.Formatting.Indented,
 
-                     Indentation = 4,
 
-                     IndentChar = ' '
 
-                 };
 
-                 serializer.Serialize(jsonWriter, obj);
 
-                 return textWriter.ToString();
 
-             }
 
-             else
 
-             {
 
-                 return str;
 
-             }
 
-         }
 
-         public static string RecipeToString(Recipe recipe)
 
-         {
 
-             return JsonConvert.SerializeObject(recipe);
 
-         }
 
-         public static String CreateRecipe(RecipeType recipeType,string recipeName)
 
-         {
 
-             Recipe recipe = new Recipe();
 
-             recipe.Header = new RecipeHead();
 
-             recipe.Header.CreateTime = DateTime.Now.ToString();
 
-             recipe.Header.Type = recipeType;
 
-             recipe.Header.Name = recipeName;
 
-             recipe.Header.LastModifiedBy = "Admin";
 
-             recipe.Steps = new ObservableCollection<RecipeStep>();
 
-             recipe.Steps.Add(new RecipeStep()
 
-             {
 
-                 LstUnit = new ObservableCollection<Object>()
 
-                 {
 
-                  new PressureByPressureModeUnit(),
 
-                  new TCPUnit(),
 
-                  new BiasUnit(),
 
-                  new GasControlUnit(),
 
-                  new ESCHVUnit(),
 
-                  new ProcessKitUnit()
 
-                  }
 
-             });
 
-             var recipeString = JsonConvert.SerializeObject(recipe);
 
-             //var Recipe2=JsonConvert.DeserializeObject<Recipe>(recipeString);
 
-             //string test = "";
 
-             //test = Recipe2.Steps[0].LstUnit[0].ToString();
 
-             //var tcpinit = JsonConvert.DeserializeObject<TCPUnit>(test);
 
-             return recipeString;
 
-         }
 
-     }
 
- }
 
 
  |