Exemplo n.º 1
0
 private MWNumericArray[][] wrap_func(int num, int ray_num, Transmitter.EMIT_OPTION emit_opt, Signal_Type signal_type, int sample_cnt)
 {
     MWNumericArray[][] signals = new MWNumericArray[num][];
     while (num-- > 0)
     {
         foreach (Transmitter trans in this.viz_rps.Map.Transmitters)
         {
             trans.Reset();
             trans.EmitRays(ray_num, emit_opt);   //各发射机辐射波束
             foreach (Receiver rec in this.viz_rps.Map.Receivers)
             {
                 rec.Reset();
                 if (this.viz_rps.Map.IsLOS(trans.Location, rec.Location))    //若存在LOS情况
                 {
                     LineSegment segLOS = new LineSegment(trans.Location, rec.Location);
                     Ray rayLOS = new Ray(trans, new LineSegment[] { segLOS }, segLOS.DirectionRadian, trans.CenterFrequency, trans.EmitPower * trans.Gain, trans.EmitPower * trans.Gain, true);
                     rec.AcceptRay(rayLOS, this.viz_rps.Map);
                 }
             }
             foreach (Ray ray in trans.Rays)  //更新每条ray, 若被接收,则更新接收它的接收机
             {
                 Receiver rec = null;
                 while (!ray.Update(this.viz_rps.Map, out rec)) ;
                 if (rec != null)
                     rec.AcceptRay(ray, this.viz_rps.Map);
             }
         }
         FingerprintGenerator fg = new FingerprintGenerator();
         Dictionary<Fingerprint_Name, Fingerprint> result = new Dictionary<Fingerprint_Name, Fingerprint>();
         List<double>[] ray_angles = new List<double>[this.viz_rps.Map.ReceiverCount];
         List<double>[] ray_strengths = new List<double>[this.viz_rps.Map.ReceiverCount];
         List<double>[] ray_taus = new List<double>[this.viz_rps.Map.ReceiverCount];
         int kk = 0;
         foreach (Receiver rec in this.viz_rps.Map.Receivers)
         {
             ray_angles[kk] = new List<double>();
             ray_strengths[kk] = new List<double>();
             ray_taus[kk] = new List<double>();
             foreach (Ray ray in rec.Rays)
             {
                 ray_angles[kk].Add(ray.CurrentDirection);
                 ray_strengths[kk].Add(ray.FadedPower(this.viz_rps.Map.MeterPixelRatio));
                 ray_taus[kk].Add(ray.GetLifeSpan(this.viz_rps.Map.MeterPixelRatio));
             }
             kk++;
         }
         double[] args = null;
         switch (signal_type)
         {
             case Signal_Type.PSEUDO_DOPPLER:
                 //if (this.receivers.First().Value.Antenna.AntType != AntennaType.PSEUDO_DOPPLER)
                 //    return null;
                 Antenna_PseudoDoppler ant = this.viz_rps.Map.receivers.First().Value.Antenna as Antenna_PseudoDoppler;
                 args = fg.PackArgs_PseudoDoppler(this.viz_rps.Map.receivers.First().Value.FrequencyLow, this.viz_rps.Map.receivers.First().Value.CenterFrequency,
                                                  this.viz_rps.Map.receivers.First().Value.SampleFrequency, ant.SwitchFrequency, ant.Radius, ant.AntennaNumber);
                 break;
         }
         signals[num - 1] = new MWNumericArray[ray_angles.GetLength(0)];
         for (int i = 0; i < signals.Length; i++)
         {
             signals[num - 1][i] = new FingerprintGenerator().GenerateSignal_MW(signal_type, ray_angles[i].ToArray(), ray_strengths[i].ToArray(), ray_taus[i].ToArray(), sample_cnt, args);
         }
     }
     return signals;
 }
Exemplo n.º 2
0
 public TransmitterEnumerator(Transmitter[] transmitter)
 {
     this.transmitters = transmitter.Clone() as Transmitter[];
 }
Exemplo n.º 3
0
 /// <summary>
 /// 添加信号源
 /// </summary>
 /// <param name="tr"></param>
 public void AddTransmitter(Transmitter tr)
 {
     try
     {
         this.viz_rps.Map.AddTransmitter(tr);
         ListViewItem lvi = new ListViewItem(tr.Name);
         lvi.SubItems.Add(tr.Location.ToString());
         lvi.Name = tr.Name;
         this.lvTransmitters.Items.Add(lvi);
         this.RePaint();
     }
     catch (Exception ex)
     {
         MessageBox.Show("添加信号源失败:\n" + ex.Message);
     }
 }
Exemplo n.º 4
0
 public TransmitterCollection(Transmitter[] t)
 {
     this.trans = t;
 }
