-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPathloss.py
177 lines (135 loc) · 6.3 KB
/
Pathloss.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
from tkinter import *
import tkinter.ttk as ttk
from models.OkumaraHata import OkumaraHataModel
#Second Window Function
def CalcPathLoss(Frame):
def centerWindow(width, height=200):
# get screen width and height
screenWidth = Frame.winfo_screenwidth()
screenHeight = Frame.winfo_screenheight()
# calculate position x and y coordinates
x = (screenHeight / 2) + (-100)
y = (screenHeight / 2) - (height / 2)
Frame.geometry('%dx%d+%d+%d' % (width, height, x, y))
centerWindow(700, 600)
# Input Variables are here
carrierFreq = StringVar()
antennaheight1 = StringVar()
antennaheight2 = StringVar()
propagationDistance = StringVar()
selectedCity = StringVar()
selectedArea = StringVar()
selectedCityValue = IntVar(value=1)
selectedAreaValue = IntVar(value=1)
# labels
labelsfont = ('Times New Roman', 14)
# text filed
textFieldFont = ('Times New Roman', 15, 'bold')
# Heading
labelHeading = Label(Frame,
text='Cellular Toolkit',
font="-family {Century Gothic} -size 20 -weight bold",
background="#1DBC60",
foreground="#ffffff"
)
# carrier frequency
labelCarrierFrequency = Label(Frame,
text='Value of carrier frequency (in range 150-1500MHz) :',
font=labelsfont,
foreground="black")
carrierFrequencyField = Entry(Frame, width=16, textvariable=carrierFreq,
justify=CENTER,
relief='flat',
foreground='#F56954',
font=textFieldFont)
carrierFrequencyField.focus_force()
# height of transmitter antenna
labelantennaheightT = Label(Frame,
text='Height of transmitter antenna(in range 30 - 300 meter) :',
font=labelsfont,
foreground="black")
antennaheightFieldT = Entry(Frame,
width=16,
textvariable=antennaheight1,
justify=CENTER,
relief='flat',
foreground='#F56954',
font=textFieldFont)
antennaheightFieldT.focus_force()
# height of receiver antenna
labelAntennaheightR = Label(Frame,
text='Height of receiver antenna (in range 1 - 10 meter) :',
font=labelsfont,
foreground="black")
antennaheightFieldR = Entry(Frame,
width=16,
textvariable=antennaheight2,
justify=CENTER,
relief='flat',
foreground='#F56954',
font=textFieldFont)
antennaheightFieldR.focus_force()
# Propagation distance
labelPropagationDistance = Label(Frame,
text='Propagation distance between antennas (1 - 20 in km) :',
font=labelsfont,
foreground="black")
propagationDistanceField = Entry(Frame,
width=16,
textvariable=propagationDistance,
justify=CENTER,
relief='flat',
foreground='#F56954',
font=textFieldFont)
propagationDistanceField.focus_force()
# Option menu of type of city
labelCityType = Label(Frame,
text='Select the type of city',
font=labelsfont,
foreground="black")
cityOptions = ['Small/Medium', 'Large']
def citySelected(event):
selectedCityValue.set(1 if selectedCity.get() == 'Small/Medium' else 2)
selectedCity.set(cityOptions[0])
cityTypeOptionsMenu = OptionMenu(Frame,
selectedCity,
*cityOptions,
command=citySelected)
cityTypeOptionsMenu.config(width=15)
# Option menu of type of area
labelAreaType = Label(Frame,
text='Select the type of area',
font=labelsfont,
foreground="black")
areaOptions = ['Urban/Suburban', 'Open area']
def areaSelected(event):
selectedAreaValue.set(1 if selectedArea.get() == 'Urban/Suburban' else 2)
selectedArea.set(areaOptions[0])
areaTypeOptionsMenu = OptionMenu(Frame,
selectedArea,
*areaOptions,
command=areaSelected)
areaTypeOptionsMenu.config(width=15)
def getPathLoss():
okumara_hata_model = OkumaraHataModel(
carrierFrequency=int(carrierFreq.get()),
heightTransmitter=int(antennaheight1.get()),
heightReceiver=int(antennaheight2.get()),
linkDistance=int(propagationDistance.get()),
city=selectedCityValue.get(),
area=selectedAreaValue.get())
ttk.Label(Frame,
text="Path loss (in dB):" +
str(okumara_hata_model.pathLoss) + 'dB',
font=textFieldFont,
foreground="black").grid(column=1, row=12, padx=20, pady=20)
myButton = Button(Frame, text='Get Path Loss',
command=getPathLoss, fg='white', bg='#F56954', relief='flat', font=labelsfont)
labels = [labelHeading, labelCarrierFrequency, labelantennaheightT,
labelAntennaheightR, labelPropagationDistance, labelCityType, labelAreaType, myButton]
fields = [carrierFrequencyField, antennaheightFieldT,
antennaheightFieldR, propagationDistanceField, cityTypeOptionsMenu, areaTypeOptionsMenu]
for i in range(8):
labels[i].grid(row=i, column=1, sticky='W', padx=20, pady=10)
for i in range(6):
fields[i].grid(row=i + 1, column=2)