Exemple #1
0
        public void EfieldCalTest15()
        {
            string uan = uanstr; // TODO: 初始化为适当的值

            ReadUan.GetGainPara(uan);
            double power1      = 1;                             // TODO: 初始化为适当的值
            double frequency   = 1000;                          // TODO: 初始化为适当的值
            Point  originPoint = new Point(0, 0, 0);            // TODO: 初始化为适当的值
            Point  targetPoint = new Point(1, 1, Math.Sqrt(2)); // TODO: 初始化为适当的值
            Point  rotateAngle = null;                          // TODO: 初始化为适当的值
            EField expected    = new EField();                  // TODO: 初始化为适当的值

            expected.X.Re = 0.191101863744437;
            expected.X.Im = -0.330998137426465;
            expected.Y.Re = -2.54751092378142;
            expected.Y.Im = 4.41241835282609;
            expected.Z.Re = 1.66623282560157;
            expected.Z.Im = -2.88599991118093;
            EField actual;

            actual = DirectEfieldCal.EfieldCal(uan, power1, frequency, originPoint, targetPoint, rotateAngle);
            Assert.IsTrue((Math.Abs(expected.X.Re - actual.X.Re) < 0.00001) && (Math.Abs(expected.X.Im - actual.X.Im) < 0.00001) &&
                          (Math.Abs(expected.Y.Re - actual.Y.Re) < 0.00001) && (Math.Abs(expected.Y.Im - actual.Y.Im) < 0.00001) &&
                          (Math.Abs(expected.Z.Re - actual.Z.Re) < 0.00001) && (Math.Abs(expected.Z.Im - actual.Z.Im) < 0.00001));
            //Assert.Inconclusive("验证此测试方法的正确性。");
        }
Exemple #2
0
        public void EfieldCalTest1()
        {
            string uan = uanstr; // TODO: 初始化为适当的值

            ReadUan.GetGainPara(uan);
            double power1      = 1;                  // TODO: 初始化为适当的值
            double frequency   = 1000;               // TODO: 初始化为适当的值
            Point  originPoint = new Point(0, 0, 0); // TODO: 初始化为适当的值
            Point  targetPoint = new Point(1, 0, 0); // TODO: 初始化为适当的值
            Point  rotateAngle = null;               // TODO: 初始化为适当的值
            EField expected    = new EField();       // TODO: 初始化为适当的值

            expected.X.Re = 0;
            expected.X.Im = 0;
            expected.Y.Re = -3.8729833462074;
            expected.Y.Im = -6.70820393249938;
            expected.Z.Re = 6.66493056834915;
            expected.Z.Im = 11.5439983732997;
            EField actual;

            actual = DirectEfieldCal.EfieldCal(uan, power1, frequency, originPoint, targetPoint, rotateAngle);
            Assert.IsTrue((Math.Abs(expected.X.Re - actual.X.Re) < 0.00001) && (Math.Abs(expected.X.Im - actual.X.Im) < 0.00001) &&
                          (Math.Abs(expected.Y.Re - actual.Y.Re) < 0.00001) && (Math.Abs(expected.Y.Im - actual.Y.Im) < 0.00001) &&
                          (Math.Abs(expected.Z.Re - actual.Z.Re) < 0.00001) && (Math.Abs(expected.Z.Im - actual.Z.Im) < 0.00001));
            //Assert.Inconclusive("验证此测试方法的正确性。");
        }
