@@ -1,56 +1,56 | |||
|
1 | 1 | from django import forms |
|
2 | 2 | from .models import ABSConfiguration, ABSBeam |
|
3 | 3 | from .widgets import UpDataWidget, DownDataWidget, EditUpDataWidget, EditDownDataWidget |
|
4 | 4 | from apps.main.models import Configuration |
|
5 | 5 | |
|
6 | 6 | class ABSConfigurationForm(forms.ModelForm): |
|
7 | 7 | def __init__(self, *args, **kwargs): |
|
8 | 8 | super(ABSConfigurationForm, self).__init__(*args, **kwargs) |
|
9 | 9 | #instance = getattr(self, 'instance', None) |
|
10 | 10 | |
|
11 | 11 | #if instance and instance.pk: |
|
12 | 12 | # devices = Device.objects.filter(device_type__name='abs') |
|
13 | 13 | |
|
14 | 14 | #if instance.experiment: |
|
15 | 15 | # experiments = Experiment.objects.filter(pk=instance.experiment.id) |
|
16 | 16 | # self.fields['experiment'].widget.choices = [(experiment.id, experiment) for experiment in experiments] |
|
17 | 17 | |
|
18 | 18 | class Meta: |
|
19 | 19 | model = ABSConfiguration |
|
20 |
exclude = ('type', 'status', 'parameters', 'beam |
|
|
20 | exclude = ('type', 'status', 'parameters', 'active_beam', 'module_status') | |
|
21 | 21 | |
|
22 | 22 | class ABSBeamAddForm(forms.Form): |
|
23 | 23 | |
|
24 | 24 | #abs_conf = forms.CharField(widget=forms.HiddenInput) |
|
25 | 25 | #name = forms.CharField(max_length=60) |
|
26 | 26 | up_data = forms.CharField(widget=UpDataWidget, label='') |
|
27 | 27 | down_data = forms.CharField(widget=DownDataWidget, label='') |
|
28 | 28 | |
|
29 | 29 | def __init__(self, *args, **kwargs): |
|
30 | 30 | super(ABSBeamAddForm, self).__init__(*args, **kwargs) |
|
31 | 31 | #if 'abs_conf' in self.initial: |
|
32 | 32 | # self.fields['abs_conf'].initial = self.initial['abs_conf'] |
|
33 | 33 | #self.fields['name'].initial = 'Beam' |
|
34 | 34 | # self.fields['up_data'].initial = self.initial['abs_conf'] |
|
35 | 35 | # self.fields['down_data'].initial = self.initial['abs_conf'] |
|
36 | 36 | #self.fields['abs_conf'].initial = self.initial['abs_conf'] |
|
37 | 37 | #self.fields['name'].initial = 'Beam' |
|
38 | 38 | #self.fields['up_data'].initial = self.initial['abs_conf'] |
|
39 | 39 | #self.fields['down_data'].initial = self.initial['abs_conf'] |
|
40 | 40 | |
|
41 | 41 | |
|
42 | 42 | |
|
43 | 43 | class ABSBeamEditForm(forms.Form): |
|
44 | 44 | |
|
45 | 45 | #abs_conf = forms.CharField(widget=forms.HiddenInput) |
|
46 | 46 | up_data = forms.CharField(widget=EditUpDataWidget, label='') |
|
47 | 47 | down_data = forms.CharField(widget=EditDownDataWidget, label='') |
|
48 | 48 | |
|
49 | 49 | def __init__(self, *args, **kwargs): |
|
50 | 50 | super(ABSBeamEditForm, self).__init__(*args, **kwargs) |
|
51 | 51 | |
|
52 | 52 | if 'initial' in kwargs: |
|
53 | 53 | if 'beam' in self.initial: |
|
54 | 54 | #self.fields['abs_conf'].initial = self.initial['beam'].abs_conf |
|
55 | 55 | self.fields['up_data'].initial = self.initial['beam'] |
|
56 | 56 | self.fields['down_data'].initial = self.initial['beam'] |
@@ -1,1077 +1,967 | |||
|
1 | 1 | from django.db import models |
|
2 | 2 | from apps.main.models import Configuration |
|
3 | 3 | from django.core.urlresolvers import reverse |
|
4 | 4 | # Create your models here. |
|
5 | 5 | |
|
6 | 6 | import ast |
|
7 | 7 | import socket |
|
8 | 8 | import json |
|
9 | 9 | import requests |
|
10 | 10 | import struct |
|
11 | 11 | import sys, time |
|
12 | 12 | |
|
13 | 13 | import multiprocessing |
|
14 | 14 | |
|
15 | 15 | |
|
16 | 16 | antenna_default = json.dumps({ |
|
17 | 17 | "antenna_up": [[0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5], |
|
18 | 18 | [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5], |
|
19 | 19 | [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5], |
|
20 | 20 | [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5], |
|
21 | 21 | [0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0], |
|
22 | 22 | [0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0], |
|
23 | 23 | [0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0], |
|
24 | 24 | [0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0] |
|
25 | 25 | ] |
|
26 | 26 | , |
|
27 | 27 | "antenna_down": [[0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5], |
|
28 | 28 | [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5], |
|
29 | 29 | [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5], |
|
30 | 30 | [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5], |
|
31 | 31 | [0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0], |
|
32 | 32 | [0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0], |
|
33 | 33 | [0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0], |
|
34 | 34 | [0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0]], |
|
35 | 35 | }) |
|
36 | 36 | |
|
37 | 37 | |
|
38 | 38 | tx_default = json.dumps({ |
|
39 | 39 | "up": [[1,1,1,1,0,0,0,0], |
|
40 | 40 | [1,1,1,1,0,0,0,0], |
|
41 | 41 | [1,1,1,1,0,0,0,0], |
|
42 | 42 | [1,1,1,1,0,0,0,0], |
|
43 | 43 | [0,0,0,0,1,1,1,1], |
|
44 | 44 | [0,0,0,0,1,1,1,1], |
|
45 | 45 | [0,0,0,0,1,1,1,1], |
|
46 | 46 | [0,0,0,0,1,1,1,1]], |
|
47 | 47 | |
|
48 | 48 | "down": [[1,1,1,1,0,0,0,0], |
|
49 | 49 | [1,1,1,1,0,0,0,0], |
|
50 | 50 | [1,1,1,1,0,0,0,0], |
|
51 | 51 | [1,1,1,1,0,0,0,0], |
|
52 | 52 | [0,0,0,0,1,1,1,1], |
|
53 | 53 | [0,0,0,0,1,1,1,1], |
|
54 | 54 | [0,0,0,0,1,1,1,1], |
|
55 | 55 | [0,0,0,0,1,1,1,1]], |
|
56 | 56 | }) |
|
57 | 57 | |
|
58 | 58 | rx_default = json.dumps({ |
|
59 | 59 | "up": [[1,1,1,1,0,0,0,0], |
|
60 | 60 | [1,1,1,1,0,0,0,0], |
|
61 | 61 | [1,1,1,1,0,0,0,0], |
|
62 | 62 | [1,1,1,1,0,0,0,0], |
|
63 | 63 | [0,0,0,0,1,1,1,1], |
|
64 | 64 | [0,0,0,0,1,1,1,1], |
|
65 | 65 | [0,0,0,0,1,1,1,1], |
|
66 | 66 | [0,0,0,0,1,1,1,1]], |
|
67 | 67 | |
|
68 | 68 | "down": [[1,1,1,1,0,0,0,0], |
|
69 | 69 | [1,1,1,1,0,0,0,0], |
|
70 | 70 | [1,1,1,1,0,0,0,0], |
|
71 | 71 | [1,1,1,1,0,0,0,0], |
|
72 | 72 | [0,0,0,0,1,1,1,1], |
|
73 | 73 | [0,0,0,0,1,1,1,1], |
|
74 | 74 | [0,0,0,0,1,1,1,1], |
|
75 | 75 | [0,0,0,0,1,1,1,1]], |
|
76 | 76 | }) |
|
77 | 77 | |
|
78 | 78 | conf_default = {} |
|
79 | 79 | status_default = {} |
|
80 | 80 | for i in range(1,65): |
|
81 | 81 | conf_default[str(i)] = "" |
|
82 | 82 | status_default[str(i)] = 0 |
|
83 | 83 | |
|
84 | 84 | ues_default = json.dumps({ |
|
85 | 85 | "up": [0.533333,0.00000,1.06667,0.00000], |
|
86 | 86 | "down": [0.533333,0.00000,1.06667,0.00000] |
|
87 | 87 | }) |
|
88 | 88 | |
|
89 | 89 | onlyrx_default = json.dumps({ |
|
90 | 90 | "up": False, |
|
91 | 91 | "down": False |
|
92 | 92 | }) |
|
93 | 93 | |
|
94 | 94 | def up_convertion(cadena): |
|
95 | 95 | valores = [] |
|
96 | 96 | for c in cadena: |
|
97 | 97 | if c == 1.0: valores=valores+['000'] |
|
98 | 98 | if c == 2.0: valores=valores+['001'] |
|
99 | 99 | if c == 3.0: valores=valores+['010'] |
|
100 | 100 | if c == 0.0: valores=valores+['011'] |
|
101 | 101 | if c == 0.5: valores=valores+['100'] |
|
102 | 102 | if c == 1.5: valores=valores+['101'] |
|
103 | 103 | if c == 2.5: valores=valores+['110'] |
|
104 | 104 | if c == 3.5: valores=valores+['111'] |
|
105 | 105 | |
|
106 | 106 | return valores |
|
107 | 107 | |
|
108 | 108 | def up_conv_bits(value): |
|
109 | 109 | |
|
110 | 110 | if value == 1.0: bits="000" |
|
111 | 111 | if value == 2.0: bits="001" |
|
112 | 112 | if value == 3.0: bits="010" |
|
113 | 113 | if value == 0.0: bits="011" |
|
114 | 114 | if value == 0.5: bits="100" |
|
115 | 115 | if value == 1.5: bits="101" |
|
116 | 116 | if value == 2.5: bits="110" |
|
117 | 117 | if value == 3.5: bits="111" |
|
118 | 118 | |
|
119 | 119 | return bits |
|
120 | 120 | |
|
121 | 121 | def down_convertion(cadena): |
|
122 | 122 | valores = [] |
|
123 | 123 | for c in cadena: |
|
124 | 124 | if c == 1.0: valores=valores+['000'] |
|
125 | 125 | if c == 2.0: valores=valores+['001'] |
|
126 | 126 | if c == 3.0: valores=valores+['010'] |
|
127 | 127 | if c == 0.0: valores=valores+['011'] |
|
128 | 128 | if c == 0.5: valores=valores+['100'] |
|
129 | 129 | if c == 1.5: valores=valores+['101'] |
|
130 | 130 | if c == 2.5: valores=valores+['110'] |
|
131 | 131 | if c == 3.5: valores=valores+['111'] |
|
132 | 132 | |
|
133 | 133 | return valores |
|
134 | 134 | |
|
135 | 135 | def down_conv_bits(value): |
|
136 | 136 | |
|
137 | 137 | if value == 1.0: bits="000" |
|
138 | 138 | if value == 2.0: bits="001" |
|
139 | 139 | if value == 3.0: bits="010" |
|
140 | 140 | if value == 0.0: bits="011" |
|
141 | 141 | if value == 0.5: bits="100" |
|
142 | 142 | if value == 1.5: bits="101" |
|
143 | 143 | if value == 2.5: bits="110" |
|
144 | 144 | if value == 3.5: bits="111" |
|
145 | 145 | |
|
146 | 146 | return bits |
|
147 | 147 | |
|
148 | 148 | def ip2position(module_number): |
|
149 | 149 | j=0 |
|
150 | 150 | i=0 |
|
151 | 151 | for x in range(0,module_number-1): |
|
152 | 152 | j=j+1 |
|
153 | 153 | if j==8: |
|
154 | 154 | i=i+1 |
|
155 | 155 | j=0 |
|
156 | 156 | |
|
157 | 157 | pos = [i,j] |
|
158 | 158 | return pos |
|
159 | 159 | |
|
160 | 160 | |
|
161 | 161 | def fromBinary2Char(binary_string): |
|
162 | 162 | number = int(binary_string, 2) |
|
163 | 163 | #Plus 33 to avoid more than 1 characters values such as: '\x01'-'\x1f' |
|
164 | 164 | number = number + 33 |
|
165 | 165 | char = chr(number) |
|
166 | 166 | return char |
|
167 | 167 | |
|
168 | 168 | def fromChar2Binary(char): |
|
169 | 169 | number = ord(char) - 33 |
|
170 | 170 | #Minus 33 to get the real value |
|
171 | 171 | bits = bin(number)[2:] |
|
172 | 172 | #To ensure we have a string with 6bits |
|
173 | 173 | if len(bits) < 6: |
|
174 | 174 | bits = bits.zfill(6) |
|
175 | 175 | return bits |
|
176 | 176 | |
|
177 | 177 | |
|
178 | def change_beam_for_multiprocessing(module): | |
|
179 | ||
|
180 | for i in range (1,50): | |
|
181 | beam_pos = 0 | |
|
182 | module_address = ('192.168.1.'+str(module), 5500) | |
|
183 | header = 'JROABSCeCnModCnMod0100000' | |
|
184 | numbers = len(str(beam_pos)) | |
|
185 | function = 'CHGB' | |
|
186 | ||
|
187 | message_tx = header+str(numbers)+function+str(beam_pos)+'0' | |
|
188 | ||
|
189 | # Create the datagram socket | |
|
190 | sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
|
191 | sock.connect(module_address) | |
|
192 | ||
|
193 | sock.send(message_tx) | |
|
194 | #t = sock.recv(1024) | |
|
195 | sock.close() | |
|
196 | sock = None | |
|
197 | ||
|
198 | ||
|
199 | time.sleep(0.2) | |
|
200 | ||
|
201 | ||
|
202 | beam_pos = 1 | |
|
203 | numbers = len(str(beam_pos)) | |
|
204 | ||
|
205 | message_tx = header+str(numbers)+function+str(beam_pos)+'0' | |
|
206 | ||
|
207 | # Create the datagram socket | |
|
208 | sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
|
209 | sock.connect(module_address) | |
|
210 | sock.send(message_tx) | |
|
211 | sock.close() | |
|
212 | sock = None | |
|
213 | ||
|
214 | time.sleep(0.2) | |
|
215 | ||
|
216 | ||
|
217 | ||
|
218 | 178 | class ABSConfiguration(Configuration): |
|
219 |
beam |
|
|
179 | active_beam = models.CharField(verbose_name='Active Beam', max_length=20000, default="{}") | |
|
220 | 180 | module_status = models.CharField(verbose_name='Module Status', max_length=10000, default=json.dumps(status_default)) |
|
221 | 181 | |
|
222 | 182 | class Meta: |
|
223 | 183 | db_table = 'abs_configurations' |
|
224 | 184 | |
|
225 | 185 | def get_absolute_url_plot(self): |
|
226 | 186 | return reverse('url_plot_abs_patterns', args=[str(self.id)]) |
|
227 | 187 | |
|
228 | 188 | |
|
229 | 189 | def parms_to_dict(self): |
|
230 | 190 | |
|
231 | 191 | parameters = {} |
|
232 | 192 | |
|
233 | 193 | parameters['device_id'] = self.device.id |
|
234 | 194 | parameters['name'] = self.name |
|
235 | 195 | parameters['beams'] = {} |
|
236 | 196 | |
|
237 | beams = ast.literal_eval(self.beams) | |
|
197 | beams = ABSBeam.objects.get(pk=self.id) | |
|
238 | 198 | b=1 |
|
239 | 199 | for beam in beams: |
|
240 | absbeam = ABSBeam.objects.get(pk=beams[beam]) | |
|
241 |
parameters['beams']['beam'+str(b)] = |
|
|
200 | #absbeam = ABSBeam.objects.get(pk=beams[beam]) | |
|
201 | parameters['beams']['beam'+str(b)] = beam.parms_to_dict()#absbeam.parms_to_dict() | |
|
242 | 202 | b+=1 |
|
243 | 203 | |
|
244 | 204 | return parameters |
|
245 | 205 | |
|
246 | 206 | def get_beams(self, **kwargs): |
|
247 | 207 | ''' |
|
248 | 208 | This function returns ABS Configuration beams |
|
249 | 209 | ''' |
|
250 | 210 | return ABSBeam.objects.filter(abs_conf=self.pk, **kwargs) |
|
251 | 211 | |
|
252 | 212 | def clone(self, **kwargs): |
|
253 | 213 | |
|
254 | 214 | beams = self.get_beams() |
|
255 | 215 | self.pk = None |
|
256 | 216 | self.id = None |
|
257 | 217 | for attr, value in kwargs.items(): |
|
258 | 218 | setattr(self, attr, value) |
|
259 | 219 | self.save() |
|
260 | 220 | |
|
261 | 221 | for beam in beams: |
|
262 | 222 | beam.clone(abs_conf=self) |
|
263 | 223 | |
|
264 | 224 | return self |
|
265 | 225 | |
|
266 | 226 | |
|
267 | 227 | def module_conf(self, module_num, beams): |
|
268 | 228 | """ |
|
269 | 229 | This function creates beam configurations for one abs module. |
|
270 | 230 | """ |
|
271 | 231 | ip_address = self.device.ip_address |
|
272 | 232 | ip_address = ip_address.split('.') |
|
273 | 233 | module_seq = (ip_address[0],ip_address[1],ip_address[2]) |
|
274 | 234 | dot = '.' |
|
275 | 235 | module_ip = dot.join(module_seq)+'.'+str(module_num) |
|
276 | 236 | module_port = self.device.port_address |
|
277 | 237 | write_route = 'http://'+module_ip+':'+str(module_port)+'/configure' |
|
278 | 238 | |
|
279 | 239 | header = 'JROABSCeCnModCnMod01000108SNDFexperimento1.ab1' |
|
280 | 240 | module = 'ABS_'+str(module_num) |
|
281 | 241 | bs = '' #{} |
|
282 | 242 | i=1 |
|
283 | 243 | #beams = {1: '001000', 2: '010001', 3: '010010', 4: '000011', 5: '101100', 6: '101101', |
|
284 | 244 | # 7: '110110', 8: '111111', 9: '000000', 10: '001001', 11: '010010', 12: '011011'} |
|
285 | 245 | for beam in beams: |
|
286 | 246 | #bs[i] = fromBinary2Char(beam.module_6bits(module_num)) |
|
287 | 247 | bs = bs + fromBinary2Char(beam.module_6bits(module_num)) |
|
288 | 248 | i=i+1 |
|
289 | 249 | |
|
290 | 250 | beams = bs |
|
291 | 251 | |
|
292 | 252 | parameters = {} |
|
293 | 253 | parameters['header'] = header |
|
294 | 254 | parameters['module'] = module |
|
295 | 255 | parameters['beams'] = beams #json.dumps(beams) |
|
296 | 256 | print parameters['beams'] |
|
297 | 257 | answer = '' |
|
298 | 258 | |
|
299 | 259 | try: |
|
300 | 260 | r_write = requests.post(write_route, parameters, timeout=0.5) |
|
301 | 261 | answer = r_write.json() |
|
302 | 262 | self.message = answer['message'] |
|
303 | 263 | except: |
|
304 | 264 | self.message = "Could not write ABS parameters" |
|
305 | 265 | return 0 |
|
306 | 266 | return 1 |
|
307 | 267 | |
|
308 | 268 | def read_module(self, module): |
|
309 | 269 | |
|
310 | 270 | """ |
|
311 | 271 | Read out-bits (up-down) of 1 abs module NOT for Configuration |
|
312 | 272 | """ |
|
313 | 273 | |
|
314 | 274 | parameters = {} |
|
315 | 275 | ip_address = self.device.ip_address |
|
316 | 276 | ip_address = ip_address.split('.') |
|
317 | 277 | module_seq = (ip_address[0],ip_address[1],ip_address[2]) |
|
318 | 278 | dot = '.' |
|
319 | 279 | module_ip = dot.join(module_seq)+'.'+str(module) |
|
320 | 280 | module_port = self.device.port_address |
|
321 | 281 | read_route = 'http://'+module_ip+':'+str(module_port)+'/read' |
|
322 | 282 | |
|
323 | 283 | print(read_route) |
|
324 | 284 | |
|
325 | 285 | answer = '' |
|
326 | 286 | module_bits = '' |
|
327 | 287 | |
|
328 | 288 | try: |
|
329 | 289 | r_write = requests.get(read_route, timeout=0.7) |
|
330 | 290 | answer = r_write.json() |
|
331 | 291 | self.message = answer['message'] |
|
332 | 292 | module_bits = answer['allbits'] |
|
333 | 293 | except: |
|
334 | 294 | #message = "Could not read ABS parameters" |
|
335 | 295 | return 0 |
|
336 | 296 | |
|
337 | 297 | return module_bits |
|
338 | 298 | |
|
299 | def status_device(self): | |
|
300 | """ | |
|
301 | This function gets the status of each abs module. It sends GET method to Web Application | |
|
302 | in Python Bottle. | |
|
303 | """ | |
|
304 | ip_address = self.device.ip_address | |
|
305 | ip_address = ip_address.split('.') | |
|
306 | module_seq = (ip_address[0],ip_address[1],ip_address[2]) | |
|
307 | dot = '.' | |
|
308 | module_port = self.device.port_address | |
|
309 | ||
|
310 | modules_status = json.loads(self.module_status) | |
|
311 | ||
|
312 | for i in range(1,65): | |
|
313 | module_ip = dot.join(module_seq)+'.'+str(i) | |
|
314 | print module_ip | |
|
315 | ||
|
316 | route = 'http://'+module_ip+':'+str(module_port)+'/hello' | |
|
317 | ||
|
318 | try: | |
|
319 | r = requests.get(route, timeout=0.7) | |
|
320 | modules_status[str(i)] = 1 | |
|
321 | except: | |
|
322 | modules_status[str(i)] = 0 | |
|
323 | pass | |
|
324 | ||
|
325 | self.message = 'ABS modules Status have been updated.' | |
|
326 | self.module_status=json.dumps(modules_status) | |
|
327 | self.save() | |
|
328 | ||
|
329 | return | |
|
330 | ||
|
339 | 331 | |
|
340 | 332 | def write_device(self): |
|
341 | 333 | """ |
|
342 | 334 | This function sends the beams list to every abs module. |
|
343 | 335 | It needs 'module_conf' function |
|
344 | 336 | """ |
|
345 | 337 | |
|
346 | 338 | ###beams_list = ast.literal_eval(self.beams) |
|
347 | 339 | ###beams = [] |
|
348 | 340 | beams = ABSBeam.objects.filter(abs_conf=self) |
|
349 | 341 | ###for bl in range(1,len(beams_list)+1): |
|
350 | 342 | ### b = ABSBeam.objects.get(pk=beams_list['beam'+str(bl)]) |
|
351 | 343 | ### beams.append(b) |
|
352 | 344 | |
|
353 | 345 | #---Write each abs module--- |
|
354 | 346 | if beams: |
|
355 | 347 | beams_status = ast.literal_eval(self.module_status) |
|
356 | 348 | for i in range(62,65): #(62,65) |
|
357 | 349 | try: |
|
358 | 350 | answer = self.module_conf(i, beams) |
|
359 | 351 | beams_status[str(i)] = 1 |
|
360 | 352 | self.module_status = json.dumps(beams_status) |
|
361 | 353 | self.save() |
|
362 | 354 | #self.module_conf(63,beams) |
|
363 | 355 | #beams_status[str(63)] = 1 |
|
364 | 356 | #self.module_status = json.dumps(beams_status) |
|
365 | 357 | except: |
|
366 | 358 | beams_status[str(i)] = 0 |
|
367 | 359 | self.module_status = json.dumps(beams_status) |
|
368 | 360 | self.save() |
|
369 | 361 | answer = 0 |
|
370 | 362 | return 0 |
|
371 | 363 | else: |
|
372 | 364 | self.message = "ABS Configuration does not have beams" |
|
373 | 365 | return 0 |
|
374 | 366 | |
|
375 | 367 | #self.device.status = 1 |
|
376 | 368 | ## |
|
377 | 369 | if answer==1: |
|
378 | 370 | self.message = "ABS Beams List have been sent to ABS Modules" |
|
379 | 371 | else: |
|
380 | 372 | self.message = "Could not read ABS parameters" |
|
381 | 373 | |
|
382 | 374 | ## |
|
383 | 375 | self.save() |
|
384 | 376 | return 1 |
|
385 | 377 | |
|
386 | 378 | |
|
387 | 379 | def write_module(self, module): |
|
388 | 380 | |
|
389 | 381 | """ |
|
390 | 382 | Send configuration to one abs module |
|
391 | 383 | """ |
|
392 | 384 | |
|
393 | 385 | parameters = {} |
|
394 | 386 | ip_address = self.abs_conf.device.ip_address |
|
395 | 387 | ip_address = ip_address.split('.') |
|
396 | 388 | module_seq = (ip_address[0],ip_address[1],ip_address[2]) |
|
397 | 389 | dot = '.' |
|
398 | 390 | module_ip = dot.join(module_seq)+'.'+str(module) |
|
399 | 391 | module_port = self.abs_conf.device.port_address |
|
400 | 392 | write_route = 'http://'+module_ip+':'+str(module_port)+'/configure' |
|
401 | 393 | |
|
402 | 394 | #print write_route |
|
403 | 395 | |
|
404 | 396 | header = 'JROABSCeCnModCnMod01000108SNDFexperimento1.ab1' |
|
405 | 397 | module = 'ABS_'+str(module) |
|
406 | 398 | beams = {1: '001000', 2: '010001', 3: '010010', 4: '000011', 5: '101100', 6: '101101', |
|
407 | 399 | 7: '110110', 8: '111111', 9: '000000', 10: '001001', 11: '010010', 12: '011011'} |
|
408 | 400 | |
|
409 | 401 | parameters['header'] = header |
|
410 | 402 | parameters['module'] = module |
|
411 | 403 | parameters['beams'] = json.dumps(beams) |
|
412 | 404 | |
|
413 | 405 | answer = '' |
|
414 | 406 | |
|
415 | 407 | try: |
|
416 | 408 | r_write = requests.post(write_route, parameters, timeout=0.5) |
|
417 | 409 | answer = r_write.json() |
|
418 | 410 | self.message = answer['message'] |
|
419 | 411 | except: |
|
420 | 412 | self.message = "Could not write ABS parameters" |
|
421 | 413 | return 0 |
|
422 | 414 | |
|
423 | 415 | |
|
424 | 416 | #self.device.status = int(answer['status']) |
|
425 | 417 | |
|
426 | 418 | return 1 |
|
427 | 419 | |
|
428 | 420 | |
|
429 | 421 | def beam_selector(self, module, beam_pos): |
|
430 | 422 | """ |
|
431 | 423 | This function selects the beam number for one absmodule. |
|
432 | 424 | """ |
|
433 | 425 | |
|
434 | 426 | if beam_pos > 0: |
|
435 | 427 | beam_pos = beam_pos - 1 |
|
436 | 428 | else: |
|
437 | 429 | beam_pos = 0 |
|
438 | 430 | |
|
439 | 431 | #El indice del apunte debe ser menor que el numero total de apuntes |
|
440 | 432 | #El servidor tcp en el embebido comienza a contar desde 0 |
|
441 |
beams_list = |
|
|
433 | beams_list = ABSBeam.objects.filter(abs_conf=self) | |
|
442 | 434 | if len(beams_list) < beam_pos: |
|
443 | 435 | return 0 |
|
444 | 436 | |
|
445 | 437 | flag = 1 |
|
446 | 438 | if beam_pos>9: |
|
447 | 439 | flag = 2 |
|
448 | 440 | |
|
449 | 441 | module_address = ('192.168.1.'+str(module), 5500) |
|
450 | 442 | header = 'JROABSCeCnModCnMod0100000' |
|
451 | 443 | numbers = len(str(beam_pos)) |
|
452 | 444 | function = 'CHGB' |
|
453 | 445 | |
|
454 | 446 | message_tx = header+str(numbers)+function+str(beam_pos)+'0' |
|
455 | 447 | |
|
456 | 448 | # Create the datagram socket |
|
457 | 449 | sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
|
458 | 450 | #sock.connect(module_address) |
|
459 | 451 | try: |
|
460 | 452 | sock.connect(module_address) |
|
461 | 453 | sock.send(message_tx) |
|
462 | 454 | sock.close() |
|
463 | 455 | print("Writing abs module:"+module_address[0]+"...") |
|
464 | 456 | except: |
|
465 | 457 | sock = None |
|
466 | 458 | print("Problem writing abs module:"+module_address[0]) |
|
467 | 459 | return 0 |
|
468 | 460 | |
|
469 | 461 | return 1 |
|
470 | 462 | |
|
471 | 463 | |
|
472 | 464 | def change_beam(self, beam_pos): |
|
473 | 465 | """ |
|
474 | 466 | This function selects the beam number for all absmodules. |
|
475 | 467 | """ |
|
476 | 468 | for i in range(1,65): |
|
477 | 469 | try: |
|
478 | 470 | self.beam_selector(i,beam_pos) |
|
479 | 471 | except: |
|
480 | 472 | print("Problem with module: 192.168.1."+str(i)) |
|
481 | 473 | self.message = "Problem with module: 192.168.1."+str(i) |
|
482 | 474 | #return 0 |
|
483 | 475 | return 1 |
|
484 | 476 | |
|
485 | 477 | |
|
486 | 478 | def send_beam_num(self, beam_pos): |
|
487 | 479 | """ |
|
488 | 480 | This function connects to a multicast group and sends the beam number |
|
489 | 481 | to all abs modules. |
|
490 | 482 | """ |
|
491 | 483 | |
|
492 | 484 | if beam_pos > 0: |
|
493 | 485 | beam_pos = beam_pos - 1 |
|
494 | 486 | else: |
|
495 | 487 | beam_pos = 0 |
|
496 | 488 | |
|
497 | 489 | #El indice del apunte debe ser menor que el numero total de apuntes |
|
498 | 490 | #El servidor tcp en el embebido comienza a contar desde 0 |
|
499 |
beams_list = |
|
|
491 | beams_list = ABSBeam.objects.filter(abs_conf=self) | |
|
500 | 492 | if len(beams_list) < beam_pos: |
|
501 | 493 | return 0 |
|
502 | 494 | |
|
503 | 495 | flag = 1 |
|
504 | 496 | if beam_pos>9: |
|
505 | 497 | flag = 2 |
|
506 | 498 | |
|
507 | 499 | header = 'JROABSCeCnModCnMod0100000' |
|
508 | 500 | flag = str(flag) |
|
509 | 501 | function = 'CHGB' |
|
510 | 502 | message_tx = header+flag+function+str(beam_pos)+'0' |
|
511 | 503 | |
|
512 | 504 | multicast_group = '224.3.29.71' |
|
513 | 505 | server_address = ('',10000) |
|
514 | 506 | |
|
515 | 507 | # Create the socket |
|
516 | 508 | sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) |
|
517 | 509 | # Bind to the server address |
|
518 | 510 | sock.bind(server_address) |
|
519 | 511 | # Telling the OS add the socket to the multicast on all interfaces |
|
520 | 512 | group = socket.inet_aton(multicast_group) |
|
521 | 513 | mreq = struct.pack('4sL', group, socket.INADDR_ANY) |
|
522 | 514 | sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq) |
|
523 | 515 | |
|
524 | 516 | #print 'sending acknowledgement to all: \n' + message_tx |
|
525 | 517 | sock.sendto(message_tx, (multicast_group, 10000)) |
|
526 | 518 | sock.close() |
|
527 | 519 | sock = None |
|
528 | 520 | |
|
529 | 521 | return 1 |
|
530 | 522 | |
|
531 | 523 | def test1(self): |
|
532 | 524 | t1 = time.time() |
|
533 | 525 | t2 = 0 |
|
534 | 526 | while (t2-t1)<100:#300 |
|
535 | 527 | t2 = time.time() |
|
536 | 528 | self.send_beam_num(2) |
|
537 | 529 | time.sleep(0.04) |
|
538 | 530 | self.send_beam_num(1) |
|
539 | 531 | time.sleep(0.04) |
|
540 | 532 | return |
|
541 | 533 | |
|
542 | 534 | def change_procs_test1(self, module): |
|
543 | 535 | |
|
544 | 536 | for i in range (1,300):#300 |
|
545 | 537 | beam_pos = 1 |
|
546 | 538 | module_address = ('192.168.1.'+str(module), 5500) |
|
547 | 539 | header = 'JROABSCeCnModCnMod0100000' |
|
548 | 540 | numbers = len(str(beam_pos)) |
|
549 | 541 | function = 'CHGB' |
|
550 | 542 | |
|
551 | 543 | message_tx = header+str(numbers)+function+str(beam_pos)+'0' |
|
552 | 544 | |
|
553 | 545 | # Create the datagram socket |
|
554 | 546 | sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
|
555 | 547 | sock.connect(module_address) |
|
556 | 548 | |
|
557 | 549 | sock.send(message_tx) |
|
558 | 550 | #t = sock.recv(1024) |
|
559 | 551 | sock.close() |
|
560 | 552 | sock = None |
|
561 | 553 | |
|
562 | 554 | |
|
563 | 555 | time.sleep(0.04) |
|
564 | 556 | |
|
565 | 557 | |
|
566 | 558 | beam_pos = 0 |
|
567 | 559 | numbers = len(str(beam_pos)) |
|
568 | 560 | |
|
569 | 561 | message_tx = header+str(numbers)+function+str(beam_pos)+'0' |
|
570 | 562 | |
|
571 | 563 | # Create the datagram socket |
|
572 | 564 | sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
|
573 | 565 | sock.connect(module_address) |
|
574 | 566 | sock.send(message_tx) |
|
575 | 567 | sock.close() |
|
576 | 568 | sock = None |
|
577 | 569 | |
|
578 | 570 | time.sleep(0.04) |
|
579 | 571 | |
|
580 | 572 | |
|
581 | 573 | def multi_procs_test1(self): |
|
582 | 574 | |
|
583 | 575 | """ |
|
584 | 576 | This function sends the beam number to all abs modules using multiprocessing. |
|
585 | 577 | """ |
|
586 | 578 | |
|
587 | 579 | #if __name__ == "__main__": |
|
588 | 580 | size = 10000000 # Number of random numbers to add |
|
589 | 581 | procs = 65 # (Number-1) of processes to create (absmodule) |
|
590 | 582 | |
|
591 | 583 | # Create a list of jobs and then iterate through |
|
592 | 584 | # the number of processes appending each process to |
|
593 | 585 | # the job list |
|
594 | 586 | jobs = [] |
|
595 | 587 | for i in range(1, procs): |
|
596 | 588 | |
|
597 | 589 | process = multiprocessing.Process(target=self.change_procs_test1,args=(i,)) |
|
598 | 590 | jobs.append(process) |
|
599 | 591 | #print jobs |
|
600 | 592 | |
|
601 | 593 | # Start the processes (i.e. calculate the random number lists) |
|
602 | 594 | for j in jobs: |
|
603 | 595 | #time.sleep(0.4) |
|
604 | 596 | #print j |
|
605 | 597 | j.start() |
|
606 | 598 | |
|
607 | 599 | # Ensure all of the processes have finished |
|
608 | 600 | for j in jobs: |
|
609 | 601 | j.join() |
|
610 | 602 | |
|
611 | 603 | print("List processing complete.") |
|
612 | 604 | return 1 |
|
613 | 605 | |
|
614 | 606 | |
|
615 | 607 | |
|
616 | 608 | def multi_procs_test2(self): |
|
617 | 609 | """ |
|
618 | 610 | This function use multiprocessing python library. Importing Pool we can select |
|
619 | 611 | the number of cores we want to use |
|
620 | 612 | After 'nproc' linux command, we know how many cores computer has. |
|
621 | 613 | NOT WORKING |
|
622 | 614 | """ |
|
623 | 615 | import multiprocessing |
|
624 | 616 | pool = multiprocessing.Pool(3) # cores |
|
625 | 617 | |
|
626 | 618 | tasks = [] |
|
627 | 619 | procs = 65 |
|
628 | 620 | for i in range(62, procs): |
|
629 | 621 | tasks.append( (i,)) |
|
630 | 622 | #print tasks |
|
631 | 623 | #pool.apply_async(self.change_procs_test1, 62) |
|
632 | 624 | results = [pool.apply( self.change_procs_test1, t ) for t in tasks] |
|
633 | 625 | #for result in results: |
|
634 | 626 | #result.get() |
|
635 | 627 | #(plotNum, plotFilename) = result.get() |
|
636 | 628 | #print("Result: plot %d written to %s" % (plotNum, plotFilename) ) |
|
637 | 629 | |
|
638 | 630 | return 1 |
|
639 | 631 | |
|
640 | 632 | |
|
641 | 633 | def multi_procs_test3(self): |
|
642 | 634 | """ |
|
643 | 635 | This function use multiprocessing python library. Importing Pool we can select |
|
644 | 636 | the number of cores we want to use |
|
645 | 637 | After 'nproc' linux command, we know how many cores computer has. |
|
646 | 638 | """ |
|
647 | 639 | from multiprocessing import Pool |
|
648 | 640 | import time |
|
649 | 641 | |
|
650 | 642 | def f(x): |
|
651 | 643 | return x*x |
|
652 | 644 | |
|
653 | 645 | tasks = [] |
|
654 | 646 | procs = 65 |
|
655 | 647 | pool = Pool(processes=4) |
|
656 | 648 | |
|
657 | 649 | #for i in range(62, procs): |
|
658 | 650 | #result = pool.map(f, range(62,65)) |
|
659 | 651 | it = pool.imap(self.change_procs_test1, range(62,65)) |
|
660 | 652 | #result.get(timeout=5) |
|
661 | 653 | |
|
662 | 654 | return 1 |
|
663 | 655 | |
|
664 | 656 | |
|
665 | 657 | def f(x): |
|
666 | 658 | print x |
|
667 | 659 | return |
|
668 | 660 | |
|
669 | 661 | def multi_procs_test4(self): |
|
670 | 662 | import multiprocessing as mp |
|
671 | 663 | |
|
672 | 664 | |
|
673 | 665 | num_workers = mp.cpu_count() |
|
674 | 666 | |
|
675 | 667 | pool = mp.Pool(num_workers) |
|
676 | 668 | procs = 65 |
|
677 | 669 | for i in range(62, procs): |
|
678 | 670 | #for task in tasks: |
|
679 | 671 | pool.apply_async(self.f, args = (i,)) |
|
680 | 672 | |
|
681 | 673 | pool.close() |
|
682 | 674 | pool.join() |
|
683 | 675 | |
|
684 | 676 | return 1 |
|
685 | 677 | |
|
686 | 678 | |
|
687 | def status_device(self): | |
|
688 | ||
|
689 | return 1 | |
|
690 | ||
|
691 | 679 | |
|
692 | 680 | |
|
693 | 681 | class ABSBeam(models.Model): |
|
694 | 682 | |
|
695 | 683 | name = models.CharField(max_length=60, default='Beam') |
|
696 | 684 | antenna = models.CharField(verbose_name='Antenna', max_length=1000, default=antenna_default) |
|
697 | 685 | abs_conf = models.ForeignKey(ABSConfiguration, null=True, verbose_name='ABS Configuration') |
|
698 | 686 | tx = models.CharField(verbose_name='Tx', max_length=1000, default=tx_default) |
|
699 | 687 | rx = models.CharField(verbose_name='Rx', max_length=1000, default=rx_default) |
|
700 | 688 | s_time = models.TimeField(verbose_name='Star Time', default='00:00:00') |
|
701 | 689 | e_time = models.TimeField(verbose_name='End Time', default='23:59:59') |
|
702 | 690 | modules_conf = models.CharField(verbose_name='Modules', max_length=2000, default=json.dumps(conf_default)) |
|
703 | 691 | ues = models.CharField(verbose_name='Ues', max_length=100, default=ues_default) |
|
704 | 692 | only_rx = models.CharField(verbose_name='Only RX', max_length=40, default=onlyrx_default) |
|
705 | 693 | |
|
706 | 694 | class Meta: |
|
707 | 695 | db_table = 'abs_beams' |
|
708 | 696 | |
|
709 | 697 | def __unicode__(self): |
|
710 | 698 | return u'%s' % (self.name) |
|
711 | 699 | |
|
712 | 700 | def parms_to_dict(self): |
|
713 | 701 | |
|
714 | 702 | #Update data |
|
715 | 703 | self.modules_6bits() |
|
716 | 704 | |
|
717 | 705 | parameters = {} |
|
718 | 706 | |
|
719 | 707 | parameters['name'] = self.name |
|
720 | 708 | parameters['antenna'] = ast.literal_eval(self.antenna) |
|
721 | 709 | parameters['abs_conf'] = self.abs_conf.name |
|
722 | 710 | parameters['tx'] = ast.literal_eval(self.tx) |
|
723 | 711 | parameters['rx'] = ast.literal_eval(self.rx) |
|
724 | 712 | parameters['s_time'] = self.s_time.strftime("%H:%M:%S") |
|
725 | 713 | parameters['e_time'] = self.e_time.strftime("%H:%M:%S") |
|
726 | 714 | parameters['configuration'] = ast.literal_eval(self.modules_conf) |
|
727 | 715 | parameters['ues'] = ast.literal_eval(self.ues) |
|
728 | 716 | parameters['only_rx'] = json.loads(self.only_rx) |
|
729 | 717 | |
|
730 | 718 | return parameters |
|
731 | 719 | |
|
732 | 720 | def dict_to_parms(self, parameters): |
|
733 | 721 | |
|
734 | 722 | self.name = parameters['name'] |
|
735 | 723 | self.antenna = json.dumps(parameters['antenna']) |
|
736 | 724 | #self.abs_conf = parameters['abs_conf'] |
|
737 | 725 | self.tx = json.dumps(parameters['tx']) |
|
738 | 726 | self.rx = json.dumps(parameters['rx']) |
|
739 | 727 | #parameters['s_time'] |
|
740 | 728 | #parameters['e_time'] |
|
741 | 729 | self.ues = json.dumps(parameters['ues']) |
|
742 | 730 | self.only_rx = json.dumps(parameters['only_rx']) |
|
743 | 731 | |
|
744 | 732 | self.modules_6bits() |
|
745 | 733 | self.save() |
|
746 | 734 | |
|
747 | 735 | return parameters |
|
748 | 736 | |
|
749 | 737 | def clone(self, **kwargs): |
|
750 | 738 | |
|
751 | 739 | self.pk = None |
|
752 | 740 | self.id = None |
|
753 | 741 | for attr, value in kwargs.items(): |
|
754 | 742 | setattr(self, attr, value) |
|
755 | 743 | |
|
756 | 744 | self.save() |
|
757 | 745 | |
|
758 | 746 | return self |
|
759 | 747 | |
|
760 | 748 | |
|
761 | def change_beam(self, beam_pos=0): | |
|
762 | ||
|
763 | module_63 = ('192.168.1.63', 5500) | |
|
764 | header = 'JROABSCeCnModCnMod0100000' | |
|
765 | numbers = len(str(beam_pos)) | |
|
766 | function = 'CHGB' | |
|
767 | ||
|
768 | message_tx = header+str(numbers)+function+str(beam_pos)+'0' | |
|
769 | ||
|
770 | # Create the datagram socket | |
|
771 | sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
|
772 | sock.connect(module_63) | |
|
773 | sock.send(message_tx) | |
|
774 | sock.close() | |
|
775 | return message_tx | |
|
776 | ||
|
777 | def change_module_beam(self, module=61,beam_pos=0): | |
|
778 | ||
|
779 | module_address = ('192.168.1.'+str(module), 5500) | |
|
780 | header = 'JROABSCeCnModCnMod0100000' | |
|
781 | numbers = len(str(beam_pos)) | |
|
782 | function = 'CHGB' | |
|
783 | ||
|
784 | message_tx = header+str(numbers)+function+str(beam_pos)+'0' | |
|
785 | ||
|
786 | # Create the datagram socket | |
|
787 | try: | |
|
788 | sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
|
789 | sock.connect(module_address) | |
|
790 | sock.send(message_tx) | |
|
791 | sock.close() | |
|
792 | except: | |
|
793 | return 0 | |
|
794 | return message_tx | |
|
795 | ||
|
796 | def write_device(self): | |
|
797 | ||
|
798 | parameters = {} | |
|
799 | ||
|
800 | module_ip = '192.168.1.63' | |
|
801 | write_route = 'http://192.168.1.63:8080/configure' | |
|
802 | ||
|
803 | header = 'JROABSCeCnModCnMod01000108SNDFexperimento1.ab1' | |
|
804 | module = 'ABS_63' | |
|
805 | beams = {1: '001000', 2: '010001', 3: '010010', 4: '000011', 5: '101100', 6: '101101', | |
|
806 | 7: '110110', 8: '111111', 9: '000000', 10: '001001', 11: '010010', 12: '011011'} | |
|
807 | ||
|
808 | parameters['header'] = header | |
|
809 | parameters['module'] = module | |
|
810 | parameters['beams'] = json.dumps(beams) | |
|
811 | ||
|
812 | answer = '' | |
|
813 | ||
|
814 | try: | |
|
815 | r_write = requests.post(write_route, parameters, timeout=0.5) | |
|
816 | answer = r_write.json() | |
|
817 | self.message = answer['message'] | |
|
818 | except: | |
|
819 | self.message = "Could not write ABS parameters" | |
|
820 | return 0 | |
|
821 | ||
|
822 | ||
|
823 | #self.device.status = int(answer['status']) | |
|
824 | ||
|
825 | return 1 | |
|
826 | ||
|
827 | ||
|
828 | 749 | |
|
829 | 750 | def module_6bits(self, module): |
|
830 | 751 | """ |
|
831 | 752 | This function reads antenna pattern and choose 6bits (upbits-downbits) for one abs module |
|
832 | 753 | """ |
|
833 | 754 | if module > 64: |
|
834 | 755 | beam_bits = "" |
|
835 | 756 | return beam_bits |
|
836 | 757 | |
|
837 | 758 | data = ast.literal_eval(self.antenna) |
|
838 | 759 | up_data = data['antenna_up'] |
|
839 | 760 | down_data = data['antenna_down'] |
|
840 | 761 | |
|
841 | 762 | pos = ip2position(module) |
|
842 | 763 | up_value = up_data[pos[0]][pos[1]] |
|
843 | 764 | down_value = down_data[pos[0]][pos[1]] |
|
844 | 765 | |
|
845 | 766 | up_bits = up_conv_bits(up_value) |
|
846 | 767 | down_bits = down_conv_bits(down_value) |
|
847 | 768 | beam_bits = up_bits+down_bits |
|
848 | 769 | |
|
849 | 770 | return beam_bits |
|
850 | 771 | |
|
851 | 772 | def modules_6bits(self): |
|
852 | 773 | """ |
|
853 | 774 | This function returns 6bits from every abs module (1-64) in a dict |
|
854 | 775 | """ |
|
855 | 776 | modules_configuration = ast.literal_eval(self.modules_conf) |
|
856 | 777 | |
|
857 | 778 | for i in range(1,65): |
|
858 | 779 | modules_configuration[str(i)] = self.module_6bits(i) |
|
859 | 780 | |
|
860 | 781 | self.modules_conf = json.dumps(modules_configuration) |
|
861 | 782 | self.save() |
|
862 | 783 | |
|
863 | 784 | return self.modules_conf |
|
864 | 785 | |
|
865 | def add_beam2list(self): | |
|
866 | """ | |
|
867 | This function adds a beam to the beams list of ABS Configuration. | |
|
868 | """ | |
|
869 | beams = ast.literal_eval(self.abs_conf.beams) | |
|
870 | if any(beams): | |
|
871 | for beam in beams: | |
|
872 | if beams[beam] == self.id: | |
|
873 | return | |
|
874 | i = len(beams)+1 | |
|
875 | beams['beam'+str(i)] = self.id | |
|
876 | else: | |
|
877 | beams['beam1'] = self.id | |
|
878 | ||
|
879 | self.abs_conf.beams = json.dumps(beams) | |
|
880 | self.abs_conf.save() | |
|
881 | ||
|
882 | return | |
|
883 | 786 | |
|
884 |
def |
|
|
787 | def active_beam(self): | |
|
885 | 788 | """ |
|
886 |
This function |
|
|
789 | This function set this beam as the active beam of its ABS Configuration. | |
|
887 | 790 | """ |
|
888 | beams = ast.literal_eval(self.abs_conf.beams) | |
|
889 | dict_position = '' | |
|
890 | ||
|
891 | if any(beams): | |
|
892 | for beam in beams: | |
|
893 | if beams[beam] == self.id: | |
|
894 | dict_position = beam | |
|
895 | if dict_position != '': | |
|
896 | beams.pop(str(dict_position),None) | |
|
897 | else: | |
|
898 | return | |
|
899 | ||
|
900 | self.abs_conf.beams = json.dumps(beams) | |
|
791 | self.abs_conf.active_beam = json.dumps({'active_beam': self.id}) | |
|
901 | 792 | self.abs_conf.save() |
|
902 | ||
|
903 | 793 | return |
|
904 | 794 | |
|
905 | 795 | @property |
|
906 | 796 | def get_upvalues(self): |
|
907 | 797 | """ |
|
908 | 798 | This function reads antenna pattern and show the up-value of one abs module |
|
909 | 799 | """ |
|
910 | 800 | |
|
911 | 801 | data = ast.literal_eval(self.antenna) |
|
912 | 802 | up_data = data['antenna_up'] |
|
913 | 803 | |
|
914 | 804 | up_values = [] |
|
915 | 805 | for data in up_data: |
|
916 | 806 | for i in range(0,8): |
|
917 | 807 | up_values.append(data[i]) |
|
918 | 808 | |
|
919 | 809 | return up_values |
|
920 | 810 | |
|
921 | 811 | @property |
|
922 | 812 | def antenna_upvalues(self): |
|
923 | 813 | """ |
|
924 | 814 | This function reads antenna pattern and show the up - values of one abs beam |
|
925 | 815 | in a particular order |
|
926 | 816 | """ |
|
927 | 817 | data = ast.literal_eval(self.antenna) |
|
928 | 818 | up_data = data['antenna_up'] |
|
929 | 819 | |
|
930 | 820 | return up_data |
|
931 | 821 | |
|
932 | 822 | @property |
|
933 | 823 | def antenna_downvalues(self): |
|
934 | 824 | """ |
|
935 | 825 | This function reads antenna pattern and show the down - values of one abs beam |
|
936 | 826 | in a particular order |
|
937 | 827 | """ |
|
938 | 828 | data = ast.literal_eval(self.antenna) |
|
939 | 829 | down_data = data['antenna_down'] |
|
940 | 830 | |
|
941 | 831 | return down_data |
|
942 | 832 | |
|
943 | 833 | @property |
|
944 | 834 | def get_downvalues(self): |
|
945 | 835 | """ |
|
946 | 836 | This function reads antenna pattern and show the down-value of one abs module |
|
947 | 837 | """ |
|
948 | 838 | |
|
949 | 839 | data = ast.literal_eval(self.antenna) |
|
950 | 840 | down_data = data['antenna_down'] |
|
951 | 841 | |
|
952 | 842 | down_values = [] |
|
953 | 843 | for data in down_data: |
|
954 | 844 | for i in range(0,8): |
|
955 | 845 | down_values.append(data[i]) |
|
956 | 846 | |
|
957 | 847 | return down_values |
|
958 | 848 | |
|
959 | 849 | @property |
|
960 | 850 | def get_up_ues(self): |
|
961 | 851 | """ |
|
962 | 852 | This function shows the up-ues-value of one beam |
|
963 | 853 | """ |
|
964 | 854 | data = ast.literal_eval(self.ues) |
|
965 | 855 | up_ues = data['up'] |
|
966 | 856 | |
|
967 | 857 | return up_ues |
|
968 | 858 | |
|
969 | 859 | @property |
|
970 | 860 | def get_down_ues(self): |
|
971 | 861 | """ |
|
972 | 862 | This function shows the down-ues-value of one beam |
|
973 | 863 | """ |
|
974 | 864 | data = ast.literal_eval(self.ues) |
|
975 | 865 | down_ues = data['down'] |
|
976 | 866 | |
|
977 | 867 | return down_ues |
|
978 | 868 | |
|
979 | 869 | @property |
|
980 | 870 | def get_up_onlyrx(self): |
|
981 | 871 | """ |
|
982 | 872 | This function shows the up-onlyrx-value of one beam |
|
983 | 873 | """ |
|
984 | 874 | data = json.loads(self.only_rx) |
|
985 | 875 | up_onlyrx = data['up'] |
|
986 | 876 | |
|
987 | 877 | return up_onlyrx |
|
988 | 878 | |
|
989 | 879 | @property |
|
990 | 880 | def get_down_onlyrx(self): |
|
991 | 881 | """ |
|
992 | 882 | This function shows the down-onlyrx-value of one beam |
|
993 | 883 | """ |
|
994 | 884 | data = json.loads(self.only_rx) |
|
995 | 885 | down_onlyrx = data['down'] |
|
996 | 886 | |
|
997 | 887 | return down_onlyrx |
|
998 | 888 | |
|
999 | 889 | @property |
|
1000 | 890 | def get_tx(self): |
|
1001 | 891 | """ |
|
1002 | 892 | This function shows the tx-values of one beam |
|
1003 | 893 | """ |
|
1004 | 894 | data = json.loads(self.tx) |
|
1005 | 895 | |
|
1006 | 896 | return data |
|
1007 | 897 | |
|
1008 | 898 | @property |
|
1009 | 899 | def get_uptx(self): |
|
1010 | 900 | """ |
|
1011 | 901 | This function shows the up-tx-values of one beam |
|
1012 | 902 | """ |
|
1013 | 903 | data = json.loads(self.tx) |
|
1014 | 904 | up_data = data['up'] |
|
1015 | 905 | |
|
1016 | 906 | up_values = [] |
|
1017 | 907 | for data in up_data: |
|
1018 | 908 | for i in range(0,8): |
|
1019 | 909 | up_values.append(data[i]) |
|
1020 | 910 | |
|
1021 | 911 | return up_values |
|
1022 | 912 | |
|
1023 | 913 | @property |
|
1024 | 914 | def get_downtx(self): |
|
1025 | 915 | """ |
|
1026 | 916 | This function shows the down-tx-values of one beam |
|
1027 | 917 | """ |
|
1028 | 918 | data = json.loads(self.tx) |
|
1029 | 919 | down_data = data['down'] |
|
1030 | 920 | |
|
1031 | 921 | down_values = [] |
|
1032 | 922 | for data in down_data: |
|
1033 | 923 | for i in range(0,8): |
|
1034 | 924 | down_values.append(data[i]) |
|
1035 | 925 | |
|
1036 | 926 | return down_values |
|
1037 | 927 | |
|
1038 | 928 | |
|
1039 | 929 | |
|
1040 | 930 | @property |
|
1041 | 931 | def get_rx(self): |
|
1042 | 932 | """ |
|
1043 | 933 | This function shows the rx-values of one beam |
|
1044 | 934 | """ |
|
1045 | 935 | data = json.loads(self.rx) |
|
1046 | 936 | |
|
1047 | 937 | return data |
|
1048 | 938 | |
|
1049 | 939 | @property |
|
1050 | 940 | def get_uprx(self): |
|
1051 | 941 | """ |
|
1052 | 942 | This function shows the up-rx-values of one beam |
|
1053 | 943 | """ |
|
1054 | 944 | data = json.loads(self.rx) |
|
1055 | 945 | up_data = data['up'] |
|
1056 | 946 | |
|
1057 | 947 | up_values = [] |
|
1058 | 948 | for data in up_data: |
|
1059 | 949 | for i in range(0,8): |
|
1060 | 950 | up_values.append(data[i]) |
|
1061 | 951 | |
|
1062 | 952 | return up_values |
|
1063 | 953 | |
|
1064 | 954 | @property |
|
1065 | 955 | def get_downrx(self): |
|
1066 | 956 | """ |
|
1067 | 957 | This function shows the down-rx-values of one beam |
|
1068 | 958 | """ |
|
1069 | 959 | data = json.loads(self.rx) |
|
1070 | 960 | down_data = data['down'] |
|
1071 | 961 | |
|
1072 | 962 | down_values = [] |
|
1073 | 963 | for data in down_data: |
|
1074 | 964 | for i in range(0,8): |
|
1075 | 965 | down_values.append(data[i]) |
|
1076 | 966 | |
|
1077 | 967 | return down_values |
@@ -1,462 +1,533 | |||
|
1 | 1 | {% extends "dev_conf.html" %} |
|
2 | 2 | |
|
3 | 3 | {% block extra-menu-actions %} |
|
4 | 4 | <li><a href="{{ dev_conf.get_absolute_url_plot }}" target="_blank"><span class="glyphicon glyphicon-picture" aria-hidden="true"></span> View Patterns </a></li> |
|
5 | 5 | <!--<li><a href="{{ dev_conf.get_absolute_url_write }}"><span class="glyphicon glyphicon-download" aria-hidden="true"></span> Write</a></li>--> |
|
6 | 6 | {% endblock %} |
|
7 | 7 | |
|
8 | 8 | {% block extra-content %} |
|
9 | 9 | <style> |
|
10 | 10 | |
|
11 | 11 | .abs { |
|
12 | 12 | border: 2px solid #00334d; |
|
13 | 13 | vertical-align: center; |
|
14 | 14 | display: inline-block; |
|
15 | 15 | } |
|
16 | 16 | .abs tr:nth-child(1){ |
|
17 | 17 | border-bottom: 1px dashed #00334d; |
|
18 | 18 | } |
|
19 | 19 | .abs tr{ |
|
20 | 20 | border-bottom: 0px solid #00334d; |
|
21 | 21 | } |
|
22 | 22 | .abs td { |
|
23 | 23 | border-right: 1px dashed #00334d; |
|
24 | 24 | text-align: center; |
|
25 | 25 | padding: 5px; |
|
26 | 26 | } |
|
27 | 27 | |
|
28 | 28 | |
|
29 | 29 | .legend { |
|
30 | 30 | margin-left: 15px; |
|
31 | 31 | display: inline-block; |
|
32 | 32 | border: 2px solid #00334d; |
|
33 | 33 | vertical-align: top; |
|
34 | 34 | } |
|
35 | 35 | .legend th{ |
|
36 | 36 | border-bottom: 1px dashed #00334d; |
|
37 | 37 | font-weight: bold; |
|
38 | 38 | vertical-align: center; |
|
39 | 39 | text-align: center; |
|
40 | 40 | } |
|
41 | 41 | .legend td { |
|
42 | 42 | padding: 2px; |
|
43 | 43 | text-align: center; |
|
44 | 44 | } |
|
45 | 45 | |
|
46 | 46 | |
|
47 | 47 | .north { |
|
48 | 48 | border: 2px solid #00334d; |
|
49 | 49 | vertical-align: center; |
|
50 | 50 | font-weight: bold; |
|
51 | 51 | } |
|
52 | 52 | .north tr{ |
|
53 | 53 | border: 1px solid #ffffff; |
|
54 | background-color: #FF0000; | |
|
54 | ||
|
55 | 55 | } |
|
56 | 56 | .north td{ |
|
57 | 57 | border: 2px solid #e2e2e7; |
|
58 | 58 | text-align: center; |
|
59 | 59 | padding: 1px 15px 1px 15px; |
|
60 | 60 | } |
|
61 | 61 | .north tr:nth-child(even) td:nth-child(n){ |
|
62 | 62 | border-bottom: 12px solid #e2e2e7; |
|
63 | 63 | } |
|
64 | 64 | .north td:nth-child(n) { |
|
65 | 65 | border-right: 12px solid #e2e2e7; |
|
66 | 66 | } |
|
67 | 67 | .north td:nth-last-child(4n+1) { |
|
68 | 68 | border-right: 2px solid #e2e2e7; |
|
69 | 69 | } |
|
70 | 70 | .north tr:nth-last-child(1) td:nth-child(n){ |
|
71 | 71 | border-bottom: 3px solid #e2e2e7; |
|
72 | 72 | } |
|
73 | 73 | |
|
74 | .north tr:nth-child(2) td:nth-child(2){ | |
|
75 | background-color: #00cc00; | |
|
76 | } | |
|
77 | ||
|
78 | .north tr:nth-child(2) td:nth-child(4){ | |
|
79 | background-color: #ee902c; | |
|
80 | } | |
|
81 | ||
|
82 | 74 | |
|
83 | 75 | |
|
84 | 76 | .east { |
|
85 | 77 | border: 2px solid #00334d; |
|
86 | 78 | vertical-align: center; |
|
87 | 79 | font-weight: bold; |
|
88 | 80 | } |
|
89 | 81 | .east tr{ |
|
90 | 82 | border: 1px solid #ffffff; |
|
91 | background-color: #FF0000; | |
|
92 | 83 | } |
|
93 | 84 | .east td{ |
|
94 | 85 | border: 2px solid #e2e2e7; |
|
95 | 86 | text-align: center; |
|
96 | 87 | padding: 1px 15px 1px 15px; |
|
97 | 88 | } |
|
98 | 89 | .east tr:nth-child(even) td:nth-child(n){ |
|
99 | 90 | border-bottom: 12px solid #e2e2e7; |
|
100 | 91 | } |
|
101 | 92 | .east td:nth-child(n) { |
|
102 | 93 | border-right: 12px solid #e2e2e7; |
|
103 | 94 | } |
|
104 | 95 | .east td:nth-last-child(4n+1) { |
|
105 | 96 | border-right: 2px solid #e2e2e7; |
|
106 | 97 | } |
|
107 | 98 | .east tr:nth-last-child(1) td:nth-child(n){ |
|
108 | 99 | border-bottom: 3px solid #e2e2e7; |
|
109 | 100 | } |
|
110 | 101 | |
|
111 | .east tr:nth-child(2) td:nth-child(2){ | |
|
112 | background-color: #00cc00; | |
|
113 | } | |
|
114 | 102 | |
|
115 | .east tr:nth-child(2) td:nth-child(4){ | |
|
116 | background-color: #ee902c; | |
|
117 | } | |
|
118 | 103 | |
|
119 | 104 | |
|
120 | 105 | .west { |
|
121 | 106 | border: 2px solid #00334d; |
|
122 | 107 | vertical-align: center; |
|
123 | 108 | font-weight: bold; |
|
124 | 109 | } |
|
125 | 110 | .west tr{ |
|
126 | 111 | border: 1px solid #ffffff; |
|
127 | background-color: #FF0000; | |
|
128 | 112 | } |
|
129 | 113 | .west td{ |
|
130 | 114 | border: 2px solid #e2e2e7; |
|
131 | 115 | text-align: center; |
|
132 | 116 | padding: 1px 15px 1px 15px; |
|
133 | 117 | } |
|
134 | 118 | .west tr:nth-child(even) td:nth-child(n){ |
|
135 | 119 | border-bottom: 12px solid #e2e2e7; |
|
136 | 120 | } |
|
137 | 121 | .west td:nth-child(n) { |
|
138 | 122 | border-right: 12px solid #e2e2e7; |
|
139 | 123 | } |
|
140 | 124 | .west td:nth-last-child(4n+1) { |
|
141 | 125 | border-right: 2px solid #e2e2e7; |
|
142 | 126 | } |
|
143 | 127 | .west tr:nth-last-child(1) td:nth-child(n){ |
|
144 | 128 | border-bottom: 3px solid #e2e2e7; |
|
145 | 129 | } |
|
146 | 130 | |
|
147 | .west tr:nth-child(2) td:nth-child(2){ | |
|
148 | background-color: #00cc00; | |
|
149 | } | |
|
150 | 131 | |
|
151 | .west tr:nth-child(2) td:nth-child(4){ | |
|
152 | background-color: #ee902c; | |
|
153 | } | |
|
154 | 132 | |
|
155 | 133 | |
|
156 | 134 | .south { |
|
157 | 135 | border: 2px solid #00334d; |
|
158 | 136 | vertical-align: center; |
|
159 | 137 | font-weight: bold; |
|
160 | 138 | } |
|
161 | 139 | .south tr{ |
|
162 | 140 | border: 1px solid #ffffff; |
|
163 | background-color: #FF0000; | |
|
164 | 141 | } |
|
165 | 142 | .south td{ |
|
166 | 143 | border: 2px solid #e2e2e7; |
|
167 | 144 | text-align: center; |
|
168 | 145 | padding: 1px 15px 1px 15px; |
|
169 | 146 | } |
|
170 | 147 | .south tr:nth-child(even) td:nth-child(n){ |
|
171 | 148 | border-bottom: 12px solid #e2e2e7; |
|
172 | 149 | } |
|
173 | 150 | .south td:nth-child(n) { |
|
174 | 151 | border-right: 12px solid #e2e2e7; |
|
175 | 152 | } |
|
176 | 153 | .south td:nth-last-child(4n+1) { |
|
177 | 154 | border-right: 2px solid #e2e2e7; |
|
178 | 155 | } |
|
179 | 156 | .south tr:nth-last-child(1) td:nth-child(n){ |
|
180 | 157 | border-bottom: 3px solid #e2e2e7; |
|
181 | 158 | } |
|
182 | 159 | |
|
183 | .south tr:nth-child(2) td:nth-child(2){ | |
|
184 | background-color: #00cc00; | |
|
185 | } | |
|
186 | ||
|
187 | .south tr:nth-child(2) td:nth-child(4){ | |
|
188 | background-color: #ee902c; | |
|
189 | } | |
|
190 | 160 | |
|
191 | 161 | |
|
192 | 162 | |
|
193 | 163 | </style> |
|
194 | 164 | |
|
195 | <h4>Beams:</h4> | |
|
165 | ||
|
196 | 166 | {% if beams %} |
|
197 | 167 | |
|
168 | ||
|
169 | ||
|
170 | <h4>Beams:</h4> | |
|
198 | 171 | <div class="container"> |
|
199 | 172 | <ul class="nav nav-pills"> |
|
200 | ||
|
201 | 173 | {% for beam in beams %} |
|
202 | <li {% if forloop.counter == 1 %} class="active" {% endif %}> | |
|
203 |
<a data-toggle="pill" |
|
|
174 | <li > | |
|
175 | <a data-toggle="pill" href="#menu{{forloop.counter}}">{{forloop.counter}}</a> | |
|
204 | 176 | </li> |
|
205 | 177 | {% endfor %} |
|
206 | ||
|
207 | 178 | </ul> |
|
208 | </div> | |
|
209 | ||
|
210 | ||
|
211 | <script> | |
|
212 | $(document).ready(function() { | |
|
213 | 179 | |
|
214 | {% for beam in beams %} | |
|
215 | $( "#button-{{ forloop.counter }}" ).click(function() { | |
|
216 | //$(this).addClass('active'); | |
|
217 | 180 | |
|
218 | var beam_upvalues = {{beam.get_upvalues}}; | |
|
219 | var beam_downvalues = {{beam.get_downvalues}}; | |
|
220 | //alert(beam_upvalues) | |
|
221 | var table = document.getElementById('abs_pattern'); | |
|
222 | var cells = table.getElementsByTagName('td'); | |
|
223 | //alert(cells[99].textContent); | |
|
181 | <div class="tab-content"> | |
|
182 | <div id="home" class="tab-pane fade in active"> | |
|
183 | <!----> | |
|
184 | {% if active_beam %} | |
|
185 | <h3>Active Beam: {{active_beam.name}}</h3> | |
|
224 | 186 |
|
|
225 | for (var i = 1, len = 30; i < len; i++) { | |
|
226 | if ((i > 24) && (i<29)){ | |
|
227 | cells[i].innerHTML = beam_upvalues[i-1].toFixed(1); | |
|
228 | cells[i+4].innerHTML = beam_downvalues[i-1].toFixed(1); | |
|
229 |
|
|
|
230 | else if ((i > 16) && (i<21)){ | |
|
231 | cells[i].innerHTML = beam_upvalues[i-1].toFixed(1); | |
|
232 | cells[i+4].innerHTML = beam_downvalues[i-1].toFixed(1); | |
|
233 | } | |
|
234 | else if ((i > 8) && (i<13)){ | |
|
235 | cells[i].innerHTML = beam_upvalues[i-1].toFixed(1); | |
|
236 | cells[i+4].innerHTML = beam_downvalues[i-1].toFixed(1); | |
|
237 |
|
|
|
238 | else if (i < 5) { | |
|
239 | cells[i].innerHTML = beam_upvalues[i-1].toFixed(1); | |
|
240 | cells[i+4].innerHTML = beam_downvalues[i-1].toFixed(1); | |
|
241 |
|
|
|
242 | } | |
|
243 | ||
|
244 | for (var i = 34, len = 63; i < len; i++) { | |
|
245 | if ((i > 57) && (i<62)) { | |
|
246 | cells[i].innerHTML = beam_upvalues[i-30].toFixed(1); | |
|
247 | cells[i+4].innerHTML = beam_downvalues[i-30].toFixed(1); | |
|
248 | } | |
|
249 | if ((i > 49) && (i<54)) { | |
|
250 | cells[i].innerHTML = beam_upvalues[i-30].toFixed(1); | |
|
251 | cells[i+4].innerHTML = beam_downvalues[i-30].toFixed(1); | |
|
252 |
|
|
|
253 | else if ((i > 41) && (i<46)) { | |
|
254 | cells[i].innerHTML = beam_upvalues[i-30].toFixed(1); | |
|
255 | cells[i+4].innerHTML = beam_downvalues[i-30].toFixed(1); | |
|
256 | } | |
|
257 | else if (i < 38) { | |
|
258 | cells[i].innerHTML = beam_upvalues[i-30].toFixed(1); | |
|
259 | cells[i+4].innerHTML = beam_downvalues[i-30].toFixed(1); | |
|
260 |
|
|
|
261 | } | |
|
262 | ||
|
263 | for (var i = 67, len = 96; i < len; i++) { | |
|
264 | if ((i > 90) && (i<95)) { | |
|
265 | cells[i].innerHTML = beam_upvalues[i-35].toFixed(1); | |
|
266 | cells[i+4].innerHTML = beam_downvalues[i-35].toFixed(1); | |
|
267 | } | |
|
268 | else if ((i > 82) && (i<87)) { | |
|
269 | cells[i].innerHTML = beam_upvalues[i-35].toFixed(1); | |
|
270 | cells[i+4].innerHTML = beam_downvalues[i-35].toFixed(1); | |
|
271 |
|
|
|
272 | else if ((i > 74) && (i<79)) { | |
|
273 | cells[i].innerHTML = beam_upvalues[i-35].toFixed(1); | |
|
274 | cells[i+4].innerHTML = beam_downvalues[i-35].toFixed(1); | |
|
275 |
|
|
|
276 | else if (i < 71) { | |
|
277 | cells[i].innerHTML = beam_upvalues[i-35].toFixed(1); | |
|
278 | cells[i+4].innerHTML = beam_downvalues[i-35].toFixed(1); | |
|
279 | } | |
|
280 | } | |
|
187 | <table id="abs_pattern" class="abs"> | |
|
188 | <tr> | |
|
189 | <td> <b>North Quarter</b> | |
|
190 | <table class="north "> | |
|
191 | <tr> | |
|
192 | <td {{color_status.1}}>{{active_beam.get_upvalues.0}}</td> <td {{color_status.2}}>{{active_beam.get_upvalues.1}}</td> <td {{color_status.3}}>{{active_beam.get_upvalues.2}}</td> <td {{color_status.4}}>{{active_beam.get_upvalues.3}}</td> | |
|
193 | </tr> | |
|
194 | <tr> | |
|
195 | <td {{color_status.1}}>{{active_beam.get_downvalues.0}}</td> <td {{color_status.2}}>{{active_beam.get_downvalues.1}}</td> <td {{color_status.3}}>{{active_beam.get_downvalues.2}}</td> <td {{color_status.4}}>{{active_beam.get_downvalues.3}}</td> | |
|
196 | </tr> | |
|
197 | <tr> | |
|
198 | <td {{color_status.9}}>{{active_beam.get_upvalues.8}}</td> <td {{color_status.10}}>{{active_beam.get_upvalues.9}}</td> <td {{color_status.11}}>{{active_beam.get_upvalues.10}}</td> <td {{color_status.12}}>{{active_beam.get_upvalues.11}}</td> | |
|
199 | </tr> | |
|
200 | <tr> | |
|
201 | <td {{color_status.9}}>{{active_beam.get_downvalues.8}}</td> <td {{color_status.10}}>{{active_beam.get_downvalues.9}}</td> <td {{color_status.11}}>{{active_beam.get_downvalues.10}}</td> <td {{color_status.12}}>{{active_beam.get_downvalues.11}}</td> | |
|
202 | </tr> | |
|
203 | <tr> | |
|
204 | <td {{color_status.17}}>{{active_beam.get_upvalues.16}}</td> <td {{color_status.18}}>{{active_beam.get_upvalues.17}}</td> <td {{color_status.19}}>{{active_beam.get_upvalues.18}}</td> <td {{color_status.20}}>{{active_beam.get_upvalues.19}}</td> | |
|
205 | </tr> | |
|
206 | <tr> | |
|
207 | <td {{color_status.17}}>{{active_beam.get_downvalues.16}}</td> <td {{color_status.18}}>{{active_beam.get_downvalues.17}}</td> <td {{color_status.19}}>{{active_beam.get_downvalues.18}}</td> <td {{color_status.20}}>{{active_beam.get_downvalues.19}}</td> | |
|
208 | </tr> | |
|
209 | <tr> | |
|
210 | <td {{color_status.25}}>{{active_beam.get_upvalues.24}}</td> <td {{color_status.26}}>{{active_beam.get_upvalues.25}}</td> <td {{color_status.27}}>{{active_beam.get_upvalues.26}}</td> <td {{color_status.28}}>{{active_beam.get_upvalues.27}}</td> | |
|
211 | </tr> | |
|
212 | <tr> | |
|
213 | <td {{color_status.25}}>{{active_beam.get_downvalues.24}}</td> <td {{color_status.26}}>{{active_beam.get_downvalues.25}}</td> <td {{color_status.27}}>{{active_beam.get_downvalues.26}}</td> <td {{color_status.28}}>{{active_beam.get_downvalues.27}}</td> | |
|
214 | </tr> | |
|
215 | </table> | |
|
216 | </td> | |
|
217 | <td> <b>East Quarter</b> | |
|
218 | <table class="east "> | |
|
219 | <tr> | |
|
220 | <td {{color_status.5}}>{{active_beam.get_upvalues.4}}</td> <td {{color_status.6}}>{{active_beam.get_upvalues.5}}</td> <td {{color_status.7}}>{{active_beam.get_upvalues.6}}</td> <td {{color_status.8}}>{{active_beam.get_upvalues.7}}</td> | |
|
221 | </tr> | |
|
222 | <tr> | |
|
223 | <td {{color_status.5}}>{{active_beam.get_downvalues.4}}</td> <td {{color_status.6}}>{{active_beam.get_downvalues.5}}</td> <td {{color_status.7}}>{{active_beam.get_downvalues.6}}</td> <td {{color_status.8}}>{{active_beam.get_downvalues.7}}</td> | |
|
224 | </tr> | |
|
225 | <tr> | |
|
226 | <td {{color_status.13}}>{{active_beam.get_upvalues.12}}</td> <td {{color_status.14}}>{{active_beam.get_upvalues.13}}</td> <td {{color_status.15}}>{{active_beam.get_upvalues.14}}</td> <td {{color_status.16}}>{{active_beam.get_upvalues.15}}</td> | |
|
227 | </tr> | |
|
228 | <tr> | |
|
229 | <td {{color_status.13}}>{{active_beam.get_downvalues.12}}</td> <td {{color_status.14}}>{{active_beam.get_downvalues.13}}</td> <td {{color_status.15}}>{{active_beam.get_downvalues.14}}</td> <td {{color_status.16}}>{{active_beam.get_downvalues.15}}</td> | |
|
230 | </tr> | |
|
231 | <tr> | |
|
232 | <td {{color_status.21}}>{{active_beam.get_upvalues.20}}</td> <td {{color_status.22}}>{{active_beam.get_upvalues.21}}</td> <td {{color_status.23}}>{{active_beam.get_upvalues.22}}</td> <td {{color_status.24}}>{{active_beam.get_upvalues.23}}</td> | |
|
233 | </tr> | |
|
234 | <tr> | |
|
235 | <td {{color_status.21}}>{{active_beam.get_downvalues.20}}</td> <td {{color_status.22}}>{{active_beam.get_downvalues.21}}</td> <td {{color_status.23}}>{{active_beam.get_downvalues.22}}</td> <td {{color_status.24}}>{{active_beam.get_downvalues.23}}</td> | |
|
236 | </tr> | |
|
237 | <tr> | |
|
238 | <td {{color_status.29}}>{{active_beam.get_upvalues.28}}</td> <td {{color_status.30}}>{{active_beam.get_upvalues.29}}</td> <td {{color_status.31}}>{{active_beam.get_upvalues.30}}</td> <td {{color_status.32}}>{{active_beam.get_upvalues.31}}</td> | |
|
239 | </tr> | |
|
240 | <tr> | |
|
241 | <td {{color_status.29}}>{{active_beam.get_downvalues.28}}</td> <td {{color_status.30}}>{{active_beam.get_downvalues.29}}</td> <td {{color_status.31}}>{{active_beam.get_downvalues.30}}</td> <td {{color_status.32}}>{{active_beam.get_downvalues.31}}</td> | |
|
242 | </tr> | |
|
243 | </table> | |
|
244 | </td> | |
|
245 | </tr> | |
|
246 | <tr> | |
|
247 | <td> <b>West Quarter</b> | |
|
248 | <table class="west "> | |
|
249 | <tr> | |
|
250 | <td {{color_status.33}}>{{active_beam.get_upvalues.32}}</td> <td {{color_status.34}}>{{active_beam.get_upvalues.33}}</td> <td {{color_status.35}}>{{active_beam.get_upvalues.34}}</td> <td {{color_status.36}}>{{active_beam.get_upvalues.35}}</td> | |
|
251 | </tr> | |
|
252 | <tr> | |
|
253 | <td {{color_status.33}}>{{active_beam.get_downvalues.32}}</td> <td {{color_status.34}}>{{active_beam.get_downvalues.33}}</td> <td {{color_status.35}}>{{active_beam.get_downvalues.34}}</td> <td {{color_status.36}}>{{active_beam.get_downvalues.35}}</td> | |
|
254 | </tr> | |
|
255 | <tr> | |
|
256 | <td {{color_status.41}}>{{active_beam.get_upvalues.40}}</td> <td {{color_status.42}}>{{active_beam.get_upvalues.41}}</td> <td {{color_status.43}}>{{active_beam.get_upvalues.42}}</td> <td {{color_status.44}}>{{active_beam.get_upvalues.43}}</td> | |
|
257 | </tr> | |
|
258 | <tr> | |
|
259 | <td {{color_status.41}}>{{active_beam.get_downvalues.40}}</td> <td {{color_status.42}}>{{active_beam.get_downvalues.41}}</td> <td {{color_status.43}}>{{active_beam.get_downvalues.42}}</td> <td {{color_status.44}}>{{active_beam.get_downvalues.43}}</td> | |
|
260 | </tr> | |
|
261 | <tr> | |
|
262 | <td {{color_status.49}}>{{active_beam.get_upvalues.48}}</td> <td {{color_status.50}}>{{active_beam.get_upvalues.49}}</td> <td {{color_status.51}}>{{active_beam.get_upvalues.50}}</td> <td {{color_status.52}}>{{active_beam.get_upvalues.51}}</td> | |
|
263 | </tr> | |
|
264 | <tr> | |
|
265 | <td {{color_status.49}}>{{active_beam.get_downvalues.48}}</td> <td {{color_status.50}}>{{active_beam.get_downvalues.49}}</td> <td {{color_status.51}}>{{active_beam.get_downvalues.50}}</td> <td {{color_status.52}}>{{active_beam.get_downvalues.51}}</td> | |
|
266 | </tr> | |
|
267 | <tr> | |
|
268 | <td {{color_status.57}}>{{active_beam.get_upvalues.56}}</td> <td {{color_status.58}}>{{active_beam.get_upvalues.57}}</td> <td {{color_status.59}}>{{active_beam.get_upvalues.58}}</td> <td {{color_status.60}}>{{active_beam.get_upvalues.59}}</td> | |
|
269 | </tr> | |
|
270 | <tr> | |
|
271 | <td {{color_status.57}}>{{active_beam.get_downvalues.56}}</td> <td {{color_status.58}}>{{active_beam.get_downvalues.57}}</td> <td {{color_status.59}}>{{active_beam.get_downvalues.58}}</td> <td {{color_status.60}}>{{active_beam.get_downvalues.59}}</td> | |
|
272 | </tr> | |
|
273 | </table> | |
|
274 | </td> | |
|
275 | <td> <b>South Quarter</b> | |
|
276 | <table class="south "> | |
|
277 | <tr> | |
|
278 | <td {{color_status.37}}>{{active_beam.get_upvalues.36}}</td> <td {{color_status.38}}>{{active_beam.get_upvalues.37}}</td> <td {{color_status.39}}>{{active_beam.get_upvalues.38}}</td> <td {{color_status.40}}>{{active_beam.get_upvalues.39}}</td> | |
|
279 | </tr> | |
|
280 | <tr> | |
|
281 | <td {{color_status.37}}>{{active_beam.get_downvalues.36}}</td> <td {{color_status.38}}>{{active_beam.get_downvalues.37}}</td> <td {{color_status.39}}>{{active_beam.get_downvalues.38}}</td> <td {{color_status.40}}>{{active_beam.get_downvalues.39}}</td> | |
|
282 | </tr> | |
|
283 | <tr> | |
|
284 | <td {{color_status.45}}>{{active_beam.get_upvalues.44}}</td> <td {{color_status.46}}>{{active_beam.get_upvalues.45}}</td> <td {{color_status.47}}>{{active_beam.get_upvalues.46}}</td> <td {{color_status.48}}>{{active_beam.get_upvalues.47}}</td> | |
|
285 | </tr> | |
|
286 | <tr> | |
|
287 | <td {{color_status.45}}>{{active_beam.get_downvalues.44}}</td> <td {{color_status.46}}>{{active_beam.get_downvalues.45}}</td> <td {{color_status.47}}>{{active_beam.get_downvalues.46}}</td> <td {{color_status.48}}>{{active_beam.get_downvalues.47}}</td> | |
|
288 | </tr> | |
|
289 | <tr> | |
|
290 | <td {{color_status.53}}>{{active_beam.get_upvalues.52}}</td> <td {{color_status.54}}>{{active_beam.get_upvalues.53}}</td> <td {{color_status.55}}>{{active_beam.get_upvalues.54}}</td> <td {{color_status.56}}>{{active_beam.get_upvalues.55}}</td> | |
|
291 | </tr> | |
|
292 | <tr> | |
|
293 | <td {{color_status.53}}>{{active_beam.get_downvalues.52}}</td> <td {{color_status.54}}>{{active_beam.get_downvalues.53}}</td> <td {{color_status.55}}>{{active_beam.get_downvalues.54}}</td> <td {{color_status.56}}>{{active_beam.get_downvalues.55}}</td> | |
|
294 | </tr> | |
|
295 | <tr> | |
|
296 | <td {{color_status.61}}>{{active_beam.get_upvalues.60}}</td> <td {{color_status.62}}>{{active_beam.get_upvalues.61}}</td> <td {{color_status.63}}>{{active_beam.get_upvalues.62}}</td> <td {{color_status.64}}>{{active_beam.get_upvalues.63}}</td> | |
|
297 | </tr> | |
|
298 | <tr> | |
|
299 | <td {{color_status.61}}>{{active_beam.get_downvalues.60}}</td> <td {{color_status.62}}>{{active_beam.get_downvalues.61}}</td> <td {{color_status.63}}>{{active_beam.get_downvalues.62}}</td> <td {{color_status.64}}>{{active_beam.get_downvalues.63}}</td> | |
|
300 | </tr> | |
|
301 | </table> | |
|
302 | </td> | |
|
303 | </tr> | |
|
304 | </table> | |
|
281 | 305 | |
|
282 | for (var i = 100, len = 129; i < len; i++) { | |
|
283 | if ((i > 123) && (i<128)) { | |
|
284 | cells[i].innerHTML = beam_upvalues[i-64].toFixed(1); | |
|
285 | cells[i+4].innerHTML = beam_downvalues[i-64].toFixed(1); | |
|
286 | } | |
|
287 | else if ((i > 115) && (i<120)) { | |
|
288 | cells[i].innerHTML = beam_upvalues[i-64].toFixed(1); | |
|
289 | cells[i+4].innerHTML = beam_downvalues[i-64].toFixed(1); | |
|
290 | } | |
|
291 | else if ((i > 107) && (i<112)) { | |
|
292 | cells[i].innerHTML = beam_upvalues[i-64].toFixed(1); | |
|
293 | cells[i+4].innerHTML = beam_downvalues[i-64].toFixed(1); | |
|
294 | } | |
|
295 | else if (i < 104) { | |
|
296 | cells[i].innerHTML = beam_upvalues[i-64].toFixed(1); | |
|
297 | cells[i+4].innerHTML = beam_downvalues[i-64].toFixed(1); | |
|
298 | } | |
|
299 | } | |
|
300 | 306 | |
|
301 | //$('#button-1').addClass("active"); | |
|
302 | 307 | |
|
303 | }); | |
|
308 | <table class="legend"> | |
|
309 | <tr> | |
|
310 | <th colspan="2">Legend</th> | |
|
311 | </tr> | |
|
312 | <tr> | |
|
313 | <td style="color:#ff0000;"><i>RED</i></td><td>Disconnected</td> | |
|
314 | </tr> | |
|
315 | <tr> | |
|
316 | <td style="color:#ee902c;"><i>ORANGE</i></td><td>Connected</td> | |
|
317 | </tr> | |
|
318 | <tr> | |
|
319 | <td style="color:#00cc00;"><i>GREEN</i></td><td>Running | |
|
320 | </td> | |
|
321 | </tr> | |
|
322 | <!-- | |
|
323 | <tr> | |
|
324 | <td colspan="2"> | |
|
325 | <button style="margin: 10px;" id="sendbeam" type="button" class="btn btn-default"> | |
|
326 | <span class="glyphicon glyphicon-export" aria-hidden="true"></span> | |
|
327 | Change Beam</button> | |
|
328 | </td> | |
|
329 | </tr> | |
|
330 | --> | |
|
331 | </table> | |
|
304 | 332 | |
|
305 | {% endfor %} | |
|
306 | 333 | |
|
307 | 334 | |
|
308 | 335 | |
|
336 | {% else %} | |
|
337 | <p><i>This ABS Configuration does not have a current active ABS Beam...<br> | |
|
338 | Please send Beam List to ABS modules. </i></p> | |
|
309 | 339 | |
|
310 | //}) | |
|
340 | {% endif %} | |
|
311 | 341 |
|
|
312 | //function ChangeColor() { | |
|
313 | // document.getElementById("button_1").style.backgroundColor = "#2c3e50"; | |
|
314 | // document.getElementById("button_1").style.color = "#ecf0f1"; | |
|
315 | //} | |
|
316 | }); | |
|
317 | </script> | |
|
318 | 342 | |
|
343 | </div> | |
|
319 | 344 | |
|
320 | 345 | |
|
321 | <br> | |
|
322 | 346 | |
|
323 | <table id="abs_pattern" class="abs"> | |
|
347 | {% for beam in beams %} | |
|
348 | <div id="menu{{forloop.counter}}" class="tab-pane fade"> | |
|
349 | <h3>{%if active_beam.id == beam.id%}Active Beam: {%endif%}{{beam.name}}</h3> | |
|
350 | <!--<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>--> | |
|
351 | <table id="abs_pattern{{forloop.counter}}" class="abs"> | |
|
324 | 352 | <tr> |
|
325 | 353 | <td> <b>North Quarter</b> |
|
326 | 354 | <table class="north "> |
|
327 | 355 | <tr> |
|
328 | <td>{{beams.0.get_upvalues.0}}</td> <td>{{beams.0.get_upvalues.1}}</td> <td>{{beams.0.get_upvalues.2}}</td> <td>{{beams.0.get_upvalues.3}}</td> | |
|
356 | <td {{beam.color_status.1}}>{{beam.get_upvalues.0}}</td> <td {{beam.color_status.2}}>{{beam.get_upvalues.1}}</td> <td {{beam.color_status.3}}>{{beam.get_upvalues.2}}</td> <td {{beam.color_status.4}}>{{beam.get_upvalues.3}}</td> | |
|
329 | 357 | </tr> |
|
330 | 358 | <tr> |
|
331 | <td>{{beams.0.get_downvalues.0}}</td> <td>{{beams.0.get_downvalues.1}}</td> <td>{{beams.0.get_downvalues.2}}</td> <td>{{beams.0.get_downvalues.3}}</td> | |
|
359 | <td {{beam.color_status.1}}>{{beam.get_downvalues.0}}</td> <td {{beam.color_status.2}}>{{beam.get_downvalues.1}}</td> <td {{beam.color_status.3}}>{{beam.get_downvalues.2}}</td> <td {{beam.color_status.4}}>{{beam.get_downvalues.3}}</td> | |
|
332 | 360 | </tr> |
|
333 | 361 | <tr> |
|
334 | <td>{{beams.0.get_upvalues.8}}</td> <td>{{beams.0.get_upvalues.9}}</td> <td>{{beams.0.get_upvalues.10}}</td> <td>{{beams.0.get_upvalues.11}}</td> | |
|
362 | <td {{beam.color_status.9}}>{{beam.get_upvalues.8}}</td> <td {{beam.color_status.10}}>{{beam.get_upvalues.9}}</td> <td {{beam.color_status.11}}>{{beam.get_upvalues.10}}</td> <td {{beam.color_status.12}}>{{beam.get_upvalues.11}}</td> | |
|
335 | 363 | </tr> |
|
336 | 364 | <tr> |
|
337 | <td>{{beams.0.get_downvalues.8}}</td> <td>{{beams.0.get_downvalues.9}}</td> <td>{{beams.0.get_downvalues.10}}</td> <td>{{beams.0.get_downvalues.11}}</td> | |
|
365 | <td {{beam.color_status.9}}>{{beam.get_downvalues.8}}</td> <td {{beam.color_status.10}}>{{beam.get_downvalues.9}}</td> <td {{beam.color_status.11}}>{{beam.get_downvalues.10}}</td> <td {{beam.color_status.12}}>{{beam.get_downvalues.11}}</td> | |
|
338 | 366 | </tr> |
|
339 | 367 | <tr> |
|
340 | <td>{{beams.0.get_upvalues.16}}</td> <td>{{beams.0.get_upvalues.17}}</td> <td>{{beams.0.get_upvalues.18}}</td> <td>{{beams.0.get_upvalues.19}}</td> | |
|
368 | <td {{beam.color_status.17}}>{{beam.get_upvalues.16}}</td> <td {{beam.color_status.18}}>{{beam.get_upvalues.17}}</td> <td {{beam.color_status.19}}>{{beam.get_upvalues.18}}</td> <td {{beam.color_status.20}}>{{beam.get_upvalues.19}}</td> | |
|
341 | 369 | </tr> |
|
342 | 370 | <tr> |
|
343 | <td>{{beams.0.get_downvalues.16}}</td> <td>{{beams.0.get_downvalues.17}}</td> <td>{{beams.0.get_downvalues.18}}</td> <td>{{beams.0.get_downvalues.19}}</td> | |
|
371 | <td {{beam.color_status.17}}>{{beam.get_downvalues.16}}</td> <td {{beam.color_status.18}}>{{beam.get_downvalues.17}}</td> <td {{beam.color_status.19}}>{{beam.get_downvalues.18}}</td> <td {{beam.color_status.20}}>{{beam.get_downvalues.19}}</td> | |
|
344 | 372 | </tr> |
|
345 | 373 | <tr> |
|
346 | <td>{{beams.0.get_upvalues.24}}</td> <td>{{beams.0.get_upvalues.25}}</td> <td>{{beams.0.get_upvalues.26}}</td> <td>{{beams.0.get_upvalues.27}}</td> | |
|
374 | <td {{beam.color_status.25}}>{{beam.get_upvalues.24}}</td> <td {{beam.color_status.26}}>{{beam.get_upvalues.25}}</td> <td {{beam.color_status.27}}>{{beam.get_upvalues.26}}</td> <td {{beam.color_status.28}}>{{beam.get_upvalues.27}}</td> | |
|
347 | 375 | </tr> |
|
348 | 376 | <tr> |
|
349 | <td>{{beams.0.get_downvalues.24}}</td> <td>{{beams.0.get_downvalues.25}}</td> <td>{{beams.0.get_downvalues.26}}</td> <td>{{beams.0.get_downvalues.27}}</td> | |
|
377 | <td {{beam.color_status.25}}>{{beam.get_downvalues.24}}</td> <td {{beam.color_status.26}}>{{beam.get_downvalues.25}}</td> <td {{beam.color_status.27}}>{{beam.get_downvalues.26}}</td> <td {{beam.color_status.28}}>{{beam.get_downvalues.27}}</td> | |
|
350 | 378 | </tr> |
|
351 | 379 | </table> |
|
352 | 380 | </td> |
|
353 | 381 | <td> <b>East Quarter</b> |
|
354 | 382 | <table class="east "> |
|
355 | 383 | <tr> |
|
356 | <td>{{beams.0.get_upvalues.4}}</td> <td>{{beams.0.get_upvalues.5}}</td> <td>{{beams.0.get_upvalues.6}}</td> <td>{{beams.0.get_upvalues.7}}</td> | |
|
384 | <td {{beam.color_status.5}}>{{beam.get_upvalues.4}}</td> <td {{beam.color_status.6}}>{{beam.get_upvalues.5}}</td> <td {{beam.color_status.7}}>{{beam.get_upvalues.6}}</td> <td {{beam.color_status.8}}>{{beam.get_upvalues.7}}</td> | |
|
357 | 385 | </tr> |
|
358 | 386 | <tr> |
|
359 | <td>{{beams.0.get_downvalues.4}}</td> <td>{{beams.0.get_downvalues.5}}</td> <td>{{beams.0.get_downvalues.6}}</td> <td>{{beams.0.get_downvalues.7}}</td> | |
|
387 | <td {{beam.color_status.5}}>{{beam.get_downvalues.4}}</td> <td {{beam.color_status.6}}>{{beam.get_downvalues.5}}</td> <td {{beam.color_status.7}}>{{beam.get_downvalues.6}}</td> <td {{beam.color_status.8}}>{{beam.get_downvalues.7}}</td> | |
|
360 | 388 | </tr> |
|
361 | 389 | <tr> |
|
362 | <td>{{beams.0.get_upvalues.12}}</td> <td>{{beams.0.get_upvalues.13}}</td> <td>{{beams.0.get_upvalues.14}}</td> <td>{{beams.0.get_upvalues.15}}</td> | |
|
390 | <td {{beam.color_status.13}}>{{beam.get_upvalues.12}}</td> <td {{beam.color_status.14}}>{{beam.get_upvalues.13}}</td> <td {{beam.color_status.15}}>{{beam.get_upvalues.14}}</td> <td {{beam.color_status.16}}>{{beam.get_upvalues.15}}</td> | |
|
363 | 391 | </tr> |
|
364 | 392 | <tr> |
|
365 | <td>{{beams.0.get_downvalues.12}}</td> <td>{{beams.0.get_downvalues.13}}</td> <td>{{beams.0.get_downvalues.14}}</td> <td>{{beams.0.get_downvalues.15}}</td> | |
|
393 | <td {{beam.color_status.13}}>{{beam.get_downvalues.12}}</td> <td {{beam.color_status.14}}>{{beam.get_downvalues.13}}</td> <td {{beam.color_status.15}}>{{beam.get_downvalues.14}}</td> <td {{beam.color_status.16}}>{{beam.get_downvalues.15}}</td> | |
|
366 | 394 | </tr> |
|
367 | 395 | <tr> |
|
368 | <td>{{beams.0.get_upvalues.20}}</td> <td>{{beams.0.get_upvalues.21}}</td> <td>{{beams.0.get_upvalues.22}}</td> <td>{{beams.0.get_upvalues.23}}</td> | |
|
396 | <td {{beam.color_status.21}}>{{beam.get_upvalues.20}}</td> <td {{beam.color_status.22}}>{{beam.get_upvalues.21}}</td> <td {{beam.color_status.23}}>{{beam.get_upvalues.22}}</td> <td {{beam.color_status.24}}>{{beam.get_upvalues.23}}</td> | |
|
369 | 397 | </tr> |
|
370 | 398 | <tr> |
|
371 | <td>{{beams.0.get_downvalues.20}}</td> <td>{{beams.0.get_downvalues.21}}</td> <td>{{beams.0.get_downvalues.22}}</td> <td>{{beams.0.get_downvalues.23}}</td> | |
|
399 | <td {{beam.color_status.21}}>{{beam.get_downvalues.20}}</td> <td {{beam.color_status.22}}>{{beam.get_downvalues.21}}</td> <td {{beam.color_status.23}}>{{beam.get_downvalues.22}}</td> <td {{beam.color_status.24}}>{{beam.get_downvalues.23}}</td> | |
|
372 | 400 | </tr> |
|
373 | 401 | <tr> |
|
374 | <td>{{beams.0.get_upvalues.28}}</td> <td>{{beams.0.get_upvalues.29}}</td> <td>{{beams.0.get_upvalues.30}}</td> <td>{{beams.0.get_upvalues.31}}</td> | |
|
402 | <td {{beam.color_status.29}}>{{beam.get_upvalues.28}}</td> <td {{beam.color_status.30}}>{{beam.get_upvalues.29}}</td> <td {{beam.color_status.31}}>{{beam.get_upvalues.30}}</td> <td {{beam.color_status.32}}>{{beam.get_upvalues.31}}</td> | |
|
375 | 403 | </tr> |
|
376 | 404 | <tr> |
|
377 | <td>{{beams.0.get_downvalues.28}}</td> <td>{{beams.0.get_downvalues.29}}</td> <td>{{beams.0.get_downvalues.30}}</td> <td>{{beams.0.get_downvalues.31}}</td> | |
|
405 | <td {{beam.color_status.29}}>{{beam.get_downvalues.28}}</td> <td {{beam.color_status.30}}>{{beam.get_downvalues.29}}</td> <td {{beam.color_status.31}}>{{beam.get_downvalues.30}}</td> <td {{beam.color_status.32}}>{{beam.get_downvalues.31}}</td> | |
|
378 | 406 | </tr> |
|
379 | 407 | </table> |
|
380 | 408 | </td> |
|
381 | 409 | </tr> |
|
382 | 410 | <tr> |
|
383 | 411 | <td> <b>West Quarter</b> |
|
384 | 412 | <table class="west "> |
|
385 | 413 | <tr> |
|
386 | <td>{{beams.0.get_upvalues.32}}</td> <td>{{beams.0.get_upvalues.33}}</td> <td>{{beams.0.get_upvalues.34}}</td> <td>{{beams.0.get_upvalues.35}}</td> | |
|
414 | <td {{beam.color_status.33}}>{{beam.get_upvalues.32}}</td> <td {{beam.color_status.34}}>{{beam.get_upvalues.33}}</td> <td {{beam.color_status.35}}>{{beam.get_upvalues.34}}</td> <td {{beam.color_status.36}}>{{beam.get_upvalues.35}}</td> | |
|
387 | 415 | </tr> |
|
388 | 416 | <tr> |
|
389 | <td>{{beams.0.get_downvalues.32}}</td> <td>{{beams.0.get_downvalues.33}}</td> <td>{{beams.0.get_downvalues.34}}</td> <td>{{beams.0.get_downvalues.35}}</td> | |
|
417 | <td {{beam.color_status.33}}>{{beam.get_downvalues.32}}</td> <td {{beam.color_status.34}}>{{beam.get_downvalues.33}}</td> <td {{beam.color_status.35}}>{{beam.get_downvalues.34}}</td> <td {{beam.color_status.36}}>{{beam.get_downvalues.35}}</td> | |
|
390 | 418 | </tr> |
|
391 | 419 | <tr> |
|
392 | <td>{{beams.0.get_upvalues.40}}</td> <td>{{beams.0.get_upvalues.41}}</td> <td>{{beams.0.get_upvalues.42}}</td> <td>{{beams.0.get_upvalues.43}}</td> | |
|
420 | <td {{beam.color_status.41}}>{{beam.get_upvalues.40}}</td> <td {{beam.color_status.42}}>{{beam.get_upvalues.41}}</td> <td {{beam.color_status.43}}>{{beam.get_upvalues.42}}</td> <td {{beam.color_status.44}}>{{beam.get_upvalues.43}}</td> | |
|
393 | 421 | </tr> |
|
394 | 422 | <tr> |
|
395 | <td>{{beams.0.get_downvalues.40}}</td> <td>{{beams.0.get_downvalues.41}}</td> <td>{{beams.0.get_downvalues.42}}</td> <td>{{beams.0.get_downvalues.43}}</td> | |
|
423 | <td {{beam.color_status.41}}>{{beam.get_downvalues.40}}</td> <td {{beam.color_status.42}}>{{beam.get_downvalues.41}}</td> <td {{beam.color_status.43}}>{{beam.get_downvalues.42}}</td> <td {{beam.color_status.44}}>{{beam.get_downvalues.43}}</td> | |
|
396 | 424 | </tr> |
|
397 | 425 | <tr> |
|
398 | <td>{{beams.0.get_upvalues.48}}</td> <td>{{beams.0.get_upvalues.49}}</td> <td>{{beams.0.get_upvalues.50}}</td> <td>{{beams.0.get_upvalues.51}}</td> | |
|
426 | <td {{beam.color_status.49}}>{{beam.get_upvalues.48}}</td> <td {{beam.color_status.50}}>{{beam.get_upvalues.49}}</td> <td {{beam.color_status.51}}>{{beam.get_upvalues.50}}</td> <td {{beam.color_status.52}}>{{beam.get_upvalues.51}}</td> | |
|
399 | 427 | </tr> |
|
400 | 428 | <tr> |
|
401 | <td>{{beams.0.get_downvalues.48}}</td> <td>{{beams.0.get_downvalues.49}}</td> <td>{{beams.0.get_downvalues.50}}</td> <td>{{beams.0.get_downvalues.51}}</td> | |
|
429 | <td {{beam.color_status.49}}>{{beam.get_downvalues.48}}</td> <td {{beam.color_status.50}}>{{beam.get_downvalues.49}}</td> <td {{beam.color_status.51}}>{{beam.get_downvalues.50}}</td> <td {{beam.color_status.52}}>{{beam.get_downvalues.51}}</td> | |
|
402 | 430 | </tr> |
|
403 | 431 | <tr> |
|
404 | <td>{{beams.0.get_upvalues.56}}</td> <td>{{beams.0.get_upvalues.57}}</td> <td>{{beams.0.get_upvalues.58}}</td> <td>{{beams.0.get_upvalues.59}}</td> | |
|
432 | <td {{beam.color_status.57}}>{{beam.get_upvalues.56}}</td> <td {{beam.color_status.58}}>{{beam.get_upvalues.57}}</td> <td {{beam.color_status.59}}>{{beam.get_upvalues.58}}</td> <td {{beam.color_status.60}}>{{beam.get_upvalues.59}}</td> | |
|
405 | 433 | </tr> |
|
406 | 434 | <tr> |
|
407 | <td>{{beams.0.get_downvalues.56}}</td> <td>{{beams.0.get_downvalues.57}}</td> <td>{{beams.0.get_downvalues.58}}</td> <td>{{beams.0.get_downvalues.59}}</td> | |
|
435 | <td {{beam.color_status.57}}>{{beam.get_downvalues.56}}</td> <td {{beam.color_status.58}}>{{beam.get_downvalues.57}}</td> <td {{beam.color_status.59}}>{{beam.get_downvalues.58}}</td> <td {{beam.color_status.60}}>{{beam.get_downvalues.59}}</td> | |
|
408 | 436 | </tr> |
|
409 | 437 | </table> |
|
410 | 438 | </td> |
|
411 | 439 | <td> <b>South Quarter</b> |
|
412 | 440 | <table class="south "> |
|
413 | 441 | <tr> |
|
414 | <td>{{beams.0.get_upvalues.36}}</td> <td>{{beams.0.get_upvalues.37}}</td> <td>{{beams.0.get_upvalues.38}}</td> <td>{{beams.0.get_upvalues.39}}</td> | |
|
442 | <td {{beam.color_status.37}}>{{beam.get_upvalues.36}}</td> <td {{beam.color_status.38}}>{{beam.get_upvalues.37}}</td> <td {{beam.color_status.39}}>{{beam.get_upvalues.38}}</td> <td {{beam.color_status.40}}>{{beam.get_upvalues.39}}</td> | |
|
415 | 443 | </tr> |
|
416 | 444 | <tr> |
|
417 | <td>{{beams.0.get_downvalues.36}}</td> <td>{{beams.0.get_downvalues.37}}</td> <td>{{beams.0.get_downvalues.38}}</td> <td>{{beams.0.get_downvalues.39}}</td> | |
|
445 | <td {{beam.color_status.37}}>{{beam.get_downvalues.36}}</td> <td {{beam.color_status.38}}>{{beam.get_downvalues.37}}</td> <td {{beam.color_status.39}}>{{beam.get_downvalues.38}}</td> <td {{beam.color_status.40}}>{{beam.get_downvalues.39}}</td> | |
|
418 | 446 | </tr> |
|
419 | 447 | <tr> |
|
420 | <td>{{beams.0.get_upvalues.44}}</td> <td>{{beams.0.get_upvalues.45}}</td> <td>{{beams.0.get_upvalues.46}}</td> <td>{{beams.0.get_upvalues.47}}</td> | |
|
448 | <td {{beam.color_status.45}}>{{beam.get_upvalues.44}}</td> <td {{beam.color_status.46}}>{{beam.get_upvalues.45}}</td> <td {{beam.color_status.47}}>{{beam.get_upvalues.46}}</td> <td {{beam.color_status.48}}>{{beam.get_upvalues.47}}</td> | |
|
421 | 449 | </tr> |
|
422 | 450 | <tr> |
|
423 | <td>{{beams.0.get_downvalues.44}}</td> <td>{{beams.0.get_downvalues.45}}</td> <td>{{beams.0.get_downvalues.46}}</td> <td>{{beams.0.get_downvalues.47}}</td> | |
|
451 | <td {{beam.color_status.45}}>{{beam.get_downvalues.44}}</td> <td {{beam.color_status.46}}>{{beam.get_downvalues.45}}</td> <td {{beam.color_status.47}}>{{beam.get_downvalues.46}}</td> <td {{beam.color_status.48}}>{{beam.get_downvalues.47}}</td> | |
|
424 | 452 | </tr> |
|
425 | 453 | <tr> |
|
426 | <td>{{beams.0.get_upvalues.52}}</td> <td>{{beams.0.get_upvalues.53}}</td> <td>{{beams.0.get_upvalues.54}}</td> <td>{{beams.0.get_upvalues.55}}</td> | |
|
454 | <td {{beam.color_status.53}}>{{beam.get_upvalues.52}}</td> <td {{beam.color_status.54}}>{{beam.get_upvalues.53}}</td> <td {{beam.color_status.55}}>{{beam.get_upvalues.54}}</td> <td {{beam.color_status.56}}>{{beam.get_upvalues.55}}</td> | |
|
427 | 455 | </tr> |
|
428 | 456 | <tr> |
|
429 | <td>{{beams.0.get_downvalues.52}}</td> <td>{{beams.0.get_downvalues.53}}</td> <td>{{beams.0.get_downvalues.54}}</td> <td>{{beams.0.get_downvalues.55}}</td> | |
|
457 | <td {{beam.color_status.53}}>{{beam.get_downvalues.52}}</td> <td {{beam.color_status.54}}>{{beam.get_downvalues.53}}</td> <td {{beam.color_status.55}}>{{beam.get_downvalues.54}}</td> <td {{beam.color_status.56}}>{{beam.get_downvalues.55}}</td> | |
|
430 | 458 | </tr> |
|
431 | 459 | <tr> |
|
432 | <td>{{beams.0.get_upvalues.60}}</td> <td>{{beams.0.get_upvalues.61}}</td> <td>{{beams.0.get_upvalues.62}}</td> <td>{{beams.0.get_upvalues.63}}</td> | |
|
460 | <td {{beam.color_status.61}}>{{beam.get_upvalues.60}}</td> <td {{beam.color_status.62}}>{{beam.get_upvalues.61}}</td> <td {{beam.color_status.63}}>{{beam.get_upvalues.62}}</td> <td {{beam.color_status.64}}>{{beam.get_upvalues.63}}</td> | |
|
433 | 461 | </tr> |
|
434 | 462 | <tr> |
|
435 | <td>{{beams.0.get_downvalues.60}}</td> <td>{{beams.0.get_downvalues.61}}</td> <td>{{beams.0.get_downvalues.62}}</td> <td>{{beams.0.get_downvalues.63}}</td> | |
|
463 | <td {{beam.color_status.61}}>{{beam.get_downvalues.60}}</td> <td {{beam.color_status.62}}>{{beam.get_downvalues.61}}</td> <td {{beam.color_status.63}}>{{beam.get_downvalues.62}}</td> <td {{beam.color_status.64}}>{{beam.get_downvalues.63}}</td> | |
|
436 | 464 | </tr> |
|
437 | 465 | </table> |
|
438 | 466 | </td> |
|
439 | 467 | </tr> |
|
440 | 468 | </table> |
|
441 | 469 | |
|
470 | {% if active_beam.id != beam.id %} | |
|
471 | <div style="vertical-align: top; display:inline-block;"> | |
|
472 | <button style="" id="sendbeam" type="button" class="btn btn-default"> | |
|
473 | <span class="glyphicon glyphicon-export" aria-hidden="true"></span> | |
|
474 | Change Beam</button> | |
|
475 | </div> | |
|
476 | {% endif %} | |
|
477 | ||
|
478 | ||
|
479 | ||
|
480 | ||
|
481 | {% if active_beam %} | |
|
482 | {% if active_beam.id == beam.id %} | |
|
442 | 483 | <table class="legend"> |
|
443 | 484 | <tr> |
|
444 | 485 | <th colspan="2">Legend</th> |
|
445 | 486 | </tr> |
|
446 | 487 | <tr> |
|
447 | 488 | <td style="color:#ff0000;"><i>RED</i></td><td>Disconnected</td> |
|
448 | 489 | </tr> |
|
449 | 490 | <tr> |
|
450 | 491 | <td style="color:#ee902c;"><i>ORANGE</i></td><td>Connected</td> |
|
451 | 492 | </tr> |
|
452 | 493 | <tr> |
|
453 |
<td style="color:#00cc00;"><i>GREEN</i></td><td>Running |
|
|
494 | <td style="color:#00cc00;"><i>GREEN</i></td><td>Running | |
|
495 | </td> | |
|
454 | 496 | </tr> |
|
455 | 497 | </table> |
|
456 | 498 | |
|
499 | {% endif %} | |
|
500 | {% endif %} | |
|
501 | ||
|
502 | ||
|
503 | </div> | |
|
504 | ||
|
505 | ||
|
506 | {% endfor %} | |
|
507 | ||
|
508 | ||
|
509 | ||
|
510 | </div> | |
|
511 | </div> | |
|
512 | ||
|
513 | ||
|
514 | ||
|
515 | ||
|
516 | <script> | |
|
517 | $(document).ready(function() { | |
|
518 | ||
|
519 | ||
|
520 | }); | |
|
521 | </script> | |
|
522 | ||
|
523 | ||
|
524 | ||
|
525 | ||
|
526 | ||
|
527 | ||
|
457 | 528 | {% else %} |
|
458 | 529 | <p style="color:#b4bcc2; margin-left: 5%;"><i>No Beams...</i></p> |
|
459 | 530 | {% endif %} |
|
460 | 531 | |
|
461 | 532 | |
|
462 | 533 | {% endblock %} |
@@ -1,368 +1,373 | |||
|
1 | 1 | from django.shortcuts import render_to_response |
|
2 | 2 | from django.template import RequestContext |
|
3 | 3 | from django.shortcuts import redirect, render, get_object_or_404 |
|
4 | 4 | from django.contrib import messages |
|
5 | 5 | from django.conf import settings |
|
6 | 6 | from django.http import HttpResponse |
|
7 | 7 | |
|
8 | 8 | from datetime import datetime |
|
9 | 9 | from time import sleep |
|
10 | 10 | import os |
|
11 | 11 | |
|
12 | 12 | from apps.main.models import Device, Configuration |
|
13 | 13 | from apps.main.views import sidebar |
|
14 | 14 | |
|
15 | 15 | from .models import ABSConfiguration, ABSBeam |
|
16 | 16 | from .forms import ABSConfigurationForm, ABSBeamEditForm, ABSBeamAddForm |
|
17 | 17 | |
|
18 | 18 | from .utils.overJroShow import overJroShow |
|
19 | 19 | from .utils.OverJRO import OverJRO |
|
20 | 20 | # Create your views here. |
|
21 | 21 | import json, ast |
|
22 | 22 | |
|
23 | 23 | |
|
24 | 24 | def get_values_from_form(form_data): |
|
25 | 25 | |
|
26 | 26 | sublistup = [] |
|
27 | 27 | sublistdown = [] |
|
28 | 28 | subtxlistup = [] |
|
29 | 29 | subtxlistdown = [] |
|
30 | 30 | subrxlistup = [] |
|
31 | 31 | subrxlistdown = [] |
|
32 | 32 | |
|
33 | 33 | up_values_list = [] |
|
34 | 34 | down_values_list = [] |
|
35 | 35 | up_txvalues_list = [] |
|
36 | 36 | down_txvalues_list = [] |
|
37 | 37 | up_rxvalues_list = [] |
|
38 | 38 | down_rxvalues_list = [] |
|
39 | 39 | |
|
40 | 40 | values_list = {} |
|
41 | 41 | cont = 1 |
|
42 | 42 | |
|
43 | 43 | for i in range(1,65): |
|
44 | 44 | x = float(form_data['abs_up'+str(i)]) |
|
45 | 45 | y = float(form_data['abs_down'+str(i)]) |
|
46 | 46 | sublistup.append(x) |
|
47 | 47 | sublistdown.append(y) |
|
48 | 48 | |
|
49 | 49 | if str(i) in form_data.getlist('uptx_checks'): |
|
50 | 50 | subtxlistup.append(1) |
|
51 | 51 | else: |
|
52 | 52 | subtxlistup.append(0) |
|
53 | 53 | if str(i) in form_data.getlist('downtx_checks'): |
|
54 | 54 | subtxlistdown.append(1) |
|
55 | 55 | else: |
|
56 | 56 | subtxlistdown.append(0) |
|
57 | 57 | |
|
58 | 58 | if str(i) in form_data.getlist('uprx_checks'): |
|
59 | 59 | subrxlistup.append(1) |
|
60 | 60 | else: |
|
61 | 61 | subrxlistup.append(0) |
|
62 | 62 | if str(i) in form_data.getlist('downrx_checks'): |
|
63 | 63 | subrxlistdown.append(1) |
|
64 | 64 | else: |
|
65 | 65 | subrxlistdown.append(0) |
|
66 | 66 | |
|
67 | 67 | cont = cont+1 |
|
68 | 68 | |
|
69 | 69 | if cont == 9: |
|
70 | 70 | up_values_list.append(sublistup) |
|
71 | 71 | down_values_list.append(sublistdown) |
|
72 | 72 | sublistup = [] |
|
73 | 73 | sublistdown = [] |
|
74 | 74 | |
|
75 | 75 | up_txvalues_list.append(subtxlistup) |
|
76 | 76 | down_txvalues_list.append(subtxlistdown) |
|
77 | 77 | subtxlistup = [] |
|
78 | 78 | subtxlistdown = [] |
|
79 | 79 | up_rxvalues_list.append(subrxlistup) |
|
80 | 80 | down_rxvalues_list.append(subrxlistdown) |
|
81 | 81 | subrxlistup = [] |
|
82 | 82 | subrxlistdown = [] |
|
83 | 83 | cont = 1 |
|
84 | 84 | |
|
85 | 85 | |
|
86 | 86 | list_uesup = [] |
|
87 | 87 | list_uesdown = [] |
|
88 | 88 | for i in range(1,5): |
|
89 | 89 | if form_data['ues_up'+str(i)] == '': |
|
90 | 90 | list_uesup.append(0.0) |
|
91 | 91 | else: |
|
92 | 92 | list_uesup.append(float(form_data['ues_up'+str(i)])) |
|
93 | 93 | |
|
94 | 94 | if form_data['ues_down'+str(i)] == '': |
|
95 | 95 | list_uesdown.append(0.0) |
|
96 | 96 | else: |
|
97 | 97 | list_uesdown.append(float(form_data['ues_down'+str(i)])) |
|
98 | 98 | |
|
99 | 99 | onlyrx_list = form_data.getlist('onlyrx') |
|
100 | 100 | only_rx = {} |
|
101 | 101 | if '1' in onlyrx_list: |
|
102 | 102 | only_rx['up'] = True |
|
103 | 103 | else: |
|
104 | 104 | only_rx['up'] = False |
|
105 | 105 | if '2' in onlyrx_list: |
|
106 | 106 | only_rx['down'] = True |
|
107 | 107 | else: |
|
108 | 108 | only_rx['down'] = False |
|
109 | 109 | |
|
110 | 110 | antenna = {'antenna_up': up_values_list, 'antenna_down': down_values_list} |
|
111 | 111 | tx = {'up': up_txvalues_list, 'down': down_txvalues_list} |
|
112 | 112 | rx = {'up': up_rxvalues_list, 'down': down_rxvalues_list} |
|
113 | 113 | ues = {'up': list_uesup, 'down': list_uesdown} |
|
114 | 114 | name = str(form_data['beam_name']) |
|
115 | 115 | |
|
116 | 116 | beam_data = {'name': name, 'antenna': antenna, 'tx': tx, 'rx': rx, 'ues': ues, 'only_rx': only_rx} |
|
117 | 117 | |
|
118 | 118 | return beam_data |
|
119 | 119 | |
|
120 | 120 | |
|
121 | 121 | |
|
122 | 122 | def abs_conf(request, id_conf): |
|
123 | 123 | |
|
124 | 124 | conf = get_object_or_404(ABSConfiguration, pk=id_conf) |
|
125 | 125 | beams = ABSBeam.objects.filter(abs_conf=conf) |
|
126 | #beams_dict = ast.literal_eval(conf.beams) | |
|
127 | #beams = [] | |
|
128 | #for beam_id in range(1,len(beams_dict)+1): | |
|
129 | # beam = ABSBeam.objects.get(pk=beams_dict['beam'+str(beam_id)]) | |
|
130 | # beams.append(beam) | |
|
126 | active_beam_id = json.loads(conf.active_beam) | |
|
131 | 127 | |
|
132 | #beams_id = ast.literal_eval(conf.beams) | |
|
128 | #------------Colors for Active Beam:------------- | |
|
129 | modules_status = json.loads(conf.module_status) | |
|
133 | 130 | |
|
134 | ip=conf.device.ip_address | |
|
135 | port=conf.device.port_address | |
|
131 | color_status = {} | |
|
132 | for status in modules_status: | |
|
133 | if modules_status[status] == 2: #Running background-color: #ff0000; | |
|
134 | color_status[status] = 'bgcolor=#00cc00' | |
|
135 | elif modules_status[status] == 1: #Connected background-color: #ee902c; | |
|
136 | color_status[status] = 'bgcolor=#ee902c' | |
|
137 | else: #Disconnected background-color: #00cc00; | |
|
138 | color_status[status] = 'bgcolor=#FF0000' | |
|
139 | #------------------------------------------------ | |
|
136 | 140 | |
|
137 | 141 | kwargs = {} |
|
138 | 142 | kwargs['status'] = conf.device.get_status_display() |
|
139 | 143 | |
|
140 | 144 | |
|
141 | 145 | kwargs['dev_conf'] = conf |
|
142 | 146 | kwargs['dev_conf_keys'] = ['name',] |
|
143 | 147 | |
|
144 | 148 | kwargs['title'] = 'ABS Configuration' |
|
145 | 149 | kwargs['suptitle'] = 'Details' |
|
146 | 150 | kwargs['no_play'] = True |
|
147 | 151 | |
|
148 | 152 | kwargs['button'] = 'Edit Configuration' |
|
149 | ||
|
150 | #kwargs['no_play'] = True | |
|
151 | #kwargs['beams_id'] = beams_id | |
|
153 | #------------------Active Beam----------------------- | |
|
154 | try: | |
|
155 | active_beam_id = active_beam_id['active_beam'] | |
|
156 | active_beam = ABSBeam.objects.get(pk=active_beam_id) | |
|
157 | kwargs['active_beam'] = active_beam | |
|
158 | for beam in beams: | |
|
159 | if beam.id == active_beam.id: | |
|
160 | beam.color_status=color_status | |
|
161 | except: | |
|
162 | active_beam = '' | |
|
163 | #---------------------------------------------------- | |
|
152 | 164 | kwargs['beams'] = beams |
|
153 | kwargs['beam_selector'] = 0 | |
|
154 | #kwargs['my_data'] = simplejson.dumps(beams) | |
|
165 | kwargs['modules_status'] = modules_status | |
|
166 | kwargs['color_status'] = color_status | |
|
155 | 167 | |
|
156 | 168 | kwargs['only_stop'] = True |
|
157 | 169 | |
|
158 | 170 | ###### SIDEBAR ###### |
|
159 | 171 | kwargs.update(sidebar(conf=conf)) |
|
160 | 172 | |
|
161 | 173 | return render(request, 'abs_conf.html', kwargs) |
|
162 | 174 | |
|
163 | 175 | def abs_conf_edit(request, id_conf): |
|
164 | 176 | |
|
165 | 177 | conf = get_object_or_404(ABSConfiguration, pk=id_conf) |
|
166 | #beams_list = ast.literal_eval(conf.beams) | |
|
167 | #i = 1 | |
|
168 | #beams = [] | |
|
169 | #for b in beams_list: | |
|
170 | # beam = ABSBeam.objects.get(pk=beams_list['beam'+str(i)]) | |
|
171 | # beams.append(beam) | |
|
172 | # i=i+1 | |
|
173 | 178 | |
|
174 | 179 | beams = ABSBeam.objects.filter(abs_conf=conf) |
|
175 | 180 | print beams |
|
176 | 181 | |
|
177 | 182 | if request.method=='GET': |
|
178 | 183 | form = ABSConfigurationForm(instance=conf) |
|
179 | 184 | |
|
180 | 185 | if request.method=='POST': |
|
181 | 186 | form = ABSConfigurationForm(request.POST, instance=conf) |
|
182 | 187 | |
|
183 | 188 | if form.is_valid(): |
|
184 | 189 | conf = form.save(commit=False) |
|
185 | 190 | conf.save() |
|
186 | 191 | return redirect('url_abs_conf', id_conf=conf.id) |
|
187 | 192 | |
|
188 | 193 | ###### SIDEBAR ###### |
|
189 | 194 | kwargs = {} |
|
190 | 195 | |
|
191 | 196 | kwargs['dev_conf'] = conf |
|
192 | 197 | #kwargs['id_dev'] = conf.id |
|
193 | 198 | kwargs['id_conf'] = conf.id |
|
194 | 199 | kwargs['form'] = form |
|
195 | 200 | kwargs['abs_beams'] = beams |
|
196 | 201 | kwargs['title'] = 'Device Configuration' |
|
197 | 202 | kwargs['suptitle'] = 'Edit' |
|
198 | 203 | kwargs['button'] = 'Save' |
|
199 | 204 | |
|
200 | 205 | kwargs['edit'] = True |
|
201 | 206 | |
|
202 | 207 | return render(request, 'abs_conf_edit.html', kwargs) |
|
203 | 208 | |
|
204 | 209 | |
|
205 | 210 | |
|
206 | 211 | |
|
207 | 212 | def add_beam(request, id_conf): |
|
208 | 213 | |
|
209 | 214 | conf = get_object_or_404(ABSConfiguration, pk=id_conf) |
|
210 | 215 | confs = Configuration.objects.all() |
|
211 | 216 | |
|
212 | 217 | if request.method=='GET': |
|
213 | 218 | #form = ABSBeamEditForm() |
|
214 | 219 | form = ABSBeamAddForm() |
|
215 | 220 | |
|
216 | 221 | if request.method=='POST': |
|
217 | 222 | form = ABSBeamAddForm(request.POST) |
|
218 | 223 | |
|
219 | 224 | beam_data = get_values_from_form(request.POST) |
|
220 | 225 | |
|
221 | 226 | new_beam = ABSBeam( |
|
222 | 227 | name =beam_data['name'], |
|
223 | 228 | antenna =json.dumps(beam_data['antenna']), |
|
224 | 229 | abs_conf=conf, |
|
225 | 230 | tx =json.dumps(beam_data['tx']), |
|
226 | 231 | rx =json.dumps(beam_data['rx']), |
|
227 | 232 | ues =json.dumps(beam_data['ues']), |
|
228 | 233 | only_rx =json.dumps(beam_data['only_rx']) |
|
229 | 234 | ) |
|
230 | 235 | new_beam.save() |
|
231 | 236 | #---Update 6bits configuration and add beam to abs configuration beams list. |
|
232 | 237 | new_beam.modules_6bits() |
|
233 | new_beam.add_beam2list() | |
|
238 | #new_beam.add_beam2list() | |
|
234 | 239 | messages.success(request, 'Beam: "%s" has been added.' % new_beam.name) |
|
235 | 240 | |
|
236 | 241 | return redirect('url_edit_abs_conf', conf.id) |
|
237 | 242 | |
|
238 | 243 | ###### SIDEBAR ###### |
|
239 | 244 | kwargs = {} |
|
240 | 245 | |
|
241 | 246 | #kwargs['dev_conf'] = conf.device |
|
242 | 247 | #kwargs['id_dev'] = conf.device |
|
243 | 248 | kwargs['id_conf'] = conf.id |
|
244 | 249 | kwargs['form'] = form |
|
245 | 250 | kwargs['title'] = 'ABS Beams' |
|
246 | 251 | kwargs['suptitle'] = 'Add Beam' |
|
247 | 252 | kwargs['button'] = 'Add' |
|
248 | 253 | kwargs['no_sidebar'] = True |
|
249 | 254 | |
|
250 | 255 | #kwargs['previous'] = conf.get_absolute_url_edit() |
|
251 | 256 | kwargs['edit'] = True |
|
252 | 257 | |
|
253 | 258 | return render(request, 'abs_add_beam.html', kwargs) |
|
254 | 259 | |
|
255 | 260 | |
|
256 | 261 | def edit_beam(request, id_conf, id_beam): |
|
257 | 262 | |
|
258 | 263 | conf = get_object_or_404(ABSConfiguration, pk=id_conf) |
|
259 | 264 | beam = get_object_or_404(ABSBeam, pk=id_beam) |
|
260 | 265 | |
|
261 | 266 | if request.method=='GET': |
|
262 | 267 | form = ABSBeamEditForm(initial={'beam': beam}) |
|
263 | 268 | |
|
264 | 269 | if request.method=='POST': |
|
265 | 270 | form = ABSBeamEditForm(request.POST) |
|
266 | 271 | |
|
267 | 272 | beam_data = get_values_from_form(request.POST) |
|
268 | 273 | |
|
269 | 274 | beam.dict_to_parms(beam_data) |
|
270 | 275 | beam.save() |
|
271 | 276 | |
|
272 | 277 | messages.success(request, 'Beam: "%s" has been updated.' % beam.name) |
|
273 | 278 | |
|
274 | 279 | return redirect('url_edit_abs_conf', conf.id) |
|
275 | 280 | |
|
276 | 281 | ###### SIDEBAR ###### |
|
277 | 282 | kwargs = {} |
|
278 | 283 | |
|
279 | 284 | kwargs['id_conf'] = conf.id |
|
280 | 285 | kwargs['form'] = form |
|
281 | 286 | kwargs['title'] = 'ABS Beams' |
|
282 | 287 | kwargs['suptitle'] = 'Edit Beam' |
|
283 | 288 | kwargs['button'] = 'Save' |
|
284 | 289 | kwargs['no_sidebar'] = True |
|
285 | 290 | |
|
286 | 291 | #kwargs['previous'] = conf.get_absolute_url_edit() |
|
287 | 292 | kwargs['edit'] = True |
|
288 | 293 | |
|
289 | 294 | return render(request, 'abs_edit_beam.html', kwargs) |
|
290 | 295 | |
|
291 | 296 | |
|
292 | 297 | |
|
293 | 298 | def remove_beam(request, id_conf, id_beam): |
|
294 | 299 | |
|
295 | 300 | conf = get_object_or_404(ABSConfiguration, pk=id_conf) |
|
296 | 301 | beam = get_object_or_404(ABSBeam, pk=id_beam) |
|
297 | 302 | |
|
298 | 303 | if request.method=='POST': |
|
299 | 304 | if beam: |
|
300 | 305 | try: |
|
301 | 306 | beam.remove_beamfromlist() |
|
302 | 307 | beam.delete() |
|
303 | 308 | messages.success(request, 'Beam: "%s" has been deleted.' % beam) |
|
304 | 309 | except: |
|
305 | 310 | messages.error(request, 'Unable to delete beam: "%s".' % beam) |
|
306 | 311 | |
|
307 | 312 | return redirect('url_edit_abs_conf', conf.id) |
|
308 | 313 | |
|
309 | 314 | ###### SIDEBAR ###### |
|
310 | 315 | kwargs = {} |
|
311 | 316 | |
|
312 | 317 | kwargs['object'] = beam |
|
313 | 318 | kwargs['delete'] = True |
|
314 | 319 | kwargs['title'] = 'Delete' |
|
315 | 320 | kwargs['suptitle'] = 'Beam' |
|
316 | 321 | kwargs['previous'] = conf.get_absolute_url_edit() |
|
317 | 322 | return render(request, 'confirm.html', kwargs) |
|
318 | 323 | |
|
319 | 324 | |
|
320 | 325 | |
|
321 | 326 | def plot_patterns(request, id_conf, id_beam=None): |
|
322 | 327 | |
|
323 | 328 | kwargs = {} |
|
324 | 329 | conf = get_object_or_404(ABSConfiguration, pk=id_conf) |
|
325 | 330 | beams = ABSBeam.objects.filter(abs_conf=conf) |
|
326 | 331 | |
|
327 | 332 | if id_beam: |
|
328 | 333 | beam = get_object_or_404(ABSBeam, pk=id_beam) |
|
329 | 334 | kwargs['beam'] = beam |
|
330 | 335 | |
|
331 | 336 | |
|
332 | 337 | ###### SIDEBAR ###### |
|
333 | 338 | |
|
334 | 339 | kwargs['dev_conf'] = conf.device |
|
335 | 340 | kwargs['id_dev'] = conf.device |
|
336 | 341 | kwargs['id_conf'] = conf.id |
|
337 | 342 | kwargs['abs_beams'] = beams |
|
338 | 343 | kwargs['title'] = 'ABS Patterns' |
|
339 | 344 | kwargs['suptitle'] = conf.name |
|
340 | 345 | kwargs['no_sidebar'] = True |
|
341 | 346 | |
|
342 | 347 | return render(request, 'abs_patterns.html', kwargs) |
|
343 | 348 | |
|
344 | 349 | |
|
345 | 350 | def plot_pattern(request, id_conf, id_beam, antenna): |
|
346 | 351 | |
|
347 | 352 | if antenna=='down': |
|
348 | 353 | sleep(3) |
|
349 | 354 | |
|
350 | 355 | conf = get_object_or_404(ABSConfiguration, pk=id_conf) |
|
351 | 356 | beam = get_object_or_404(ABSBeam, pk=id_beam) |
|
352 | 357 | |
|
353 | 358 | name = conf.experiment.name |
|
354 | 359 | |
|
355 | 360 | just_rx = 1 if json.loads(beam.only_rx)[antenna] else 0 |
|
356 | 361 | phases = json.loads(beam.antenna)['antenna_{}'.format(antenna)] |
|
357 | 362 | gain_tx = json.loads(beam.tx)[antenna] |
|
358 | 363 | gain_rx = json.loads(beam.rx)[antenna] |
|
359 | 364 | ues = json.loads(beam.ues)[antenna] |
|
360 | 365 | |
|
361 | 366 | newOverJro = overJroShow(name) |
|
362 | 367 | fig = newOverJro.plotPattern2(datetime.today(), phases, gain_tx, gain_rx, ues, just_rx) |
|
363 | 368 | |
|
364 | 369 | response=HttpResponse(content_type='image/png') |
|
365 | 370 | |
|
366 | 371 | fig.canvas.print_png(response) |
|
367 | 372 | |
|
368 | 373 | return response |
General Comments 0
You need to be logged in to leave comments.
Login now