Example #1
0
        public static LoadGraph LoadLeftTs(string fileName, int nf)
        {
            double[]  S11  = new double[nf];
            double[]  S12  = new double[nf];
            double[]  S13  = new double[nf];
            double[]  S14  = new double[nf];
            double[]  S22  = new double[nf];
            double[]  S23  = new double[nf];
            double[]  S24  = new double[nf];
            double[]  S33  = new double[nf];
            double[]  S34  = new double[nf];
            double[]  S44  = new double[nf];
            double[]  S21  = new double[nf];
            double[]  S31  = new double[nf];
            double[]  S32  = new double[nf];
            double[]  S41  = new double[nf];
            double[]  S42  = new double[nf];
            double[]  S43  = new double[nf];
            double[]  F11  = new double[nf];
            double[]  F12  = new double[nf];
            double[]  F13  = new double[nf];
            double[]  F14  = new double[nf];
            double[]  F22  = new double[nf];
            double[]  F23  = new double[nf];
            double[]  F24  = new double[nf];
            double[]  F33  = new double[nf];
            double[]  F34  = new double[nf];
            double[]  F44  = new double[nf];
            double[]  F21  = new double[nf];
            double[]  F31  = new double[nf];
            double[]  F32  = new double[nf];
            double[]  F41  = new double[nf];
            double[]  F42  = new double[nf];
            double[]  F43  = new double[nf];
            double[]  Fi   = new double[nf];
            var       line = "";
            var       i    = 0;
            var       k    = 0;
            double    z1in;
            double    z1out;
            double    z2in;
            double    z2out;
            LoadGraph dataLoadGraph = new LoadGraph();

            using (StreamReader sr = new StreamReader(fileName, Encoding.UTF8))
            {
                while ((line = sr.ReadLine()) != null)
                {
                    if (line.Contains("[Reference]"))
                    {
                        int    i0 = 0;
                        int    i1 = 0;
                        int    i2 = 0;
                        int    i3 = 0;
                        string v0 = "";
                        string v1 = "";
                        string v2 = "";
                        string v3 = "";
                        string s0 = "";
                        string s1 = "";
                        string s2 = "";

                        i0 = line.IndexOf(" ");
                        s0 = line.Substring(i0 + 1);
                        i1 = s0.IndexOf(" ");
                        s1 = s0.Substring(i1 + 1);
                        i2 = s1.IndexOf(" ");
                        s2 = s1.Substring(i2 + 1);
                        i3 = s2.IndexOf(" ");


                        v0 = line.Substring(i0 + 1, i1).Replace(".", ",");
                        v1 = s0.Substring(i1 + 1, i2).Replace(".", ",");
                        v2 = s1.Substring(i2 + 1, i3).Replace(".", ",");
                        v3 = s2.Substring(i3 + 1).Replace(".", ",");
                        double.TryParse(v0, _styles, _culture, out z1in);
                        double.TryParse(v1, _styles, _culture, out z1out);
                        double.TryParse(v2, _styles, _culture, out z2in);
                        double.TryParse(v3, _styles, _culture, out z2out);
                        dataLoadGraph.RelatedData = new SortedList <string, double>
                        {
                            { "Z1inTextBox", z1in },
                            { "Z2inTextBox", z1out },
                            { "Z1outTextBox", z2in },
                            { "Z2outTextBox", z2out },
                            { "FreqMinTextBox", 0 },
                            { "FreqMaxTextBox", 0 },
                            { "LengthTextBox", 0 },
                            { "NfTextBox", 0 }
                        };
                    }
                    if (!line.Contains("#") && !line.Contains("!") && !line.Contains("]"))
                    {
                        if (k % 4 == 0)
                        {
                            var data = GetStringsWithFreq(line);
                            double.TryParse(data[0].Replace(".", ","), _styles, _culture, out Fi[i]);
                            double.TryParse(data[1].Replace(".", ","), _styles, _culture, out S11[i]);
                            double.TryParse(data[2].Replace(".", ","), _styles, _culture, out F11[i]);
                            double.TryParse(data[3].Replace(".", ","), _styles, _culture, out S12[i]);
                            double.TryParse(data[4].Replace(".", ","), _styles, _culture, out F12[i]);
                            double.TryParse(data[5].Replace(".", ","), _styles, _culture, out S13[i]);
                            double.TryParse(data[6].Replace(".", ","), _styles, _culture, out F13[i]);
                            double.TryParse(data[7].Replace(".", ","), _styles, _culture, out S14[i]);
                            double.TryParse(data[8].Replace(".", ","), _styles, _culture, out F14[i]);
                            i++;
                            if (i == nf)
                            {
                                break;
                            }
                        }
                        if (k % 4 == 1)
                        {
                            var data = GetStringsWithoutFreq(line);

                            double.TryParse(data[0].Replace(".", ","), _styles, _culture, out S21[i - 1]);
                            double.TryParse(data[1].Replace(".", ","), _styles, _culture, out F21[i - 1]);
                            double.TryParse(data[2].Replace(".", ","), _styles, _culture, out S22[i - 1]);
                            double.TryParse(data[3].Replace(".", ","), _styles, _culture, out F22[i - 1]);
                            double.TryParse(data[4].Replace(".", ","), _styles, _culture, out S23[i - 1]);
                            double.TryParse(data[5].Replace(".", ","), _styles, _culture, out F23[i - 1]);
                            double.TryParse(data[6].Replace(".", ","), _styles, _culture, out S24[i - 1]);
                            double.TryParse(data[7].Replace(".", ","), _styles, _culture, out F24[i - 1]);
                        }
                        if (k % 4 == 2)
                        {
                            var data = GetStringsWithoutFreq(line);

                            double.TryParse(data[0].Replace(".", ","), _styles, _culture, out S31[i - 1]);
                            double.TryParse(data[1].Replace(".", ","), _styles, _culture, out F31[i - 1]);
                            double.TryParse(data[2].Replace(".", ","), _styles, _culture, out S32[i - 1]);
                            double.TryParse(data[3].Replace(".", ","), _styles, _culture, out F32[i - 1]);
                            double.TryParse(data[4].Replace(".", ","), _styles, _culture, out S33[i - 1]);
                            double.TryParse(data[5].Replace(".", ","), _styles, _culture, out F33[i - 1]);
                            double.TryParse(data[6].Replace(".", ","), _styles, _culture, out S34[i - 1]);
                            double.TryParse(data[7].Replace(".", ","), _styles, _culture, out F34[i - 1]);
                        }
                        if (k % 4 == 3)
                        {
                            var data = GetStringsWithoutFreq(line);

                            double.TryParse(data[0].Replace(".", ","), _styles, _culture, out S41[i - 1]);
                            double.TryParse(data[1].Replace(".", ","), _styles, _culture, out F41[i - 1]);
                            double.TryParse(data[2].Replace(".", ","), _styles, _culture, out S42[i - 1]);
                            double.TryParse(data[3].Replace(".", ","), _styles, _culture, out F42[i - 1]);
                            double.TryParse(data[4].Replace(".", ","), _styles, _culture, out S43[i - 1]);
                            double.TryParse(data[5].Replace(".", ","), _styles, _culture, out F43[i - 1]);
                            double.TryParse(data[6].Replace(".", ","), _styles, _culture, out S44[i - 1]);
                            double.TryParse(data[7].Replace(".", ","), _styles, _culture, out F44[i - 1]);
                        }

                        k++;
                    }
                }
            }

            dataLoadGraph.data = new double[][]
            {
                Fi, S11, F11, S12, F12, S13, F13, S14, F14, S21, F21, S22, F22, S23, F23, S24, F24, S31, F31, S32, F32,
                S33, F33, S34, F34, S41, F41, S42, F42, S43, F43, S44, F44
            };
            return(dataLoadGraph);
        }
