##// END OF EJS Templates
Review & fix ABS module
Juan C. Espinoza -
r307:678cf1e292ab
parent child
Show More
This diff has been collapsed as it changes many lines, (643 lines changed) Show them Hide them
@@ -1,1345 +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 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 conf_default = {}
79 status_default = '0000000000000000000000000000000000000000000000000000000000000000'
80 status_default = {}
81 default_messages = {}
80 default_messages = {}
82 default_modulemode = {"1": 0, "2": 0, "3": 0, "4": 0, "5": 0, "6": 0, "7": 0, "8": 0, "9": 0, "10": 0,
83 "11": 0, "12": 0, "13": 0, "14": 0, "15": 0, "16": 0, "17": 0, "18": 0, "19": 0, "20": 0,
84 "21": 0, "22": 0, "23": 0, "24": 0, "25": 0, "26": 0, "27": 0, "28": 0, "29": 0, "30": 0,
85 "31": 0, "32": 0, "33": 0, "34": 0, "35": 0, "36": 0, "37": 0, "38": 0, "39": 0, "40": 0,
86 "41": 0, "42": 0, "43": 0, "44": 0, "45": 0, "46": 0, "47": 0, "48": 0, "49": 0, "50": 0,
87 "51": 0, "52": 0, "53": 0, "54": 0, "55": 0, "56": 0, "57": 0, "58": 0, "59": 0, "60": 0,
88 "61": 0, "62": 0, "63": 0, "64": 0} # 0 : Socket // 1: API Rest
89
81
90 for i in range(1,65):
82 for i in range(1,65):
91 conf_default[str(i)] = ""
92 status_default[str(i)] = 0
93 default_messages[str(i)] = "Module "+str(i)
83 default_messages[str(i)] = "Module "+str(i)
94
84
95
85
96 ues_default = json.dumps({
86 ues_default = json.dumps({
97 "up": [0.533333,0.00000,1.06667,0.00000],
87 "up": [0.533333,0.00000,1.06667,0.00000],
98 "down": [0.533333,0.00000,1.06667,0.00000]
88 "down": [0.533333,0.00000,1.06667,0.00000]
99 })
89 })
100
90
101 onlyrx_default = json.dumps({
91 onlyrx_default = json.dumps({
102 "up": False,
92 "up": False,
103 "down": False
93 "down": False
104 })
94 })
105
95
106 def up_convertion(cadena):
96 def up_convertion(cadena):
107 valores = []
97 valores = []
108 for c in cadena:
98 for c in cadena:
109 if c == 1.0: valores=valores+['000']
99 if c == 1.0: valores=valores+['000']
110 if c == 2.0: valores=valores+['001']
100 if c == 2.0: valores=valores+['001']
111 if c == 3.0: valores=valores+['010']
101 if c == 3.0: valores=valores+['010']
112 if c == 0.0: valores=valores+['011']
102 if c == 0.0: valores=valores+['011']
113 if c == 0.5: valores=valores+['100']
103 if c == 0.5: valores=valores+['100']
114 if c == 1.5: valores=valores+['101']
104 if c == 1.5: valores=valores+['101']
115 if c == 2.5: valores=valores+['110']
105 if c == 2.5: valores=valores+['110']
116 if c == 3.5: valores=valores+['111']
106 if c == 3.5: valores=valores+['111']
117
107
118 return valores
108 return valores
119
109
120 def up_conv_bits(value):
110 def up_conv_bits(value):
121
111
122 if value == 1.0: bits="000"
112 if value == 1.0: bits="000"
123 if value == 2.0: bits="001"
113 if value == 2.0: bits="001"
124 if value == 3.0: bits="010"
114 if value == 3.0: bits="010"
125 if value == 0.0: bits="011"
115 if value == 0.0: bits="011"
126 if value == 0.5: bits="100"
116 if value == 0.5: bits="100"
127 if value == 1.5: bits="101"
117 if value == 1.5: bits="101"
128 if value == 2.5: bits="110"
118 if value == 2.5: bits="110"
129 if value == 3.5: bits="111"
119 if value == 3.5: bits="111"
130
120
131 return bits
121 return bits
132
122
133 def down_convertion(cadena):
123 def down_convertion(cadena):
134 valores = []
124 valores = []
135 for c in cadena:
125 for c in cadena:
136 if c == 1.0: valores=valores+['000']
126 if c == 1.0: valores=valores+['000']
137 if c == 2.0: valores=valores+['001']
127 if c == 2.0: valores=valores+['001']
138 if c == 3.0: valores=valores+['010']
128 if c == 3.0: valores=valores+['010']
139 if c == 0.0: valores=valores+['011']
129 if c == 0.0: valores=valores+['011']
140 if c == 0.5: valores=valores+['100']
130 if c == 0.5: valores=valores+['100']
141 if c == 1.5: valores=valores+['101']
131 if c == 1.5: valores=valores+['101']
142 if c == 2.5: valores=valores+['110']
132 if c == 2.5: valores=valores+['110']
143 if c == 3.5: valores=valores+['111']
133 if c == 3.5: valores=valores+['111']
144
134
145 return valores
135 return valores
146
136
147 def down_conv_bits(value):
137 def down_conv_bits(value):
148
138
149 if value == 1.0: bits="000"
139 if value == 1.0: bits="000"
150 if value == 2.0: bits="001"
140 if value == 2.0: bits="001"
151 if value == 3.0: bits="010"
141 if value == 3.0: bits="010"
152 if value == 0.0: bits="011"
142 if value == 0.0: bits="011"
153 if value == 0.5: bits="100"
143 if value == 0.5: bits="100"
154 if value == 1.5: bits="101"
144 if value == 1.5: bits="101"
155 if value == 2.5: bits="110"
145 if value == 2.5: bits="110"
156 if value == 3.5: bits="111"
146 if value == 3.5: bits="111"
157
147
158 return bits
148 return bits
159
149
160 def up_conv_value(bits):
150 def up_conv_value(bits):
161
151
162 if bits == "000": value=1.0
152 if bits == "000": value=1.0
163 if bits == "001": value=2.0
153 if bits == "001": value=2.0
164 if bits == "010": value=3.0
154 if bits == "010": value=3.0
165 if bits == "011": value=0.0
155 if bits == "011": value=0.0
166 if bits == "100": value=0.5
156 if bits == "100": value=0.5
167 if bits == "101": value=1.5
157 if bits == "101": value=1.5
168 if bits == "110": value=2.5
158 if bits == "110": value=2.5
169 if bits == "111": value=3.5
159 if bits == "111": value=3.5
170
160
171 return value
161 return value
172
162
173 def down_conv_value(bits):
163 def down_conv_value(bits):
174
164
175 if bits == "000": value=1.0
165 if bits == "000": value=1.0
176 if bits == "001": value=2.0
166 if bits == "001": value=2.0
177 if bits == "010": value=3.0
167 if bits == "010": value=3.0
178 if bits == "011": value=0.0
168 if bits == "011": value=0.0
179 if bits == "100": value=0.5
169 if bits == "100": value=0.5
180 if bits == "101": value=1.5
170 if bits == "101": value=1.5
181 if bits == "110": value=2.5
171 if bits == "110": value=2.5
182 if bits == "111": value=3.5
172 if bits == "111": value=3.5
183
173
184 return value
174 return value
185
175
186 def ip2position(module_number):
176 def ip2position(module_number):
187 j=0
177 j=0
188 i=0
178 i=0
189 for x in range(0,module_number-1):
179 for x in range(0,module_number-1):
190 j=j+1
180 j=j+1
191 if j==8:
181 if j==8:
192 i=i+1
182 i=i+1
193 j=0
183 j=0
194
184
195 pos = [i,j]
185 pos = [i,j]
196 return pos
186 return pos
197
187
198
188
199 def fromBinary2Char(binary_string):
189 def fromBinary2Char(binary_string):
200 number = int(binary_string, 2)
190 number = int(binary_string, 2)
201 #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'
202 number = number + 33
192 number = number + 33
203 char = chr(number)
193 char = chr(number)
204 return char
194 return char
205
195
206 def fromChar2Binary(char):
196 def fromChar2Binary(char):
207 number = ord(char) - 33
197 number = ord(char) - 33
208 #Minus 33 to get the real value
198 #Minus 33 to get the real value
209 bits = bin(number)[2:]
199 bits = bin(number)[2:]
210 #To ensure we have a string with 6bits
200 #To ensure we have a string with 6bits
211 if len(bits) < 6:
201 if len(bits) < 6:
212 bits = bits.zfill(6)
202 bits = bits.zfill(6)
213 return bits
203 return bits
214
204
215 OPERATION_MODES = (
205 OPERATION_MODES = (
216 (0, 'Manual'),
206 (0, 'Manual'),
217 (1, 'Automatic'),
207 (1, 'Automatic'),
218 )
208 )
219
209
220
210
221 class ABSConfiguration(Configuration):
211 class ABSConfiguration(Configuration):
222 active_beam = models.CharField(verbose_name='Active Beam', max_length=20000, default="{}")
212 active_beam = models.PositiveSmallIntegerField(verbose_name='Active Beam', default=0)
223 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))
224 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)
225 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)
226 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))
227 module_mode = models.CharField(verbose_name='Modules Mode', max_length=10000, default=json.dumps(default_modulemode))
228
217
229 class Meta:
218 class Meta:
230 db_table = 'abs_configurations'
219 db_table = 'abs_configurations'
231
220
232 def get_absolute_url_plot(self):
221 def get_absolute_url_plot(self):
233 return reverse('url_plot_abs_patterns', args=[str(self.id)])
222 return reverse('url_plot_abs_patterns', args=[str(self.id)])
234
223
235
224
236 def parms_to_dict(self):
225 def parms_to_dict(self):
237
226
238 parameters = {}
227 parameters = {}
239
228
240 parameters['device_id'] = self.device.id
229 parameters['device_id'] = self.device.id
241 parameters['name'] = self.name
230 parameters['name'] = self.name
242 parameters['device_type'] = self.device.device_type.name
231 parameters['device_type'] = self.device.device_type.name
243 parameters['beams'] = {}
232 parameters['beams'] = {}
244
233
245 beams = ABSBeam.objects.filter(abs_conf=self)
234 beams = ABSBeam.objects.filter(abs_conf=self)
246 b=1
235 b=1
247 for beam in beams:
236 for beam in beams:
248 #absbeam = ABSBeam.objects.get(pk=beams[beam])
237 #absbeam = ABSBeam.objects.get(pk=beams[beam])
249 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()
250 b+=1
239 b+=1
251
240
252 return parameters
241 return parameters
253
242
254
243
255 def dict_to_parms(self, parameters):
244 def dict_to_parms(self, parameters):
256
245
257 self.name = parameters['name']
246 self.name = parameters['name']
258
247
259 absbeams = ABSBeam.objects.filter(abs_conf=self)
248 absbeams = ABSBeam.objects.filter(abs_conf=self)
260 beams = parameters['beams']
249 beams = parameters['beams']
261
250
262 if absbeams:
251 if absbeams:
263 beams_number = len(beams)
252 beams_number = len(beams)
264 absbeams_number = len(absbeams)
253 absbeams_number = len(absbeams)
265 if beams_number==absbeams_number:
254 if beams_number==absbeams_number:
266 i = 1
255 i = 1
267 for absbeam in absbeams:
256 for absbeam in absbeams:
268 absbeam.dict_to_parms(beams['beam'+str(i)])
257 absbeam.dict_to_parms(beams['beam'+str(i)])
269 i = i+1
258 i = i+1
270 elif beams_number > absbeams_number:
259 elif beams_number > absbeams_number:
271 i = 1
260 i = 1
272 for absbeam in absbeams:
261 for absbeam in absbeams:
273 absbeam.dict_to_parms(beams['beam'+str(i)])
262 absbeam.dict_to_parms(beams['beam'+str(i)])
274 i=i+1
263 i=i+1
275 for x in range(i,beams_number+1):
264 for x in range(i,beams_number+1):
276 new_beam = ABSBeam(
265 new_beam = ABSBeam(
277 name =beams['beam'+str(i)]['name'],
266 name =beams['beam'+str(i)]['name'],
278 antenna =json.dumps(beams['beam'+str(i)]['antenna']),
267 antenna =json.dumps(beams['beam'+str(i)]['antenna']),
279 abs_conf = self,
268 abs_conf = self,
280 tx =json.dumps(beams['beam'+str(i)]['tx']),
269 tx =json.dumps(beams['beam'+str(i)]['tx']),
281 rx =json.dumps(beams['beam'+str(i)]['rx']),
270 rx =json.dumps(beams['beam'+str(i)]['rx']),
282 ues =json.dumps(beams['beam'+str(i)]['ues']),
271 ues =json.dumps(beams['beam'+str(i)]['ues']),
283 only_rx =json.dumps(beams['beam'+str(i)]['only_rx'])
272 only_rx =json.dumps(beams['beam'+str(i)]['only_rx'])
284 )
273 )
285 new_beam.save()
274 new_beam.save()
286 i=i+1
275 i=i+1
287 else: #beams_number < absbeams_number:
276 else: #beams_number < absbeams_number:
288 i = 1
277 i = 1
289 for absbeam in absbeams:
278 for absbeam in absbeams:
290 if i <= beams_number:
279 if i <= beams_number:
291 absbeam.dict_to_parms(beams['beam'+str(i)])
280 absbeam.dict_to_parms(beams['beam'+str(i)])
292 i=i+1
281 i=i+1
293 else:
282 else:
294 absbeam.delete()
283 absbeam.delete()
295 else:
284 else:
296 for beam in beams:
285 for beam in beams:
297 new_beam = ABSBeam(
286 new_beam = ABSBeam(
298 name =beams[beam]['name'],
287 name =beams[beam]['name'],
299 antenna =json.dumps(beams[beam]['antenna']),
288 antenna =json.dumps(beams[beam]['antenna']),
300 abs_conf = self,
289 abs_conf = self,
301 tx =json.dumps(beams[beam]['tx']),
290 tx =json.dumps(beams[beam]['tx']),
302 rx =json.dumps(beams[beam]['rx']),
291 rx =json.dumps(beams[beam]['rx']),
303 ues =json.dumps(beams[beam]['ues']),
292 ues =json.dumps(beams[beam]['ues']),
304 only_rx =json.dumps(beams[beam]['only_rx'])
293 only_rx =json.dumps(beams[beam]['only_rx'])
305 )
294 )
306 new_beam.save()
295 new_beam.save()
307
296
308
297
309
298
310 def update_from_file(self, parameters):
299 def update_from_file(self, parameters):
311
300
312 self.dict_to_parms(parameters)
301 self.dict_to_parms(parameters)
313 self.save()
302 self.save()
314
303
315
304
316 def get_beams(self, **kwargs):
305 def get_beams(self, **kwargs):
317 '''
306 '''
318 This function returns ABS Configuration beams
307 This function returns ABS Configuration beams
319 '''
308 '''
320 return ABSBeam.objects.filter(abs_conf=self.pk, **kwargs)
309 return ABSBeam.objects.filter(abs_conf=self.pk, **kwargs)
321
310
322 def clone(self, **kwargs):
311 def clone(self, **kwargs):
323
312
324 beams = self.get_beams()
313 beams = self.get_beams()
325 self.pk = None
314 self.pk = None
326 self.id = None
315 self.id = None
327 for attr, value in kwargs.items():
316 for attr, value in kwargs.items():
328 setattr(self, attr, value)
317 setattr(self, attr, value)
329 self.save()
318 self.save()
330
319
331 for beam in beams:
320 for beam in beams:
332 beam.clone(abs_conf=self)
321 beam.clone(abs_conf=self)
333
322
334 #-----For Active Beam-----
323 #-----For Active Beam-----
335 active_beam = json.loads(self.active_beam)
336 new_beams = ABSBeam.objects.filter(abs_conf=self)
324 new_beams = ABSBeam.objects.filter(abs_conf=self)
337 active_beam['active_beam'] = new_beams[0].id
325 self.active_beam = new_beams[0].id
338
339 self.active_beam = json.dumps(active_beam)
340 self.save()
326 self.save()
341 #-----For Active Beam-----
327 #-----For Active Beam-----
342 #-----For Device Status---
328 #-----For Device Status---
343 self.device.status = 3
329 self.device.status = 3
344 self.device.save()
330 self.device.save()
345 #-----For Device Status---
331 #-----For Device Status---
346
332
347 return self
333 return self
348
334
349
335
350 def start_device(self):
336 def start_device(self):
351
337
352 if self.device.status == 3:
338 if self.device.status == 3:
353
339
354 try:
340 try:
355 #self.write_device()
341 #self.write_device()
356 send_task('task_change_beam', [self.id],)
342 send_task('task_change_beam', [self.id],)
357 self.message = 'ABS running'
343 self.message = 'ABS running'
358
344
359 except Exception as e:
345 except Exception as e:
360 self.message = str(e)
346 self.message = str(e)
361 return False
347 return False
362
348
363 return True
349 return True
364
350
365 else:
351 else:
366 self.message = 'Please, select Write ABS Device first.'
352 self.message = 'Please, select Write ABS Device first.'
367 return False
353 return False
368
354
369
355
370 def stop_device(self):
356 def stop_device(self):
371
357
372 self.device.status = 2
358 self.device.status = 2
373 self.device.save()
359 self.device.save()
374 self.message = 'ABS has been stopped.'
360 self.message = 'ABS has been stopped.'
375 self.save()
361 self.save()
376
362
377 return True
363 return True
378
364
379 def monitoring_device(self):
380
381 monitoreo_tx = 'JROABSClnt_01CeCnMod000000MNTR10'
382 beam_tx = 'JROABSCeCnModCnMod01000001CHGB10'
383
384 beam_pos = 1
385 module_address = ('192.168.1.63', 5500)
386
387 message_tx = monitoreo_tx
388 # Create the datagram socket
389 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
390 sock.connect(module_address)
391
392 sock.send(message_tx)
393 t = sock.recv(1024)
394 print 'Respuesta: \n',t
395 sock.close()
396 sock = None
397
398 return True
399
400
401 def module_conf(self, module_num, beams):
402 """
403 This function creates beam configurations for one abs module.
404 """
405 ip_address = self.device.ip_address
406 ip_address = ip_address.split('.')
407 module_seq = (ip_address[0],ip_address[1],ip_address[2])
408 dot = '.'
409 module_ip = dot.join(module_seq)+'.'+str(module_num)
410 module_port = self.device.port_address
411 write_route = 'http://'+module_ip+':'+str(module_port)+'/write'
412
413 #header = 'JROABSCeCnModCnMod01000108SNDFexperimento1.ab1'
414 #module = 'ABS_'+str(module_num)
415 bs = '' #{}
416 i=1
417
418 for beam in beams:
419 #bs[i] = fromBinary2Char(beam.module_6bits(module_num))
420 bs = bs + fromBinary2Char(beam.module_6bits(module_num))
421 i=i+1
422
423 beams = bs
424
425 parameters = {}
426 parameters['beams'] = beams #json.dumps(beams)
427 print parameters
428 answer = ''
429
430 try:
431 #r_write = requests.post(write_route, parameters, timeout=0.5)
432 r_write = requests.post(write_route, json = parameters, timeout=0.7)
433 answer = r_write.json()
434 #self.message = answer['message']
435 except:
436 #self.message = "Could not write ABS parameters"
437 return False
438
439 return answer
440
441
442
365
443 def write_device(self):
366 def write_device(self):
444
367
445 """
368 """
446 This function sends the beams list to every abs module.
369 This function sends the beams list to every abs module.
447 It needs 'module_conf' function
370 It needs 'module_conf' function
448 """
371 """
449
372
450 beams = ABSBeam.objects.filter(abs_conf=self)
373 beams = ABSBeam.objects.filter(abs_conf=self)
451 connected_modules = ast.literal_eval(self.module_status)
374 nbeams = len(beams)
452 suma_connected_modules = 0
375 if self.connected_modules() == 0 :
453
454 for c in connected_modules:
455 suma_connected_modules = suma_connected_modules+connected_modules[c]
456 if not suma_connected_modules > 0 :
457 self.message = "No ABS Module detected."
376 self.message = "No ABS Module detected."
458 return False
377 return False
459
378
460 #-------------Write each abs module-----------
379 #-------------Write each abs module-----------
461 if beams:
380 if beams:
462 beams_status = ast.literal_eval(self.module_status)
381 message = 'SNDF{:02d}'.format(nbeams)
463 disconnected_modules = 0
382 for i, status in enumerate(self.module_status):
464 for i in range(1,65): #(62,65)
383 message += ''.join([fromBinary2Char(beam.module_6bits(i)) for beam in beams])
465 #--------------JUEVES-------------
384 status = ['0'] * 64
466 if beams_status[str(i)] != 0:
385 n = 0
467 try:
386
468 answer = self.module_conf(i,beams)
387 sock = self.send_multicast(message)
469 if answer:
470 if answer['status']:
471 beams_status[str(i)] = 3
472 print answer
473
474 except:
475 beams_status[str(i)] = 1
476
477 pass
478 else:
479 disconnected_modules += 1
480
388
389 for i in range(64):
390 try:
391 data, address = sock.recvfrom(1024)
392 if data == '1':
393 status[int(address[0][10:])-1] = '3'
394 elif data == '0':
395 status[int(address[0][10:])-1] = '1'
396 except:
397 n += 1
398 sock.close()
481 else:
399 else:
482 self.message = "ABS Configuration does not have beams"
400 self.message = "ABS Configuration does not have beams"
483 return False
401 return False
484
402
485 #self.device.status = 1
403 if n == 64:
486 ##
487 #-------------Jueves-------------
488 if disconnected_modules == 64:
489 self.message = "Could not write ABS Modules"
404 self.message = "Could not write ABS Modules"
490 self.device.status = 0
405 self.device.status = 0
406 self.module_status = ''.join(status)
407 self.save()
491 return False
408 return False
492 else:
409 else:
493 self.message = "ABS Beams List have been sent to ABS Modules"
410 self.message = "ABS Beams List have been sent to ABS Modules"
494 beams[0].set_as_activebeam()
411 beams[0].set_as_activebeam()
495
412
496 self.device.status = 3
413 self.device.status = 3
497 self.module_status = json.dumps(beams_status)
414 self.module_status = ''.join(status)
498
499
500
501 self.save()
415 self.save()
502 return True
416 return True
503
417
504
418
505
506
507 def read_module(self, module):
419 def read_module(self, module):
508
420
509 """
421 """
510 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
511 """
423 """
512
424
513 ip_address = self.device.ip_address
425 ip_address = self.device.ip_address
514 ip_address = ip_address.split('.')
426 ip_address = ip_address.split('.')
515 module_seq = (ip_address[0],ip_address[1],ip_address[2])
427 module_seq = (ip_address[0],ip_address[1],ip_address[2])
516 dot = '.'
428 dot = '.'
517 module_ip = dot.join(module_seq)+'.'+str(module)
429 module_ip = dot.join(module_seq)+'.'+str(module)
518 module_port = self.device.port_address
430 module_port = self.device.port_address
519 read_route = 'http://'+module_ip+':'+str(module_port)+'/read'
431 read_route = 'http://'+module_ip+':'+str(module_port)+'/read'
520
432
521 module_status = json.loads(self.module_status)
433 module_status = json.loads(self.module_status)
522 print(read_route)
434 print(read_route)
523
435
524 module_bits = ''
436 module_bits = ''
525
437
526 try:
438 try:
527 r_read = requests.get(read_route, timeout=0.5)
439 r_read = requests.get(read_route, timeout=0.5)
528 answer = r_read.json()
440 answer = r_read.json()
529 module_bits = answer['allbits']
441 module_bits = answer['allbits']
530 except:
442 except:
531 return {}
443 return {}
532
444
533 return module_bits
445 return module_bits
534
446
535 def read_device(self):
447 def read_device(self):
536
448
537 parms = {}
449 parms = {}
538 # Reads active modules.
450 # Reads active modules.
539 module_status = json.loads(self.module_status)
451 module_status = json.loads(self.module_status)
540 total = 0
452 total = 0
541 for status in module_status:
453 for status in module_status:
542 if module_status[status] != 0:
454 if module_status[status] != 0:
543 module_bits = self.read_module(int(status))
455 module_bits = self.read_module(int(status))
544 bits={}
456 bits={}
545 if module_bits:
457 if module_bits:
546 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']) +
547 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']) )
548 parms[str(status)] = bits
460 parms[str(status)] = bits
549
461
550 total +=1
462 total +=1
551
463
552 if total==0:
464 if total==0:
553 self.message = "No ABS Module detected. Please select 'Status'."
465 self.message = "No ABS Module detected. Please select 'Status'."
554 return False
466 return False
555
467
556
468
557
469
558 self.message = "ABS Modules have been read"
470 self.message = "ABS Modules have been read"
559 #monitoreo_tx = JROABSClnt_01CeCnMod000000MNTR10
471 #monitoreo_tx = JROABSClnt_01CeCnMod000000MNTR10
560 return parms
472 return parms
561
473
562
474
563 def absmodule_status(self):
564 """
565 This function gets the status of each abs module. It sends GET method to Web Application
566 in Python Bottle.
567 This function updates "module_status" field from ABSconfiguration.
568 """
569 ip_address = self.device.ip_address
570 ip_address = ip_address.split('.')
571 module_seq = (ip_address[0],ip_address[1],ip_address[2])
572 dot = '.'
573 module_port = self.device.port_address
574
575 modules_status = json.loads(self.module_status)
576 module_messages = json.loads(self.module_messages)
577
578 for i in range(1,65):
579 module_ip = dot.join(module_seq)+'.'+str(i)
580 print module_ip
581
582 route = 'http://'+module_ip+':'+str(module_port)+'/status'
583
584 try:
585 r = requests.get(route, timeout=0.8)#, timeout=0.7)
586 answer = r.json()
587 modules_status[str(i)] = answer['status']
588 module_messages[str(i)] = answer['message']
589 except:
590 modules_status[str(i)] = 0
591 pass
592
593
594 self.module_status = json.dumps(modules_status)
595 self.module_messages = json.dumps(module_messages)
596 self.save()
597
598 print 'Termino (='
599
600 return
601
602
603 def connected_modules(self):
475 def connected_modules(self):
604 """
476 """
605 This function returns the number of connected abs-modules without updating.
477 This function returns the number of connected abs-modules without updating.
606 """
478 """
607 modules_status = json.loads(self.module_status)
608 num = 0
479 num = 0
609 for status in modules_status:
480 print(self.module_status)
610 if modules_status[status] != 0:
481 for i, status in enumerate(self.module_status):
482 if status != '0':
611 num += 1
483 num += 1
612
484 print('status {}:{}'.format(i+1, status))
613 return num
485 return num
614
486
487 def send_multicast(self, message):
488
489 multicast_group = ('224.3.29.71', 10000)
490 # Create the datagram socket
491 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
492 sock.settimeout(0.01)
493 local_ip = "0.0.0.0"
494 sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_IF, socket.inet_aton(local_ip))
495 sent = sock.sendto(message, multicast_group)
496 print('Sending ' + message)
497 return sock
615
498
616 def status_device(self):
499 def status_device(self):
617 """
500 """
618 This function returns the status of all abs-modules as one.
501 This function returns the status of all abs-modules as one.
619 If at least one module is connected, its answer is "1"
502 If at least one module is connected, its answer is "1"
620 """
503 """
621 #self.absmodule_status()
504
622 send_task('status_absdevice', [self.id],)
505 sock = self.send_multicast('MNTR')
623 connected_modules = self.connected_modules()
506
624 if connected_modules>0:
507 n = 0
508 status = ['0'] * 64
509 for i in range(64):
510 try:
511 data, address = sock.recvfrom(1024)
512 if data == '1':
513 status[int(address[0][10:])-1] = '3'
514 elif data == '0':
515 status[int(address[0][10:])-1] = '1'
516 n += 1
517 print('Module: {} connected'.format(address))
518 except:
519 pass
520 sock.close()
521
522 if n > 0:
625 self.message = 'ABS modules Status have been updated.'
523 self.message = 'ABS modules Status have been updated.'
626 return 1
524 self.device.status = 1
627 else:
525 else:
628 self.device.status=0
526 self.device.status = 0
629
527 self.message = 'No ABS module is connected.'
630 self.message = 'No ABS module is connected.'
528 self.module_status = ''.join(status)
631 self.save()
529 self.save()
632 return 0
633
634
635
636 def write_module(self, module):
637
638 """
639 Send configuration to one abs module
640 """
641
642 parameters = {}
643 ip_address = self.device.ip_address
644 ip_address = ip_address.split('.')
645 module_seq = (ip_address[0],ip_address[1],ip_address[2])
646 dot = '.'
647 module_ip = dot.join(module_seq)+'.'+str(module)
648 module_port = self.device.port_address
649 write_route = 'http://'+module_ip+':'+str(module_port)+'/write'
650
651 #print write_route
652
653 #header = 'JROABSCeCnModCnMod01000108SNDFexperimento1.ab1'
654 #module = 'ABS_'+str(module)
655 beams = '!`*3<ENW'#{1: '001000', 2: '010001', 3: '010010', 4: '000011', 5: '101100', 6: '101101',
656 # 7: '110110', 8: '111111', 9: '000000', 10: '001001', 11: '010010', 12: '011011'}
657
658 #parameters['header'] = header
659 parameters['module'] = module
660 parameters['beams'] = json.dumps(beams)
661
662 answer = ''
663
664 try:
665 r_write = requests.post(write_route, parameters, timeout=0.5)
666 answer = r_write.json()
667 self.message = answer['message']
668 except:
669 self.message = "Could not write ABS parameters"
670 return 0
671
530
531 return self.device.status
672
532
673 #self.device.status = int(answer['status'])
674
533
675 return 1
534 def send_beam(self, beam_pos):
676
677
678 def write_module_socket(self, module):
679 """
680 This function sends beams list to one abs-module to TCP_Control_Module using sockets
681 """
682
683 ip_address = self.device.ip_address
684 ip_address = ip_address.split('.')
685 module_seq = (ip_address[0],ip_address[1],ip_address[2])
686 dot = '.'
687 module_ip = dot.join(module_seq)+'.'+str(module)
688 module_port = self.device.port_address
689
690 header = 'JROABSCeCnModCnMod01000108SNDFexperimento1.ab1'
691 abs_module = 'ABS_'+str(module)
692
693 beams = self.get_beams()
694 beams_text = ''
695 for beam in beams:
696 modules_conf=json.loads(beam.modules_conf)
697 beams_text = beams_text + modules_conf[str(module)] + '\n'
698
699 message_tx = header + '\n' + abs_module + '\n' + beams_text + '0'
700 print "Send: ", message_tx
701
702 # Create the datagram socket
703 module_address = (module_ip, 5500)
704 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
705 try:
706 sock.connect(module_address)
707 sock.send(message_tx)
708 t = sock.recv(1024)
709 print 'Respuesta: \n',t
710
711 except Exception as e:
712 print str(e)
713 sock.close()
714 sock = None
715 return False
716
717 sock.close()
718 sock = None
719
720 return True
721
722 def write_device_socket(self):
723 """
724 This function sends beams list to every connected abs-module to TCP_Control_Module using sockets
725 """
726 module_mode = json.loads(self.module_mode)
727 module_status = json.loads(self.module_status)
728
729 for i in range(1,65):
730 if module_mode[str(i)] == 0 and module_status[str(i)] == 1: # 0: Sockets + Cserver & 1: Connected
731 try:
732 self.write_module_socket(i)
733 except Exception as e:
734 print 'Error ABS '+str(i)+': '+str(e)
735
736 return True
737
738
739 def beam_selector(self, module, beam_pos):
740 """
741 This function selects the beam number for one absmodule.
742 """
743
744 if beam_pos > 0:
745 beam_pos = beam_pos - 1
746 else:
747 beam_pos = 0
748
749 #El indice del apunte debe ser menor que el numero total de apuntes
750 #El servidor tcp en el embebido comienza a contar desde 0
751 beams_list = ABSBeam.objects.filter(abs_conf=self)
752 if len(beams_list) < beam_pos:
753 return 0
754
755 flag = 1
756 if beam_pos>9:
757 flag = 2
758
759 module_address = ('192.168.1.'+str(module), 5500)
760 header = 'JROABSCeCnModCnMod0100000'
761 numbers = len(str(beam_pos))
762 function = 'CHGB'
763
764 message_tx = header+str(numbers)+function+str(beam_pos)+'0'
765
766 # Create the datagram socket
767 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
768 #sock.connect(module_address)
769 try:
770 sock.connect(module_address)
771 sock.send(message_tx)
772 sock.close()
773 print("Writing abs module:"+module_address[0]+"...")
774 except:
775 sock = None
776 print("Problem writing abs module:"+module_address[0])
777 return 0
778
779 return 1
780
781
782 def change_beam(self, beam_pos):
783 """
784 This function selects the beam number for all absmodules.
785 """
786 for i in range(1,65):
787 try:
788 self.beam_selector(i,beam_pos)
789 except:
790 print("Problem with module: 192.168.1."+str(i))
791 self.message = "Problem with module: 192.168.1."+str(i)
792 #return 0
793 return 1
794
795
796 def send_beam_num(self, beam_pos):
797 """
535 """
798 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
799 to all abs modules.
537 to all abs modules.
800 """
538 """
801
539
802 # Se manda a cero RC para poder realizar cambio de beam
540 # Se manda a cero RC para poder realizar cambio de beam
803 confs = Configuration.objects.filter(experiment = self.experiment).filter(type=0)
541 confs = Configuration.objects.filter(experiment = self.experiment).filter(type=0)
804 confdds = ''
542 confdds = ''
805 confjars = ''
543 confjars = ''
806 confrc = ''
544 confrc = ''
807
545
808 #TO STOP DEVICES: DDS-JARS-RC
546 #TO STOP DEVICES: DDS-JARS-RC
809 for i in range(0,len(confs)):
547 for i in range(0,len(confs)):
810 if i==0:
548 if i==0:
811 for conf in confs:
549 for conf in confs:
812 if conf.device.device_type.name == 'dds':
550 if conf.device.device_type.name == 'dds':
813 confdds = conf
551 confdds = conf
814 confdds.stop_device()
552 confdds.stop_device()
815 break
553 break
816 if i==1:
554 if i==1:
817 for conf in confs:
555 for conf in confs:
818 if conf.device.device_type.name == 'jars':
556 if conf.device.device_type.name == 'jars':
819 confjars = conf
557 confjars = conf
820 confjars.stop_device()
558 confjars.stop_device()
821 break
559 break
822 if i==2:
560 if i==2:
823 for conf in confs:
561 for conf in confs:
824 if conf.device.device_type.name == 'rc':
562 if conf.device.device_type.name == 'rc':
825 confrc = conf
563 confrc = conf
826 confrc.stop_device()
564 confrc.stop_device()
827 break
565 break
828
566
829 if beam_pos > 0:
567 if beam_pos > 0:
830 beam_pos = beam_pos - 1
568 beam_pos = beam_pos - 1
831 else:
569 else:
832 beam_pos = 0
570 beam_pos = 0
833
571
834 #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
835 #El servidor tcp en el embebido comienza a contar desde 0
573 #El servidor tcp en el embebido comienza a contar desde 0
836 beams_list = ABSBeam.objects.filter(abs_conf=self)
574 status = ['0'] * 64
837 if len(beams_list) < beam_pos:
575 message = 'CHGB{}'.format(beam_pos)
838 return 0
576 sock = self.send_multicast(message)
839
840 flag = 1
841 if beam_pos>9:
842 flag = 2
843
844 header = 'JROABSCeCnModCnMod0100000'
845 flag = str(flag)
846 function = 'CHGB'
847 message_tx = header+flag+function+str(beam_pos)+'0'
848 print message_tx
849 multicast_group = '224.3.29.71'
850 server_address = ('',10000)
851 #Specific Netwrok Interface
852 local_ip='192.168.1.153'
853 # Create the socket
854 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
855 # Bind to the server address
856 sock.bind(server_address)
857 # Telling the OS add the socket to the multicast on all interfaces
858 group = socket.inet_aton(multicast_group)
859 mreq = struct.pack('4sL', group, 1) #socket.INADDR_ANY
860
577
861 try:
578 for i in range(64):
862 #sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)
579 try:
863 sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_IF, socket.inet_aton(local_ip)) #Specific Netwrok Interface
580 data, address = sock.recvfrom(1024)
864 except Exception as e:
581 print address, data
865 self.message = str(e)
582 if data == '1':
866 print str(e)
583 status[int(address[0][10:])-1] = '3'
867 sock.close()
584 elif data == '0':
868 sock = None
585 status[int(address[0][10:])-1] = '1'
869 return False
586 except:
587 pass
870
588
871 #print 'sending acknowledgement to all: \n' + message_tx
872 try:
873 sock.sendto(message_tx, (multicast_group, 10000))
874 except Exception as e:
875 self.message = str(e)
876 print str(e)
877 sock.close()
878 sock = None
879 return False
880 sock.close()
589 sock.close()
881 sock = None
882
590
883 #Start DDS-RC-JARS
591 #Start DDS-RC-JARS
884 if confdds:
592 if confdds:
885 confdds.start_device()
593 confdds.start_device()
886 if confrc:
594 if confrc:
887 #print confrc
595 #print confrc
888 confrc.start_device()
596 confrc.start_device()
889 if confjars:
597 if confjars:
890 confjars.start_device()
598 confjars.start_device()
891
599
892 self.message = "ABS Beam has been changed"
600 self.message = "ABS Beam has been changed"
893 print self.message
601 self.module_status = ''.join(status)
894
602 self.save()
895 return True
603 return True
896
604
897 def test1(self):
898 t1 = time.time()
899 t2 = 0
900 while (t2-t1)<100:#300
901 t2 = time.time()
902 self.send_beam_num(2)
903 time.sleep(0.04)
904 self.send_beam_num(1)
905 time.sleep(0.04)
906 return
907
908 def change_procs_test1(self, module):
909
910 for i in range (1,300):#300
911 beam_pos = 1
912 module_address = ('192.168.1.'+str(module), 5500)
913 header = 'JROABSCeCnModCnMod0100000'
914 numbers = len(str(beam_pos))
915 function = 'CHGB'
916
917 message_tx = header+str(numbers)+function+str(beam_pos)+'0'
918
919 # Create the datagram socket
920 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
921 sock.connect(module_address)
922
923 sock.send(message_tx)
924 #t = sock.recv(1024)
925 sock.close()
926 sock = None
927
928
929 time.sleep(0.04)
930
931
932 beam_pos = 0
933 numbers = len(str(beam_pos))
934
935 message_tx = header+str(numbers)+function+str(beam_pos)+'0'
936
937 # Create the datagram socket
938 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
939 sock.connect(module_address)
940 sock.send(message_tx)
941 sock.close()
942 sock = None
943
944 time.sleep(0.04)
945
946
947 def multi_procs_test1(self):
948
949 """
950 This function sends the beam number to all abs modules using multiprocessing.
951 """
952
953 #if __name__ == "__main__":
954 size = 10000000 # Number of random numbers to add
955 procs = 65 # (Number-1) of processes to create (absmodule)
956
957 # Create a list of jobs and then iterate through
958 # the number of processes appending each process to
959 # the job list
960 jobs = []
961 for i in range(1, procs):
962
963 process = multiprocessing.Process(target=self.change_procs_test1,args=(i,))
964 jobs.append(process)
965 #print jobs
966
967 # Start the processes (i.e. calculate the random number lists)
968 for j in jobs:
969 #time.sleep(0.4)
970 #print j
971 j.start()
972
973 # Ensure all of the processes have finished
974 for j in jobs:
975 j.join()
976
977 print("List processing complete.")
978 return 1
979
980
981
982 def multi_procs_test2(self):
983 """
984 This function use multiprocessing python library. Importing Pool we can select
985 the number of cores we want to use
986 After 'nproc' linux command, we know how many cores computer has.
987 NOT WORKING
988 """
989 import multiprocessing
990 pool = multiprocessing.Pool(3) # cores
991
992 tasks = []
993 procs = 65
994 for i in range(62, procs):
995 tasks.append( (i,))
996 #print tasks
997 #pool.apply_async(self.change_procs_test1, 62)
998 results = [pool.apply( self.change_procs_test1, t ) for t in tasks]
999 #for result in results:
1000 #result.get()
1001 #(plotNum, plotFilename) = result.get()
1002 #print("Result: plot %d written to %s" % (plotNum, plotFilename) )
1003
1004 return 1
1005
1006
1007 def multi_procs_test3(self):
1008 """
1009 This function use multiprocessing python library. Importing Pool we can select
1010 the number of cores we want to use
1011 After 'nproc' linux command, we know how many cores computer has.
1012 """
1013 from multiprocessing import Pool
1014 import time
1015
1016 def f(x):
1017 return x*x
1018
1019 tasks = []
1020 procs = 65
1021 pool = Pool(processes=4)
1022
1023 #for i in range(62, procs):
1024 #result = pool.map(f, range(62,65))
1025 it = pool.imap(self.change_procs_test1, range(62,65))
1026 #result.get(timeout=5)
1027
1028 return 1
1029
1030
1031 def multi_procs_test4(self):
1032 import multiprocessing as mp
1033
1034
1035 num_workers = mp.cpu_count()
1036
1037 pool = mp.Pool(num_workers)
1038 procs = 65
1039 for i in range(62, procs):
1040 #for task in tasks:
1041 pool.apply_async(self.f, args = (i,))
1042
1043 pool.close()
1044 pool.join()
1045
1046 return 1
1047
1048
605
1049 def get_absolute_url_import(self):
606 def get_absolute_url_import(self):
1050 return reverse('url_import_abs_conf', args=[str(self.id)])
607 return reverse('url_import_abs_conf', args=[str(self.id)])
1051
608
1052
609
1053 def get_absolute_url_status(self):
1054 return reverse('url_status_abs_conf', args=[str(self.id)])
1055
1056
1057
1058 class ABSBeam(models.Model):
610 class ABSBeam(models.Model):
1059
611
1060 name = models.CharField(max_length=60, default='Beam')
612 name = models.CharField(max_length=60, default='Beam')
1061 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)
1062 abs_conf = models.ForeignKey(ABSConfiguration, null=True, verbose_name='ABS Configuration')
614 abs_conf = models.ForeignKey(ABSConfiguration, null=True, verbose_name='ABS Configuration')
1063 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)
1064 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)
1065 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')
1066 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')
1067 modules_conf = models.CharField(verbose_name='Modules', max_length=2000, default=json.dumps(conf_default))
1068 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)
1069 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)
1070
621
1071 class Meta:
622 class Meta:
1072 db_table = 'abs_beams'
623 db_table = 'abs_beams'
1073
624
1074 def __unicode__(self):
625 def __unicode__(self):
1075 return u'%s' % (self.name)
626 return u'%s' % (self.name)
1076
627
1077 def parms_to_dict(self):
628 def parms_to_dict(self):
1078
629
1079 #Update data
1080 self.modules_6bits()
1081
1082 parameters = {}
630 parameters = {}
1083
1084 parameters['name'] = self.name
631 parameters['name'] = self.name
1085 parameters['antenna'] = ast.literal_eval(self.antenna)
632 parameters['antenna'] = ast.literal_eval(self.antenna)
1086 parameters['abs_conf'] = self.abs_conf.name
633 parameters['abs_conf'] = self.abs_conf.name
1087 parameters['tx'] = ast.literal_eval(self.tx)
634 parameters['tx'] = ast.literal_eval(self.tx)
1088 parameters['rx'] = ast.literal_eval(self.rx)
635 parameters['rx'] = ast.literal_eval(self.rx)
1089 parameters['s_time'] = self.s_time.strftime("%H:%M:%S")
636 parameters['s_time'] = self.s_time.strftime("%H:%M:%S")
1090 parameters['e_time'] = self.e_time.strftime("%H:%M:%S")
637 parameters['e_time'] = self.e_time.strftime("%H:%M:%S")
1091 parameters['configuration'] = ast.literal_eval(self.modules_conf)
1092 parameters['ues'] = ast.literal_eval(self.ues)
638 parameters['ues'] = ast.literal_eval(self.ues)
1093 parameters['only_rx'] = json.loads(self.only_rx)
639 parameters['only_rx'] = json.loads(self.only_rx)
1094
640
1095 return parameters
641 return parameters
1096
642
1097 def dict_to_parms(self, parameters):
643 def dict_to_parms(self, parameters):
1098
644
1099 self.name = parameters['name']
645 self.name = parameters['name']
1100 self.antenna = json.dumps(parameters['antenna'])
646 self.antenna = json.dumps(parameters['antenna'])
1101 #self.abs_conf = parameters['abs_conf']
647 #self.abs_conf = parameters['abs_conf']
1102 self.tx = json.dumps(parameters['tx'])
648 self.tx = json.dumps(parameters['tx'])
1103 self.rx = json.dumps(parameters['rx'])
649 self.rx = json.dumps(parameters['rx'])
1104 #self.s_time = parameters['s_time']
650 #self.s_time = parameters['s_time']
1105 #self.e_time = parameters['e_time']
651 #self.e_time = parameters['e_time']
1106 self.ues = json.dumps(parameters['ues'])
652 self.ues = json.dumps(parameters['ues'])
1107 self.only_rx = json.dumps(parameters['only_rx'])
653 self.only_rx = json.dumps(parameters['only_rx'])
1108
1109 self.modules_6bits()
1110 self.save()
654 self.save()
1111
655
1112
656
1113 def clone(self, **kwargs):
657 def clone(self, **kwargs):
1114
658
1115 self.pk = None
659 self.pk = None
1116 self.id = None
660 self.id = None
1117 for attr, value in kwargs.items():
661 for attr, value in kwargs.items():
1118 setattr(self, attr, value)
662 setattr(self, attr, value)
1119
663
1120 self.save()
664 self.save()
1121
665
1122 return self
666 return self
1123
667
1124
668
1125
1126 def module_6bits(self, module):
669 def module_6bits(self, module):
1127 """
670 """
1128 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
1129 """
672 """
1130 if module > 64:
673 if module > 64:
1131 beam_bits = ""
674 beam_bits = ""
1132 return beam_bits
675 return beam_bits
1133
676
1134 data = ast.literal_eval(self.antenna)
677 data = ast.literal_eval(self.antenna)
1135 up_data = data['antenna_up']
678 up_data = data['antenna_up']
1136 down_data = data['antenna_down']
679 down_data = data['antenna_down']
1137
680
1138 pos = ip2position(module)
681 pos = ip2position(module)
1139 up_value = up_data[pos[0]][pos[1]]
682 up_value = up_data[pos[0]][pos[1]]
1140 down_value = down_data[pos[0]][pos[1]]
683 down_value = down_data[pos[0]][pos[1]]
1141
684
1142 up_bits = up_conv_bits(up_value)
685 up_bits = up_conv_bits(up_value)
1143 down_bits = down_conv_bits(down_value)
686 down_bits = down_conv_bits(down_value)
1144 beam_bits = up_bits+down_bits
687 beam_bits = up_bits+down_bits
1145
688
1146 return beam_bits
689 return beam_bits
1147
690
1148 def modules_6bits(self):
1149 """
1150 This function returns 6bits from every abs module (1-64) in a dict
1151 """
1152 modules_configuration = ast.literal_eval(self.modules_conf)
1153
1154 for i in range(1,65):
1155 modules_configuration[str(i)] = self.module_6bits(i)
1156
1157 self.modules_conf = json.dumps(modules_configuration)
1158 self.save()
1159
1160 return self.modules_conf
1161
1162
1163 def set_as_activebeam(self):
1164 """
1165 This function set this beam as the active beam of its ABS Configuration.
1166 """
1167 self.abs_conf.active_beam = json.dumps({'active_beam': self.id})
1168 self.abs_conf.save()
1169
1170 return
1171
1172
691
1173 @property
692 @property
1174 def get_upvalues(self):
693 def get_upvalues(self):
1175 """
694 """
1176 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
1177 """
696 """
1178
697
1179 data = ast.literal_eval(self.antenna)
698 data = ast.literal_eval(self.antenna)
1180 up_data = data['antenna_up']
699 up_data = data['antenna_up']
1181
700
1182 up_values = []
701 up_values = []
1183 for data in up_data:
702 for data in up_data:
1184 for i in range(0,8):
703 for i in range(0,8):
1185 up_values.append(data[i])
704 up_values.append(data[i])
1186
705
1187 return up_values
706 return up_values
1188
707
1189 @property
708 @property
1190 def antenna_upvalues(self):
709 def antenna_upvalues(self):
1191 """
710 """
1192 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
1193 in a particular order
712 in a particular order
1194 """
713 """
1195 data = ast.literal_eval(self.antenna)
714 data = ast.literal_eval(self.antenna)
1196 up_data = data['antenna_up']
715 up_data = data['antenna_up']
1197
716
1198 return up_data
717 return up_data
1199
718
1200 @property
719 @property
1201 def antenna_downvalues(self):
720 def antenna_downvalues(self):
1202 """
721 """
1203 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
1204 in a particular order
723 in a particular order
1205 """
724 """
1206 data = ast.literal_eval(self.antenna)
725 data = ast.literal_eval(self.antenna)
1207 down_data = data['antenna_down']
726 down_data = data['antenna_down']
1208
727
1209 return down_data
728 return down_data
1210
729
1211 @property
730 @property
1212 def get_downvalues(self):
731 def get_downvalues(self):
1213 """
732 """
1214 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
1215 """
734 """
1216
735
1217 data = ast.literal_eval(self.antenna)
736 data = ast.literal_eval(self.antenna)
1218 down_data = data['antenna_down']
737 down_data = data['antenna_down']
1219
738
1220 down_values = []
739 down_values = []
1221 for data in down_data:
740 for data in down_data:
1222 for i in range(0,8):
741 for i in range(0,8):
1223 down_values.append(data[i])
742 down_values.append(data[i])
1224
743
1225 return down_values
744 return down_values
1226
745
1227 @property
746 @property
1228 def get_up_ues(self):
747 def get_up_ues(self):
1229 """
748 """
1230 This function shows the up-ues-value of one beam
749 This function shows the up-ues-value of one beam
1231 """
750 """
1232 data = ast.literal_eval(self.ues)
751 data = ast.literal_eval(self.ues)
1233 up_ues = data['up']
752 up_ues = data['up']
1234
753
1235 return up_ues
754 return up_ues
1236
755
1237 @property
756 @property
1238 def get_down_ues(self):
757 def get_down_ues(self):
1239 """
758 """
1240 This function shows the down-ues-value of one beam
759 This function shows the down-ues-value of one beam
1241 """
760 """
1242 data = ast.literal_eval(self.ues)
761 data = ast.literal_eval(self.ues)
1243 down_ues = data['down']
762 down_ues = data['down']
1244
763
1245 return down_ues
764 return down_ues
1246
765
1247 @property
766 @property
1248 def get_up_onlyrx(self):
767 def get_up_onlyrx(self):
1249 """
768 """
1250 This function shows the up-onlyrx-value of one beam
769 This function shows the up-onlyrx-value of one beam
1251 """
770 """
1252 data = json.loads(self.only_rx)
771 data = json.loads(self.only_rx)
1253 up_onlyrx = data['up']
772 up_onlyrx = data['up']
1254
773
1255 return up_onlyrx
774 return up_onlyrx
1256
775
1257 @property
776 @property
1258 def get_down_onlyrx(self):
777 def get_down_onlyrx(self):
1259 """
778 """
1260 This function shows the down-onlyrx-value of one beam
779 This function shows the down-onlyrx-value of one beam
1261 """
780 """
1262 data = json.loads(self.only_rx)
781 data = json.loads(self.only_rx)
1263 down_onlyrx = data['down']
782 down_onlyrx = data['down']
1264
783
1265 return down_onlyrx
784 return down_onlyrx
1266
785
1267 @property
786 @property
1268 def get_tx(self):
787 def get_tx(self):
1269 """
788 """
1270 This function shows the tx-values of one beam
789 This function shows the tx-values of one beam
1271 """
790 """
1272 data = json.loads(self.tx)
791 data = json.loads(self.tx)
1273
792
1274 return data
793 return data
1275
794
1276 @property
795 @property
1277 def get_uptx(self):
796 def get_uptx(self):
1278 """
797 """
1279 This function shows the up-tx-values of one beam
798 This function shows the up-tx-values of one beam
1280 """
799 """
1281 data = json.loads(self.tx)
800 data = json.loads(self.tx)
1282 up_data = data['up']
801 up_data = data['up']
1283
802
1284 up_values = []
803 up_values = []
1285 for data in up_data:
804 for data in up_data:
1286 for i in range(0,8):
805 for i in range(0,8):
1287 up_values.append(data[i])
806 up_values.append(data[i])
1288
807
1289 return up_values
808 return up_values
1290
809
1291 @property
810 @property
1292 def get_downtx(self):
811 def get_downtx(self):
1293 """
812 """
1294 This function shows the down-tx-values of one beam
813 This function shows the down-tx-values of one beam
1295 """
814 """
1296 data = json.loads(self.tx)
815 data = json.loads(self.tx)
1297 down_data = data['down']
816 down_data = data['down']
1298
817
1299 down_values = []
818 down_values = []
1300 for data in down_data:
819 for data in down_data:
1301 for i in range(0,8):
820 for i in range(0,8):
1302 down_values.append(data[i])
821 down_values.append(data[i])
1303
822
1304 return down_values
823 return down_values
1305
824
1306
825
1307
826
1308 @property
827 @property
1309 def get_rx(self):
828 def get_rx(self):
1310 """
829 """
1311 This function shows the rx-values of one beam
830 This function shows the rx-values of one beam
1312 """
831 """
1313 data = json.loads(self.rx)
832 data = json.loads(self.rx)
1314
833
1315 return data
834 return data
1316
835
1317 @property
836 @property
1318 def get_uprx(self):
837 def get_uprx(self):
1319 """
838 """
1320 This function shows the up-rx-values of one beam
839 This function shows the up-rx-values of one beam
1321 """
840 """
1322 data = json.loads(self.rx)
841 data = json.loads(self.rx)
1323 up_data = data['up']
842 up_data = data['up']
1324
843
1325 up_values = []
844 up_values = []
1326 for data in up_data:
845 for data in up_data:
1327 for i in range(0,8):
846 for i in range(0,8):
1328 up_values.append(data[i])
847 up_values.append(data[i])
1329
848
1330 return up_values
849 return up_values
1331
850
1332 @property
851 @property
1333 def get_downrx(self):
852 def get_downrx(self):
1334 """
853 """
1335 This function shows the down-rx-values of one beam
854 This function shows the down-rx-values of one beam
1336 """
855 """
1337 data = json.loads(self.rx)
856 data = json.loads(self.rx)
1338 down_data = data['down']
857 down_data = data['down']
1339
858
1340 down_values = []
859 down_values = []
1341 for data in down_data:
860 for data in down_data:
1342 for i in range(0,8):
861 for i in range(0,8):
1343 down_values.append(data[i])
862 down_values.append(data[i])
1344
863
1345 return down_values
864 return down_values
This diff has been collapsed as it changes many lines, (854 lines changed) Show them Hide them
@@ -1,550 +1,476
1 {% extends "dev_conf.html" %}
1 {% extends "dev_conf.html" %} {% load static %} {% load bootstrap3 %} {% load main_tags %}
2
2 {% block extra-head %}
3 {% load static %}
4 {% load bootstrap3 %}
5 {% load main_tags %}
6
7 {% block extra-menu-actions %}
8 <li><a href="{{ dev_conf.get_absolute_url_plot }}" target="_blank"><span class="glyphicon glyphicon-picture" aria-hidden="true"></span> View Patterns </a></li>
9 {% endblock %}
10
11 {% block extra-content %}
12 <style>
3 <style>
13
4 .abs {
14 .abs {
15 border: 2px solid #00334d;
5 border: 2px solid #00334d;
16 vertical-align: center;
6 vertical-align: center;
17 display: inline-block;
7 display: inline-block;
18 }
8 }
19 .abs tr:nth-child(1){
9
10 .abs tr:nth-child(1) {
20 border-bottom: 1px dashed #00334d;
11 border-bottom: 1px dashed #00334d;
21 }
12 }
22 .abs tr{
13
14 .abs tr {
23 border-bottom: 0px solid #00334d;
15 border-bottom: 0px solid #00334d;
24 }
16 }
25 .abs td {
17
18 .abs td {
26 border-right: 1px dashed #00334d;
19 border-right: 1px dashed #00334d;
27 text-align: center;
20 text-align: center;
28 padding: 5px;
21 padding: 5px;
29 }
22 }
30
23
31
24
32 .legend {
25 .legend {
33 margin-left: 15px;
26 margin-left: 15px;
34 display: inline-block;
27 display: inline-block;
35 border: 2px solid #00334d;
28 border: 2px solid #00334d;
36 vertical-align: top;
29 vertical-align: top;
37 }
30 }
38 .legend th{
31
32 .legend th {
39 border-bottom: 1px dashed #00334d;
33 border-bottom: 1px dashed #00334d;
40 font-weight: bold;
34 font-weight: bold;
41 vertical-align: center;
35 vertical-align: center;
42 text-align: center;
36 text-align: center;
43 }
37 }
44 .legend td {
38
39 .legend td {
45 padding: 2px;
40 padding: 2px;
46 text-align: center;
41 text-align: center;
47 }
42 }
48
43
49
44
50 .north {
45 .north {
51 border: 2px solid #00334d;
46 border: 2px solid #00334d;
52 vertical-align: center;
47 vertical-align: center;
53 font-weight: bold;
48 font-weight: bold;
54 }
49 }
55 .north tr{
50
51 .north tr {
56 border: 1px solid #ffffff;
52 border: 1px solid #ffffff;
57
53
58 }
54 }
59 .north td{
55
56 .north td {
60 border: 2px solid #e2e2e7;
57 border: 2px solid #e2e2e7;
61 text-align: center;
58 text-align: center;
62 padding: 1px 15px 1px 15px;
59 padding: 1px 15px 1px 15px;
63 }
60 }
64 .north tr:nth-child(even) td:nth-child(n){
61
62 .north tr:nth-child(even) td:nth-child(n) {
65 border-bottom: 12px solid #e2e2e7;
63 border-bottom: 12px solid #e2e2e7;
66 }
64 }
67 .north td:nth-child(n) {
65
66 .north td:nth-child(n) {
68 border-right: 12px solid #e2e2e7;
67 border-right: 12px solid #e2e2e7;
69 }
68 }
70 .north td:nth-last-child(4n+1) {
71 border-right: 2px solid #e2e2e7;
72 }
73 .north tr:nth-last-child(1) td:nth-child(n){
74 border-bottom: 3px solid #e2e2e7;
75 }
76
69
70 .north td:nth-last-child(4n+1) {
71 border-right: 2px solid #e2e2e7;
72 }
77
73
74 .north tr:nth-last-child(1) td:nth-child(n) {
75 border-bottom: 3px solid #e2e2e7;
76 }
78
77
79 .east {
78 .east {
80 border: 2px solid #00334d;
79 border: 2px solid #00334d;
81 vertical-align: center;
80 vertical-align: center;
82 font-weight: bold;
81 font-weight: bold;
83 }
82 }
84 .east tr{
83
84 .east tr {
85 border: 1px solid #ffffff;
85 border: 1px solid #ffffff;
86 }
86 }
87 .east td{
87
88 .east td {
88 border: 2px solid #e2e2e7;
89 border: 2px solid #e2e2e7;
89 text-align: center;
90 text-align: center;
90 padding: 1px 15px 1px 15px;
91 padding: 1px 15px 1px 15px;
91 }
92 }
92 .east tr:nth-child(even) td:nth-child(n){
93
94 .east tr:nth-child(even) td:nth-child(n) {
93 border-bottom: 12px solid #e2e2e7;
95 border-bottom: 12px solid #e2e2e7;
94 }
96 }
95 .east td:nth-child(n) {
96 border-right: 12px solid #e2e2e7;
97 }
98 .east td:nth-last-child(4n+1) {
99 border-right: 2px solid #e2e2e7;
100 }
101 .east tr:nth-last-child(1) td:nth-child(n){
102 border-bottom: 3px solid #e2e2e7;
103 }
104
97
98 .east td:nth-child(n) {
99 border-right: 12px solid #e2e2e7;
100 }
105
101
102 .east td:nth-last-child(4n+1) {
103 border-right: 2px solid #e2e2e7;
104 }
106
105
106 .east tr:nth-last-child(1) td:nth-child(n) {
107 border-bottom: 3px solid #e2e2e7;
108 }
107
109
108 .west {
110 .west {
109 border: 2px solid #00334d;
111 border: 2px solid #00334d;
110 vertical-align: center;
112 vertical-align: center;
111 font-weight: bold;
113 font-weight: bold;
112 }
114 }
113 .west tr{
115
116 .west tr {
114 border: 1px solid #ffffff;
117 border: 1px solid #ffffff;
115 }
118 }
116 .west td{
119
120 .west td {
117 border: 2px solid #e2e2e7;
121 border: 2px solid #e2e2e7;
118 text-align: center;
122 text-align: center;
119 padding: 1px 15px 1px 15px;
123 padding: 1px 15px 1px 15px;
120 }
124 }
121 .west tr:nth-child(even) td:nth-child(n){
125
126 .west tr:nth-child(even) td:nth-child(n) {
122 border-bottom: 12px solid #e2e2e7;
127 border-bottom: 12px solid #e2e2e7;
123 }
128 }
124 .west td:nth-child(n) {
125 border-right: 12px solid #e2e2e7;
126 }
127 .west td:nth-last-child(4n+1) {
128 border-right: 2px solid #e2e2e7;
129 }
130 .west tr:nth-last-child(1) td:nth-child(n){
131 border-bottom: 3px solid #e2e2e7;
132 }
133
129
130 .west td:nth-child(n) {
131 border-right: 12px solid #e2e2e7;
132 }
134
133
134 .west td:nth-last-child(4n+1) {
135 border-right: 2px solid #e2e2e7;
136 }
135
137
138 .west tr:nth-last-child(1) td:nth-child(n) {
139 border-bottom: 3px solid #e2e2e7;
140 }
136
141
137 .south {
142 .south {
138 border: 2px solid #00334d;
143 border: 2px solid #00334d;
139 vertical-align: center;
144 vertical-align: center;
140 font-weight: bold;
145 font-weight: bold;
141 }
146 }
142 .south tr{
147
148 .south tr {
143 border: 1px solid #ffffff;
149 border: 1px solid #ffffff;
144 }
150 }
145 .south td{
151
152 .south td {
146 border: 2px solid #e2e2e7;
153 border: 2px solid #e2e2e7;
147 text-align: center;
154 text-align: center;
148 padding: 1px 15px 1px 15px;
155 padding: 1px 15px 1px 15px;
149 }
156 }
150 .south tr:nth-child(even) td:nth-child(n){
151 border-bottom: 12px solid #e2e2e7;
152 }
153 .south td:nth-child(n) {
154 border-right: 12px solid #e2e2e7;
155 }
156 .south td:nth-last-child(4n+1) {
157 border-right: 2px solid #e2e2e7;
158 }
159 .south tr:nth-last-child(1) td:nth-child(n){
160 border-bottom: 3px solid #e2e2e7;
161 }
162
157
158 .south tr:nth-child(even) td:nth-child(n) {
159 border-bottom: 12px solid #e2e2e7;
160 }
163
161
162 .south td:nth-child(n) {
163 border-right: 12px solid #e2e2e7;
164 }
164
165
166 .south td:nth-last-child(4n+1) {
167 border-right: 2px solid #e2e2e7;
168 }
165
169
170 .south tr:nth-last-child(1) td:nth-child(n) {
171 border-bottom: 3px solid #e2e2e7;
172 }
166 </style>
173 </style>
167
174 {% endblock %}
168 {% if status_request %}
175 {% block extra-menu-actions %}
169 <img id="loading" src="{% static 'images/loader.gif' %}">
176 <li>
170 {% endif %}
177 <a href="{{ dev_conf.get_absolute_url_plot }}" target="_blank">
171
178 <span class="glyphicon glyphicon-picture" aria-hidden="true"></span> View Patterns </a>
172
179 </li>
180 {% endblock %}
181 {% block extra-content %}
173 {% if beams %}
182 {% if beams %}
174
183 <h4>Beams:</h4>
175
184 <div class="container">
176
185 <ul class="nav nav-pills">
177 <h4>Beams:</h4>
186 {% for beam in beams %}
178 <div class="container">
187 <li {%if beam.pk == active_beam %} class="active" {% endif %}>
179 <ul class="nav nav-pills">
188 <a data-toggle="pill" href="#menu{{forloop.counter}}">{{forloop.counter}}</a>
180 {% for beam in beams %}
189 </li>
181 <li {% if active_beam.id == beam.id %} class="active" {% endif %} >
190 {% endfor %}
182 <a data-toggle="pill" href="#menu{{forloop.counter}}">{{forloop.counter}}</a>
191 </ul>
183 </li>
192
184 {% endfor %}
193 <div class="tab-content">
185 </ul>
194 {% for beam in beams %}
186
195 <div id="menu{{forloop.counter}}" class="tab-pane fade {%if beam.pk == active_beam %}active in{% endif %}">
187
196 <h3>{%if beam.pk == active_beam %}Active Beam: {%endif%}{{beam.name}}</h3>
188 <div class="tab-content">
197 <table id="abs_pattern{{forloop.counter}}" class="abs">
189 <div id="home" class="tab-pane fade in active">
198 <tr>
190 <!---->
199 <td>
191 {% if active_beam %}
200 <b>North Quarter</b>
192 <h3>Active Beam: {{active_beam.name}}</h3>
201 <table class="north ">
193
202 <tr>
194 <table id="abs_pattern" class="abs">
203 <td {%if beam.pk == active_beam %} {{color_status.1}} t{%endif%} itle='{{module_messages.1}}'>{{beam.get_upvalues.0}}</td>
195 <tr>
204 <td {%if beam.pk == active_beam %} {{color_status.2}} t{%endif%} itle='{{module_messages.2}}'>{{beam.get_upvalues.1}}</td>
196 <td> <b>North Quarter</b>
205 <td {%if beam.pk == active_beam %} {{color_status.3}} t{%endif%} itle='{{module_messages.3}}'>{{beam.get_upvalues.2}}</td>
197 <table class="north ">
206 <td {%if beam.pk == active_beam %} {{color_status.4}} t{%endif%} itle='{{module_messages.4}}'>{{beam.get_upvalues.3}}</td>
198 <tr>
207 </tr>
199 <td {{color_status.1}} title='{{module_messages.1}}'>{{active_beam.get_upvalues.0}}</td> <td {{color_status.2}} title='{{module_messages.2}}'>{{active_beam.get_upvalues.1}}</td> <td {{color_status.3}} title='{{module_messages.3}}'>{{active_beam.get_upvalues.2}}</td> <td {{color_status.4}} title='{{module_messages.4}}'>{{active_beam.get_upvalues.3}}</td>
208 <tr>
200 </tr>
209 <td {%if beam.pk == active_beam %} {{color_status.1}} t{%endif%} itle='{{module_messages.1}}'>{{beam.get_downvalues.0}}</td>
201 <tr>
210 <td {%if beam.pk == active_beam %} {{color_status.2}} t{%endif%} itle='{{module_messages.2}}'>{{beam.get_downvalues.1}}</td>
202 <td {{color_status.1}} title='{{module_messages.1}}'>{{active_beam.get_downvalues.0}}</td> <td {{color_status.2}} title='{{module_messages.2}}'>{{active_beam.get_downvalues.1}}</td> <td {{color_status.3}} title='{{module_messages.3}}'>{{active_beam.get_downvalues.2}}</td> <td {{color_status.4}} title='{{module_messages.4}}'>{{active_beam.get_downvalues.3}}</td>
211 <td {%if beam.pk == active_beam %} {{color_status.3}} t{%endif%} itle='{{module_messages.3}}'>{{beam.get_downvalues.2}}</td>
203 </tr>
212 <td {%if beam.pk == active_beam %} {{color_status.4}} t{%endif%} itle='{{module_messages.4}}'>{{beam.get_downvalues.3}}</td>
204 <tr>
213 </tr>
205 <td {{color_status.9}} title='{{module_messages.9}}'>{{active_beam.get_upvalues.8}}</td> <td {{color_status.10}} title='{{module_messages.10}}'>{{active_beam.get_upvalues.9}}</td> <td {{color_status.11}} title='{{module_messages.11}}'>{{active_beam.get_upvalues.10}}</td> <td {{color_status.12}} title='{{module_messages.12}}'>{{active_beam.get_upvalues.11}}</td>
214 <tr>
206 </tr>
215 <td {%if beam.pk == active_beam %} {{color_status.9}} t{%endif%} itle='{{module_messages.9}}'>{{beam.get_upvalues.8}}</td>
207 <tr>
216 <td {%if beam.pk == active_beam %} {{color_status.10}} {%endif%} title='{{module_messages.10}}'>{{beam.get_upvalues.9}}</td>
208 <td {{color_status.9}} title='{{module_messages.9}}'>{{active_beam.get_downvalues.8}}</td> <td {{color_status.10}} title='{{module_messages.10}}'>{{active_beam.get_downvalues.9}}</td> <td {{color_status.11}} title='{{module_messages.11}}'>{{active_beam.get_downvalues.10}}</td> <td {{color_status.12}} title='{{module_messages.12}}'>{{active_beam.get_downvalues.11}}</td>
217 <td {%if beam.pk == active_beam %} {{color_status.11}} {%endif%} title='{{module_messages.11}}'>{{beam.get_upvalues.10}}</td>
209 </tr>
218 <td {%if beam.pk == active_beam %} {{color_status.12}} {%endif%} title='{{module_messages.12}}'>{{beam.get_upvalues.11}}</td>
210 <tr>
219 </tr>
211 <td {{color_status.17}} title='{{module_messages.17}}'>{{active_beam.get_upvalues.16}}</td> <td {{color_status.18}} title='{{module_messages.18}}'>{{active_beam.get_upvalues.17}}</td> <td {{color_status.19}} title='{{module_messages.19}}'>{{active_beam.get_upvalues.18}}</td> <td {{color_status.20}} title='{{module_messages.20}}'>{{active_beam.get_upvalues.19}}</td>
220 <tr>
212 </tr>
221 <td {%if beam.pk == active_beam %} {{color_status.9}} t{%endif%} itle='{{module_messages.9}}'>{{beam.get_downvalues.8}}</td>
213 <tr>
222 <td {%if beam.pk == active_beam %} {{color_status.10}} {%endif%} title='{{module_messages.10}}'>{{beam.get_downvalues.9}}</td>
214 <td {{color_status.17}} title='{{module_messages.17}}'>{{active_beam.get_downvalues.16}}</td> <td {{color_status.18}} title='{{module_messages.18}}'>{{active_beam.get_downvalues.17}}</td> <td {{color_status.19}} title='{{module_messages.19}}'>{{active_beam.get_downvalues.18}}</td> <td {{color_status.20}} title='{{module_messages.20}}'>{{active_beam.get_downvalues.19}}</td>
223 <td {%if beam.pk == active_beam %} {{color_status.11}} {%endif%} title='{{module_messages.11}}'>{{beam.get_downvalues.10}}</td>
215 </tr>
224 <td {%if beam.pk == active_beam %} {{color_status.12}} {%endif%} title='{{module_messages.12}}'>{{beam.get_downvalues.11}}</td>
216 <tr>
225 </tr>
217 <td {{color_status.25}} title='{{module_messages.25}}'>{{active_beam.get_upvalues.24}}</td> <td {{color_status.26}} title='{{module_messages.26}}'>{{active_beam.get_upvalues.25}}</td> <td {{color_status.27}} title='{{module_messages.27}}'>{{active_beam.get_upvalues.26}}</td> <td {{color_status.28}} title='{{module_messages.28}}'>{{active_beam.get_upvalues.27}}</td>
226 <tr>
218 </tr>
227 <td {%if beam.pk == active_beam %} {{color_status.17}} {%endif%} title='{{module_messages.17}}'>{{beam.get_upvalues.16}}</td>
219 <tr>
228 <td {%if beam.pk == active_beam %} {{color_status.18}} {%endif%} title='{{module_messages.18}}'>{{beam.get_upvalues.17}}</td>
220 <td {{color_status.25}} title='{{module_messages.25}}'>{{active_beam.get_downvalues.24}}</td> <td {{color_status.26}} title='{{module_messages.26}}'>{{active_beam.get_downvalues.25}}</td> <td {{color_status.27}} title='{{module_messages.27}}'>{{active_beam.get_downvalues.26}}</td> <td {{color_status.28}} title='{{module_messages.28}}'>{{active_beam.get_downvalues.27}}</td>
229 <td {%if beam.pk == active_beam %} {{color_status.19}} {%endif%} title='{{module_messages.19}}'>{{beam.get_upvalues.18}}</td>
221 </tr>
230 <td {%if beam.pk == active_beam %} {{color_status.20}} {%endif%} title='{{module_messages.20}}'>{{beam.get_upvalues.19}}</td>
222 </table>
231 </tr>
223 </td>
232 <tr>
224 <td> <b>East Quarter</b>
233 <td {%if beam.pk == active_beam %} {{color_status.17}} {%endif%} title='{{module_messages.17}}'>{{beam.get_downvalues.16}}</td>
225 <table class="east ">
234 <td {%if beam.pk == active_beam %} {{color_status.18}} {%endif%} title='{{module_messages.18}}'>{{beam.get_downvalues.17}}</td>
226 <tr>
235 <td {%if beam.pk == active_beam %} {{color_status.19}} {%endif%} title='{{module_messages.19}}'>{{beam.get_downvalues.18}}</td>
227 <td {{color_status.5}} title='{{module_messages.5}}'>{{active_beam.get_upvalues.4}}</td> <td {{color_status.6}} title='{{module_messages.6}}'>{{active_beam.get_upvalues.5}}</td> <td {{color_status.7}} title='{{module_messages.7}}'>{{active_beam.get_upvalues.6}}</td> <td {{color_status.8}} title='{{module_messages.8}}'>{{active_beam.get_upvalues.7}}</td>
236 <td {%if beam.pk == active_beam %} {{color_status.20}} {%endif%} title='{{module_messages.20}}'>{{beam.get_downvalues.19}}</td>
228 </tr>
237 </tr>
229 <tr>
238 <tr>
230 <td {{color_status.5}} title='{{module_messages.5}}'>{{active_beam.get_downvalues.4}}</td> <td {{color_status.6}} title='{{module_messages.6}}'>{{active_beam.get_downvalues.5}}</td> <td {{color_status.7}} title='{{module_messages.7}}'>{{active_beam.get_downvalues.6}}</td> <td {{color_status.8}} title='{{module_messages.8}}'>{{active_beam.get_downvalues.7}}</td>
239 <td {%if beam.pk == active_beam %} {{color_status.25}} {%endif%} title='{{module_messages.25}}'>{{beam.get_upvalues.24}}</td>
231 </tr>
240 <td {%if beam.pk == active_beam %} {{color_status.26}} {%endif%} title='{{module_messages.26}}'>{{beam.get_upvalues.25}}</td>
232 <tr>
241 <td {%if beam.pk == active_beam %} {{color_status.27}} {%endif%} title='{{module_messages.27}}'>{{beam.get_upvalues.26}}</td>
233 <td {{color_status.13}} title='{{module_messages.13}}'>{{active_beam.get_upvalues.12}}</td> <td {{color_status.14}} title='{{module_messages.14}}'>{{active_beam.get_upvalues.13}}</td> <td {{color_status.15}} title='{{module_messages.15}}'>{{active_beam.get_upvalues.14}}</td> <td {{color_status.16}} title='{{module_messages.16}}'>{{active_beam.get_upvalues.15}}</td>
242 <td {%if beam.pk == active_beam %} {{color_status.28}} {%endif%} title='{{module_messages.28}}'>{{beam.get_upvalues.27}}</td>
234 </tr>
243 </tr>
235 <tr>
244 <tr>
236 <td {{color_status.13}} title='{{module_messages.13}}'>{{active_beam.get_downvalues.12}}</td> <td {{color_status.14}} title='{{module_messages.14}}'>{{active_beam.get_downvalues.13}}</td> <td {{color_status.15}} title='{{module_messages.15}}'>{{active_beam.get_downvalues.14}}</td> <td {{color_status.16}} title='{{module_messages.16}}'>{{active_beam.get_downvalues.15}}</td>
245 <td {%if beam.pk == active_beam %} {{color_status.25}} {%endif%} title='{{module_messages.25}}'>{{beam.get_downvalues.24}}</td>
237 </tr>
246 <td {%if beam.pk == active_beam %} {{color_status.26}} {%endif%} title='{{module_messages.26}}'>{{beam.get_downvalues.25}}</td>
238 <tr>
247 <td {%if beam.pk == active_beam %} {{color_status.27}} {%endif%} title='{{module_messages.27}}'>{{beam.get_downvalues.26}}</td>
239 <td {{color_status.21}} title='{{module_messages.21}}'>{{active_beam.get_upvalues.20}}</td> <td {{color_status.22}} title='{{module_messages.22}}'>{{active_beam.get_upvalues.21}}</td> <td {{color_status.23}} title='{{module_messages.23}}'>{{active_beam.get_upvalues.22}}</td> <td {{color_status.24}} title='{{module_messages.24}}'>{{active_beam.get_upvalues.23}}</td>
248 <td {%if beam.pk == active_beam %} {{color_status.28}} {%endif%} title='{{module_messages.28}}'>{{beam.get_downvalues.27}}</td>
240 </tr>
249 </tr>
241 <tr>
250 </table>
242 <td {{color_status.21}} title='{{module_messages.21}}'>{{active_beam.get_downvalues.20}}</td> <td {{color_status.22}} title='{{module_messages.22}}'>{{active_beam.get_downvalues.21}}</td> <td {{color_status.23}} title='{{module_messages.23}}'>{{active_beam.get_downvalues.22}}</td> <td {{color_status.24}} title='{{module_messages.24}}'>{{active_beam.get_downvalues.23}}</td>
251 </td>
243 </tr>
252 <td>
244 <tr>
253 <b>East Quarter</b>
245 <td {{color_status.29}} title='{{module_messages.29}}'>{{active_beam.get_upvalues.28}}</td> <td {{color_status.30}} title='{{module_messages.30}}'>{{active_beam.get_upvalues.29}}</td> <td {{color_status.31}} title='{{module_messages.31}}'>{{active_beam.get_upvalues.30}}</td> <td {{color_status.32}} title='{{module_messages.32}}'>{{active_beam.get_upvalues.31}}</td>
254 <table class="east ">
246 </tr>
255 <tr>
247 <tr>
256 <td {%if beam.pk == active_beam %} {{color_status.5}} t{%endif%} itle='{{module_messages.5}}'>{{beam.get_upvalues.4}}</td>
248 <td {{color_status.29}} title='{{module_messages.29}}'>{{active_beam.get_downvalues.28}}</td> <td {{color_status.30}} title='{{module_messages.30}}'>{{active_beam.get_downvalues.29}}</td> <td {{color_status.31}} title='{{module_messages.31}}'>{{active_beam.get_downvalues.30}}</td> <td {{color_status.32}} title='{{module_messages.32}}'>{{active_beam.get_downvalues.31}}</td>
257 <td {%if beam.pk == active_beam %} {{color_status.6}} t{%endif%} itle='{{module_messages.6}}'>{{beam.get_upvalues.5}}</td>
249 </tr>
258 <td {%if beam.pk == active_beam %} {{color_status.7}} t{%endif%} itle='{{module_messages.7}}'>{{beam.get_upvalues.6}}</td>
250 </table>
259 <td {%if beam.pk == active_beam %} {{color_status.8}} t{%endif%} itle='{{module_messages.8}}'>{{beam.get_upvalues.7}}</td>
251 </td>
260 </tr>
252 </tr>
261 <tr>
253 <tr>
262 <td {%if beam.pk == active_beam %} {{color_status.5}} t{%endif%} itle='{{module_messages.5}}'>{{beam.get_downvalues.4}}</td>
254 <td> <b>West Quarter</b>
263 <td {%if beam.pk == active_beam %} {{color_status.6}} t{%endif%} itle='{{module_messages.6}}'>{{beam.get_downvalues.5}}</td>
255 <table class="west ">
264 <td {%if beam.pk == active_beam %} {{color_status.7}} t{%endif%} itle='{{module_messages.7}}'>{{beam.get_downvalues.6}}</td>
256 <tr>
265 <td {%if beam.pk == active_beam %} {{color_status.8}} t{%endif%} itle='{{module_messages.8}}'>{{beam.get_downvalues.7}}</td>
257 <td {{color_status.33}} title='{{module_messages.33}}'>{{active_beam.get_upvalues.32}}</td> <td {{color_status.34}} title='{{module_messages.34}}'>{{active_beam.get_upvalues.33}}</td> <td {{color_status.35}} title='{{module_messages.35}}'>{{active_beam.get_upvalues.34}}</td> <td {{color_status.36}} title='{{module_messages.36}}'>{{active_beam.get_upvalues.35}}</td>
266 </tr>
258 </tr>
267 <tr>
259 <tr>
268 <td {%if beam.pk == active_beam %} {{color_status.13}} {%endif%} title='{{module_messages.13}}'>{{beam.get_upvalues.12}}</td>
260 <td {{color_status.33}} title='{{module_messages.33}}'>{{active_beam.get_downvalues.32}}</td> <td {{color_status.34}} title='{{module_messages.34}}'>{{active_beam.get_downvalues.33}}</td> <td {{color_status.35}} title='{{module_messages.35}}'>{{active_beam.get_downvalues.34}}</td> <td {{color_status.36}} title='{{module_messages.36}}'>{{active_beam.get_downvalues.35}}</td>
269 <td {%if beam.pk == active_beam %} {{color_status.14}} {%endif%} title='{{module_messages.14}}'>{{beam.get_upvalues.13}}</td>
261 </tr>
270 <td {%if beam.pk == active_beam %} {{color_status.15}} {%endif%} title='{{module_messages.15}}'>{{beam.get_upvalues.14}}</td>
262 <tr>
271 <td {%if beam.pk == active_beam %} {{color_status.16}} {%endif%} title='{{module_messages.16}}'>{{beam.get_upvalues.15}}</td>
263 <td {{color_status.41}} title='{{module_messages.41}}'>{{active_beam.get_upvalues.40}}</td> <td {{color_status.42}} title='{{module_messages.42}}'>{{active_beam.get_upvalues.41}}</td> <td {{color_status.43}} title='{{module_messages.43}}'>{{active_beam.get_upvalues.42}}</td> <td {{color_status.44}} title='{{module_messages.44}}'>{{active_beam.get_upvalues.43}}</td>
272 </tr>
264 </tr>
273 <tr>
265 <tr>
274 <td {%if beam.pk == active_beam %} {{color_status.13}} {%endif%} title='{{module_messages.13}}'>{{beam.get_downvalues.12}}</td>
266 <td {{color_status.41}} title='{{module_messages.41}}'>{{active_beam.get_downvalues.40}}</td> <td {{color_status.42}} title='{{module_messages.42}}'>{{active_beam.get_downvalues.41}}</td> <td {{color_status.43}} title='{{module_messages.43}}'>{{active_beam.get_downvalues.42}}</td> <td {{color_status.44}} title='{{module_messages.44}}'>{{active_beam.get_downvalues.43}}</td>
275 <td {%if beam.pk == active_beam %} {{color_status.14}} {%endif%} title='{{module_messages.14}}'>{{beam.get_downvalues.13}}</td>
267 </tr>
276 <td {%if beam.pk == active_beam %} {{color_status.15}} {%endif%} title='{{module_messages.15}}'>{{beam.get_downvalues.14}}</td>
268 <tr>
277 <td {%if beam.pk == active_beam %} {{color_status.16}} {%endif%} title='{{module_messages.16}}'>{{beam.get_downvalues.15}}</td>
269 <td {{color_status.49}} title='{{module_messages.49}}'>{{active_beam.get_upvalues.48}}</td> <td {{color_status.50}} title='{{module_messages.50}}'>{{active_beam.get_upvalues.49}}</td> <td {{color_status.51}} title='{{module_messages.51}}'>{{active_beam.get_upvalues.50}}</td> <td {{color_status.52}} title='{{module_messages.52}}'>{{active_beam.get_upvalues.51}}</td>
278 </tr>
270 </tr>
279 <tr>
271 <tr>
280 <td {%if beam.pk == active_beam %} {{color_status.21}} {%endif%} title='{{module_messages.21}}'>{{beam.get_upvalues.20}}</td>
272 <td {{color_status.49}} title='{{module_messages.49}}'>{{active_beam.get_downvalues.48}}</td> <td {{color_status.50}} title='{{module_messages.50}}'>{{active_beam.get_downvalues.49}}</td> <td {{color_status.51}} title='{{module_messages.51}}'>{{active_beam.get_downvalues.50}}</td> <td {{color_status.52}} title='{{module_messages.52}}'>{{active_beam.get_downvalues.51}}</td>
281 <td {%if beam.pk == active_beam %} {{color_status.22}} {%endif%} title='{{module_messages.22}}'>{{beam.get_upvalues.21}}</td>
273 </tr>
282 <td {%if beam.pk == active_beam %} {{color_status.23}} {%endif%} title='{{module_messages.23}}'>{{beam.get_upvalues.22}}</td>
274 <tr>
283 <td {%if beam.pk == active_beam %} {{color_status.24}} {%endif%} title='{{module_messages.24}}'>{{beam.get_upvalues.23}}</td>
275 <td {{color_status.57}} title='{{module_messages.57}}'>{{active_beam.get_upvalues.56}}</td> <td {{color_status.58}} title='{{module_messages.58}}'>{{active_beam.get_upvalues.57}}</td> <td {{color_status.59}} title='{{module_messages.59}}'>{{active_beam.get_upvalues.58}}</td> <td {{color_status.60}} title='{{module_messages.60}}'>{{active_beam.get_upvalues.59}}</td>
284 </tr>
276 </tr>
285 <tr>
277 <tr>
286 <td {%if beam.pk == active_beam %} {{color_status.21}} {%endif%} title='{{module_messages.21}}'>{{beam.get_downvalues.20}}</td>
278 <td {{color_status.57}} title='{{module_messages.57}}'>{{active_beam.get_downvalues.56}}</td> <td {{color_status.58}} title='{{module_messages.58}}'>{{active_beam.get_downvalues.57}}</td> <td {{color_status.59}} title='{{module_messages.59}}'>{{active_beam.get_downvalues.58}}</td> <td {{color_status.60}} title='{{module_messages.60}}'>{{active_beam.get_downvalues.59}}</td>
287 <td {%if beam.pk == active_beam %} {{color_status.22}} {%endif%} title='{{module_messages.22}}'>{{beam.get_downvalues.21}}</td>
279 </tr>
288 <td {%if beam.pk == active_beam %} {{color_status.23}} {%endif%} title='{{module_messages.23}}'>{{beam.get_downvalues.22}}</td>
280 </table>
289 <td {%if beam.pk == active_beam %} {{color_status.24}} {%endif%} title='{{module_messages.24}}'>{{beam.get_downvalues.23}}</td>
281 </td>
290 </tr>
282 <td> <b>South Quarter</b>
291 <tr>
283 <table class="south ">
292 <td {%if beam.pk == active_beam %} {{color_status.29}} {%endif%} title='{{module_messages.29}}'>{{beam.get_upvalues.28}}</td>
284 <tr>
293 <td {%if beam.pk == active_beam %} {{color_status.30}} {%endif%} title='{{module_messages.30}}'>{{beam.get_upvalues.29}}</td>
285 <td {{color_status.37}} title='{{module_messages.37}}'>{{active_beam.get_upvalues.36}}</td> <td {{color_status.38}} title='{{module_messages.38}}'>{{active_beam.get_upvalues.37}}</td> <td {{color_status.39}} title='{{module_messages.39}}'>{{active_beam.get_upvalues.38}}</td> <td {{color_status.40}} title='{{module_messages.40}}'>{{active_beam.get_upvalues.39}}</td>
294 <td {%if beam.pk == active_beam %} {{color_status.31}} {%endif%} title='{{module_messages.31}}'>{{beam.get_upvalues.30}}</td>
286 </tr>
295 <td {%if beam.pk == active_beam %} {{color_status.32}} {%endif%} title='{{module_messages.32}}'>{{beam.get_upvalues.31}}</td>
287 <tr>
296 </tr>
288 <td {{color_status.37}} title='{{module_messages.37}}'>{{active_beam.get_downvalues.36}}</td> <td {{color_status.38}} title='{{module_messages.38}}'>{{active_beam.get_downvalues.37}}</td> <td {{color_status.39}} title='{{module_messages.39}}'>{{active_beam.get_downvalues.38}}</td> <td {{color_status.40}} title='{{module_messages.40}}'>{{active_beam.get_downvalues.39}}</td>
297 <tr>
289 </tr>
298 <td {%if beam.pk == active_beam %} {{color_status.29}} {%endif%} title='{{module_messages.29}}'>{{beam.get_downvalues.28}}</td>
290 <tr>
299 <td {%if beam.pk == active_beam %} {{color_status.30}} {%endif%} title='{{module_messages.30}}'>{{beam.get_downvalues.29}}</td>
291 <td {{color_status.45}} title='{{module_messages.45}}'>{{active_beam.get_upvalues.44}}</td> <td {{color_status.46}} title='{{module_messages.46}}'>{{active_beam.get_upvalues.45}}</td> <td {{color_status.47}} title='{{module_messages.47}}'>{{active_beam.get_upvalues.46}}</td> <td {{color_status.48}} title='{{module_messages.48}}'>{{active_beam.get_upvalues.47}}</td>
300 <td {%if beam.pk == active_beam %} {{color_status.31}} {%endif%} title='{{module_messages.31}}'>{{beam.get_downvalues.30}}</td>
292 </tr>
301 <td {%if beam.pk == active_beam %} {{color_status.32}} {%endif%} title='{{module_messages.32}}'>{{beam.get_downvalues.31}}</td>
293 <tr>
302 </tr>
294 <td {{color_status.45}} title='{{module_messages.45}}'>{{active_beam.get_downvalues.44}}</td> <td {{color_status.46}} title='{{module_messages.46}}'>{{active_beam.get_downvalues.45}}</td> <td {{color_status.47}} title='{{module_messages.47}}'>{{active_beam.get_downvalues.46}}</td> <td {{color_status.48}} title='{{module_messages.48}}'>{{active_beam.get_downvalues.47}}</td>
303 </table>
295 </tr>
304 </td>
296 <tr>
305 </tr>
297 <td {{color_status.53}} title='{{module_messages.53}}'>{{active_beam.get_upvalues.52}}</td> <td {{color_status.54}} title='{{module_messages.54}}'>{{active_beam.get_upvalues.53}}</td> <td {{color_status.55}} title='{{module_messages.55}}'>{{active_beam.get_upvalues.54}}</td> <td {{color_status.56}} title='{{module_messages.56}}'>{{active_beam.get_upvalues.55}}</td>
306 <tr>
298 </tr>
307 <td>
299 <tr>
308 <b>West Quarter</b>
300 <td {{color_status.53}} title='{{module_messages.53}}'>{{active_beam.get_downvalues.52}}</td> <td {{color_status.54}} title='{{module_messages.54}}'>{{active_beam.get_downvalues.53}}</td> <td {{color_status.55}} title='{{module_messages.55}}'>{{active_beam.get_downvalues.54}}</td> <td {{color_status.56}} title='{{module_messages.56}}'>{{active_beam.get_downvalues.55}}</td>
309 <table class="west ">
301 </tr>
310 <tr>
302 <tr>
311 <td {%if beam.pk == active_beam %} {{color_status.33}} {%endif%} title='{{module_messages.33}}'>{{beam.get_upvalues.32}}</td>
303 <td {{color_status.61}} title='{{module_messages.61}}'>{{active_beam.get_upvalues.60}}</td> <td {{color_status.62}} title='{{module_messages.62}}'>{{active_beam.get_upvalues.61}}</td> <td {{color_status.63}} title='{{module_messages.63}}'>{{active_beam.get_upvalues.62}}</td> <td {{color_status.64}} title='{{module_messages.64}}'>{{active_beam.get_upvalues.63}}</td>
312 <td {%if beam.pk == active_beam %} {{color_status.34}} {%endif%} title='{{module_messages.34}}'>{{beam.get_upvalues.33}}</td>
304 </tr>
313 <td {%if beam.pk == active_beam %} {{color_status.35}} {%endif%} title='{{module_messages.35}}'>{{beam.get_upvalues.34}}</td>
305 <tr>
314 <td {%if beam.pk == active_beam %} {{color_status.36}} {%endif%} title='{{module_messages.36}}'>{{beam.get_upvalues.35}}</td>
306 <td {{color_status.61}} title='{{module_messages.61}}'>{{active_beam.get_downvalues.60}}</td> <td {{color_status.62}} title='{{module_messages.62}}'>{{active_beam.get_downvalues.61}}</td> <td {{color_status.63}} title='{{module_messages.63}}'>{{active_beam.get_downvalues.62}}</td> <td {{color_status.64}} title='{{module_messages.64}}'>{{active_beam.get_downvalues.63}}</td>
315 </tr>
307 </tr>
316 <tr>
308 </table>
317 <td {%if beam.pk == active_beam %} {{color_status.33}} {%endif%} title='{{module_messages.33}}'>{{beam.get_downvalues.32}}</td>
309 </td>
318 <td {%if beam.pk == active_beam %} {{color_status.34}} {%endif%} title='{{module_messages.34}}'>{{beam.get_downvalues.33}}</td>
310 </tr>
319 <td {%if beam.pk == active_beam %} {{color_status.35}} {%endif%} title='{{module_messages.35}}'>{{beam.get_downvalues.34}}</td>
311 </table>
320 <td {%if beam.pk == active_beam %} {{color_status.36}} {%endif%} title='{{module_messages.36}}'>{{beam.get_downvalues.35}}</td>
312
321 </tr>
313
322 <tr>
314
323 <td {%if beam.pk == active_beam %} {{color_status.41}} {%endif%} title='{{module_messages.41}}'>{{beam.get_upvalues.40}}</td>
315 <table class="legend">
324 <td {%if beam.pk == active_beam %} {{color_status.42}} {%endif%} title='{{module_messages.42}}'>{{beam.get_upvalues.41}}</td>
316 <tr>
325 <td {%if beam.pk == active_beam %} {{color_status.43}} {%endif%} title='{{module_messages.43}}'>{{beam.get_upvalues.42}}</td>
317 <th colspan="2">Legend</th>
326 <td {%if beam.pk == active_beam %} {{color_status.44}} {%endif%} title='{{module_messages.44}}'>{{beam.get_upvalues.43}}</td>
318 </tr>
327 </tr>
319 <tr>
328 <tr>
320 <td class="text-danger"><i>RED</i></td><td>Disconnected</td>
329 <td {%if beam.pk == active_beam %} {{color_status.41}} {%endif%} title='{{module_messages.41}}'>{{beam.get_downvalues.40}}</td>
321 </tr>
330 <td {%if beam.pk == active_beam %} {{color_status.42}} {%endif%} title='{{module_messages.42}}'>{{beam.get_downvalues.41}}</td>
322 <tr>
331 <td {%if beam.pk == active_beam %} {{color_status.43}} {%endif%} title='{{module_messages.43}}'>{{beam.get_downvalues.42}}</td>
323 <td class="text-warning"><i>ORANGE</i></td><td>Connected</td>
332 <td {%if beam.pk == active_beam %} {{color_status.44}} {%endif%} title='{{module_messages.44}}'>{{beam.get_downvalues.43}}</td>
324 </tr>
333 </tr>
325 <tr>
334 <tr>
326 <td class="text-success"><i>GREEN</i></td><td>Running </td>
335 <td {%if beam.pk == active_beam %} {{color_status.49}} {%endif%} title='{{module_messages.49}}'>{{beam.get_upvalues.48}}</td>
327 </tr>
336 <td {%if beam.pk == active_beam %} {{color_status.50}} {%endif%} title='{{module_messages.50}}'>{{beam.get_upvalues.49}}</td>
328 <!--
337 <td {%if beam.pk == active_beam %} {{color_status.51}} {%endif%} title='{{module_messages.51}}'>{{beam.get_upvalues.50}}</td>
329 <tr>
338 <td {%if beam.pk == active_beam %} {{color_status.52}} {%endif%} title='{{module_messages.52}}'>{{beam.get_upvalues.51}}</td>
330 <td colspan="2">
339 </tr>
331 <button style="margin: 10px;" id="sendbeam" type="button" class="btn btn-default">
340 <tr>
332 <span class="glyphicon glyphicon-export" aria-hidden="true"></span>
341 <td {%if beam.pk == active_beam %} {{color_status.49}} {%endif%} title='{{module_messages.49}}'>{{beam.get_downvalues.48}}</td>
333 Change Beam</button>
342 <td {%if beam.pk == active_beam %} {{color_status.50}} {%endif%} title='{{module_messages.50}}'>{{beam.get_downvalues.49}}</td>
334 </td>
343 <td {%if beam.pk == active_beam %} {{color_status.51}} {%endif%} title='{{module_messages.51}}'>{{beam.get_downvalues.50}}</td>
335 </tr>
344 <td {%if beam.pk == active_beam %} {{color_status.52}} {%endif%} title='{{module_messages.52}}'>{{beam.get_downvalues.51}}</td>
336 -->
345 </tr>
337 </table>
346 <tr>
338
347 <td {%if beam.pk == active_beam %} {{color_status.57}} {%endif%} title='{{module_messages.57}}'>{{beam.get_upvalues.56}}</td>
339
348 <td {%if beam.pk == active_beam %} {{color_status.58}} {%endif%} title='{{module_messages.58}}'>{{beam.get_upvalues.57}}</td>
340
349 <td {%if beam.pk == active_beam %} {{color_status.59}} {%endif%} title='{{module_messages.59}}'>{{beam.get_upvalues.58}}</td>
341
350 <td {%if beam.pk == active_beam %} {{color_status.60}} {%endif%} title='{{module_messages.60}}'>{{beam.get_upvalues.59}}</td>
342 {% else %}
351 </tr>
343 <p><i>This ABS Configuration does not have a current active ABS Beam...<br>
352 <tr>
344 Please send Beam List to ABS modules. </i></p>
353 <td {%if beam.pk == active_beam %} {{color_status.57}} {%endif%} title='{{module_messages.57}}'>{{beam.get_downvalues.56}}</td>
345
354 <td {%if beam.pk == active_beam %} {{color_status.58}} {%endif%} title='{{module_messages.58}}'>{{beam.get_downvalues.57}}</td>
346 {% endif %}
355 <td {%if beam.pk == active_beam %} {{color_status.59}} {%endif%} title='{{module_messages.59}}'>{{beam.get_downvalues.58}}</td>
347
356 <td {%if beam.pk == active_beam %} {{color_status.60}} {%endif%} title='{{module_messages.60}}'>{{beam.get_downvalues.59}}</td>
348
357 </tr>
358 </table>
359 </td>
360 <td>
361 <b>South Quarter</b>
362 <table class="south ">
363 <tr>
364 <td {%if beam.pk == active_beam %} {{color_status.37}} {%endif%} title='{{module_messages.37}}'>{{beam.get_upvalues.36}}</td>
365 <td {%if beam.pk == active_beam %} {{color_status.38}} {%endif%} title='{{module_messages.38}}'>{{beam.get_upvalues.37}}</td>
366 <td {%if beam.pk == active_beam %} {{color_status.39}} {%endif%} title='{{module_messages.39}}'>{{beam.get_upvalues.38}}</td>
367 <td {%if beam.pk == active_beam %} {{color_status.40}} {%endif%} title='{{module_messages.40}}'>{{beam.get_upvalues.39}}</td>
368 </tr>
369 <tr>
370 <td {%if beam.pk == active_beam %} {{color_status.37}} {%endif%} title='{{module_messages.37}}'>{{beam.get_downvalues.36}}</td>
371 <td {%if beam.pk == active_beam %} {{color_status.38}} {%endif%} title='{{module_messages.38}}'>{{beam.get_downvalues.37}}</td>
372 <td {%if beam.pk == active_beam %} {{color_status.39}} {%endif%} title='{{module_messages.39}}'>{{beam.get_downvalues.38}}</td>
373 <td {%if beam.pk == active_beam %} {{color_status.40}} {%endif%} title='{{module_messages.40}}'>{{beam.get_downvalues.39}}</td>
374 </tr>
375 <tr>
376 <td {%if beam.pk == active_beam %} {{color_status.45}} {%endif%} title='{{module_messages.45}}'>{{beam.get_upvalues.44}}</td>
377 <td {%if beam.pk == active_beam %} {{color_status.46}} {%endif%} title='{{module_messages.46}}'>{{beam.get_upvalues.45}}</td>
378 <td {%if beam.pk == active_beam %} {{color_status.47}} {%endif%} title='{{module_messages.47}}'>{{beam.get_upvalues.46}}</td>
379 <td {%if beam.pk == active_beam %} {{color_status.48}} {%endif%} title='{{module_messages.48}}'>{{beam.get_upvalues.47}}</td>
380 </tr>
381 <tr>
382 <td {%if beam.pk == active_beam %} {{color_status.45}} {%endif%} title='{{module_messages.45}}'>{{beam.get_downvalues.44}}</td>
383 <td {%if beam.pk == active_beam %} {{color_status.46}} {%endif%} title='{{module_messages.46}}'>{{beam.get_downvalues.45}}</td>
384 <td {%if beam.pk == active_beam %} {{color_status.47}} {%endif%} title='{{module_messages.47}}'>{{beam.get_downvalues.46}}</td>
385 <td {%if beam.pk == active_beam %} {{color_status.48}} {%endif%} title='{{module_messages.48}}'>{{beam.get_downvalues.47}}</td>
386 </tr>
387 <tr>
388 <td {%if beam.pk == active_beam %} {{color_status.53}} {%endif%} title='{{module_messages.53}}'>{{beam.get_upvalues.52}}</td>
389 <td {%if beam.pk == active_beam %} {{color_status.54}} {%endif%} title='{{module_messages.54}}'>{{beam.get_upvalues.53}}</td>
390 <td {%if beam.pk == active_beam %} {{color_status.55}} {%endif%} title='{{module_messages.55}}'>{{beam.get_upvalues.54}}</td>
391 <td {%if beam.pk == active_beam %} {{color_status.56}} {%endif%} title='{{module_messages.56}}'>{{beam.get_upvalues.55}}</td>
392 </tr>
393 <tr>
394 <td {%if beam.pk == active_beam %} {{color_status.53}} {%endif%} title='{{module_messages.53}}'>{{beam.get_downvalues.52}}</td>
395 <td {%if beam.pk == active_beam %} {{color_status.54}} {%endif%} title='{{module_messages.54}}'>{{beam.get_downvalues.53}}</td>
396 <td {%if beam.pk == active_beam %} {{color_status.55}} {%endif%} title='{{module_messages.55}}'>{{beam.get_downvalues.54}}</td>
397 <td {%if beam.pk == active_beam %} {{color_status.56}} {%endif%} title='{{module_messages.56}}'>{{beam.get_downvalues.55}}</td>
398 </tr>
399 <tr>
400 <td {%if beam.pk == active_beam %} {{color_status.61}} {%endif%} title='{{module_messages.61}}'>{{beam.get_upvalues.60}}</td>
401 <td {%if beam.pk == active_beam %} {{color_status.62}} {%endif%} title='{{module_messages.62}}'>{{beam.get_upvalues.61}}</td>
402 <td {%if beam.pk == active_beam %} {{color_status.63}} {%endif%} title='{{module_messages.63}}'>{{beam.get_upvalues.62}}</td>
403 <td {%if beam.pk == active_beam %} {{color_status.64}} {%endif%} title='{{module_messages.64}}'>{{beam.get_upvalues.63}}</td>
404 </tr>
405 <tr>
406 <td {%if beam.pk == active_beam %} {{color_status.61}} {%endif%} title='{{module_messages.61}}'>{{beam.get_downvalues.60}}</td>
407 <td {%if beam.pk == active_beam %} {{color_status.62}} {%endif%} title='{{module_messages.62}}'>{{beam.get_downvalues.61}}</td>
408 <td {%if beam.pk == active_beam %} {{color_status.63}} {%endif%} title='{{module_messages.63}}'>{{beam.get_downvalues.62}}</td>
409 <td {%if beam.pk == active_beam %} {{color_status.64}} {%endif%} title='{{module_messages.64}}'>{{beam.get_downvalues.63}}</td>
410 </tr>
411 </table>
412 </td>
413 </tr>
414 </table>
415
416 {% if beam.id == active_beam %}
417 <table class="legend">
418 <tr>
419 <th colspan="2">Legend</th>
420 </tr>
421 <tr>
422 <td class="text-danger">
423 <i>RED</i>
424 </td>
425 <td>Disconnected</td>
426 </tr>
427 <tr>
428 <td class="text-warning">
429 <i>ORANGE</i>
430 </td>
431 <td>Connected</td>
432 </tr>
433 <tr>
434 <td class="text-success">
435 <i>GREEN</i>
436 </td>
437 <td>Running
438 </td>
439 </tr>
440 </table>
441 {% else %}
442 <div style="vertical-align: top; display:inline-block;">
443 <button id="send_beam{{forloop.counter}}" type="button" class="btn btn-default">
444 <span class="glyphicon glyphicon-export" aria-hidden="true"></span>
445 Change Beam</button>
349 </div>
446 </div>
350
447 {% endif %}
351
352
353 {% for beam in beams %}
354 <div id="menu{{forloop.counter}}" class="tab-pane fade">
355 <h3>{%if active_beam.id == beam.id%}Active Beam: {%endif%}{{beam.name}}</h3>
356 <!--<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>-->
357 <table id="abs_pattern{{forloop.counter}}" class="abs">
358 <tr>
359 <td> <b>North Quarter</b>
360 <table class="north ">
361 <tr>
362 <td {{beam.color_status.1}} title='{{beam.module_messages.1}}'>{{beam.get_upvalues.0}}</td> <td {{beam.color_status.2}} title='{{beam.module_messages.2}}'>{{beam.get_upvalues.1}}</td> <td {{beam.color_status.3}} title='{{beam.module_messages.3}}'>{{beam.get_upvalues.2}}</td> <td {{beam.color_status.4}} title='{{beam.module_messages.4}}'>{{beam.get_upvalues.3}}</td>
363 </tr>
364 <tr>
365 <td {{beam.color_status.1}} title='{{beam.module_messages.1}}'>{{beam.get_downvalues.0}}</td> <td {{beam.color_status.2}} title='{{beam.module_messages.2}}'>{{beam.get_downvalues.1}}</td> <td {{beam.color_status.3}} title='{{beam.module_messages.3}}'>{{beam.get_downvalues.2}}</td> <td {{beam.color_status.4}} title='{{beam.module_messages.4}}'>{{beam.get_downvalues.3}}</td>
366 </tr>
367 <tr>
368 <td {{beam.color_status.9}} title='{{beam.module_messages.9}}'>{{beam.get_upvalues.8}}</td> <td {{beam.color_status.10}} title='{{beam.module_messages.10}}'>{{beam.get_upvalues.9}}</td> <td {{beam.color_status.11}} title='{{beam.module_messages.11}}'>{{beam.get_upvalues.10}}</td> <td {{beam.color_status.12}} title='{{beam.module_messages.12}}'>{{beam.get_upvalues.11}}</td>
369 </tr>
370 <tr>
371 <td {{beam.color_status.9}} title='{{beam.module_messages.9}}'>{{beam.get_downvalues.8}}</td> <td {{beam.color_status.10}} title='{{beam.module_messages.10}}'>{{beam.get_downvalues.9}}</td> <td {{beam.color_status.11}} title='{{beam.module_messages.11}}'>{{beam.get_downvalues.10}}</td> <td {{beam.color_status.12}} title='{{beam.module_messages.12}}'>{{beam.get_downvalues.11}}</td>
372 </tr>
373 <tr>
374 <td {{beam.color_status.17}} title='{{beam.module_messages.17}}'>{{beam.get_upvalues.16}}</td> <td {{beam.color_status.18}} title='{{beam.module_messages.18}}'>{{beam.get_upvalues.17}}</td> <td {{beam.color_status.19}} title='{{beam.module_messages.19}}'>{{beam.get_upvalues.18}}</td> <td {{beam.color_status.20}} title='{{beam.module_messages.20}}'>{{beam.get_upvalues.19}}</td>
375 </tr>
376 <tr>
377 <td {{beam.color_status.17}} title='{{beam.module_messages.17}}'>{{beam.get_downvalues.16}}</td> <td {{beam.color_status.18}} title='{{beam.module_messages.18}}'>{{beam.get_downvalues.17}}</td> <td {{beam.color_status.19}} title='{{beam.module_messages.19}}'>{{beam.get_downvalues.18}}</td> <td {{beam.color_status.20}} title='{{beam.module_messages.20}}'>{{beam.get_downvalues.19}}</td>
378 </tr>
379 <tr>
380 <td {{beam.color_status.25}} title='{{beam.module_messages.25}}'>{{beam.get_upvalues.24}}</td> <td {{beam.color_status.26}} title='{{beam.module_messages.26}}'>{{beam.get_upvalues.25}}</td> <td {{beam.color_status.27}} title='{{beam.module_messages.27}}'>{{beam.get_upvalues.26}}</td> <td {{beam.color_status.28}} title='{{beam.module_messages.28}}'>{{beam.get_upvalues.27}}</td>
381 </tr>
382 <tr>
383 <td {{beam.color_status.25}} title='{{beam.module_messages.25}}'>{{beam.get_downvalues.24}}</td> <td {{beam.color_status.26}} title='{{beam.module_messages.26}}'>{{beam.get_downvalues.25}}</td> <td {{beam.color_status.27}} title='{{beam.module_messages.27}}'>{{beam.get_downvalues.26}}</td> <td {{beam.color_status.28}} title='{{beam.module_messages.28}}'>{{beam.get_downvalues.27}}</td>
384 </tr>
385 </table>
386 </td>
387 <td> <b>East Quarter</b>
388 <table class="east ">
389 <tr>
390 <td {{beam.color_status.5}} title='{{beam.module_messages.5}}'>{{beam.get_upvalues.4}}</td> <td {{beam.color_status.6}} title='{{beam.module_messages.6}}'>{{beam.get_upvalues.5}}</td> <td {{beam.color_status.7}} title='{{beam.module_messages.7}}'>{{beam.get_upvalues.6}}</td> <td {{beam.color_status.8}} title='{{beam.module_messages.8}}'>{{beam.get_upvalues.7}}</td>
391 </tr>
392 <tr>
393 <td {{beam.color_status.5}} title='{{beam.module_messages.5}}'>{{beam.get_downvalues.4}}</td> <td {{beam.color_status.6}} title='{{beam.module_messages.6}}'>{{beam.get_downvalues.5}}</td> <td {{beam.color_status.7}} title='{{beam.module_messages.7}}'>{{beam.get_downvalues.6}}</td> <td {{beam.color_status.8}} title='{{beam.module_messages.8}}'>{{beam.get_downvalues.7}}</td>
394 </tr>
395 <tr>
396 <td {{beam.color_status.13}} title='{{beam.module_messages.13}}'>{{beam.get_upvalues.12}}</td> <td {{beam.color_status.14}} title='{{beam.module_messages.14}}'>{{beam.get_upvalues.13}}</td> <td {{beam.color_status.15}} title='{{beam.module_messages.15}}'>{{beam.get_upvalues.14}}</td> <td {{beam.color_status.16}} title='{{beam.module_messages.16}}'>{{beam.get_upvalues.15}}</td>
397 </tr>
398 <tr>
399 <td {{beam.color_status.13}} title='{{beam.module_messages.13}}'>{{beam.get_downvalues.12}}</td> <td {{beam.color_status.14}} title='{{beam.module_messages.14}}'>{{beam.get_downvalues.13}}</td> <td {{beam.color_status.15}} title='{{beam.module_messages.15}}'>{{beam.get_downvalues.14}}</td> <td {{beam.color_status.16}} title='{{beam.module_messages.16}}'>{{beam.get_downvalues.15}}</td>
400 </tr>
401 <tr>
402 <td {{beam.color_status.21}} title='{{beam.module_messages.21}}'>{{beam.get_upvalues.20}}</td> <td {{beam.color_status.22}} title='{{beam.module_messages.22}}'>{{beam.get_upvalues.21}}</td> <td {{beam.color_status.23}} title='{{beam.module_messages.23}}'>{{beam.get_upvalues.22}}</td> <td {{beam.color_status.24}} title='{{beam.module_messages.24}}'>{{beam.get_upvalues.23}}</td>
403 </tr>
404 <tr>
405 <td {{beam.color_status.21}} title='{{beam.module_messages.21}}'>{{beam.get_downvalues.20}}</td> <td {{beam.color_status.22}} title='{{beam.module_messages.22}}'>{{beam.get_downvalues.21}}</td> <td {{beam.color_status.23}} title='{{beam.module_messages.23}}'>{{beam.get_downvalues.22}}</td> <td {{beam.color_status.24}} title='{{beam.module_messages.24}}'>{{beam.get_downvalues.23}}</td>
406 </tr>
407 <tr>
408 <td {{beam.color_status.29}} title='{{beam.module_messages.29}}'>{{beam.get_upvalues.28}}</td> <td {{beam.color_status.30}} title='{{beam.module_messages.30}}'>{{beam.get_upvalues.29}}</td> <td {{beam.color_status.31}} title='{{beam.module_messages.31}}'>{{beam.get_upvalues.30}}</td> <td {{beam.color_status.32}} title='{{beam.module_messages.32}}'>{{beam.get_upvalues.31}}</td>
409 </tr>
410 <tr>
411 <td {{beam.color_status.29}} title='{{beam.module_messages.29}}'>{{beam.get_downvalues.28}}</td> <td {{beam.color_status.30}} title='{{beam.module_messages.30}}'>{{beam.get_downvalues.29}}</td> <td {{beam.color_status.31}} title='{{beam.module_messages.31}}'>{{beam.get_downvalues.30}}</td> <td {{beam.color_status.32}} title='{{beam.module_messages.32}}'>{{beam.get_downvalues.31}}</td>
412 </tr>
413 </table>
414 </td>
415 </tr>
416 <tr>
417 <td> <b>West Quarter</b>
418 <table class="west ">
419 <tr>
420 <td {{beam.color_status.33}} title='{{beam.module_messages.33}}'>{{beam.get_upvalues.32}}</td> <td {{beam.color_status.34}} title='{{beam.module_messages.34}}'>{{beam.get_upvalues.33}}</td> <td {{beam.color_status.35}} title='{{beam.module_messages.35}}'>{{beam.get_upvalues.34}}</td> <td {{beam.color_status.36}} title='{{beam.module_messages.36}}'>{{beam.get_upvalues.35}}</td>
421 </tr>
422 <tr>
423 <td {{beam.color_status.33}} title='{{beam.module_messages.33}}'>{{beam.get_downvalues.32}}</td> <td {{beam.color_status.34}} title='{{beam.module_messages.34}}'>{{beam.get_downvalues.33}}</td> <td {{beam.color_status.35}} title='{{beam.module_messages.35}}'>{{beam.get_downvalues.34}}</td> <td {{beam.color_status.36}} title='{{beam.module_messages.36}}'>{{beam.get_downvalues.35}}</td>
424 </tr>
425 <tr>
426 <td {{beam.color_status.41}} title='{{beam.module_messages.41}}'>{{beam.get_upvalues.40}}</td> <td {{beam.color_status.42}} title='{{beam.module_messages.42}}'>{{beam.get_upvalues.41}}</td> <td {{beam.color_status.43}} title='{{beam.module_messages.43}}'>{{beam.get_upvalues.42}}</td> <td {{beam.color_status.44}} title='{{beam.module_messages.44}}'>{{beam.get_upvalues.43}}</td>
427 </tr>
428 <tr>
429 <td {{beam.color_status.41}} title='{{beam.module_messages.41}}'>{{beam.get_downvalues.40}}</td> <td {{beam.color_status.42}} title='{{beam.module_messages.42}}'>{{beam.get_downvalues.41}}</td> <td {{beam.color_status.43}} title='{{beam.module_messages.43}}'>{{beam.get_downvalues.42}}</td> <td {{beam.color_status.44}} title='{{beam.module_messages.44}}'>{{beam.get_downvalues.43}}</td>
430 </tr>
431 <tr>
432 <td {{beam.color_status.49}} title='{{beam.module_messages.49}}'>{{beam.get_upvalues.48}}</td> <td {{beam.color_status.50}} title='{{beam.module_messages.50}}'>{{beam.get_upvalues.49}}</td> <td {{beam.color_status.51}} title='{{beam.module_messages.51}}'>{{beam.get_upvalues.50}}</td> <td {{beam.color_status.52}} title='{{beam.module_messages.52}}'>{{beam.get_upvalues.51}}</td>
433 </tr>
434 <tr>
435 <td {{beam.color_status.49}} title='{{beam.module_messages.49}}'>{{beam.get_downvalues.48}}</td> <td {{beam.color_status.50}} title='{{beam.module_messages.50}}'>{{beam.get_downvalues.49}}</td> <td {{beam.color_status.51}} title='{{beam.module_messages.51}}'>{{beam.get_downvalues.50}}</td> <td {{beam.color_status.52}} title='{{beam.module_messages.52}}'>{{beam.get_downvalues.51}}</td>
436 </tr>
437 <tr>
438 <td {{beam.color_status.57}} title='{{beam.module_messages.57}}'>{{beam.get_upvalues.56}}</td> <td {{beam.color_status.58}} title='{{beam.module_messages.58}}'>{{beam.get_upvalues.57}}</td> <td {{beam.color_status.59}} title='{{beam.module_messages.59}}'>{{beam.get_upvalues.58}}</td> <td {{beam.color_status.60}} title='{{beam.module_messages.60}}'>{{beam.get_upvalues.59}}</td>
439 </tr>
440 <tr>
441 <td {{beam.color_status.57}} title='{{beam.module_messages.57}}'>{{beam.get_downvalues.56}}</td> <td {{beam.color_status.58}} title='{{beam.module_messages.58}}'>{{beam.get_downvalues.57}}</td> <td {{beam.color_status.59}} title='{{beam.module_messages.59}}'>{{beam.get_downvalues.58}}</td> <td {{beam.color_status.60}} title='{{beam.module_messages.60}}'>{{beam.get_downvalues.59}}</td>
442 </tr>
443 </table>
444 </td>
445 <td> <b>South Quarter</b>
446 <table class="south ">
447 <tr>
448 <td {{beam.color_status.37}} title='{{beam.module_messages.37}}'>{{beam.get_upvalues.36}}</td> <td {{beam.color_status.38}} title='{{beam.module_messages.38}}'>{{beam.get_upvalues.37}}</td> <td {{beam.color_status.39}} title='{{beam.module_messages.39}}'>{{beam.get_upvalues.38}}</td> <td {{beam.color_status.40}} title='{{beam.module_messages.40}}'>{{beam.get_upvalues.39}}</td>
449 </tr>
450 <tr>
451 <td {{beam.color_status.37}} title='{{beam.module_messages.37}}'>{{beam.get_downvalues.36}}</td> <td {{beam.color_status.38}} title='{{beam.module_messages.38}}'>{{beam.get_downvalues.37}}</td> <td {{beam.color_status.39}} title='{{beam.module_messages.39}}'>{{beam.get_downvalues.38}}</td> <td {{beam.color_status.40}} title='{{beam.module_messages.40}}'>{{beam.get_downvalues.39}}</td>
452 </tr>
453 <tr>
454 <td {{beam.color_status.45}} title='{{beam.module_messages.45}}'>{{beam.get_upvalues.44}}</td> <td {{beam.color_status.46}} title='{{beam.module_messages.46}}'>{{beam.get_upvalues.45}}</td> <td {{beam.color_status.47}} title='{{beam.module_messages.47}}'>{{beam.get_upvalues.46}}</td> <td {{beam.color_status.48}} title='{{beam.module_messages.48}}'>{{beam.get_upvalues.47}}</td>
455 </tr>
456 <tr>
457 <td {{beam.color_status.45}} title='{{beam.module_messages.45}}'>{{beam.get_downvalues.44}}</td> <td {{beam.color_status.46}} title='{{beam.module_messages.46}}'>{{beam.get_downvalues.45}}</td> <td {{beam.color_status.47}} title='{{beam.module_messages.47}}'>{{beam.get_downvalues.46}}</td> <td {{beam.color_status.48}} title='{{beam.module_messages.48}}'>{{beam.get_downvalues.47}}</td>
458 </tr>
459 <tr>
460 <td {{beam.color_status.53}} title='{{beam.module_messages.53}}'>{{beam.get_upvalues.52}}</td> <td {{beam.color_status.54}} title='{{beam.module_messages.54}}'>{{beam.get_upvalues.53}}</td> <td {{beam.color_status.55}} title='{{beam.module_messages.55}}'>{{beam.get_upvalues.54}}</td> <td {{beam.color_status.56}} title='{{beam.module_messages.56}}'>{{beam.get_upvalues.55}}</td>
461 </tr>
462 <tr>
463 <td {{beam.color_status.53}} title='{{beam.module_messages.53}}'>{{beam.get_downvalues.52}}</td> <td {{beam.color_status.54}} title='{{beam.module_messages.54}}'>{{beam.get_downvalues.53}}</td> <td {{beam.color_status.55}} title='{{beam.module_messages.55}}'>{{beam.get_downvalues.54}}</td> <td {{beam.color_status.56}} title='{{beam.module_messages.56}}'>{{beam.get_downvalues.55}}</td>
464 </tr>
465 <tr>
466 <td {{beam.color_status.61}} title='{{beam.module_messages.61}}'>{{beam.get_upvalues.60}}</td> <td {{beam.color_status.62}} title='{{beam.module_messages.62}}'>{{beam.get_upvalues.61}}</td> <td {{beam.color_status.63}} title='{{beam.module_messages.63}}'>{{beam.get_upvalues.62}}</td> <td {{beam.color_status.64}} title='{{beam.module_messages.64}}'>{{beam.get_upvalues.63}}</td>
467 </tr>
468 <tr>
469 <td {{beam.color_status.61}} title='{{beam.module_messages.61}}'>{{beam.get_downvalues.60}}</td> <td {{beam.color_status.62}} title='{{beam.module_messages.62}}'>{{beam.get_downvalues.61}}</td> <td {{beam.color_status.63}} title='{{beam.module_messages.63}}'>{{beam.get_downvalues.62}}</td> <td {{beam.color_status.64}} title='{{beam.module_messages.64}}'>{{beam.get_downvalues.63}}</td>
470 </tr>
471 </table>
472 </td>
473 </tr>
474 </table>
475
476 {% if active_beam.id != beam.id %}
477 <div style="vertical-align: top; display:inline-block;">
478 <button style="" id="send_beam{{forloop.counter}}" type="button" class="btn btn-default">
479 <span class="glyphicon glyphicon-export" aria-hidden="true"></span>
480 Change Beam</button>
481 </div>
482 {% endif %}
483
484
485
486
487 {% if active_beam %}
488 {% if active_beam.id == beam.id %}
489 <table class="legend">
490 <tr>
491 <th colspan="2">Legend</th>
492 </tr>
493 <tr>
494 <td class="text-danger"><i>RED</i></td><td>Disconnected</td>
495 </tr>
496 <tr>
497 <td class="text-warning"><i>ORANGE</i></td><td>Connected</td>
498 </tr>
499 <tr>
500 <td class="text-success"><i>GREEN</i></td><td>Running
501 </td>
502 </tr>
503 </table>
504
505 {% endif %}
506 {% endif %}
507
508
509 </div>
510
511
512 {% endfor %}
513
514
515
516 </div>
448 </div>
449 {% endfor %}
517 </div>
450 </div>
451 </div>
518
452
519
453
520 {% else %}
454 {% else %}
521 <p style="color:#b4bcc2; margin-left: 5%;"><i>No Beams...</i></p>
455 <p style="color:#b4bcc2; margin-left: 5%;">
522 {% endif %}
456 <i>No Beams...</i>
523
457 </p>
524 {% endblock extra-content %}
458 {% endif %} {% endblock extra-content %} {% block extra-js%}
525
526
527
528 {% block extra-js%}
529 <script>
459 <script>
530 $(document).ready(function() {
460 $(document).ready(function () {
531
461
532 {% for beam in beams %}
462 {% for beam in beams %}
533
463
534 {% if dev_conf.operation_mode == 1 %}
464 {% if dev_conf.operation_mode == 1 %}
535 $("#send_beam{{forloop.counter}}").prop('disabled', true)
465 $("#send_beam{{forloop.counter}}").prop('disabled', true)
536 {% else %}
466 {% else %}
537 $("#send_beam{{forloop.counter}}").click(function() {
467 $("#send_beam{{forloop.counter}}").click(function () {
538 document.location = "{% url 'url_send_beam' dev_conf.id beam.id %}";
468 document.location = "{% url 'url_send_beam' dev_conf.id beam.id %}";
539 });
469 });
540 {% endif %}
470 {% endif %}
541
471
542 {% endfor %}
472 {% endfor %}
543
473
544 {% if status_request %}
545 setTimeout("location.href = '{% url 'url_abs_conf' dev_conf.id %}'",53000);
546 {% endif %}
547
474
548 });
475 });
549 </script>
476 </script> {% endblock %} No newline at end of file
550 {% endblock %}
@@ -1,17 +1,17
1 from django.conf.urls import url
1 from django.conf.urls import url
2
2
3 from apps.abs import views
3 from apps.abs import views
4
4
5 urlpatterns = (
5 urlpatterns = (
6 url(r'^(?P<id_conf>-?\d+)/$', views.abs_conf, name='url_abs_conf'),
6 url(r'^(?P<id_conf>-?\d+)/$', views.abs_conf, name='url_abs_conf'),
7 url(r'^(?P<id_conf>-?\d+)/edit/$', views.abs_conf_edit, name='url_edit_abs_conf'),
7 url(r'^(?P<id_conf>-?\d+)/edit/$', views.abs_conf_edit, name='url_edit_abs_conf'),
8 url(r'^(?P<id_conf>-?\d+)/import/$', views.import_file, name='url_import_abs_conf'),
8 url(r'^(?P<id_conf>-?\d+)/import/$', views.import_file, name='url_import_abs_conf'),
9 url(r'^(?P<id_conf>-?\d+)/status/', views.abs_conf, {'status_request':True},name='url_status_abs_conf'),
9 #url(r'^(?P<id_conf>-?\d+)/status/', views.abs_conf, {'status_request':True},name='url_status_abs_conf'),
10 url(r'^(?P<id_conf>-?\d+)/change_beam/(?P<id_beam>-?\d+)/$', views.send_beam, name='url_send_beam'),
10 url(r'^(?P<id_conf>-?\d+)/change_beam/(?P<id_beam>-?\d+)/$', views.send_beam, name='url_send_beam'),
11 url(r'^(?P<id_conf>-?\d+)/plot/$', views.plot_patterns, name='url_plot_abs_patterns'),
11 url(r'^(?P<id_conf>-?\d+)/plot/$', views.plot_patterns, name='url_plot_abs_patterns'),
12 url(r'^(?P<id_conf>-?\d+)/plot/(?P<id_beam>-?\d+)/$', views.plot_patterns, name='url_plot_abs_patterns'),
12 url(r'^(?P<id_conf>-?\d+)/plot/(?P<id_beam>-?\d+)/$', views.plot_patterns, name='url_plot_abs_patterns'),
13 url(r'^(?P<id_conf>-?\d+)/plot/(?P<id_beam>-?\d+)/(?P<antenna>[\w\-]+)/pattern.png$', views.plot_pattern, name='url_plot_beam'),
13 url(r'^(?P<id_conf>-?\d+)/plot/(?P<id_beam>-?\d+)/(?P<antenna>[\w\-]+)/pattern.png$', views.plot_pattern, name='url_plot_beam'),
14 url(r'^(?P<id_conf>-?\d+)/add_beam/$', views.add_beam, name='url_add_abs_beam'),
14 url(r'^(?P<id_conf>-?\d+)/add_beam/$', views.add_beam, name='url_add_abs_beam'),
15 url(r'^(?P<id_conf>-?\d+)/beam/(?P<id_beam>-?\d+)/delete/$', views.remove_beam, name='url_remove_abs_beam'),
15 url(r'^(?P<id_conf>-?\d+)/beam/(?P<id_beam>-?\d+)/delete/$', views.remove_beam, name='url_remove_abs_beam'),
16 url(r'^(?P<id_conf>-?\d+)/beam/(?P<id_beam>-?\d+)/edit/$', views.edit_beam, name='url_edit_abs_beam'),
16 url(r'^(?P<id_conf>-?\d+)/beam/(?P<id_beam>-?\d+)/edit/$', views.edit_beam, name='url_edit_abs_beam'),
17 )
17 )
@@ -1,442 +1,411
1 from django.shortcuts import render_to_response
1 from django.shortcuts import render_to_response
2 from django.template import RequestContext
2 from django.template import RequestContext
3 from django.shortcuts import redirect, render, get_object_or_404
3 from django.shortcuts import redirect, render, get_object_or_404
4 from django.contrib import messages
4 from django.contrib import messages
5 from django.conf import settings
5 from django.conf import settings
6 from django.http import HttpResponse
6 from django.http import HttpResponse
7 from django.core.urlresolvers import reverse
7 from django.core.urlresolvers import reverse
8
8
9 from datetime import datetime
9 from datetime import datetime
10 from time import sleep
10 from time import sleep
11 import os
11 import os
12
12
13 from apps.main.models import Device, Configuration, Experiment
13 from apps.main.models import Device, Configuration, Experiment
14 from apps.main.views import sidebar
14 from apps.main.views import sidebar
15
15
16 from .models import ABSConfiguration, ABSBeam
16 from .models import ABSConfiguration, ABSBeam
17 from .forms import ABSConfigurationForm, ABSBeamEditForm, ABSBeamAddForm, ABSImportForm
17 from .forms import ABSConfigurationForm, ABSBeamEditForm, ABSBeamAddForm, ABSImportForm
18
18
19 from .utils.overJroShow import overJroShow
19 from .utils.overJroShow import overJroShow
20 from .utils.OverJRO import OverJRO
20 from .utils.OverJRO import OverJRO
21 # Create your views here.
21 # Create your views here.
22 import json, ast
22 import json, ast
23
23
24
24
25 def get_values_from_form(form_data):
25 def get_values_from_form(form_data):
26
26
27 sublistup = []
27 sublistup = []
28 sublistdown = []
28 sublistdown = []
29 subtxlistup = []
29 subtxlistup = []
30 subtxlistdown = []
30 subtxlistdown = []
31 subrxlistup = []
31 subrxlistup = []
32 subrxlistdown = []
32 subrxlistdown = []
33
33
34 up_values_list = []
34 up_values_list = []
35 down_values_list = []
35 down_values_list = []
36 up_txvalues_list = []
36 up_txvalues_list = []
37 down_txvalues_list = []
37 down_txvalues_list = []
38 up_rxvalues_list = []
38 up_rxvalues_list = []
39 down_rxvalues_list = []
39 down_rxvalues_list = []
40
40
41 values_list = {}
41 values_list = {}
42 cont = 1
42 cont = 1
43
43
44 for i in range(1,65):
44 for i in range(1,65):
45 x = float(form_data['abs_up'+str(i)])
45 x = float(form_data['abs_up'+str(i)])
46 y = float(form_data['abs_down'+str(i)])
46 y = float(form_data['abs_down'+str(i)])
47 sublistup.append(x)
47 sublistup.append(x)
48 sublistdown.append(y)
48 sublistdown.append(y)
49
49
50 if str(i) in form_data.getlist('uptx_checks'):
50 if str(i) in form_data.getlist('uptx_checks'):
51 subtxlistup.append(1)
51 subtxlistup.append(1)
52 else:
52 else:
53 subtxlistup.append(0)
53 subtxlistup.append(0)
54 if str(i) in form_data.getlist('downtx_checks'):
54 if str(i) in form_data.getlist('downtx_checks'):
55 subtxlistdown.append(1)
55 subtxlistdown.append(1)
56 else:
56 else:
57 subtxlistdown.append(0)
57 subtxlistdown.append(0)
58
58
59 if str(i) in form_data.getlist('uprx_checks'):
59 if str(i) in form_data.getlist('uprx_checks'):
60 subrxlistup.append(1)
60 subrxlistup.append(1)
61 else:
61 else:
62 subrxlistup.append(0)
62 subrxlistup.append(0)
63 if str(i) in form_data.getlist('downrx_checks'):
63 if str(i) in form_data.getlist('downrx_checks'):
64 subrxlistdown.append(1)
64 subrxlistdown.append(1)
65 else:
65 else:
66 subrxlistdown.append(0)
66 subrxlistdown.append(0)
67
67
68 cont = cont+1
68 cont = cont+1
69
69
70 if cont == 9:
70 if cont == 9:
71 up_values_list.append(sublistup)
71 up_values_list.append(sublistup)
72 down_values_list.append(sublistdown)
72 down_values_list.append(sublistdown)
73 sublistup = []
73 sublistup = []
74 sublistdown = []
74 sublistdown = []
75
75
76 up_txvalues_list.append(subtxlistup)
76 up_txvalues_list.append(subtxlistup)
77 down_txvalues_list.append(subtxlistdown)
77 down_txvalues_list.append(subtxlistdown)
78 subtxlistup = []
78 subtxlistup = []
79 subtxlistdown = []
79 subtxlistdown = []
80 up_rxvalues_list.append(subrxlistup)
80 up_rxvalues_list.append(subrxlistup)
81 down_rxvalues_list.append(subrxlistdown)
81 down_rxvalues_list.append(subrxlistdown)
82 subrxlistup = []
82 subrxlistup = []
83 subrxlistdown = []
83 subrxlistdown = []
84 cont = 1
84 cont = 1
85
85
86
86
87 list_uesup = []
87 list_uesup = []
88 list_uesdown = []
88 list_uesdown = []
89 for i in range(1,5):
89 for i in range(1,5):
90 if form_data['ues_up'+str(i)] == '':
90 if form_data['ues_up'+str(i)] == '':
91 list_uesup.append(0.0)
91 list_uesup.append(0.0)
92 else:
92 else:
93 list_uesup.append(float(form_data['ues_up'+str(i)]))
93 list_uesup.append(float(form_data['ues_up'+str(i)]))
94
94
95 if form_data['ues_down'+str(i)] == '':
95 if form_data['ues_down'+str(i)] == '':
96 list_uesdown.append(0.0)
96 list_uesdown.append(0.0)
97 else:
97 else:
98 list_uesdown.append(float(form_data['ues_down'+str(i)]))
98 list_uesdown.append(float(form_data['ues_down'+str(i)]))
99
99
100 onlyrx_list = form_data.getlist('onlyrx')
100 onlyrx_list = form_data.getlist('onlyrx')
101 only_rx = {}
101 only_rx = {}
102 if '1' in onlyrx_list:
102 if '1' in onlyrx_list:
103 only_rx['up'] = True
103 only_rx['up'] = True
104 else:
104 else:
105 only_rx['up'] = False
105 only_rx['up'] = False
106 if '2' in onlyrx_list:
106 if '2' in onlyrx_list:
107 only_rx['down'] = True
107 only_rx['down'] = True
108 else:
108 else:
109 only_rx['down'] = False
109 only_rx['down'] = False
110
110
111 antenna = {'antenna_up': up_values_list, 'antenna_down': down_values_list}
111 antenna = {'antenna_up': up_values_list, 'antenna_down': down_values_list}
112 tx = {'up': up_txvalues_list, 'down': down_txvalues_list}
112 tx = {'up': up_txvalues_list, 'down': down_txvalues_list}
113 rx = {'up': up_rxvalues_list, 'down': down_rxvalues_list}
113 rx = {'up': up_rxvalues_list, 'down': down_rxvalues_list}
114 ues = {'up': list_uesup, 'down': list_uesdown}
114 ues = {'up': list_uesup, 'down': list_uesdown}
115 name = str(form_data['beam_name'])
115 name = str(form_data['beam_name'])
116
116
117 beam_data = {'name': name, 'antenna': antenna, 'tx': tx, 'rx': rx, 'ues': ues, 'only_rx': only_rx}
117 beam_data = {'name': name, 'antenna': antenna, 'tx': tx, 'rx': rx, 'ues': ues, 'only_rx': only_rx}
118
118
119 return beam_data
119 return beam_data
120
120
121
121
122 def abs_conf(request, id_conf):
122
123
123 def abs_conf(request, id_conf, status_request=None):
124 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
124
125 beams = ABSBeam.objects.filter(abs_conf=conf)
125 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
126 beams = ABSBeam.objects.filter(abs_conf=conf)
127 active_beam_id = json.loads(conf.active_beam)
128
129 #------------Colors for Active Beam:-------------
126 #------------Colors for Active Beam:-------------
130 modules_status = json.loads(conf.module_status)
127 all_status = {}
131 module_messages = json.loads(conf.module_messages)
128 module_messages = json.loads(conf.module_messages)
132
129
133 color_status = {}
130 color_status = {}
134 for status in modules_status:
131 for i, status in enumerate(conf.module_status):
135 if modules_status[status] == 3: #Running background-color: #00cc00;
132 if status == '3': #Running background-color: #00cc00;
136 color_status[status] = 'class=text-success'#'bgcolor=#00cc00'
133 all_status['{}'.format(i+1)] = 2
137 elif modules_status[status] == 1: #Connected background-color: #ee902c;
134 color_status['{}'.format(i+1)] = 'class=text-success'#'bgcolor=#00cc00'
138 color_status[status] = 'class=text-warning'#'bgcolor=#ee902c'
135 elif status == '1': #Connected background-color: #ee902c;
139 else: #Disconnected background-color: #ff0000;
136 all_status['{}'.format(i+1)] = 1
140 color_status[status] = 'class=text-danger'#'bgcolor=#FF0000'
137 color_status['{}'.format(i+1)] = 'class=text-warning'#'bgcolor=#ee902c'
138 else: #Disconnected background-color: #ff0000;
139 all_status['{}'.format(i+1)] = 0
140 color_status['{}'.format(i+1)] = 'class=text-danger'#'bgcolor=#FF0000'
141 #------------------------------------------------
141 #------------------------------------------------
142
142
143 kwargs = {}
143 kwargs = {}
144 #kwargs['status'] = conf.device.get_status_display()
145 kwargs['connected_modules'] = str(conf.connected_modules())+'/64'
144 kwargs['connected_modules'] = str(conf.connected_modules())+'/64'
146
147 kwargs['dev_conf'] = conf
145 kwargs['dev_conf'] = conf
146
148 if conf.operation_mode == 0:
147 if conf.operation_mode == 0:
149 kwargs['dev_conf_keys'] = ['name', 'operation_mode']
148 kwargs['dev_conf_keys'] = ['name', 'operation_mode']
150 else:
149 else:
151 kwargs['dev_conf_keys'] = ['name', 'operation_mode', 'operation_value']
150 kwargs['dev_conf_keys'] = ['name', 'operation_mode', 'operation_value']
152
151
153 kwargs['title'] = 'ABS Configuration'
152 kwargs['title'] = 'ABS Configuration'
154 kwargs['suptitle'] = 'Details'
153 kwargs['suptitle'] = 'Details'
155 #kwargs['no_play'] = True
156
157 kwargs['button'] = 'Edit Configuration'
154 kwargs['button'] = 'Edit Configuration'
158 #------------------Active Beam-----------------------
155
159 try:
156 if conf.active_beam != 0:
160 active_beam_id = active_beam_id['active_beam']
157 kwargs['active_beam'] = int(conf.active_beam)
161 active_beam = ABSBeam.objects.get(pk=active_beam_id)
158
162 kwargs['active_beam'] = active_beam
159 kwargs['beams'] = beams
163 for beam in beams:
160 kwargs['modules_status'] = all_status
164 if beam.id == active_beam.id:
165 beam.color_status = color_status
166 beam.module_messages = module_messages
167 except:
168 active_beam = ''
169 #----------------------------------------------------
170 kwargs['beams'] = beams
171 kwargs['modules_status'] = modules_status
172 kwargs['color_status'] = color_status
161 kwargs['color_status'] = color_status
173 kwargs['module_messages'] = module_messages
162 kwargs['module_messages'] = module_messages
174
175 #if conf.device.status in [0,1]:
176 if conf.connected_modules() == 0:
177 conf.device.status = 0
178 messages.error(request, 'No ABS module is connected.')#conf.message)
179 conf.device.save()
180 else:
181 messages.success(request, 'ABS modules are connected.')#conf.message)
182
183 ###### SIDEBAR ######
163 ###### SIDEBAR ######
184 kwargs.update(sidebar(conf=conf))
164 kwargs.update(sidebar(conf=conf))
185
165
186 if status_request:
187 conf.status_device()
188 kwargs['status_request'] = True
189 return render(request, 'abs_conf.html', kwargs)
190
191 return render(request, 'abs_conf.html', kwargs)
166 return render(request, 'abs_conf.html', kwargs)
192
167
193
168
194 def abs_conf_edit(request, id_conf):
169 def abs_conf_edit(request, id_conf):
195
170
196 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
171 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
197
172
198 beams = ABSBeam.objects.filter(abs_conf=conf)
173 beams = ABSBeam.objects.filter(abs_conf=conf)
199 print beams
200
174
201 if request.method=='GET':
175 if request.method=='GET':
202 form = ABSConfigurationForm(instance=conf)
176 form = ABSConfigurationForm(instance=conf)
203
177
204 if request.method=='POST':
178 if request.method=='POST':
205 form = ABSConfigurationForm(request.POST, instance=conf)
179 form = ABSConfigurationForm(request.POST, instance=conf)
206
180
207 if form.is_valid():
181 if form.is_valid():
208 conf = form.save(commit=False)
182 conf = form.save(commit=False)
209 conf.save()
183 conf.save()
210 return redirect('url_abs_conf', id_conf=conf.id)
184 return redirect('url_abs_conf', id_conf=conf.id)
211
185
212 ###### SIDEBAR ######
186 ###### SIDEBAR ######
213 kwargs = {}
187 kwargs = {}
214
188
215 kwargs['dev_conf'] = conf
189 kwargs['dev_conf'] = conf
216 #kwargs['id_dev'] = conf.id
190 #kwargs['id_dev'] = conf.id
217 kwargs['id_conf'] = conf.id
191 kwargs['id_conf'] = conf.id
218 kwargs['form'] = form
192 kwargs['form'] = form
219 kwargs['abs_beams'] = beams
193 kwargs['abs_beams'] = beams
220 kwargs['title'] = 'Device Configuration'
194 kwargs['title'] = 'Device Configuration'
221 kwargs['suptitle'] = 'Edit'
195 kwargs['suptitle'] = 'Edit'
222 kwargs['button'] = 'Save'
196 kwargs['button'] = 'Save'
223
197
224 kwargs['edit'] = True
198 kwargs['edit'] = True
225
199
226 return render(request, 'abs_conf_edit.html', kwargs)
200 return render(request, 'abs_conf_edit.html', kwargs)
227
201
228
202
229 def import_file(request, id_conf):
203 def import_file(request, id_conf):
230
204
231 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
205 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
232 if request.method=='POST':
206 if request.method=='POST':
233 form = ABSImportForm(request.POST, request.FILES)
207 form = ABSImportForm(request.POST, request.FILES)
234 if form.is_valid():
208 if form.is_valid():
235 try:
209 try:
236 parms = conf.import_from_file(request.FILES['file_name'])
210 parms = conf.import_from_file(request.FILES['file_name'])
237
211
238 if parms:
212 if parms:
239 conf.update_from_file(parms)
213 conf.update_from_file(parms)
240 messages.success(request, 'Configuration "%s" loaded succesfully' % request.FILES['file_name'])
214 messages.success(request, 'Configuration "%s" loaded succesfully' % request.FILES['file_name'])
241 return redirect(conf.get_absolute_url_edit())
215 return redirect(conf.get_absolute_url_edit())
242
216
243 except Exception as e:
217 except Exception as e:
244 messages.error(request, 'Error parsing file: "%s" - %s' % (request.FILES['file_name'], e))
218 messages.error(request, 'Error parsing file: "%s" - %s' % (request.FILES['file_name'], e))
245
219
246 else:
220 else:
247 messages.warning(request, 'Your current configuration will be replaced')
221 messages.warning(request, 'Your current configuration will be replaced')
248 form = ABSImportForm()
222 form = ABSImportForm()
249
223
250 kwargs = {}
224 kwargs = {}
251 kwargs['form'] = form
225 kwargs['form'] = form
252 kwargs['title'] = 'ABS Configuration'
226 kwargs['title'] = 'ABS Configuration'
253 kwargs['suptitle'] = 'Import file'
227 kwargs['suptitle'] = 'Import file'
254 kwargs['button'] = 'Upload'
228 kwargs['button'] = 'Upload'
255 kwargs['previous'] = conf.get_absolute_url()
229 kwargs['previous'] = conf.get_absolute_url()
256
230
257 return render(request, 'abs_import.html', kwargs)
231 return render(request, 'abs_import.html', kwargs)
258
232
259
233
260 def send_beam(request, id_conf, id_beam):
234 def send_beam(request, id_conf, id_beam):
261
235
262 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
236 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
263 beam = get_object_or_404(ABSBeam, pk=id_beam)
237 beam = get_object_or_404(ABSBeam, pk=id_beam)
264 beams_list = ABSBeam.objects.filter(abs_conf=conf)
238 beams_list = ABSBeam.objects.filter(abs_conf=conf)
265 #To set this beam as an Active Beam
239 conf.active_beam = id_beam
266 beam.set_as_activebeam()
240
267 #To send beam position to abs-modules
268 i = 0
241 i = 0
269 for b in beams_list:
242 for b in beams_list:
270 if b.id == int(id_beam):
243 if b.id == int(id_beam):
271 break
244 break
272 else:
245 else:
273 i += 1
246 i += 1
274 beam_pos = i + 1 #Estandarizar
247 beam_pos = i + 1 #Estandarizar
275 print '%s Position: %s' % (beam.name, str(beam_pos))
248 print '%s Position: %s' % (beam.name, str(beam_pos))
276 conf.send_beam_num(beam_pos)
249 conf.send_beam(beam_pos)
277
250
278 return redirect('url_abs_conf', conf.id)
251 return redirect('url_abs_conf', conf.id)
279
252
280
253
281 def add_beam(request, id_conf):
254 def add_beam(request, id_conf):
282
255
283 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
256 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
284 confs = Configuration.objects.all()
257 confs = Configuration.objects.all()
285
258
286 if request.method=='GET':
259 if request.method=='GET':
287 #form = ABSBeamEditForm()
288 form = ABSBeamAddForm()
260 form = ABSBeamAddForm()
289
261
290 if request.method=='POST':
262 if request.method=='POST':
291 form = ABSBeamAddForm(request.POST)
263 form = ABSBeamAddForm(request.POST)
292
264
293 beam_data = get_values_from_form(request.POST)
265 beam_data = get_values_from_form(request.POST)
294
266
295 new_beam = ABSBeam(
267 new_beam = ABSBeam(
296 name =beam_data['name'],
268 name = beam_data['name'],
297 antenna =json.dumps(beam_data['antenna']),
269 antenna = json.dumps(beam_data['antenna']),
298 abs_conf=conf,
270 abs_conf = conf,
299 tx =json.dumps(beam_data['tx']),
271 tx = json.dumps(beam_data['tx']),
300 rx =json.dumps(beam_data['rx']),
272 rx = json.dumps(beam_data['rx']),
301 ues =json.dumps(beam_data['ues']),
273 ues = json.dumps(beam_data['ues']),
302 only_rx =json.dumps(beam_data['only_rx'])
274 only_rx = json.dumps(beam_data['only_rx'])
303 )
275 )
304 new_beam.save()
276 new_beam.save()
305 #---Update 6bits configuration and add beam to abs configuration beams list.
306 new_beam.modules_6bits()
307 #new_beam.add_beam2list()
308 messages.success(request, 'Beam: "%s" has been added.' % new_beam.name)
277 messages.success(request, 'Beam: "%s" has been added.' % new_beam.name)
309
278
310 return redirect('url_edit_abs_conf', conf.id)
279 return redirect('url_edit_abs_conf', conf.id)
311
280
312 ###### SIDEBAR ######
281 ###### SIDEBAR ######
313 kwargs = {}
282 kwargs = {}
314
283
315 #kwargs['dev_conf'] = conf.device
284 #kwargs['dev_conf'] = conf.device
316 #kwargs['id_dev'] = conf.device
285 #kwargs['id_dev'] = conf.device
317 kwargs['id_conf'] = conf.id
286 kwargs['id_conf'] = conf.id
318 kwargs['form'] = form
287 kwargs['form'] = form
319 kwargs['title'] = 'ABS Beams'
288 kwargs['title'] = 'ABS Beams'
320 kwargs['suptitle'] = 'Add Beam'
289 kwargs['suptitle'] = 'Add Beam'
321 kwargs['button'] = 'Add'
290 kwargs['button'] = 'Add'
322 kwargs['no_sidebar'] = True
291 kwargs['no_sidebar'] = True
323
292
324 #kwargs['previous'] = conf.get_absolute_url_edit()
293 #kwargs['previous'] = conf.get_absolute_url_edit()
325 kwargs['edit'] = True
294 kwargs['edit'] = True
326
295
327 return render(request, 'abs_add_beam.html', kwargs)
296 return render(request, 'abs_add_beam.html', kwargs)
328
297
329
298
330 def edit_beam(request, id_conf, id_beam):
299 def edit_beam(request, id_conf, id_beam):
331
300
332 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
301 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
333 beam = get_object_or_404(ABSBeam, pk=id_beam)
302 beam = get_object_or_404(ABSBeam, pk=id_beam)
334
303
335 if request.method=='GET':
304 if request.method=='GET':
336 form = ABSBeamEditForm(initial={'beam': beam})
305 form = ABSBeamEditForm(initial={'beam': beam})
337
306
338 if request.method=='POST':
307 if request.method=='POST':
339 form = ABSBeamEditForm(request.POST)
308 form = ABSBeamEditForm(request.POST)
340
309
341 beam_data = get_values_from_form(request.POST)
310 beam_data = get_values_from_form(request.POST)
342
311
343 beam.dict_to_parms(beam_data)
312 beam.dict_to_parms(beam_data)
344 beam.save()
313 beam.save()
345
314
346 messages.success(request, 'Beam: "%s" has been updated.' % beam.name)
315 messages.success(request, 'Beam: "%s" has been updated.' % beam.name)
347
316
348 return redirect('url_edit_abs_conf', conf.id)
317 return redirect('url_edit_abs_conf', conf.id)
349
318
350 ###### SIDEBAR ######
319 ###### SIDEBAR ######
351 kwargs = {}
320 kwargs = {}
352
321
353 kwargs['id_conf'] = conf.id
322 kwargs['id_conf'] = conf.id
354 kwargs['form'] = form
323 kwargs['form'] = form
355 kwargs['title'] = 'ABS Beams'
324 kwargs['title'] = 'ABS Beams'
356 kwargs['suptitle'] = 'Edit Beam'
325 kwargs['suptitle'] = 'Edit Beam'
357 kwargs['button'] = 'Save'
326 kwargs['button'] = 'Save'
358 kwargs['no_sidebar'] = True
327 kwargs['no_sidebar'] = True
359
328
360 #kwargs['previous'] = conf.get_absolute_url_edit()
329 #kwargs['previous'] = conf.get_absolute_url_edit()
361 kwargs['edit'] = True
330 kwargs['edit'] = True
362
331
363 return render(request, 'abs_edit_beam.html', kwargs)
332 return render(request, 'abs_edit_beam.html', kwargs)
364
333
365
334
366
335
367 def remove_beam(request, id_conf, id_beam):
336 def remove_beam(request, id_conf, id_beam):
368
337
369 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
338 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
370 beam = get_object_or_404(ABSBeam, pk=id_beam)
339 beam = get_object_or_404(ABSBeam, pk=id_beam)
371
340
372 if request.method=='POST':
341 if request.method=='POST':
373 if beam:
342 if beam:
374 try:
343 try:
375 beam.remove_beamfromlist()
344 beam.remove_beamfromlist()
376 beam.delete()
345 beam.delete()
377 messages.success(request, 'Beam: "%s" has been deleted.' % beam)
346 messages.success(request, 'Beam: "%s" has been deleted.' % beam)
378 except:
347 except:
379 messages.error(request, 'Unable to delete beam: "%s".' % beam)
348 messages.error(request, 'Unable to delete beam: "%s".' % beam)
380
349
381 return redirect('url_edit_abs_conf', conf.id)
350 return redirect('url_edit_abs_conf', conf.id)
382
351
383 ###### SIDEBAR ######
352 ###### SIDEBAR ######
384 kwargs = {}
353 kwargs = {}
385
354
386 kwargs['object'] = beam
355 kwargs['object'] = beam
387 kwargs['delete'] = True
356 kwargs['delete'] = True
388 kwargs['title'] = 'Delete'
357 kwargs['title'] = 'Delete'
389 kwargs['suptitle'] = 'Beam'
358 kwargs['suptitle'] = 'Beam'
390 kwargs['previous'] = conf.get_absolute_url_edit()
359 kwargs['previous'] = conf.get_absolute_url_edit()
391 return render(request, 'confirm.html', kwargs)
360 return render(request, 'confirm.html', kwargs)
392
361
393
362
394
363
395 def plot_patterns(request, id_conf, id_beam=None):
364 def plot_patterns(request, id_conf, id_beam=None):
396
365
397 kwargs = {}
366 kwargs = {}
398 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
367 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
399 beams = ABSBeam.objects.filter(abs_conf=conf)
368 beams = ABSBeam.objects.filter(abs_conf=conf)
400
369
401 if id_beam:
370 if id_beam:
402 beam = get_object_or_404(ABSBeam, pk=id_beam)
371 beam = get_object_or_404(ABSBeam, pk=id_beam)
403 kwargs['beam'] = beam
372 kwargs['beam'] = beam
404
373
405
374
406 ###### SIDEBAR ######
375 ###### SIDEBAR ######
407
376
408 kwargs['dev_conf'] = conf.device
377 kwargs['dev_conf'] = conf.device
409 kwargs['id_dev'] = conf.device
378 kwargs['id_dev'] = conf.device
410 kwargs['id_conf'] = conf.id
379 kwargs['id_conf'] = conf.id
411 kwargs['abs_beams'] = beams
380 kwargs['abs_beams'] = beams
412 kwargs['title'] = 'ABS Patterns'
381 kwargs['title'] = 'ABS Patterns'
413 kwargs['suptitle'] = conf.name
382 kwargs['suptitle'] = conf.name
414 kwargs['no_sidebar'] = True
383 kwargs['no_sidebar'] = True
415
384
416 return render(request, 'abs_patterns.html', kwargs)
385 return render(request, 'abs_patterns.html', kwargs)
417
386
418
387
419 def plot_pattern(request, id_conf, id_beam, antenna):
388 def plot_pattern(request, id_conf, id_beam, antenna):
420
389
421 if antenna=='down':
390 if antenna=='down':
422 sleep(3)
391 sleep(3)
423
392
424 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
393 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
425 beam = get_object_or_404(ABSBeam, pk=id_beam)
394 beam = get_object_or_404(ABSBeam, pk=id_beam)
426
395
427 name = conf.experiment.name
396 name = conf.experiment.name
428
397
429 just_rx = 1 if json.loads(beam.only_rx)[antenna] else 0
398 just_rx = 1 if json.loads(beam.only_rx)[antenna] else 0
430 phases = json.loads(beam.antenna)['antenna_{}'.format(antenna)]
399 phases = json.loads(beam.antenna)['antenna_{}'.format(antenna)]
431 gain_tx = json.loads(beam.tx)[antenna]
400 gain_tx = json.loads(beam.tx)[antenna]
432 gain_rx = json.loads(beam.rx)[antenna]
401 gain_rx = json.loads(beam.rx)[antenna]
433 ues = json.loads(beam.ues)[antenna]
402 ues = json.loads(beam.ues)[antenna]
434
403
435 newOverJro = overJroShow(name)
404 newOverJro = overJroShow(name)
436 fig = newOverJro.plotPattern2(datetime.today(), phases, gain_tx, gain_rx, ues, just_rx)
405 fig = newOverJro.plotPattern2(datetime.today(), phases, gain_tx, gain_rx, ues, just_rx)
437
406
438 response=HttpResponse(content_type='image/png')
407 response=HttpResponse(content_type='image/png')
439
408
440 fig.canvas.print_png(response)
409 fig.canvas.print_png(response)
441
410
442 return response
411 return response
General Comments 0
You need to be logged in to leave comments. Login now