Procházet zdrojové kódy

Enhance Routing algorithm and simulator configure file path.

sangwq před 1 rokem
rodič
revize
d89a4c81f9

+ 20 - 0
Venus/Framework/Common/Jobs/SequenceInfo.cs

@@ -9,6 +9,13 @@ using SciChart.Core.Extensions;
 
 namespace MECF.Framework.Common.Jobs
 {
+    public enum SequenceLLInOutPath
+    {
+        AInBOut,
+        BInAOut,
+        DInDOut,
+    }
+
     [Serializable]
     [DataContract]
     public class SequenceInfo
@@ -25,11 +32,15 @@ namespace MECF.Framework.Common.Jobs
 
         [DataMember]
         public Guid InnerId { get; set; }
+
+        [DataMember]
+        public SequenceLLInOutPath LLInOutPath { get; set; }
  
         public SequenceInfo(string name)
         {
             Name = name;
             InnerId = Guid.NewGuid();
+            LLInOutPath =  SequenceLLInOutPath.DInDOut;
             Steps = new List<SequenceStepInfo>();
         }
     }
@@ -130,6 +141,15 @@ namespace MECF.Framework.Common.Jobs
                         info.Steps.Add(stepInfo);
                     }
 
+                    // Loadlock Single In Single Out property check
+                    var llSteps = info.Steps.FindAll(item => item.StepModules.Contains(ModuleName.LLA) || item.StepModules.Contains(ModuleName.LLB));
+                    if ((llSteps.Count == 2) && 
+                        (llSteps[0].StepModules.Count == 1 && llSteps[1].StepModules.Count == 1) && 
+                        (llSteps[0].StepModules[0] != llSteps[1].StepModules[0]))
+                    {
+                        info.LLInOutPath = llSteps[0].StepModules[0] == ModuleName.LLA ? SequenceLLInOutPath.AInBOut : SequenceLLInOutPath.BInAOut;
+                    }
+
                 }
                 catch (Exception ex)
                 {

+ 15 - 2
Venus/Venus_RT/Devices/IODevices/IoMfc.cs

@@ -251,6 +251,9 @@ namespace Venus_RT.Devices.IODevices
 
     public class IoMfc : MfcBase1
     {
+        byte[] _buffer_1 = new byte[4];
+        byte[] _buffer_2 = new byte[4];
+
         public string Unit
         {
             get; set;
@@ -276,8 +279,13 @@ namespace Venus_RT.Devices.IODevices
                 {
                     byte[] high = BitConverter.GetBytes(_aoFlow.Buffer[_aoFlow.Index]);
                     byte[] low = BitConverter.GetBytes(_aoFlow.Buffer[_aoFlow.Index + 1]);
-                    float flow = BitConverter.ToSingle(new[] { high[0], high[1], low[0], low[1] }, 0);
+                    _buffer_1[0] = high[0];
+                    _buffer_1[1] = high[1];
+                    _buffer_1[2] = low[0];
+                    _buffer_1[3] = low[1];
 
+                    float flow = BitConverter.ToSingle(_buffer_1, 0);
+                    
                     return flow * Scale / RtInstance.ANALOG_TRANS_RANGE;
                 }
                 return 0;
@@ -314,7 +322,12 @@ namespace Venus_RT.Devices.IODevices
                 {
                     byte[] high = BitConverter.GetBytes(_aiFlow.Buffer[_aiFlow.Index]);
                     byte[] low = BitConverter.GetBytes(_aiFlow.Buffer[_aiFlow.Index + 1]);
-                    float flow = BitConverter.ToSingle(new[] { high[0], high[1], low[0], low[1] }, 0);
+
+                    _buffer_2[0] = high[0];
+                    _buffer_2[1] = high[1];
+                    _buffer_2[2] = low[0];
+                    _buffer_2[3] = low[1];
+                    float flow = BitConverter.ToSingle(_buffer_2, 0);
 
                     return (_scRegulationFactor != null && _scRegulationFactor.IntValue > 0) ? flow * Scale / RtInstance.ANALOG_TRANS_RANGE / _scRegulationFactor.IntValue 
                                                                                              : flow * Scale / RtInstance.ANALOG_TRANS_RANGE;

+ 54 - 21
Venus/Venus_RT/Modules/AutoCycle.cs

@@ -92,6 +92,7 @@ namespace Venus_RT.Modules
         int _LLASlotNumber = 4;
         int _LLBSlotNumber = 4;
         int _efemRobotSingleArmOption = 0;
+        SequenceLLInOutPath _LLInOutPath = SequenceLLInOutPath.DInDOut;
 
         List<MoveItem> _movingItems = new List<MoveItem>();
         List<MoveItem> _efemMovingItems = new List<MoveItem>();
@@ -574,6 +575,7 @@ namespace Venus_RT.Modules
             UpdateProcessJobStatus();
             UpdateControlJobStatus();
             StartNewJob();
+            UpdateLLInOutPathProperty();
         }
 
         private void driveVacSystem()
@@ -1187,22 +1189,25 @@ namespace Venus_RT.Modules
 
             return nCount;
         }
-        private bool IsReadyPushWaferIn()
+
+        private int CanPushInWaferNumber()
         {
             var llaWaferStatus = GetLLProcessStatusCount(ModuleName.LLA);
             var llbWaferStatus = GetLLProcessStatusCount(ModuleName.LLB);
             var pmWaferStatus = GetPMWaferExistence();
 
-            if (llaWaferStatus.Item1 + llbWaferStatus.Item1 > 0)
-                return false;
-
-            if (_LLAInSlot.Count + _LLBInSlot.Count + pmWaferStatus.Item2 - llaWaferStatus.Item2 - llbWaferStatus.Item2 <= 2)
-                return false;
-
-            if (GetEfemRoborWaferCount() >= 1 && GetAtmInerWaferCount() > 0)
-                return false;
-
-            return true;
+            if(_LLInOutPath == SequenceLLInOutPath.AInBOut)
+            {
+                return _LLASlotNumber - llaWaferStatus.Item1 - llaWaferStatus.Item2 - GetAtmInerWaferCount() - GetEfemRoborWaferCount();
+            }
+            else if(_LLInOutPath == SequenceLLInOutPath.BInAOut)
+            {
+                return _LLBSlotNumber - llbWaferStatus.Item1 - llbWaferStatus.Item2 - GetAtmInerWaferCount() - GetEfemRoborWaferCount();
+            }
+            else
+            {
+                return (_LLASlotNumber + _LLBSlotNumber) / 2 + pmWaferStatus.Item2 - GetTMRobotWaferCount() - GetEfemRoborWaferCount() - GetAtmInerWaferCount(); 
+            }
         }
 
         private bool IsForwardPathBlocking(ModuleName mod, int slot)
@@ -1248,7 +1253,8 @@ namespace Venus_RT.Modules
                 }
             }
 