Example #2
0
        public static LoadGraph LoadS4p(string fileName)
        {
            var    loadedParams = new LoadGraph();
            string line;
            double c11          = 0;
            double c22          = 0;
            double c12          = 0;
            double l11          = 0;
            double l22          = 0;
            double l12          = 0;
            double z2Out        = 50;
            double z1Out        = 50;
            double z2In         = 50;
            double z1In         = 50;
            double nf           = 0;
            double l            = 0;
            double fmin         = 0;
            double fmax         = 0;
            var    i            = 0;
            var    stringCounts = 0;
            bool   s4pright     = false;

            using (StreamReader sr = new StreamReader(fileName, Encoding.UTF8))
            {
                while ((line = sr.ReadLine()) != null)
                {
                    if (line.Contains("! ParamApp"))
                    {
                        s4pright = true;
                        break;
                    }
                    else
                    {
                        if (!line.Contains("#") && !line.Contains("!"))
                        {
                            stringCounts++;
                        }
                    }
                }

                sr.Close();
            }

            if (s4pright)
            {
                using (StreamReader sr = new StreamReader(fileName, Encoding.UTF8))
                {
                    while ((line = sr.ReadLine()) != null)
                    {
                        if (line.Contains("C11, pF/m="))
                        {
                            var index = line.IndexOf('=');
                            double.TryParse(line.Substring(index + 1), _styles, _culture, out c11);
                            i++;
                        }

                        if (line.Contains("C22, pF/m="))
                        {
                            var index = line.IndexOf('=');
                            double.TryParse(line.Substring(index + 1), _styles, _culture, out c22);
                            i++;
                        }

                        if (line.Contains("C12, pF/m="))
                        {
                            var index = line.IndexOf('=');
                            double.TryParse(line.Substring(index + 1), _styles, _culture, out c12);
                            i++;
                        }

                        if (line.Contains("L11, μH/m="))
                        {
                            var index = line.IndexOf('=');
                            double.TryParse(line.Substring(index + 1), _styles, _culture, out l11);
                            i++;
                        }

                        if (line.Contains("L22, μH/m="))
                        {
                            var index = line.IndexOf('=');
                            double.TryParse(line.Substring(index + 1), _styles, _culture, out l22);
                            i++;
                        }

                        if (line.Contains("L12, μH/m="))
                        {
                            var index = line.IndexOf('=');
                            double.TryParse(line.Substring(index + 1), _styles, _culture, out l12);
                            i++;
                        }

                        if (line.Contains("Nf="))
                        {
                            var index = line.IndexOf('=');
                            double.TryParse(line.Substring(index + 1), _styles, _culture, out nf);
                            i++;
                        }

                        if (line.Contains("L, mm="))
                        {
                            var index = line.IndexOf('=');
                            double.TryParse(line.Substring(index + 1), _styles, _culture, out l);
                            i++;
                        }

                        if (line.Contains("FreqMax, GHz="))
                        {
                            var index = line.IndexOf('=');
                            double.TryParse(line.Substring(index + 1), _styles, _culture, out fmax);
                            i++;
                        }

                        if (line.Contains("FreqMin, GHz="))
                        {
                            var index = line.IndexOf('=');
                            double.TryParse(line.Substring(index + 1), _styles, _culture, out fmin);
                            i++;
                        }

                        if (i == 10)
                        {
                            sr.Close();
                            break;
                        }
                    }
                }

                var calculator = new CalculateFromPogonie();
                loadedParams.CurrentParams = calculator.Calculate(c11, c12, c22, l11, l12, l22);
                loadedParams.RelatedData   = new SortedList <string, double>
                {
                    { "Z1inTextBox", z1In },
                    { "Z2inTextBox", z2In },
                    { "Z1outTextBox", z1Out },
                    { "Z2outTextBox", z2Out },
                    { "FreqMinTextBox", fmin },
                    { "FreqMaxTextBox", fmax },
                    { "LengthTextBox", l },
                    { "NfTextBox", nf }
                };
            }
            else
            {
                loadedParams = LoadLeftS4p(fileName, stringCounts / 4);
            }

            loadedParams.inParams = s4pright;
            return(loadedParams);
        }
