Example #1
0
        public static void GetAreaTotalPower(List <CalculateModelClasses.Path> Paths, string sPath, string projectName, int txIndex, int txTotol, ReceiveArea rArea, Terrain ter)
        {
            if (Paths.Count != 0)
            {
                string Rxname = Paths[0].node[Paths[0].node.Count - 1].NodeName;
                Console.WriteLine(sPath + projectName + "_power" + "_t00" + txIndex + "_0" + txTotol + ".p2m");
                FileStream   fs        = new FileStream(sPath + projectName + "_" + "situation" + "_power" + "_total" + "_" + "t00" + txIndex + "_0" + txTotol + ".p2m", FileMode.Create);//如果是接收区域的话,多个接收点组成一组接收机组成一个编号
                StreamWriter sw        = new StreamWriter(fs);
                List <int>   rxCounter = AreaUtils.getCount4Rx(rArea);
                int          Rxnum     = rxCounter[0] * rxCounter[1];
                sb.AppendLine("# Receiver Set:" + Rxname);
                sb.AppendLine("#   Rx#      X(m)           Y(m)          Z(m)       Distance (m)   Power (dBm)    Phase (Deg.)");
                List <CalculateModelClasses.Path> omg = AreaUtils.getPaths(Paths);
                Console.WriteLine("Power begin" + System.DateTime.Now);
                Dictionary <int, List <Plural> > projectionResult = AreaUtils.yingshe(rxCounter, omg, rArea);
                Console.WriteLine("Power finish" + System.DateTime.Now);
                double temp = rArea.temp;
                foreach (var item in projectionResult.Keys)
                {
                    Point  receiverPoint = AreaUtils.GetCenterPointInAreaDivision(rArea, rxCounter, ter, item, temp);
                    double distance      = Paths[0].node[0].Position.GetDistance(receiverPoint);
                    Plural tempPower     = projectionResult[item][0];
                    //角度计算,从局域信息中读取
                    double angle = projectionResult[item][4].Re;

                    if (tempPower.Re == 0 && tempPower.Im == 0)
                    {
                        sb.AppendLine(AreaUtils.getBlank(item, 6) + item + "  " + receiverPoint.X.ToString("E7") + "  " + receiverPoint.Y.ToString("E7") + "     " + receiverPoint.Z.ToString("f3") + "       " + distance.ToString("f2") + "        " + "-100.00" + "          " + "0.00");
                    }
                    else
                    {
                        double powerMag = (10 * Math.Log10(tempPower.Re)) + 30;
                        //string test = AreaUtils.getBlank((int)Math.Floor(powerMag), 11);
                        //AreaUtils.getBlank((int)Math.Floor(angle), 11);
                        //string test2 = AreaUtils.getBlank(int.Parse(angle.ToString()), 11);
                        sb.AppendLine(AreaUtils.getBlank(item, 6) + item + "  " + receiverPoint.X.ToString("E7") + "  " + receiverPoint.Y.ToString("E7") + "     " + receiverPoint.Z.ToString("f3") + "       " + distance.ToString("f2") + AreaUtils.getBlank((int)Math.Floor(powerMag), 11) + powerMag.ToString("f2") + AreaUtils.getBlank((int)Math.Floor(angle), 11) + angle.ToString("f2"));
                    }
                }
                projectionResult.Clear();
                sw.Write(sb);
                sb.Clear();
                sw.Close();
                fs.Close();
            }
            else
            {
                FileStream   fs = new FileStream(sPath + "t00" + txIndex + "_0" + txTotol + "TotalPowerOutputNull.p2m", FileMode.Append);
                StreamWriter sw = new StreamWriter(fs);
                sw.Close();
                fs.Close();
            }
        }
