##// END OF EJS Templates
Bug local_ip, set_active
Juan C. Espinoza -
r310:4c37291b233c
parent child
Show More
@@ -1,11 +1,12
1 REDIS_HOST=radarsys-redis
1 REDIS_HOST=radarsys-redis
2 REDIS_PORT=6379
2 REDIS_PORT=6379
3 POSTGRES_DB_NAME=radarsys
3 POSTGRES_DB_NAME=radarsys
4 POSTGRES_PORT_5432_TCP_ADDR=radarsys-postgres
4 POSTGRES_PORT_5432_TCP_ADDR=radarsys-postgres
5 POSTGRES_PORT_5432_TCP_PORT=5432
5 POSTGRES_PORT_5432_TCP_PORT=5432
6 POSTGRES_USER=docker
6 POSTGRES_USER=docker
7 POSTGRES_PASSWORD=docker
7 POSTGRES_PASSWORD=docker
8 PGDATA=/var/lib/postgresql/data
8 PGDATA=/var/lib/postgresql/data
9 LC_ALL=C.UTF-8
9 LC_ALL=C.UTF-8
10 TZ=America/Lima
10 TZ=America/Lima
11 DOCKER_DATA=/Volumes/dockers/radarsys/
11 DOCKER_DATA=/Volumes/dockers/radarsys/
12 LOCAL_IP=192.168.1.128
@@ -1,864 +1,864
1 from django.db import models
1 from django.db import models
2 from apps.main.models import Configuration
2 from apps.main.models import Configuration
3 from django.core.urlresolvers import reverse
3 from django.core.urlresolvers import reverse
4 # Create your models here.
4 # Create your models here.
5 from celery.execute import send_task
5 from celery.execute import send_task
6 from datetime import datetime
6 from datetime import datetime
7 import ast
7 import ast
8 import socket
8 import socket
9 import json
9 import json
10 import requests
10 import requests
11 import struct
11 import struct
12 import sys, time
12 import os, sys, time
13
13
14 import multiprocessing
14 import multiprocessing
15
15
16
16
17 antenna_default = json.dumps({
17 antenna_default = json.dumps({
18 "antenna_up": [[0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
18 "antenna_up": [[0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
19 [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
19 [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
20 [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
20 [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
21 [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
21 [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
22 [0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0],
22 [0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0],
23 [0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0],
23 [0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0],
24 [0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0],
24 [0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0],
25 [0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0]
25 [0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0]
26 ]
26 ]
27 ,
27 ,
28 "antenna_down": [[0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
28 "antenna_down": [[0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
29 [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
29 [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
30 [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
30 [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
31 [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
31 [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
32 [0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0],
32 [0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0],
33 [0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0],
33 [0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0],
34 [0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0],
34 [0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0],
35 [0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0]],
35 [0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0]],
36 })
36 })
37
37
38
38
39 tx_default = json.dumps({
39 tx_default = json.dumps({
40 "up": [[1,1,1,1,0,0,0,0],
40 "up": [[1,1,1,1,0,0,0,0],
41 [1,1,1,1,0,0,0,0],
41 [1,1,1,1,0,0,0,0],
42 [1,1,1,1,0,0,0,0],
42 [1,1,1,1,0,0,0,0],
43 [1,1,1,1,0,0,0,0],
43 [1,1,1,1,0,0,0,0],
44 [0,0,0,0,1,1,1,1],
44 [0,0,0,0,1,1,1,1],
45 [0,0,0,0,1,1,1,1],
45 [0,0,0,0,1,1,1,1],
46 [0,0,0,0,1,1,1,1],
46 [0,0,0,0,1,1,1,1],
47 [0,0,0,0,1,1,1,1]],
47 [0,0,0,0,1,1,1,1]],
48
48
49 "down": [[1,1,1,1,0,0,0,0],
49 "down": [[1,1,1,1,0,0,0,0],
50 [1,1,1,1,0,0,0,0],
50 [1,1,1,1,0,0,0,0],
51 [1,1,1,1,0,0,0,0],
51 [1,1,1,1,0,0,0,0],
52 [1,1,1,1,0,0,0,0],
52 [1,1,1,1,0,0,0,0],
53 [0,0,0,0,1,1,1,1],
53 [0,0,0,0,1,1,1,1],
54 [0,0,0,0,1,1,1,1],
54 [0,0,0,0,1,1,1,1],
55 [0,0,0,0,1,1,1,1],
55 [0,0,0,0,1,1,1,1],
56 [0,0,0,0,1,1,1,1]],
56 [0,0,0,0,1,1,1,1]],
57 })
57 })
58
58
59 rx_default = json.dumps({
59 rx_default = json.dumps({
60 "up": [[1,1,1,1,0,0,0,0],
60 "up": [[1,1,1,1,0,0,0,0],
61 [1,1,1,1,0,0,0,0],
61 [1,1,1,1,0,0,0,0],
62 [1,1,1,1,0,0,0,0],
62 [1,1,1,1,0,0,0,0],
63 [1,1,1,1,0,0,0,0],
63 [1,1,1,1,0,0,0,0],
64 [0,0,0,0,1,1,1,1],
64 [0,0,0,0,1,1,1,1],
65 [0,0,0,0,1,1,1,1],
65 [0,0,0,0,1,1,1,1],
66 [0,0,0,0,1,1,1,1],
66 [0,0,0,0,1,1,1,1],
67 [0,0,0,0,1,1,1,1]],
67 [0,0,0,0,1,1,1,1]],
68
68
69 "down": [[1,1,1,1,0,0,0,0],
69 "down": [[1,1,1,1,0,0,0,0],
70 [1,1,1,1,0,0,0,0],
70 [1,1,1,1,0,0,0,0],
71 [1,1,1,1,0,0,0,0],
71 [1,1,1,1,0,0,0,0],
72 [1,1,1,1,0,0,0,0],
72 [1,1,1,1,0,0,0,0],
73 [0,0,0,0,1,1,1,1],
73 [0,0,0,0,1,1,1,1],
74 [0,0,0,0,1,1,1,1],
74 [0,0,0,0,1,1,1,1],
75 [0,0,0,0,1,1,1,1],
75 [0,0,0,0,1,1,1,1],
76 [0,0,0,0,1,1,1,1]],
76 [0,0,0,0,1,1,1,1]],
77 })
77 })
78
78
79 status_default = '0000000000000000000000000000000000000000000000000000000000000000'
79 status_default = '0000000000000000000000000000000000000000000000000000000000000000'
80 default_messages = {}
80 default_messages = {}
81
81
82 for i in range(1,65):
82 for i in range(1,65):
83 default_messages[str(i)] = "Module "+str(i)
83 default_messages[str(i)] = "Module "+str(i)
84
84
85
85
86 ues_default = json.dumps({
86 ues_default = json.dumps({
87 "up": [0.533333,0.00000,1.06667,0.00000],
87 "up": [0.533333,0.00000,1.06667,0.00000],
88 "down": [0.533333,0.00000,1.06667,0.00000]
88 "down": [0.533333,0.00000,1.06667,0.00000]
89 })
89 })
90
90
91 onlyrx_default = json.dumps({
91 onlyrx_default = json.dumps({
92 "up": False,
92 "up": False,
93 "down": False
93 "down": False
94 })
94 })
95
95
96 def up_convertion(cadena):
96 def up_convertion(cadena):
97 valores = []
97 valores = []
98 for c in cadena:
98 for c in cadena:
99 if c == 1.0: valores=valores+['000']
99 if c == 1.0: valores=valores+['000']
100 if c == 2.0: valores=valores+['001']
100 if c == 2.0: valores=valores+['001']
101 if c == 3.0: valores=valores+['010']
101 if c == 3.0: valores=valores+['010']
102 if c == 0.0: valores=valores+['011']
102 if c == 0.0: valores=valores+['011']
103 if c == 0.5: valores=valores+['100']
103 if c == 0.5: valores=valores+['100']
104 if c == 1.5: valores=valores+['101']
104 if c == 1.5: valores=valores+['101']
105 if c == 2.5: valores=valores+['110']
105 if c == 2.5: valores=valores+['110']
106 if c == 3.5: valores=valores+['111']
106 if c == 3.5: valores=valores+['111']
107
107
108 return valores
108 return valores
109
109
110 def up_conv_bits(value):
110 def up_conv_bits(value):
111
111
112 if value == 1.0: bits="000"
112 if value == 1.0: bits="000"
113 if value == 2.0: bits="001"
113 if value == 2.0: bits="001"
114 if value == 3.0: bits="010"
114 if value == 3.0: bits="010"
115 if value == 0.0: bits="011"
115 if value == 0.0: bits="011"
116 if value == 0.5: bits="100"
116 if value == 0.5: bits="100"
117 if value == 1.5: bits="101"
117 if value == 1.5: bits="101"
118 if value == 2.5: bits="110"
118 if value == 2.5: bits="110"
119 if value == 3.5: bits="111"
119 if value == 3.5: bits="111"
120
120
121 return bits
121 return bits
122
122
123 def down_convertion(cadena):
123 def down_convertion(cadena):
124 valores = []
124 valores = []
125 for c in cadena:
125 for c in cadena:
126 if c == 1.0: valores=valores+['000']
126 if c == 1.0: valores=valores+['000']
127 if c == 2.0: valores=valores+['001']
127 if c == 2.0: valores=valores+['001']
128 if c == 3.0: valores=valores+['010']
128 if c == 3.0: valores=valores+['010']
129 if c == 0.0: valores=valores+['011']
129 if c == 0.0: valores=valores+['011']
130 if c == 0.5: valores=valores+['100']
130 if c == 0.5: valores=valores+['100']
131 if c == 1.5: valores=valores+['101']
131 if c == 1.5: valores=valores+['101']
132 if c == 2.5: valores=valores+['110']
132 if c == 2.5: valores=valores+['110']
133 if c == 3.5: valores=valores+['111']
133 if c == 3.5: valores=valores+['111']
134
134
135 return valores
135 return valores
136
136
137 def down_conv_bits(value):
137 def down_conv_bits(value):
138
138
139 if value == 1.0: bits="000"
139 if value == 1.0: bits="000"
140 if value == 2.0: bits="001"
140 if value == 2.0: bits="001"
141 if value == 3.0: bits="010"
141 if value == 3.0: bits="010"
142 if value == 0.0: bits="011"
142 if value == 0.0: bits="011"
143 if value == 0.5: bits="100"
143 if value == 0.5: bits="100"
144 if value == 1.5: bits="101"
144 if value == 1.5: bits="101"
145 if value == 2.5: bits="110"
145 if value == 2.5: bits="110"
146 if value == 3.5: bits="111"
146 if value == 3.5: bits="111"
147
147
148 return bits
148 return bits
149
149
150 def up_conv_value(bits):
150 def up_conv_value(bits):
151
151
152 if bits == "000": value=1.0
152 if bits == "000": value=1.0
153 if bits == "001": value=2.0
153 if bits == "001": value=2.0
154 if bits == "010": value=3.0
154 if bits == "010": value=3.0
155 if bits == "011": value=0.0
155 if bits == "011": value=0.0
156 if bits == "100": value=0.5
156 if bits == "100": value=0.5
157 if bits == "101": value=1.5
157 if bits == "101": value=1.5
158 if bits == "110": value=2.5
158 if bits == "110": value=2.5
159 if bits == "111": value=3.5
159 if bits == "111": value=3.5
160
160
161 return value
161 return value
162
162
163 def down_conv_value(bits):
163 def down_conv_value(bits):
164
164
165 if bits == "000": value=1.0
165 if bits == "000": value=1.0
166 if bits == "001": value=2.0
166 if bits == "001": value=2.0
167 if bits == "010": value=3.0
167 if bits == "010": value=3.0
168 if bits == "011": value=0.0
168 if bits == "011": value=0.0
169 if bits == "100": value=0.5
169 if bits == "100": value=0.5
170 if bits == "101": value=1.5
170 if bits == "101": value=1.5
171 if bits == "110": value=2.5
171 if bits == "110": value=2.5
172 if bits == "111": value=3.5
172 if bits == "111": value=3.5
173
173
174 return value
174 return value
175
175
176 def ip2position(module_number):
176 def ip2position(module_number):
177 j=0
177 j=0
178 i=0
178 i=0
179 for x in range(0,module_number-1):
179 for x in range(0,module_number-1):
180 j=j+1
180 j=j+1
181 if j==8:
181 if j==8:
182 i=i+1
182 i=i+1
183 j=0
183 j=0
184
184
185 pos = [i,j]
185 pos = [i,j]
186 return pos
186 return pos
187
187
188
188
189 def fromBinary2Char(binary_string):
189 def fromBinary2Char(binary_string):
190 number = int(binary_string, 2)
190 number = int(binary_string, 2)
191 #Plus 33 to avoid more than 1 characters values such as: '\x01'-'\x1f'
191 #Plus 33 to avoid more than 1 characters values such as: '\x01'-'\x1f'
192 number = number + 33
192 number = number + 33
193 char = chr(number)
193 char = chr(number)
194 return char
194 return char
195
195
196 def fromChar2Binary(char):
196 def fromChar2Binary(char):
197 number = ord(char) - 33
197 number = ord(char) - 33
198 #Minus 33 to get the real value
198 #Minus 33 to get the real value
199 bits = bin(number)[2:]
199 bits = bin(number)[2:]
200 #To ensure we have a string with 6bits
200 #To ensure we have a string with 6bits
201 if len(bits) < 6:
201 if len(bits) < 6:
202 bits = bits.zfill(6)
202 bits = bits.zfill(6)
203 return bits
203 return bits
204
204
205 OPERATION_MODES = (
205 OPERATION_MODES = (
206 (0, 'Manual'),
206 (0, 'Manual'),
207 (1, 'Automatic'),
207 (1, 'Automatic'),
208 )
208 )
209
209
210
210
211 class ABSConfiguration(Configuration):
211 class ABSConfiguration(Configuration):
212 active_beam = models.PositiveSmallIntegerField(verbose_name='Active Beam', default=0)
212 active_beam = models.PositiveSmallIntegerField(verbose_name='Active Beam', default=0)
213 module_status = models.CharField(verbose_name='Module Status', max_length=10000, default=json.dumps(status_default))
213 module_status = models.CharField(verbose_name='Module Status', max_length=10000, default=json.dumps(status_default))
214 operation_mode = models.PositiveSmallIntegerField(verbose_name='Operation Mode', choices=OPERATION_MODES, default = 0)
214 operation_mode = models.PositiveSmallIntegerField(verbose_name='Operation Mode', choices=OPERATION_MODES, default = 0)
215 operation_value = models.FloatField(verbose_name='Periodic (seconds)', default="10", null=True, blank=True)
215 operation_value = models.FloatField(verbose_name='Periodic (seconds)', default="10", null=True, blank=True)
216 module_messages = models.CharField(verbose_name='Modules Messages', max_length=10000, default=json.dumps(default_messages))
216 module_messages = models.CharField(verbose_name='Modules Messages', max_length=10000, default=json.dumps(default_messages))
217
217
218 class Meta:
218 class Meta:
219 db_table = 'abs_configurations'
219 db_table = 'abs_configurations'
220
220
221 def get_absolute_url_plot(self):
221 def get_absolute_url_plot(self):
222 return reverse('url_plot_abs_patterns', args=[str(self.id)])
222 return reverse('url_plot_abs_patterns', args=[str(self.id)])
223
223
224
224
225 def parms_to_dict(self):
225 def parms_to_dict(self):
226
226
227 parameters = {}
227 parameters = {}
228
228
229 parameters['device_id'] = self.device.id
229 parameters['device_id'] = self.device.id
230 parameters['name'] = self.name
230 parameters['name'] = self.name
231 parameters['device_type'] = self.device.device_type.name
231 parameters['device_type'] = self.device.device_type.name
232 parameters['beams'] = {}
232 parameters['beams'] = {}
233
233
234 beams = ABSBeam.objects.filter(abs_conf=self)
234 beams = ABSBeam.objects.filter(abs_conf=self)
235 b=1
235 b=1
236 for beam in beams:
236 for beam in beams:
237 #absbeam = ABSBeam.objects.get(pk=beams[beam])
237 #absbeam = ABSBeam.objects.get(pk=beams[beam])
238 parameters['beams']['beam'+str(b)] = beam.parms_to_dict()#absbeam.parms_to_dict()
238 parameters['beams']['beam'+str(b)] = beam.parms_to_dict()#absbeam.parms_to_dict()
239 b+=1
239 b+=1
240
240
241 return parameters
241 return parameters
242
242
243
243
244 def dict_to_parms(self, parameters):
244 def dict_to_parms(self, parameters):
245
245
246 self.name = parameters['name']
246 self.name = parameters['name']
247
247
248 absbeams = ABSBeam.objects.filter(abs_conf=self)
248 absbeams = ABSBeam.objects.filter(abs_conf=self)
249 beams = parameters['beams']
249 beams = parameters['beams']
250
250
251 if absbeams:
251 if absbeams:
252 beams_number = len(beams)
252 beams_number = len(beams)
253 absbeams_number = len(absbeams)
253 absbeams_number = len(absbeams)
254 if beams_number==absbeams_number:
254 if beams_number==absbeams_number:
255 i = 1
255 i = 1
256 for absbeam in absbeams:
256 for absbeam in absbeams:
257 absbeam.dict_to_parms(beams['beam'+str(i)])
257 absbeam.dict_to_parms(beams['beam'+str(i)])
258 i = i+1
258 i = i+1
259 elif beams_number > absbeams_number:
259 elif beams_number > absbeams_number:
260 i = 1
260 i = 1
261 for absbeam in absbeams:
261 for absbeam in absbeams:
262 absbeam.dict_to_parms(beams['beam'+str(i)])
262 absbeam.dict_to_parms(beams['beam'+str(i)])
263 i=i+1
263 i=i+1
264 for x in range(i,beams_number+1):
264 for x in range(i,beams_number+1):
265 new_beam = ABSBeam(
265 new_beam = ABSBeam(
266 name =beams['beam'+str(i)]['name'],
266 name =beams['beam'+str(i)]['name'],
267 antenna =json.dumps(beams['beam'+str(i)]['antenna']),
267 antenna =json.dumps(beams['beam'+str(i)]['antenna']),
268 abs_conf = self,
268 abs_conf = self,
269 tx =json.dumps(beams['beam'+str(i)]['tx']),
269 tx =json.dumps(beams['beam'+str(i)]['tx']),
270 rx =json.dumps(beams['beam'+str(i)]['rx']),
270 rx =json.dumps(beams['beam'+str(i)]['rx']),
271 ues =json.dumps(beams['beam'+str(i)]['ues']),
271 ues =json.dumps(beams['beam'+str(i)]['ues']),
272 only_rx =json.dumps(beams['beam'+str(i)]['only_rx'])
272 only_rx =json.dumps(beams['beam'+str(i)]['only_rx'])
273 )
273 )
274 new_beam.save()
274 new_beam.save()
275 i=i+1
275 i=i+1
276 else: #beams_number < absbeams_number:
276 else: #beams_number < absbeams_number:
277 i = 1
277 i = 1
278 for absbeam in absbeams:
278 for absbeam in absbeams:
279 if i <= beams_number:
279 if i <= beams_number:
280 absbeam.dict_to_parms(beams['beam'+str(i)])
280 absbeam.dict_to_parms(beams['beam'+str(i)])
281 i=i+1
281 i=i+1
282 else:
282 else:
283 absbeam.delete()
283 absbeam.delete()
284 else:
284 else:
285 for beam in beams:
285 for beam in beams:
286 new_beam = ABSBeam(
286 new_beam = ABSBeam(
287 name =beams[beam]['name'],
287 name =beams[beam]['name'],
288 antenna =json.dumps(beams[beam]['antenna']),
288 antenna =json.dumps(beams[beam]['antenna']),
289 abs_conf = self,
289 abs_conf = self,
290 tx =json.dumps(beams[beam]['tx']),
290 tx =json.dumps(beams[beam]['tx']),
291 rx =json.dumps(beams[beam]['rx']),
291 rx =json.dumps(beams[beam]['rx']),
292 ues =json.dumps(beams[beam]['ues']),
292 ues =json.dumps(beams[beam]['ues']),
293 only_rx =json.dumps(beams[beam]['only_rx'])
293 only_rx =json.dumps(beams[beam]['only_rx'])
294 )
294 )
295 new_beam.save()
295 new_beam.save()
296
296
297
297
298
298
299 def update_from_file(self, parameters):
299 def update_from_file(self, parameters):
300
300
301 self.dict_to_parms(parameters)
301 self.dict_to_parms(parameters)
302 self.save()
302 self.save()
303
303
304
304
305 def get_beams(self, **kwargs):
305 def get_beams(self, **kwargs):
306 '''
306 '''
307 This function returns ABS Configuration beams
307 This function returns ABS Configuration beams
308 '''
308 '''
309 return ABSBeam.objects.filter(abs_conf=self.pk, **kwargs)
309 return ABSBeam.objects.filter(abs_conf=self.pk, **kwargs)
310
310
311 def clone(self, **kwargs):
311 def clone(self, **kwargs):
312
312
313 beams = self.get_beams()
313 beams = self.get_beams()
314 self.pk = None
314 self.pk = None
315 self.id = None
315 self.id = None
316 for attr, value in kwargs.items():
316 for attr, value in kwargs.items():
317 setattr(self, attr, value)
317 setattr(self, attr, value)
318 self.save()
318 self.save()
319
319
320 for beam in beams:
320 for beam in beams:
321 beam.clone(abs_conf=self)
321 beam.clone(abs_conf=self)
322
322
323 #-----For Active Beam-----
323 #-----For Active Beam-----
324 new_beams = ABSBeam.objects.filter(abs_conf=self)
324 new_beams = ABSBeam.objects.filter(abs_conf=self)
325 self.active_beam = new_beams[0].id
325 self.active_beam = new_beams[0].id
326 self.save()
326 self.save()
327 #-----For Active Beam-----
327 #-----For Active Beam-----
328 #-----For Device Status---
328 #-----For Device Status---
329 self.device.status = 3
329 self.device.status = 3
330 self.device.save()
330 self.device.save()
331 #-----For Device Status---
331 #-----For Device Status---
332
332
333 return self
333 return self
334
334
335
335
336 def start_device(self):
336 def start_device(self):
337
337
338 if self.device.status == 3:
338 if self.device.status == 3:
339
339
340 try:
340 try:
341 #self.write_device()
341 #self.write_device()
342 send_task('task_change_beam', [self.id],)
342 send_task('task_change_beam', [self.id],)
343 self.message = 'ABS running'
343 self.message = 'ABS running'
344
344
345 except Exception as e:
345 except Exception as e:
346 self.message = str(e)
346 self.message = str(e)
347 return False
347 return False
348
348
349 return True
349 return True
350
350
351 else:
351 else:
352 self.message = 'Please, select Write ABS Device first.'
352 self.message = 'Please, select Write ABS Device first.'
353 return False
353 return False
354
354
355
355
356 def stop_device(self):
356 def stop_device(self):
357
357
358 self.device.status = 2
358 self.device.status = 2
359 self.device.save()
359 self.device.save()
360 self.message = 'ABS has been stopped.'
360 self.message = 'ABS has been stopped.'
361 self.save()
361 self.save()
362
362
363 return True
363 return True
364
364
365
365
366 def write_device(self):
366 def write_device(self):
367
367
368 """
368 """
369 This function sends the beams list to every abs module.
369 This function sends the beams list to every abs module.
370 It needs 'module_conf' function
370 It needs 'module_conf' function
371 """
371 """
372
372
373 beams = ABSBeam.objects.filter(abs_conf=self)
373 beams = ABSBeam.objects.filter(abs_conf=self)
374 nbeams = len(beams)
374 nbeams = len(beams)
375 if self.connected_modules() == 0 :
375 if self.connected_modules() == 0 :
376 self.message = "No ABS Module detected."
376 self.message = "No ABS Module detected."
377 return False
377 return False
378
378
379 #-------------Write each abs module-----------
379 #-------------Write each abs module-----------
380 if beams:
380 if beams:
381 message = 'SNDF{:02d}'.format(nbeams)
381 message = 'SNDF{:02d}'.format(nbeams)
382 for i, status in enumerate(self.module_status):
382 for i, status in enumerate(self.module_status):
383 message += ''.join([fromBinary2Char(beam.module_6bits(i)) for beam in beams])
383 message += ''.join([fromBinary2Char(beam.module_6bits(i)) for beam in beams])
384 status = ['0'] * 64
384 status = ['0'] * 64
385 n = 0
385 n = 0
386
386
387 sock = self.send_multicast(message)
387 sock = self.send_multicast(message)
388
388
389 for i in range(64):
389 for i in range(64):
390 try:
390 try:
391 data, address = sock.recvfrom(1024)
391 data, address = sock.recvfrom(1024)
392 if data == '1':
392 if data == '1':
393 status[int(address[0][10:])-1] = '3'
393 status[int(address[0][10:])-1] = '3'
394 elif data == '0':
394 elif data == '0':
395 status[int(address[0][10:])-1] = '1'
395 status[int(address[0][10:])-1] = '1'
396 except:
396 except:
397 n += 1
397 n += 1
398 sock.close()
398 sock.close()
399 else:
399 else:
400 self.message = "ABS Configuration does not have beams"
400 self.message = "ABS Configuration does not have beams"
401 return False
401 return False
402
402
403 if n == 64:
403 if n == 64:
404 self.message = "Could not write ABS Modules"
404 self.message = "Could not write ABS Modules"
405 self.device.status = 0
405 self.device.status = 0
406 self.module_status = ''.join(status)
406 self.module_status = ''.join(status)
407 self.save()
407 self.save()
408 return False
408 return False
409 else:
409 else:
410 self.message = "ABS Beams List have been sent to ABS Modules"
410 self.message = "ABS Beams List have been sent to ABS Modules"
411 beams[0].set_as_activebeam()
411 self.active_beam = beams[0].pk
412
412
413 self.device.status = 3
413 self.device.status = 3
414 self.module_status = ''.join(status)
414 self.module_status = ''.join(status)
415 self.save()
415 self.save()
416 return True
416 return True
417
417
418
418
419 def read_module(self, module):
419 def read_module(self, module):
420
420
421 """
421 """
422 Read out-bits (up-down) of 1 abs module NOT for Configuration
422 Read out-bits (up-down) of 1 abs module NOT for Configuration
423 """
423 """
424
424
425 ip_address = self.device.ip_address
425 ip_address = self.device.ip_address
426 ip_address = ip_address.split('.')
426 ip_address = ip_address.split('.')
427 module_seq = (ip_address[0],ip_address[1],ip_address[2])
427 module_seq = (ip_address[0],ip_address[1],ip_address[2])
428 dot = '.'
428 dot = '.'
429 module_ip = dot.join(module_seq)+'.'+str(module)
429 module_ip = dot.join(module_seq)+'.'+str(module)
430 module_port = self.device.port_address
430 module_port = self.device.port_address
431 read_route = 'http://'+module_ip+':'+str(module_port)+'/read'
431 read_route = 'http://'+module_ip+':'+str(module_port)+'/read'
432
432
433 module_status = json.loads(self.module_status)
433 module_status = json.loads(self.module_status)
434 print(read_route)
434 print(read_route)
435
435
436 module_bits = ''
436 module_bits = ''
437
437
438 try:
438 try:
439 r_read = requests.get(read_route, timeout=0.5)
439 r_read = requests.get(read_route, timeout=0.5)
440 answer = r_read.json()
440 answer = r_read.json()
441 module_bits = answer['allbits']
441 module_bits = answer['allbits']
442 except:
442 except:
443 return {}
443 return {}
444
444
445 return module_bits
445 return module_bits
446
446
447 def read_device(self):
447 def read_device(self):
448
448
449 parms = {}
449 parms = {}
450 # Reads active modules.
450 # Reads active modules.
451 module_status = json.loads(self.module_status)
451 module_status = json.loads(self.module_status)
452 total = 0
452 total = 0
453 for status in module_status:
453 for status in module_status:
454 if module_status[status] != 0:
454 if module_status[status] != 0:
455 module_bits = self.read_module(int(status))
455 module_bits = self.read_module(int(status))
456 bits={}
456 bits={}
457 if module_bits:
457 if module_bits:
458 bits = (str(module_bits['um2']) + str(module_bits['um1']) + str(module_bits['um0']) +
458 bits = (str(module_bits['um2']) + str(module_bits['um1']) + str(module_bits['um0']) +
459 str(module_bits['dm2']) + str(module_bits['dm1']) + str(module_bits['dm0']) )
459 str(module_bits['dm2']) + str(module_bits['dm1']) + str(module_bits['dm0']) )
460 parms[str(status)] = bits
460 parms[str(status)] = bits
461
461
462 total +=1
462 total +=1
463
463
464 if total==0:
464 if total==0:
465 self.message = "No ABS Module detected. Please select 'Status'."
465 self.message = "No ABS Module detected. Please select 'Status'."
466 return False
466 return False
467
467
468
468
469
469
470 self.message = "ABS Modules have been read"
470 self.message = "ABS Modules have been read"
471 #monitoreo_tx = JROABSClnt_01CeCnMod000000MNTR10
471 #monitoreo_tx = JROABSClnt_01CeCnMod000000MNTR10
472 return parms
472 return parms
473
473
474
474
475 def connected_modules(self):
475 def connected_modules(self):
476 """
476 """
477 This function returns the number of connected abs-modules without updating.
477 This function returns the number of connected abs-modules without updating.
478 """
478 """
479 num = 0
479 num = 0
480 print(self.module_status)
480 print(self.module_status)
481 for i, status in enumerate(self.module_status):
481 for i, status in enumerate(self.module_status):
482 if status != '0':
482 if status != '0':
483 num += 1
483 num += 1
484 print('status {}:{}'.format(i+1, status))
484 print('status {}:{}'.format(i+1, status))
485 return num
485 return num
486
486
487 def send_multicast(self, message):
487 def send_multicast(self, message):
488
488
489 multicast_group = ('224.3.29.71', 10000)
489 multicast_group = ('224.3.29.71', 10000)
490 # Create the datagram socket
490 # Create the datagram socket
491 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
491 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
492 sock.settimeout(0.01)
492 sock.settimeout(0.01)
493 local_ip = "0.0.0.0"
493 local_ip = os.environ.get('LOCAL_IP', '127.0.0.1')
494 sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_IF, socket.inet_aton(local_ip))
494 sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_IF, socket.inet_aton(local_ip))
495 sent = sock.sendto(message, multicast_group)
495 sent = sock.sendto(message, multicast_group)
496 print('Sending ' + message)
496 print('Sending ' + message)
497 return sock
497 return sock
498
498
499 def status_device(self):
499 def status_device(self):
500 """
500 """
501 This function returns the status of all abs-modules as one.
501 This function returns the status of all abs-modules as one.
502 If at least one module is connected, its answer is "1"
502 If at least one module is connected, its answer is "1"
503 """
503 """
504
504
505 sock = self.send_multicast('MNTR')
505 sock = self.send_multicast('MNTR')
506
506
507 n = 0
507 n = 0
508 status = ['0'] * 64
508 status = ['0'] * 64
509 for i in range(64):
509 for i in range(64):
510 try:
510 try:
511 data, address = sock.recvfrom(1024)
511 data, address = sock.recvfrom(1024)
512 if data == '1':
512 if data == '1':
513 status[int(address[0][10:])-1] = '3'
513 status[int(address[0][10:])-1] = '3'
514 elif data == '0':
514 elif data == '0':
515 status[int(address[0][10:])-1] = '1'
515 status[int(address[0][10:])-1] = '1'
516 n += 1
516 n += 1
517 print('Module: {} connected'.format(address))
517 print('Module: {} connected'.format(address))
518 except:
518 except:
519 pass
519 pass
520 sock.close()
520 sock.close()
521
521
522 if n > 0:
522 if n > 0:
523 self.message = 'ABS modules Status have been updated.'
523 self.message = 'ABS modules Status have been updated.'
524 self.device.status = 1
524 self.device.status = 1
525 else:
525 else:
526 self.device.status = 0
526 self.device.status = 0
527 self.message = 'No ABS module is connected.'
527 self.message = 'No ABS module is connected.'
528 self.module_status = ''.join(status)
528 self.module_status = ''.join(status)
529 self.save()
529 self.save()
530
530
531 return self.device.status
531 return self.device.status
532
532
533
533
534 def send_beam(self, beam_pos):
534 def send_beam(self, beam_pos):
535 """
535 """
536 This function connects to a multicast group and sends the beam number
536 This function connects to a multicast group and sends the beam number
537 to all abs modules.
537 to all abs modules.
538 """
538 """
539
539
540 # Se manda a cero RC para poder realizar cambio de beam
540 # Se manda a cero RC para poder realizar cambio de beam
541 confs = Configuration.objects.filter(experiment = self.experiment).filter(type=0)
541 confs = Configuration.objects.filter(experiment = self.experiment).filter(type=0)
542 confdds = ''
542 confdds = ''
543 confjars = ''
543 confjars = ''
544 confrc = ''
544 confrc = ''
545
545
546 #TO STOP DEVICES: DDS-JARS-RC
546 #TO STOP DEVICES: DDS-JARS-RC
547 for i in range(0,len(confs)):
547 for i in range(0,len(confs)):
548 if i==0:
548 if i==0:
549 for conf in confs:
549 for conf in confs:
550 if conf.device.device_type.name == 'dds':
550 if conf.device.device_type.name == 'dds':
551 confdds = conf
551 confdds = conf
552 confdds.stop_device()
552 confdds.stop_device()
553 break
553 break
554 if i==1:
554 if i==1:
555 for conf in confs:
555 for conf in confs:
556 if conf.device.device_type.name == 'jars':
556 if conf.device.device_type.name == 'jars':
557 confjars = conf
557 confjars = conf
558 confjars.stop_device()
558 confjars.stop_device()
559 break
559 break
560 if i==2:
560 if i==2:
561 for conf in confs:
561 for conf in confs:
562 if conf.device.device_type.name == 'rc':
562 if conf.device.device_type.name == 'rc':
563 confrc = conf
563 confrc = conf
564 confrc.stop_device()
564 confrc.stop_device()
565 break
565 break
566
566
567 if beam_pos > 0:
567 if beam_pos > 0:
568 beam_pos = beam_pos - 1
568 beam_pos = beam_pos - 1
569 else:
569 else:
570 beam_pos = 0
570 beam_pos = 0
571
571
572 #El indice del apunte debe ser menor que el numero total de apuntes
572 #El indice del apunte debe ser menor que el numero total de apuntes
573 #El servidor tcp en el embebido comienza a contar desde 0
573 #El servidor tcp en el embebido comienza a contar desde 0
574 status = ['0'] * 64
574 status = ['0'] * 64
575 message = 'CHGB{}'.format(beam_pos)
575 message = 'CHGB{}'.format(beam_pos)
576 sock = self.send_multicast(message)
576 sock = self.send_multicast(message)
577
577
578 for i in range(64):
578 for i in range(64):
579 try:
579 try:
580 data, address = sock.recvfrom(1024)
580 data, address = sock.recvfrom(1024)
581 print address, data
581 print address, data
582 if data == '1':
582 if data == '1':
583 status[int(address[0][10:])-1] = '3'
583 status[int(address[0][10:])-1] = '3'
584 elif data == '0':
584 elif data == '0':
585 status[int(address[0][10:])-1] = '1'
585 status[int(address[0][10:])-1] = '1'
586 except:
586 except:
587 pass
587 pass
588
588
589 sock.close()
589 sock.close()
590
590
591 #Start DDS-RC-JARS
591 #Start DDS-RC-JARS
592 if confdds:
592 if confdds:
593 confdds.start_device()
593 confdds.start_device()
594 if confrc:
594 if confrc:
595 #print confrc
595 #print confrc
596 confrc.start_device()
596 confrc.start_device()
597 if confjars:
597 if confjars:
598 confjars.start_device()
598 confjars.start_device()
599
599
600 self.message = "ABS Beam has been changed"
600 self.message = "ABS Beam has been changed"
601 self.module_status = ''.join(status)
601 self.module_status = ''.join(status)
602 self.save()
602 self.save()
603 return True
603 return True
604
604
605
605
606 def get_absolute_url_import(self):
606 def get_absolute_url_import(self):
607 return reverse('url_import_abs_conf', args=[str(self.id)])
607 return reverse('url_import_abs_conf', args=[str(self.id)])
608
608
609
609
610 class ABSBeam(models.Model):
610 class ABSBeam(models.Model):
611
611
612 name = models.CharField(max_length=60, default='Beam')
612 name = models.CharField(max_length=60, default='Beam')
613 antenna = models.CharField(verbose_name='Antenna', max_length=1000, default=antenna_default)
613 antenna = models.CharField(verbose_name='Antenna', max_length=1000, default=antenna_default)
614 abs_conf = models.ForeignKey(ABSConfiguration, null=True, verbose_name='ABS Configuration')
614 abs_conf = models.ForeignKey(ABSConfiguration, null=True, verbose_name='ABS Configuration')
615 tx = models.CharField(verbose_name='Tx', max_length=1000, default=tx_default)
615 tx = models.CharField(verbose_name='Tx', max_length=1000, default=tx_default)
616 rx = models.CharField(verbose_name='Rx', max_length=1000, default=rx_default)
616 rx = models.CharField(verbose_name='Rx', max_length=1000, default=rx_default)
617 s_time = models.TimeField(verbose_name='Star Time', default='00:00:00')
617 s_time = models.TimeField(verbose_name='Star Time', default='00:00:00')
618 e_time = models.TimeField(verbose_name='End Time', default='23:59:59')
618 e_time = models.TimeField(verbose_name='End Time', default='23:59:59')
619 ues = models.CharField(verbose_name='Ues', max_length=100, default=ues_default)
619 ues = models.CharField(verbose_name='Ues', max_length=100, default=ues_default)
620 only_rx = models.CharField(verbose_name='Only RX', max_length=40, default=onlyrx_default)
620 only_rx = models.CharField(verbose_name='Only RX', max_length=40, default=onlyrx_default)
621
621
622 class Meta:
622 class Meta:
623 db_table = 'abs_beams'
623 db_table = 'abs_beams'
624
624
625 def __unicode__(self):
625 def __unicode__(self):
626 return u'%s' % (self.name)
626 return u'%s' % (self.name)
627
627
628 def parms_to_dict(self):
628 def parms_to_dict(self):
629
629
630 parameters = {}
630 parameters = {}
631 parameters['name'] = self.name
631 parameters['name'] = self.name
632 parameters['antenna'] = ast.literal_eval(self.antenna)
632 parameters['antenna'] = ast.literal_eval(self.antenna)
633 parameters['abs_conf'] = self.abs_conf.name
633 parameters['abs_conf'] = self.abs_conf.name
634 parameters['tx'] = ast.literal_eval(self.tx)
634 parameters['tx'] = ast.literal_eval(self.tx)
635 parameters['rx'] = ast.literal_eval(self.rx)
635 parameters['rx'] = ast.literal_eval(self.rx)
636 parameters['s_time'] = self.s_time.strftime("%H:%M:%S")
636 parameters['s_time'] = self.s_time.strftime("%H:%M:%S")
637 parameters['e_time'] = self.e_time.strftime("%H:%M:%S")
637 parameters['e_time'] = self.e_time.strftime("%H:%M:%S")
638 parameters['ues'] = ast.literal_eval(self.ues)
638 parameters['ues'] = ast.literal_eval(self.ues)
639 parameters['only_rx'] = json.loads(self.only_rx)
639 parameters['only_rx'] = json.loads(self.only_rx)
640
640
641 return parameters
641 return parameters
642
642
643 def dict_to_parms(self, parameters):
643 def dict_to_parms(self, parameters):
644
644
645 self.name = parameters['name']
645 self.name = parameters['name']
646 self.antenna = json.dumps(parameters['antenna'])
646 self.antenna = json.dumps(parameters['antenna'])
647 #self.abs_conf = parameters['abs_conf']
647 #self.abs_conf = parameters['abs_conf']
648 self.tx = json.dumps(parameters['tx'])
648 self.tx = json.dumps(parameters['tx'])
649 self.rx = json.dumps(parameters['rx'])
649 self.rx = json.dumps(parameters['rx'])
650 #self.s_time = parameters['s_time']
650 #self.s_time = parameters['s_time']
651 #self.e_time = parameters['e_time']
651 #self.e_time = parameters['e_time']
652 self.ues = json.dumps(parameters['ues'])
652 self.ues = json.dumps(parameters['ues'])
653 self.only_rx = json.dumps(parameters['only_rx'])
653 self.only_rx = json.dumps(parameters['only_rx'])
654 self.save()
654 self.save()
655
655
656
656
657 def clone(self, **kwargs):
657 def clone(self, **kwargs):
658
658
659 self.pk = None
659 self.pk = None
660 self.id = None
660 self.id = None
661 for attr, value in kwargs.items():
661 for attr, value in kwargs.items():
662 setattr(self, attr, value)
662 setattr(self, attr, value)
663
663
664 self.save()
664 self.save()
665
665
666 return self
666 return self
667
667
668
668
669 def module_6bits(self, module):
669 def module_6bits(self, module):
670 """
670 """
671 This function reads antenna pattern and choose 6bits (upbits-downbits) for one abs module
671 This function reads antenna pattern and choose 6bits (upbits-downbits) for one abs module
672 """
672 """
673 if module > 64:
673 if module > 64:
674 beam_bits = ""
674 beam_bits = ""
675 return beam_bits
675 return beam_bits
676
676
677 data = ast.literal_eval(self.antenna)
677 data = ast.literal_eval(self.antenna)
678 up_data = data['antenna_up']
678 up_data = data['antenna_up']
679 down_data = data['antenna_down']
679 down_data = data['antenna_down']
680
680
681 pos = ip2position(module)
681 pos = ip2position(module)
682 up_value = up_data[pos[0]][pos[1]]
682 up_value = up_data[pos[0]][pos[1]]
683 down_value = down_data[pos[0]][pos[1]]
683 down_value = down_data[pos[0]][pos[1]]
684
684
685 up_bits = up_conv_bits(up_value)
685 up_bits = up_conv_bits(up_value)
686 down_bits = down_conv_bits(down_value)
686 down_bits = down_conv_bits(down_value)
687 beam_bits = up_bits+down_bits
687 beam_bits = up_bits+down_bits
688
688
689 return beam_bits
689 return beam_bits
690
690
691
691
692 @property
692 @property
693 def get_upvalues(self):
693 def get_upvalues(self):
694 """
694 """
695 This function reads antenna pattern and show the up-value of one abs module
695 This function reads antenna pattern and show the up-value of one abs module
696 """
696 """
697
697
698 data = ast.literal_eval(self.antenna)
698 data = ast.literal_eval(self.antenna)
699 up_data = data['antenna_up']
699 up_data = data['antenna_up']
700
700
701 up_values = []
701 up_values = []
702 for data in up_data:
702 for data in up_data:
703 for i in range(0,8):
703 for i in range(0,8):
704 up_values.append(data[i])
704 up_values.append(data[i])
705
705
706 return up_values
706 return up_values
707
707
708 @property
708 @property
709 def antenna_upvalues(self):
709 def antenna_upvalues(self):
710 """
710 """
711 This function reads antenna pattern and show the up - values of one abs beam
711 This function reads antenna pattern and show the up - values of one abs beam
712 in a particular order
712 in a particular order
713 """
713 """
714 data = ast.literal_eval(self.antenna)
714 data = ast.literal_eval(self.antenna)
715 up_data = data['antenna_up']
715 up_data = data['antenna_up']
716
716
717 return up_data
717 return up_data
718
718
719 @property
719 @property
720 def antenna_downvalues(self):
720 def antenna_downvalues(self):
721 """
721 """
722 This function reads antenna pattern and show the down - values of one abs beam
722 This function reads antenna pattern and show the down - values of one abs beam
723 in a particular order
723 in a particular order
724 """
724 """
725 data = ast.literal_eval(self.antenna)
725 data = ast.literal_eval(self.antenna)
726 down_data = data['antenna_down']
726 down_data = data['antenna_down']
727
727
728 return down_data
728 return down_data
729
729
730 @property
730 @property
731 def get_downvalues(self):
731 def get_downvalues(self):
732 """
732 """
733 This function reads antenna pattern and show the down-value of one abs module
733 This function reads antenna pattern and show the down-value of one abs module
734 """
734 """
735
735
736 data = ast.literal_eval(self.antenna)
736 data = ast.literal_eval(self.antenna)
737 down_data = data['antenna_down']
737 down_data = data['antenna_down']
738
738
739 down_values = []
739 down_values = []
740 for data in down_data:
740 for data in down_data:
741 for i in range(0,8):
741 for i in range(0,8):
742 down_values.append(data[i])
742 down_values.append(data[i])
743
743
744 return down_values
744 return down_values
745
745
746 @property
746 @property
747 def get_up_ues(self):
747 def get_up_ues(self):
748 """
748 """
749 This function shows the up-ues-value of one beam
749 This function shows the up-ues-value of one beam
750 """
750 """
751 data = ast.literal_eval(self.ues)
751 data = ast.literal_eval(self.ues)
752 up_ues = data['up']
752 up_ues = data['up']
753
753
754 return up_ues
754 return up_ues
755
755
756 @property
756 @property
757 def get_down_ues(self):
757 def get_down_ues(self):
758 """
758 """
759 This function shows the down-ues-value of one beam
759 This function shows the down-ues-value of one beam
760 """
760 """
761 data = ast.literal_eval(self.ues)
761 data = ast.literal_eval(self.ues)
762 down_ues = data['down']
762 down_ues = data['down']
763
763
764 return down_ues
764 return down_ues
765
765
766 @property
766 @property
767 def get_up_onlyrx(self):
767 def get_up_onlyrx(self):
768 """
768 """
769 This function shows the up-onlyrx-value of one beam
769 This function shows the up-onlyrx-value of one beam
770 """
770 """
771 data = json.loads(self.only_rx)
771 data = json.loads(self.only_rx)
772 up_onlyrx = data['up']
772 up_onlyrx = data['up']
773
773
774 return up_onlyrx
774 return up_onlyrx
775
775
776 @property
776 @property
777 def get_down_onlyrx(self):
777 def get_down_onlyrx(self):
778 """
778 """
779 This function shows the down-onlyrx-value of one beam
779 This function shows the down-onlyrx-value of one beam
780 """
780 """
781 data = json.loads(self.only_rx)
781 data = json.loads(self.only_rx)
782 down_onlyrx = data['down']
782 down_onlyrx = data['down']
783
783
784 return down_onlyrx
784 return down_onlyrx
785
785
786 @property
786 @property
787 def get_tx(self):
787 def get_tx(self):
788 """
788 """
789 This function shows the tx-values of one beam
789 This function shows the tx-values of one beam
790 """
790 """
791 data = json.loads(self.tx)
791 data = json.loads(self.tx)
792
792
793 return data
793 return data
794
794
795 @property
795 @property
796 def get_uptx(self):
796 def get_uptx(self):
797 """
797 """
798 This function shows the up-tx-values of one beam
798 This function shows the up-tx-values of one beam
799 """
799 """
800 data = json.loads(self.tx)
800 data = json.loads(self.tx)
801 up_data = data['up']
801 up_data = data['up']
802
802
803 up_values = []
803 up_values = []
804 for data in up_data:
804 for data in up_data:
805 for i in range(0,8):
805 for i in range(0,8):
806 up_values.append(data[i])
806 up_values.append(data[i])
807
807
808 return up_values
808 return up_values
809
809
810 @property
810 @property
811 def get_downtx(self):
811 def get_downtx(self):
812 """
812 """
813 This function shows the down-tx-values of one beam
813 This function shows the down-tx-values of one beam
814 """
814 """
815 data = json.loads(self.tx)
815 data = json.loads(self.tx)
816 down_data = data['down']
816 down_data = data['down']
817
817
818 down_values = []
818 down_values = []
819 for data in down_data:
819 for data in down_data:
820 for i in range(0,8):
820 for i in range(0,8):
821 down_values.append(data[i])
821 down_values.append(data[i])
822
822
823 return down_values
823 return down_values
824
824
825
825
826
826
827 @property
827 @property
828 def get_rx(self):
828 def get_rx(self):
829 """
829 """
830 This function shows the rx-values of one beam
830 This function shows the rx-values of one beam
831 """
831 """
832 data = json.loads(self.rx)
832 data = json.loads(self.rx)
833
833
834 return data
834 return data
835
835
836 @property
836 @property
837 def get_uprx(self):
837 def get_uprx(self):
838 """
838 """
839 This function shows the up-rx-values of one beam
839 This function shows the up-rx-values of one beam
840 """
840 """
841 data = json.loads(self.rx)
841 data = json.loads(self.rx)
842 up_data = data['up']
842 up_data = data['up']
843
843
844 up_values = []
844 up_values = []
845 for data in up_data:
845 for data in up_data:
846 for i in range(0,8):
846 for i in range(0,8):
847 up_values.append(data[i])
847 up_values.append(data[i])
848
848
849 return up_values
849 return up_values
850
850
851 @property
851 @property
852 def get_downrx(self):
852 def get_downrx(self):
853 """
853 """
854 This function shows the down-rx-values of one beam
854 This function shows the down-rx-values of one beam
855 """
855 """
856 data = json.loads(self.rx)
856 data = json.loads(self.rx)
857 down_data = data['down']
857 down_data = data['down']
858
858
859 down_values = []
859 down_values = []
860 for data in down_data:
860 for data in down_data:
861 for i in range(0,8):
861 for i in range(0,8):
862 down_values.append(data[i])
862 down_values.append(data[i])
863
863
864 return down_values
864 return down_values
General Comments 0
You need to be logged in to leave comments. Login now