Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package eti.radio.pr_inz;
- import javax.imageio.ImageIO;
- import javax.swing.*;
- import java.lang.Math;
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.image.BufferedImage;
- import java.io.File;
- import java.io.IOException;
- public class Licz extends JPanel implements ActionListener {
- private JButton wyjscie;
- public BufferedImage tlo_dane;
- int wybrane_nw = O2I.nw;
- int wyb_model = Mapa.s;
- double f_c = 10000000; //musi byc bo w log10(double a)
- int d_2D = 100; //m
- int d_2D_IN = 2; //m
- // d_2D = Dane.d_watosc;
- int h_BS = 25; //zrobić jako Slidery
- int h_UT = 1; ///zrobić jako Slidery
- int h_E = 1; // 1m
- int h = 5; //w metrach, do RMa
- int W = 20; //w metrach, do RMa
- int c = 3*(10^8);
- double sigma_LOS, sigma_NLOS;
- double PL_LOS, PL_NLOS, PL_NLOS2, PL_LOS_O2I, PL_NLOS_O2I;
- double d_BP, d2_BP;
- double d_3D = Math.abs( (h_BS-h_UT)^2 + d_2D^2 );
- public Licz(){
- setLayout(null);
- //setVisible(false);
- System.out.println("Wybrany model: " + wyb_model);
- System.out.println("Wybrany scenariusz O2I: " + wybrane_nw);
- d_BP = 4*(h_BS -h_E)*(h_UT -h_E)*f_c/c;
- d2_BP = 2*Math.PI*h_BS*h_UT*f_c/c;
- if(wyb_model == 1){ //model Indoor Hotspot - InH
- PL_LOS = 32.4 + 17.3*Math.log10(d_3D) + 20*Math.log10(f_c); //- path loss for LOS
- PL_NLOS2 = 38.3*Math.log10(d_3D) + 17.3 + 24.9*Math.log10(f_c);
- PL_NLOS = Math.max(PL_LOS, PL_NLOS2); //- path loss for NLOS
- sigma_LOS = 3; //dB
- sigma_NLOS = 8.03; //dB
- }
- else if(wyb_model == 2 || wyb_model == 3){ //model Urban Macro- UMa
- if( d_2D >= 10 && d_2D <= d_BP){
- PL_LOS = 28 + 22*Math.log10(d_3D) + 20*Math.log10(f_c);
- PL_NLOS2 = 13.54 + 39.08*Math.log10(d_3D) + 20*Math.log10(f_c) -6*(h_UT-1.5);
- PL_NLOS = Math.max(PL_LOS, PL_NLOS2);
- }
- else if(d_2D >= d_BP && d_2D <= 5000){
- 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));
- PL_NLOS2 = 13.54 + 39.08*Math.log10(d_3D) + 20*Math.log10(f_c) -6*(h_UT-1.5);
- PL_NLOS = Math.max(PL_LOS, PL_NLOS2);
- }
- sigma_LOS = 4; //dB
- sigma_NLOS = 6; //dB
- if(wyb_model == 3) {
- PL_LOS_O2I = PL_O2I(wybrane_nw, PL_LOS);
- PL_NLOS_O2I = PL_O2I(wybrane_nw, PL_NLOS);
- }
- }
- else if(wyb_model == 4 || wyb_model == 5){ //model Urban Micro- UMi
- if( d_2D >= 10 && d_2D <= d_BP){
- PL_LOS = 32.4 + 21*Math.log10(d_3D) + 20*Math.log10(f_c);
- PL_NLOS2 = 22.4 + 35.3*Math.log10(d_3D) + 21.3*Math.log10(f_c) -0.3*(h_UT-1.5);
- PL_NLOS = Math.max(PL_LOS, PL_NLOS2);
- }
- else if(d_2D >= d_BP && d_2D <= 5000){
- 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));
- PL_NLOS2 = 22.4 + 35.3*Math.log10(d_3D) + 21.3*Math.log10(f_c) -0.3*(h_UT-1.5);
- PL_NLOS = Math.max(PL_LOS, PL_NLOS2);
- }
- sigma_LOS = 4; //dB
- sigma_NLOS = 7.82; //dB
- if(wyb_model == 5) {
- PL_LOS_O2I = PL_O2I(wybrane_nw, PL_LOS);
- PL_NLOS_O2I = PL_O2I(wybrane_nw, PL_NLOS);
- }
- }
- else if(wyb_model == 6 || wyb_model == 7){ //model Rural Macro- RMa
- if( d_2D >= 10 && d_2D <= d2_BP){
- 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;
- 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)));
- PL_NLOS = Math.max(PL_LOS, PL_NLOS2);
- sigma_LOS = 4; //dB
- }
- else if(d_2D >= d2_BP && d_2D <= 21000) {
- 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);
- 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)));
- PL_NLOS = Math.max(PL_LOS, PL_NLOS2);
- sigma_LOS = 6; //dB
- }
- sigma_NLOS = 8; //dB
- if(wyb_model == 7) {
- PL_LOS_O2I = PL_O2I(wybrane_nw, PL_LOS);
- PL_NLOS_O2I = PL_O2I(wybrane_nw, PL_NLOS);
- System.out.println("Udało się, yaaaaaaaaaaaaaaaaaaaaaaaaay!");
- }
- }
- File zdj_menu = new File("zdjecia/strona_logo.png");
- try{ tlo_dane = ImageIO.read(zdj_menu); }
- catch(IOException e){ System.err.println("Blad odczytu obrazków"); }
- wyjscie = new JButton("Wyjście");
- wyjscie.addActionListener(this);
- wyjscie.setBounds(724, 620, 200, 60);
- wyjscie.setFont(new Font("Sitka Text", Font.BOLD, 25));
- wyjscie.setBackground(Color.white);
- add(wyjscie);
- }
- public double PL_O2I(int n, double pl){
- double L_szklo = 2 + 0.2*f_c; //dB
- double L_beton = 5 + 4*f_c; //dB
- double PL_przeniki = 0;
- double PL_tw, PL_in, sigma_P;
- double N = 5; // !!!!!!!!!!!!!!!!!!! ZMIENIĆ
- PL_in = 0.5*d_2D_IN;
- if(n == 0){ //nisko stratny model
- PL_tw = 5 - Math.log10(0.3*Math.pow(10, (-L_szklo/10)) + 0.7*Math.pow(10, (-L_beton/10)));
- sigma_P = 4.4; //dB
- PL_przeniki = pl + PL_tw + PL_in + N;
- }
- else if(n == 1){ ////wysoko stratny model
- PL_tw = 5 - Math.log10(0.7*Math.pow(10, (-L_szklo/10)) + 0.3*Math.pow(10, (-L_beton/10)));
- sigma_P = 4.4; //dB
- PL_przeniki = pl + PL_tw + PL_in + N;
- }
- return PL_przeniki; //WYWALA BŁĄD, CZEMU?
- }
- public void actionPerformed(ActionEvent e){
- Object source = e.getSource();
- if(source == wyjscie){
- System.exit(0);
- }
- }
- public void paintComponent(Graphics graphic) {
- Graphics2D g2d = (Graphics2D) graphic;
- g2d.drawImage(tlo_dane, 0, 0, this);
- }
- }
Add Comment
Please, Sign In to add comment