Exemple #3
0
        public void EfieldCalTest12()
        {
            string uan = uanstr; // TODO: 初始化为适当的值

            ReadUan.GetGainPara(uan);
            double power1      = 1;                                 // TODO: 初始化为适当的值
            double frequency   = 1000;                              // TODO: 初始化为适当的值
            Point  originPoint = new Point(0, 0, 0);                // TODO: 初始化为适当的值
            Point  targetPoint = new Point(1, 0, Math.Sqrt(3) / 3); // TODO: 初始化为适当的值
            Point  rotateAngle = null;                              // TODO: 初始化为适当的值
            EField expected    = new EField();                      // TODO: 初始化为适当的值

            expected.X.Re = 2.9127396218559;
            expected.X.Im = 4.06237996247662;
            expected.Y.Re = 3.90886803931641;
            expected.Y.Im = 5.45167411454598;
            expected.Z.Re = -5.04501301427337;
            expected.Z.Im = -7.03624849465925;
            EField actual;

            actual = DirectEfieldCal.EfieldCal(uan, power1, frequency, originPoint, targetPoint, rotateAngle);
            Assert.IsTrue((Math.Abs(expected.X.Re - actual.X.Re) < 0.00001) && (Math.Abs(expected.X.Im - actual.X.Im) < 0.00001) &&
                          (Math.Abs(expected.Y.Re - actual.Y.Re) < 0.00001) && (Math.Abs(expected.Y.Im - actual.Y.Im) < 0.00001) &&
                          (Math.Abs(expected.Z.Re - actual.Z.Re) < 0.00001) && (Math.Abs(expected.Z.Im - actual.Z.Im) < 0.00001));
            //Assert.Inconclusive("验证此测试方法的正确性。");
        }
Exemple #4
0
        public void EfieldCalTest13()
        {
            string uan = uanstr; // TODO: 初始化为适当的值

            ReadUan.GetGainPara(uan);
            double power1      = 1;                             // TODO: 初始化为适当的值
            double frequency   = 1000;                          // TODO: 初始化为适当的值
            Point  originPoint = new Point(0, 0, 0);            // TODO: 初始化为适当的值
            Point  targetPoint = new Point(1, 0, Math.Sqrt(3)); // TODO: 初始化为适当的值
            Point  rotateAngle = null;                          // TODO: 初始化为适当的值
            EField expected    = new EField();                  // TODO: 初始化为适当的值

            expected.X.Re = -1.44299978225551;
            expected.X.Im = 2.4993489381773;
            expected.Y.Re = -1.93649167310375;
            expected.Y.Im = 3.35410196624966;
            expected.Z.Re = 0.833116312725791;
            expected.Z.Im = -1.44299978225547;
            EField actual;

            actual = DirectEfieldCal.EfieldCal(uan, power1, frequency, originPoint, targetPoint, rotateAngle);
            Assert.IsTrue((Math.Abs(expected.X.Re - actual.X.Re) < 0.00001) && (Math.Abs(expected.X.Im - actual.X.Im) < 0.00001) &&
                          (Math.Abs(expected.Y.Re - actual.Y.Re) < 0.00001) && (Math.Abs(expected.Y.Im - actual.Y.Im) < 0.00001) &&
                          (Math.Abs(expected.Z.Re - actual.Z.Re) < 0.00001) && (Math.Abs(expected.Z.Im - actual.Z.Im) < 0.00001));
            //Assert.Inconclusive("验证此测试方法的正确性。");
        }
Exemple #5
0
        public void EfieldCalTest10()
        {
            string uan = uanstr; // TODO: 初始化为适当的值

            ReadUan.GetGainPara(uan);
            double power1      = 1;                             // TODO: 初始化为适当的值
            double frequency   = 1000;                          // TODO: 初始化为适当的值
            Point  originPoint = new Point(0, 0, 0);            // TODO: 初始化为适当的值
            Point  targetPoint = new Point(1, Math.Sqrt(3), 0); // TODO: 初始化为适当的值
            Point  rotateAngle = null;                          // TODO: 初始化为适当的值
            EField expected    = new EField();                  // TODO: 初始化为适当的值

            expected.X.Re = 1.67705098312488;
            expected.X.Im = -2.90473750965554;
            expected.Y.Re = -0.968245836551877;
            expected.Y.Im = 1.67705098312483;
            expected.Z.Re = 3.33246528417467;
            expected.Z.Im = -5.77199918664981;
            EField actual;

            actual = DirectEfieldCal.EfieldCal(uan, power1, frequency, originPoint, targetPoint, rotateAngle);
            Assert.IsTrue((Math.Abs(expected.X.Re - actual.X.Re) < 0.00001) && (Math.Abs(expected.X.Im - actual.X.Im) < 0.00001) &&
                          (Math.Abs(expected.Y.Re - actual.Y.Re) < 0.00001) && (Math.Abs(expected.Y.Im - actual.Y.Im) < 0.00001) &&
                          (Math.Abs(expected.Z.Re - actual.Z.Re) < 0.00001) && (Math.Abs(expected.Z.Im - actual.Z.Im) < 0.00001));
            //Assert.Inconclusive("验证此测试方法的正确性。");
        }
