/// <summary>
        ///
        /// </summary>
        /// <param name="startParams">0: L11;1: L22;2: L12;3: C11;4: C22;5: -C12;
        /// 6: fmin;7: fmax;8: l;
        /// 9: z2out;10: z1out;11: z2in;
        /// 12: z1in;13: nf;</param>
        /// <param name="setOfParams">Номер набора параметров начинается с 1, или строка с неазванием параметра</param>
        /// <param name="setOfShematic">Номер набора схемы начинается с 0, или строка с неазванием параметра</param>
        public ACLPParams(double[] startParams, string setOfParams, string setOfShematic)
        {
            if (!Enum.TryParse(setOfParams, out _setOfParameters))
            {
                throw new ArgumentException("Неверный набор параметров");
            }
            if (!Enum.TryParse(setOfShematic, out _setOfShematic))
            {
                throw new ArgumentException("Неверный набор параметров");
            }

            switch (_setOfParameters)
            {
            case SetOfParametersEnum.Pogonie:
                _params.L11 = startParams[0];
                _params.L22 = startParams[1];
                _params.L12 = startParams[2];
                _params.C11 = startParams[3];
                _params.C22 = startParams[4];
                _params.C12 = startParams[5];
                _params     = _pogonCalculateor.Calculate(_params.C11, _params.C12,
                                                          _params.C22, _params.L11, _params.L12, _params.L22);
                break;

            case SetOfParametersEnum.Pogonie_pF_nGn:
                _params.L11 = startParams[0];
                _params.L22 = startParams[1];
                _params.L12 = startParams[2];
                _params.C11 = startParams[3];
                _params.C22 = startParams[4];
                _params.C12 = startParams[5];
                _params     = _pogonCalculateor.Calculate(_params.C11, _params.C12,
                                                          _params.C22, _params.L11, _params.L12, _params.L22);
                break;

            case SetOfParametersEnum.Modalnie:
                _params.Z0  = startParams[0];
                _params.k   = startParams[1];
                _params.Rc  = startParams[2];
                _params.Rp  = startParams[3];
                _params.Erc = startParams[4];
                _params.Erp = startParams[5];
                _params     = _modalCalculateor.CalculateAll(_params.Z0, _params.k, _params.Rc, _params.Rp, _params.Erc, _params.Erp);
                break;

            case SetOfParametersEnum.Zc1_Zp1:
                _params.Zc1 = startParams[0];
                _params.Zp1 = startParams[1];
                _params.Rc  = startParams[2];
                _params.Rp  = startParams[3];
                _params.Erc = startParams[4];
                _params.Erp = startParams[5];
                _params     = _zC1ZC2ZP1ZP2Calculateor.CalculateWithZc1Zp1(_params.Zc1, _params.Zp1, _params.Rc,
                                                                           _params.Rp, _params.Erc, _params.Erp);
                break;

            case SetOfParametersEnum.Zp1_Zc2:
                _params.Zc2 = startParams[0];
                _params.Zp1 = startParams[1];
                _params.Rc  = startParams[2];
                _params.Rp  = startParams[3];
                _params.Erc = startParams[4];
                _params.Erp = startParams[5];
                _params     = _zC1ZC2ZP1ZP2Calculateor.CalculateZc2Zp1(_params.Zc2, _params.Zp1,
                                                                       _params.Rc, _params.Rp, _params.Erc, _params.Erp);
                break;

            case SetOfParametersEnum.Zp1_Zc2_RcOne_RpZero:
                _params.Zc2 = startParams[0];
                _params.Zp1 = startParams[1];
                _params.Rc  = startParams[2];
                _params.Rp  = startParams[3];
                _params.Erc = startParams[4];
                _params.Erp = startParams[5];
                _params     = _zC1ZC2ZP1ZP2Calculateor.CalculateZc2Zp1(_params.Zc2, _params.Zp1,
                                                                       _params.Rc, _params.Rp, _params.Erc, _params.Erp);
                break;

            case SetOfParametersEnum.ModalnieSymm:
                _params.Z0  = startParams[0];
                _params.k   = startParams[1];
                _params.Rc  = startParams[2];
                _params.Rp  = startParams[3];
                _params.Erc = startParams[4];
                _params.Erp = startParams[5];
                _params     = _modalCalculateor.CalculateAll(_params.Z0, _params.k, _params.Rc,
                                                             _params.Rp, _params.Erc, _params.Erp);
                break;
            }

            _l    = startParams[8];
            _fmin = startParams[6];
            _fmax = startParams[7];
            _nf   = (int)startParams[13];
            _z1in = startParams[12];
            _z2in = startParams[11];
            switch (_setOfShematic)
            {
            case SetOfShematicEnum.CLike:
                _z1out = Math.Pow(10, 10);
                _z2out = Math.Pow(10, 10);
                break;

            case SetOfShematicEnum.General:
                _z1out = startParams[10];
                _z2out = startParams[9];
                break;

            case SetOfShematicEnum.LineToLine:
                _z1out = _z1in;
                _z2out = _z2in;
                break;
            }
            var sParamData = new CouplLinesInFreqRange(_params, _l, _fmin, _fmax, _nf, _z1in, _z2in, _z1out, _z2out);

            _params.Length           = _l;
            _params.FreqRange        = sParamData.GetFi();
            _params.Points           = _nf;
            _params.SParamMagnitudes = sParamData.GetSParamMagnitude();
            _params.SParamPhases     = sParamData.GetSParamPhase();
            _params._z1in            = _z1in;
            _params._z1out           = _z1out;
            _params._z2in            = _z2in;
            _params._z2out           = _z2out;
        }
示例#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);
        }