##// END OF EJS Templates
Recuperación parcial
Renato Huallpa -
r383:10ef20bfab46
parent child
Show More
@@ -0,0 +1,39
1 import os
2 import paho.mqtt.client as mqtt
3 from radarsys import settings
4 from radarsys.socketconfig import sio as sio
5
6 lista_ack=[
7 chr( 33 ), chr( 34 ), chr( 35 ), chr( 36 ), chr( 37 ), chr( 38 ), chr( 39 ), chr( 40 ), chr( 41 ), chr( 42 ), chr( 43 ), chr( 44 ), chr( 45 ), chr( 46 ), chr( 47 ), chr( 48 ), chr( 49 ), chr( 50 ), chr( 51 ), chr( 52 ), chr( 53 ), chr( 54 ), chr( 55 ), chr( 56 ), chr( 57 ), chr( 58 ), chr( 59 ), chr( 60 ), chr( 61 ), chr( 62 ), chr( 63 ), chr( 64 ), chr( 65 ), chr( 66 ), chr( 67 ), chr( 68 ), chr( 69 ), chr( 70 ), chr( 71 ), chr( 72 ), chr( 73 ), chr( 74 ), chr( 75 ), chr( 76 ), chr( 77 ), chr( 78 ), chr( 79 ), chr( 80 ), chr( 81 ), chr( 82 ), chr( 83 ), chr( 84 ), chr( 85 ), chr( 86 ), chr( 87 ), chr( 88 ), chr( 89 ), chr( 90 ), chr( 91 ), chr( 92 ), chr( 93 ), chr( 94 ), chr( 95 ), chr( 96 )
8 ]
9
10 lista_ack_dismatching=[
11 chr( 97 ), chr( 98 ), chr( 99 ), chr( 100 ), chr( 101 ), chr( 102 ), chr( 103 ), chr( 104 ), chr( 105 ), chr( 106 ), chr( 107 ), chr( 108 ), chr( 109 ), chr( 110 ), chr( 111 ), chr( 112 ), chr( 113 ), chr( 114 ), chr( 115 ), chr( 116 ), chr( 117 ), chr( 118 ), chr( 119 ), chr( 120 ), chr( 121 ), chr( 122 ), chr( 123 ), chr( 124 ), chr( 125 ), chr( 126 ), chr( 127 ), chr( 128 ), chr( 129 ), chr( 130 ), chr( 131 ), chr( 132 ), chr( 133 ), chr( 134 ), chr( 135 ), chr( 136 ), chr( 137 ), chr( 138 ), chr( 139 ), chr( 140 ), chr( 141 ), chr( 142 ), chr( 143 ), chr( 144 ), chr( 145 ), chr( 146 ), chr( 147 ), chr( 148 ), chr( 149 ), chr( 150 ), chr( 151 ), chr( 152 ), chr( 153 ), chr( 154 ), chr( 155 ), chr( 156 ), chr( 157 ), chr( 158 ), chr( 159 ), chr(160)
12 ]
13
14 def on_connect(mqtt_client, userdata, flags, rc):
15 if rc == 0:
16 print('Connected successfully')
17 mqtt_client.subscribe(os.environ.get('TOPIC_ABS_ACK','abs/beams_ack'))
18 else:
19 print('Bad connection. Code:', rc)
20
21 def on_message(mqtt_client, userdata, msg):
22 # print(f'Received message on topic: {msg.topic} with payload: {msg.payload}', flush=True)
23 # message= str(msg.payload)
24 # sio.emit('abs_ws',data={'msg':message})
25 #message=str(msg.payload)
26 #lista_ack.pop(message)
27 print("Mientras" ,flush=True)
28
29
30
31 client = mqtt.Client()
32 client.on_connect = on_connect
33 client.on_message = on_message
34 client.username_pw_set(os.environ.get('MQTT_USER', 'abs'), os.environ.get('MQTT_PASSWORD', 'abs'))
35 client.connect(
36 host=os.environ.get('MQTT_SERVER', '10.10.10.200'),
37 port=int(settings.os.environ.get('MQTT_PORT', 1883)),
38 keepalive=int(os.environ.get('MQTT_KEEPALIVE', 36000))
39 ) No newline at end of file
@@ -1,19 +1,32
1
1
2 REDIS_HOST=radarsys-redis
2 REDIS_HOST=radarsys-redis
3 REDIS_PORT=6300
3 REDIS_PORT=6300
4 POSTGRES_PORT_5432_TCP_ADDR=radarsys-postgres
4 POSTGRES_PORT_5432_TCP_ADDR=radarsys-postgres
5 POSTGRES_PORT_5432_TCP_PORT=5432
5 POSTGRES_PORT_5432_TCP_PORT=5432
6 #POSTGRES_HOST=postgres
6 #POSTGRES_HOST=postgres
7 POSTGRES_HOST=localhost
7 POSTGRES_HOST=localhost
8 POSTGRES_USER=docker
8 POSTGRES_USER=docker
9 POSTGRES_PASSWORD=docker
9 POSTGRES_PASSWORD=docker
10 POSTGRES_DB=radarsys
10 POSTGRES_DB=radarsys
11
11
12 # DB_NAME=radarsys
12 # DB_NAME=radarsys
13 # DB_USER=docker
13 # DB_USER=docker
14 # DB_PASSWORD=docker
14 # DB_PASSWORD=docker
15 PGDATA=/var/lib/postgresql/data
15 PGDATA=/var/lib/postgresql/data
16 LC_ALL=C.UTF-8
16 LC_ALL=C.UTF-8
17 TZ=America/Lima
17 TZ=America/Lima
18 DOCKER_DATA=/data/dockers/radarsys/
18 DOCKER_DATA=/data/dockers/radarsys/
19 LOCAL_IP=192.168.1.128
19 LOCAL_IP=192.168.1.128
20
21 MQTT_SERVER=10.10.10.102
22 #MQTT_SERVER = 0.0.0.0
23 MQTT_PORT = 1883
24 MQTT_KEEPALIVE = 3660
25
26 MQTT_USER_ATRAD=atrad
27 MQTT_PASSWORD_ATRAD = atrad
28 MQTT_USER = abs
29 MQTT_PASSWORD = abs
30 MQTT_CLIENT_ID= abs_id
31 TOPIC_ABS=abs/beams
32 TOPIC_ABS_ACK=abs/beams_ack
@@ -1,1013 +1,1038
1 from django.db import models
1 from django.db import models
2 from apps.main.models import Configuration , User
2 from apps.main.models import Configuration , User
3 from django.urls import reverse
3 from django.urls import reverse
4 from celery.execute import send_task
4 from celery.execute import send_task
5 from datetime import datetime
5 from datetime import datetime
6 import ast
6 import ast
7 import socket
7 import socket
8 import json
8 import json
9 import requests
9 import requests
10 import struct
10 import struct
11 import os, sys, time
11 import os, sys, time
12
12
13 from .mqtt import client as mqtt_client
14 from radarsys.socketconfig import sio as sio
15 import json
16
13 antenna_default = json.dumps({
17 antenna_default = json.dumps({
14 "antenna_up": [[0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
18 "antenna_up": [[0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
15 [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
19 [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
16 [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
20 [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
17 [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
21 [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
18 [0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0],
22 [0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0],
19 [0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0],
23 [0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0],
20 [0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0],
24 [0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0],
21 [0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0]
25 [0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0]
22 ]
26 ]
23 ,
27 ,
24 "antenna_down": [[0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
28 "antenna_down": [[0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
25 [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
29 [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
26 [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
30 [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
27 [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
31 [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
28 [0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0],
32 [0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0],
29 [0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0],
33 [0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0],
30 [0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0],
34 [0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0],
31 [0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0]],
35 [0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0]],
32 })
36 })
33
37
34
38
35 tx_default = json.dumps({
39 tx_default = json.dumps({
36 "up": [[1,1,1,1,0,0,0,0],
40 "up": [[1,1,1,1,0,0,0,0],
37 [1,1,1,1,0,0,0,0],
41 [1,1,1,1,0,0,0,0],
38 [1,1,1,1,0,0,0,0],
42 [1,1,1,1,0,0,0,0],
39 [1,1,1,1,0,0,0,0],
43 [1,1,1,1,0,0,0,0],
40 [0,0,0,0,1,1,1,1],
44 [0,0,0,0,1,1,1,1],
41 [0,0,0,0,1,1,1,1],
45 [0,0,0,0,1,1,1,1],
42 [0,0,0,0,1,1,1,1],
46 [0,0,0,0,1,1,1,1],
43 [0,0,0,0,1,1,1,1]],
47 [0,0,0,0,1,1,1,1]],
44
48
45 "down": [[1,1,1,1,0,0,0,0],
49 "down": [[1,1,1,1,0,0,0,0],
46 [1,1,1,1,0,0,0,0],
50 [1,1,1,1,0,0,0,0],
47 [1,1,1,1,0,0,0,0],
51 [1,1,1,1,0,0,0,0],
48 [1,1,1,1,0,0,0,0],
52 [1,1,1,1,0,0,0,0],
49 [0,0,0,0,1,1,1,1],
53 [0,0,0,0,1,1,1,1],
50 [0,0,0,0,1,1,1,1],
54 [0,0,0,0,1,1,1,1],
51 [0,0,0,0,1,1,1,1],
55 [0,0,0,0,1,1,1,1],
52 [0,0,0,0,1,1,1,1]],
56 [0,0,0,0,1,1,1,1]],
53 })
57 })
54
58
55 rx_default = json.dumps({
59 rx_default = json.dumps({
56 "up": [[1,1,1,1,0,0,0,0],
60 "up": [[1,1,1,1,0,0,0,0],
57 [1,1,1,1,0,0,0,0],
61 [1,1,1,1,0,0,0,0],
58 [1,1,1,1,0,0,0,0],
62 [1,1,1,1,0,0,0,0],
59 [1,1,1,1,0,0,0,0],
63 [1,1,1,1,0,0,0,0],
60 [0,0,0,0,1,1,1,1],
64 [0,0,0,0,1,1,1,1],
61 [0,0,0,0,1,1,1,1],
65 [0,0,0,0,1,1,1,1],
62 [0,0,0,0,1,1,1,1],
66 [0,0,0,0,1,1,1,1],
63 [0,0,0,0,1,1,1,1]],
67 [0,0,0,0,1,1,1,1]],
64
68
65 "down": [[1,1,1,1,0,0,0,0],
69 "down": [[1,1,1,1,0,0,0,0],
66 [1,1,1,1,0,0,0,0],
70 [1,1,1,1,0,0,0,0],
67 [1,1,1,1,0,0,0,0],
71 [1,1,1,1,0,0,0,0],
68 [1,1,1,1,0,0,0,0],
72 [1,1,1,1,0,0,0,0],
69 [0,0,0,0,1,1,1,1],
73 [0,0,0,0,1,1,1,1],
70 [0,0,0,0,1,1,1,1],
74 [0,0,0,0,1,1,1,1],
71 [0,0,0,0,1,1,1,1],
75 [0,0,0,0,1,1,1,1],
72 [0,0,0,0,1,1,1,1]],
76 [0,0,0,0,1,1,1,1]],
73 })
77 })
74
78
75 status_default = '0000000000000000000000000000000000000000000000000000000000000000'
79 status_default = '0000000000000000000000000000000000000000000000000000000000000000'
76 default_messages = {}
80 default_messages = {}
77
81
78 for i in range(1,65):
82 for i in range(1,65):
79 default_messages[str(i)] = "Module "+str(i)
83 default_messages[str(i)] = "Module "+str(i)
80
84
81
85
82 ues_default = json.dumps({
86 ues_default = json.dumps({
83 "up": [0.533333,0.00000,1.06667,0.00000],
87 "up": [0.533333,0.00000,1.06667,0.00000],
84 "down": [0.533333,0.00000,1.06667,0.00000]
88 "down": [0.533333,0.00000,1.06667,0.00000]
85 })
89 })
86
90
87 onlyrx_default = json.dumps({
91 onlyrx_default = json.dumps({
88 "up": False,
92 "up": False,
89 "down": False
93 "down": False
90 })
94 })
91
95
92 def up_convertion(cadena):
96 def up_convertion(cadena):
93 valores = []
97 valores = []
94 for c in cadena:
98 for c in cadena:
95 if c == 1.0: valores=valores+['000']
99 if c == 1.0: valores=valores+['000']
96 if c == 2.0: valores=valores+['001']
100 if c == 2.0: valores=valores+['001']
97 if c == 3.0: valores=valores+['010']
101 if c == 3.0: valores=valores+['010']
98 if c == 0.0: valores=valores+['011']
102 if c == 0.0: valores=valores+['011']
99 if c == 0.5: valores=valores+['100']
103 if c == 0.5: valores=valores+['100']
100 if c == 1.5: valores=valores+['101']
104 if c == 1.5: valores=valores+['101']
101 if c == 2.5: valores=valores+['110']
105 if c == 2.5: valores=valores+['110']
102 if c == 3.5: valores=valores+['111']
106 if c == 3.5: valores=valores+['111']
103
107
104 return valores
108 return valores
105
109
106 def up_conv_bits(value):
110 def up_conv_bits(value):
107
111
108 if value == 1.0: bits="000"
112 if value == 1.0: bits="000"
109 if value == 2.0: bits="001"
113 if value == 2.0: bits="001"
110 if value == 3.0: bits="010"
114 if value == 3.0: bits="010"
111 if value == 0.0: bits="011"
115 if value == 0.0: bits="011"
112 if value == 0.5: bits="100"
116 if value == 0.5: bits="100"
113 if value == 1.5: bits="101"
117 if value == 1.5: bits="101"
114 if value == 2.5: bits="110"
118 if value == 2.5: bits="110"
115 if value == 3.5: bits="111"
119 if value == 3.5: bits="111"
116
120
117 return bits
121 return bits
118
122
119 def down_convertion(cadena):
123 def down_convertion(cadena):
120 valores = []
124 valores = []
121 for c in cadena:
125 for c in cadena:
122 if c == 1.0: valores=valores+['000']
126 if c == 1.0: valores=valores+['000']
123 if c == 2.0: valores=valores+['001']
127 if c == 2.0: valores=valores+['001']
124 if c == 3.0: valores=valores+['010']
128 if c == 3.0: valores=valores+['010']
125 if c == 0.0: valores=valores+['011']
129 if c == 0.0: valores=valores+['011']
126 if c == 0.5: valores=valores+['100']
130 if c == 0.5: valores=valores+['100']
127 if c == 1.5: valores=valores+['101']
131 if c == 1.5: valores=valores+['101']
128 if c == 2.5: valores=valores+['110']
132 if c == 2.5: valores=valores+['110']
129 if c == 3.5: valores=valores+['111']
133 if c == 3.5: valores=valores+['111']
130
134
131 return valores
135 return valores
132
136
133 def down_conv_bits(value):
137 def down_conv_bits(value):
134
138
135 if value == 1.0: bits="000"
139 if value == 1.0: bits="000"
136 if value == 2.0: bits="001"
140 if value == 2.0: bits="001"
137 if value == 3.0: bits="010"
141 if value == 3.0: bits="010"
138 if value == 0.0: bits="011"
142 if value == 0.0: bits="011"
139 if value == 0.5: bits="100"
143 if value == 0.5: bits="100"
140 if value == 1.5: bits="101"
144 if value == 1.5: bits="101"
141 if value == 2.5: bits="110"
145 if value == 2.5: bits="110"
142 if value == 3.5: bits="111"
146 if value == 3.5: bits="111"
143
147
144 return bits
148 return bits
145
149
146 def up_conv_value(bits):
150 def up_conv_value(bits):
147
151
148 if bits == "000": value=1.0
152 if bits == "000": value=1.0
149 if bits == "001": value=2.0
153 if bits == "001": value=2.0
150 if bits == "010": value=3.0
154 if bits == "010": value=3.0
151 if bits == "011": value=0.0
155 if bits == "011": value=0.0
152 if bits == "100": value=0.5
156 if bits == "100": value=0.5
153 if bits == "101": value=1.5
157 if bits == "101": value=1.5
154 if bits == "110": value=2.5
158 if bits == "110": value=2.5
155 if bits == "111": value=3.5
159 if bits == "111": value=3.5
156
160
157 return value
161 return value
158
162
159 def down_conv_value(bits):
163 def down_conv_value(bits):
160
164
161 if bits == "000": value=1.0
165 if bits == "000": value=1.0
162 if bits == "001": value=2.0
166 if bits == "001": value=2.0
163 if bits == "010": value=3.0
167 if bits == "010": value=3.0
164 if bits == "011": value=0.0
168 if bits == "011": value=0.0
165 if bits == "100": value=0.5
169 if bits == "100": value=0.5
166 if bits == "101": value=1.5
170 if bits == "101": value=1.5
167 if bits == "110": value=2.5
171 if bits == "110": value=2.5
168 if bits == "111": value=3.5
172 if bits == "111": value=3.5
169
173
170 return value
174 return value
171
175
172 def ip2position(module_number):
176 def ip2position(module_number):
173 j=0
177 j=0
174 i=0
178 i=0
175 for x in range(0,module_number-1):
179 for x in range(0,module_number-1):
176 j=j+1
180 j=j+1
177 if j==8:
181 if j==8:
178 i=i+1
182 i=i+1
179 j=0
183 j=0
180
184
181 pos = [i,j]
185 pos = [i,j]
182 return pos
186 return pos
183
187
184
188
185 def fromBinary2Char(binary_string):
189 def fromBinary2Char(binary_string):
186 number = int(binary_string, 2)
190 number = int(binary_string, 2)
187 #Plus 33 to avoid more than 1 characters values such as: '\x01'-'\x1f'
191 #Plus 33 to avoid more than 1 characters values such as: '\x01'-'\x1f'
188 number = number + 33
192 number = number + 33
189 char = chr(number)
193 char = chr(number)
190 return char
194 return char
191
195
192 def fromChar2Binary(char):
196 def fromChar2Binary(char):
193 number = ord(char) - 33
197 number = ord(char) - 33
194 #Minus 33 to get the real value
198 #Minus 33 to get the real value
195 bits = bin(number)[2:]
199 bits = bin(number)[2:]
196 #To ensure we have a string with 6bits
200 #To ensure we have a string with 6bits
197 if len(bits) < 6:
201 if len(bits) < 6:
198 bits = bits.zfill(6)
202 bits = bits.zfill(6)
199 return bits
203 return bits
200
204
201 OPERATION_MODES = (
205 OPERATION_MODES = (
202 (0, 'Manual'),
206 (0, 'Manual'),
203 (1, 'Automatic'),
207 (1, 'Automatic'),
204 )
208 )
205
209
206 class ABSConfiguration(Configuration):
210 class ABSConfiguration(Configuration):
207 active_beam = models.PositiveSmallIntegerField(verbose_name='Active Beam', default=0)
211 active_beam = models.PositiveSmallIntegerField(verbose_name='Active Beam', default=0)
208 module_status = models.CharField(verbose_name='Module Status', max_length=10000, default=status_default)
212 module_status = models.CharField(verbose_name='Module Status', max_length=10000, default=status_default)
209 operation_mode = models.PositiveSmallIntegerField(verbose_name='Operation Mode', choices=OPERATION_MODES, default = 0)
213 operation_mode = models.PositiveSmallIntegerField(verbose_name='Operation Mode', choices=OPERATION_MODES, default = 0)
210 operation_value = models.FloatField(verbose_name='Periodic (seconds)', default="10", null=True, blank=True)
214 operation_value = models.FloatField(verbose_name='Periodic (seconds)', default="10", null=True, blank=True)
211 module_messages = models.CharField(verbose_name='Modules Messages', max_length=10000, default=json.dumps(default_messages))
215 module_messages = models.CharField(verbose_name='Modules Messages', max_length=10000, default=json.dumps(default_messages))
212
216
213 class Meta:
217 class Meta:
214 db_table = 'abs_configurations'
218 db_table = 'abs_configurations'
215
219
216 def get_absolute_url_plot(self):
220 def get_absolute_url_plot(self):
217 return reverse('url_plot_abs_patterns', args=[str(self.id)])
221 return reverse('url_plot_abs_patterns', args=[str(self.id)])
218
222
219
223
220 def parms_to_dict(self):
224 def parms_to_dict(self):
221
225
222 parameters = {}
226 parameters = {}
223
227
224 parameters['device_id'] = self.device.id
228 parameters['device_id'] = self.device.id
225 parameters['label'] = self.label
229 parameters['label'] = self.label
226 parameters['device_type'] = self.device.device_type.name
230 parameters['device_type'] = self.device.device_type.name
227 parameters['beams'] = {}
231 parameters['beams'] = {}
228
232
229 beams = ABSBeam.objects.filter(abs_conf=self)
233 beams = ABSBeam.objects.filter(abs_conf=self)
230 b=1
234 b=1
231 for beam in beams:
235 for beam in beams:
232 #absbeam = ABSBeam.objects.get(pk=beams[beam])
236 #absbeam = ABSBeam.objects.get(pk=beams[beam])
233 parameters['beams']['beam'+str(b)] = beam.parms_to_dict()#absbeam.parms_to_dict()
237 parameters['beams']['beam'+str(b)] = beam.parms_to_dict()#absbeam.parms_to_dict()
234 b+=1
238 b+=1
235
239
236 return parameters
240 return parameters
237
241
238
242
239 def dict_to_parms(self, parameters):
243 def dict_to_parms(self, parameters):
240
244
241 self.label = parameters['label']
245 self.label = parameters['label']
242
246
243 absbeams = ABSBeam.objects.filter(abs_conf=self)
247 absbeams = ABSBeam.objects.filter(abs_conf=self)
244 beams = parameters['beams']
248 beams = parameters['beams']
245
249
246 if absbeams:
250 if absbeams:
247 beams_number = len(beams)
251 beams_number = len(beams)
248 absbeams_number = len(absbeams)
252 absbeams_number = len(absbeams)
249 if beams_number==absbeams_number:
253 if beams_number==absbeams_number:
250 i = 1
254 i = 1
251 for absbeam in absbeams:
255 for absbeam in absbeams:
252 absbeam.dict_to_parms(beams['beam'+str(i)])
256 absbeam.dict_to_parms(beams['beam'+str(i)])
253 i = i+1
257 i = i+1
254 elif beams_number > absbeams_number:
258 elif beams_number > absbeams_number:
255 i = 1
259 i = 1
256 for absbeam in absbeams:
260 for absbeam in absbeams:
257 absbeam.dict_to_parms(beams['beam'+str(i)])
261 absbeam.dict_to_parms(beams['beam'+str(i)])
258 i=i+1
262 i=i+1
259 for x in range(i,beams_number+1):
263 for x in range(i,beams_number+1):
260 new_beam = ABSBeam(
264 new_beam = ABSBeam(
261 name =beams['beam'+str(i)]['name'],
265 name =beams['beam'+str(i)]['name'],
262 antenna =json.dumps(beams['beam'+str(i)]['antenna']),
266 antenna =json.dumps(beams['beam'+str(i)]['antenna']),
263 abs_conf = self,
267 abs_conf = self,
264 tx =json.dumps(beams['beam'+str(i)]['tx']),
268 tx =json.dumps(beams['beam'+str(i)]['tx']),
265 rx =json.dumps(beams['beam'+str(i)]['rx']),
269 rx =json.dumps(beams['beam'+str(i)]['rx']),
266 ues =json.dumps(beams['beam'+str(i)]['ues']),
270 ues =json.dumps(beams['beam'+str(i)]['ues']),
267 only_rx =json.dumps(beams['beam'+str(i)]['only_rx'])
271 only_rx =json.dumps(beams['beam'+str(i)]['only_rx'])
268 )
272 )
269 new_beam.save()
273 new_beam.save()
270 i=i+1
274 i=i+1
271 else: #beams_number < absbeams_number:
275 else: #beams_number < absbeams_number:
272 i = 1
276 i = 1
273 for absbeam in absbeams:
277 for absbeam in absbeams:
274 if i <= beams_number:
278 if i <= beams_number:
275 absbeam.dict_to_parms(beams['beam'+str(i)])
279 absbeam.dict_to_parms(beams['beam'+str(i)])
276 i=i+1
280 i=i+1
277 else:
281 else:
278 absbeam.delete()
282 absbeam.delete()
279 else:
283 else:
280 for beam in beams:
284 for beam in beams:
281 new_beam = ABSBeam(
285 new_beam = ABSBeam(
282 name =beams[beam]['name'],
286 name =beams[beam]['name'],
283 antenna =json.dumps(beams[beam]['antenna']),
287 antenna =json.dumps(beams[beam]['antenna']),
284 abs_conf = self,
288 abs_conf = self,
285 tx =json.dumps(beams[beam]['tx']),
289 tx =json.dumps(beams[beam]['tx']),
286 rx =json.dumps(beams[beam]['rx']),
290 rx =json.dumps(beams[beam]['rx']),
287 ues =json.dumps(beams[beam]['ues']),
291 ues =json.dumps(beams[beam]['ues']),
288 only_rx =json.dumps(beams[beam]['only_rx'])
292 only_rx =json.dumps(beams[beam]['only_rx'])
289 )
293 )
290 new_beam.save()
294 new_beam.save()
291
295
292
296
293
297
294 def update_from_file(self, parameters):
298 def update_from_file(self, parameters):
295
299
296 self.dict_to_parms(parameters)
300 self.dict_to_parms(parameters)
297 self.save()
301 self.save()
298
302
299
303
300 def get_beams(self, **kwargs):
304 def get_beams(self, **kwargs):
301 '''
305 '''
302 This function returns ABS Configuration beams
306 This function returns ABS Configuration beams
303 '''
307 '''
304 return ABSBeam.objects.filter(abs_conf=self.pk, **kwargs)
308 return ABSBeam.objects.filter(abs_conf=self.pk, **kwargs)
305
309
306 def clone(self, **kwargs):
310 def clone(self, **kwargs):
307
311
308 beams = self.get_beams()
312 beams = self.get_beams()
309 self.pk = None
313 self.pk = None
310 self.id = None
314 self.id = None
311 for attr, value in kwargs.items():
315 for attr, value in kwargs.items():
312 setattr(self, attr, value)
316 setattr(self, attr, value)
313 self.save()
317 self.save()
314
318
315 for beam in beams:
319 for beam in beams:
316 beam.clone(abs_conf=self)
320 beam.clone(abs_conf=self)
317
321
318 #-----For Active Beam-----
322 #-----For Active Beam-----
319 new_beams = ABSBeam.objects.filter(abs_conf=self)
323 new_beams = ABSBeam.objects.filter(abs_conf=self)
320 self.active_beam = new_beams[0].id
324 self.active_beam = new_beams[0].id
321 self.save()
325 self.save()
322 #-----For Active Beam-----
326 #-----For Active Beam-----
323 #-----For Device Status---
327 #-----For Device Status---
324 self.device.status = 3
328 self.device.status = 3
325 self.device.save()
329 self.device.save()
326 #-----For Device Status---
330 #-----For Device Status---
327
331
328 return self
332 return self
329
333
330
334
331 def start_device(self):
335 def start_device(self):
332
336
333 if self.device.status == 3:
337 if self.device.status == 3:
334
338
335 try:
339 try:
336 #self.write_device()
340 #self.write_device()
337 send_task('task_change_beam', [self.id],)
341 send_task('task_change_beam', [self.id],)
338 self.message = 'ABS running'
342 self.message = 'ABS running'
339
343
340 except Exception as e:
344 except Exception as e:
341 self.message = str(e)
345 self.message = str(e)
342 return False
346 return False
343
347
344 return True
348 return True
345
349
346 else:
350 else:
347 self.message = 'Please, select Write ABS Device first.'
351 self.message = 'Please, select Write ABS Device first.'
348 return False
352 return False
349
353
350
354
351 def stop_device(self):
355 def stop_device(self):
352
356
353 self.device.status = 2
357 self.device.status = 2
354 self.device.save()
358 self.device.save()
355 self.message = 'ABS has been stopped.'
359 self.message = 'ABS has been stopped.'
356 self.save()
360 self.save()
357
361
358 return True
362 return True
359
363
360
364
361 def write_device(self):
365 def write_device(self):
362
366
363 """
367 """
364 This function sends the beams list to every abs module.
368 This function sends the beams list to every abs module.
365 It needs 'module_conf' function
369 It needs 'module_conf' function
366 """
370 """
367 print("Write 3")
371 print("Write 3")
368
372
369 beams = ABSBeam.objects.filter(abs_conf=self)
373 beams = ABSBeam.objects.filter(abs_conf=self)
370 nbeams = len(beams)
374 nbeams = len(beams)
371
375
372 # Se manda a cero RC para poder realizar cambio de beam
376 # Se manda a cero RC para poder realizar cambio de beam
373 if self.experiment is None:
377 if self.experiment is None:
374 confs = []
378 confs = []
375 else:
379 else:
376 confs = Configuration.objects.filter(experiment = self.experiment).filter(type=0)
380 confs = Configuration.objects.filter(experiment = self.experiment).filter(type=0)
377 confdds = ''
381 confdds = ''
378 confjars = ''
382 confjars = ''
379 confrc = ''
383 confrc = ''
380 #TO STOP DEVICES: DDS-JARS-RC
384 #TO STOP DEVICES: DDS-JARS-RC
381 for i in range(0,len(confs)):
385 for i in range(0,len(confs)):
382 if i==0:
386 if i==0:
383 for conf in confs:
387 for conf in confs:
384 if conf.device.device_type.name == 'dds':
388 if conf.device.device_type.name == 'dds':
385 confdds = conf
389 confdds = conf
386 confdds.stop_device()
390 confdds.stop_device()
387 break
391 break
388 if i==1:
392 if i==1:
389 for conf in confs:
393 for conf in confs:
390 if conf.device.device_type.name == 'jars':
394 if conf.device.device_type.name == 'jars':
391 confjars = conf
395 confjars = conf
392 confjars.stop_device()
396 confjars.stop_device()
393 break
397 break
394 if i==2:
398 if i==2:
395 for conf in confs:
399 for conf in confs:
396 if conf.device.device_type.name == 'rc':
400 if conf.device.device_type.name == 'rc':
397 confrc = conf
401 confrc = conf
398 confrc.stop_device()
402 confrc.stop_device()
399 break
403 break
400
404
401 '''
405 '''
402 if self.connected_modules() == 0 :
406 if self.connected_modules() == 0 :
403 print("No encuentra modulos")
407 print("No encuentra modulos")
404 self.message = "No ABS Module detected."
408 self.message = "No ABS Module detected."
405 return False
409 return False
406 '''
410 '''
407 #-------------Write each abs module-----------
411 #-------------Write each abs module-----------
408
412
409 if beams:
413 if beams:
410 block_id = 0
414 block_id = 0
411 message = 'SNDF{:03d}{:02d}{:02d}'.format(nbeams, nbeams, block_id)
415 message = 'SNDF{:03d}{:02d}{:02d}'.format(nbeams, nbeams, block_id)
412 for i, status in enumerate(self.module_status):
416 for i, status in enumerate(self.module_status):
413 message += ''.join([fromBinary2Char(beam.module_6bits(i)) for beam in beams])
417 message += ''.join([fromBinary2Char(beam.module_6bits(i)) for beam in beams])
414 status = ['0'] * 64
418 status = ['0'] * 64
415 n = 0
419 n = 0
416
420
417 print("Llega una antes entrar a multicast4")
421 print("Llega una antes entrar a multicast4")
418
422
419 sock = self.send_multicast(message)
423 sock = self.send_multicast(message)
420
424
421 while True:
425 while True:
422 #for i in range(32):
426 #for i in range(32):
423 try:
427 try:
424 data, address = sock.recvfrom(1024)
428 data, address = sock.recvfrom(1024)
425 print (address, data)
429 print (address, data)
426 data = data.decode("utf-8")
430 data = data.decode("utf-8")
427 if data == '1':
431 if data == '1':
428 status[int(address[0][10:])-1] = '3'
432 status[int(address[0][10:])-1] = '3'
429 #print (int(address[0][10:])-1)
433 #print (int(address[0][10:])-1)
430 elif data == '0':
434 elif data == '0':
431 status[int(address[0][10:])-1] = '1'
435 status[int(address[0][10:])-1] = '1'
432 except socket.timeout:
436 except socket.timeout:
433 print('Timeout')
437 print('Timeout')
434 break
438 break
435 except Exception as e:
439 except Exception as e:
436 print ('Error {}'.format(e))
440 print ('Error {}'.format(e))
437 n += 1
441 n += 1
438 sock.close()
442 sock.close()
439 else:
443 else:
440 self.message = "ABS Configuration does not have beams"
444 self.message = "ABS Configuration does not have beams"
441 print('No beams')
445 print('No beams')
442 #Start DDS-RC-JARS
446 #Start DDS-RC-JARS
443 if confdds:
447 if confdds:
444 confdds.start_device()
448 confdds.start_device()
445 if confrc:
449 if confrc:
446 #print confrc
450 #print confrc
447 confrc.start_device()
451 confrc.start_device()
448 if confjars:
452 if confjars:
449 confjars.start_device()
453 confjars.start_device()
450 return False
454 return False
451
455
452 if n == 64:
456 if n == 64:
453 self.message = "Could not write ABS Modules"
457 self.message = "Could not write ABS Modules"
454 self.device.status = 0
458 self.device.status = 0
455 self.module_status = ''.join(status)
459 self.module_status = ''.join(status)
456 self.save()
460 self.save()
457 print('Could not write ABS')
461 print('Could not write ABS')
458 #Start DDS-RC-JARS
462 #Start DDS-RC-JARS
459 if confdds:
463 if confdds:
460 confdds.start_device()
464 confdds.start_device()
461 if confrc:
465 if confrc:
462 #print confrc
466 #print confrc
463 confrc.start_device()
467 confrc.start_device()
464 if confjars:
468 if confjars:
465 confjars.start_device()
469 confjars.start_device()
466 return False
470 return False
467 else:
471 else:
468 self.message = "ABS Beams List have been sent to ABS Modules"
472 self.message = "ABS Beams List have been sent to ABS Modules"
469 print('ABS beams list sent')
473 print('ABS beams list sent')
470 self.active_beam = beams[0].pk
474 self.active_beam = beams[0].pk
471
475
472 #Start DDS-RC-JARS
476 #Start DDS-RC-JARS
473 if confdds:
477 if confdds:
474 confdds.start_device()
478 confdds.start_device()
475 if confrc:
479 if confrc:
476 #print confrc
480 #print confrc
477 confrc.start_device()
481 confrc.start_device()
478 if confjars:
482 if confjars:
479 confjars.start_device()
483 confjars.start_device()
480
484
481 print('Inicia intento de salvar device.status')
485 print('Inicia intento de salvar device.status')
482 self.device.status = 3
486 self.device.status = 3
483 self.module_status = ''.join(status)
487 self.module_status = ''.join(status)
484 #print(status)
488 #print(status)
485 self.save()
489 self.save()
486 print('Estatus salvado')
490 print('Estatus salvado')
487 conf_active, __ = ABSActive.objects.get_or_create(pk=1)
491 conf_active, __ = ABSActive.objects.get_or_create(pk=1)
488 conf_active.conf = self
492 conf_active.conf = self
489 conf_active.save()
493 conf_active.save()
490 return True
494 return True
491
495
496 def write_device_mqtt(self):
497 apuntes_up_down=''
498 beams = ABSBeam.objects.filter(abs_conf=self)
499
500 inicializacion="{\"beams\":["
501 finalizacion="]}"
502
503 for beam in beams:
504 beam.antenna=beam.antenna[1:]
505 info="{\"id\":"+str(beam.id)+","+beam.antenna + ","
506 apuntes_up_down=apuntes_up_down+info
507
508 apuntes_up_down=apuntes_up_down[:len(apuntes_up_down)-1]
509
510 apuntes_up_down=inicializacion+ apuntes_up_down+finalizacion
511
512 #print(apuntes_up_down,flush=True)
513
514 mqtt_client.publish(os.environ.get('TOPIC_ABS', 'abs/beams'),apuntes_up_down)
515
516 return True
492
517
493 def read_module(self, module):
518 def read_module(self, module):
494
519
495 """
520 """
496 Read out-bits (up-down) of 1 abs module NOT for Configuration
521 Read out-bits (up-down) of 1 abs module NOT for Configuration
497 """
522 """
498
523
499 ip_address = self.device.ip_address
524 ip_address = self.device.ip_address
500 ip_address = ip_address.split('.')
525 ip_address = ip_address.split('.')
501 module_seq = (ip_address[0],ip_address[1],ip_address[2])
526 module_seq = (ip_address[0],ip_address[1],ip_address[2])
502 dot = '.'
527 dot = '.'
503 module_ip = dot.join(module_seq)+'.'+str(module)
528 module_ip = dot.join(module_seq)+'.'+str(module)
504 module_port = self.device.port_address
529 module_port = self.device.port_address
505 read_route = 'http://'+module_ip+':'+str(module_port)+'/read'
530 read_route = 'http://'+module_ip+':'+str(module_port)+'/read'
506
531
507 module_status = json.loads(self.module_status)
532 module_status = json.loads(self.module_status)
508 print(read_route)
533 print(read_route)
509
534
510 module_bits = ''
535 module_bits = ''
511
536
512 try:
537 try:
513 r_read = requests.get(read_route, timeout=0.5)
538 r_read = requests.get(read_route, timeout=0.5)
514 answer = r_read.json()
539 answer = r_read.json()
515 module_bits = answer['allbits']
540 module_bits = answer['allbits']
516 except:
541 except:
517 return {}
542 return {}
518
543
519 return module_bits
544 return module_bits
520
545
521 def read_device(self):
546 def read_device(self):
522
547
523 parms = {}
548 parms = {}
524 # Reads active modules.
549 # Reads active modules.
525 module_status = json.loads(self.module_status)
550 module_status = json.loads(self.module_status)
526 total = 0
551 total = 0
527 for status in module_status:
552 for status in module_status:
528 if module_status[status] != 0:
553 if module_status[status] != 0:
529 module_bits = self.read_module(int(status))
554 module_bits = self.read_module(int(status))
530 bits={}
555 bits={}
531 if module_bits:
556 if module_bits:
532 bits = (str(module_bits['um2']) + str(module_bits['um1']) + str(module_bits['um0']) +
557 bits = (str(module_bits['um2']) + str(module_bits['um1']) + str(module_bits['um0']) +
533 str(module_bits['dm2']) + str(module_bits['dm1']) + str(module_bits['dm0']) )
558 str(module_bits['dm2']) + str(module_bits['dm1']) + str(module_bits['dm0']) )
534 parms[str(status)] = bits
559 parms[str(status)] = bits
535
560
536 total +=1
561 total +=1
537
562
538 if total==0:
563 if total==0:
539 self.message = "No ABS Module detected. Please select 'Status'."
564 self.message = "No ABS Module detected. Please select 'Status'."
540 return False
565 return False
541
566
542
567
543
568
544 self.message = "ABS Modules have been read"
569 self.message = "ABS Modules have been read"
545 #monitoreo_tx = JROABSClnt_01CeCnMod000000MNTR10
570 #monitoreo_tx = JROABSClnt_01CeCnMod000000MNTR10
546 return parms
571 return parms
547
572
548
573
549 def connected_modules(self):
574 def connected_modules(self):
550 """
575 """
551 This function returns the number of connected abs-modules without updating.
576 This function returns the number of connected abs-modules without updating.
552 """
577 """
553 num = 0
578 num = 0
554 print(self.module_status)
579 print(self.module_status)
555 for i, status in enumerate(self.module_status):
580 for i, status in enumerate(self.module_status):
556 if status != '0':
581 if status != '0':
557 num += 1
582 num += 1
558 #print('status {}:{}'.format(i+1, status))
583 #print('status {}:{}'.format(i+1, status))
559 return num
584 return num
560
585
561 def send_multicast(self, message):
586 def send_multicast(self, message):
562 #print("Send multicast")
587 #print("Send multicast")
563 multicast_group = ('224.3.29.71', 10000)
588 multicast_group = ('224.3.29.71', 10000)
564 # Create the datagram socket
589 # Create the datagram socket
565 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
590 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
566 sock.settimeout(1)
591 sock.settimeout(1)
567 local_ip = os.environ.get('LOCAL_IP', '0.0.0.0')
592 local_ip = os.environ.get('LOCAL_IP', '0.0.0.0')
568 local_ip = '0.0.0.0'
593 local_ip = '0.0.0.0'
569 print("He llegado a IP local")
594 print("He llegado a IP local")
570
595
571 sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_IF, socket.inet_aton(local_ip))
596 sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_IF, socket.inet_aton(local_ip))
572 sock.sendto(message.encode(), multicast_group)
597 sock.sendto(message.encode(), multicast_group)
573 print('Sending ' + message)
598 print('Sending ' + message)
574 return sock
599 return sock
575
600
576 def status_device(self):
601 def status_device(self):
577 """
602 """
578 This function returns the status of all abs-modules as one.
603 This function returns the status of all abs-modules as one.
579 If at least one module is connected, its answer is "1"
604 If at least one module is connected, its answer is "1"
580 """
605 """
581 print ('Status device')
606 print ('Status device')
582 print (self.active_beam)
607 print (self.active_beam)
583 beams = ABSBeam.objects.filter(abs_conf=self)
608 beams = ABSBeam.objects.filter(abs_conf=self)
584 #print beams[self.active_beam-1].module_6bits(0)
609 #print beams[self.active_beam-1].module_6bits(0)
585 active = ABSActive.objects.get(pk=1)
610 active = ABSActive.objects.get(pk=1)
586 if active.conf != self:
611 if active.conf != self:
587 self.message = 'La configuracion actual es la del siguiente enlace %s.' % active.conf.get_absolute_url()
612 self.message = 'La configuracion actual es la del siguiente enlace %s.' % active.conf.get_absolute_url()
588 self.message += "\n"
613 self.message += "\n"
589 self.message += 'Se debe realizar un write en esta configuracion para luego obtener un status valido.'
614 self.message += 'Se debe realizar un write en esta configuracion para luego obtener un status valido.'
590
615
591 return False
616 return False
592
617
593 sock = self.send_multicast('MNTR')
618 sock = self.send_multicast('MNTR')
594
619
595 n = 0
620 n = 0
596 status = ['0'] * 64
621 status = ['0'] * 64
597
622
598 while True:
623 while True:
599 #for i in range(32):
624 #for i in range(32):
600 #if True:
625 #if True:
601 try:
626 try:
602 print("Recibiendo")
627 print("Recibiendo")
603 address = None
628 address = None
604 data, address = sock.recvfrom(2)
629 data, address = sock.recvfrom(2)
605 print (address, data)
630 print (address, data)
606 print("!!!!")
631 print("!!!!")
607 data = data.decode()
632 data = data.decode()
608 aux_mon = "1"
633 aux_mon = "1"
609 aux_expected = aux_mon
634 aux_expected = aux_mon
610 if(len(data)==2):
635 if(len(data)==2):
611 print ("data[1]: ")
636 print ("data[1]: ")
612 print (data[1])
637 print (data[1])
613 aux_mon = fromChar2Binary(data[1])
638 aux_mon = fromChar2Binary(data[1])
614 print (aux_mon)
639 print (aux_mon)
615 aux_i = (str(address[0]).split('.'))[3]
640 aux_i = (str(address[0]).split('.'))[3]
616 print (aux_i)
641 print (aux_i)
617 print ('Active beam')
642 print ('Active beam')
618 beam_active = ABSBeam.objects.get(pk=self.active_beam)
643 beam_active = ABSBeam.objects.get(pk=self.active_beam)
619 print (beam_active)
644 print (beam_active)
620 aux_expected = beam_active.module_6bits(int(aux_i)-1)
645 aux_expected = beam_active.module_6bits(int(aux_i)-1)
621 print (aux_expected)
646 print (aux_expected)
622
647
623 print ("data[0]: ")
648 print ("data[0]: ")
624 print (data[0])
649 print (data[0])
625
650
626 if data[0] == '1':
651 if data[0] == '1':
627 status[int(address[0][10:])-1] = '3'
652 status[int(address[0][10:])-1] = '3'
628 if aux_mon == aux_expected:
653 if aux_mon == aux_expected:
629 print ('Es igual')
654 print ('Es igual')
630 else:
655 else:
631 print ('Es diferente')
656 print ('Es diferente')
632 status[int(address[0][10:])-1] = '2'
657 status[int(address[0][10:])-1] = '2'
633
658
634 elif data[0] == '0':
659 elif data[0] == '0':
635 status[int(address[0][10:])-1] = '1'
660 status[int(address[0][10:])-1] = '1'
636 n += 1
661 n += 1
637 print('Module: {} connected'.format(address))
662 print('Module: {} connected'.format(address))
638 except socket.timeout:
663 except socket.timeout:
639 print('Timeout')
664 print('Timeout')
640 break
665 break
641 except:
666 except:
642 print('Module: {} error'.format(address))
667 print('Module: {} error'.format(address))
643 pass
668 pass
644
669
645 sock.close()
670 sock.close()
646
671
647 if n > 0:
672 if n > 0:
648 self.message = 'ABS modules Status have been updated.'
673 self.message = 'ABS modules Status have been updated.'
649 self.device.status = 1
674 self.device.status = 1
650 else:
675 else:
651 self.device.status = 0
676 self.device.status = 0
652 self.message = 'No ABS module is connected.'
677 self.message = 'No ABS module is connected.'
653 self.module_status = ''.join(status)
678 self.module_status = ''.join(status)
654 self.save()
679 self.save()
655
680
656 return self.device.status
681 return self.device.status
657
682
658
683
659 def send_beam(self, beam_pos):
684 def send_beam(self, beam_pos):
660 """
685 """
661 This function connects to a multicast group and sends the beam number
686 This function connects to a multicast group and sends the beam number
662 to all abs modules.
687 to all abs modules.
663 """
688 """
664 print ('Send beam')
689 print ('Send beam')
665 print (self.active_beam)
690 print (self.active_beam)
666 beams = ABSBeam.objects.filter(abs_conf=self)
691 beams = ABSBeam.objects.filter(abs_conf=self)
667 #print beams[self.active_beam-1].module_6bits(0)
692 #print beams[self.active_beam-1].module_6bits(0)
668 active = ABSActive.objects.get(pk=1)
693 active = ABSActive.objects.get(pk=1)
669 if active.conf != self:
694 if active.conf != self:
670 self.message = 'La configuracion actual es la del siguiente enlace %s.' % active.conf.get_absolute_url()
695 self.message = 'La configuracion actual es la del siguiente enlace %s.' % active.conf.get_absolute_url()
671 self.message += "\n"
696 self.message += "\n"
672 self.message += 'Se debe realizar un write en esta configuracion para luego obtener un status valido.'
697 self.message += 'Se debe realizar un write en esta configuracion para luego obtener un status valido.'
673
698
674 return False
699 return False
675
700
676 # Se manda a cero RC para poder realizar cambio de beam
701 # Se manda a cero RC para poder realizar cambio de beam
677 if self.experiment is None:
702 if self.experiment is None:
678 confs = []
703 confs = []
679 else:
704 else:
680 confs = Configuration.objects.filter(experiment = self.experiment).filter(type=0)
705 confs = Configuration.objects.filter(experiment = self.experiment).filter(type=0)
681 confdds = ''
706 confdds = ''
682 confjars = ''
707 confjars = ''
683 confrc = ''
708 confrc = ''
684 #TO STOP DEVICES: DDS-JARS-RC
709 #TO STOP DEVICES: DDS-JARS-RC
685 for i in range(0,len(confs)):
710 for i in range(0,len(confs)):
686 if i==0:
711 if i==0:
687 for conf in confs:
712 for conf in confs:
688 if conf.device.device_type.name == 'dds':
713 if conf.device.device_type.name == 'dds':
689 confdds = conf
714 confdds = conf
690 confdds.stop_device()
715 confdds.stop_device()
691 break
716 break
692 if i==1:
717 if i==1:
693 for conf in confs:
718 for conf in confs:
694 if conf.device.device_type.name == 'jars':
719 if conf.device.device_type.name == 'jars':
695 confjars = conf
720 confjars = conf
696 confjars.stop_device()
721 confjars.stop_device()
697 break
722 break
698 if i==2:
723 if i==2:
699 for conf in confs:
724 for conf in confs:
700 if conf.device.device_type.name == 'rc':
725 if conf.device.device_type.name == 'rc':
701 confrc = conf
726 confrc = conf
702 confrc.stop_device()
727 confrc.stop_device()
703 break
728 break
704 if beam_pos > 0:
729 if beam_pos > 0:
705 beam_pos = beam_pos - 1
730 beam_pos = beam_pos - 1
706 else:
731 else:
707 beam_pos = 0
732 beam_pos = 0
708
733
709 #El indice del apunte debe ser menor que el numero total de apuntes
734 #El indice del apunte debe ser menor que el numero total de apuntes
710 #El servidor tcp en el embebido comienza a contar desde 0
735 #El servidor tcp en el embebido comienza a contar desde 0
711 status = ['0'] * 64
736 status = ['0'] * 64
712 message = 'CHGB{}'.format(beam_pos)
737 message = 'CHGB{}'.format(beam_pos)
713 sock = self.send_multicast(message)
738 sock = self.send_multicast(message)
714 while True:
739 while True:
715 #for i in range(32):
740 #for i in range(32):
716 try:
741 try:
717 data, address = sock.recvfrom(1024)
742 data, address = sock.recvfrom(1024)
718 print (address, data)
743 print (address, data)
719 data = data.decode()
744 data = data.decode()
720 if data == '1':
745 if data == '1':
721 status[int(address[0][10:])-1] = '3'
746 status[int(address[0][10:])-1] = '3'
722 elif data == '0':
747 elif data == '0':
723 status[int(address[0][10:])-1] = '1'
748 status[int(address[0][10:])-1] = '1'
724 except socket.timeout:
749 except socket.timeout:
725 print('Timeout')
750 print('Timeout')
726 break
751 break
727 except Exception as e:
752 except Exception as e:
728 print ('Error {}'.format(e))
753 print ('Error {}'.format(e))
729 pass
754 pass
730
755
731 sock.close()
756 sock.close()
732
757
733 #Start DDS-RC-JARS
758 #Start DDS-RC-JARS
734 if confdds:
759 if confdds:
735 confdds.start_device()
760 confdds.start_device()
736 if confrc:
761 if confrc:
737 #print confrc
762 #print confrc
738 confrc.start_device()
763 confrc.start_device()
739 if confjars:
764 if confjars:
740 confjars.start_device()
765 confjars.start_device()
741
766
742 self.message = "ABS Beam has been changed"
767 self.message = "ABS Beam has been changed"
743 self.module_status = ''.join(status)
768 self.module_status = ''.join(status)
744 self.save()
769 self.save()
745 return True
770 return True
746
771
747
772
748 def get_absolute_url_import(self):
773 def get_absolute_url_import(self):
749 return reverse('url_import_abs_conf', args=[str(self.id)])
774 return reverse('url_import_abs_conf', args=[str(self.id)])
750
775
751 class ABSActive(models.Model):
776 class ABSActive(models.Model):
752 conf = models.ForeignKey(ABSConfiguration, null=True, verbose_name='ABS Configuration', on_delete=models.CASCADE)
777 conf = models.ForeignKey(ABSConfiguration, null=True, verbose_name='ABS Configuration', on_delete=models.CASCADE)
753
778
754 class Meta:
779 class Meta:
755 db_table = 'abs_absactive'
780 db_table = 'abs_absactive'
756
781
757 class ABSBeam(models.Model):
782 class ABSBeam(models.Model):
758
783
759 name = models.CharField(max_length=60, default='Beam')
784 name = models.CharField(max_length=60, default='Beam')
760 antenna = models.CharField(verbose_name='Antenna', max_length=1000, default=antenna_default)
785 antenna = models.CharField(verbose_name='Antenna', max_length=1000, default=antenna_default)
761 abs_conf = models.ForeignKey('ABSConfiguration', null=True,
786 abs_conf = models.ForeignKey('ABSConfiguration', null=True,
762 verbose_name='ABS Configuration', on_delete=models.CASCADE)
787 verbose_name='ABS Configuration', on_delete=models.CASCADE)
763 tx = models.CharField(verbose_name='Tx', max_length=1000, default=tx_default)
788 tx = models.CharField(verbose_name='Tx', max_length=1000, default=tx_default)
764 rx = models.CharField(verbose_name='Rx', max_length=1000, default=rx_default)
789 rx = models.CharField(verbose_name='Rx', max_length=1000, default=rx_default)
765 s_time = models.TimeField(verbose_name='Star Time', default='00:00:00')
790 s_time = models.TimeField(verbose_name='Star Time', default='00:00:00')
766 e_time = models.TimeField(verbose_name='End Time', default='23:59:59')
791 e_time = models.TimeField(verbose_name='End Time', default='23:59:59')
767 ues = models.CharField(verbose_name='Ues', max_length=100, default=ues_default)
792 ues = models.CharField(verbose_name='Ues', max_length=100, default=ues_default)
768 only_rx = models.CharField(verbose_name='Only RX', max_length=40, default=onlyrx_default)
793 only_rx = models.CharField(verbose_name='Only RX', max_length=40, default=onlyrx_default)
769
794
770 class Meta:
795 class Meta:
771 db_table = 'abs_beams'
796 db_table = 'abs_beams'
772
797
773 def __unicode__(self):
798 def __unicode__(self):
774 return u'%s' % (self.name)
799 return u'%s' % (self.name)
775
800
776 def parms_to_dict(self):
801 def parms_to_dict(self):
777
802
778 parameters = {}
803 parameters = {}
779 parameters['name'] = self.name
804 parameters['name'] = self.name
780 parameters['antenna'] = ast.literal_eval(self.antenna)
805 parameters['antenna'] = ast.literal_eval(self.antenna)
781 parameters['abs_conf'] = self.abs_conf.name
806 parameters['abs_conf'] = self.abs_conf.name
782 parameters['tx'] = ast.literal_eval(self.tx)
807 parameters['tx'] = ast.literal_eval(self.tx)
783 parameters['rx'] = ast.literal_eval(self.rx)
808 parameters['rx'] = ast.literal_eval(self.rx)
784 parameters['s_time'] = self.s_time.strftime("%H:%M:%S")
809 parameters['s_time'] = self.s_time.strftime("%H:%M:%S")
785 parameters['e_time'] = self.e_time.strftime("%H:%M:%S")
810 parameters['e_time'] = self.e_time.strftime("%H:%M:%S")
786 parameters['ues'] = ast.literal_eval(self.ues)
811 parameters['ues'] = ast.literal_eval(self.ues)
787 parameters['only_rx'] = json.loads(self.only_rx)
812 parameters['only_rx'] = json.loads(self.only_rx)
788
813
789 return parameters
814 return parameters
790
815
791 def dict_to_parms(self, parameters):
816 def dict_to_parms(self, parameters):
792
817
793 self.name = parameters['name']
818 self.name = parameters['name']
794 self.antenna = json.dumps(parameters['antenna'])
819 self.antenna = json.dumps(parameters['antenna'])
795 #self.abs_conf = parameters['abs_conf']
820 #self.abs_conf = parameters['abs_conf']
796 self.tx = json.dumps(parameters['tx'])
821 self.tx = json.dumps(parameters['tx'])
797 self.rx = json.dumps(parameters['rx'])
822 self.rx = json.dumps(parameters['rx'])
798 #self.s_time = parameters['s_time']
823 #self.s_time = parameters['s_time']
799 #self.e_time = parameters['e_time']
824 #self.e_time = parameters['e_time']
800 self.ues = json.dumps(parameters['ues'])
825 self.ues = json.dumps(parameters['ues'])
801 self.only_rx = json.dumps(parameters['only_rx'])
826 self.only_rx = json.dumps(parameters['only_rx'])
802 self.save()
827 self.save()
803
828
804
829
805 def clone(self, **kwargs):
830 def clone(self, **kwargs):
806
831
807 self.pk = None
832 self.pk = None
808 self.id = None
833 self.id = None
809 for attr, value in kwargs.items():
834 for attr, value in kwargs.items():
810 setattr(self, attr, value)
835 setattr(self, attr, value)
811
836
812 self.save()
837 self.save()
813
838
814 return self
839 return self
815
840
816
841
817 def module_6bits(self, module):
842 def module_6bits(self, module):
818 """
843 """
819 This function reads antenna pattern and choose 6bits (upbits-downbits) for one abs module
844 This function reads antenna pattern and choose 6bits (upbits-downbits) for one abs module
820 """
845 """
821 module += 1
846 module += 1
822 if module > 64:
847 if module > 64:
823 beam_bits = ""
848 beam_bits = ""
824 return beam_bits
849 return beam_bits
825
850
826 data = ast.literal_eval(self.antenna)
851 data = ast.literal_eval(self.antenna)
827 up_data = data['antenna_up']
852 up_data = data['antenna_up']
828 down_data = data['antenna_down']
853 down_data = data['antenna_down']
829
854
830 pos = ip2position(module)
855 pos = ip2position(module)
831 up_value = up_data[pos[0]][pos[1]]
856 up_value = up_data[pos[0]][pos[1]]
832 down_value = down_data[pos[0]][pos[1]]
857 down_value = down_data[pos[0]][pos[1]]
833
858
834 up_bits = up_conv_bits(up_value)
859 up_bits = up_conv_bits(up_value)
835 down_bits = down_conv_bits(down_value)
860 down_bits = down_conv_bits(down_value)
836 beam_bits = up_bits+down_bits
861 beam_bits = up_bits+down_bits
837
862
838 return beam_bits
863 return beam_bits
839
864
840
865
841 @property
866 @property
842 def get_upvalues(self):
867 def get_upvalues(self):
843 """
868 """
844 This function reads antenna pattern and show the up-value of one abs module
869 This function reads antenna pattern and show the up-value of one abs module
845 """
870 """
846
871
847 data = ast.literal_eval(self.antenna)
872 data = ast.literal_eval(self.antenna)
848 up_data = data['antenna_up']
873 up_data = data['antenna_up']
849
874
850 up_values = []
875 up_values = []
851 for data in up_data:
876 for data in up_data:
852 for i in range(0,8):
877 for i in range(0,8):
853 up_values.append(data[i])
878 up_values.append(data[i])
854
879
855 return up_values
880 return up_values
856
881
857 @property
882 @property
858 def antenna_upvalues(self):
883 def antenna_upvalues(self):
859 """
884 """
860 This function reads antenna pattern and show the up - values of one abs beam
885 This function reads antenna pattern and show the up - values of one abs beam
861 in a particular order
886 in a particular order
862 """
887 """
863 data = ast.literal_eval(self.antenna)
888 data = ast.literal_eval(self.antenna)
864 up_data = data['antenna_up']
889 up_data = data['antenna_up']
865
890
866 return up_data
891 return up_data
867
892
868 @property
893 @property
869 def antenna_downvalues(self):
894 def antenna_downvalues(self):
870 """
895 """
871 This function reads antenna pattern and show the down - values of one abs beam
896 This function reads antenna pattern and show the down - values of one abs beam
872 in a particular order
897 in a particular order
873 """
898 """
874 data = ast.literal_eval(self.antenna)
899 data = ast.literal_eval(self.antenna)
875 down_data = data['antenna_down']
900 down_data = data['antenna_down']
876
901
877 return down_data
902 return down_data
878
903
879 @property
904 @property
880 def get_downvalues(self):
905 def get_downvalues(self):
881 """
906 """
882 This function reads antenna pattern and show the down-value of one abs module
907 This function reads antenna pattern and show the down-value of one abs module
883 """
908 """
884
909
885 data = ast.literal_eval(self.antenna)
910 data = ast.literal_eval(self.antenna)
886 down_data = data['antenna_down']
911 down_data = data['antenna_down']
887
912
888 down_values = []
913 down_values = []
889 for data in down_data:
914 for data in down_data:
890 for i in range(0,8):
915 for i in range(0,8):
891 down_values.append(data[i])
916 down_values.append(data[i])
892
917
893 return down_values
918 return down_values
894
919
895 @property
920 @property
896 def get_up_ues(self):
921 def get_up_ues(self):
897 """
922 """
898 This function shows the up-ues-value of one beam
923 This function shows the up-ues-value of one beam
899 """
924 """
900 data = ast.literal_eval(self.ues)
925 data = ast.literal_eval(self.ues)
901 up_ues = data['up']
926 up_ues = data['up']
902
927
903 return up_ues
928 return up_ues
904
929
905 @property
930 @property
906 def get_down_ues(self):
931 def get_down_ues(self):
907 """
932 """
908 This function shows the down-ues-value of one beam
933 This function shows the down-ues-value of one beam
909 """
934 """
910 data = ast.literal_eval(self.ues)
935 data = ast.literal_eval(self.ues)
911 down_ues = data['down']
936 down_ues = data['down']
912
937
913 return down_ues
938 return down_ues
914
939
915 @property
940 @property
916 def get_up_onlyrx(self):
941 def get_up_onlyrx(self):
917 """
942 """
918 This function shows the up-onlyrx-value of one beam
943 This function shows the up-onlyrx-value of one beam
919 """
944 """
920 data = json.loads(self.only_rx)
945 data = json.loads(self.only_rx)
921 up_onlyrx = data['up']
946 up_onlyrx = data['up']
922
947
923 return up_onlyrx
948 return up_onlyrx
924
949
925 @property
950 @property
926 def get_down_onlyrx(self):
951 def get_down_onlyrx(self):
927 """
952 """
928 This function shows the down-onlyrx-value of one beam
953 This function shows the down-onlyrx-value of one beam
929 """
954 """
930 data = json.loads(self.only_rx)
955 data = json.loads(self.only_rx)
931 down_onlyrx = data['down']
956 down_onlyrx = data['down']
932
957
933 return down_onlyrx
958 return down_onlyrx
934
959
935 @property
960 @property
936 def get_tx(self):
961 def get_tx(self):
937 """
962 """
938 This function shows the tx-values of one beam
963 This function shows the tx-values of one beam
939 """
964 """
940 data = json.loads(self.tx)
965 data = json.loads(self.tx)
941
966
942 return data
967 return data
943
968
944 @property
969 @property
945 def get_uptx(self):
970 def get_uptx(self):
946 """
971 """
947 This function shows the up-tx-values of one beam
972 This function shows the up-tx-values of one beam
948 """
973 """
949 data = json.loads(self.tx)
974 data = json.loads(self.tx)
950 up_data = data['up']
975 up_data = data['up']
951
976
952 up_values = []
977 up_values = []
953 for data in up_data:
978 for data in up_data:
954 for i in range(0,8):
979 for i in range(0,8):
955 up_values.append(data[i])
980 up_values.append(data[i])
956
981
957 return up_values
982 return up_values
958
983
959 @property
984 @property
960 def get_downtx(self):
985 def get_downtx(self):
961 """
986 """
962 This function shows the down-tx-values of one beam
987 This function shows the down-tx-values of one beam
963 """
988 """
964 data = json.loads(self.tx)
989 data = json.loads(self.tx)
965 down_data = data['down']
990 down_data = data['down']
966
991
967 down_values = []
992 down_values = []
968 for data in down_data:
993 for data in down_data:
969 for i in range(0,8):
994 for i in range(0,8):
970 down_values.append(data[i])
995 down_values.append(data[i])
971
996
972 return down_values
997 return down_values
973
998
974
999
975
1000
976 @property
1001 @property
977 def get_rx(self):
1002 def get_rx(self):
978 """
1003 """
979 This function shows the rx-values of one beam
1004 This function shows the rx-values of one beam
980 """
1005 """
981 data = json.loads(self.rx)
1006 data = json.loads(self.rx)
982
1007
983 return data
1008 return data
984
1009
985 @property
1010 @property
986 def get_uprx(self):
1011 def get_uprx(self):
987 """
1012 """
988 This function shows the up-rx-values of one beam
1013 This function shows the up-rx-values of one beam
989 """
1014 """
990 data = json.loads(self.rx)
1015 data = json.loads(self.rx)
991 up_data = data['up']
1016 up_data = data['up']
992
1017
993 up_values = []
1018 up_values = []
994 for data in up_data:
1019 for data in up_data:
995 for i in range(0,8):
1020 for i in range(0,8):
996 up_values.append(data[i])
1021 up_values.append(data[i])
997
1022
998 return up_values
1023 return up_values
999
1024
1000 @property
1025 @property
1001 def get_downrx(self):
1026 def get_downrx(self):
1002 """
1027 """
1003 This function shows the down-rx-values of one beam
1028 This function shows the down-rx-values of one beam
1004 """
1029 """
1005 data = json.loads(self.rx)
1030 data = json.loads(self.rx)
1006 down_data = data['down']
1031 down_data = data['down']
1007
1032
1008 down_values = []
1033 down_values = []
1009 for data in down_data:
1034 for data in down_data:
1010 for i in range(0,8):
1035 for i in range(0,8):
1011 down_values.append(data[i])
1036 down_values.append(data[i])
1012
1037
1013 return down_values
1038 return down_values
@@ -1,339 +1,384
1 {% extends "dev_conf.html" %} {% load static %} {% load django_bootstrap5 %} {% load main_tags %}
1 {% extends "dev_conf.html" %} {% load static %} {% load django_bootstrap5 %} {% load main_tags %}
2 {% block extra-head %}
2 {% block extra-head %}
3 <style>
3 <style>
4 .abs {
4 .abs {
5 width: auto;
5 width: auto;
6 display: inline-block;
6 display: inline-block;
7 text-align: center;
7 text-align: center;
8 }
8 }
9
9
10 .abs td {
10 .abs td {
11 padding: 4px;
11 padding: 4px;
12 }
12 }
13
13
14 .module td {
14 .module td {
15 padding: 4px 15px 4px 15px;
15 padding: 4px 15px 4px 15px;
16 font-weight: bold;
16 font-weight: bold;
17 border: 1px solid
17 border: 1px solid
18 }
18 }
19
19
20 .legend {
20 .legend {
21 margin-left: 15px;
21 margin-left: 15px;
22 display: inline-block;
22 display: inline-block;
23 border: 2px solid;
23 border: 2px solid;
24 vertical-align: top;
24 vertical-align: top;
25 }
25 }
26
26
27 .legend th {
27 .legend th {
28 border-bottom: 1px dashed;
28 border-bottom: 1px dashed;
29 font-weight: bold;
29 font-weight: bold;
30 vertical-align: center;
30 vertical-align: center;
31 text-align: center;
31 text-align: center;
32 }
32 }
33
33
34 .legend td {
34 .legend td {
35 padding: 2px;
35 padding: 2px;
36 text-align: center;
36 text-align: center;
37 font-weight: bold;
37 font-weight: bold;
38 }
38 }
39
39
40 </style>
40 </style>
41 {% endblock %}
41 {% endblock %}
42
43
42 {% block extra-menu-actions %}
44 {% block extra-menu-actions %}
43 <li>
45 <li>
44 <a href="{{ dev_conf.get_absolute_url_plot }}" target="_blank">
46 <a href="{{ dev_conf.get_absolute_url_plot }}" target="_blank">
45 <span class="far fa-image" aria-hidden="true"></span> View Patterns </a>
47 <span class="far fa-image" aria-hidden="true"></span> View Patterns </a>
46 </li>
48 </li>
47 {% endblock %}
49 {% endblock %}
50
51
48 {% block extra-content %}
52 {% block extra-content %}
53 <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script>
54 <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/socket.io/4.4.1/socket.io.min.js">
55 </script>
56
57
49 {% if beams %}
58 {% if beams %}
50 <h4>Beams:</h4>
59 <h4>Beams:</h4>
51 <div class="container">
60 <div class="container">
52 <ul class="nav nav-pills">
61 <ul class="nav nav-pills">
53 {% for beam in beams %}
62 {% for beam in beams %}
54 <li class="nav-item">
63 <li class="nav-item">
55 <a {%if beam.pk == active_beam %} class="nav-link active" {% else %} class="nav-link" {% endif %} data-toggle="pill" href="#menu{{forloop.counter}}">{{forloop.counter}}</a>
64 <a {%if beam.pk == active_beam %} class="nav-link active" {% else %} class="nav-link" {% endif %} data-toggle="pill" href="#menu{{forloop.counter}}">{{forloop.counter}}</a>
56 </li>
65 </li>
57 {% endfor %}
66 {% endfor %}
58 </ul>
67 </ul>
59
68
60 <div class="tab-content">
69 <div class="tab-content">
61 {% for beam in beams %}
70 {% for beam in beams %}
62 <div id="menu{{forloop.counter}}" class="tab-pane fade {%if beam.pk == active_beam %}in active show{% endif %}">
71 <div id="menu{{forloop.counter}}" class="tab-pane fade {%if beam.pk == active_beam %}in active show{% endif %}">
63 <h3>{%if beam.pk == active_beam %}Active Beam: {%endif%}{{beam.name}}</h3>
72 <h3>{%if beam.pk == active_beam %}Active Beam: {%endif%}{{beam.name}}</h3>
64 <table id="abs_pattern{{forloop.counter}}" class="abs">
73 <table id="abs_pattern{{forloop.counter}}" class="abs">
65 <tr>
74 <tr>
66 <td>
75 <td>
67 <b>North Quarter</b>
76 <b>North Quarter</b>
68 <table class="module">
77 <table class="module">
69 <tr>
78 <tr>
70 <td title='{{module_messages.1}}'><span {%if beam.pk == active_beam %} {{color_status.1}} {%endif%}>{{beam.get_upvalues.0}}</span></td>
79 <td title='{{module_messages.1}}'><span {%if beam.pk == active_beam %} {{color_status.1}} {%endif%}>{{beam.get_upvalues.0}}</span></td>
71 <td title='{{module_messages.2}}'><span {%if beam.pk == active_beam %} {{color_status.2}} {%endif%}>{{beam.get_upvalues.1}}</span></td>
80 <td title='{{module_messages.2}}'><span {%if beam.pk == active_beam %} {{color_status.2}} {%endif%}>{{beam.get_upvalues.1}}</span></td>
72 <td title='{{module_messages.3}}'><span {%if beam.pk == active_beam %} {{color_status.3}} {%endif%}>{{beam.get_upvalues.2}}</span></td>
81 <td title='{{module_messages.3}}'><span {%if beam.pk == active_beam %} {{color_status.3}} {%endif%}>{{beam.get_upvalues.2}}</span></td>
73 <td title='{{module_messages.4}}'><span {%if beam.pk == active_beam %} {{color_status.4}} {%endif%}>{{beam.get_upvalues.3}}</span></td>
82 <td title='{{module_messages.4}}'><span {%if beam.pk == active_beam %} {{color_status.4}} {%endif%}>{{beam.get_upvalues.3}}</span></td>
74 </tr>
83 </tr>
75 <tr>
84 <tr>
76 <td title='{{module_messages.1}}'><span {%if beam.pk == active_beam %} {{color_status.1}} {%endif%}>{{beam.get_downvalues.0}}</span></td>
85 <td title='{{module_messages.1}}'><span {%if beam.pk == active_beam %} {{color_status.1}} {%endif%}>{{beam.get_downvalues.0}}</span></td>
77 <td title='{{module_messages.2}}'><span {%if beam.pk == active_beam %} {{color_status.2}} {%endif%}>{{beam.get_downvalues.1}}</span></td>
86 <td title='{{module_messages.2}}'><span {%if beam.pk == active_beam %} {{color_status.2}} {%endif%}>{{beam.get_downvalues.1}}</span></td>
78 <td title='{{module_messages.3}}'> <span {%if beam.pk == active_beam %} {{color_status.3}} {%endif%}>{{beam.get_downvalues.2}}</span></td>
87 <td title='{{module_messages.3}}'> <span {%if beam.pk == active_beam %} {{color_status.3}} {%endif%}>{{beam.get_downvalues.2}}</span></td>
79 <td title='{{module_messages.4}}'> <span {%if beam.pk == active_beam %} {{color_status.4}} {%endif%}>{{beam.get_downvalues.3}}</span></td>
88 <td title='{{module_messages.4}}'> <span {%if beam.pk == active_beam %} {{color_status.4}} {%endif%}>{{beam.get_downvalues.3}}</span></td>
80 </tr>
89 </tr>
81 <tr>
90 <tr>
82 <td title='{{module_messages.9}}'> <span {%if beam.pk == active_beam %} {{color_status.9}} {%endif%}>{{beam.get_upvalues.8}}</span></td>
91 <td title='{{module_messages.9}}'> <span {%if beam.pk == active_beam %} {{color_status.9}} {%endif%}>{{beam.get_upvalues.8}}</span></td>
83 <td title='{{module_messages.10}}'><span {%if beam.pk == active_beam %} {{color_status.10}} {%endif%}>{{beam.get_upvalues.9}}</span></td>
92 <td title='{{module_messages.10}}'><span {%if beam.pk == active_beam %} {{color_status.10}} {%endif%}>{{beam.get_upvalues.9}}</span></td>
84 <td title='{{module_messages.11}}'><span {%if beam.pk == active_beam %} {{color_status.11}} {%endif%}>{{beam.get_upvalues.10}}</span></td>
93 <td title='{{module_messages.11}}'><span {%if beam.pk == active_beam %} {{color_status.11}} {%endif%}>{{beam.get_upvalues.10}}</span></td>
85 <td title='{{module_messages.12}}'><span {%if beam.pk == active_beam %} {{color_status.12}} {%endif%}>{{beam.get_upvalues.11}}</span></td>
94 <td title='{{module_messages.12}}'><span {%if beam.pk == active_beam %} {{color_status.12}} {%endif%}>{{beam.get_upvalues.11}}</span></td>
86 </tr>
95 </tr>
87 <tr>
96 <tr>
88 <td title='{{module_messages.9}}'> <span {%if beam.pk == active_beam %} {{color_status.9}} {%endif%}>{{beam.get_downvalues.8}}</span></td>
97 <td title='{{module_messages.9}}'> <span {%if beam.pk == active_beam %} {{color_status.9}} {%endif%}>{{beam.get_downvalues.8}}</span></td>
89 <td title='{{module_messages.10}}'><span {%if beam.pk == active_beam %} {{color_status.10}} {%endif%}>{{beam.get_downvalues.9}}</span></td>
98 <td title='{{module_messages.10}}'><span {%if beam.pk == active_beam %} {{color_status.10}} {%endif%}>{{beam.get_downvalues.9}}</span></td>
90 <td title='{{module_messages.11}}'><span {%if beam.pk == active_beam %} {{color_status.11}} {%endif%}>{{beam.get_downvalues.10}}</span></td>
99 <td title='{{module_messages.11}}'><span {%if beam.pk == active_beam %} {{color_status.11}} {%endif%}>{{beam.get_downvalues.10}}</span></td>
91 <td title='{{module_messages.12}}'><span {%if beam.pk == active_beam %} {{color_status.12}} {%endif%}>{{beam.get_downvalues.11}}</span></td>
100 <td title='{{module_messages.12}}'><span {%if beam.pk == active_beam %} {{color_status.12}} {%endif%}>{{beam.get_downvalues.11}}</span></td>
92 </tr>
101 </tr>
93 <tr>
102 <tr>
94 <td title='{{module_messages.17}}'><span {%if beam.pk == active_beam %} {{color_status.17}} {%endif%}>{{beam.get_upvalues.16}}</span></td>
103 <td title='{{module_messages.17}}'><span {%if beam.pk == active_beam %} {{color_status.17}} {%endif%}>{{beam.get_upvalues.16}}</span></td>
95 <td title='{{module_messages.18}}'><span {%if beam.pk == active_beam %} {{color_status.18}} {%endif%}>{{beam.get_upvalues.17}}</span></td>
104 <td title='{{module_messages.18}}'><span {%if beam.pk == active_beam %} {{color_status.18}} {%endif%}>{{beam.get_upvalues.17}}</span></td>
96 <td title='{{module_messages.19}}'><span {%if beam.pk == active_beam %} {{color_status.19}} {%endif%}>{{beam.get_upvalues.18}}</span></td>
105 <td title='{{module_messages.19}}'><span {%if beam.pk == active_beam %} {{color_status.19}} {%endif%}>{{beam.get_upvalues.18}}</span></td>
97 <td title='{{module_messages.20}}'><span {%if beam.pk == active_beam %} {{color_status.20}} {%endif%}>{{beam.get_upvalues.19}}</span></td>
106 <td title='{{module_messages.20}}'><span {%if beam.pk == active_beam %} {{color_status.20}} {%endif%}>{{beam.get_upvalues.19}}</span></td>
98 </tr>
107 </tr>
99 <tr>
108 <tr>
100 <td title='{{module_messages.17}}'><span {%if beam.pk == active_beam %} {{color_status.17}} {%endif%}>{{beam.get_downvalues.16}}</span></td>
109 <td title='{{module_messages.17}}'><span {%if beam.pk == active_beam %} {{color_status.17}} {%endif%}>{{beam.get_downvalues.16}}</span></td>
101 <td title='{{module_messages.18}}'><span {%if beam.pk == active_beam %} {{color_status.18}} {%endif%}>{{beam.get_downvalues.17}}</span></td>
110 <td title='{{module_messages.18}}'><span {%if beam.pk == active_beam %} {{color_status.18}} {%endif%}>{{beam.get_downvalues.17}}</span></td>
102 <td title='{{module_messages.19}}'><span {%if beam.pk == active_beam %} {{color_status.19}} {%endif%}>{{beam.get_downvalues.18}}</span></td>
111 <td title='{{module_messages.19}}'><span {%if beam.pk == active_beam %} {{color_status.19}} {%endif%}>{{beam.get_downvalues.18}}</span></td>
103 <td title='{{module_messages.20}}'><span {%if beam.pk == active_beam %} {{color_status.20}} {%endif%}>{{beam.get_downvalues.19}}</span></td>
112 <td title='{{module_messages.20}}'><span {%if beam.pk == active_beam %} {{color_status.20}} {%endif%}>{{beam.get_downvalues.19}}</span></td>
104 </tr>
113 </tr>
105 <tr>
114 <tr>
106 <td title='{{module_messages.25}}'><span {%if beam.pk == active_beam %} {{color_status.25}} {%endif%}>{{beam.get_upvalues.24}}</span></td>
115 <td title='{{module_messages.25}}'><span {%if beam.pk == active_beam %} {{color_status.25}} {%endif%}>{{beam.get_upvalues.24}}</span></td>
107 <td title='{{module_messages.26}}'><span {%if beam.pk == active_beam %} {{color_status.26}} {%endif%}>{{beam.get_upvalues.25}}</span></td>
116 <td title='{{module_messages.26}}'><span {%if beam.pk == active_beam %} {{color_status.26}} {%endif%}>{{beam.get_upvalues.25}}</span></td>
108 <td title='{{module_messages.27}}'><span {%if beam.pk == active_beam %} {{color_status.27}} {%endif%}>{{beam.get_upvalues.26}}</span></td>
117 <td title='{{module_messages.27}}'><span {%if beam.pk == active_beam %} {{color_status.27}} {%endif%}>{{beam.get_upvalues.26}}</span></td>
109 <td title='{{module_messages.28}}'><span {%if beam.pk == active_beam %} {{color_status.28}} {%endif%}>{{beam.get_upvalues.27}}</span></td>
118 <td title='{{module_messages.28}}'><span {%if beam.pk == active_beam %} {{color_status.28}} {%endif%}>{{beam.get_upvalues.27}}</span></td>
110 </tr>
119 </tr>
111 <tr>
120 <tr>
112 <td title='{{module_messages.25}}'><span {%if beam.pk == active_beam %} {{color_status.25}} {%endif%}>{{beam.get_downvalues.24}}</span></td>
121 <td title='{{module_messages.25}}'><span {%if beam.pk == active_beam %} {{color_status.25}} {%endif%}>{{beam.get_downvalues.24}}</span></td>
113 <td title='{{module_messages.26}}'><span {%if beam.pk == active_beam %} {{color_status.26}} {%endif%}>{{beam.get_downvalues.25}}</span></td>
122 <td title='{{module_messages.26}}'><span {%if beam.pk == active_beam %} {{color_status.26}} {%endif%}>{{beam.get_downvalues.25}}</span></td>
114 <td title='{{module_messages.27}}'><span {%if beam.pk == active_beam %} {{color_status.27}} {%endif%}>{{beam.get_downvalues.26}}</span></td>
123 <td title='{{module_messages.27}}'><span {%if beam.pk == active_beam %} {{color_status.27}} {%endif%}>{{beam.get_downvalues.26}}</span></td>
115 <td title='{{module_messages.28}}'><span {%if beam.pk == active_beam %} {{color_status.28}} {%endif%}>{{beam.get_downvalues.27}}</span></td>
124 <td title='{{module_messages.28}}'><span {%if beam.pk == active_beam %} {{color_status.28}} {%endif%}>{{beam.get_downvalues.27}}</span></td>
116 </tr>
125 </tr>
117 </table>
126 </table>
118 </td>
127 </td>
119 <td>
128 <td>
120 <b>East Quarter</b>
129 <b>East Quarter</b>
121 <table class="module">
130 <table class="module">
122 <tr>
131 <tr>
123 <td title='{{module_messages.5}}'> <span {%if beam.pk == active_beam %} {{color_status.5}} {%endif%}>{{beam.get_upvalues.4}}</span></td>
132 <td title='{{module_messages.5}}'> <span {%if beam.pk == active_beam %} {{color_status.5}} {%endif%}>{{beam.get_upvalues.4}}</span></td>
124 <td title='{{module_messages.6}}'> <span {%if beam.pk == active_beam %} {{color_status.6}} {%endif%}>{{beam.get_upvalues.5}}</span></td>
133 <td title='{{module_messages.6}}'> <span {%if beam.pk == active_beam %} {{color_status.6}} {%endif%}>{{beam.get_upvalues.5}}</span></td>
125 <td title='{{module_messages.7}}'> <span {%if beam.pk == active_beam %} {{color_status.7}} {%endif%}>{{beam.get_upvalues.6}}</span></td>
134 <td title='{{module_messages.7}}'> <span {%if beam.pk == active_beam %} {{color_status.7}} {%endif%}>{{beam.get_upvalues.6}}</span></td>
126 <td title='{{module_messages.8}}'> <span {%if beam.pk == active_beam %} {{color_status.8}} {%endif%}>{{beam.get_upvalues.7}}</span></td>
135 <td title='{{module_messages.8}}'> <span {%if beam.pk == active_beam %} {{color_status.8}} {%endif%}>{{beam.get_upvalues.7}}</span></td>
127 </tr>
136 </tr>
128 <tr>
137 <tr>
129 <td title='{{module_messages.5}}'> <span {%if beam.pk == active_beam %} {{color_status.5}} {%endif%}>{{beam.get_downvalues.4}}</span></td>
138 <td title='{{module_messages.5}}'> <span {%if beam.pk == active_beam %} {{color_status.5}} {%endif%}>{{beam.get_downvalues.4}}</span></td>
130 <td title='{{module_messages.6}}'> <span {%if beam.pk == active_beam %} {{color_status.6}} {%endif%}>{{beam.get_downvalues.5}}</span></td>
139 <td title='{{module_messages.6}}'> <span {%if beam.pk == active_beam %} {{color_status.6}} {%endif%}>{{beam.get_downvalues.5}}</span></td>
131 <td title='{{module_messages.7}}'> <span {%if beam.pk == active_beam %} {{color_status.7}} {%endif%}>{{beam.get_downvalues.6}}</span></td>
140 <td title='{{module_messages.7}}'> <span {%if beam.pk == active_beam %} {{color_status.7}} {%endif%}>{{beam.get_downvalues.6}}</span></td>
132 <td title='{{module_messages.8}}'> <span {%if beam.pk == active_beam %} {{color_status.8}} {%endif%}>{{beam.get_downvalues.7}}</span></td>
141 <td title='{{module_messages.8}}'> <span {%if beam.pk == active_beam %} {{color_status.8}} {%endif%}>{{beam.get_downvalues.7}}</span></td>
133 </tr>
142 </tr>
134 <tr>
143 <tr>
135 <td title='{{module_messages.13}}'><span {%if beam.pk == active_beam %} {{color_status.13}} {%endif%}>{{beam.get_upvalues.12}}</span></td>
144 <td title='{{module_messages.13}}'><span {%if beam.pk == active_beam %} {{color_status.13}} {%endif%}>{{beam.get_upvalues.12}}</span></td>
136 <td title='{{module_messages.14}}'><span {%if beam.pk == active_beam %} {{color_status.14}} {%endif%}>{{beam.get_upvalues.13}}</span></td>
145 <td title='{{module_messages.14}}'><span {%if beam.pk == active_beam %} {{color_status.14}} {%endif%}>{{beam.get_upvalues.13}}</span></td>
137 <td title='{{module_messages.15}}'><span {%if beam.pk == active_beam %} {{color_status.15}} {%endif%}>{{beam.get_upvalues.14}}</span></td>
146 <td title='{{module_messages.15}}'><span {%if beam.pk == active_beam %} {{color_status.15}} {%endif%}>{{beam.get_upvalues.14}}</span></td>
138 <td title='{{module_messages.16}}'><span {%if beam.pk == active_beam %} {{color_status.16}} {%endif%}>{{beam.get_upvalues.15}}</span></td>
147 <td title='{{module_messages.16}}'><span {%if beam.pk == active_beam %} {{color_status.16}} {%endif%}>{{beam.get_upvalues.15}}</span></td>
139 </tr>
148 </tr>
140 <tr>
149 <tr>
141 <td title='{{module_messages.13}}'><span {%if beam.pk == active_beam %} {{color_status.13}} {%endif%}>{{beam.get_downvalues.12}}</span></td>
150 <td title='{{module_messages.13}}'><span {%if beam.pk == active_beam %} {{color_status.13}} {%endif%}>{{beam.get_downvalues.12}}</span></td>
142 <td title='{{module_messages.14}}'><span {%if beam.pk == active_beam %} {{color_status.14}} {%endif%}>{{beam.get_downvalues.13}}</span></td>
151 <td title='{{module_messages.14}}'><span {%if beam.pk == active_beam %} {{color_status.14}} {%endif%}>{{beam.get_downvalues.13}}</span></td>
143 <td title='{{module_messages.15}}'><span {%if beam.pk == active_beam %} {{color_status.15}} {%endif%}>{{beam.get_downvalues.14}}</span></td>
152 <td title='{{module_messages.15}}'><span {%if beam.pk == active_beam %} {{color_status.15}} {%endif%}>{{beam.get_downvalues.14}}</span></td>
144 <td title='{{module_messages.16}}'><span {%if beam.pk == active_beam %} {{color_status.16}} {%endif%}>{{beam.get_downvalues.15}}</span></td>
153 <td title='{{module_messages.16}}'><span {%if beam.pk == active_beam %} {{color_status.16}} {%endif%}>{{beam.get_downvalues.15}}</span></td>
145 </tr>
154 </tr>
146 <tr>
155 <tr>
147 <td title='{{module_messages.21}}'><span {%if beam.pk == active_beam %} {{color_status.21}} {%endif%}>{{beam.get_upvalues.20}}</span></td>
156 <td title='{{module_messages.21}}'><span {%if beam.pk == active_beam %} {{color_status.21}} {%endif%}>{{beam.get_upvalues.20}}</span></td>
148 <td title='{{module_messages.22}}'><span {%if beam.pk == active_beam %} {{color_status.22}} {%endif%}>{{beam.get_upvalues.21}}</span></td>
157 <td title='{{module_messages.22}}'><span {%if beam.pk == active_beam %} {{color_status.22}} {%endif%}>{{beam.get_upvalues.21}}</span></td>
149 <td title='{{module_messages.23}}'><span {%if beam.pk == active_beam %} {{color_status.23}} {%endif%}>{{beam.get_upvalues.22}}</span></td>
158 <td title='{{module_messages.23}}'><span {%if beam.pk == active_beam %} {{color_status.23}} {%endif%}>{{beam.get_upvalues.22}}</span></td>
150 <td title='{{module_messages.24}}'><span {%if beam.pk == active_beam %} {{color_status.24}} {%endif%}>{{beam.get_upvalues.23}}</span></td>
159 <td title='{{module_messages.24}}'><span {%if beam.pk == active_beam %} {{color_status.24}} {%endif%}>{{beam.get_upvalues.23}}</span></td>
151 </tr>
160 </tr>
152 <tr>
161 <tr>
153 <td title='{{module_messages.21}}'><span {%if beam.pk == active_beam %} {{color_status.21}} {%endif%}>{{beam.get_downvalues.20}}</span></td>
162 <td title='{{module_messages.21}}'><span {%if beam.pk == active_beam %} {{color_status.21}} {%endif%}>{{beam.get_downvalues.20}}</span></td>
154 <td title='{{module_messages.22}}'><span {%if beam.pk == active_beam %} {{color_status.22}} {%endif%}>{{beam.get_downvalues.21}}</span></td>
163 <td title='{{module_messages.22}}'><span {%if beam.pk == active_beam %} {{color_status.22}} {%endif%}>{{beam.get_downvalues.21}}</span></td>
155 <td title='{{module_messages.23}}'><span {%if beam.pk == active_beam %} {{color_status.23}} {%endif%}>{{beam.get_downvalues.22}}</span></td>
164 <td title='{{module_messages.23}}'><span {%if beam.pk == active_beam %} {{color_status.23}} {%endif%}>{{beam.get_downvalues.22}}</span></td>
156 <td title='{{module_messages.24}}'><span {%if beam.pk == active_beam %} {{color_status.24}} {%endif%}>{{beam.get_downvalues.23}}</span></td>
165 <td title='{{module_messages.24}}'><span {%if beam.pk == active_beam %} {{color_status.24}} {%endif%}>{{beam.get_downvalues.23}}</span></td>
157 </tr>
166 </tr>
158 <tr>
167 <tr>
159 <td title='{{module_messages.29}}'><span {%if beam.pk == active_beam %} {{color_status.29}} {%endif%}>{{beam.get_upvalues.28}}</span></td>
168 <td title='{{module_messages.29}}'><span {%if beam.pk == active_beam %} {{color_status.29}} {%endif%}>{{beam.get_upvalues.28}}</span></td>
160 <td title='{{module_messages.30}}'><span {%if beam.pk == active_beam %} {{color_status.30}} {%endif%}>{{beam.get_upvalues.29}}</span></td>
169 <td title='{{module_messages.30}}'><span {%if beam.pk == active_beam %} {{color_status.30}} {%endif%}>{{beam.get_upvalues.29}}</span></td>
161 <td title='{{module_messages.31}}'><span {%if beam.pk == active_beam %} {{color_status.31}} {%endif%}>{{beam.get_upvalues.30}}</span></td>
170 <td title='{{module_messages.31}}'><span {%if beam.pk == active_beam %} {{color_status.31}} {%endif%}>{{beam.get_upvalues.30}}</span></td>
162 <td title='{{module_messages.32}}'><span {%if beam.pk == active_beam %} {{color_status.32}} {%endif%}>{{beam.get_upvalues.31}}</span></td>
171 <td title='{{module_messages.32}}'><span {%if beam.pk == active_beam %} {{color_status.32}} {%endif%}>{{beam.get_upvalues.31}}</span></td>
163 </tr>
172 </tr>
164 <tr>
173 <tr>
165 <td title='{{module_messages.29}}'><span {%if beam.pk == active_beam %} {{color_status.29}} {%endif%}>{{beam.get_downvalues.28}}</span></td>
174 <td title='{{module_messages.29}}'><span {%if beam.pk == active_beam %} {{color_status.29}} {%endif%}>{{beam.get_downvalues.28}}</span></td>
166 <td title='{{module_messages.30}}'><span {%if beam.pk == active_beam %} {{color_status.30}} {%endif%}>{{beam.get_downvalues.29}}</span></td>
175 <td title='{{module_messages.30}}'><span {%if beam.pk == active_beam %} {{color_status.30}} {%endif%}>{{beam.get_downvalues.29}}</span></td>
167 <td title='{{module_messages.31}}'><span {%if beam.pk == active_beam %} {{color_status.31}} {%endif%}>{{beam.get_downvalues.30}}</span></td>
176 <td title='{{module_messages.31}}'><span {%if beam.pk == active_beam %} {{color_status.31}} {%endif%}>{{beam.get_downvalues.30}}</span></td>
168 <td title='{{module_messages.32}}'><span {%if beam.pk == active_beam %} {{color_status.32}} {%endif%}>{{beam.get_downvalues.31}}</span></td>
177 <td title='{{module_messages.32}}'><span {%if beam.pk == active_beam %} {{color_status.32}} {%endif%}>{{beam.get_downvalues.31}}</span></td>
169 </tr>
178 </tr>
170 </table>
179 </table>
171 </td>
180 </td>
172 </tr>
181 </tr>
173 <tr>
182 <tr>
174 <td>
183 <td>
175 <b>West Quarter</b>
184 <b>West Quarter</b>
176 <table class="module">
185 <table class="module">
177 <tr>
186 <tr>
178 <td title='{{module_messages.33}}'><span {%if beam.pk == active_beam %} {{color_status.33}} {%endif%}>{{beam.get_upvalues.32}}</span></td>
187 <td title='{{module_messages.33}}'><span {%if beam.pk == active_beam %} {{color_status.33}} {%endif%}>{{beam.get_upvalues.32}}</span></td>
179 <td title='{{module_messages.34}}'><span {%if beam.pk == active_beam %} {{color_status.34}} {%endif%}>{{beam.get_upvalues.33}}</span></td>
188 <td title='{{module_messages.34}}'><span {%if beam.pk == active_beam %} {{color_status.34}} {%endif%}>{{beam.get_upvalues.33}}</span></td>
180 <td title='{{module_messages.35}}'><span {%if beam.pk == active_beam %} {{color_status.35}} {%endif%}>{{beam.get_upvalues.34}}</span></td>
189 <td title='{{module_messages.35}}'><span {%if beam.pk == active_beam %} {{color_status.35}} {%endif%}>{{beam.get_upvalues.34}}</span></td>
181 <td title='{{module_messages.36}}'><span {%if beam.pk == active_beam %} {{color_status.36}} {%endif%}>{{beam.get_upvalues.35}}</span></td>
190 <td title='{{module_messages.36}}'><span {%if beam.pk == active_beam %} {{color_status.36}} {%endif%}>{{beam.get_upvalues.35}}</span></td>
182 </tr>
191 </tr>
183 <tr>
192 <tr>
184 <td title='{{module_messages.33}}'><span {%if beam.pk == active_beam %} {{color_status.33}} {%endif%}>{{beam.get_downvalues.32}}</span></td>
193 <td title='{{module_messages.33}}'><span {%if beam.pk == active_beam %} {{color_status.33}} {%endif%}>{{beam.get_downvalues.32}}</span></td>
185 <td title='{{module_messages.34}}'><span {%if beam.pk == active_beam %} {{color_status.34}} {%endif%}>{{beam.get_downvalues.33}}</span></td>
194 <td title='{{module_messages.34}}'><span {%if beam.pk == active_beam %} {{color_status.34}} {%endif%}>{{beam.get_downvalues.33}}</span></td>
186 <td title='{{module_messages.35}}'><span {%if beam.pk == active_beam %} {{color_status.35}} {%endif%}>{{beam.get_downvalues.34}}</span></td>
195 <td title='{{module_messages.35}}'><span {%if beam.pk == active_beam %} {{color_status.35}} {%endif%}>{{beam.get_downvalues.34}}</span></td>
187 <td title='{{module_messages.36}}'><span {%if beam.pk == active_beam %} {{color_status.36}} {%endif%}>{{beam.get_downvalues.35}}</span></td>
196 <td title='{{module_messages.36}}'><span {%if beam.pk == active_beam %} {{color_status.36}} {%endif%}>{{beam.get_downvalues.35}}</span></td>
188 </tr>
197 </tr>
189 <tr>
198 <tr>
190 <td title='{{module_messages.41}}'><span {%if beam.pk == active_beam %} {{color_status.41}} {%endif%}>{{beam.get_upvalues.40}}</span></td>
199 <td title='{{module_messages.41}}'><span {%if beam.pk == active_beam %} {{color_status.41}} {%endif%}>{{beam.get_upvalues.40}}</span></td>
191 <td title='{{module_messages.42}}'><span {%if beam.pk == active_beam %} {{color_status.42}} {%endif%}>{{beam.get_upvalues.41}}</span></td>
200 <td title='{{module_messages.42}}'><span {%if beam.pk == active_beam %} {{color_status.42}} {%endif%}>{{beam.get_upvalues.41}}</span></td>
192 <td title='{{module_messages.43}}'><span {%if beam.pk == active_beam %} {{color_status.43}} {%endif%}>{{beam.get_upvalues.42}}</span></td>
201 <td title='{{module_messages.43}}'><span {%if beam.pk == active_beam %} {{color_status.43}} {%endif%}>{{beam.get_upvalues.42}}</span></td>
193 <td title='{{module_messages.44}}'><span {%if beam.pk == active_beam %} {{color_status.44}} {%endif%}>{{beam.get_upvalues.43}}</span></td>
202 <td title='{{module_messages.44}}'><span {%if beam.pk == active_beam %} {{color_status.44}} {%endif%}>{{beam.get_upvalues.43}}</span></td>
194 </tr>
203 </tr>
195 <tr>
204 <tr>
196 <td title='{{module_messages.41}}'><span {%if beam.pk == active_beam %} {{color_status.41}} {%endif%}>{{beam.get_downvalues.40}}</span></td>
205 <td title='{{module_messages.41}}'><span {%if beam.pk == active_beam %} {{color_status.41}} {%endif%}>{{beam.get_downvalues.40}}</span></td>
197 <td title='{{module_messages.42}}'><span {%if beam.pk == active_beam %} {{color_status.42}} {%endif%}>{{beam.get_downvalues.41}}</span></td>
206 <td title='{{module_messages.42}}'><span {%if beam.pk == active_beam %} {{color_status.42}} {%endif%}>{{beam.get_downvalues.41}}</span></td>
198 <td title='{{module_messages.43}}'><span {%if beam.pk == active_beam %} {{color_status.43}} {%endif%}>{{beam.get_downvalues.42}}</span></td>
207 <td title='{{module_messages.43}}'><span {%if beam.pk == active_beam %} {{color_status.43}} {%endif%}>{{beam.get_downvalues.42}}</span></td>
199 <td title='{{module_messages.44}}'><span {%if beam.pk == active_beam %} {{color_status.44}} {%endif%}>{{beam.get_downvalues.43}}</span></td>
208 <td title='{{module_messages.44}}'><span {%if beam.pk == active_beam %} {{color_status.44}} {%endif%}>{{beam.get_downvalues.43}}</span></td>
200 </tr>
209 </tr>
201 <tr>
210 <tr>
202 <td title='{{module_messages.49}}'><span {%if beam.pk == active_beam %} {{color_status.49}} {%endif%}>{{beam.get_upvalues.48}}</span></td>
211 <td title='{{module_messages.49}}'><span {%if beam.pk == active_beam %} {{color_status.49}} {%endif%}>{{beam.get_upvalues.48}}</span></td>
203 <td title='{{module_messages.51}}'><span {%if beam.pk == active_beam %} {{color_status.50}} {%endif%}>{{beam.get_upvalues.49}}</span></td>
212 <td title='{{module_messages.51}}'><span {%if beam.pk == active_beam %} {{color_status.50}} {%endif%}>{{beam.get_upvalues.49}}</span></td>
204 <td title='{{module_messages.52}}'><span {%if beam.pk == active_beam %} {{color_status.51}} {%endif%}>{{beam.get_upvalues.50}}</span></td>
213 <td title='{{module_messages.52}}'><span {%if beam.pk == active_beam %} {{color_status.51}} {%endif%}>{{beam.get_upvalues.50}}</span></td>
205 <td title='{{module_messages.53}}'><span {%if beam.pk == active_beam %} {{color_status.52}} {%endif%}>{{beam.get_upvalues.51}}</span></td>
214 <td title='{{module_messages.53}}'><span {%if beam.pk == active_beam %} {{color_status.52}} {%endif%}>{{beam.get_upvalues.51}}</span></td>
206 </tr>
215 </tr>
207 <tr>
216 <tr>
208 <td title='{{module_messages.49}}'><span {%if beam.pk == active_beam %} {{color_status.49}} {%endif%}>{{beam.get_downvalues.48}}</span></td>
217 <td title='{{module_messages.49}}'><span {%if beam.pk == active_beam %} {{color_status.49}} {%endif%}>{{beam.get_downvalues.48}}</span></td>
209 <td title='{{module_messages.50}}'><span {%if beam.pk == active_beam %} {{color_status.50}} {%endif%}>{{beam.get_downvalues.49}}</span></td>
218 <td title='{{module_messages.50}}'><span {%if beam.pk == active_beam %} {{color_status.50}} {%endif%}>{{beam.get_downvalues.49}}</span></td>
210 <td title='{{module_messages.51}}'><span {%if beam.pk == active_beam %} {{color_status.51}} {%endif%}>{{beam.get_downvalues.50}}</span></td>
219 <td title='{{module_messages.51}}'><span {%if beam.pk == active_beam %} {{color_status.51}} {%endif%}>{{beam.get_downvalues.50}}</span></td>
211 <td title='{{module_messages.52}}'><span {%if beam.pk == active_beam %} {{color_status.52}} {%endif%}>{{beam.get_downvalues.51}}</span></td>
220 <td title='{{module_messages.52}}'><span {%if beam.pk == active_beam %} {{color_status.52}} {%endif%}>{{beam.get_downvalues.51}}</span></td>
212 </tr>
221 </tr>
213 <tr>
222 <tr>
214 <td title='{{module_messages.57}}'><span {%if beam.pk == active_beam %} {{color_status.57}} {%endif%}>{{beam.get_upvalues.56}}</span></td>
223 <td title='{{module_messages.57}}'><span {%if beam.pk == active_beam %} {{color_status.57}} {%endif%}>{{beam.get_upvalues.56}}</span></td>
215 <td title='{{module_messages.58}}'><span {%if beam.pk == active_beam %} {{color_status.58}} {%endif%}>{{beam.get_upvalues.57}}</span></td>
224 <td title='{{module_messages.58}}'><span {%if beam.pk == active_beam %} {{color_status.58}} {%endif%}>{{beam.get_upvalues.57}}</span></td>
216 <td title='{{module_messages.59}}'><span {%if beam.pk == active_beam %} {{color_status.59}} {%endif%}>{{beam.get_upvalues.58}}</span></td>
225 <td title='{{module_messages.59}}'><span {%if beam.pk == active_beam %} {{color_status.59}} {%endif%}>{{beam.get_upvalues.58}}</span></td>
217 <td title='{{module_messages.60}}'><span {%if beam.pk == active_beam %} {{color_status.60}} {%endif%}>{{beam.get_upvalues.59}}</span></td>
226 <td title='{{module_messages.60}}'><span {%if beam.pk == active_beam %} {{color_status.60}} {%endif%}>{{beam.get_upvalues.59}}</span></td>
218 </tr>
227 </tr>
219 <tr>
228 <tr>
220 <td title='{{module_messages.57}}'><span {%if beam.pk == active_beam %} {{color_status.57}} {%endif%}>{{beam.get_downvalues.56}}</span></td>
229 <td title='{{module_messages.57}}'><span {%if beam.pk == active_beam %} {{color_status.57}} {%endif%}>{{beam.get_downvalues.56}}</span></td>
221 <td title='{{module_messages.58}}'><span {%if beam.pk == active_beam %} {{color_status.58}} {%endif%}>{{beam.get_downvalues.57}}</span></td>
230 <td title='{{module_messages.58}}'><span {%if beam.pk == active_beam %} {{color_status.58}} {%endif%}>{{beam.get_downvalues.57}}</span></td>
222 <td title='{{module_messages.59}}'><span {%if beam.pk == active_beam %} {{color_status.59}} {%endif%}>{{beam.get_downvalues.58}}</span></td>
231 <td title='{{module_messages.59}}'><span {%if beam.pk == active_beam %} {{color_status.59}} {%endif%}>{{beam.get_downvalues.58}}</span></td>
223 <td title='{{module_messages.60}}'><span {%if beam.pk == active_beam %} {{color_status.60}} {%endif%}>{{beam.get_downvalues.59}}</span></td>
232 <td title='{{module_messages.60}}'><span {%if beam.pk == active_beam %} {{color_status.60}} {%endif%}>{{beam.get_downvalues.59}}</span></td>
224 </tr>
233 </tr>
225 </table>
234 </table>
226 </td>
235 </td>
227 <td>
236 <td>
228 <b>South Quarter</b>
237 <b>South Quarter</b>
229 <table class="module">
238 <table class="module">
230 <tr>
239 <tr>
231 <td title='{{module_messages.37}}'><span {%if beam.pk == active_beam %} {{color_status.37}} {%endif%}>{{beam.get_upvalues.36}}</span></td>
240 <td title='{{module_messages.37}}'><span {%if beam.pk == active_beam %} {{color_status.37}} {%endif%}>{{beam.get_upvalues.36}}</span></td>
232 <td title='{{module_messages.38}}'><span {%if beam.pk == active_beam %} {{color_status.38}} {%endif%}>{{beam.get_upvalues.37}}</span></td>
241 <td title='{{module_messages.38}}'><span {%if beam.pk == active_beam %} {{color_status.38}} {%endif%}>{{beam.get_upvalues.37}}</span></td>
233 <td title='{{module_messages.39}}'><span {%if beam.pk == active_beam %} {{color_status.39}} {%endif%}>{{beam.get_upvalues.38}}</span></td>
242 <td title='{{module_messages.39}}'><span {%if beam.pk == active_beam %} {{color_status.39}} {%endif%}>{{beam.get_upvalues.38}}</span></td>
234 <td title='{{module_messages.40}}'><span {%if beam.pk == active_beam %} {{color_status.40}} {%endif%}>{{beam.get_upvalues.39}}</span></td>
243 <td title='{{module_messages.40}}'><span {%if beam.pk == active_beam %} {{color_status.40}} {%endif%}>{{beam.get_upvalues.39}}</span></td>
235 </tr>
244 </tr>
236 <tr>
245 <tr>
237 <td title='{{module_messages.37}}'><span {%if beam.pk == active_beam %} {{color_status.37}} {%endif%}>{{beam.get_downvalues.36}}</span></td>
246 <td title='{{module_messages.37}}'><span {%if beam.pk == active_beam %} {{color_status.37}} {%endif%}>{{beam.get_downvalues.36}}</span></td>
238 <td title='{{module_messages.38}}'><span {%if beam.pk == active_beam %} {{color_status.38}} {%endif%}>{{beam.get_downvalues.37}}</span></td>
247 <td title='{{module_messages.38}}'><span {%if beam.pk == active_beam %} {{color_status.38}} {%endif%}>{{beam.get_downvalues.37}}</span></td>
239 <td title='{{module_messages.39}}'><span {%if beam.pk == active_beam %} {{color_status.39}} {%endif%}>{{beam.get_downvalues.38}}</span></td>
248 <td title='{{module_messages.39}}'><span {%if beam.pk == active_beam %} {{color_status.39}} {%endif%}>{{beam.get_downvalues.38}}</span></td>
240 <td title='{{module_messages.40}}'><span {%if beam.pk == active_beam %} {{color_status.40}} {%endif%}>{{beam.get_downvalues.39}}</span></td>
249 <td title='{{module_messages.40}}'><span {%if beam.pk == active_beam %} {{color_status.40}} {%endif%}>{{beam.get_downvalues.39}}</span></td>
241 </tr>
250 </tr>
242 <tr>
251 <tr>
243 <td title='{{module_messages.45}}'><span {%if beam.pk == active_beam %} {{color_status.45}} {%endif%}>{{beam.get_upvalues.44}}</span></td>
252 <td title='{{module_messages.45}}'><span {%if beam.pk == active_beam %} {{color_status.45}} {%endif%}>{{beam.get_upvalues.44}}</span></td>
244 <td title='{{module_messages.46}}'><span {%if beam.pk == active_beam %} {{color_status.46}} {%endif%}>{{beam.get_upvalues.45}}</span></td>
253 <td title='{{module_messages.46}}'><span {%if beam.pk == active_beam %} {{color_status.46}} {%endif%}>{{beam.get_upvalues.45}}</span></td>
245 <td title='{{module_messages.47}}'><span {%if beam.pk == active_beam %} {{color_status.47}} {%endif%}>{{beam.get_upvalues.46}}</span></td>
254 <td title='{{module_messages.47}}'><span {%if beam.pk == active_beam %} {{color_status.47}} {%endif%}>{{beam.get_upvalues.46}}</span></td>
246 <td title='{{module_messages.48}}'><span {%if beam.pk == active_beam %} {{color_status.48}} {%endif%}>{{beam.get_upvalues.47}}</span></td>
255 <td title='{{module_messages.48}}'><span {%if beam.pk == active_beam %} {{color_status.48}} {%endif%}>{{beam.get_upvalues.47}}</span></td>
247 </tr>
256 </tr>
248 <tr>
257 <tr>
249 <td title='{{module_messages.45}}'><span {%if beam.pk == active_beam %} {{color_status.45}} {%endif%}>{{beam.get_downvalues.44}}</span></td>
258 <td title='{{module_messages.45}}'><span {%if beam.pk == active_beam %} {{color_status.45}} {%endif%}>{{beam.get_downvalues.44}}</span></td>
250 <td title='{{module_messages.46}}'><span {%if beam.pk == active_beam %} {{color_status.46}} {%endif%}>{{beam.get_downvalues.45}}</span></td>
259 <td title='{{module_messages.46}}'><span {%if beam.pk == active_beam %} {{color_status.46}} {%endif%}>{{beam.get_downvalues.45}}</span></td>
251 <td title='{{module_messages.47}}'><span {%if beam.pk == active_beam %} {{color_status.47}} {%endif%}>{{beam.get_downvalues.46}}</span></td>
260 <td title='{{module_messages.47}}'><span {%if beam.pk == active_beam %} {{color_status.47}} {%endif%}>{{beam.get_downvalues.46}}</span></td>
252 <td title='{{module_messages.48}}'><span {%if beam.pk == active_beam %} {{color_status.48}} {%endif%}>{{beam.get_downvalues.47}}</span></td>
261 <td title='{{module_messages.48}}'><span {%if beam.pk == active_beam %} {{color_status.48}} {%endif%}>{{beam.get_downvalues.47}}</span></td>
253 </tr>
262 </tr>
254 <tr>
263 <tr>
255 <td title='{{module_messages.53}}'><span {%if beam.pk == active_beam %} {{color_status.53}} {%endif%}>{{beam.get_upvalues.52}}</span></td>
264 <td title='{{module_messages.53}}'><span {%if beam.pk == active_beam %} {{color_status.53}} {%endif%}>{{beam.get_upvalues.52}}</span></td>
256 <td title='{{module_messages.54}}'><span {%if beam.pk == active_beam %} {{color_status.54}} {%endif%}>{{beam.get_upvalues.53}}</span></td>
265 <td title='{{module_messages.54}}'><span {%if beam.pk == active_beam %} {{color_status.54}} {%endif%}>{{beam.get_upvalues.53}}</span></td>
257 <td title='{{module_messages.55}}'><span {%if beam.pk == active_beam %} {{color_status.55}} {%endif%}>{{beam.get_upvalues.54}}</span></td>
266 <td title='{{module_messages.55}}'><span {%if beam.pk == active_beam %} {{color_status.55}} {%endif%}>{{beam.get_upvalues.54}}</span></td>
258 <td title='{{module_messages.56}}'><span {%if beam.pk == active_beam %} {{color_status.56}} {%endif%}>{{beam.get_upvalues.55}}</span></td>
267 <td title='{{module_messages.56}}'><span {%if beam.pk == active_beam %} {{color_status.56}} {%endif%}>{{beam.get_upvalues.55}}</span></td>
259 </tr>
268 </tr>
260 <tr>
269 <tr>
261 <td title='{{module_messages.53}}'><span {%if beam.pk == active_beam %} {{color_status.53}} {%endif%}>{{beam.get_downvalues.52}}</span></td>
270 <td title='{{module_messages.53}}'><span {%if beam.pk == active_beam %} {{color_status.53}} {%endif%}>{{beam.get_downvalues.52}}</span></td>
262 <td title='{{module_messages.54}}'><span {%if beam.pk == active_beam %} {{color_status.54}} {%endif%}>{{beam.get_downvalues.53}}</span></td>
271 <td title='{{module_messages.54}}'><span {%if beam.pk == active_beam %} {{color_status.54}} {%endif%}>{{beam.get_downvalues.53}}</span></td>
263 <td title='{{module_messages.55}}'><span {%if beam.pk == active_beam %} {{color_status.55}} {%endif%}>{{beam.get_downvalues.54}}</span></td>
272 <td title='{{module_messages.55}}'><span {%if beam.pk == active_beam %} {{color_status.55}} {%endif%}>{{beam.get_downvalues.54}}</span></td>
264 <td title='{{module_messages.56}}'><span {%if beam.pk == active_beam %} {{color_status.56}} {%endif%}>{{beam.get_downvalues.55}}</span></td>
273 <td title='{{module_messages.56}}'><span {%if beam.pk == active_beam %} {{color_status.56}} {%endif%}>{{beam.get_downvalues.55}}</span></td>
265 </tr>
274 </tr>
266 <tr>
275 <tr>
267 <td title='{{module_messages.61}}'><span {%if beam.pk == active_beam %} {{color_status.61}} {%endif%}>{{beam.get_upvalues.60}}</span></td>
276 <td title='{{module_messages.61}}'><span {%if beam.pk == active_beam %} {{color_status.61}} {%endif%}>{{beam.get_upvalues.60}}</span></td>
268 <td title='{{module_messages.62}}'><span {%if beam.pk == active_beam %} {{color_status.62}} {%endif%}>{{beam.get_upvalues.61}}</span></td>
277 <td title='{{module_messages.62}}'><span {%if beam.pk == active_beam %} {{color_status.62}} {%endif%}>{{beam.get_upvalues.61}}</span></td>
269 <td title='{{module_messages.63}}'><span {%if beam.pk == active_beam %} {{color_status.63}} {%endif%}>{{beam.get_upvalues.62}}</span></td>
278 <td title='{{module_messages.63}}'><span {%if beam.pk == active_beam %} {{color_status.63}} {%endif%}>{{beam.get_upvalues.62}}</span></td>
270 <td title='{{module_messages.64}}'><span {%if beam.pk == active_beam %} {{color_status.64}} {%endif%}>{{beam.get_upvalues.63}}</span></td>
279 <td title='{{module_messages.64}}'><span {%if beam.pk == active_beam %} {{color_status.64}} {%endif%}>{{beam.get_upvalues.63}}</span></td>
271 </tr>
280 </tr>
272 <tr>
281 <tr>
273 <td title='{{module_messages.61}}'><span {%if beam.pk == active_beam %} {{color_status.61}} {%endif%}>{{beam.get_downvalues.60}}</span></td>
282 <td title='{{module_messages.61}}'><span {%if beam.pk == active_beam %} {{color_status.61}} {%endif%}>{{beam.get_downvalues.60}}</span></td>
274 <td title='{{module_messages.62}}'><span {%if beam.pk == active_beam %} {{color_status.62}} {%endif%}>{{beam.get_downvalues.61}}</span></td>
283 <td title='{{module_messages.62}}'><span {%if beam.pk == active_beam %} {{color_status.62}} {%endif%}>{{beam.get_downvalues.61}}</span></td>
275 <td title='{{module_messages.63}}'><span {%if beam.pk == active_beam %} {{color_status.63}} {%endif%}>{{beam.get_downvalues.62}}</span></td>
284 <td title='{{module_messages.63}}'><span {%if beam.pk == active_beam %} {{color_status.63}} {%endif%}>{{beam.get_downvalues.62}}</span></td>
276 <td title='{{module_messages.64}}'><span {%if beam.pk == active_beam %} {{color_status.64}} {%endif%}>{{beam.get_downvalues.63}}</span></td>
285 <td title='{{module_messages.64}}'><span {%if beam.pk == active_beam %} {{color_status.64}} {%endif%}>{{beam.get_downvalues.63}}</span></td>
277 </tr>
286 </tr>
278 </table>
287 </table>
279 </td>
288 </td>
280 </tr>
289 </tr>
281 </table>
290 </table>
282
291
292 <!-- <meta id="configuraciones_down" data-playlist="{{ beam.get_downvalues }}">
293 <meta id="configuraciones_up" data-playlist="{{ beam.get_upvalues }}">
294 <meta id="sda" data-toggle="" -->
295
283 {% if beam.id == active_beam %}
296 {% if beam.id == active_beam %}
284 <table class="legend">
297 <table class="legend">
285 <tr>
298 <tr>
286 <th>Legend</th>
299 <th>Legend</th>
287 </tr>
300 </tr>
288 <tr>
301 <tr>
289 <td class="text-warning">Connected</td>
302 <td class="text-warning">Connected</td>
290 </tr>
303 </tr>
291 <tr>
304 <tr>
292 <td class="text-success">Running</td>
305 <td class="text-success">Running</td>
293 </tr>
306 </tr>
294 <tr>
307 <tr>
295 <td class="text-info">Mismath</td>
308 <td class="text-info">Mismath</td>
296 </tr>
309 </tr>
297 <tr>
310 <tr>
298 <td class="text-danger">Disconnected</td>
311 <td class="text-danger">Disconnected</td>
299 </tr>
312 </tr>
300 </table>
313 </table>
301 {% else %}
314 {% else %}
302 <div style="vertical-align: top; display:inline-block;">
315 <div style="vertical-align: top; display:inline-block;">
303 <button id="send_beam{{forloop.counter}}" type="button" class="btn btn-default">
316 <button id="send_beam{{forloop.counter}}" type="button" class="btn btn-default">
304 <span class="fas fa-external-link-square-alt" aria-hidden="true"></span>
317 <span class="fas fa-external-link-square-alt" aria-hidden="true"></span>
305 Change Beam</button>
318 Change Beam</button>
319 <br><br><br>
320 <button id="change_beam_mqtt{{forloop.counter}}" type="button" class="btn btn-default">
321 <span class="fas fa-external-link-square-alt" aria-hidden="true"></span>
322 Change Beam MQTT</button>
306 </div>
323 </div>
307 {% endif %}
324 {% endif %}
308 </div>
325 </div>
309 {% endfor %}
326 {% endfor %}
310 </div>
327 </div>
311 </div>
328 </div>
312
329
313
330
314 {% else %}
331 {% else %}
315 <p style="color:#b4bcc2; margin-left: 5%;">
332 <p style="color:#b4bcc2; margin-left: 5%;">
316 <i>No Beams...</i>
333 <i>No Beams...</i>
317 </p>
334 </p>
318 {% endif %}
335 {% endif %}
319 {% endblock extra-content %}
336 {% endblock extra-content %}
337
320 {% block extra-js%}
338 {% block extra-js%}
321 <script>
339 <script>
322 $(document).ready(function () {
340 $(document).ready(function () {
323
341
342 var socket = io.connect('http://' + document.domain + ':' + location.port);
343
344 socket.on('connect', function(data) {
345 console.log('Connecting... OK');
346 })
347
348 socket.on('abs_ws', function(data) {
349 console.log('ingresamos');
350 console.log(data.msg);
351 var text = data['msg'];
352 // $('#chatLog').val(text);
353
354 if(data.msg=="b\'Hola\'"){console.log('Hola_amigo')};
355 })
356
357
324 {% for beam in beams %}
358 {% for beam in beams %}
325
359
326 {% if dev_conf.operation_mode == 1 %}
360 {% if dev_conf.operation_mode == 1 %}
327 $("#send_beam{{forloop.counter}}").prop('disabled', true)
361 $("#send_beam{{forloop.counter}}").prop('disabled', true)
362 $("#change_beam_mqtt{{forloop.counter}}").prop('disabled', true)
328 {% else %}
363 {% else %}
329 $("#send_beam{{forloop.counter}}").click(function () {
364 $("#send_beam{{forloop.counter}}").click(function () {
330 document.location = "{% url 'url_send_beam' dev_conf.id beam.id %}";
365 document.location = "{% url 'url_send_beam' dev_conf.id beam.id %}";
331 });
366 });
367
368 a=$("#change_beam_mqtt{{forloop.counter}}")
369 a.click(function () {
370 info="change_beam_mqtt{{forloop.counter}}"
371 socket.emit('change_beam',{data:info})
372 });
373
332 {% endif %}
374 {% endif %}
333
375
334 {% endfor %}
376 {% endfor %}
335
377
336
378
337 });
379 });
380
338 </script>
381 </script>
382
383
339 {% endblock %}
384 {% endblock %}
@@ -1,445 +1,512
1 from django.shortcuts import render
1 from django.shortcuts import render
2 from django.template import RequestContext
2 from django.template import RequestContext
3 from django.shortcuts import redirect, render, get_object_or_404
3 from django.shortcuts import redirect, render, get_object_or_404
4 from django.contrib import messages
4 from django.contrib import messages
5 from django.conf import settings
5 from django.conf import settings
6 from django.http import HttpResponse
6 from django.http import HttpResponse
7 from django.urls import reverse
7 from django.urls import reverse
8 from django.views.decorators.csrf import csrf_exempt
8 from django.views.decorators.csrf import csrf_exempt
9 from django.utils.safestring import mark_safe
9 from django.utils.safestring import mark_safe
10
10
11 from datetime import datetime
11 from datetime import datetime
12 from time import sleep
12 from time import sleep
13 import os
13 import os
14 import io
14 import io
15
15
16 from apps.main.models import Device, Configuration, Experiment
16 from apps.main.models import Device, Configuration, Experiment
17 from apps.main.views import sidebar
17 from apps.main.views import sidebar
18
18
19 from .models import ABSConfiguration, ABSBeam
19 from .models import ABSConfiguration, ABSBeam
20 from .forms import ABSConfigurationForm, ABSBeamEditForm, ABSBeamAddForm, ABSImportForm
20 from .forms import ABSConfigurationForm, ABSBeamEditForm, ABSBeamAddForm, ABSImportForm
21
21
22 from .utils.overJroShow import overJroShow
22 from .utils.overJroShow import overJroShow
23 #from .utils.OverJRO import OverJRO
23 #from .utils.OverJRO import OverJRO
24 #Create your views here.
24 #Create your views here.
25 import json, ast
25 import json, ast
26
26
27 from .mqtt import client as mqtt_client
28 from radarsys.socketconfig import sio as sio
27
29
28 def get_values_from_form(form_data):
30 def get_values_from_form(form_data):
29
31
30 sublistup = []
32 sublistup = []
31 sublistdown = []
33 sublistdown = []
32 subtxlistup = []
34 subtxlistup = []
33 subtxlistdown = []
35 subtxlistdown = []
34 subrxlistup = []
36 subrxlistup = []
35 subrxlistdown = []
37 subrxlistdown = []
36
38
37 up_values_list = []
39 up_values_list = []
38 down_values_list = []
40 down_values_list = []
39 up_txvalues_list = []
41 up_txvalues_list = []
40 down_txvalues_list = []
42 down_txvalues_list = []
41 up_rxvalues_list = []
43 up_rxvalues_list = []
42 down_rxvalues_list = []
44 down_rxvalues_list = []
43
45
44 values_list = {}
46 values_list = {}
45 cont = 1
47 cont = 1
46
48
47 for i in range(1,65):
49 for i in range(1,65):
48 x = float(form_data['abs_up'+str(i)])
50 x = float(form_data['abs_up'+str(i)])
49 y = float(form_data['abs_down'+str(i)])
51 y = float(form_data['abs_down'+str(i)])
50 sublistup.append(x)
52 sublistup.append(x)
51 sublistdown.append(y)
53 sublistdown.append(y)
52
54
53 if str(i) in form_data.getlist('uptx_checks'):
55 if str(i) in form_data.getlist('uptx_checks'):
54 subtxlistup.append(1)
56 subtxlistup.append(1)
55 else:
57 else:
56 subtxlistup.append(0)
58 subtxlistup.append(0)
57 if str(i) in form_data.getlist('downtx_checks'):
59 if str(i) in form_data.getlist('downtx_checks'):
58 subtxlistdown.append(1)
60 subtxlistdown.append(1)
59 else:
61 else:
60 subtxlistdown.append(0)
62 subtxlistdown.append(0)
61
63
62 if str(i) in form_data.getlist('uprx_checks'):
64 if str(i) in form_data.getlist('uprx_checks'):
63 subrxlistup.append(1)
65 subrxlistup.append(1)
64 else:
66 else:
65 subrxlistup.append(0)
67 subrxlistup.append(0)
66 if str(i) in form_data.getlist('downrx_checks'):
68 if str(i) in form_data.getlist('downrx_checks'):
67 subrxlistdown.append(1)
69 subrxlistdown.append(1)
68 else:
70 else:
69 subrxlistdown.append(0)
71 subrxlistdown.append(0)
70
72
71 cont = cont+1
73 cont = cont+1
72
74
73 if cont == 9:
75 if cont == 9:
74 up_values_list.append(sublistup)
76 up_values_list.append(sublistup)
75 down_values_list.append(sublistdown)
77 down_values_list.append(sublistdown)
76 sublistup = []
78 sublistup = []
77 sublistdown = []
79 sublistdown = []
78
80
79 up_txvalues_list.append(subtxlistup)
81 up_txvalues_list.append(subtxlistup)
80 down_txvalues_list.append(subtxlistdown)
82 down_txvalues_list.append(subtxlistdown)
81 subtxlistup = []
83 subtxlistup = []
82 subtxlistdown = []
84 subtxlistdown = []
83 up_rxvalues_list.append(subrxlistup)
85 up_rxvalues_list.append(subrxlistup)
84 down_rxvalues_list.append(subrxlistdown)
86 down_rxvalues_list.append(subrxlistdown)
85 subrxlistup = []
87 subrxlistup = []
86 subrxlistdown = []
88 subrxlistdown = []
87 cont = 1
89 cont = 1
88
90
89
91
90 list_uesup = []
92 list_uesup = []
91 list_uesdown = []
93 list_uesdown = []
92 for i in range(1,5):
94 for i in range(1,5):
93 if form_data['ues_up'+str(i)] == '':
95 if form_data['ues_up'+str(i)] == '':
94 list_uesup.append(0.0)
96 list_uesup.append(0.0)
95 else:
97 else:
96 list_uesup.append(float(form_data['ues_up'+str(i)]))
98 list_uesup.append(float(form_data['ues_up'+str(i)]))
97
99
98 if form_data['ues_down'+str(i)] == '':
100 if form_data['ues_down'+str(i)] == '':
99 list_uesdown.append(0.0)
101 list_uesdown.append(0.0)
100 else:
102 else:
101 list_uesdown.append(float(form_data['ues_down'+str(i)]))
103 list_uesdown.append(float(form_data['ues_down'+str(i)]))
102
104
103 onlyrx_list = form_data.getlist('onlyrx')
105 onlyrx_list = form_data.getlist('onlyrx')
104 only_rx = {}
106 only_rx = {}
105 if '1' in onlyrx_list:
107 if '1' in onlyrx_list:
106 only_rx['up'] = True
108 only_rx['up'] = True
107 else:
109 else:
108 only_rx['up'] = False
110 only_rx['up'] = False
109 if '2' in onlyrx_list:
111 if '2' in onlyrx_list:
110 only_rx['down'] = True
112 only_rx['down'] = True
111 else:
113 else:
112 only_rx['down'] = False
114 only_rx['down'] = False
113
115
114 antenna = {'antenna_up': up_values_list, 'antenna_down': down_values_list}
116 antenna = {'antenna_up': up_values_list, 'antenna_down': down_values_list}
115 tx = {'up': up_txvalues_list, 'down': down_txvalues_list}
117 tx = {'up': up_txvalues_list, 'down': down_txvalues_list}
116 rx = {'up': up_rxvalues_list, 'down': down_rxvalues_list}
118 rx = {'up': up_rxvalues_list, 'down': down_rxvalues_list}
117 ues = {'up': list_uesup, 'down': list_uesdown}
119 ues = {'up': list_uesup, 'down': list_uesdown}
118 name = str(form_data['beam_name'])
120 name = str(form_data['beam_name'])
119
121
120 beam_data = {'name': name, 'antenna': antenna, 'tx': tx, 'rx': rx, 'ues': ues, 'only_rx': only_rx}
122 beam_data = {'name': name, 'antenna': antenna, 'tx': tx, 'rx': rx, 'ues': ues, 'only_rx': only_rx}
121
123
122 return beam_data
124 return beam_data
123
125
124
126
125 def abs_conf(request, id_conf):
127 def abs_conf(request, id_conf):
126
128
127 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
129 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
128 beams = ABSBeam.objects.filter(abs_conf=conf)
130 beams = ABSBeam.objects.filter(abs_conf=conf)
129 #------------Colors for Active Beam:-------------
131 #------------Colors for Active Beam:-------------
130 all_status = {}
132 all_status = {}
131 module_messages = json.loads(conf.module_messages)
133 module_messages = json.loads(conf.module_messages)
132
134
133 color_status = {}
135 color_status = {}
134 for i, status in enumerate(conf.module_status):
136 for i, status in enumerate(conf.module_status):
135 if status == '3': #Running background-color: #00cc00;
137 if status == '3': #Running background-color: #00cc00;
136 all_status['{}'.format(i+1)] = 2
138 all_status['{}'.format(i+1)] = 2
137 color_status['{}'.format(i+1)] = 'class=text-success'#'bgcolor=#00cc00'
139 color_status['{}'.format(i+1)] = 'class=text-success'#'bgcolor=#00cc00'
138 elif status == '2':
140 elif status == '2':
139 all_status['{}'.format(i+1)] = 1
141 all_status['{}'.format(i+1)] = 1
140 color_status['{}'.format(i+1)] = 'class=text-info'
142 color_status['{}'.format(i+1)] = 'class=text-info'
141 elif status == '1': #Connected background-color: #ee902c;
143 elif status == '1': #Connected background-color: #ee902c;
142 all_status['{}'.format(i+1)] = 1
144 all_status['{}'.format(i+1)] = 1
143 color_status['{}'.format(i+1)] = 'class=text-warning'#'bgcolor=#ee902c'
145 color_status['{}'.format(i+1)] = 'class=text-warning'#'bgcolor=#ee902c'
144 else: #Disconnected background-color: #ff0000;
146 else: #Disconnected background-color: #ff0000;
145 all_status['{}'.format(i+1)] = 0
147 all_status['{}'.format(i+1)] = 0
146 color_status['{}'.format(i+1)] = 'class=text-danger'#'bgcolor=#FF0000'
148 color_status['{}'.format(i+1)] = 'class=text-danger'#'bgcolor=#FF0000'
147 #------------------------------------------------
149 #------------------------------------------------
148
150
149 kwargs = {}
151 kwargs = {}
150 kwargs['connected_modules'] = str(conf.connected_modules())+'/64'
152 kwargs['connected_modules'] = str(conf.connected_modules())+'/64'
151 kwargs['dev_conf'] = conf
153 kwargs['dev_conf'] = conf
152
154
153 if conf.operation_mode == 0:
155 if conf.operation_mode == 0:
154 kwargs['dev_conf_keys'] = ['label', 'operation_mode']
156 kwargs['dev_conf_keys'] = ['label', 'operation_mode']
155 else:
157 else:
156 kwargs['dev_conf_keys'] = ['label', 'operation_mode', 'operation_value']
158 kwargs['dev_conf_keys'] = ['label', 'operation_mode', 'operation_value']
157
159
158 kwargs['title'] = 'ABS Configuration'
160 kwargs['title'] = 'ABS Configuration'
159 kwargs['suptitle'] = 'Details'
161 kwargs['suptitle'] = 'Details'
160 kwargs['button'] = 'Edit Configuration'
162 kwargs['button'] = 'Edit Configuration'
161
163
162 if conf.active_beam != 0:
164 if conf.active_beam != 0:
163 kwargs['active_beam'] = int(conf.active_beam)
165 kwargs['active_beam'] = int(conf.active_beam)
164
166
165 kwargs['beams'] = beams
167 kwargs['beams'] = beams
166 kwargs['modules_status'] = all_status
168 kwargs['modules_status'] = all_status
167 kwargs['color_status'] = color_status
169 kwargs['color_status'] = color_status
168 kwargs['module_messages'] = module_messages
170 kwargs['module_messages'] = module_messages
169 ###### SIDEBAR ######
171 ###### SIDEBAR ######
170 kwargs.update(sidebar(conf=conf))
172 kwargs.update(sidebar(conf=conf))
171
173
172 return render(request, 'abs_conf.html', kwargs)
174 return render(request, 'abs_conf.html', kwargs)
173
175
174
176
175 def abs_conf_edit(request, id_conf):
177 def abs_conf_edit(request, id_conf):
176
178
177 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
179 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
178
180
179 beams = ABSBeam.objects.filter(abs_conf=conf)
181 beams = ABSBeam.objects.filter(abs_conf=conf)
180
182
181 if request.method=='GET':
183 if request.method=='GET':
182 form = ABSConfigurationForm(instance=conf)
184 form = ABSConfigurationForm(instance=conf)
183
185
184 if request.method=='POST':
186 if request.method=='POST':
185 form = ABSConfigurationForm(request.POST, instance=conf)
187 form = ABSConfigurationForm(request.POST, instance=conf)
186
188
187 if form.is_valid():
189 if form.is_valid():
188 conf = form.save(commit=False)
190 conf = form.save(commit=False)
189 conf.save()
191 conf.save()
190 return redirect('url_abs_conf', id_conf=conf.id)
192 return redirect('url_abs_conf', id_conf=conf.id)
191
193
192 ###### SIDEBAR ######
194 ###### SIDEBAR ######
193 kwargs = {}
195 kwargs = {}
194
196
195 kwargs['dev_conf'] = conf
197 kwargs['dev_conf'] = conf
196 #kwargs['id_dev'] = conf.id
198 #kwargs['id_dev'] = conf.id
197 kwargs['id_conf'] = conf.id
199 kwargs['id_conf'] = conf.id
198 kwargs['form'] = form
200 kwargs['form'] = form
199 kwargs['abs_beams'] = beams
201 kwargs['abs_beams'] = beams
200 kwargs['title'] = 'Device Configuration'
202 kwargs['title'] = 'Device Configuration'
201 kwargs['suptitle'] = 'Edit'
203 kwargs['suptitle'] = 'Edit'
202 kwargs['button'] = 'Save'
204 kwargs['button'] = 'Save'
203
205
204 kwargs['edit'] = True
206 kwargs['edit'] = True
205
207
206 return render(request, 'abs_conf_edit.html', kwargs)
208 return render(request, 'abs_conf_edit.html', kwargs)
207
209
208 @csrf_exempt
210 @csrf_exempt
209 def abs_conf_alert(request):
211 def abs_conf_alert(request):
210
212
211 if request.method == 'POST':
213 if request.method == 'POST':
212 print (request.POST)
214 print (request.POST)
213 return HttpResponse(json.dumps({'result':1}), content_type='application/json')
215 return HttpResponse(json.dumps({'result':1}), content_type='application/json')
214 else:
216 else:
215 return redirect('index')
217 return redirect('index')
216
218
217
219
218 def import_file(request, id_conf):
220 def import_file(request, id_conf):
219
221
220 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
222 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
221 if request.method=='POST':
223 if request.method=='POST':
222 form = ABSImportForm(request.POST, request.FILES)
224 form = ABSImportForm(request.POST, request.FILES)
223 if form.is_valid():
225 if form.is_valid():
224 try:
226 try:
225 parms = conf.import_from_file(request.FILES['file_name'])
227 parms = conf.import_from_file(request.FILES['file_name'])
226
228
227 if parms:
229 if parms:
228 conf.update_from_file(parms)
230 conf.update_from_file(parms)
229 messages.success(request, 'Configuration "%s" loaded succesfully' % request.FILES['file_name'])
231 messages.success(request, 'Configuration "%s" loaded succesfully' % request.FILES['file_name'])
230 return redirect(conf.get_absolute_url_edit())
232 return redirect(conf.get_absolute_url_edit())
231
233
232 except Exception as e:
234 except Exception as e:
233 messages.error(request, 'Error parsing file: "%s" - %s' % (request.FILES['file_name'], e))
235 messages.error(request, 'Error parsing file: "%s" - %s' % (request.FILES['file_name'], e))
234
236
235 else:
237 else:
236 messages.warning(request, 'Your current configuration will be replaced')
238 messages.warning(request, 'Your current configuration will be replaced')
237 form = ABSImportForm()
239 form = ABSImportForm()
238
240
239 kwargs = {}
241 kwargs = {}
240 kwargs['form'] = form
242 kwargs['form'] = form
241 kwargs['title'] = 'ABS Configuration'
243 kwargs['title'] = 'ABS Configuration'
242 kwargs['suptitle'] = 'Import file'
244 kwargs['suptitle'] = 'Import file'
243 kwargs['button'] = 'Upload'
245 kwargs['button'] = 'Upload'
244 kwargs['previous'] = conf.get_absolute_url()
246 kwargs['previous'] = conf.get_absolute_url()
245
247
246 return render(request, 'abs_import.html', kwargs)
248 return render(request, 'abs_import.html', kwargs)
247
249
248
250
251 # def send_mqtt(request,id_conf):
252
253 # # conf = get_object_or_404(ABSConfiguration, pk=id_conf)
254
255 # # abs_mqtt = Configuration.objects.filter(pk=conf.device.conf_active).first()
256 # # if abs_mqtt!=conf:
257 # # url_mqtt = '#' if abs is None else abs.get_absolute_url()
258 # # label_mqtt = 'None' if abs is None else abs.label
259 # # messages.warning(
260 # # request,
261 # # mark_safe('The current configuration has not been written in the modules, the active configuration is <a href="{}">{}</a>'.format(
262 # # url_mqtt,
263 # # label_mqtt
264 # # ))
265 # # )
266 # # return redirect(conf.get_absolute_url())
267
268 # # beam = get_object_or_404(ABSBeam, pk=id_beam)
269
270 # conf = get_object_or_404(ABSConfiguration, pk=id_conf)
271
272 # mqtt_client.publish('abs/beams_up', 'Hola up')
273 # mqtt_client.publish('abs/beams_down', 'Hola down')
274
275 # kwargs = {
276 # 'title': 'ABS',
277 # 'suptitle': conf.label,
278 # 'message': 'Are you sure you want to write ABS Beam?',
279 # 'delete': False
280 # }
281 # kwargs['menu_configurations'] = 'active'
282
283 # return render(request, 'confirm.html', kwargs)
284
285
249 def send_beam(request, id_conf, id_beam):
286 def send_beam(request, id_conf, id_beam):
250
287
251 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
288 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
252
289
253 abs = Configuration.objects.filter(pk=conf.device.conf_active).first()
290 abs = Configuration.objects.filter(pk=conf.device.conf_active).first()
254 if abs!=conf:
291 if abs!=conf:
255 url = '#' if abs is None else abs.get_absolute_url()
292 url = '#' if abs is None else abs.get_absolute_url()
256 label = 'None' if abs is None else abs.label
293 label = 'None' if abs is None else abs.label
257 messages.warning(
294 messages.warning(
258 request,
295 request,
259 mark_safe('The current configuration has not been written in the modules, the active configuration is <a href="{}">{}</a>'.format(
296 mark_safe('The current configuration has not been written in the modules, the active configuration is <a href="{}">{}</a>'.format(
260 url,
297 url,
261 label
298 label
262 ))
299 ))
263 )
300 )
264 return redirect(conf.get_absolute_url())
301 return redirect(conf.get_absolute_url())
265
302
266 beam = get_object_or_404(ABSBeam, pk=id_beam)
303 beam = get_object_or_404(ABSBeam, pk=id_beam)
267
304
268 if request.method == 'POST':
305 if request.method == 'POST':
269
306
270 beams_list = ABSBeam.objects.filter(abs_conf=conf)
307 beams_list = ABSBeam.objects.filter(abs_conf=conf)
271 conf.active_beam = id_beam
308 conf.active_beam = id_beam
272
309
273 i = 0
310 i = 0
274 for b in beams_list:
311 for b in beams_list:
275 if b.id == int(id_beam):
312 if b.id == int(id_beam):
276 break
313 break
277 else:
314 else:
278 i += 1
315 i += 1
279 beam_pos = i + 1 #Estandarizar
316 beam_pos = i + 1 #Estandarizar
280 print ('%s Position: %s') % (beam.name, str(beam_pos))
317 print ('%s Position: %s') % (beam.name, str(beam_pos))
281 conf.send_beam(beam_pos)
318 conf.send_beam(beam_pos)
282
319
283 return redirect('url_abs_conf', conf.id)
320 return redirect('url_abs_conf', conf.id)
284
321
285 kwargs = {
322 kwargs = {
286 'title': 'ABS',
323 'title': 'ABS',
287 'suptitle': conf.label,
324 'suptitle': conf.label,
288 'message': 'Are you sure you want to change ABS Beam to: {}?'.format(beam.name),
325 'message': 'Are you sure you want to change ABS Beam to: {}?'.format(beam.name),
289 'delete': False
326 'delete': False
290 }
327 }
291 kwargs['menu_configurations'] = 'active'
328 kwargs['menu_configurations'] = 'active'
292
329
293 return render(request, 'confirm.html', kwargs)
330 return render(request, 'confirm.html', kwargs)
294
331
295
332
296 def add_beam(request, id_conf):
333 def add_beam(request, id_conf):
297
334
298 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
335 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
299 confs = Configuration.objects.all()
336 confs = Configuration.objects.all()
300
337
301 if request.method=='GET':
338 if request.method=='GET':
302 form = ABSBeamAddForm()
339 form = ABSBeamAddForm()
303
340
304 if request.method=='POST':
341 if request.method=='POST':
305 form = ABSBeamAddForm(request.POST)
342 form = ABSBeamAddForm(request.POST)
306
343
307 beam_data = get_values_from_form(request.POST)
344 beam_data = get_values_from_form(request.POST)
308
345
309 new_beam = ABSBeam(
346 new_beam = ABSBeam(
310 name = beam_data['name'],
347 name = beam_data['name'],
311 antenna = json.dumps(beam_data['antenna']),
348 antenna = json.dumps(beam_data['antenna']),
312 abs_conf = conf,
349 abs_conf = conf,
313 tx = json.dumps(beam_data['tx']),
350 tx = json.dumps(beam_data['tx']),
314 rx = json.dumps(beam_data['rx']),
351 rx = json.dumps(beam_data['rx']),
315 ues = json.dumps(beam_data['ues']),
352 ues = json.dumps(beam_data['ues']),
316 only_rx = json.dumps(beam_data['only_rx'])
353 only_rx = json.dumps(beam_data['only_rx'])
317 )
354 )
318 new_beam.save()
355 new_beam.save()
319 messages.success(request, 'Beam: "%s" has been added.' % new_beam.name)
356 messages.success(request, 'Beam: "%s" has been added.' % new_beam.name)
320
357
321 return redirect('url_edit_abs_conf', conf.id)
358 return redirect('url_edit_abs_conf', conf.id)
322
359
323 ###### SIDEBAR ######
360 ###### SIDEBAR ######
324 kwargs = {}
361 kwargs = {}
325
362
326 #kwargs['dev_conf'] = conf.device
363 #kwargs['dev_conf'] = conf.device
327 #kwargs['id_dev'] = conf.device
364 #kwargs['id_dev'] = conf.device
328 #kwargs['previous'] = conf.get_absolute_url_edit()
365 #kwargs['previous'] = conf.get_absolute_url_edit()
329 kwargs['id_conf'] = conf.id
366 kwargs['id_conf'] = conf.id
330 kwargs['form'] = form
367 kwargs['form'] = form
331 kwargs['title'] = 'ABS Beams'
368 kwargs['title'] = 'ABS Beams'
332 kwargs['suptitle'] = 'Add Beam'
369 kwargs['suptitle'] = 'Add Beam'
333 kwargs['button'] = 'Add'
370 kwargs['button'] = 'Add'
334 kwargs['no_sidebar'] = True
371 kwargs['no_sidebar'] = True
335 kwargs['edit'] = True
372 kwargs['edit'] = True
336
373
337 return render(request, 'abs_add_beam.html', kwargs)
374 return render(request, 'abs_add_beam.html', kwargs)
338
375
339
376
340 def edit_beam(request, id_conf, id_beam):
377 def edit_beam(request, id_conf, id_beam):
341
378
342 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
379 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
343 beam = get_object_or_404(ABSBeam, pk=id_beam)
380 beam = get_object_or_404(ABSBeam, pk=id_beam)
344
381
345 if request.method=='GET':
382 if request.method=='GET':
346 form = ABSBeamEditForm(initial={'beam': beam})
383 form = ABSBeamEditForm(initial={'beam': beam})
347
384
348 if request.method=='POST':
385 if request.method=='POST':
349 form = ABSBeamEditForm(request.POST)
386 form = ABSBeamEditForm(request.POST)
350
387
351 beam_data = get_values_from_form(request.POST)
388 beam_data = get_values_from_form(request.POST)
352
389
353 beam.dict_to_parms(beam_data)
390 beam.dict_to_parms(beam_data)
354 beam.save()
391 beam.save()
355
392
356 messages.success(request, 'Beam: "%s" has been updated.' % beam.name)
393 messages.success(request, 'Beam: "%s" has been updated.' % beam.name)
357
394
358 return redirect('url_edit_abs_conf', conf.id)
395 return redirect('url_edit_abs_conf', conf.id)
359
396
360 ###### SIDEBAR ######
397 ###### SIDEBAR ######
361 kwargs = {}
398 kwargs = {}
362
399
363 kwargs['id_conf'] = conf.id
400 kwargs['id_conf'] = conf.id
364 kwargs['form'] = form
401 kwargs['form'] = form
365 kwargs['title'] = 'ABS Beams'
402 kwargs['title'] = 'ABS Beams'
366 kwargs['suptitle'] = 'Edit Beam'
403 kwargs['suptitle'] = 'Edit Beam'
367 kwargs['button'] = 'Save'
404 kwargs['button'] = 'Save'
368 kwargs['no_sidebar'] = True
405 kwargs['no_sidebar'] = True
369
406
370 #kwargs['previous'] = conf.get_absolute_url_edit()
407 #kwargs['previous'] = conf.get_absolute_url_edit()
371 kwargs['edit'] = True
408 kwargs['edit'] = True
372
409
373 return render(request, 'abs_edit_beam.html', kwargs)
410 return render(request, 'abs_edit_beam.html', kwargs)
374
411
375
412
376
413
377 def remove_beam(request, id_conf, id_beam):
414 def remove_beam(request, id_conf, id_beam):
378
415
379 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
416 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
380 beam = get_object_or_404(ABSBeam, pk=id_beam)
417 beam = get_object_or_404(ABSBeam, pk=id_beam)
381
418
382 if request.method=='POST':
419 if request.method=='POST':
383 if beam:
420 if beam:
384 try:
421 try:
385 beam.delete()
422 beam.delete()
386 messages.success(request, 'Beam: "%s" has been deleted.' % beam)
423 messages.success(request, 'Beam: "%s" has been deleted.' % beam)
387 except:
424 except:
388 messages.error(request, 'Unable to delete beam: "%s".' % beam)
425 messages.error(request, 'Unable to delete beam: "%s".' % beam)
389
426
390 return redirect('url_edit_abs_conf', conf.id)
427 return redirect('url_edit_abs_conf', conf.id)
391
428
392 ###### SIDEBAR ######
429 ###### SIDEBAR ######
393 kwargs = {}
430 kwargs = {}
394
431
395 kwargs['object'] = beam
432 kwargs['object'] = beam
396 kwargs['delete'] = True
433 kwargs['delete'] = True
397 kwargs['title'] = 'Delete'
434 kwargs['title'] = 'Delete'
398 kwargs['suptitle'] = 'Beam'
435 kwargs['suptitle'] = 'Beam'
399 kwargs['previous'] = conf.get_absolute_url_edit()
436 kwargs['previous'] = conf.get_absolute_url_edit()
400 return render(request, 'confirm.html', kwargs)
437 return render(request, 'confirm.html', kwargs)
401
438
402
439
403
440
404 def plot_patterns(request, id_conf, id_beam=None):
441 def plot_patterns(request, id_conf, id_beam=None):
405
442
406 kwargs = {}
443 kwargs = {}
407 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
444 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
408 beams = ABSBeam.objects.filter(abs_conf=conf)
445 beams = ABSBeam.objects.filter(abs_conf=conf)
409
446
410 if id_beam:
447 if id_beam:
411 beam = get_object_or_404(ABSBeam, pk=id_beam)
448 beam = get_object_or_404(ABSBeam, pk=id_beam)
412 kwargs['beam'] = beam
449 kwargs['beam'] = beam
413
450
414 ###### SIDEBAR ######
451 ###### SIDEBAR ######
415
452
416 kwargs['dev_conf'] = conf.device
453 kwargs['dev_conf'] = conf.device
417 kwargs['id_dev'] = conf.device
454 kwargs['id_dev'] = conf.device
418 kwargs['id_conf'] = conf.id
455 kwargs['id_conf'] = conf.id
419 kwargs['abs_beams'] = beams
456 kwargs['abs_beams'] = beams
420 kwargs['title'] = 'ABS Patterns'
457 kwargs['title'] = 'ABS Patterns'
421 kwargs['suptitle'] = conf.name
458 kwargs['suptitle'] = conf.name
422 kwargs['no_sidebar'] = True
459 kwargs['no_sidebar'] = True
423
460
424 return render(request, 'abs_patterns.html', kwargs)
461 return render(request, 'abs_patterns.html', kwargs)
425
462
426
463
427 def plot_pattern(request, id_conf, id_beam, antenna):
464 def plot_pattern(request, id_conf, id_beam, antenna):
428
465
429 if antenna=='down':
466 if antenna=='down':
430 sleep(3)
467 sleep(3)
431
468
432 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
469 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
433 beam = get_object_or_404(ABSBeam, pk=id_beam)
470 beam = get_object_or_404(ABSBeam, pk=id_beam)
434 just_rx = 1 if json.loads(beam.only_rx)[antenna] else 0
471 just_rx = 1 if json.loads(beam.only_rx)[antenna] else 0
435 phases = json.loads(beam.antenna)['antenna_{}'.format(antenna)]
472 phases = json.loads(beam.antenna)['antenna_{}'.format(antenna)]
436 gain_tx = json.loads(beam.tx)[antenna]
473 gain_tx = json.loads(beam.tx)[antenna]
437 gain_rx = json.loads(beam.rx)[antenna]
474 gain_rx = json.loads(beam.rx)[antenna]
438 ues = json.loads(beam.ues)[antenna]
475 ues = json.loads(beam.ues)[antenna]
439 newOverJro = overJroShow(beam.name)
476 newOverJro = overJroShow(beam.name)
440 fig = newOverJro.plotPattern2(datetime.today(), phases, gain_tx, gain_rx, ues, just_rx)
477 fig = newOverJro.plotPattern2(datetime.today(), phases, gain_tx, gain_rx, ues, just_rx)
441 buf = io.BytesIO()
478 buf = io.BytesIO()
442 fig.savefig(buf, format='png')
479 fig.savefig(buf, format='png')
443 response = HttpResponse(buf.getvalue(), content_type='image/png')
480 response = HttpResponse(buf.getvalue(), content_type='image/png')
444 return response
481 return response
445
482
483 import os
484 from django.http import HttpResponse
485
486 @sio.on('connection-bind')
487 def abs_connection_bind(sid, data):
488 print("sid:",sid,"data",data)
489
490 @sio.on('disconnect')
491 def abs_test_disconnect(sid):
492 print("Disconnected")
493
494 @sio.event
495 def abs_send_beam_up(sid, message):
496 mqtt_client.publish('abs/beams_up', message['data'])
497
498 @sio.event
499 def abs_send_beam_down(sid, message):
500 mqtt_client.publish('abs/beams_down', message['data'])
501
502 @sio.event
503 def change_beam(sid,message):
504 data=str(message['data'])
505 data=data[16]
506 mqtt_client.publish('abs/change_beam',data)
507
508
509
510
511
512
@@ -1,38 +1,39
1 import os
1 import paho.mqtt.client as mqtt
2 import paho.mqtt.client as mqtt
2 from radarsys import settings
3 from radarsys import settings
3 from radarsys.socketconfig import sio as sio
4 from radarsys.socketconfig import sio as sio
4 import numpy as np
5 import numpy as np
5
6
6 def on_connect(mqtt_client, userdata, flags, rc):
7 def on_connect(mqtt_client, userdata, flags, rc):
7 if rc == 0:
8 if rc == 0:
8 print('Connected successfully')
9 print('Connected successfully')
9 mqtt_client.subscribe('atrad/test3')
10 mqtt_client.subscribe('atrad/test3')
10 else:
11 else:
11 print('Bad connection. Code:', rc)
12 print('Bad connection. Code:', rc)
12
13
13 def maxima_temp(trs):
14 def maxima_temp(trs):
14 np_array = [np.array(i) for i in trs]
15 np_array = [np.array(i) for i in trs]
15 temps = [max(i[i<40]) for i in np_array]
16 temps = [max(i[i<40]) for i in np_array]
16 return max(temps)
17 return max(temps)
17
18
18 def on_message(mqtt_client, userdata, msg):
19 def on_message(mqtt_client, userdata, msg):
19 print(f'Received message on topic: {msg.topic} with payload: {msg.payload}', flush=True)
20 # print(f'Received message on topic: {msg.topic} with payload: {msg.payload}', flush=True)
20 trsi = [[],[],[],[]]
21 trsi = [[],[],[],[]]
21 mensaje = str(msg.payload)
22 mensaje = str(msg.payload)
22 datos = [i for i in mensaje[21:-1].split("*")]
23 datos = [i for i in mensaje[21:-1].split("*")]
23 status=''.join([datos[i][3] for i in [0,1,2,3]])
24 status=''.join([datos[i][3] for i in range(3)])
24 for trs,i in zip(datos,[0,1,2,3]) :
25 for trs,i in zip(datos,[0,1,2,3]) :
25 trsi[i]= [int(i) for i in trs[1:-1].split(",")]
26 trsi[i]= [int(i) for i in trs[1:-1].split(",")]
26 potencias = [trsi[0][34],trsi[0][36],trsi[2][32],trsi[2][34]]
27 potencias = [trsi[0][34],trsi[0][36],trsi[2][32],trsi[2][34]]
27 tmax = maxima_temp(trsi)
28 tmax = maxima_temp(trsi)
28 sio.emit('test', data={'time':mensaje[2:21],'num':trsi[0][0],'pow':potencias,'tmax':str(tmax),'status':status})
29 sio.emit('test', data={'time':mensaje[2:21],'num':trsi[0][0],'pow':potencias,'tmax':str(tmax),'status':status})
29
30
30 client = mqtt.Client()
31 client = mqtt.Client()
31 client.on_connect = on_connect
32 client.on_connect = on_connect
32 client.on_message = on_message
33 client.on_message = on_message
33 client.username_pw_set(settings.MQTT_USER, settings.MQTT_PASSWORD)
34 client.username_pw_set(os.environ.get('MQTT_USER_ATRAD', 'atrad'), os.environ.get('MQTT_PASSWORD_ATRAD', 'atrad'))
34 client.connect(
35 client.connect(
35 host=settings.MQTT_SERVER,
36 host=os.environ.get('MQTT_SERVER', '0.0.0.0'),
36 port=settings.MQTT_PORT,
37 port=int(settings.os.environ.get('MQTT_PORT', 1883)),
37 keepalive=settings.MQTT_KEEPALIVE
38 keepalive=int(os.environ.get('MQTT_KEEPALIVE', 36000))
38 ) No newline at end of file
39 )
@@ -1,177 +1,177
1 """
1 """
2 Django settings for radarsys project.
2 Django settings for radarsys project.
3
3
4 Generated by 'django-admin startproject' using Django 1.8.6.
4 Generated by 'django-admin startproject' using Django 1.8.6.
5
5
6 For more information on this file, see
6 For more information on this file, see
7 https://docs.djangoproject.com/en/1.8/topics/settings/
7 https://docs.djangoproject.com/en/1.8/topics/settings/
8
8
9 For the full list of settings and their values, see
9 For the full list of settings and their values, see
10 https://docs.djangoproject.com/en/1.8/ref/settings/
10 https://docs.djangoproject.com/en/1.8/ref/settings/
11 """
11 """
12
12
13 # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
13 # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
14 import os
14 import os
15
15
16 BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
16 BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
17
17
18 # Quick-start development settings - unsuitable for production
18 # Quick-start development settings - unsuitable for production
19 # See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
19 # See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
20
20
21 # SECURITY WARNING: keep the secret key used in production secret!
21 # SECURITY WARNING: keep the secret key used in production secret!
22 SECRET_KEY = 'xshb$k5fc-+j16)cvyffj&9u__0q3$l!hieh#+tbzqg)*f^km0'
22 SECRET_KEY = 'xshb$k5fc-+j16)cvyffj&9u__0q3$l!hieh#+tbzqg)*f^km0'
23
23
24 # SECURITY WARNING: don't run with debug turned on in production!
24 # SECURITY WARNING: don't run with debug turned on in production!
25 DEBUG = True
25 DEBUG = True
26
26
27 ALLOWED_HOSTS = ['*']
27 ALLOWED_HOSTS = ['*']
28
28
29 CSRF_TRUSTED_ORIGINS=[
29 CSRF_TRUSTED_ORIGINS=[
30 "http://*.localhost:8030",
30 "http://*.localhost:8030",
31 "http://localhost:8030",
31 "http://localhost:8030",
32 "http://127.0.0.1:8030"
32 "http://127.0.0.1:8030"
33 ]
33 ]
34 #Si se requiere que la aplicación salga de este entorno, para otros usuarios es necesario hacer una API request https://fractalideas.com/blog/making-react-and-django-play-well-together-single-page-app-model/
34 #Si se requiere que la aplicación salga de este entorno, para otros usuarios es necesario hacer una API request https://fractalideas.com/blog/making-react-and-django-play-well-together-single-page-app-model/
35
35
36 # Application definition
36 # Application definition
37
37
38 INSTALLED_APPS = [
38 INSTALLED_APPS = [
39 'django.contrib.admin',
39 'django.contrib.admin',
40 'django.contrib.auth',
40 'django.contrib.auth',
41 'django.contrib.contenttypes',
41 'django.contrib.contenttypes',
42 'django.contrib.sessions',
42 'django.contrib.sessions',
43 'django.contrib.messages',
43 'django.contrib.messages',
44 'django.contrib.staticfiles',
44 'django.contrib.staticfiles',
45 'apps.accounts',
45 'apps.accounts',
46 'apps.main',
46 'apps.main',
47 'apps.misc',
47 'apps.misc',
48 'apps.rc',
48 'apps.rc',
49 'apps.dds',
49 'apps.dds',
50 'apps.jars',
50 'apps.jars',
51 'apps.usrp',
51 'apps.usrp',
52 'apps.abs',
52 'apps.abs',
53 'apps.cgs',
53 'apps.cgs',
54 'apps.dds_rest',
54 'apps.dds_rest',
55 'apps.atrad',
55 'apps.atrad',
56 "django_bootstrap5",
56 "django_bootstrap5",
57 'polymorphic',
57 'polymorphic',
58 'radarsys',
58 'radarsys',
59 ]
59 ]
60
60
61 MIDDLEWARE = [
61 MIDDLEWARE = [
62 'django.middleware.security.SecurityMiddleware',
62 'django.middleware.security.SecurityMiddleware',
63 'django.contrib.sessions.middleware.SessionMiddleware',
63 'django.contrib.sessions.middleware.SessionMiddleware',
64 'django.middleware.common.CommonMiddleware',
64 'django.middleware.common.CommonMiddleware',
65 'django.middleware.csrf.CsrfViewMiddleware',
65 'django.middleware.csrf.CsrfViewMiddleware',
66 'django.contrib.auth.middleware.AuthenticationMiddleware',
66 'django.contrib.auth.middleware.AuthenticationMiddleware',
67 'django.contrib.messages.middleware.MessageMiddleware',
67 'django.contrib.messages.middleware.MessageMiddleware',
68 'django.middleware.clickjacking.XFrameOptionsMiddleware',
68 'django.middleware.clickjacking.XFrameOptionsMiddleware',
69
69
70 ]
70 ]
71
71
72 ROOT_URLCONF = 'radarsys.urls'
72 ROOT_URLCONF = 'radarsys.urls'
73
73
74 TEMPLATES = [
74 TEMPLATES = [
75 {
75 {
76 'BACKEND': 'django.template.backends.django.DjangoTemplates',
76 'BACKEND': 'django.template.backends.django.DjangoTemplates',
77 'DIRS': [os.path.join(BASE_DIR, "templates")],
77 'DIRS': [os.path.join(BASE_DIR, "templates")],
78 'APP_DIRS': True,
78 'APP_DIRS': True,
79 'OPTIONS': {
79 'OPTIONS': {
80 'context_processors': [
80 'context_processors': [
81 'django.template.context_processors.debug',
81 'django.template.context_processors.debug',
82 'django.template.context_processors.request',
82 'django.template.context_processors.request',
83 'django.contrib.auth.context_processors.auth',
83 'django.contrib.auth.context_processors.auth',
84 'django.contrib.messages.context_processors.messages',
84 'django.contrib.messages.context_processors.messages',
85 'apps.main.processors.radarsys_globals',
85 'apps.main.processors.radarsys_globals',
86 ],
86 ],
87 },
87 },
88 },
88 },
89 ]
89 ]
90
90
91 WSGI_APPLICATION = 'radarsys.wsgi.application'
91 WSGI_APPLICATION = 'radarsys.wsgi.application'
92 ASGI_APPLICATION = 'radarsys.asgi.application'
92 ASGI_APPLICATION = 'radarsys.asgi.application'
93
93
94 # Database
94 # Database
95 # https://docs.djangoproject.com/en/1.8/ref/settings/#databases
95 # https://docs.djangoproject.com/en/1.8/ref/settings/#databases
96
96
97 DATABASES = {
97 DATABASES = {
98 # 'default': {
98 # 'default': {
99 # 'ENGINE': 'django.db.backends.sqlite3',
99 # 'ENGINE': 'django.db.backends.sqlite3',
100 # 'NAME': 'radarsys.sqlite',
100 # 'NAME': 'radarsys.sqlite',
101 # }
101 # }
102 'default': {
102 'default': {
103 'ENGINE': 'django.db.backends.postgresql_psycopg2',
103 'ENGINE': 'django.db.backends.postgresql_psycopg2',
104 'NAME': os.environ.get('DB_NAME', 'radarsys'),
104 'NAME': os.environ.get('DB_NAME', 'radarsys'),
105 'USER': os.environ.get('DB_USER', 'docker'),
105 'USER': os.environ.get('DB_USER', 'docker'),
106 'PASSWORD': os.environ.get('DB_PASSWORD', 'docker'),
106 'PASSWORD': os.environ.get('DB_PASSWORD', 'docker'),
107 'HOST': os.environ.get('POSTGRES_PORT_5432_TCP_ADDR', 'localhost'),
107 'HOST': os.environ.get('POSTGRES_PORT_5432_TCP_ADDR', 'localhost'),
108 'PORT': os.environ.get('POSTGRES_PORT_5432_TCP_PORT', '5432'),
108 'PORT': os.environ.get('POSTGRES_PORT_5432_TCP_PORT', '5432'),
109 }
109 }
110 }
110 }
111
111
112 # Internationalization
112 # Internationalization
113 # https://docs.djangoproject.com/en/1.8/topics/i18n/
113 # https://docs.djangoproject.com/en/1.8/topics/i18n/
114
114
115 LANGUAGE_CODE = 'en-us'
115 LANGUAGE_CODE = 'en-us'
116
116
117 USE_TZ = False #True
117 USE_TZ = False #True
118
118
119 TIME_ZONE = os.environ.get('TZ', 'America/Lima')
119 TIME_ZONE = os.environ.get('TZ', 'America/Lima')
120
120
121 USE_I18N = True
121 USE_I18N = True
122
122
123 USE_L10N = True
123 USE_L10N = True
124
124
125 # Static files (CSS, JavaScript, Images)
125 # Static files (CSS, JavaScript, Images)
126 # https://docs.djangoproject.com/en/1.8/howto/static-files/
126 # https://docs.djangoproject.com/en/1.8/howto/static-files/
127
127
128 MEDIA_URL = '/media/'
128 MEDIA_URL = '/media/'
129 MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
129 MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
130
130
131 STATICFILES_DIRS = [
131 STATICFILES_DIRS = [
132 os.path.join(BASE_DIR, 'radarsys/static/')
132 os.path.join(BASE_DIR, 'radarsys/static/')
133 ]
133 ]
134
134
135 STATIC_URL = '/static/'
135 STATIC_URL = '/static/'
136 STATIC_ROOT = os.path.join(BASE_DIR, 'static')
136 STATIC_ROOT = os.path.join(BASE_DIR, 'static')
137
137
138 LOGIN_URL = '/accounts/login'
138 LOGIN_URL = '/accounts/login'
139 LOGOUT_URL = 'logout'
139 LOGOUT_URL = 'logout'
140 LOGIN_REDIRECT_URL = '/admin'
140 LOGIN_REDIRECT_URL = '/admin'
141 LOGOUT_REDIRECT_URL = '/'
141 LOGOUT_REDIRECT_URL = '/'
142
142
143 STATICFILES_FINDERS = (
143 STATICFILES_FINDERS = (
144 'django.contrib.staticfiles.finders.FileSystemFinder',
144 'django.contrib.staticfiles.finders.FileSystemFinder',
145 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
145 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
146 )
146 )
147
147
148 # # Celery stuff
148 # # Celery stuff
149
149
150 # REDIS_HOST = os.environ.get('REDIS_HOST', 'localhost')
150 # REDIS_HOST = os.environ.get('REDIS_HOST', 'localhost')
151 # #REDIS_HOST = os.environ.get('REDIS_HOST', '127.0.0.1')
151 # #REDIS_HOST = os.environ.get('REDIS_HOST', '127.0.0.1')
152 # REDIS_PORT = os.environ.get('REDIS_PORT', 6379)
152 # REDIS_PORT = os.environ.get('REDIS_PORT', 6379)
153
153
154 # BROKER_TRANSPORT = 'redis'
154 # BROKER_TRANSPORT = 'redis'
155 # #BROKER_URL = 'redis://{}:{}/0'.format(REDIS_HOST, REDIS_PORT)
155 # #BROKER_URL = 'redis://{}:{}/0'.format(REDIS_HOST, REDIS_PORT)
156 # BROKER_URL = 'redis://{}:{}'.format(REDIS_HOST, REDIS_PORT)
156 # BROKER_URL = 'redis://{}:{}'.format(REDIS_HOST, REDIS_PORT)
157
157
158 # CELERY_RESULT_BACKEND = 'redis://{}:{}/0'.format(REDIS_HOST, REDIS_PORT)
158 # CELERY_RESULT_BACKEND = 'redis://{}:{}/0'.format(REDIS_HOST, REDIS_PORT)
159 # CELERY_BROKER_TRANSPORT = BROKER_URL
159 # CELERY_BROKER_TRANSPORT = BROKER_URL
160 # CELERY_ACCEPT_CONTENT = ['application/json']
160 # CELERY_ACCEPT_CONTENT = ['application/json']
161 # CELERY_TASK_SERIALIZER = 'json'
161 # CELERY_TASK_SERIALIZER = 'json'
162 # CELERY_RESULT_SERIALIZER = 'json'
162 # CELERY_RESULT_SERIALIZER = 'json'
163 # CELERY_ENABLE_UTC = False
163 # CELERY_ENABLE_UTC = False
164 # CELERY_TIMEZONE = 'America/Lima'
164 # CELERY_TIMEZONE = 'America/Lima'
165
165
166 import django
166 import django
167 from django.utils.encoding import force_str
167 from django.utils.encoding import force_str
168 django.utils.encoding.force_text = force_str
168 django.utils.encoding.force_text = force_str
169
169
170 # choose of auto-created primary keys
170 # choose of auto-created primary keys
171 DEFAULT_AUTO_FIELD='django.db.models.AutoField'
171 DEFAULT_AUTO_FIELD='django.db.models.AutoField'
172
172
173 MQTT_SERVER = '10.10.10.99'
173 MQTT_SERVER = '10.10.10.200'
174 MQTT_PORT = 1883
174 MQTT_PORT = 1883
175 MQTT_KEEPALIVE = 60
175 MQTT_KEEPALIVE = 60
176 MQTT_USER = ''
176 MQTT_USER = ''
177 MQTT_PASSWORD = '' No newline at end of file
177 MQTT_PASSWORD = ''
General Comments 0
You need to be logged in to leave comments. Login now