Exemple #6
0
        public void EfieldCalTest11()
        {
            string uan = uanstr; // TODO: 初始化为适当的值

            ReadUan.GetGainPara(uan);
            double power1      = 1;                  // TODO: 初始化为适当的值
            double frequency   = 1000;               // TODO: 初始化为适当的值
            Point  originPoint = new Point(0, 0, 0); // TODO: 初始化为适当的值
            Point  targetPoint = new Point(1, 0, 1); // TODO: 初始化为适当的值
            Point  rotateAngle = null;               // TODO: 初始化为适当的值
            EField expected    = new EField();       // TODO: 初始化为适当的值

            expected.X.Re = -1.05564268913923;
            expected.X.Im = 4.59306794482337;
            expected.Y.Re = -1.22686532511019;
            expected.Y.Im = 5.33805221724575;
            expected.Z.Re = 1.05564268913923;
            expected.Z.Im = -4.59306794482337;
            EField actual;

            actual = DirectEfieldCal.EfieldCal(uan, power1, frequency, originPoint, targetPoint, rotateAngle);
            Assert.IsTrue((Math.Abs(expected.X.Re - actual.X.Re) < 0.00001) && (Math.Abs(expected.X.Im - actual.X.Im) < 0.00001) &&
                          (Math.Abs(expected.Y.Re - actual.Y.Re) < 0.00001) && (Math.Abs(expected.Y.Im - actual.Y.Im) < 0.00001) &&
                          (Math.Abs(expected.Z.Re - actual.Z.Re) < 0.00001) && (Math.Abs(expected.Z.Im - actual.Z.Im) < 0.00001));
            //Assert.Inconclusive("验证此测试方法的正确性。");
        }
Exemple #7
0
        public void EfieldCalTest9()
        {
            string uan = uanstr; // TODO: 初始化为适当的值

            ReadUan.GetGainPara(uan);
            double power1      = 1;                                 // TODO: 初始化为适当的值
            double frequency   = 1000;                              // TODO: 初始化为适当的值
            Point  originPoint = new Point(0, 0, 0);                // TODO: 初始化为适当的值
            Point  targetPoint = new Point(1, Math.Sqrt(3) / 3, 0); // TODO: 初始化为适当的值
            Point  rotateAngle = null;                              // TODO: 初始化为适当的值
            EField expected    = new EField();                      // TODO: 初始化为适当的值

            expected.X.Re = -1.95443401965821;
            expected.X.Im = -2.72583705727299;
            expected.Y.Re = 3.38517902208908;
            expected.Y.Im = 4.72128827635085;
            expected.Z.Re = -6.72668373552254;
            expected.Z.Im = -9.38166426413794;
            EField actual;

            actual = DirectEfieldCal.EfieldCal(uan, power1, frequency, originPoint, targetPoint, rotateAngle);
            Assert.IsTrue((Math.Abs(expected.X.Re - actual.X.Re) < 0.00001) && (Math.Abs(expected.X.Im - actual.X.Im) < 0.00001) &&
                          (Math.Abs(expected.Y.Re - actual.Y.Re) < 0.00001) && (Math.Abs(expected.Y.Im - actual.Y.Im) < 0.00001) &&
                          (Math.Abs(expected.Z.Re - actual.Z.Re) < 0.00001) && (Math.Abs(expected.Z.Im - actual.Z.Im) < 0.00001));
            //Assert.Inconclusive("验证此测试方法的正确性。");
        }