-            if(_efemMovingItems.Count == 0 && IsReadyPushWaferIn())
+            var canPushInWafers = CanPushInWaferNumber();
+            if(_efemMovingItems.Count == 0 && canPushInWafers > 0)
             {
                 var outSlots = GetNextWaferInJobQueue(lp);
 
@@ -1258,13 +1264,14 @@ namespace Venus_RT.Modules
                     _efemMovingItems.Add(new MoveItem(lp, outSlots[0], ModuleName.EfemRobot, (int)hand, hand));
                 }
 
-
-                hand = GetEFEMRobotFreeHand();
-                if (hand != Hand.None && outSlots.Count> 1 && !IsForwardPathBlocking(lp, outSlots[1]))
+                if(canPushInWafers > 1)
                 {
-                    _efemMovingItems.Add(new MoveItem(lp, outSlots[1], ModuleName.EfemRobot, (int)hand, hand));
+                    hand = GetEFEMRobotFreeHand();
+                    if (hand != Hand.None && outSlots.Count > 1 && !IsForwardPathBlocking(lp, outSlots[1]))
+                    {
+                        _efemMovingItems.Add(new MoveItem(lp, outSlots[1], ModuleName.EfemRobot, (int)hand, hand));
+                    }
                 }
-
             }
 
             return _efemMovingItems.Count > 0;
@@ -1902,9 +1909,6 @@ namespace Venus_RT.Modules
             if (_lstControlJobs.Count == 0)
                 return;
 
-            //if (_curAction.state != ActionState.Done)
-            //    return;
-
             bool allControlJobComplete = true;
             List<ControlJobInfo> cjRemoveList = new List<ControlJobInfo>();
             foreach (var cj in _lstControlJobs)
@@ -2039,13 +2043,42 @@ namespace Venus_RT.Modules
             }
         }
 