Example #3
0
        public static LoadGraph LoadLeftS4p(string fileName, int nf)
        {
            double[] S11             = new double[nf];
            double[] S12             = new double[nf];
            double[] S13             = new double[nf];
            double[] S14             = new double[nf];
            double[] S22             = new double[nf];
            double[] S23             = new double[nf];
            double[] S24             = new double[nf];
            double[] S33             = new double[nf];
            double[] S34             = new double[nf];
            double[] S44             = new double[nf];
            double[] S21             = new double[nf];
            double[] S31             = new double[nf];
            double[] S32             = new double[nf];
            double[] S41             = new double[nf];
            double[] S42             = new double[nf];
            double[] S43             = new double[nf];
            double[] F11             = new double[nf];
            double[] F12             = new double[nf];
            double[] F13             = new double[nf];
            double[] F14             = new double[nf];
            double[] F22             = new double[nf];
            double[] F23             = new double[nf];
            double[] F24             = new double[nf];
            double[] F33             = new double[nf];
            double[] F34             = new double[nf];
            double[] F44             = new double[nf];
            double[] F21             = new double[nf];
            double[] F31             = new double[nf];
            double[] F32             = new double[nf];
            double[] F41             = new double[nf];
            double[] F42             = new double[nf];
            double[] F43             = new double[nf];
            double[] Fi              = new double[nf];
            var      line            = "";
            var      i               = 0;
            var      k               = 0;
            int      indexOfLoad     = 0;
            double   terminationLoad = 0;
            var      dataLoadGraph   = new LoadGraph();

            using (StreamReader sr = new StreamReader(fileName, Encoding.UTF8))
            {
                while ((line = sr.ReadLine()) != null)
                {
                    if (line.Contains("#") && line.Contains("GHz"))
                    {
                        indexOfLoad = line.IndexOf("R", StringComparison.Ordinal) + 2;
                        double.TryParse(line.Substring(indexOfLoad), out terminationLoad);
                        dataLoadGraph.RelatedData = new SortedList <string, double>
                        {
                            { "Z1inTextBox", terminationLoad },
                            { "Z2inTextBox", terminationLoad },
                            { "Z1outTextBox", terminationLoad },
                            { "Z2outTextBox", terminationLoad },
                            { "FreqMinTextBox", 0 },
                            { "FreqMaxTextBox", 0 },
                            { "LengthTextBox", 0 },
                            { "NfTextBox", 0 }
                        };
                    }
                    if (!line.Contains("#") && !line.Contains("!"))
                    {
                        if (k % 4 == 0)
                        {
                            var data = GetStringsWithFreq(line);
                            double.TryParse(data[0].Replace(".", ","), _styles, _culture, out Fi[i]);
                            double.TryParse(data[1].Replace(".", ","), _styles, _culture, out S11[i]);
                            double.TryParse(data[2].Replace(".", ","), _styles, _culture, out F11[i]);
                            double.TryParse(data[3].Replace(".", ","), _styles, _culture, out S12[i]);
                            double.TryParse(data[4].Replace(".", ","), _styles, _culture, out F12[i]);
                            double.TryParse(data[5].Replace(".", ","), _styles, _culture, out S13[i]);
                            double.TryParse(data[6].Replace(".", ","), _styles, _culture, out F13[i]);
                            double.TryParse(data[7].Replace(".", ","), _styles, _culture, out S14[i]);
                            double.TryParse(data[8].Replace(".", ","), _styles, _culture, out F14[i]);
                            i++;
                            if (i == nf)
                            {
                                break;
                            }
                        }
                        if (k % 4 == 1)
                        {
                            var data = GetStringsWithoutFreq(line);

                            double.TryParse(data[0].Replace(".", ","), _styles, _culture, out S21[i]);
                            double.TryParse(data[1].Replace(".", ","), _styles, _culture, out F21[i]);
                            double.TryParse(data[2].Replace(".", ","), _styles, _culture, out S22[i]);
                            double.TryParse(data[3].Replace(".", ","), _styles, _culture, out F22[i]);
                            double.TryParse(data[4].Replace(".", ","), _styles, _culture, out S23[i]);
                            double.TryParse(data[5].Replace(".", ","), _styles, _culture, out F23[i]);
                            double.TryParse(data[6].Replace(".", ","), _styles, _culture, out S24[i]);
                            double.TryParse(data[7].Replace(".", ","), _styles, _culture, out F24[i]);
                        }
                        if (k % 4 == 2)
                        {
                            var data = GetStringsWithoutFreq(line);

                            double.TryParse(data[0].Replace(".", ","), _styles, _culture, out S31[i]);
                            double.TryParse(data[1].Replace(".", ","), _styles, _culture, out F31[i]);
                            double.TryParse(data[2].Replace(".", ","), _styles, _culture, out S32[i]);
                            double.TryParse(data[3].Replace(".", ","), _styles, _culture, out F32[i]);
                            double.TryParse(data[4].Replace(".", ","), _styles, _culture, out S33[i]);
                            double.TryParse(data[5].Replace(".", ","), _styles, _culture, out F33[i]);
                            double.TryParse(data[6].Replace(".", ","), _styles, _culture, out S34[i]);
                            double.TryParse(data[7].Replace(".", ","), _styles, _culture, out F34[i]);
                        }
                        if (k % 4 == 3)
                        {
                            var data = GetStringsWithoutFreq(line);

                            double.TryParse(data[0].Replace(".", ","), _styles, _culture, out S41[i]);
                            double.TryParse(data[1].Replace(".", ","), _styles, _culture, out F41[i]);
                            double.TryParse(data[2].Replace(".", ","), _styles, _culture, out S42[i]);
                            double.TryParse(data[3].Replace(".", ","), _styles, _culture, out F42[i]);
                            double.TryParse(data[4].Replace(".", ","), _styles, _culture, out S43[i]);
                            double.TryParse(data[5].Replace(".", ","), _styles, _culture, out F43[i]);
                            double.TryParse(data[6].Replace(".", ","), _styles, _culture, out S44[i]);
                            double.TryParse(data[7].Replace(".", ","), _styles, _culture, out F44[i]);
                        }

                        k++;
                    }
                }
            }

            dataLoadGraph.data = new double[][]
            {
                Fi, S11, F11, S12, F12, S13, F13, S14, F14, S21, F21, S22, F22, S23, F23, S24, F24, S31, F31, S32, F32,
                S33, F33, S34, F34, S41, F41, S42, F42, S43, F43, S44, F44
            };
            return(dataLoadGraph);
        }