| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488 | 
							- using Aitex.Core.RT.ConfigCenter;
 
- using Aitex.Core.RT.DataCenter;
 
- using Aitex.Core.RT.SCCore;
 
- using MECF.Framework.Common.DataCenter;
 
- using MECF.Framework.Common.SCCore;
 
- using System;
 
- using System.Collections.Generic;
 
- using System.Linq;
 
- using System.Text;
 
- using System.Threading.Tasks;
 
- using static MECF.Framework.Common.Utilities.Parameter;
 
- namespace MECF.Framework.Common.Utilities
 
- {
 
-     public static class ParameterConfigManager
 
-     {
 
-         private static bool _isInit = false;
 
-         private static void InitializeAllBlocks()
 
-         {
 
-             if (_isInit) return;
 
-             string key = "System.SetUp.BlockNumber";
 
-            // string numberVlaue = SC.IsEnable ? SC.GetStringValue(key) : QueryDataClient.Instance.Service.GetConfig(key)?.ToString();
 
-             string numberVlaue ="3Block";
 
-             var numberOfBlock = int.Parse((numberVlaue.Replace("Block", "")));
 
-             ParameterManager.Instance.NumberOfBlocks = numberOfBlock;
 
-             ParameterManager.InitializeBlock();
 
-             SCValue SCBlock = null;
 
-             switch (numberOfBlock)
 
-             {
 
-                 case 2:
 
-                     SCBlock = new SCValue2Block();
 
-                     break;
 
-                 case 3:
 
-                     SCBlock = new SCValue3Block();
 
-                     break;
 
-                 case 4:
 
-                     SCBlock = new SCValue4Block();
 
-                     break;
 
-                 default:
 
-                     break;
 
-             }
 
-             SCBlock.SetKeys();
 
-             var scValue = CONFIG.IsEnable ? CONFIG.PollConfig(SCBlock.GetKeys()) : QueryDataClient.Instance.Service.PollConfig(SCBlock.GetKeys());
 
-             SCBlock.Update(scValue);
 
-             SCBlock.SetParameterValue(ParameterManager.Instance);
 
-             _isInit = true;
 
-         }
 
-         public static void ResetInitializeAllBlocks()
 
-         {
 
-             string key = "System.SetUp.BlockNumber";
 
-             string numberVlaue = SC.IsEnable ? SC.GetStringValue(key) : QueryDataClient.Instance.Service.GetConfig(key)?.ToString();
 
-             var numberOfBlock = int.Parse((numberVlaue.Replace("Block", "")));
 
-             ParameterManager.Instance.NumberOfBlocks = numberOfBlock;
 
-             ParameterManager.InitializeBlock();
 
-             SCValue SCBlock = null;
 
-             switch (numberOfBlock)
 
-             {
 
-                 case 2:
 
-                     SCBlock = new SCValue2Block();
 
-                     break;
 
-                 case 3:
 
-                     SCBlock = new SCValue3Block();
 
-                     break;
 
-                 case 4:
 
-                     SCBlock = new SCValue4Block();
 
-                     break;
 
-                 default:
 
-                     break;
 
-             }
 
-             SCBlock.SetKeys();
 
-             var scValue = CONFIG.IsEnable ? CONFIG.PollConfig(SCBlock.GetKeys()) : QueryDataClient.Instance.Service.PollConfig(SCBlock.GetKeys());
 
-             SCBlock.Update(scValue);
 
-             SCBlock.SetParameterValue(ParameterManager.Instance);
 
-         }
 
-         public static string GetChemicalSupplySystem(string module)
 
-         {
 
-             string strRet = string.Empty;
 
-             var tempString = module.Replace("PM", "").Split('_');
 
-             string strCurrentBlock = tempString[0];
 
-             string strCurrentModule = tempString.Length > 1 ? tempString[1] : string.Empty;
 
-             string strDispenseConfig = string.Empty;
 
-             string key = $"System.SetUp.Block{strCurrentBlock}.{strCurrentModule}.DispenseConfig";
 
-             if (SC.IsEnable)
 
-                 strDispenseConfig = SC.GetStringValue(key).ToString();
 
-             else
 
-                 strDispenseConfig = QueryDataClient.Instance.Service.GetConfig(key).ToString();
 
-             string[] listDispense = strDispenseConfig.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
 
-             for (int x = 0; x < listDispense.Length; x++)
 
-             {
 
-                 string[] sigDispense = listDispense[x].Split(':');
 
-                 if (sigDispense[1].Split(',')[1].ToLower().Contains("true"))
 
-                 {
 
-                     strRet = sigDispense[1].Split(',')[8];
 
-                     if (strRet == "-") continue;
 
-                     break;
 
-                 }
 
-             }
 
-             strRet = strRet.Replace("CSS", "").Replace(" ", "");
 
-             return strRet;
 
-         }
 
-         public static string GetParameterValueByIndex(string module, int firstIndex, int secondIndex)
 
-         {
 
-             string strRet = string.Empty;
 
-             var tempString = module.Replace("PM", "").Split('_');
 
-             string strCurrentBlock = tempString[0];
 
-             string strCurrentModule = tempString.Length > 1 ? tempString[1] : string.Empty;
 
-             string strDispenseConfig = string.Empty;
 
-             string key = $"System.SetUp.Block{strCurrentBlock}.{strCurrentModule}.DispenseConfig";
 
-             if (SC.IsEnable)
 
-                 strDispenseConfig = SC.GetStringValue(key).ToString();
 
-             else
 
-                 strDispenseConfig = QueryDataClient.Instance.Service.GetConfig(key).ToString();
 
-             string[] listDispense = strDispenseConfig.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
 
-             for (int x = 0; x < listDispense.Length; x++)
 
-             {
 
-                 string[] sigDispense = listDispense[x].Split(':');
 
-                 if (sigDispense[1].Split(',')[1].ToLower().Contains("true"))
 
-                 {
 
-                     string[] firstStrs = sigDispense[1].Split(',');
 
-                     if (firstStrs.Length > firstIndex)
 
-                     {
 
-                         string[] secondStrs = firstStrs[firstIndex].Split('/');
 
-                         if (secondStrs.Length > secondIndex)
 
-                             strRet = secondStrs[secondIndex];
 
-                     }
 
-                 }
 
-             }
 
-             return strRet;
 
-         }
 
-         public static string GetParameterValueByIndex(string module, string device, int firstIndex, int secondIndex)
 
-         {
 
-             string strRet = string.Empty;
 
-             var tempString = module.Replace("PM", "").Split('_');
 
-             string strCurrentBlock = tempString[0];
 
-             string strCurrentModule = tempString.Length > 1 ? tempString[1] : string.Empty;
 
-             string strDispenseConfig = string.Empty;
 
-             string key = $"System.SetUp.Block{strCurrentBlock}.{strCurrentModule}.DispenseConfig";
 
-             if (SC.IsEnable)
 
-                 strDispenseConfig = SC.GetStringValue(key).ToString();
 
-             else
 
-                 strDispenseConfig = QueryDataClient.Instance.Service.GetConfig(key).ToString();
 
-             string[] listDispense = strDispenseConfig.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
 
-             for (int x = 0; x < listDispense.Length; x++)
 
-             {
 
-                 string[] sigDispense = listDispense[x].Split(':');
 
-                 if (!sigDispense[0].Replace(".", "").ToLower().Contains(device))
 
-                 {
 
-                     continue;
 
-                 }
 
-                 if (sigDispense[1].Split(',')[1].ToLower().Contains("true"))
 
-                 {
 
-                     string[] firstStrs = sigDispense[1].Split(',');
 
-                     if (firstStrs.Length > firstIndex)
 
-                     {
 
-                         string[] secondStrs = firstStrs[firstIndex].Split('/');
 
-                         if (secondStrs.Length > secondIndex)
 
-                             strRet = secondStrs[secondIndex];
 
-                     }
 
-                 }
 
-             }
 
-             return strRet;
 
-         }
 
-         private static DeviceModule GetDeviceModuleByID(string ID)
 
-         {
 
-             InitializeAllBlocks();
 
-             ID = ID.Replace("PM", "").Replace("_", "-");
 
-             return ParameterManager.Instance.SpinerDeviceModule.First(x => x.ID == ID);
 
-         }
 
-         public static string GetDispenseRange(string moduleName, string deviceName, int index)
 
-         {
 
-             string strRet = string.Empty;
 
-             var tempString = moduleName.Split('_');
 
-             string strCurrentBlock = tempString[0];
 
-             string strCurrentModule = tempString.Length > 1 ? tempString[1] : string.Empty;
 
-             string strDispenseConfig = string.Empty;
 
-             string key = $"System.SetUp.Block{strCurrentBlock}.{strCurrentModule}.DispenseConfig";
 
-             if (SC.IsEnable)
 
-                 strDispenseConfig = SC.GetStringValue(key).ToString();
 
-             else
 
-                 strDispenseConfig = QueryDataClient.Instance.Service.GetConfig(key).ToString(); string[] listDispense = strDispenseConfig.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
 
-             for (int x = 0; x < listDispense.Length; x++)
 
-             {
 
-                 string[] sigDispense = listDispense[x].Split(':');
 
-                 if (!sigDispense[0].Contains(deviceName))
 
-                 {
 
-                     continue;
 
-                 }
 
-                 if (sigDispense[1].Split(',')[1].ToLower().Contains("true"))
 
-                 {
 
-                     strRet = sigDispense[1].Split(',')[7].Split('/')[index];
 
-                 }
 
-             }
 
-             return strRet;
 
-         }
 
-         public static int GetSpinOffTime(string name)
 
-         {
 
-             int ret = -1;
 
-             DeviceModule moudle = GetDeviceModuleByID(name);
 
-             if (moudle !=null)
 
-             {
 
-                 int.TryParse(moudle.ModuleSpiner.SpinOutTime,out ret);
 
-             }
 
-             return ret;
 
-         }
 
-         public static float GetSpinOffSpeed(string name)
 
-         {
 
-             float ret = -1;
 
-             DeviceModule moudle = GetDeviceModuleByID(name);
 
-             if (moudle != null)
 
-             {
 
-                 float.TryParse(moudle.ModuleSpiner.SpinOutSpeed, out ret);
 
-             }
 
-             return ret;
 
-         }
 
-         public static List<float> GetSpinModulePara(string name, string armName, string pos)
 
-         {
 
-             //Arm1 resist arm
 
-             //Arm2 ebr arm
 
-             //Arm3 spin
 
-             //Arm4 nozzle change
 
-             DeviceModule moudle = GetDeviceModuleByID(name);
 
-             if (moudle is null)
 
-                 return null;
 
-             object obj = null;
 
-             switch (armName)
 
-             {
 
-                 case "Arm1":
 
-                     obj = moudle.ModuleSpiner.NozzleArmInformat1;
 
-                     break;
 
-                 case "Arm2":
 
-                     obj = moudle.ModuleSpiner.NozzleArmInformat2;
 
-                     break;
 
-                 case "Arm4":
 
-                     obj = moudle.ModuleSpiner.NozzleChanger;
 
-                     break;
 
-             }
 
-             if (obj == null)
 
-                 return null;
 
-             List<float> listRet = new List<float>();
 
-             float position = 0;
 
-             float speed = 0;
 
-             float acc = 0;
 
-             float dec = 0;
 
-             float unit = 0;
 
-             if (obj is NozzleArmInformat)
 
-             {
 
-                 NozzleArmInformat arm = obj as NozzleArmInformat;
 
-                 float.TryParse(arm.MotorPulsesRate, out unit);
 
-                 if (pos.ToLower().Contains("begin"))
 
-                     pos = "Begin";
 
-                 if (pos.ToLower().Contains("end"))
 
-                     pos = "End";
 
-                 var prop = arm.GetType().GetProperty(pos);
 
-                 if (prop != null)
 
-                 {
 
-                     TransferArmRecipePositionData data = prop.GetValue(arm) as TransferArmRecipePositionData;
 
-                     float.TryParse(data.Position, out position);
 
-                     float.TryParse(data.Acceleration, out acc);
 
-                     float.TryParse(data.Deceleration, out dec);
 
-                 }
 
-             }
 
-             else if (obj is NozzleChanger)
 
-             {
 
-                 NozzleChanger arm = obj as NozzleChanger;
 
-                 float.TryParse(arm.MotorPulseRate, out unit);
 
-                 int.TryParse(pos, out int index);
 
-                 if (index > 0 && index <= arm.NozzleChangerData.Count)
 
-                 {
 
-                     NozzleChangerData data = arm.NozzleChangerData[index - 1];
 
-                     float.TryParse(data.Position, out position);
 
-                 }
 
-             }
 
-             listRet.Add(position);
 
-             listRet.Add(speed);
 
-             listRet.Add(acc);
 
-             listRet.Add(dec);
 
-             listRet.Add(unit);
 
-             return listRet;
 
-         }
 
-         public static List<string> GetSpinModulePositions(string name, string armName)
 
-         {
 
-             DeviceModule moudle = GetDeviceModuleByID(name);
 
-             if (moudle is null)
 
-                 return null;
 
-             object obj = null;
 
-             switch (armName)
 
-             {
 
-                 case "Arm1":
 
-                     obj = moudle.ModuleSpiner.NozzleArmInformat1;
 
-                     break;
 
-                 case "Arm2":
 
-                     obj = moudle.ModuleSpiner.NozzleArmInformat2;
 
-                     break;
 
-                 case "Arm4":
 
-                     obj = moudle.ModuleSpiner.NozzleChanger;
 
-                     break;
 
-             }
 
-             if (obj == null)
 
-                 return null;
 
-             List<string> listRet = new List<string>();
 
-             if (obj is NozzleArmInformat)
 
-             {
 
-                 foreach (var item in obj.GetType().GetProperties())
 
-                 {
 
-                     if (item.PropertyType == typeof(TransferArmRecipePositionData))
 
-                     {
 
-                         listRet.Add(item.Name);
 
-                     }
 
-                 }
 
-             }
 
-             else if (obj is NozzleChanger)
 
-             {
 
-                 NozzleChanger arm = obj as NozzleChanger;
 
-                 foreach (var item in arm.NozzleChangerData.Where(x => x.IsNozzleChangerEnable.ToLower() == "yes"))
 
-                 {
 
-                     listRet.Add(item.ID);
 
-                 }
 
-             }
 
-             return listRet;
 
-         }
 
-         public static bool SetStnParas(string module, string hand, Dictionary<string, double> robotStnParas)
 
-         {
 
-             var name = module.Replace("PM", "").Replace("_", ".");
 
-             Dictionary<string, object> scItems = new Dictionary<string, object>();
 
-             foreach (var item in robotStnParas.Keys)
 
-             {
 
-                 if (item == "StartOffset" || item == "EndOffset")
 
-                 {
 
-                     scItems.Add($"System.SetUp.Block{name}.TransferArmPosition.Zaxis.{item}", robotStnParas[item]);
 
-                 }
 
-                 else
 
-                 {
 
-                     scItems.Add($"System.SetUp.Block{name}.TransferArmPosition.{hand}.{item}", robotStnParas[item]);
 
-                 }
 
-             }
 
-             SystemConfigManager.Instance.SetItemValues(scItems);
 
-             return true;
 
-         }
 
-         public static bool SetCassetteStnParas(string module, string hand, Dictionary<string, double> robotStnParas)
 
-         {
 
-             if (module.Contains("Cassette"))
 
-             {
 
-                 var name = module.Replace("Cassette", "1.");
 
-                 Dictionary<string, object> scItems = new Dictionary<string, object>();
 
-                 foreach (var item in robotStnParas.Keys)
 
-                 {
 
-                     if (item == "StartOffset" || item == "EndOffset")
 
-                     {
 
-                         scItems.Add($"System.SetUp.Block{name}.TransferArmPosition.Zaxis.{item}", robotStnParas[item]);
 
-                     }
 
-                     else
 
-                     {
 
-                         scItems.Add($"System.SetUp.Block{name}.TransferArmPosition.{hand}.{item}", robotStnParas[item]);
 
-                     }
 
-                 }
 
-                 SystemConfigManager.Instance.SetItemValues(scItems);
 
-             }
 
-             else if (module.Contains("PM"))
 
-             {
 
-                 var name = module.Replace("PM", "").Replace("_", ".");
 
-                 Dictionary<string, object> scItems = new Dictionary<string, object>();
 
-                 foreach (var item in robotStnParas.Keys)
 
-                 {
 
-                     if (item == "StartOffset" || item == "EndOffset")
 
-                     {
 
-                         scItems.Add($"System.SetUp.Block{name}.TransferArmPosition.Zaxis.{item}", robotStnParas[item]);
 
-                     }
 
-                     else
 
-                     {
 
-                         scItems.Add($"System.SetUp.Block{name}.TransferArmPosition.{hand}.{item}", robotStnParas[item]);
 
-                     }
 
-                 }
 
-                 SystemConfigManager.Instance.SetItemValues(scItems);
 
-             }
 
-             return true;
 
-         }
 
-         private static Dictionary<string, string> dicCSMappingKey = new Dictionary<string, string>() {
 
-                 {"FB_THICKNESS","WaferThickness"},
 
-                 {"Z_WAF","FirstSlotposition"},
 
-                 {"PITCH","SlotPitch"},
 
-                 {"MAP_START","MappingStartPosition"},
 
-                 {"MAP_END","MappingEndPosition"},
 
-                 {"NSLOTS","SlotNo"}
 
-             };
 
-         public static bool SetCassetteStnMappingParas(string module, string strData)
 
-         {
 
-             Dictionary<string, int> dicData = new Dictionary<string, int>();
 
-             List<string> lstData = strData.Replace("STN 1", "").Trim(' ').Split(' ').ToList();
 
-             
 
-             for (int i = 0; i < lstData.Count; i=i+2)
 
-             {
 
-                 if(dicCSMappingKey.ContainsKey(lstData[i]))
 
-                     dicData.Add(dicCSMappingKey[lstData[i]], int.Parse(lstData[i + 1]));
 
-             }
 
-             var name = module.Replace("Cassette", "1.");
 
-             Dictionary<string, object> scItems = new Dictionary<string, object>();
 
-             foreach (var item in dicData.Keys)
 
-             {
 
-                 scItems.Add($"System.SetUp.Block{name}.{item}", dicData[item]);
 
-             }
 
-             SystemConfigManager.Instance.SetItemValues(scItems);
 
-             return true;
 
-         }
 
-         public static Dictionary<string,object> GetCassetteStnMappingParas(string module)
 
-         {
 
-             Dictionary<string, object> ret = new Dictionary<string, object>();
 
-             var name = module.Replace("Cassette", "1.");
 
-             foreach (var item in dicCSMappingKey)
 
-             {
 
-                 string key = $"System.SetUp.Block{name}.{item.Value}";
 
-                 object data = SC.GetValue<int>(key);
 
-                 ret.Add(item.Key, data);
 
-             }
 
-             return ret;
 
-         }
 
-         public static EunmTransferOrder GetTransferOrder(string key)
 
-         {
 
-             string configKey = $"Parameter.TransferOutOrInOrder.{key}";
 
-             string value = SC.IsEnable ? SC.GetStringValue(configKey) : QueryDataClient.Instance.Service.GetConfig(configKey)?.ToString();
 
-             EunmTransferOrder ret = EunmTransferOrder.ByTop;
 
-             switch (value)
 
-             {
 
-                 case "Top":
 
-                     ret = EunmTransferOrder.ByTop;
 
-                     break;
 
-                 case "Bottom":
 
-                     ret = EunmTransferOrder.ByBottom;
 
-                     break;
 
-                 case "Slot":
 
-                     ret = EunmTransferOrder.BySlot;
 
-                     break;
 
-             }
 
-             return ret;
 
-         }
 
-         public static MonitorEditData GetMonitorData(string moduleIndex, string controlName)
 
-         {
 
-             InitializeAllBlocks();
 
-             return ParameterManager.Instance.MonitorData.FirstOrDefault(x => x.Module == moduleIndex.Replace("_", "-") && x.MeasDateName.ToLower().Contains(controlName.ToLower()));
 
-         }
 
-         public static List<KeyValuePair<string, DispenseConfig>> GetDPConigData(string moduleIndex)
 
-         {
 
-             InitializeAllBlocks();
 
-             return ParameterManager.Instance.ModuleDispenseConfigList[$"{moduleIndex.Replace("_", "-")}"].Where(x => x.Value.IsChecked).ToList();
 
-         }
 
-         public static FlowSensorData GetDPConigFlowSensorData(string moduleIndex, string deviceName)
 
-         {
 
-             InitializeAllBlocks();
 
-             return ParameterManager.Instance.ModuleDispenseConfigList[moduleIndex].FirstOrDefault(x => x.Value.IsChecked && x.Key == deviceName).Value?.FlowSensorData;
 
-         }
 
-     }
 
- }
 
 
  |