+        private void UpdateLLInOutPathProperty()
+        {
+            if (_lstControlJobs.Count == 0)
+                return;
+
+            List<SequenceLLInOutPath> inOutPaths = new List<SequenceLLInOutPath>();
+            foreach (var cj in _lstControlJobs)
+            {
+                if (cj.State == EnumControlJobState.Executing)
+                {
+                    bool allPjCompleted = true;
+                    foreach (var pjName in cj.ProcessJobNameList)
+                    {
+                        var pj = _lstProcessJobs.Find(x => x.Name == pjName);
+                        if (pj == null || pj.State != EnumProcessJobState.Processing)
+                            continue;
+
+                        if (!inOutPaths.Exists(item => item == pj.Sequence.LLInOutPath))
+                            inOutPaths.Add(pj.Sequence.LLInOutPath);
+                    }
+                }
+            }
+
+            if (inOutPaths.Count == 1)
+            {
+                _LLInOutPath = inOutPaths[0];
+            }
+        }
+
         private static WaferInfo GetCloneWafer(ModuleName mod, int slot)
         {
             var Wafer = WaferManager.Instance.GetWafer(mod, slot);
             if (Wafer.IsEmpty || Wafer.ProcessJob == null || Wafer.ProcessJob.Sequence == null)
                 return Wafer;
 
-            var cloneWafer = Wafer.Clone(Wafer);
+            var cloneWafer = SerializeHelper.DeepCopyJson(Wafer);
 
             if (Wafer.IsEmpty || Wafer.ProcessJob == null || Wafer.ProcessJob.Sequence == null)
                 return Wafer;

+ 68 - 21
Venus/Venus_Simulator/Instances/SystemConfig.cs

@@ -2,6 +2,7 @@
 using System.IO;
 using System.Collections.Generic;
 using System.Xml;
+using System.Linq;
 using Aitex.Core.Util;
 using Aitex.Core.RT.SCCore;
 using Aitex.Core.RT.Log;
@@ -11,34 +12,37 @@ namespace Venus_Simulator.Instances
     public class SystemConfig : Singleton<SystemConfig>
     {
         private Dictionary<string, SCConfigItem> _items = new Dictionary<string, SCConfigItem>();
+        List<string> paths = new List<string>();
         public void Initialize()
         {
-            var processs = System.Diagnostics.Process.GetProcessesByName("Venus_RT");
-            if(processs.Length > 0)
+            var current_path = Environment.CurrentDirectory;
+            int nIndesx = current_path.LastIndexOf("Venus\\");
+            current_path = current_path.Substring(0, nIndesx + 5);
+                
+            GetConfigFilePath(current_path);
+            string cfgPath = paths.Find(item => item.Contains("Venus_RT"));
+            if (cfgPath != null)
             {
-                var venus_path = processs[0].MainModule.FileName;
-                var venus_dir = Path.GetDirectoryName(venus_path);
-                if (venus_dir != null)
+                string config_path = cfgPath;
+                string system_cfg = config_path.Replace("_sc.data", "System.sccfg"); 
+                if(File.Exists(system_cfg))
                 {
-                    string config_path = $"{venus_dir}\\Config\\_sc.data";
-                    string system_cfg = $"{venus_dir}\\Config\\System.sccfg";
-                    if(File.Exists(system_cfg))
+                    BuildItems(system_cfg);
+
+                    if (File.Exists(config_path))
                     {
-                        BuildItems(system_cfg);
+                        var cfg_stream = File.Open(config_path, FileMode.Open, FileAccess.Read);
+                        XmlDocument xmlData = new XmlDocument();
+                        xmlData.Load(config_path);
+                        xmlData.Load(stream);
 
-                        if (File.Exists(config_path))
+                        XmlNodeList scdatas = xmlData.SelectNodes("root/scdata");
+                        foreach (XmlElement nodedata in scdatas)
                         {
-                            XmlDocument xmlData = new XmlDocument();
-                            xmlData.Load(config_path);
-
-                            XmlNodeList scdatas = xmlData.SelectNodes("root/scdata");
-                            foreach (XmlElement nodedata in scdatas)
+                            string name = nodedata.GetAttribute("name");
+                            if (_items.ContainsKey(name))
                             {
-                                string name = nodedata.GetAttribute("name");
-                                if (_items.ContainsKey(name))
-                                {
-                                    InitializeItemValue(_items[name], nodedata.GetAttribute("value"));
-                                }
+                                InitializeItemValue(_items[name], nodedata.GetAttribute("value"));
                             }
                         }
                     }
@@ -134,7 +138,8 @@ namespace Venus_Simulator.Instances
 
             try
             {
-                xml.Load(xmlFile);
+                var stream = File.Open(xmlFile, FileMode.Open, FileAccess.Read);
+                xml.Load(stream);
 
                 XmlNodeList nodeConfigs = xml.SelectNodes("root/configs");
                 foreach (XmlElement nodeConfig in nodeConfigs)
@@ -190,5 +195,47 @@ namespace Venus_Simulator.Instances
                 _items[item.PathName] = item;
             }
         }
+
+        private void SearchFileInPath(string path, string folderName, string fileName, ref List<string> projectPaths)
+        {
+            var dirs = Directory.GetDirectories(path, "*.*", SearchOption.TopDirectoryOnly).ToList();  //获取当前路径下所有文件与文件夹
+            var desFolders = dirs.FindAll(x => x.Contains(folderName)); //在当前目录中查找目标文件夹
+            if (desFolders == null || desFolders.Count <= 0)
+            {
+                //当前目录未找到目标则递归
+                foreach (var dir in dirs)
+                {
+                    SearchFileInPath(dir, folderName, fileName, ref projectPaths);
+                }
+            }
+            else
+            {
+                //找到则添加至结果集
+                projectPaths.Add(path + "\\" + folderName + "\\" + fileName);
+            }
+        }
+
+        public void GetConfigFilePath(string path)
+        {
+            DirectoryInfo dir = new DirectoryInfo(path);
+
+            //找到该目录下的文件
+            FileInfo[] fi = dir.GetFiles();
+            foreach (FileInfo f in fi)
+            {
+                if (f.FullName.Contains("\\Venus_RT\\") && f.FullName.Contains("\\Config\\") && f.Name == "_sc.data")
+                {
+                    paths.Add(f.FullName);
+                    return;
+                }
+            }
+
+            //找到该目录下的所有目录再递归
+            DirectoryInfo[] subDir = dir.GetDirectories();
+            foreach (DirectoryInfo d in subDir)
+            {
+                GetConfigFilePath(d.FullName);
+            }
+        }
     }
 }