コード例 #1
0
ファイル: KNS.cs プロジェクト: Dongeon/RecipeParsing
        public List <RecipeConfigKnsWm> KNSWirePARSE(string sDirPath, string recipeName)
        {
            //string BODY_MGR_CODE = DateTime.Now.ToString("yyyyMMddHHmmss") + SequenceGeneratorGlobal.GetInstance().Next().ToString("0000");
            //string sDirPath = string.Empty;
            System.IO.DirectoryInfo DI = null;
            string fileExtension       = string.Empty;
            string fileRead            = string.Empty;
            string fileName            = string.Empty;
            string groupid             = string.Empty;
            string wireMaster          = string.Empty;
            string masterxValue        = string.Empty;
            string masteryValue        = string.Empty;
            string masteryUnit         = string.Empty;
            string units          = string.Empty;
            string RESULT_X_VALUE = string.Empty;
            string RESULT_Y_VALUE = string.Empty;
            string X_LSL          = string.Empty;
            string X_USL          = string.Empty;
            string Y_LSL          = string.Empty;
            string Y_USL          = string.Empty;


            string[] fileSplit;

            RecipeConfigKnsWm recipeConfig = null;

            ArrayList REFList     = new ArrayList();
            ArrayList groupIdList = new ArrayList();
            List <RecipeConfigKnsWm> RecipeParaList = new List <RecipeConfigKnsWm>();
            ArrayList RecipeWireList = new ArrayList();

            #region
            //-- 1. 이름변경 'Recipename.tgz', 2. TGZ 압축해제(untgz_RECIPENAME)

            //DI = new System.IO.DirectoryInfo(filePath);
            //string tgzFileName = filePath + recipeName + ".tgz";
            //foreach (var item in DI.GetFiles())
            //{
            //    if (item.Name.Equals(recipeName))
            //    {
            //        System.IO.File.Copy(filePath + recipeName, tgzFileName, true);
            //        break;
            //    }
            //}

            //sDirPath = filePath + "untgz_" + recipeName + "\\";
            //DI = new DirectoryInfo(sDirPath);
            //if (DI.Exists == false)
            //{
            //    DI.Create();
            //}
            //FIleCompact.UnTgz(tgzFileName, sDirPath);

            //            Directory.Delete(tgzFileName, true);

            //fileExtension = string.Empty;
            //-- 3. Parameter(.PRM) Group ID = .WIR


            //DI = null;
            #endregion
            DI = new System.IO.DirectoryInfo(sDirPath);

            foreach (var item in DI.GetFiles())
            {
                if (item.Extension == ".BND")
                {
                    try
                    {
                        fileSplit     = null;
                        fileExtension = item.Name;
                        fileRead      = File.ReadAllText(sDirPath + item.Name);
                        fileSplit     = fileRead.Split('\n');
                        for (int i = 0; i < fileSplit.Length; i++)
                        {
                            if (fileSplit[i].Contains("ref"))
                            {
                                string[] paraSplit = fileSplit[i].ToString().Replace("\t", " ").Split(' ');
                                if (paraSplit[1].Contains(".REF"))
                                {
                                    REFList.Add(paraSplit[1]);
                                }
                            }
                        }
                        fileRead  = null;
                        fileSplit = null;
                    }
                    catch (Exception ex)
                    {
                        fileRead  = null;
                        fileSplit = null;
                    }
                }
            }

            groupIdList = null;
            string b = null;

            foreach (var item in DI.GetFiles())
            //Get wiremap data
            {
                List <string> wireRefactoring = new List <string>();
                try
                {
                    if (item.Extension.Equals(".REF"))
                    {
                        fileRead   = File.ReadAllText(sDirPath + item.Name);
                        fileName   = item.Name;
                        fileSplit  = fileRead.Replace("\r", "").Split('\n');
                        wireMaster = null;
                        for (int j = 0; j < fileSplit.Length; j++)
                        {
                            recipeConfig = new RecipeConfigKnsWm();
                            if (fileSplit[j].Contains("name"))
                            {
                                groupid = fileSplit[j].Split('\t')[1];
                                //recipeConfig.GROUP_ID = fileSplit[j].Split('\t')[1];
                            }
                            else if (fileSplit[j].Contains("opp") && !fileSplit[j].Contains("_"))
                            {
                                string a = null;

                                if (wireMaster == null && fileSplit[j + 1].Contains("loc"))
                                {
                                    wireMaster                  = fileSplit[j].Split(' ')[1];
                                    masterxValue                = fileSplit[j + 1].Split('\t')[4];
                                    masteryValue                = fileSplit[j + 1].Split('\t')[5];
                                    masteryUnit                 = fileSplit[j + 1].Split('\t')[6];
                                    recipeConfig.FILE_NAME      = fileName;
                                    recipeConfig.GROUP_ID       = groupid;
                                    recipeConfig.ITEM_ID        = wireMaster;
                                    recipeConfig.ITEM_UNIT      = masteryUnit;
                                    recipeConfig.MASTER_ID      = wireMaster;
                                    recipeConfig.MASTER_X_VALUE = masterxValue;
                                    recipeConfig.MASTER_Y_VALUE = masteryValue;
                                    recipeConfig.COMPARE_YN     = "N";
                                    recipeConfig.FILE_NAME      = fileName;
                                    recipeConfig.REVISION       = null;
                                    RecipeParaList.Add(recipeConfig);
                                }
                                recipeConfig = null;
                            }
                            else if (fileSplit[j].Contains("site") && fileSplit[j].Contains("{"))
                            {
                                string a       = null;
                                string itemasd = fileSplit[j].ToString();
                                recipeConfig.ITEM_ID = fileSplit[j].Split(' ')[0] + " " + fileSplit[j].Split(' ')[1];
                                if (fileSplit[j + 1].Contains("loc"))
                                {
                                    recipeConfig.GROUP_ID       = groupid;
                                    recipeConfig.WIRE_X_VALUE   = fileSplit[j + 1].Split('\t')[4];
                                    recipeConfig.WIRE_Y_VALUE   = fileSplit[j + 1].Split('\t')[5];
                                    recipeConfig.ITEM_UNIT      = fileSplit[j + 1].Split('\t')[6];
                                    recipeConfig.MASTER_ID      = wireMaster;
                                    recipeConfig.MASTER_X_VALUE = masterxValue;
                                    recipeConfig.MASTER_Y_VALUE = masteryValue;
                                    recipeConfig.COMPARE_YN     = "Y";
                                    recipeConfig.FILE_NAME      = fileName;
                                    recipeConfig.WB_VALUE       = "10";
                                    recipeConfig.RESULT_X_VALUE = calculationResult(masterxValue, recipeConfig.WIRE_X_VALUE);
                                    recipeConfig.RESULT_Y_VALUE = calculationResult(masteryValue, recipeConfig.WIRE_Y_VALUE);
                                    recipeConfig.X_LSL          = calculationLsl(recipeConfig.RESULT_X_VALUE, recipeConfig.WB_VALUE);
                                    recipeConfig.X_USL          = calculationUsl(recipeConfig.RESULT_X_VALUE, recipeConfig.WB_VALUE);
                                    recipeConfig.Y_LSL          = calculationLsl(recipeConfig.RESULT_Y_VALUE, recipeConfig.WB_VALUE);
                                    recipeConfig.Y_USL          = calculationUsl(recipeConfig.RESULT_Y_VALUE, recipeConfig.WB_VALUE);
                                    recipeConfig.VALID          = valid(recipeConfig.RESULT_X_VALUE, recipeConfig.X_LSL, recipeConfig.X_USL, recipeConfig.RESULT_Y_VALUE, recipeConfig.Y_LSL, recipeConfig.Y_USL).ToString();

                                    recipeConfig.REVISION = null;
                                }
                                RecipeParaList.Add(recipeConfig);
                            }
                        }
                        //RecipeWireList.Add(recipeConfig);
                    }
                }
                catch (Exception ex)
                {
                    fileSplit = null;
                    fileRead  = null;
                }
            }
            return(RecipeParaList);
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: Dongeon/RecipeParsing
        private void dataGridViewWM_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            //-- Revision row Data
            if (Global.FilePath.Contains("KNS"))
            {
                RecipeConfigKnsWm revision = Global.KnsWireList[e.RowIndex];
                KNS kns = new KNS();
                //-- 범위검사

                if (e.ColumnIndex == 5 || e.ColumnIndex == 6)
                {
                    revision.RESULT_X_VALUE = kns.calculationResult(revision.MASTER_X_VALUE, revision.WIRE_X_VALUE);
                    revision.RESULT_Y_VALUE = kns.calculationResult(revision.MASTER_Y_VALUE, revision.WIRE_Y_VALUE);

                    revision.X_LSL = kns.calculationLsl(revision.RESULT_X_VALUE, revision.WB_VALUE);
                    revision.X_USL = kns.calculationUsl(revision.RESULT_X_VALUE, revision.WB_VALUE);
                    revision.Y_LSL = kns.calculationLsl(revision.RESULT_Y_VALUE, revision.WB_VALUE);
                    revision.Y_USL = kns.calculationUsl(revision.RESULT_Y_VALUE, revision.WB_VALUE);

                    if (!kns.valid(revision.RESULT_X_VALUE, revision.X_LSL, revision.X_USL, revision.RESULT_Y_VALUE, revision.Y_LSL, revision.Y_USL))
                    {
                        MessageBox.Show("out of range.");
                        dataGridViewWM.DataSource = Global.KnsWireList;
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("바꿀수 없는 항목입니다.");
                    //-- roll back
                    return;
                }

                //-- changeKnsParaList 의 중복 검사

                if (Global.changeKnsWireList.Count == 0)
                {
                    Global.changeKnsWireList.Add(revision);
                    Global.KnsWireList[e.RowIndex] = revision;
                }
                else
                {
                    List <int> dblIndx = new List <int>();

                    //-- set check list
                    for (int i = 0; i < Global.changeKnsWireList.Count; i++)
                    {
                        string checkGroupItem    = Global.changeKnsWireList[i].GROUP_ID + "/" + Global.changeKnsWireList[i].ITEM_ID;
                        string revisionGroupItem = revision.GROUP_ID + "/" + revision.ITEM_ID;
                        if (checkGroupItem == revisionGroupItem)
                        {
                            dblIndx.Add(i);
                        }
                    }

                    if (dblIndx.Count == 0)
                    {
                        Global.changeKnsWireList.Add(revision);
                    }
                    else
                    {
                        foreach (int removeIndex in dblIndx)
                        {
                            Global.changeKnsWireList.RemoveAt(removeIndex);
                            Global.changeKnsWireList.Add(revision);
                        }
                    }
                    dblIndx = null;
                    //-- Revision flag
                    //Global.changeKnsWireList.Add(revision);
                    Global.KnsWireList[e.RowIndex] = revision;
                }
                dataGridViewWM.DataSource = Global.KnsWireList;
                revision = null;
                if (Global.changeKnsParaList.Count != 0 || Global.changeKnsWireList.Count != 0)
                {
                    lblStatus.Text = "Revision";
                }
            }
            else if (Global.FilePath.Contains("SKW"))
            {
            }
        }