martaczaska

Licz_17.11

Nov 17th, 2020
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.69 KB | None | 0 0
  1. package eti.radio.pr_inz;
  2.  
  3. import javax.imageio.ImageIO;
  4. import javax.swing.*;
  5. import java.lang.Math;
  6. import java.awt.*;
  7. import java.awt.event.ActionEvent;
  8. import java.awt.event.ActionListener;
  9. import java.awt.image.BufferedImage;
  10. import java.io.File;
  11. import java.io.IOException;
  12.  
  13. public class Licz extends JPanel implements ActionListener {
  14.  
  15.     private JButton wyjscie;
  16.     public BufferedImage tlo_dane;
  17.  
  18.     int wybrane_nw = O2I.nw;
  19.     int wyb_model = Mapa.s;
  20.     double f_c = 10000000; //musi byc bo w log10(double a)
  21.     int d_2D = 100; //m
  22.     int d_2D_IN = 2; //m
  23.     // d_2D = Dane.d_watosc;
  24.     int h_BS = 25; //zrobić jako Slidery
  25.     int h_UT = 1;  ///zrobić jako Slidery
  26.     int h_E = 1; // 1m
  27.     int h = 5; //w metrach, do RMa
  28.     int W = 20; //w metrach, do RMa
  29.     int c = 3*(10^8);
  30.     double sigma_LOS, sigma_NLOS;
  31.     double PL_LOS, PL_NLOS, PL_NLOS2, PL_LOS_O2I, PL_NLOS_O2I;
  32.     double d_BP, d2_BP;
  33.     double d_3D = Math.abs( (h_BS-h_UT)^2 + d_2D^2 );
  34.  
  35.     public Licz(){
  36.         setLayout(null);
  37.         //setVisible(false);
  38.  
  39.         System.out.println("Wybrany model: " + wyb_model);
  40.         System.out.println("Wybrany scenariusz O2I: " + wybrane_nw);
  41.  
  42.         d_BP = 4*(h_BS -h_E)*(h_UT -h_E)*f_c/c;
  43.         d2_BP = 2*Math.PI*h_BS*h_UT*f_c/c;
  44.  
  45.         if(wyb_model == 1){ //model Indoor Hotspot - InH
  46.             PL_LOS = 32.4 + 17.3*Math.log10(d_3D) + 20*Math.log10(f_c);     //- path loss for LOS
  47.             PL_NLOS2 = 38.3*Math.log10(d_3D) + 17.3 + 24.9*Math.log10(f_c);
  48.             PL_NLOS = Math.max(PL_LOS, PL_NLOS2);                           //- path loss for NLOS
  49.             sigma_LOS = 3; //dB
  50.             sigma_NLOS = 8.03; //dB
  51.         }
  52.         else if(wyb_model == 2 || wyb_model == 3){ //model Urban Macro- UMa
  53.             if( d_2D >= 10 && d_2D <= d_BP){
  54.                 PL_LOS = 28 + 22*Math.log10(d_3D) + 20*Math.log10(f_c);
  55.                 PL_NLOS2 = 13.54 + 39.08*Math.log10(d_3D) + 20*Math.log10(f_c) -6*(h_UT-1.5);
  56.                 PL_NLOS = Math.max(PL_LOS, PL_NLOS2);
  57.             }
  58.             else if(d_2D >= d_BP && d_2D <= 5000){
  59.                 PL_LOS = 28 + 40*Math.log10(d_3D) + 20*Math.log10(f_c) -9*(Math.pow(d_BP,2) + Math.pow((h_BS + h_UT),2));
  60.                 PL_NLOS2 = 13.54 + 39.08*Math.log10(d_3D) + 20*Math.log10(f_c) -6*(h_UT-1.5);
  61.                 PL_NLOS = Math.max(PL_LOS, PL_NLOS2);
  62.             }
  63.             sigma_LOS = 4; //dB
  64.             sigma_NLOS = 6; //dB
  65.  
  66.             if(wyb_model == 3) {
  67.                 PL_LOS_O2I = PL_O2I(wybrane_nw, PL_LOS);
  68.                 PL_NLOS_O2I = PL_O2I(wybrane_nw, PL_NLOS);
  69.             }
  70.         }
  71.         else if(wyb_model == 4 || wyb_model == 5){ //model Urban Micro- UMi
  72.             if( d_2D >= 10 && d_2D <= d_BP){
  73.                 PL_LOS = 32.4 + 21*Math.log10(d_3D) + 20*Math.log10(f_c);
  74.                 PL_NLOS2 = 22.4 + 35.3*Math.log10(d_3D) + 21.3*Math.log10(f_c) -0.3*(h_UT-1.5);
  75.                 PL_NLOS = Math.max(PL_LOS, PL_NLOS2);
  76.             }
  77.             else if(d_2D >= d_BP && d_2D <= 5000){
  78.                 PL_LOS = 32.4 + 40*Math.log10(d_3D) + 20*Math.log10(f_c) -9.5*(Math.pow(d_BP,2) + Math.pow((h_BS + h_UT),2));
  79.                 PL_NLOS2 = 22.4 + 35.3*Math.log10(d_3D) + 21.3*Math.log10(f_c) -0.3*(h_UT-1.5);
  80.                 PL_NLOS = Math.max(PL_LOS, PL_NLOS2);
  81.             }
  82.             sigma_LOS = 4; //dB
  83.             sigma_NLOS = 7.82; //dB
  84.  
  85.             if(wyb_model == 5) {
  86.                 PL_LOS_O2I = PL_O2I(wybrane_nw, PL_LOS);
  87.                 PL_NLOS_O2I = PL_O2I(wybrane_nw, PL_NLOS);
  88.             }
  89.         }
  90.  
  91.         else if(wyb_model == 6 || wyb_model == 7){ //model Rural Macro- RMa
  92.             if( d_2D >= 10 && d_2D <= d2_BP){
  93.                 PL_LOS = 2*Math.log10((40*Math.PI*d_3D*f_c)/3) + Math.min(Math.pow(0.03*h, 1.72), 10)*Math.log10(d_3D) - Math.min(Math.pow(0.044*h, 1.72), 14.77) + 0.002*Math.log10(h)*d_3D;
  94.                 PL_NLOS2 = 161.04-7.1*Math.log10(W)+7.5*Math.log10(h)-(24.37-3.7*Math.pow(h/h_BS,2)*Math.log10(h_BS) +(43.42-3.1*Math.log10(h_BS))*(Math.log10(d_3D)-3) + 20*Math.log10(f_c)- (3.2*(Math.log10(11.75*h_UT)-4.97)));
  95.                 PL_NLOS = Math.max(PL_LOS, PL_NLOS2);
  96.                 sigma_LOS = 4; //dB
  97.             }
  98.             else if(d_2D >= d2_BP && d_2D <= 21000) {
  99.                 PL_LOS = 2*Math.log10((40*Math.PI*d2_BP*f_c)/3) + Math.min(Math.pow(0.03*h, 1.72), 10)*Math.log10(d2_BP) - Math.min(Math.pow(0.044*h, 1.72), 14.77) + 0.002*Math.log10(h)*d2_BP +40*Math.log10(d_3D/d2_BP);
  100.                 PL_NLOS2 = 161.04-7.1*Math.log10(W)+7.5*Math.log10(h)-(24.37-3.7*Math.pow(h/h_BS,2)*Math.log10(h_BS) +(43.42-3.1*Math.log10(h_BS))*(Math.log10(d_3D)-3) + 20*Math.log10(f_c)- (3.2*(Math.log10(11.75*h_UT)-4.97)));
  101.                 PL_NLOS = Math.max(PL_LOS, PL_NLOS2);
  102.                 sigma_LOS = 6; //dB
  103.             }
  104.             sigma_NLOS = 8; //dB
  105.  
  106.             if(wyb_model == 7) {
  107.                 PL_LOS_O2I = PL_O2I(wybrane_nw, PL_LOS);
  108.                 PL_NLOS_O2I = PL_O2I(wybrane_nw, PL_NLOS);
  109.                 System.out.println("Udało się, yaaaaaaaaaaaaaaaaaaaaaaaaay!");
  110.             }
  111.         }
  112.  
  113.         File zdj_menu = new File("zdjecia/strona_logo.png");
  114.         try{ tlo_dane = ImageIO.read(zdj_menu); }
  115.         catch(IOException e){ System.err.println("Blad odczytu obrazków"); }
  116.  
  117.         wyjscie = new JButton("Wyjście");
  118.         wyjscie.addActionListener(this);
  119.         wyjscie.setBounds(724, 620, 200, 60);
  120.         wyjscie.setFont(new Font("Sitka Text", Font.BOLD, 25));
  121.         wyjscie.setBackground(Color.white);
  122.  
  123.         add(wyjscie);
  124.     }
  125.  
  126.     public double PL_O2I(int n, double pl){
  127.         double L_szklo = 2 + 0.2*f_c; //dB
  128.         double L_beton = 5 + 4*f_c; //dB
  129.         double PL_przeniki = 0;
  130.         double PL_tw, PL_in, sigma_P;
  131.         double N = 5;  // !!!!!!!!!!!!!!!!!!! ZMIENIĆ
  132.         PL_in = 0.5*d_2D_IN;
  133.  
  134.         if(n == 0){ //nisko stratny model
  135.             PL_tw = 5 - Math.log10(0.3*Math.pow(10, (-L_szklo/10)) + 0.7*Math.pow(10, (-L_beton/10)));
  136.             sigma_P = 4.4; //dB
  137.             PL_przeniki = pl + PL_tw + PL_in + N;
  138.         }
  139.         else if(n == 1){ ////wysoko stratny model
  140.             PL_tw = 5 - Math.log10(0.7*Math.pow(10, (-L_szklo/10)) + 0.3*Math.pow(10, (-L_beton/10)));
  141.             sigma_P = 4.4; //dB
  142.             PL_przeniki = pl + PL_tw + PL_in + N;
  143.         }
  144.         return PL_przeniki;   //WYWALA BŁĄD, CZEMU?
  145.     }
  146.  
  147.     public void actionPerformed(ActionEvent e){
  148.         Object source = e.getSource();
  149.         if(source == wyjscie){
  150.             System.exit(0);
  151.         }
  152.     }
  153.  
  154.     public void paintComponent(Graphics graphic) {
  155.         Graphics2D g2d = (Graphics2D) graphic;
  156.         g2d.drawImage(tlo_dane, 0, 0, this);
  157.     }
  158. }
Add Comment
Please, Sign In to add comment