Example #2
0
        public RealArea GetArea(int id)
        {
            RealArea cachedArea = realAreasCache.Find(area => area.Id == id);

            if (cachedArea == null)
            {
                RealArea newArea = AreaUtils.AreaToRealArea(areaController.getById(id), subAreaController, userController);
                realAreasCache.Add(newArea);
                System.Diagnostics.Debug.WriteLine("Area fetched is:" + newArea.name);
                return(newArea);
            }
            System.Diagnostics.Debug.WriteLine("Area cached is:" + cachedArea.name);
            return(cachedArea);
        }
        public ActionResult Get(int id)
        {
            System.Diagnostics.Debug.WriteLine("Recieved GET with value = " + id);
            var result = subAreaController.GetById(id);

            if (result == null)
            {
                System.Diagnostics.Debug.WriteLine("Couldn't return area");
                EditSubAreaController.currentSubArea = null;
                EditSubAreaController.Editing        = false;
                return(NotFound());
            }
            RealAreaProxy.UpdateArea(result.parentAreaId);
            EditSubAreaController.currentSubArea = AreaUtils.SubAreaToRealSubArea(result, subAreaController, userController);
            EditSubAreaController.Editing        = true;
            return(Ok(result));
        }
Example #4
0
        public static void OutPathArea(List <CalculateModelClasses.Path> Paths, string sPath, string projectName, int txIndex, int txTotol, ReceiveArea rArea, Terrain ter, ref Dictionary <int, List <Plural> > projectionResult, int Frequence, int minFrequence, int maxFrequence)
        {
            string Rxname = Paths[0].node[Paths[0].node.Count - 1].NodeName;

            Console.WriteLine(sPath + projectName + "_power" + "_t00" + txIndex + "_0" + txTotol + ".p2m");
            FileStream   fs        = new FileStream(sPath + projectName + "_" + "situation" + "_power" + "_t00" + txIndex + "_0" + txTotol + "_" + Frequence.ToString("D4") + "_" + minFrequence.ToString("D4") + "_" + maxFrequence.ToString("D4") + ".p2m", FileMode.Create);//如果是接收区域的话,多个接收点组成一组接收机组成一个编号
            StreamWriter sw        = new StreamWriter(fs);
            List <int>   rxCounter = AreaUtils.getCount4Rx(rArea);
            int          Rxnum     = rxCounter[0] * rxCounter[1];

            sb.AppendLine("# Receiver Set:" + Rxname);
            sb.AppendLine("#   Rx#      X(m)           Y(m)          Z(m)       Distance (m)   Power (dBm)    Phase (Deg.)");
            List <CalculateModelClasses.Path> omg = AreaUtils.getPaths(Paths);

            projectionResult = AreaUtils.yingshe(rxCounter, omg, rArea);
            double temp = rArea.temp;

            foreach (var item in projectionResult.Keys)
            {
                Point  receiverPoint = AreaUtils.GetCenterPointInAreaDivision(rArea, rxCounter, ter, item, temp);
                double distance      = Paths[0].node[0].Position.GetDistance(receiverPoint);
                Plural tempPower     = projectionResult[item][0];
                double angle         = Math.Atan(tempPower.Im / tempPower.Re) * 180 / Math.PI;
                if (angle < 0)
                {
                    angle = angle + 180;
                }
                if (tempPower.Re == 0 && tempPower.Im == 0)
                {
                    sb.AppendLine(AreaUtils.getBlank(item, 6) + item + "  " + receiverPoint.X.ToString("E7") + "  " + receiverPoint.Y.ToString("E7") + "     " + receiverPoint.Z.ToString("f3") + "       " + distance.ToString("f2") + "        " + "-100.00" + "          " + "0.00");
                }
                else
                {
                    double powerMag = (10 * Math.Log10(Math.Sqrt(Math.Pow(tempPower.Re, 2) + Math.Pow(tempPower.Im, 2)))) + 30;
                    //string test = AreaUtils.getBlank((int)Math.Floor(powerMag), 11);
                    //AreaUtils.getBlank((int)Math.Floor(angle), 11);
                    //string test2 = AreaUtils.getBlank(int.Parse(angle.ToString()), 11);
                    sb.AppendLine(AreaUtils.getBlank(item, 6) + item + "  " + receiverPoint.X.ToString("E7") + "  " + receiverPoint.Y.ToString("E7") + "     " + receiverPoint.Z.ToString("f3") + "       " + distance.ToString("f2") + AreaUtils.getBlank((int)Math.Floor(powerMag), 11) + powerMag.ToString("f2") + AreaUtils.getBlank((int)Math.Floor(angle), 11) + angle.ToString("f2"));
                }
            }
            sw.Write(sb);
            sb.Clear();
            sw.Close();
            fs.Close();
        }