Exemple #8
0
        public void EfieldCalTest8()
        {
            string uan = uanstr; // TODO: 初始化为适当的值

            ReadUan.GetGainPara(uan);
            double power1      = 1;                   // TODO: 初始化为适当的值
            double frequency   = 1000;                // TODO: 初始化为适当的值
            Point  originPoint = new Point(0, 0, 0);  // TODO: 初始化为适当的值
            Point  targetPoint = new Point(1, -1, 0); // TODO: 初始化为适当的值
            Point  rotateAngle = null;                // TODO: 初始化为适当的值
            EField expected    = new EField();        // TODO: 初始化为适当的值

            expected.X.Re = -0.867524790988055;
            expected.X.Im = 3.77457292114235;
            expected.Y.Re = -0.867524790988055;
            expected.Y.Im = 3.77457292114236;
            expected.Z.Re = 2.11128514574735;
            expected.Z.Im = -9.18613487791125;
            EField actual;

            actual = DirectEfieldCal.EfieldCal(uan, power1, frequency, originPoint, targetPoint, rotateAngle);
            Assert.IsTrue((Math.Abs(expected.X.Re - actual.X.Re) < 0.00001) && (Math.Abs(expected.X.Im - actual.X.Im) < 0.00001) &&
                          (Math.Abs(expected.Y.Re - actual.Y.Re) < 0.00001) && (Math.Abs(expected.Y.Im - actual.Y.Im) < 0.00001) &&
                          (Math.Abs(expected.Z.Re - actual.Z.Re) < 0.00001) && (Math.Abs(expected.Z.Im - actual.Z.Im) < 0.00001));
            //Assert.Inconclusive("验证此测试方法的正确性。");
        }
Exemple #9
0
        public PowerTest()
        {
            StreamReader sr = new StreamReader(@"C:\Users\wangnan\Desktop\EMC_Project\FinalCode6\1st_ctrl\WI_Wrapper\TestForCal\bin\Debug\HalfWaveDipole.uan");
            string       s2 = sr.ReadToEnd();

            ReadUan.GetGainPara(s2);
        }
