Example #1
0
            public void Add(double[] real, double[] imag, string name)
            {
                if (real.Length != _nbFreq || imag.Length != _nbFreq)
                {
                    throw new Exception("Invalid number of impedance values provided");
                }
                Impedance Imp = new Impedance();
                Imp.isNull = false;
                Imp.isDB = false;
                Imp.isUserDefined = true;
                Imp.real = real;
                Imp.imag = imag;
                Imp.name = name;
                _impedances.Add(Imp);

                int index = _impedances.Count;
                double[] Z = new double[_nbFreq * 2];
                for (int i = 0; i < _nbFreq; i++)
                {
                    Z[2 * i] = real[i];
                    Z[2 * i + 1] = imag[i];
                }
                int ret = P2P_SetImpedanceRI(_p2pStruct, index, ref Z[0]);
                if (ret == 0) { throw new Exception("Error adding new impedance value"); }
            }
Example #2
0
 private Impedance ReadImpedance(int Index, int NbFreq)
 {
     Impedance Imp = new Impedance();
     double sig = 0;
     double th = 0;
     int res = P2P_GetImpedanceDB(_p2pStruct, Index, ref sig, ref th);
     if (res != 0)
     {
         Imp.isNull = false;
         Imp.isDB = true;
         Imp.sigma = sig;
         Imp.thickness = th;
         Imp.name = ImpedanceName(sig);
     }
     else
     {
         double[] Z = new double[2 * NbFreq];
         res = P2P_GetImpedanceRI(_p2pStruct, Index, ref Z[0]);
         if (res != 0)
         {
             Imp.isNull = false;
             Imp.isDB = false;
             for (int i = 0; i < NbFreq; i++)
             {
                 Imp.real[i] = Z[2 * i];
                 Imp.imag[i] = Z[2 * i + 1];
             }
             Imp.name = "Std impedance #" + Index.ToString();
         }
     }
     return Imp;
 }
Example #3
0
            public void Add(double sigma, double thickness, string name)
            {
                if (Count == MAX_IMPEDANCE)
                {
                    throw new Exception("Number of impedances is limirted to " + MAX_IMPEDANCE.ToString());
                }
                Impedance Imp = new Impedance();
                Imp.isNull = false;
                Imp.isDB = true;
                Imp.isUserDefined = true;
                Imp.sigma = sigma;
                Imp.thickness = thickness;
                Imp.name = name;
                _impedances.Add(Imp);

                int index = _impedances.Count;
                int ret = P2P_SetImpedanceDB(_p2pStruct, index, sigma, thickness);
                if (ret == 0) { throw new Exception("Error adding new impedance value"); }
            }