Exemplo n.º 5
0
Arquivo: Map.cs Projeto: Yinzhe-Qi/RPS
        /// <summary>
        /// 运行单次仿真
        /// </summary>
        public Dictionary<Fingerprint_Name, Fingerprint> RunSingleSimulation(int num_rays, Transmitter.EMIT_OPTION emit_option, Signal_Type signal_type,
                                                 Noise_Type noise_type, double[] noise_params, int N)
        {
            foreach(Transmitter trans in this.Transmitters)
            {
                trans.Reset();
                trans.EmitRays(num_rays, emit_option);   //各发射机辐射波束
                foreach(Receiver rec in this.Receivers)
                {
                    rec.Reset();
                    if(this.IsLOS(trans.Location, rec.Location))    //若存在LOS情况
                    {
                        LineSegment segLOS = new LineSegment(trans.Location, rec.Location);
                        Ray rayLOS = new Ray(trans, new LineSegment[] { segLOS }, segLOS.DirectionRadian, trans.CenterFrequency, trans.EmitPower * trans.Gain, trans.EmitPower * trans.Gain, true);
                        rec.AcceptRay(rayLOS, this);
                    }
                }
                foreach(Ray ray in trans.Rays)  //更新每条ray, 若被接收,则更新接收它的接收机
                {
                    Receiver rec = null;
                    while (!ray.Update(this, out rec)) ;
                    if (rec != null)
                        rec.AcceptRay(ray, this);
                }
            }

            FingerprintGenerator fg = new FingerprintGenerator();
            Dictionary<Fingerprint_Name, Fingerprint> result = new Dictionary<Fingerprint_Name,Fingerprint>();
            List<double>[] ray_angles = new List<double>[this.receivers.Count];
            List<double>[] ray_strengths = new List<double>[this.receivers.Count];
            List<double>[] ray_taus = new List<double>[this.receivers.Count];
            int i = 0;
            foreach(Receiver rec in this.Receivers)
            {
                ray_angles[i] = new List<double>();
                ray_strengths[i] = new List<double>();
                ray_taus[i] = new List<double>();
                foreach(Ray ray in rec.Rays)
                {
                    ray_angles[i].Add(ray.CurrentDirection);
                    ray_strengths[i].Add(ray.FadedPower(this.MeterPixelRatio));
                    ray_taus[i].Add(ray.GetLifeSpan(this.MeterPixelRatio));
                }
                i++;
            }
            double[] args = null;
            switch (signal_type)
            {
                case Signal_Type.PSEUDO_DOPPLER:
                    if (this.receivers.First().Value.Antenna.AntType != AntennaType.PSEUDO_DOPPLER)
                        return null;
                    Antenna_PseudoDoppler ant = this.receivers.First().Value.Antenna as Antenna_PseudoDoppler;
                    args = fg.PackArgs_PseudoDoppler(this.receivers.First().Value.FrequencyLow, this.receivers.First().Value.CenterFrequency,
                                                     this.receivers.First().Value.SampleFrequency, ant.SwitchFrequency, ant.Radius, ant.AntennaNumber);
                    break;
            }
            for (int j = 0; j < Enum.GetNames(new Fingerprint_Name().GetType()).Length; j++ )
                result[(Fingerprint_Name)j] = fg.SingleFingerprintSim(signal_type, noise_type, noise_params, (Fingerprint_Name)j, ray_angles, ray_strengths, ray_taus,
                                                 N, args);
            return result;
        }
Exemplo n.º 6
0
Arquivo: Map.cs Projeto: Yinzhe-Qi/RPS
 /// <summary>
 /// 添加发射机
 /// </summary>
 /// <param name="transmitter"></param>
 public void AddTransmitter(Transmitter transmitter)
 {
     if (transmitter.Location.X < 0 || transmitter.Location.X > this.Size.Width - 1 || transmitter.Location.Y < 0 || transmitter.Location.Y > this.Size.Height - 1)
         throw new Exception("添加发射机失败:坐标超出地图范围!");
     foreach (Transmitter tr in this.transmitters.Values)
     {
         if (tr.Location == transmitter.Location)
             throw new Exception("添加发射机失败:坐标与现有发射机重合!");
         if (tr.Name == transmitter.Name)
             throw new Exception("添加发射机失败:名称与现有发射机相同!");
     }
     foreach (Receiver rec in this.receivers.Values)
         if (rec.Location == transmitter.Location)
             throw new Exception("添加发射机失败:坐标与现有接收机重合!");
     foreach (Scatter scatter in this.scatters.Values)
         if (scatter.IsPointInside(transmitter.Location))
             throw new Exception("添加发射机失败:坐标在现有散射体内部!");
     this.transmitters[transmitter.Name] = transmitter;
 }
Exemplo n.º 7
0
Arquivo: Ray.cs Projeto: Yinzhe-Qi/RPS
 /// <summary>
 /// 构造已包含一段路径的波束
 /// </summary>
 /// <param name="transm"></param>
 /// <param name="segs"></param>
 /// <param name="current_direction"></param>
 /// <param name="freq"></param>
 /// <param name="init_power"></param>
 /// <param name="current_power"></param>
 /// <param name="beam_width"></param>
 public Ray(Transmitter transm, LineSegment[] segs, double current_direction, double freq, double init_power, double current_power, bool is_direct=false, double beam_width = Math.PI / 3)
 {
     this.transmitter = transm;
     foreach(LineSegment seg in segs)
         this.path_segs.Add(seg);
     this.current_direction = current_direction;
     this.center_frequency = freq;
     this.init_power = init_power;
     this.power = current_power;
     this.beam_width = beam_width;
 }
Exemplo n.º 8
0
Arquivo: Ray.cs Projeto: Yinzhe-Qi/RPS
 /// <summary>
 /// 初始化波束
 /// </summary>
 /// <param name="transm"></param>
 /// <param name="init_direction"></param>
 /// <param name="freq"></param>
 /// <param name="init_power"></param>
 /// <param name="beam_width"></param>
 public Ray(Transmitter transm, double init_direction, double freq, double init_power, bool is_direct=false, double beam_width=Math.PI / 3)
 {
     this.transmitter = transm;
     this.current_direction = init_direction;
     this.center_frequency = freq;
     this.init_power = init_power;
     this.power = init_power;
     this.beam_width = beam_width;
 }