Exemple #10
0
        public PowerTest()
        {
            StreamReader sr = new StreamReader(@"C:\Users\wangnan\Desktop\新建文件夹\FinalCode6\1st_ctrl\WI_Wrapper\TestForCal\bin\Debug\");
            string       s2 = sr.ReadToEnd();

            ReadUan.GetGainPara(s2);
        }
Exemple #11
0
        public static void Calculate(string setuppath, string terpath, string txpath, string rxpath)
        {
            //此判断用来将ter文件中的三角面读入Intersection.Tris中
            Terrain     newTer        = new Terrain(terpath);
            string      DirectoryPath = GetDirectory(setuppath) + "result\\";
            SetupObject setupOne      = SetupFileProceed.GetSetupFile.GetSetup(setuppath);
            int         txTotal       = setupOne.tr.FirstAvailableTxNumber;
            string      ProName       = GetProName(setuppath);
            List <Node> txs           = TxFileProceed.GetTx(txpath, setuppath, terpath);

            myLog.Info(txs.Count);
            List <List <ReceiveBall> > rxs = RxFileProceed.GetRx(rxpath, setuppath, terpath);

            myLog.Info(rxs.Count);
            //rxs.AddRange(TxFileProceed.GetTxAsRx(txpath, setuppath, terpath));
            City buildings = new City(GetDirectory(setuppath) + ProName + ".city");

            buildings.RestructTerrainByBuildings(newTer.TerRect);
            if (buildings.Build != null && buildings.Build.Count != 0)
            {
                newTer.OutPutNewTerrain(GetDirectory(setuppath));
            }                                                    //输出新地形
            int?[] index   = { null, null };
            int    txindex = 0;

            for (int i = 0; i < txs.Count; i++)
            {
                List <FrequencyBand> txFrequencyBand = TxFileProceed.GetTxFrequenceBand(txpath, setuppath, i);//获取频段信息
                myLog.Debug("这是第" + (i + 1) + "个发射机的射线追踪==========================================================================");
                for (int j = 0; j < rxs.Count; j++)
                {
                    //该接收区只有一个接收机
                    if (rxs[j].Count == 1)
                    {
                        if (rxs[j][0].GetType().ToString().Equals("CalculateModelClasses.ReceiveArea"))
                        {
                            //电磁态势的追踪模块
                            ReceiveArea reArea = (ReceiveArea)rxs[j][0];
                            //第一步:构建态势区域
                            myLog.Debug("构建态势区域");
                            reArea.CreateAreaSituation(newTer.TerRect);
                            //第二步:正向追踪,获取路径
                            myLog.Debug("正向追踪,获取粗略路径");
                            RayTubeMethod areaTracing = new RayTubeMethod(txs[i], reArea, newTer, buildings, 64);
                            //读取发射天线的极化信息
                            string txPol = GetRxTxPol("tx", txs[i].TxNum);
                            //读取接收天线的极化信息(删除??)
                            string rxPol = GetRxTxPol("areaSituation", rxs[j][0].RxNum);
                            //第三步:反向追踪,获取准确路径
                            //for (int m = 0; m < reArea.areaSituationNodes.Count; m++)
                            //{
                            //    areaTracing.ReverseAreaTracingPathsAndDeleteRepeatedPaths(reArea.areaSituationNodes[m].paths);
                            //}
                            //获取发射天线的4个参数
                            ReadUan.GetGainPara(txs[i].UAN);
                            for (int m = 0; m < reArea.areaSituationNodes.Count; m++)
                            {
                                reArea.areaSituationNodes[m].classifiedFrequencyPaths = new List <List <CalculateModelClasses.Path> >();
                                if (reArea.areaSituationNodes[m].paths.Count != 0)
                                {
                                    PathsafterPolization(reArea.areaSituationNodes[m].paths, txPol, rxPol);//极化代码
                                    //第四步:分频段求每条路径上的场强
                                    reArea.areaSituationNodes[m].classifiedFrequencyPaths = new List <List <CalculateModelClasses.Path> >();
                                    //areaTracing.ScreenAreaSituationPathsByFrequencyAndCalculateEField(txFrequencyBand, reArea.areaSituationNodes[m].paths, reArea.areaSituationNodes[m].classifiedFrequencyPaths);
                                    //计算每个频段上的各个路径叠加的总场强
                                    for (int n = 0; n < txFrequencyBand.Count; n++)
                                    {
                                        EField tempEfield = new EField();
                                        tempEfield.X = tempEfield.GetTolEx(reArea.areaSituationNodes[m].classifiedFrequencyPaths[n]);
                                        tempEfield.Y = tempEfield.GetTolEy(reArea.areaSituationNodes[m].classifiedFrequencyPaths[n]);
                                        tempEfield.Z = tempEfield.GetTolEz(reArea.areaSituationNodes[m].classifiedFrequencyPaths[n]);
                                        //得到每个频段上各个路径叠加的场强
                                        reArea.areaSituationNodes[m].totleEfields.Add(tempEfield);
                                        //得到各个频段上各个路径后得到的总场强
                                        reArea.areaSituationNodes[m].totleEfield.X += tempEfield.X;
                                        reArea.areaSituationNodes[m].totleEfield.Y += tempEfield.Y;
                                        reArea.areaSituationNodes[m].totleEfield.Z += tempEfield.Z;
                                    }
                                }
                            }
                            //文件输出
                            string path = ".\\.\\project\\station\\areaSituationResult.txt";
                            if (!System.IO.File.Exists(path))
                            {
                                System.IO.File.Create(path).Close();
                            }
                            StringBuilder sb = new StringBuilder();
                            for (int m = 0; m < reArea.areaSituationNodes.Count; m++)
                            {
                                if (reArea.areaSituationNodes[m].paths.Count != 0)
                                {
                                    //string appendText1 =  m+" "  + reArea.areaSituationNodes[m].paths.Count+" " ;
                                    //sb.Append(appendText1);
                                    //string appendText2 = "Ex " + reArea.areaSituationNodes[m].totleEfield.X.Re + "+j" + reArea.areaSituationNodes[m].totleEfield.X.Im + ",Ey " + reArea.areaSituationNodes[m].totleEfield.Y.Re + "+j" + reArea.areaSituationNodes[m].totleEfield.Y.Im + ",Ez " + reArea.areaSituationNodes[m].totleEfield.Z.Re + "+j" + reArea.areaSituationNodes[m].totleEfield.Z.Im + "\r\n";
                                    //sb.Append(appendText2);
                                    string appendText1 = "第" + m + "个态势点上有" + reArea.areaSituationNodes[m].paths.Count + "条路径,";
                                    sb.Append(appendText1);
                                    string appendText2 = "总场强为:Ex " + reArea.areaSituationNodes[m].totleEfield.X.Re + "+j" + reArea.areaSituationNodes[m].totleEfield.X.Im + ",Ey " + reArea.areaSituationNodes[m].totleEfield.Y.Re + "+j" + reArea.areaSituationNodes[m].totleEfield.Y.Im + ",Ez " + reArea.areaSituationNodes[m].totleEfield.Z.Re + "+j" + reArea.areaSituationNodes[m].totleEfield.Z.Im + "\r\n";
                                    sb.Append(appendText2);
                                }
                                //else
                                //{
                                //    string appendText1 = "没有到达第" + m + "个态势点的路径\r\n";
                                //    sb.Append(appendText1);
                                //}
                            }
                            StreamWriter stw = new StreamWriter(path);
                            stw.Write(sb);
                            stw.Flush(); //清空缓冲区
                            stw.Close(); //关闭流
                            //---------------------------------
                            myLog.Debug("结果计算和文件输出过程结束,进入下一个接收机的追踪--------------------------------------");
                        }
                        else
                        {
                            if (("tx_" + txs[i].NodeName).Equals(rxs[j][0].RxName))
                            {
                                myLog.Debug("这是第" + (i + 1) + "个发射机第" + (j + 1) + "个接收机的射线追踪:是同一个发射机");
                                continue;
                            }
                            myLog.Debug("这是第" + (i + 1) + "个发射机第" + (j + 1) + "个接收机的射线追踪*****************************************************");
                            index[0] = j;
                            RayTubeMethod rayTubeMethod = new RayTubeMethod(txs[i], rxs[j][0], newTer, buildings, 32);
                            rayTubeMethod.ReverseTracingPathsAndDeleteRepeatedPaths();
                            rayTubeMethod.UpdateRayInForNodes();
                            //       PunctiformLaunchMethod punctiformMethod = new PunctiformLaunchMethod(txs[i], rxs[j][0], newTer, buildings, 64, txFrequencyBand);
                            //        List<CalculateModelClasses.Path> temp = punctiformMethod.GetPunctiformRxPath(tx, rxs[j][0], newTer,cityBuilding, 32, 128,TxFrequencyBand);

                            //        if (rayTubeMethod.ReceivedPaths.Count != 0)//若存在直射射线
                            //         {
                            //             string txPol = GetRxTxPol("tx", txs[i].TxNum);//极化代码
                            //             string rxPol = null;
                            //              if (rxs[j][0].isTx == true)
                            //              {
                            //                  rxPol = GetRxTxPol("tx", rxs[j][0].RxNum);
                            //              }
                            //              else
                            //              {
                            //                  rxPol = GetRxTxPol("rx", rxs[j][0].RxNum);//
                            //              }
                            //               PathsafterPolization(rayTubeMethod.ReceivedPaths, txPol, rxPol);//
                            //          }
                            myLog.Debug("射线追踪过程结束,进入射线筛选和计算过程-----------------------------------------");
                            //输出结果
                            ReadUan.GetGainPara(rxs[j][0].UAN);
                            List <List <CalculateModelClasses.Path> > ClassifiedPaths = rayTubeMethod.ScreenPunctiformPathsByFrequencyAndCalculateEField(txFrequencyBand);
                            for (int m = 0; m < txFrequencyBand.Count; m++)
                            {
                                P2mFileOutput.p2mfileoutput(ClassifiedPaths[m], DirectoryPath, ProName, txs[i].TxNum, txTotal, txindex, rxs[j][0], txs[i].Position, txFrequencyBand[m].MidPointFrequence, txFrequencyBand[m].FrequenceWidthMin, txFrequencyBand[m].FrequenceWidthMax);
                            }
                            List <CalculateModelClasses.Path> totalPowerPath = GetTotalPowerPath(ClassifiedPaths);
                            PowerOutput.GetRxTotalPower(totalPowerPath, DirectoryPath, ProName, txs[i].TxNum, txTotal, rxs[j][0], txs[i].Position);
                            myLog.Debug("结果计算和文件输出过程结束,进入下一个接收机的追踪---------------------------------------");
                        }
                    }
                    else
                    {
                        throw new Exception("没有接收机");
                    }
                }
            }
            GC.Collect();
        }