public void addParamItem(Parameter prm)
 {
     if (!mParamList.ContainsKey(prm.symbol))
     {
         mParamList.Add(prm.symbol, prm);
     }
 }
 public bool editParamItem(string symbol, Parameter newParam)
 {
     mParamList[symbol] = newParam;
     return true;
 }
Example #3
0
        public BondParams parsePRM(string strPath, string strPrm)
        {
            BondParams prm = new BondParams();
            prm.setFileName(strPrm);

            string strLine = "";
            var wordCount = 0;

            System.IO.StreamReader fstream = new StreamReader(strPath, Encoding.UTF8);

            while (!fstream.EndOfStream)
            {
                strLine = fstream.ReadLine();

                TotalLineCount++;
                //Skip for comment
                if ((strLine.Length == 0) || strLine.StartsWith("#"))
                {
                    continue;
                }

                //Get words from each lines
                var strWordList = strLine.Split(new[] { "\t", " " }, StringSplitOptions.RemoveEmptyEntries);

                wordCount = strWordList.Count();
                TotalWordCount += wordCount;
                //Empty Line
                if (wordCount == 0)
                {
                    continue;
                }

                //get PRM version
                if (strWordList[0] == "version")
                {
                    if (wordCount >= 2)
                    {
                        prm.setVersion(strWordList[1]);
                        if (strWordList[1] == "0.0")
                        {
                            Console.WriteLine("PRM file version not supported");
                        }
                    }
                    else
                    {
                        Console.WriteLine("PRM file version parse error");
                    }
                }

                if (strWordList[0] == "configurable_contact_detect")
                {
                    if (wordCount >= 2)
                    {
                        prm.setConfigContactDetect(strLine);
                    }
                    else
                    {
                        Console.WriteLine("PRM file configurable contact detect parse error");
                    }
                }

                if (strWordList[0] == "support_fmode_contact_detect")
                {
                    if (wordCount >= 2)
                    {
                        prm.setSuptFModeContactDetect(strLine);
                    }
                    else
                    {
                        Console.WriteLine("PRM file support fmode contact detect parse error");
                    }
                }
                //get each param items
                //FORMAT: "symbol = value units sys_type parm_type class min max default"
                if (wordCount >= 10)
                {
                    if ((strWordList[6] == "UNKNOWN") && (strWordList[5] == "UNKNOWN"))
                    {
                        continue;
                    }
                    else
                    {
                        Parameter param = new Parameter();
                        param.symbol = strWordList[0];
                        param.value = Double.Parse(strWordList[2]);
                        param.units = strWordList[3];
                        param.sysType = strWordList[4];
                        param.parmType = strWordList[5];
                        param.className = strWordList[6];
                        param.minVal = Double.Parse(strWordList[7]);
                        param.maxVal = Double.Parse(strWordList[8]);
                        param.defaultVal = Double.Parse(strWordList[9]);

                        if (wordCount >= 11)
                        {
                            param.processorMinVal = strWordList[10];
                        }

                        if (wordCount >= 12)
                        {
                            param.processorMaxVal = strWordList[11];
                        }

                        //add param Items into BondParams
                        prm.addParamItem(param);
                    }
                }
            }

            fstream.Close();

            return prm;
        }