-
Notifications
You must be signed in to change notification settings - Fork 0
/
zoneofcoverage.py
199 lines (170 loc) · 4.76 KB
/
zoneofcoverage.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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
import requests
import time
import json
import geopy.distance
import haversine as hs
from haversine import Unit
def get_sboxname():
sandboxname=requests.get("http://131.114.54.25/platform-ctrl/v1/sandboxes").json()['sandboxes'][0]['name']
print("Sandbox name is: %s" % sandboxname)
urlbase="http://131.114.54.25"
urlrni_base=urlbase + "/" + sandboxname +"/"+ "rni" + "/" + "v2"
urlgis_base=urlbase + "/" + sandboxname + "/" + "gis" + "/" + "v1" + "/" + "geodata"
return urlgis_base
def p_choose():
urlgis_base=get_sboxname()
gis=requests.get(urlgis_base)
gisjson=gis.json()
gis_dumped=json.dumps(gisjson,indent=4)
i=0
p_wifi1=0
p_wifi2=0
p_4g1=0
p_4g2=0
p_5g1=0
p_5g2=0
while True:
try:
uename=gisjson['geoDataAssets'][i]['assetName']
if uename=='ue1':
uepos=gisjson['geoDataAssets'][i]['location']['coordinates']
break
else:
i+=1
except:
print("No ue1 found")
break
i=0
while True:
try:
bs1=gisjson['geoDataAssets'][i]['assetName']
if bs1=='wifi1':
bs1pos=gisjson['geoDataAssets'][i]['location']['coordinates']
break
else:
i+=1
except:
print("No bs1 found")
break
i=0
while True:
try:
bs2=gisjson['geoDataAssets'][i]['assetName']
if bs2=='wifi2':
bs2pos=gisjson['geoDataAssets'][i]['location']['coordinates']
break
else:
i+=1
except:
print("No bs2 found")
break
bs1touem=hs.haversine(bs1pos,uepos,unit=Unit.METERS)
bs2touem=hs.haversine(bs2pos,uepos,unit=Unit.METERS)
bs1tobs2=hs.haversine(bs1pos,bs2pos,unit=Unit.METERS)
print("bs1 to ue=",bs1touem)
print("bs2 to ue=",bs2touem)
if bs1touem < 200:
p_wifi1=1
p_5g1=1
p_4g1=1
if bs1touem < 500 and bs1touem > 200:
p_wifi1=0
p_5g1=1
p_4g1=1
if bs1touem < 1000 and bs1touem > 500:
p_wifi1=0
p_5g1=0
p_4g1=1
if bs2touem < 200:
p_wifi2=1
p_5g2=1
p_4g2=1
if bs2touem < 500 and bs2touem > 200:
p_wifi2=0
p_5g2=1
p_4g2=1
if bs2touem < 1000 and bs2touem > 500:
p_wifi2=0
p_5g2=0
p_4g2=1
p=[[p_wifi1,p_4g1,p_5g1],[p_wifi2,p_4g2,p_5g2]]
p_description=[["wifi1","4g1","5g1"],["wifi2","4g2","5g2"]]
return p, uename, p_description
def p_choose_noMEC():
urlgis_base=get_sboxname()
gis=requests.get(urlgis_base)
gisjson=gis.json()
gis_dumped=json.dumps(gisjson,indent=4)
i=0
p_wifi1=0
p_wifi2=0
p_4g1=0
p_4g2=0
p_5g1=0
p_5g2=0
while True:
try:
uename=gisjson['geoDataAssets'][i]['assetName']
if uename=='ue1':
uepos=gisjson['geoDataAssets'][i]['location']['coordinates']
break
else:
i+=1
except:
print("No ue1 found")
break
i=0
while True:
try:
bs1=gisjson['geoDataAssets'][i]['assetName']
if bs1=='wifi1':
bs1pos=gisjson['geoDataAssets'][i]['location']['coordinates']
break
else:
i+=1
except:
print("No bs1 found")
break
i=0
while True:
try:
bs2=gisjson['geoDataAssets'][i]['assetName']
if bs2=='wifi2':
bs2pos=gisjson['geoDataAssets'][i]['location']['coordinates']
break
else:
i+=1
except:
print("No bs2 found")
break
bs1touem=hs.haversine(bs1pos,uepos,unit=Unit.METERS)
bs2touem=hs.haversine(bs2pos,uepos,unit=Unit.METERS)
bs1tobs2=hs.haversine(bs1pos,bs2pos,unit=Unit.METERS)
print("bs1 to ue=",bs1touem)
print("bs2 to ue=",bs2touem)
if bs1touem < bs2touem:
p_wifi1=0
p_5g1=1
p_4g1=0
p_wifi2=0
p_5g2=0
p_4g2=0
if bs1touem > bs2touem:
p_wifi1=0
p_5g1=0
p_4g1=0
p_wifi2=0
p_5g2=0
p_4g2=1
p=[[p_wifi1,p_4g1,p_5g1],[p_wifi2,p_4g2,p_5g2]]
p_description=[["wifi1","4g1","5g1"],["wifi2","4g2","5g2"]]
return p, uename, p_description
if __name__ == "__main__":
while True:
time.sleep(1)
p, uename, p_description=p_choose()
for i in range(len(p[0])):
if p[0][i] == 1:
print("ue1 under coverage of: ",p_description[0][i])
if p[1][i] == 1:
print("ue1 under coverage of: ",p_description[1][i])