|
@@
-1,1140
+1,1189
|
|
1
|
from django.db import models
|
|
1
|
from django.db import models
|
|
2
|
from apps.main.models import Configuration
|
|
2
|
from apps.main.models import Configuration
|
|
3
|
from django.core.urlresolvers import reverse
|
|
3
|
from django.core.urlresolvers import reverse
|
|
4
|
# Create your models here.
|
|
4
|
# Create your models here.
|
|
5
|
from celery.execute import send_task
|
|
5
|
from celery.execute import send_task
|
|
6
|
from datetime import datetime
|
|
6
|
from datetime import datetime
|
|
7
|
import ast
|
|
7
|
import ast
|
|
8
|
import socket
|
|
8
|
import socket
|
|
9
|
import json
|
|
9
|
import json
|
|
10
|
import requests
|
|
10
|
import requests
|
|
11
|
import struct
|
|
11
|
import struct
|
|
12
|
import sys, time
|
|
12
|
import sys, time
|
|
13
|
|
|
13
|
|
|
14
|
import multiprocessing
|
|
14
|
import multiprocessing
|
|
15
|
|
|
15
|
|
|
16
|
|
|
16
|
|
|
17
|
antenna_default = json.dumps({
|
|
17
|
antenna_default = json.dumps({
|
|
18
|
"antenna_up": [[0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
|
|
18
|
"antenna_up": [[0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
|
|
19
|
[0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
|
|
19
|
[0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
|
|
20
|
[0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
|
|
20
|
[0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
|
|
21
|
[0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
|
|
21
|
[0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
|
|
22
|
[0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0],
|
|
22
|
[0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0],
|
|
23
|
[0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0],
|
|
23
|
[0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0],
|
|
24
|
[0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0],
|
|
24
|
[0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0],
|
|
25
|
[0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0]
|
|
25
|
[0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0]
|
|
26
|
]
|
|
26
|
]
|
|
27
|
,
|
|
27
|
,
|
|
28
|
"antenna_down": [[0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
|
|
28
|
"antenna_down": [[0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
|
|
29
|
[0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
|
|
29
|
[0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
|
|
30
|
[0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
|
|
30
|
[0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
|
|
31
|
[0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
|
|
31
|
[0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
|
|
32
|
[0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0],
|
|
32
|
[0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0],
|
|
33
|
[0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0],
|
|
33
|
[0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0],
|
|
34
|
[0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0],
|
|
34
|
[0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0],
|
|
35
|
[0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0]],
|
|
35
|
[0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0]],
|
|
36
|
})
|
|
36
|
})
|
|
37
|
|
|
37
|
|
|
38
|
|
|
38
|
|
|
39
|
tx_default = json.dumps({
|
|
39
|
tx_default = json.dumps({
|
|
40
|
"up": [[1,1,1,1,0,0,0,0],
|
|
40
|
"up": [[1,1,1,1,0,0,0,0],
|
|
41
|
[1,1,1,1,0,0,0,0],
|
|
41
|
[1,1,1,1,0,0,0,0],
|
|
42
|
[1,1,1,1,0,0,0,0],
|
|
42
|
[1,1,1,1,0,0,0,0],
|
|
43
|
[1,1,1,1,0,0,0,0],
|
|
43
|
[1,1,1,1,0,0,0,0],
|
|
44
|
[0,0,0,0,1,1,1,1],
|
|
44
|
[0,0,0,0,1,1,1,1],
|
|
45
|
[0,0,0,0,1,1,1,1],
|
|
45
|
[0,0,0,0,1,1,1,1],
|
|
46
|
[0,0,0,0,1,1,1,1],
|
|
46
|
[0,0,0,0,1,1,1,1],
|
|
47
|
[0,0,0,0,1,1,1,1]],
|
|
47
|
[0,0,0,0,1,1,1,1]],
|
|
48
|
|
|
48
|
|
|
49
|
"down": [[1,1,1,1,0,0,0,0],
|
|
49
|
"down": [[1,1,1,1,0,0,0,0],
|
|
50
|
[1,1,1,1,0,0,0,0],
|
|
50
|
[1,1,1,1,0,0,0,0],
|
|
51
|
[1,1,1,1,0,0,0,0],
|
|
51
|
[1,1,1,1,0,0,0,0],
|
|
52
|
[1,1,1,1,0,0,0,0],
|
|
52
|
[1,1,1,1,0,0,0,0],
|
|
53
|
[0,0,0,0,1,1,1,1],
|
|
53
|
[0,0,0,0,1,1,1,1],
|
|
54
|
[0,0,0,0,1,1,1,1],
|
|
54
|
[0,0,0,0,1,1,1,1],
|
|
55
|
[0,0,0,0,1,1,1,1],
|
|
55
|
[0,0,0,0,1,1,1,1],
|
|
56
|
[0,0,0,0,1,1,1,1]],
|
|
56
|
[0,0,0,0,1,1,1,1]],
|
|
57
|
})
|
|
57
|
})
|
|
58
|
|
|
58
|
|
|
59
|
rx_default = json.dumps({
|
|
59
|
rx_default = json.dumps({
|
|
60
|
"up": [[1,1,1,1,0,0,0,0],
|
|
60
|
"up": [[1,1,1,1,0,0,0,0],
|
|
61
|
[1,1,1,1,0,0,0,0],
|
|
61
|
[1,1,1,1,0,0,0,0],
|
|
62
|
[1,1,1,1,0,0,0,0],
|
|
62
|
[1,1,1,1,0,0,0,0],
|
|
63
|
[1,1,1,1,0,0,0,0],
|
|
63
|
[1,1,1,1,0,0,0,0],
|
|
64
|
[0,0,0,0,1,1,1,1],
|
|
64
|
[0,0,0,0,1,1,1,1],
|
|
65
|
[0,0,0,0,1,1,1,1],
|
|
65
|
[0,0,0,0,1,1,1,1],
|
|
66
|
[0,0,0,0,1,1,1,1],
|
|
66
|
[0,0,0,0,1,1,1,1],
|
|
67
|
[0,0,0,0,1,1,1,1]],
|
|
67
|
[0,0,0,0,1,1,1,1]],
|
|
68
|
|
|
68
|
|
|
69
|
"down": [[1,1,1,1,0,0,0,0],
|
|
69
|
"down": [[1,1,1,1,0,0,0,0],
|
|
70
|
[1,1,1,1,0,0,0,0],
|
|
70
|
[1,1,1,1,0,0,0,0],
|
|
71
|
[1,1,1,1,0,0,0,0],
|
|
71
|
[1,1,1,1,0,0,0,0],
|
|
72
|
[1,1,1,1,0,0,0,0],
|
|
72
|
[1,1,1,1,0,0,0,0],
|
|
73
|
[0,0,0,0,1,1,1,1],
|
|
73
|
[0,0,0,0,1,1,1,1],
|
|
74
|
[0,0,0,0,1,1,1,1],
|
|
74
|
[0,0,0,0,1,1,1,1],
|
|
75
|
[0,0,0,0,1,1,1,1],
|
|
75
|
[0,0,0,0,1,1,1,1],
|
|
76
|
[0,0,0,0,1,1,1,1]],
|
|
76
|
[0,0,0,0,1,1,1,1]],
|
|
77
|
})
|
|
77
|
})
|
|
78
|
|
|
78
|
|
|
79
|
conf_default = {}
|
|
79
|
conf_default = {}
|
|
80
|
status_default = {}
|
|
80
|
status_default = {}
|
|
81
|
default_messages = {}
|
|
81
|
default_messages = {}
|
|
82
|
for i in range(1,65):
|
|
82
|
for i in range(1,65):
|
|
83
|
conf_default[str(i)] = ""
|
|
83
|
conf_default[str(i)] = ""
|
|
84
|
status_default[str(i)] = 0
|
|
84
|
status_default[str(i)] = 0
|
|
85
|
default_messages[str(i)] = "Module "+str(i)
|
|
85
|
default_messages[str(i)] = "Module "+str(i)
|
|
86
|
|
|
86
|
|
|
87
|
|
|
87
|
|
|
88
|
ues_default = json.dumps({
|
|
88
|
ues_default = json.dumps({
|
|
89
|
"up": [0.533333,0.00000,1.06667,0.00000],
|
|
89
|
"up": [0.533333,0.00000,1.06667,0.00000],
|
|
90
|
"down": [0.533333,0.00000,1.06667,0.00000]
|
|
90
|
"down": [0.533333,0.00000,1.06667,0.00000]
|
|
91
|
})
|
|
91
|
})
|
|
92
|
|
|
92
|
|
|
93
|
onlyrx_default = json.dumps({
|
|
93
|
onlyrx_default = json.dumps({
|
|
94
|
"up": False,
|
|
94
|
"up": False,
|
|
95
|
"down": False
|
|
95
|
"down": False
|
|
96
|
})
|
|
96
|
})
|
|
97
|
|
|
97
|
|
|
98
|
def up_convertion(cadena):
|
|
98
|
def up_convertion(cadena):
|
|
99
|
valores = []
|
|
99
|
valores = []
|
|
100
|
for c in cadena:
|
|
100
|
for c in cadena:
|
|
101
|
if c == 1.0: valores=valores+['000']
|
|
101
|
if c == 1.0: valores=valores+['000']
|
|
102
|
if c == 2.0: valores=valores+['001']
|
|
102
|
if c == 2.0: valores=valores+['001']
|
|
103
|
if c == 3.0: valores=valores+['010']
|
|
103
|
if c == 3.0: valores=valores+['010']
|
|
104
|
if c == 0.0: valores=valores+['011']
|
|
104
|
if c == 0.0: valores=valores+['011']
|
|
105
|
if c == 0.5: valores=valores+['100']
|
|
105
|
if c == 0.5: valores=valores+['100']
|
|
106
|
if c == 1.5: valores=valores+['101']
|
|
106
|
if c == 1.5: valores=valores+['101']
|
|
107
|
if c == 2.5: valores=valores+['110']
|
|
107
|
if c == 2.5: valores=valores+['110']
|
|
108
|
if c == 3.5: valores=valores+['111']
|
|
108
|
if c == 3.5: valores=valores+['111']
|
|
109
|
|
|
109
|
|
|
110
|
return valores
|
|
110
|
return valores
|
|
111
|
|
|
111
|
|
|
112
|
def up_conv_bits(value):
|
|
112
|
def up_conv_bits(value):
|
|
113
|
|
|
113
|
|
|
114
|
if value == 1.0: bits="000"
|
|
114
|
if value == 1.0: bits="000"
|
|
115
|
if value == 2.0: bits="001"
|
|
115
|
if value == 2.0: bits="001"
|
|
116
|
if value == 3.0: bits="010"
|
|
116
|
if value == 3.0: bits="010"
|
|
117
|
if value == 0.0: bits="011"
|
|
117
|
if value == 0.0: bits="011"
|
|
118
|
if value == 0.5: bits="100"
|
|
118
|
if value == 0.5: bits="100"
|
|
119
|
if value == 1.5: bits="101"
|
|
119
|
if value == 1.5: bits="101"
|
|
120
|
if value == 2.5: bits="110"
|
|
120
|
if value == 2.5: bits="110"
|
|
121
|
if value == 3.5: bits="111"
|
|
121
|
if value == 3.5: bits="111"
|
|
122
|
|
|
122
|
|
|
123
|
return bits
|
|
123
|
return bits
|
|
124
|
|
|
124
|
|
|
125
|
def down_convertion(cadena):
|
|
125
|
def down_convertion(cadena):
|
|
126
|
valores = []
|
|
126
|
valores = []
|
|
127
|
for c in cadena:
|
|
127
|
for c in cadena:
|
|
128
|
if c == 1.0: valores=valores+['000']
|
|
128
|
if c == 1.0: valores=valores+['000']
|
|
129
|
if c == 2.0: valores=valores+['001']
|
|
129
|
if c == 2.0: valores=valores+['001']
|
|
130
|
if c == 3.0: valores=valores+['010']
|
|
130
|
if c == 3.0: valores=valores+['010']
|
|
131
|
if c == 0.0: valores=valores+['011']
|
|
131
|
if c == 0.0: valores=valores+['011']
|
|
132
|
if c == 0.5: valores=valores+['100']
|
|
132
|
if c == 0.5: valores=valores+['100']
|
|
133
|
if c == 1.5: valores=valores+['101']
|
|
133
|
if c == 1.5: valores=valores+['101']
|
|
134
|
if c == 2.5: valores=valores+['110']
|
|
134
|
if c == 2.5: valores=valores+['110']
|
|
135
|
if c == 3.5: valores=valores+['111']
|
|
135
|
if c == 3.5: valores=valores+['111']
|
|
136
|
|
|
136
|
|
|
137
|
return valores
|
|
137
|
return valores
|
|
138
|
|
|
138
|
|
|
139
|
def down_conv_bits(value):
|
|
139
|
def down_conv_bits(value):
|
|
140
|
|
|
140
|
|
|
141
|
if value == 1.0: bits="000"
|
|
141
|
if value == 1.0: bits="000"
|
|
142
|
if value == 2.0: bits="001"
|
|
142
|
if value == 2.0: bits="001"
|
|
143
|
if value == 3.0: bits="010"
|
|
143
|
if value == 3.0: bits="010"
|
|
144
|
if value == 0.0: bits="011"
|
|
144
|
if value == 0.0: bits="011"
|
|
145
|
if value == 0.5: bits="100"
|
|
145
|
if value == 0.5: bits="100"
|
|
146
|
if value == 1.5: bits="101"
|
|
146
|
if value == 1.5: bits="101"
|
|
147
|
if value == 2.5: bits="110"
|
|
147
|
if value == 2.5: bits="110"
|
|
148
|
if value == 3.5: bits="111"
|
|
148
|
if value == 3.5: bits="111"
|
|
149
|
|
|
149
|
|
|
150
|
return bits
|
|
150
|
return bits
|
|
151
|
|
|
151
|
|
|
|
|
|
152
|
def up_conv_value(bits):
|
|
|
|
|
153
|
|
|
|
|
|
154
|
if bits == "000": value=1.0
|
|
|
|
|
155
|
if bits == "001": value=2.0
|
|
|
|
|
156
|
if bits == "010": value=3.0
|
|
|
|
|
157
|
if bits == "011": value=0.0
|
|
|
|
|
158
|
if bits == "100": value=0.5
|
|
|
|
|
159
|
if bits == "101": value=1.5
|
|
|
|
|
160
|
if bits == "110": value=2.5
|
|
|
|
|
161
|
if bits == "111": value=3.5
|
|
|
|
|
162
|
|
|
|
|
|
163
|
return value
|
|
|
|
|
164
|
|
|
|
|
|
165
|
def down_conv_value(bits):
|
|
|
|
|
166
|
|
|
|
|
|
167
|
if bits == "000": value=1.0
|
|
|
|
|
168
|
if bits == "001": value=2.0
|
|
|
|
|
169
|
if bits == "010": value=3.0
|
|
|
|
|
170
|
if bits == "011": value=0.0
|
|
|
|
|
171
|
if bits == "100": value=0.5
|
|
|
|
|
172
|
if bits == "101": value=1.5
|
|
|
|
|
173
|
if bits == "110": value=2.5
|
|
|
|
|
174
|
if bits == "111": value=3.5
|
|
|
|
|
175
|
|
|
|
|
|
176
|
return value
|
|
|
|
|
177
|
|
|
152
|
def ip2position(module_number):
|
|
178
|
def ip2position(module_number):
|
|
153
|
j=0
|
|
179
|
j=0
|
|
154
|
i=0
|
|
180
|
i=0
|
|
155
|
for x in range(0,module_number-1):
|
|
181
|
for x in range(0,module_number-1):
|
|
156
|
j=j+1
|
|
182
|
j=j+1
|
|
157
|
if j==8:
|
|
183
|
if j==8:
|
|
158
|
i=i+1
|
|
184
|
i=i+1
|
|
159
|
j=0
|
|
185
|
j=0
|
|
160
|
|
|
186
|
|
|
161
|
pos = [i,j]
|
|
187
|
pos = [i,j]
|
|
162
|
return pos
|
|
188
|
return pos
|
|
163
|
|
|
189
|
|
|
164
|
|
|
190
|
|
|
165
|
def fromBinary2Char(binary_string):
|
|
191
|
def fromBinary2Char(binary_string):
|
|
166
|
number = int(binary_string, 2)
|
|
192
|
number = int(binary_string, 2)
|
|
167
|
#Plus 33 to avoid more than 1 characters values such as: '\x01'-'\x1f'
|
|
193
|
#Plus 33 to avoid more than 1 characters values such as: '\x01'-'\x1f'
|
|
168
|
number = number + 33
|
|
194
|
number = number + 33
|
|
169
|
char = chr(number)
|
|
195
|
char = chr(number)
|
|
170
|
return char
|
|
196
|
return char
|
|
171
|
|
|
197
|
|
|
172
|
def fromChar2Binary(char):
|
|
198
|
def fromChar2Binary(char):
|
|
173
|
number = ord(char) - 33
|
|
199
|
number = ord(char) - 33
|
|
174
|
#Minus 33 to get the real value
|
|
200
|
#Minus 33 to get the real value
|
|
175
|
bits = bin(number)[2:]
|
|
201
|
bits = bin(number)[2:]
|
|
176
|
#To ensure we have a string with 6bits
|
|
202
|
#To ensure we have a string with 6bits
|
|
177
|
if len(bits) < 6:
|
|
203
|
if len(bits) < 6:
|
|
178
|
bits = bits.zfill(6)
|
|
204
|
bits = bits.zfill(6)
|
|
179
|
return bits
|
|
205
|
return bits
|
|
180
|
|
|
206
|
|
|
181
|
OPERATION_MODES = (
|
|
207
|
OPERATION_MODES = (
|
|
182
|
(0, 'Manual'),
|
|
208
|
(0, 'Manual'),
|
|
183
|
(1, 'Automatic'),
|
|
209
|
(1, 'Automatic'),
|
|
184
|
)
|
|
210
|
)
|
|
185
|
|
|
211
|
|
|
186
|
|
|
212
|
|
|
187
|
class ABSConfiguration(Configuration):
|
|
213
|
class ABSConfiguration(Configuration):
|
|
188
|
active_beam = models.CharField(verbose_name='Active Beam', max_length=20000, default="{}")
|
|
214
|
active_beam = models.CharField(verbose_name='Active Beam', max_length=20000, default="{}")
|
|
189
|
module_status = models.CharField(verbose_name='Module Status', max_length=10000, default=json.dumps(status_default))
|
|
215
|
module_status = models.CharField(verbose_name='Module Status', max_length=10000, default=json.dumps(status_default))
|
|
190
|
operation_mode = models.PositiveSmallIntegerField(verbose_name='Operation Mode', choices=OPERATION_MODES, default = 0)
|
|
216
|
operation_mode = models.PositiveSmallIntegerField(verbose_name='Operation Mode', choices=OPERATION_MODES, default = 0)
|
|
191
|
operation_value = models.FloatField(verbose_name='Periodic (seconds)', default="10", null=True, blank=True)
|
|
217
|
operation_value = models.FloatField(verbose_name='Periodic (seconds)', default="10", null=True, blank=True)
|
|
192
|
module_messages = models.CharField(verbose_name='Modules Messages', max_length=10000, default=json.dumps(default_messages))
|
|
218
|
module_messages = models.CharField(verbose_name='Modules Messages', max_length=10000, default=json.dumps(default_messages))
|
|
193
|
|
|
219
|
|
|
194
|
class Meta:
|
|
220
|
class Meta:
|
|
195
|
db_table = 'abs_configurations'
|
|
221
|
db_table = 'abs_configurations'
|
|
196
|
|
|
222
|
|
|
197
|
def get_absolute_url_plot(self):
|
|
223
|
def get_absolute_url_plot(self):
|
|
198
|
return reverse('url_plot_abs_patterns', args=[str(self.id)])
|
|
224
|
return reverse('url_plot_abs_patterns', args=[str(self.id)])
|
|
199
|
|
|
225
|
|
|
200
|
|
|
226
|
|
|
201
|
def parms_to_dict(self):
|
|
227
|
def parms_to_dict(self):
|
|
202
|
|
|
228
|
|
|
203
|
parameters = {}
|
|
229
|
parameters = {}
|
|
204
|
|
|
230
|
|
|
205
|
parameters['device_id'] = self.device.id
|
|
231
|
parameters['device_id'] = self.device.id
|
|
206
|
parameters['name'] = self.name
|
|
232
|
parameters['name'] = self.name
|
|
207
|
parameters['beams'] = {}
|
|
233
|
parameters['beams'] = {}
|
|
208
|
|
|
234
|
|
|
209
|
beams = ABSBeam.objects.filter(abs_conf=self)
|
|
235
|
beams = ABSBeam.objects.filter(abs_conf=self)
|
|
210
|
b=1
|
|
236
|
b=1
|
|
211
|
for beam in beams:
|
|
237
|
for beam in beams:
|
|
212
|
#absbeam = ABSBeam.objects.get(pk=beams[beam])
|
|
238
|
#absbeam = ABSBeam.objects.get(pk=beams[beam])
|
|
213
|
parameters['beams']['beam'+str(b)] = beam.parms_to_dict()#absbeam.parms_to_dict()
|
|
239
|
parameters['beams']['beam'+str(b)] = beam.parms_to_dict()#absbeam.parms_to_dict()
|
|
214
|
b+=1
|
|
240
|
b+=1
|
|
215
|
|
|
241
|
|
|
216
|
return parameters
|
|
242
|
return parameters
|
|
217
|
|
|
243
|
|
|
218
|
def dict_to_parms(self, parameters):
|
|
244
|
def dict_to_parms(self, parameters):
|
|
219
|
|
|
245
|
|
|
220
|
self.name = parameters['name']
|
|
246
|
self.name = parameters['name']
|
|
221
|
|
|
247
|
|
|
222
|
absbeams = ABSBeam.objects.filter(abs_conf=self)
|
|
248
|
absbeams = ABSBeam.objects.filter(abs_conf=self)
|
|
223
|
beams = parameters['beams']
|
|
249
|
beams = parameters['beams']
|
|
224
|
|
|
250
|
|
|
225
|
if absbeams:
|
|
251
|
if absbeams:
|
|
226
|
beams_number = len(beams)
|
|
252
|
beams_number = len(beams)
|
|
227
|
absbeams_number = len(absbeams)
|
|
253
|
absbeams_number = len(absbeams)
|
|
228
|
if beams_number==absbeams_number:
|
|
254
|
if beams_number==absbeams_number:
|
|
229
|
i = 1
|
|
255
|
i = 1
|
|
230
|
for absbeam in absbeams:
|
|
256
|
for absbeam in absbeams:
|
|
231
|
absbeam.dict_to_parms(beams['beam'+str(i)])
|
|
257
|
absbeam.dict_to_parms(beams['beam'+str(i)])
|
|
232
|
i = i+1
|
|
258
|
i = i+1
|
|
233
|
elif beams_number > absbeams_number:
|
|
259
|
elif beams_number > absbeams_number:
|
|
234
|
i = 1
|
|
260
|
i = 1
|
|
235
|
for absbeam in absbeams:
|
|
261
|
for absbeam in absbeams:
|
|
236
|
absbeam.dict_to_parms(beams['beam'+str(i)])
|
|
262
|
absbeam.dict_to_parms(beams['beam'+str(i)])
|
|
237
|
i=i+1
|
|
263
|
i=i+1
|
|
238
|
for x in range(i,beams_number+1):
|
|
264
|
for x in range(i,beams_number+1):
|
|
239
|
new_beam = ABSBeam(
|
|
265
|
new_beam = ABSBeam(
|
|
240
|
name =beams['beam'+str(i)]['name'],
|
|
266
|
name =beams['beam'+str(i)]['name'],
|
|
241
|
antenna =json.dumps(beams['beam'+str(i)]['antenna']),
|
|
267
|
antenna =json.dumps(beams['beam'+str(i)]['antenna']),
|
|
242
|
abs_conf = self,
|
|
268
|
abs_conf = self,
|
|
243
|
tx =json.dumps(beams['beam'+str(i)]['tx']),
|
|
269
|
tx =json.dumps(beams['beam'+str(i)]['tx']),
|
|
244
|
rx =json.dumps(beams['beam'+str(i)]['rx']),
|
|
270
|
rx =json.dumps(beams['beam'+str(i)]['rx']),
|
|
245
|
ues =json.dumps(beams['beam'+str(i)]['ues']),
|
|
271
|
ues =json.dumps(beams['beam'+str(i)]['ues']),
|
|
246
|
only_rx =json.dumps(beams['beam'+str(i)]['only_rx'])
|
|
272
|
only_rx =json.dumps(beams['beam'+str(i)]['only_rx'])
|
|
247
|
)
|
|
273
|
)
|
|
248
|
new_beam.save()
|
|
274
|
new_beam.save()
|
|
249
|
i=i+1
|
|
275
|
i=i+1
|
|
250
|
else: #beams_number < absbeams_number:
|
|
276
|
else: #beams_number < absbeams_number:
|
|
251
|
i = 1
|
|
277
|
i = 1
|
|
252
|
for absbeam in absbeams:
|
|
278
|
for absbeam in absbeams:
|
|
253
|
if i <= beams_number:
|
|
279
|
if i <= beams_number:
|
|
254
|
absbeam.dict_to_parms(beams['beam'+str(i)])
|
|
280
|
absbeam.dict_to_parms(beams['beam'+str(i)])
|
|
255
|
i=i+1
|
|
281
|
i=i+1
|
|
256
|
else:
|
|
282
|
else:
|
|
257
|
absbeam.delete()
|
|
283
|
absbeam.delete()
|
|
258
|
else:
|
|
284
|
else:
|
|
259
|
for beam in beams:
|
|
285
|
for beam in beams:
|
|
260
|
new_beam = ABSBeam(
|
|
286
|
new_beam = ABSBeam(
|
|
261
|
name =beams[beam]['name'],
|
|
287
|
name =beams[beam]['name'],
|
|
262
|
antenna =json.dumps(beams[beam]['antenna']),
|
|
288
|
antenna =json.dumps(beams[beam]['antenna']),
|
|
263
|
abs_conf = self,
|
|
289
|
abs_conf = self,
|
|
264
|
tx =json.dumps(beams[beam]['tx']),
|
|
290
|
tx =json.dumps(beams[beam]['tx']),
|
|
265
|
rx =json.dumps(beams[beam]['rx']),
|
|
291
|
rx =json.dumps(beams[beam]['rx']),
|
|
266
|
ues =json.dumps(beams[beam]['ues']),
|
|
292
|
ues =json.dumps(beams[beam]['ues']),
|
|
267
|
only_rx =json.dumps(beams[beam]['only_rx'])
|
|
293
|
only_rx =json.dumps(beams[beam]['only_rx'])
|
|
268
|
)
|
|
294
|
)
|
|
269
|
new_beam.save()
|
|
295
|
new_beam.save()
|
|
270
|
|
|
296
|
|
|
271
|
|
|
297
|
|
|
272
|
|
|
298
|
|
|
273
|
def update_from_file(self, parameters):
|
|
299
|
def update_from_file(self, parameters):
|
|
274
|
|
|
300
|
|
|
275
|
self.dict_to_parms(parameters)
|
|
301
|
self.dict_to_parms(parameters)
|
|
276
|
self.save()
|
|
302
|
self.save()
|
|
277
|
|
|
303
|
|
|
278
|
|
|
304
|
|
|
279
|
def get_beams(self, **kwargs):
|
|
305
|
def get_beams(self, **kwargs):
|
|
280
|
'''
|
|
306
|
'''
|
|
281
|
This function returns ABS Configuration beams
|
|
307
|
This function returns ABS Configuration beams
|
|
282
|
'''
|
|
308
|
'''
|
|
283
|
return ABSBeam.objects.filter(abs_conf=self.pk, **kwargs)
|
|
309
|
return ABSBeam.objects.filter(abs_conf=self.pk, **kwargs)
|
|
284
|
|
|
310
|
|
|
285
|
def clone(self, **kwargs):
|
|
311
|
def clone(self, **kwargs):
|
|
286
|
|
|
312
|
|
|
287
|
beams = self.get_beams()
|
|
313
|
beams = self.get_beams()
|
|
288
|
self.pk = None
|
|
314
|
self.pk = None
|
|
289
|
self.id = None
|
|
315
|
self.id = None
|
|
290
|
for attr, value in kwargs.items():
|
|
316
|
for attr, value in kwargs.items():
|
|
291
|
setattr(self, attr, value)
|
|
317
|
setattr(self, attr, value)
|
|
292
|
self.save()
|
|
318
|
self.save()
|
|
293
|
|
|
319
|
|
|
294
|
for beam in beams:
|
|
320
|
for beam in beams:
|
|
295
|
beam.clone(abs_conf=self)
|
|
321
|
beam.clone(abs_conf=self)
|
|
296
|
|
|
322
|
|
|
297
|
#-----For Active Beam-----
|
|
323
|
#-----For Active Beam-----
|
|
298
|
active_beam = json.loads(self.active_beam)
|
|
324
|
active_beam = json.loads(self.active_beam)
|
|
299
|
new_beams = ABSBeam.objects.filter(abs_conf=self)
|
|
325
|
new_beams = ABSBeam.objects.filter(abs_conf=self)
|
|
300
|
active_beam['active_beam'] = new_beams[0].id
|
|
326
|
active_beam['active_beam'] = new_beams[0].id
|
|
301
|
|
|
327
|
|
|
302
|
self.active_beam = json.dumps(active_beam)
|
|
328
|
self.active_beam = json.dumps(active_beam)
|
|
303
|
self.save()
|
|
329
|
self.save()
|
|
304
|
#-----For Active Beam-----
|
|
330
|
#-----For Active Beam-----
|
|
305
|
#-----For Device Status---
|
|
331
|
#-----For Device Status---
|
|
306
|
self.device.status = 3
|
|
332
|
self.device.status = 3
|
|
307
|
self.device.save()
|
|
333
|
self.device.save()
|
|
308
|
#-----For Device Status---
|
|
334
|
#-----For Device Status---
|
|
309
|
|
|
335
|
|
|
310
|
return self
|
|
336
|
return self
|
|
311
|
|
|
337
|
|
|
312
|
|
|
338
|
|
|
313
|
def start_device(self):
|
|
339
|
def start_device(self):
|
|
314
|
|
|
340
|
|
|
315
|
if self.device.status == 3:
|
|
341
|
if self.device.status == 3:
|
|
316
|
|
|
342
|
|
|
317
|
try:
|
|
343
|
try:
|
|
318
|
#self.write_device()
|
|
344
|
#self.write_device()
|
|
319
|
send_task('task_change_beam', [self.id],)
|
|
345
|
send_task('task_change_beam', [self.id],)
|
|
320
|
self.message = 'ABS running'
|
|
346
|
self.message = 'ABS running'
|
|
321
|
|
|
347
|
|
|
322
|
except Exception as e:
|
|
348
|
except Exception as e:
|
|
323
|
self.message = str(e)
|
|
349
|
self.message = str(e)
|
|
324
|
return False
|
|
350
|
return False
|
|
325
|
|
|
351
|
|
|
326
|
return True
|
|
352
|
return True
|
|
327
|
|
|
353
|
|
|
328
|
else:
|
|
354
|
else:
|
|
329
|
self.message = 'Please, select Write ABS Device first.'
|
|
355
|
self.message = 'Please, select Write ABS Device first.'
|
|
330
|
return False
|
|
356
|
return False
|
|
331
|
|
|
357
|
|
|
332
|
|
|
358
|
|
|
333
|
def stop_device(self):
|
|
359
|
def stop_device(self):
|
|
334
|
|
|
360
|
|
|
335
|
self.device.status = 2
|
|
361
|
self.device.status = 2
|
|
336
|
self.device.save()
|
|
362
|
self.device.save()
|
|
337
|
self.message = 'ABS has been stopped.'
|
|
363
|
self.message = 'ABS has been stopped.'
|
|
338
|
self.save()
|
|
364
|
self.save()
|
|
339
|
|
|
365
|
|
|
340
|
return True
|
|
366
|
return True
|
|
341
|
|
|
367
|
|
|
342
|
|
|
368
|
|
|
343
|
def module_conf(self, module_num, beams):
|
|
369
|
def module_conf(self, module_num, beams):
|
|
344
|
"""
|
|
370
|
"""
|
|
345
|
This function creates beam configurations for one abs module.
|
|
371
|
This function creates beam configurations for one abs module.
|
|
346
|
"""
|
|
372
|
"""
|
|
347
|
ip_address = self.device.ip_address
|
|
373
|
ip_address = self.device.ip_address
|
|
348
|
ip_address = ip_address.split('.')
|
|
374
|
ip_address = ip_address.split('.')
|
|
349
|
module_seq = (ip_address[0],ip_address[1],ip_address[2])
|
|
375
|
module_seq = (ip_address[0],ip_address[1],ip_address[2])
|
|
350
|
dot = '.'
|
|
376
|
dot = '.'
|
|
351
|
module_ip = dot.join(module_seq)+'.'+str(module_num)
|
|
377
|
module_ip = dot.join(module_seq)+'.'+str(module_num)
|
|
352
|
module_port = self.device.port_address
|
|
378
|
module_port = self.device.port_address
|
|
353
|
write_route = 'http://'+module_ip+':'+str(module_port)+'/write'
|
|
379
|
write_route = 'http://'+module_ip+':'+str(module_port)+'/write'
|
|
354
|
|
|
380
|
|
|
355
|
#header = 'JROABSCeCnModCnMod01000108SNDFexperimento1.ab1'
|
|
381
|
#header = 'JROABSCeCnModCnMod01000108SNDFexperimento1.ab1'
|
|
356
|
#module = 'ABS_'+str(module_num)
|
|
382
|
#module = 'ABS_'+str(module_num)
|
|
357
|
bs = '' #{}
|
|
383
|
bs = '' #{}
|
|
358
|
i=1
|
|
384
|
i=1
|
|
359
|
|
|
385
|
|
|
360
|
for beam in beams:
|
|
386
|
for beam in beams:
|
|
361
|
#bs[i] = fromBinary2Char(beam.module_6bits(module_num))
|
|
387
|
#bs[i] = fromBinary2Char(beam.module_6bits(module_num))
|
|
362
|
bs = bs + fromBinary2Char(beam.module_6bits(module_num))
|
|
388
|
bs = bs + fromBinary2Char(beam.module_6bits(module_num))
|
|
363
|
i=i+1
|
|
389
|
i=i+1
|
|
364
|
|
|
390
|
|
|
365
|
beams = bs
|
|
391
|
beams = bs
|
|
366
|
|
|
392
|
|
|
367
|
parameters = {}
|
|
393
|
parameters = {}
|
|
368
|
parameters['beams'] = beams #json.dumps(beams)
|
|
394
|
parameters['beams'] = beams #json.dumps(beams)
|
|
369
|
print parameters
|
|
395
|
print parameters
|
|
370
|
answer = ''
|
|
396
|
answer = ''
|
|
371
|
|
|
397
|
|
|
372
|
try:
|
|
398
|
try:
|
|
373
|
#r_write = requests.post(write_route, parameters, timeout=0.5)
|
|
399
|
#r_write = requests.post(write_route, parameters, timeout=0.5)
|
|
374
|
r_write = requests.post(write_route, json = parameters, timeout=0.5)
|
|
400
|
r_write = requests.post(write_route, json = parameters, timeout=0.5)
|
|
375
|
answer = r_write.json()
|
|
401
|
answer = r_write.json()
|
|
376
|
#self.message = answer['message']
|
|
402
|
#self.message = answer['message']
|
|
377
|
except:
|
|
403
|
except:
|
|
378
|
#self.message = "Could not write ABS parameters"
|
|
404
|
#self.message = "Could not write ABS parameters"
|
|
379
|
return False
|
|
405
|
return False
|
|
380
|
|
|
406
|
|
|
381
|
return answer
|
|
407
|
return answer
|
|
382
|
|
|
408
|
|
|
383
|
|
|
409
|
|
|
384
|
|
|
410
|
|
|
385
|
def write_device(self):
|
|
411
|
def write_device(self):
|
|
386
|
|
|
412
|
|
|
387
|
"""
|
|
413
|
"""
|
|
388
|
This function sends the beams list to every abs module.
|
|
414
|
This function sends the beams list to every abs module.
|
|
389
|
It needs 'module_conf' function
|
|
415
|
It needs 'module_conf' function
|
|
390
|
"""
|
|
416
|
"""
|
|
391
|
|
|
417
|
|
|
392
|
beams = ABSBeam.objects.filter(abs_conf=self)
|
|
418
|
beams = ABSBeam.objects.filter(abs_conf=self)
|
|
393
|
connected_modules = ast.literal_eval(self.module_status)
|
|
419
|
connected_modules = ast.literal_eval(self.module_status)
|
|
394
|
suma_connected_modules = 0
|
|
420
|
suma_connected_modules = 0
|
|
395
|
|
|
421
|
|
|
396
|
for c in connected_modules:
|
|
422
|
for c in connected_modules:
|
|
397
|
suma_connected_modules = suma_connected_modules+connected_modules[c]
|
|
423
|
suma_connected_modules = suma_connected_modules+connected_modules[c]
|
|
398
|
if not suma_connected_modules > 0 :
|
|
424
|
if not suma_connected_modules > 0 :
|
|
399
|
self.message = "No ABS Module detected."
|
|
425
|
self.message = "No ABS Module detected."
|
|
400
|
return False
|
|
426
|
return False
|
|
401
|
|
|
427
|
|
|
402
|
#-------------Write each abs module-----------
|
|
428
|
#-------------Write each abs module-----------
|
|
403
|
if beams:
|
|
429
|
if beams:
|
|
404
|
beams_status = ast.literal_eval(self.module_status)
|
|
430
|
beams_status = ast.literal_eval(self.module_status)
|
|
405
|
disconnected_modules = 0
|
|
431
|
disconnected_modules = 0
|
|
406
|
for i in range(1,65): #(62,65)
|
|
432
|
for i in range(1,65): #(62,65)
|
|
407
|
#--------------JUEVES-------------
|
|
433
|
#--------------JUEVES-------------
|
|
408
|
if beams_status[str(i)] != 0:
|
|
434
|
if beams_status[str(i)] != 0:
|
|
409
|
try:
|
|
435
|
try:
|
|
410
|
answer = self.module_conf(i,beams)
|
|
436
|
answer = self.module_conf(i,beams)
|
|
411
|
if answer:
|
|
437
|
if answer:
|
|
412
|
if answer['status']:
|
|
438
|
if answer['status']:
|
|
413
|
beams_status[str(i)] = 3
|
|
439
|
beams_status[str(i)] = 3
|
|
414
|
|
|
440
|
|
|
415
|
except:
|
|
441
|
except:
|
|
416
|
beams_status[str(i)] = 1
|
|
442
|
beams_status[str(i)] = 1
|
|
417
|
|
|
443
|
|
|
418
|
pass
|
|
444
|
pass
|
|
419
|
else:
|
|
445
|
else:
|
|
420
|
disconnected_modules += 1
|
|
446
|
disconnected_modules += 1
|
|
421
|
|
|
447
|
|
|
422
|
else:
|
|
448
|
else:
|
|
423
|
self.message = "ABS Configuration does not have beams"
|
|
449
|
self.message = "ABS Configuration does not have beams"
|
|
424
|
return False
|
|
450
|
return False
|
|
425
|
|
|
451
|
|
|
426
|
#self.device.status = 1
|
|
452
|
#self.device.status = 1
|
|
427
|
##
|
|
453
|
##
|
|
428
|
#-------------Jueves-------------
|
|
454
|
#-------------Jueves-------------
|
|
429
|
if disconnected_modules == 64:
|
|
455
|
if disconnected_modules == 64:
|
|
430
|
self.message = "Could not write ABS Modules"
|
|
456
|
self.message = "Could not write ABS Modules"
|
|
431
|
self.device.status = 0
|
|
457
|
self.device.status = 0
|
|
432
|
return False
|
|
458
|
return False
|
|
433
|
else:
|
|
459
|
else:
|
|
434
|
self.message = "ABS Beams List have been sent to ABS Modules"
|
|
460
|
self.message = "ABS Beams List have been sent to ABS Modules"
|
|
435
|
beams[0].set_as_activebeam()
|
|
461
|
beams[0].set_as_activebeam()
|
|
436
|
|
|
462
|
|
|
437
|
self.device.status = 3
|
|
463
|
self.device.status = 3
|
|
438
|
self.module_status = json.dumps(beams_status)
|
|
464
|
self.module_status = json.dumps(beams_status)
|
|
439
|
|
|
465
|
|
|
440
|
|
|
466
|
|
|
441
|
|
|
467
|
|
|
442
|
self.save()
|
|
468
|
self.save()
|
|
443
|
return True
|
|
469
|
return True
|
|
444
|
|
|
470
|
|
|
445
|
|
|
471
|
|
|
446
|
|
|
472
|
|
|
447
|
|
|
473
|
|
|
448
|
def read_module(self, module):
|
|
474
|
def read_module(self, module):
|
|
449
|
|
|
475
|
|
|
450
|
"""
|
|
476
|
"""
|
|
451
|
Read out-bits (up-down) of 1 abs module NOT for Configuration
|
|
477
|
Read out-bits (up-down) of 1 abs module NOT for Configuration
|
|
452
|
"""
|
|
478
|
"""
|
|
453
|
|
|
479
|
|
|
454
|
parameters = {}
|
|
|
|
|
455
|
ip_address = self.device.ip_address
|
|
480
|
ip_address = self.device.ip_address
|
|
456
|
ip_address = ip_address.split('.')
|
|
481
|
ip_address = ip_address.split('.')
|
|
457
|
module_seq = (ip_address[0],ip_address[1],ip_address[2])
|
|
482
|
module_seq = (ip_address[0],ip_address[1],ip_address[2])
|
|
458
|
dot = '.'
|
|
483
|
dot = '.'
|
|
459
|
module_ip = dot.join(module_seq)+'.'+str(module)
|
|
484
|
module_ip = dot.join(module_seq)+'.'+str(module)
|
|
460
|
module_port = self.device.port_address
|
|
485
|
module_port = self.device.port_address
|
|
461
|
read_route = 'http://'+module_ip+':'+str(module_port)+'/read'
|
|
486
|
read_route = 'http://'+module_ip+':'+str(module_port)+'/read'
|
|
462
|
|
|
487
|
|
|
|
|
|
488
|
module_status = json.loads(self.module_status)
|
|
463
|
print(read_route)
|
|
489
|
print(read_route)
|
|
464
|
|
|
490
|
|
|
465
|
answer = ''
|
|
|
|
|
466
|
module_bits = ''
|
|
491
|
module_bits = ''
|
|
467
|
|
|
492
|
|
|
468
|
try:
|
|
493
|
try:
|
|
469
|
r_write = requests.get(read_route, timeout=0.7)
|
|
494
|
r_read = requests.get(read_route, timeout=0.5)
|
|
470
|
answer = r_write.json()
|
|
495
|
answer = r_read.json()
|
|
471
|
self.message = answer['message']
|
|
496
|
module_bits = answer['allbits']
|
|
472
|
module_bits = answer['allbits']
|
|
|
|
|
473
|
except:
|
|
497
|
except:
|
|
474
|
#message = "Could not read ABS parameters"
|
|
498
|
return {}
|
|
475
|
answer = r_write.json()
|
|
|
|
|
476
|
return 0
|
|
|
|
|
477
|
|
|
499
|
|
|
478
|
return module_bits
|
|
500
|
return module_bits
|
|
479
|
|
|
501
|
|
|
|
|
|
502
|
def read_device(self):
|
|
|
|
|
503
|
|
|
|
|
|
504
|
parms = {}
|
|
|
|
|
505
|
# Reads active modules.
|
|
|
|
|
506
|
module_status = json.loads(self.module_status)
|
|
|
|
|
507
|
total = 0
|
|
|
|
|
508
|
for status in module_status:
|
|
|
|
|
509
|
if module_status[status] != 0:
|
|
|
|
|
510
|
module_bits = self.read_module(int(status))
|
|
|
|
|
511
|
bits={}
|
|
|
|
|
512
|
if module_bits:
|
|
|
|
|
513
|
bits = (str(module_bits['um2']) + str(module_bits['um1']) + str(module_bits['um0']) +
|
|
|
|
|
514
|
str(module_bits['dm2']) + str(module_bits['dm1']) + str(module_bits['dm0']) )
|
|
|
|
|
515
|
parms[str(status)] = bits
|
|
|
|
|
516
|
|
|
|
|
|
517
|
total +=1
|
|
|
|
|
518
|
|
|
|
|
|
519
|
if total==0:
|
|
|
|
|
520
|
self.message = "No ABS Module detected. Please select 'Status'."
|
|
|
|
|
521
|
return False
|
|
|
|
|
522
|
|
|
|
|
|
523
|
|
|
|
|
|
524
|
|
|
|
|
|
525
|
self.message = "ABS Modules have been read"
|
|
|
|
|
526
|
#monitoreo_tx = JROABSClnt_01CeCnMod000000MNTR10
|
|
|
|
|
527
|
return parms
|
|
|
|
|
528
|
|
|
480
|
|
|
529
|
|
|
481
|
def absmodule_status(self):
|
|
530
|
def absmodule_status(self):
|
|
482
|
"""
|
|
531
|
"""
|
|
483
|
This function gets the status of each abs module. It sends GET method to Web Application
|
|
532
|
This function gets the status of each abs module. It sends GET method to Web Application
|
|
484
|
in Python Bottle.
|
|
533
|
in Python Bottle.
|
|
485
|
This function updates "module_status" field from ABSconfiguration.
|
|
534
|
This function updates "module_status" field from ABSconfiguration.
|
|
486
|
"""
|
|
535
|
"""
|
|
487
|
ip_address = self.device.ip_address
|
|
536
|
ip_address = self.device.ip_address
|
|
488
|
ip_address = ip_address.split('.')
|
|
537
|
ip_address = ip_address.split('.')
|
|
489
|
module_seq = (ip_address[0],ip_address[1],ip_address[2])
|
|
538
|
module_seq = (ip_address[0],ip_address[1],ip_address[2])
|
|
490
|
dot = '.'
|
|
539
|
dot = '.'
|
|
491
|
module_port = self.device.port_address
|
|
540
|
module_port = self.device.port_address
|
|
492
|
|
|
541
|
|
|
493
|
modules_status = json.loads(self.module_status)
|
|
542
|
modules_status = json.loads(self.module_status)
|
|
494
|
module_messages = json.loads(self.module_messages)
|
|
543
|
module_messages = json.loads(self.module_messages)
|
|
495
|
|
|
544
|
|
|
496
|
for i in range(1,65):
|
|
545
|
for i in range(1,65):
|
|
497
|
module_ip = dot.join(module_seq)+'.'+str(i)
|
|
546
|
module_ip = dot.join(module_seq)+'.'+str(i)
|
|
498
|
print module_ip
|
|
547
|
print module_ip
|
|
499
|
|
|
548
|
|
|
500
|
route = 'http://'+module_ip+':'+str(module_port)+'/status'
|
|
549
|
route = 'http://'+module_ip+':'+str(module_port)+'/status'
|
|
501
|
|
|
550
|
|
|
502
|
try:
|
|
551
|
try:
|
|
503
|
r = requests.get(route, timeout=0.5)#, timeout=0.7)
|
|
552
|
r = requests.get(route, timeout=0.5)#, timeout=0.7)
|
|
504
|
answer = r.json()
|
|
553
|
answer = r.json()
|
|
505
|
modules_status[str(i)] = answer['status']
|
|
554
|
modules_status[str(i)] = answer['status']
|
|
506
|
module_messages[str(i)] = answer['message']
|
|
555
|
module_messages[str(i)] = answer['message']
|
|
507
|
except:
|
|
556
|
except:
|
|
508
|
modules_status[str(i)] = 0
|
|
557
|
modules_status[str(i)] = 0
|
|
509
|
pass
|
|
558
|
pass
|
|
510
|
|
|
559
|
|
|
511
|
|
|
560
|
|
|
512
|
self.module_status = json.dumps(modules_status)
|
|
561
|
self.module_status = json.dumps(modules_status)
|
|
513
|
self.module_messages = json.dumps(module_messages)
|
|
562
|
self.module_messages = json.dumps(module_messages)
|
|
514
|
self.save()
|
|
563
|
self.save()
|
|
515
|
|
|
564
|
|
|
516
|
return
|
|
565
|
return
|
|
517
|
|
|
566
|
|
|
518
|
|
|
567
|
|
|
519
|
def connected_modules(self):
|
|
568
|
def connected_modules(self):
|
|
520
|
"""
|
|
569
|
"""
|
|
521
|
This function returns the number of connected abs-modules without updating.
|
|
570
|
This function returns the number of connected abs-modules without updating.
|
|
522
|
"""
|
|
571
|
"""
|
|
523
|
modules_status = json.loads(self.module_status)
|
|
572
|
modules_status = json.loads(self.module_status)
|
|
524
|
num = 0
|
|
573
|
num = 0
|
|
525
|
for status in modules_status:
|
|
574
|
for status in modules_status:
|
|
526
|
if modules_status[status] != 0:
|
|
575
|
if modules_status[status] != 0:
|
|
527
|
num += 1
|
|
576
|
num += 1
|
|
528
|
|
|
577
|
|
|
529
|
return num
|
|
578
|
return num
|
|
530
|
|
|
579
|
|
|
531
|
|
|
580
|
|
|
532
|
def status_device(self):
|
|
581
|
def status_device(self):
|
|
533
|
"""
|
|
582
|
"""
|
|
534
|
This function returns the status of all abs-modules as one.
|
|
583
|
This function returns the status of all abs-modules as one.
|
|
535
|
If at least one module is connected, its answer is "1"
|
|
584
|
If at least one module is connected, its answer is "1"
|
|
536
|
"""
|
|
585
|
"""
|
|
537
|
self.absmodule_status()
|
|
586
|
self.absmodule_status()
|
|
538
|
connected_modules = self.connected_modules()
|
|
587
|
connected_modules = self.connected_modules()
|
|
539
|
if connected_modules>0:
|
|
588
|
if connected_modules>0:
|
|
540
|
self.message = 'ABS modules Status have been updated.'
|
|
589
|
self.message = 'ABS modules Status have been updated.'
|
|
541
|
return 1
|
|
590
|
return 1
|
|
542
|
self.message = 'No ABS module is connected.'
|
|
591
|
self.message = 'No ABS module is connected.'
|
|
543
|
return 0
|
|
592
|
return 0
|
|
544
|
|
|
593
|
|
|
545
|
|
|
594
|
|
|
546
|
|
|
595
|
|
|
547
|
def write_module(self, module):
|
|
596
|
def write_module(self, module):
|
|
548
|
|
|
597
|
|
|
549
|
"""
|
|
598
|
"""
|
|
550
|
Send configuration to one abs module
|
|
599
|
Send configuration to one abs module
|
|
551
|
"""
|
|
600
|
"""
|
|
552
|
|
|
601
|
|
|
553
|
parameters = {}
|
|
602
|
parameters = {}
|
|
554
|
ip_address = self.abs_conf.device.ip_address
|
|
603
|
ip_address = self.abs_conf.device.ip_address
|
|
555
|
ip_address = ip_address.split('.')
|
|
604
|
ip_address = ip_address.split('.')
|
|
556
|
module_seq = (ip_address[0],ip_address[1],ip_address[2])
|
|
605
|
module_seq = (ip_address[0],ip_address[1],ip_address[2])
|
|
557
|
dot = '.'
|
|
606
|
dot = '.'
|
|
558
|
module_ip = dot.join(module_seq)+'.'+str(module)
|
|
607
|
module_ip = dot.join(module_seq)+'.'+str(module)
|
|
559
|
module_port = self.abs_conf.device.port_address
|
|
608
|
module_port = self.abs_conf.device.port_address
|
|
560
|
write_route = 'http://'+module_ip+':'+str(module_port)+'/write'
|
|
609
|
write_route = 'http://'+module_ip+':'+str(module_port)+'/write'
|
|
561
|
|
|
610
|
|
|
562
|
#print write_route
|
|
611
|
#print write_route
|
|
563
|
|
|
612
|
|
|
564
|
#header = 'JROABSCeCnModCnMod01000108SNDFexperimento1.ab1'
|
|
613
|
#header = 'JROABSCeCnModCnMod01000108SNDFexperimento1.ab1'
|
|
565
|
#module = 'ABS_'+str(module)
|
|
614
|
#module = 'ABS_'+str(module)
|
|
566
|
beams = '!`*3<ENW'#{1: '001000', 2: '010001', 3: '010010', 4: '000011', 5: '101100', 6: '101101',
|
|
615
|
beams = '!`*3<ENW'#{1: '001000', 2: '010001', 3: '010010', 4: '000011', 5: '101100', 6: '101101',
|
|
567
|
# 7: '110110', 8: '111111', 9: '000000', 10: '001001', 11: '010010', 12: '011011'}
|
|
616
|
# 7: '110110', 8: '111111', 9: '000000', 10: '001001', 11: '010010', 12: '011011'}
|
|
568
|
|
|
617
|
|
|
569
|
#parameters['header'] = header
|
|
618
|
#parameters['header'] = header
|
|
570
|
parameters['module'] = module
|
|
619
|
parameters['module'] = module
|
|
571
|
parameters['beams'] = json.dumps(beams)
|
|
620
|
parameters['beams'] = json.dumps(beams)
|
|
572
|
|
|
621
|
|
|
573
|
answer = ''
|
|
622
|
answer = ''
|
|
574
|
|
|
623
|
|
|
575
|
try:
|
|
624
|
try:
|
|
576
|
r_write = requests.post(write_route, parameters, timeout=0.5)
|
|
625
|
r_write = requests.post(write_route, parameters, timeout=0.5)
|
|
577
|
answer = r_write.json()
|
|
626
|
answer = r_write.json()
|
|
578
|
self.message = answer['message']
|
|
627
|
self.message = answer['message']
|
|
579
|
except:
|
|
628
|
except:
|
|
580
|
self.message = "Could not write ABS parameters"
|
|
629
|
self.message = "Could not write ABS parameters"
|
|
581
|
return 0
|
|
630
|
return 0
|
|
582
|
|
|
631
|
|
|
583
|
|
|
632
|
|
|
584
|
#self.device.status = int(answer['status'])
|
|
633
|
#self.device.status = int(answer['status'])
|
|
585
|
|
|
634
|
|
|
586
|
return 1
|
|
635
|
return 1
|
|
587
|
|
|
636
|
|
|
588
|
|
|
637
|
|
|
589
|
def beam_selector(self, module, beam_pos):
|
|
638
|
def beam_selector(self, module, beam_pos):
|
|
590
|
"""
|
|
639
|
"""
|
|
591
|
This function selects the beam number for one absmodule.
|
|
640
|
This function selects the beam number for one absmodule.
|
|
592
|
"""
|
|
641
|
"""
|
|
593
|
|
|
642
|
|
|
594
|
if beam_pos > 0:
|
|
643
|
if beam_pos > 0:
|
|
595
|
beam_pos = beam_pos - 1
|
|
644
|
beam_pos = beam_pos - 1
|
|
596
|
else:
|
|
645
|
else:
|
|
597
|
beam_pos = 0
|
|
646
|
beam_pos = 0
|
|
598
|
|
|
647
|
|
|
599
|
#El indice del apunte debe ser menor que el numero total de apuntes
|
|
648
|
#El indice del apunte debe ser menor que el numero total de apuntes
|
|
600
|
#El servidor tcp en el embebido comienza a contar desde 0
|
|
649
|
#El servidor tcp en el embebido comienza a contar desde 0
|
|
601
|
beams_list = ABSBeam.objects.filter(abs_conf=self)
|
|
650
|
beams_list = ABSBeam.objects.filter(abs_conf=self)
|
|
602
|
if len(beams_list) < beam_pos:
|
|
651
|
if len(beams_list) < beam_pos:
|
|
603
|
return 0
|
|
652
|
return 0
|
|
604
|
|
|
653
|
|
|
605
|
flag = 1
|
|
654
|
flag = 1
|
|
606
|
if beam_pos>9:
|
|
655
|
if beam_pos>9:
|
|
607
|
flag = 2
|
|
656
|
flag = 2
|
|
608
|
|
|
657
|
|
|
609
|
module_address = ('192.168.1.'+str(module), 5500)
|
|
658
|
module_address = ('192.168.1.'+str(module), 5500)
|
|
610
|
header = 'JROABSCeCnModCnMod0100000'
|
|
659
|
header = 'JROABSCeCnModCnMod0100000'
|
|
611
|
numbers = len(str(beam_pos))
|
|
660
|
numbers = len(str(beam_pos))
|
|
612
|
function = 'CHGB'
|
|
661
|
function = 'CHGB'
|
|
613
|
|
|
662
|
|
|
614
|
message_tx = header+str(numbers)+function+str(beam_pos)+'0'
|
|
663
|
message_tx = header+str(numbers)+function+str(beam_pos)+'0'
|
|
615
|
|
|
664
|
|
|
616
|
# Create the datagram socket
|
|
665
|
# Create the datagram socket
|
|
617
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
666
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
618
|
#sock.connect(module_address)
|
|
667
|
#sock.connect(module_address)
|
|
619
|
try:
|
|
668
|
try:
|
|
620
|
sock.connect(module_address)
|
|
669
|
sock.connect(module_address)
|
|
621
|
sock.send(message_tx)
|
|
670
|
sock.send(message_tx)
|
|
622
|
sock.close()
|
|
671
|
sock.close()
|
|
623
|
print("Writing abs module:"+module_address[0]+"...")
|
|
672
|
print("Writing abs module:"+module_address[0]+"...")
|
|
624
|
except:
|
|
673
|
except:
|
|
625
|
sock = None
|
|
674
|
sock = None
|
|
626
|
print("Problem writing abs module:"+module_address[0])
|
|
675
|
print("Problem writing abs module:"+module_address[0])
|
|
627
|
return 0
|
|
676
|
return 0
|
|
628
|
|
|
677
|
|
|
629
|
return 1
|
|
678
|
return 1
|
|
630
|
|
|
679
|
|
|
631
|
|
|
680
|
|
|
632
|
def change_beam(self, beam_pos):
|
|
681
|
def change_beam(self, beam_pos):
|
|
633
|
"""
|
|
682
|
"""
|
|
634
|
This function selects the beam number for all absmodules.
|
|
683
|
This function selects the beam number for all absmodules.
|
|
635
|
"""
|
|
684
|
"""
|
|
636
|
for i in range(1,65):
|
|
685
|
for i in range(1,65):
|
|
637
|
try:
|
|
686
|
try:
|
|
638
|
self.beam_selector(i,beam_pos)
|
|
687
|
self.beam_selector(i,beam_pos)
|
|
639
|
except:
|
|
688
|
except:
|
|
640
|
print("Problem with module: 192.168.1."+str(i))
|
|
689
|
print("Problem with module: 192.168.1."+str(i))
|
|
641
|
self.message = "Problem with module: 192.168.1."+str(i)
|
|
690
|
self.message = "Problem with module: 192.168.1."+str(i)
|
|
642
|
#return 0
|
|
691
|
#return 0
|
|
643
|
return 1
|
|
692
|
return 1
|
|
644
|
|
|
693
|
|
|
645
|
|
|
694
|
|
|
646
|
def send_beam_num(self, beam_pos):
|
|
695
|
def send_beam_num(self, beam_pos):
|
|
647
|
"""
|
|
696
|
"""
|
|
648
|
This function connects to a multicast group and sends the beam number
|
|
697
|
This function connects to a multicast group and sends the beam number
|
|
649
|
to all abs modules.
|
|
698
|
to all abs modules.
|
|
650
|
"""
|
|
699
|
"""
|
|
651
|
|
|
700
|
|
|
652
|
if beam_pos > 0:
|
|
701
|
if beam_pos > 0:
|
|
653
|
beam_pos = beam_pos - 1
|
|
702
|
beam_pos = beam_pos - 1
|
|
654
|
else:
|
|
703
|
else:
|
|
655
|
beam_pos = 0
|
|
704
|
beam_pos = 0
|
|
656
|
|
|
705
|
|
|
657
|
#El indice del apunte debe ser menor que el numero total de apuntes
|
|
706
|
#El indice del apunte debe ser menor que el numero total de apuntes
|
|
658
|
#El servidor tcp en el embebido comienza a contar desde 0
|
|
707
|
#El servidor tcp en el embebido comienza a contar desde 0
|
|
659
|
beams_list = ABSBeam.objects.filter(abs_conf=self)
|
|
708
|
beams_list = ABSBeam.objects.filter(abs_conf=self)
|
|
660
|
if len(beams_list) < beam_pos:
|
|
709
|
if len(beams_list) < beam_pos:
|
|
661
|
return 0
|
|
710
|
return 0
|
|
662
|
|
|
711
|
|
|
663
|
flag = 1
|
|
712
|
flag = 1
|
|
664
|
if beam_pos>9:
|
|
713
|
if beam_pos>9:
|
|
665
|
flag = 2
|
|
714
|
flag = 2
|
|
666
|
|
|
715
|
|
|
667
|
header = 'JROABSCeCnModCnMod0100000'
|
|
716
|
header = 'JROABSCeCnModCnMod0100000'
|
|
668
|
flag = str(flag)
|
|
717
|
flag = str(flag)
|
|
669
|
function = 'CHGB'
|
|
718
|
function = 'CHGB'
|
|
670
|
message_tx = header+flag+function+str(beam_pos)+'0'
|
|
719
|
message_tx = header+flag+function+str(beam_pos)+'0'
|
|
671
|
|
|
720
|
|
|
672
|
multicast_group = '224.3.29.71'
|
|
721
|
multicast_group = '224.3.29.71'
|
|
673
|
server_address = ('',10000)
|
|
722
|
server_address = ('',10000)
|
|
674
|
|
|
723
|
|
|
675
|
# Create the socket
|
|
724
|
# Create the socket
|
|
676
|
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
|
725
|
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
|
677
|
# Bind to the server address
|
|
726
|
# Bind to the server address
|
|
678
|
sock.bind(server_address)
|
|
727
|
sock.bind(server_address)
|
|
679
|
# Telling the OS add the socket to the multicast on all interfaces
|
|
728
|
# Telling the OS add the socket to the multicast on all interfaces
|
|
680
|
group = socket.inet_aton(multicast_group)
|
|
729
|
group = socket.inet_aton(multicast_group)
|
|
681
|
mreq = struct.pack('4sL', group, socket.INADDR_ANY)
|
|
730
|
mreq = struct.pack('4sL', group, socket.INADDR_ANY)
|
|
682
|
sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)
|
|
731
|
sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)
|
|
683
|
|
|
732
|
|
|
684
|
#print 'sending acknowledgement to all: \n' + message_tx
|
|
733
|
#print 'sending acknowledgement to all: \n' + message_tx
|
|
685
|
sock.sendto(message_tx, (multicast_group, 10000))
|
|
734
|
sock.sendto(message_tx, (multicast_group, 10000))
|
|
686
|
sock.close()
|
|
735
|
sock.close()
|
|
687
|
sock = None
|
|
736
|
sock = None
|
|
688
|
|
|
737
|
|
|
689
|
return 1
|
|
738
|
return 1
|
|
690
|
|
|
739
|
|
|
691
|
def test1(self):
|
|
740
|
def test1(self):
|
|
692
|
t1 = time.time()
|
|
741
|
t1 = time.time()
|
|
693
|
t2 = 0
|
|
742
|
t2 = 0
|
|
694
|
while (t2-t1)<100:#300
|
|
743
|
while (t2-t1)<100:#300
|
|
695
|
t2 = time.time()
|
|
744
|
t2 = time.time()
|
|
696
|
self.send_beam_num(2)
|
|
745
|
self.send_beam_num(2)
|
|
697
|
time.sleep(0.04)
|
|
746
|
time.sleep(0.04)
|
|
698
|
self.send_beam_num(1)
|
|
747
|
self.send_beam_num(1)
|
|
699
|
time.sleep(0.04)
|
|
748
|
time.sleep(0.04)
|
|
700
|
return
|
|
749
|
return
|
|
701
|
|
|
750
|
|
|
702
|
def change_procs_test1(self, module):
|
|
751
|
def change_procs_test1(self, module):
|
|
703
|
|
|
752
|
|
|
704
|
for i in range (1,300):#300
|
|
753
|
for i in range (1,300):#300
|
|
705
|
beam_pos = 1
|
|
754
|
beam_pos = 1
|
|
706
|
module_address = ('192.168.1.'+str(module), 5500)
|
|
755
|
module_address = ('192.168.1.'+str(module), 5500)
|
|
707
|
header = 'JROABSCeCnModCnMod0100000'
|
|
756
|
header = 'JROABSCeCnModCnMod0100000'
|
|
708
|
numbers = len(str(beam_pos))
|
|
757
|
numbers = len(str(beam_pos))
|
|
709
|
function = 'CHGB'
|
|
758
|
function = 'CHGB'
|
|
710
|
|
|
759
|
|
|
711
|
message_tx = header+str(numbers)+function+str(beam_pos)+'0'
|
|
760
|
message_tx = header+str(numbers)+function+str(beam_pos)+'0'
|
|
712
|
|
|
761
|
|
|
713
|
# Create the datagram socket
|
|
762
|
# Create the datagram socket
|
|
714
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
763
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
715
|
sock.connect(module_address)
|
|
764
|
sock.connect(module_address)
|
|
716
|
|
|
765
|
|
|
717
|
sock.send(message_tx)
|
|
766
|
sock.send(message_tx)
|
|
718
|
#t = sock.recv(1024)
|
|
767
|
#t = sock.recv(1024)
|
|
719
|
sock.close()
|
|
768
|
sock.close()
|
|
720
|
sock = None
|
|
769
|
sock = None
|
|
721
|
|
|
770
|
|
|
722
|
|
|
771
|
|
|
723
|
time.sleep(0.04)
|
|
772
|
time.sleep(0.04)
|
|
724
|
|
|
773
|
|
|
725
|
|
|
774
|
|
|
726
|
beam_pos = 0
|
|
775
|
beam_pos = 0
|
|
727
|
numbers = len(str(beam_pos))
|
|
776
|
numbers = len(str(beam_pos))
|
|
728
|
|
|
777
|
|
|
729
|
message_tx = header+str(numbers)+function+str(beam_pos)+'0'
|
|
778
|
message_tx = header+str(numbers)+function+str(beam_pos)+'0'
|
|
730
|
|
|
779
|
|
|
731
|
# Create the datagram socket
|
|
780
|
# Create the datagram socket
|
|
732
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
781
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
733
|
sock.connect(module_address)
|
|
782
|
sock.connect(module_address)
|
|
734
|
sock.send(message_tx)
|
|
783
|
sock.send(message_tx)
|
|
735
|
sock.close()
|
|
784
|
sock.close()
|
|
736
|
sock = None
|
|
785
|
sock = None
|
|
737
|
|
|
786
|
|
|
738
|
time.sleep(0.04)
|
|
787
|
time.sleep(0.04)
|
|
739
|
|
|
788
|
|
|
740
|
|
|
789
|
|
|
741
|
def multi_procs_test1(self):
|
|
790
|
def multi_procs_test1(self):
|
|
742
|
|
|
791
|
|
|
743
|
"""
|
|
792
|
"""
|
|
744
|
This function sends the beam number to all abs modules using multiprocessing.
|
|
793
|
This function sends the beam number to all abs modules using multiprocessing.
|
|
745
|
"""
|
|
794
|
"""
|
|
746
|
|
|
795
|
|
|
747
|
#if __name__ == "__main__":
|
|
796
|
#if __name__ == "__main__":
|
|
748
|
size = 10000000 # Number of random numbers to add
|
|
797
|
size = 10000000 # Number of random numbers to add
|
|
749
|
procs = 65 # (Number-1) of processes to create (absmodule)
|
|
798
|
procs = 65 # (Number-1) of processes to create (absmodule)
|
|
750
|
|
|
799
|
|
|
751
|
# Create a list of jobs and then iterate through
|
|
800
|
# Create a list of jobs and then iterate through
|
|
752
|
# the number of processes appending each process to
|
|
801
|
# the number of processes appending each process to
|
|
753
|
# the job list
|
|
802
|
# the job list
|
|
754
|
jobs = []
|
|
803
|
jobs = []
|
|
755
|
for i in range(1, procs):
|
|
804
|
for i in range(1, procs):
|
|
756
|
|
|
805
|
|
|
757
|
process = multiprocessing.Process(target=self.change_procs_test1,args=(i,))
|
|
806
|
process = multiprocessing.Process(target=self.change_procs_test1,args=(i,))
|
|
758
|
jobs.append(process)
|
|
807
|
jobs.append(process)
|
|
759
|
#print jobs
|
|
808
|
#print jobs
|
|
760
|
|
|
809
|
|
|
761
|
# Start the processes (i.e. calculate the random number lists)
|
|
810
|
# Start the processes (i.e. calculate the random number lists)
|
|
762
|
for j in jobs:
|
|
811
|
for j in jobs:
|
|
763
|
#time.sleep(0.4)
|
|
812
|
#time.sleep(0.4)
|
|
764
|
#print j
|
|
813
|
#print j
|
|
765
|
j.start()
|
|
814
|
j.start()
|
|
766
|
|
|
815
|
|
|
767
|
# Ensure all of the processes have finished
|
|
816
|
# Ensure all of the processes have finished
|
|
768
|
for j in jobs:
|
|
817
|
for j in jobs:
|
|
769
|
j.join()
|
|
818
|
j.join()
|
|
770
|
|
|
819
|
|
|
771
|
print("List processing complete.")
|
|
820
|
print("List processing complete.")
|
|
772
|
return 1
|
|
821
|
return 1
|
|
773
|
|
|
822
|
|
|
774
|
|
|
823
|
|
|
775
|
|
|
824
|
|
|
776
|
def multi_procs_test2(self):
|
|
825
|
def multi_procs_test2(self):
|
|
777
|
"""
|
|
826
|
"""
|
|
778
|
This function use multiprocessing python library. Importing Pool we can select
|
|
827
|
This function use multiprocessing python library. Importing Pool we can select
|
|
779
|
the number of cores we want to use
|
|
828
|
the number of cores we want to use
|
|
780
|
After 'nproc' linux command, we know how many cores computer has.
|
|
829
|
After 'nproc' linux command, we know how many cores computer has.
|
|
781
|
NOT WORKING
|
|
830
|
NOT WORKING
|
|
782
|
"""
|
|
831
|
"""
|
|
783
|
import multiprocessing
|
|
832
|
import multiprocessing
|
|
784
|
pool = multiprocessing.Pool(3) # cores
|
|
833
|
pool = multiprocessing.Pool(3) # cores
|
|
785
|
|
|
834
|
|
|
786
|
tasks = []
|
|
835
|
tasks = []
|
|
787
|
procs = 65
|
|
836
|
procs = 65
|
|
788
|
for i in range(62, procs):
|
|
837
|
for i in range(62, procs):
|
|
789
|
tasks.append( (i,))
|
|
838
|
tasks.append( (i,))
|
|
790
|
#print tasks
|
|
839
|
#print tasks
|
|
791
|
#pool.apply_async(self.change_procs_test1, 62)
|
|
840
|
#pool.apply_async(self.change_procs_test1, 62)
|
|
792
|
results = [pool.apply( self.change_procs_test1, t ) for t in tasks]
|
|
841
|
results = [pool.apply( self.change_procs_test1, t ) for t in tasks]
|
|
793
|
#for result in results:
|
|
842
|
#for result in results:
|
|
794
|
#result.get()
|
|
843
|
#result.get()
|
|
795
|
#(plotNum, plotFilename) = result.get()
|
|
844
|
#(plotNum, plotFilename) = result.get()
|
|
796
|
#print("Result: plot %d written to %s" % (plotNum, plotFilename) )
|
|
845
|
#print("Result: plot %d written to %s" % (plotNum, plotFilename) )
|
|
797
|
|
|
846
|
|
|
798
|
return 1
|
|
847
|
return 1
|
|
799
|
|
|
848
|
|
|
800
|
|
|
849
|
|
|
801
|
def multi_procs_test3(self):
|
|
850
|
def multi_procs_test3(self):
|
|
802
|
"""
|
|
851
|
"""
|
|
803
|
This function use multiprocessing python library. Importing Pool we can select
|
|
852
|
This function use multiprocessing python library. Importing Pool we can select
|
|
804
|
the number of cores we want to use
|
|
853
|
the number of cores we want to use
|
|
805
|
After 'nproc' linux command, we know how many cores computer has.
|
|
854
|
After 'nproc' linux command, we know how many cores computer has.
|
|
806
|
"""
|
|
855
|
"""
|
|
807
|
from multiprocessing import Pool
|
|
856
|
from multiprocessing import Pool
|
|
808
|
import time
|
|
857
|
import time
|
|
809
|
|
|
858
|
|
|
810
|
def f(x):
|
|
859
|
def f(x):
|
|
811
|
return x*x
|
|
860
|
return x*x
|
|
812
|
|
|
861
|
|
|
813
|
tasks = []
|
|
862
|
tasks = []
|
|
814
|
procs = 65
|
|
863
|
procs = 65
|
|
815
|
pool = Pool(processes=4)
|
|
864
|
pool = Pool(processes=4)
|
|
816
|
|
|
865
|
|
|
817
|
#for i in range(62, procs):
|
|
866
|
#for i in range(62, procs):
|
|
818
|
#result = pool.map(f, range(62,65))
|
|
867
|
#result = pool.map(f, range(62,65))
|
|
819
|
it = pool.imap(self.change_procs_test1, range(62,65))
|
|
868
|
it = pool.imap(self.change_procs_test1, range(62,65))
|
|
820
|
#result.get(timeout=5)
|
|
869
|
#result.get(timeout=5)
|
|
821
|
|
|
870
|
|
|
822
|
return 1
|
|
871
|
return 1
|
|
823
|
|
|
872
|
|
|
824
|
|
|
873
|
|
|
825
|
def f(x):
|
|
874
|
def f(x):
|
|
826
|
print x
|
|
875
|
print x
|
|
827
|
return
|
|
876
|
return
|
|
828
|
|
|
877
|
|
|
829
|
def multi_procs_test4(self):
|
|
878
|
def multi_procs_test4(self):
|
|
830
|
import multiprocessing as mp
|
|
879
|
import multiprocessing as mp
|
|
831
|
|
|
880
|
|
|
832
|
|
|
881
|
|
|
833
|
num_workers = mp.cpu_count()
|
|
882
|
num_workers = mp.cpu_count()
|
|
834
|
|
|
883
|
|
|
835
|
pool = mp.Pool(num_workers)
|
|
884
|
pool = mp.Pool(num_workers)
|
|
836
|
procs = 65
|
|
885
|
procs = 65
|
|
837
|
for i in range(62, procs):
|
|
886
|
for i in range(62, procs):
|
|
838
|
#for task in tasks:
|
|
887
|
#for task in tasks:
|
|
839
|
pool.apply_async(self.f, args = (i,))
|
|
888
|
pool.apply_async(self.f, args = (i,))
|
|
840
|
|
|
889
|
|
|
841
|
pool.close()
|
|
890
|
pool.close()
|
|
842
|
pool.join()
|
|
891
|
pool.join()
|
|
843
|
|
|
892
|
|
|
844
|
return 1
|
|
893
|
return 1
|
|
845
|
|
|
894
|
|
|
846
|
|
|
895
|
|
|
847
|
def get_absolute_url_import(self):
|
|
896
|
def get_absolute_url_import(self):
|
|
848
|
return reverse('url_import_abs_conf', args=[str(self.id)])
|
|
897
|
return reverse('url_import_abs_conf', args=[str(self.id)])
|
|
849
|
|
|
898
|
|
|
850
|
|
|
899
|
|
|
851
|
|
|
900
|
|
|
852
|
|
|
901
|
|
|
853
|
class ABSBeam(models.Model):
|
|
902
|
class ABSBeam(models.Model):
|
|
854
|
|
|
903
|
|
|
855
|
name = models.CharField(max_length=60, default='Beam')
|
|
904
|
name = models.CharField(max_length=60, default='Beam')
|
|
856
|
antenna = models.CharField(verbose_name='Antenna', max_length=1000, default=antenna_default)
|
|
905
|
antenna = models.CharField(verbose_name='Antenna', max_length=1000, default=antenna_default)
|
|
857
|
abs_conf = models.ForeignKey(ABSConfiguration, null=True, verbose_name='ABS Configuration')
|
|
906
|
abs_conf = models.ForeignKey(ABSConfiguration, null=True, verbose_name='ABS Configuration')
|
|
858
|
tx = models.CharField(verbose_name='Tx', max_length=1000, default=tx_default)
|
|
907
|
tx = models.CharField(verbose_name='Tx', max_length=1000, default=tx_default)
|
|
859
|
rx = models.CharField(verbose_name='Rx', max_length=1000, default=rx_default)
|
|
908
|
rx = models.CharField(verbose_name='Rx', max_length=1000, default=rx_default)
|
|
860
|
s_time = models.TimeField(verbose_name='Star Time', default='00:00:00')
|
|
909
|
s_time = models.TimeField(verbose_name='Star Time', default='00:00:00')
|
|
861
|
e_time = models.TimeField(verbose_name='End Time', default='23:59:59')
|
|
910
|
e_time = models.TimeField(verbose_name='End Time', default='23:59:59')
|
|
862
|
modules_conf = models.CharField(verbose_name='Modules', max_length=2000, default=json.dumps(conf_default))
|
|
911
|
modules_conf = models.CharField(verbose_name='Modules', max_length=2000, default=json.dumps(conf_default))
|
|
863
|
ues = models.CharField(verbose_name='Ues', max_length=100, default=ues_default)
|
|
912
|
ues = models.CharField(verbose_name='Ues', max_length=100, default=ues_default)
|
|
864
|
only_rx = models.CharField(verbose_name='Only RX', max_length=40, default=onlyrx_default)
|
|
913
|
only_rx = models.CharField(verbose_name='Only RX', max_length=40, default=onlyrx_default)
|
|
865
|
|
|
914
|
|
|
866
|
class Meta:
|
|
915
|
class Meta:
|
|
867
|
db_table = 'abs_beams'
|
|
916
|
db_table = 'abs_beams'
|
|
868
|
|
|
917
|
|
|
869
|
def __unicode__(self):
|
|
918
|
def __unicode__(self):
|
|
870
|
return u'%s' % (self.name)
|
|
919
|
return u'%s' % (self.name)
|
|
871
|
|
|
920
|
|
|
872
|
def parms_to_dict(self):
|
|
921
|
def parms_to_dict(self):
|
|
873
|
|
|
922
|
|
|
874
|
#Update data
|
|
923
|
#Update data
|
|
875
|
self.modules_6bits()
|
|
924
|
self.modules_6bits()
|
|
876
|
|
|
925
|
|
|
877
|
parameters = {}
|
|
926
|
parameters = {}
|
|
878
|
|
|
927
|
|
|
879
|
parameters['name'] = self.name
|
|
928
|
parameters['name'] = self.name
|
|
880
|
parameters['antenna'] = ast.literal_eval(self.antenna)
|
|
929
|
parameters['antenna'] = ast.literal_eval(self.antenna)
|
|
881
|
parameters['abs_conf'] = self.abs_conf.name
|
|
930
|
parameters['abs_conf'] = self.abs_conf.name
|
|
882
|
parameters['tx'] = ast.literal_eval(self.tx)
|
|
931
|
parameters['tx'] = ast.literal_eval(self.tx)
|
|
883
|
parameters['rx'] = ast.literal_eval(self.rx)
|
|
932
|
parameters['rx'] = ast.literal_eval(self.rx)
|
|
884
|
parameters['s_time'] = self.s_time.strftime("%H:%M:%S")
|
|
933
|
parameters['s_time'] = self.s_time.strftime("%H:%M:%S")
|
|
885
|
parameters['e_time'] = self.e_time.strftime("%H:%M:%S")
|
|
934
|
parameters['e_time'] = self.e_time.strftime("%H:%M:%S")
|
|
886
|
parameters['configuration'] = ast.literal_eval(self.modules_conf)
|
|
935
|
parameters['configuration'] = ast.literal_eval(self.modules_conf)
|
|
887
|
parameters['ues'] = ast.literal_eval(self.ues)
|
|
936
|
parameters['ues'] = ast.literal_eval(self.ues)
|
|
888
|
parameters['only_rx'] = json.loads(self.only_rx)
|
|
937
|
parameters['only_rx'] = json.loads(self.only_rx)
|
|
889
|
|
|
938
|
|
|
890
|
return parameters
|
|
939
|
return parameters
|
|
891
|
|
|
940
|
|
|
892
|
def dict_to_parms(self, parameters):
|
|
941
|
def dict_to_parms(self, parameters):
|
|
893
|
|
|
942
|
|
|
894
|
self.name = parameters['name']
|
|
943
|
self.name = parameters['name']
|
|
895
|
self.antenna = json.dumps(parameters['antenna'])
|
|
944
|
self.antenna = json.dumps(parameters['antenna'])
|
|
896
|
#self.abs_conf = parameters['abs_conf']
|
|
945
|
#self.abs_conf = parameters['abs_conf']
|
|
897
|
self.tx = json.dumps(parameters['tx'])
|
|
946
|
self.tx = json.dumps(parameters['tx'])
|
|
898
|
self.rx = json.dumps(parameters['rx'])
|
|
947
|
self.rx = json.dumps(parameters['rx'])
|
|
899
|
#self.s_time = parameters['s_time']
|
|
948
|
#self.s_time = parameters['s_time']
|
|
900
|
#self.e_time = parameters['e_time']
|
|
949
|
#self.e_time = parameters['e_time']
|
|
901
|
self.ues = json.dumps(parameters['ues'])
|
|
950
|
self.ues = json.dumps(parameters['ues'])
|
|
902
|
self.only_rx = json.dumps(parameters['only_rx'])
|
|
951
|
self.only_rx = json.dumps(parameters['only_rx'])
|
|
903
|
|
|
952
|
|
|
904
|
self.modules_6bits()
|
|
953
|
self.modules_6bits()
|
|
905
|
self.save()
|
|
954
|
self.save()
|
|
906
|
|
|
955
|
|
|
907
|
|
|
956
|
|
|
908
|
def clone(self, **kwargs):
|
|
957
|
def clone(self, **kwargs):
|
|
909
|
|
|
958
|
|
|
910
|
self.pk = None
|
|
959
|
self.pk = None
|
|
911
|
self.id = None
|
|
960
|
self.id = None
|
|
912
|
for attr, value in kwargs.items():
|
|
961
|
for attr, value in kwargs.items():
|
|
913
|
setattr(self, attr, value)
|
|
962
|
setattr(self, attr, value)
|
|
914
|
|
|
963
|
|
|
915
|
self.save()
|
|
964
|
self.save()
|
|
916
|
|
|
965
|
|
|
917
|
return self
|
|
966
|
return self
|
|
918
|
|
|
967
|
|
|
919
|
|
|
968
|
|
|
920
|
|
|
969
|
|
|
921
|
def module_6bits(self, module):
|
|
970
|
def module_6bits(self, module):
|
|
922
|
"""
|
|
971
|
"""
|
|
923
|
This function reads antenna pattern and choose 6bits (upbits-downbits) for one abs module
|
|
972
|
This function reads antenna pattern and choose 6bits (upbits-downbits) for one abs module
|
|
924
|
"""
|
|
973
|
"""
|
|
925
|
if module > 64:
|
|
974
|
if module > 64:
|
|
926
|
beam_bits = ""
|
|
975
|
beam_bits = ""
|
|
927
|
return beam_bits
|
|
976
|
return beam_bits
|
|
928
|
|
|
977
|
|
|
929
|
data = ast.literal_eval(self.antenna)
|
|
978
|
data = ast.literal_eval(self.antenna)
|
|
930
|
up_data = data['antenna_up']
|
|
979
|
up_data = data['antenna_up']
|
|
931
|
down_data = data['antenna_down']
|
|
980
|
down_data = data['antenna_down']
|
|
932
|
|
|
981
|
|
|
933
|
pos = ip2position(module)
|
|
982
|
pos = ip2position(module)
|
|
934
|
up_value = up_data[pos[0]][pos[1]]
|
|
983
|
up_value = up_data[pos[0]][pos[1]]
|
|
935
|
down_value = down_data[pos[0]][pos[1]]
|
|
984
|
down_value = down_data[pos[0]][pos[1]]
|
|
936
|
|
|
985
|
|
|
937
|
up_bits = up_conv_bits(up_value)
|
|
986
|
up_bits = up_conv_bits(up_value)
|
|
938
|
down_bits = down_conv_bits(down_value)
|
|
987
|
down_bits = down_conv_bits(down_value)
|
|
939
|
beam_bits = up_bits+down_bits
|
|
988
|
beam_bits = up_bits+down_bits
|
|
940
|
|
|
989
|
|
|
941
|
return beam_bits
|
|
990
|
return beam_bits
|
|
942
|
|
|
991
|
|
|
943
|
def modules_6bits(self):
|
|
992
|
def modules_6bits(self):
|
|
944
|
"""
|
|
993
|
"""
|
|
945
|
This function returns 6bits from every abs module (1-64) in a dict
|
|
994
|
This function returns 6bits from every abs module (1-64) in a dict
|
|
946
|
"""
|
|
995
|
"""
|
|
947
|
modules_configuration = ast.literal_eval(self.modules_conf)
|
|
996
|
modules_configuration = ast.literal_eval(self.modules_conf)
|
|
948
|
|
|
997
|
|
|
949
|
for i in range(1,65):
|
|
998
|
for i in range(1,65):
|
|
950
|
modules_configuration[str(i)] = self.module_6bits(i)
|
|
999
|
modules_configuration[str(i)] = self.module_6bits(i)
|
|
951
|
|
|
1000
|
|
|
952
|
self.modules_conf = json.dumps(modules_configuration)
|
|
1001
|
self.modules_conf = json.dumps(modules_configuration)
|
|
953
|
self.save()
|
|
1002
|
self.save()
|
|
954
|
|
|
1003
|
|
|
955
|
return self.modules_conf
|
|
1004
|
return self.modules_conf
|
|
956
|
|
|
1005
|
|
|
957
|
|
|
1006
|
|
|
958
|
def set_as_activebeam(self):
|
|
1007
|
def set_as_activebeam(self):
|
|
959
|
"""
|
|
1008
|
"""
|
|
960
|
This function set this beam as the active beam of its ABS Configuration.
|
|
1009
|
This function set this beam as the active beam of its ABS Configuration.
|
|
961
|
"""
|
|
1010
|
"""
|
|
962
|
self.abs_conf.active_beam = json.dumps({'active_beam': self.id})
|
|
1011
|
self.abs_conf.active_beam = json.dumps({'active_beam': self.id})
|
|
963
|
self.abs_conf.save()
|
|
1012
|
self.abs_conf.save()
|
|
964
|
|
|
1013
|
|
|
965
|
return
|
|
1014
|
return
|
|
966
|
|
|
1015
|
|
|
967
|
|
|
1016
|
|
|
968
|
@property
|
|
1017
|
@property
|
|
969
|
def get_upvalues(self):
|
|
1018
|
def get_upvalues(self):
|
|
970
|
"""
|
|
1019
|
"""
|
|
971
|
This function reads antenna pattern and show the up-value of one abs module
|
|
1020
|
This function reads antenna pattern and show the up-value of one abs module
|
|
972
|
"""
|
|
1021
|
"""
|
|
973
|
|
|
1022
|
|
|
974
|
data = ast.literal_eval(self.antenna)
|
|
1023
|
data = ast.literal_eval(self.antenna)
|
|
975
|
up_data = data['antenna_up']
|
|
1024
|
up_data = data['antenna_up']
|
|
976
|
|
|
1025
|
|
|
977
|
up_values = []
|
|
1026
|
up_values = []
|
|
978
|
for data in up_data:
|
|
1027
|
for data in up_data:
|
|
979
|
for i in range(0,8):
|
|
1028
|
for i in range(0,8):
|
|
980
|
up_values.append(data[i])
|
|
1029
|
up_values.append(data[i])
|
|
981
|
|
|
1030
|
|
|
982
|
return up_values
|
|
1031
|
return up_values
|
|
983
|
|
|
1032
|
|
|
984
|
@property
|
|
1033
|
@property
|
|
985
|
def antenna_upvalues(self):
|
|
1034
|
def antenna_upvalues(self):
|
|
986
|
"""
|
|
1035
|
"""
|
|
987
|
This function reads antenna pattern and show the up - values of one abs beam
|
|
1036
|
This function reads antenna pattern and show the up - values of one abs beam
|
|
988
|
in a particular order
|
|
1037
|
in a particular order
|
|
989
|
"""
|
|
1038
|
"""
|
|
990
|
data = ast.literal_eval(self.antenna)
|
|
1039
|
data = ast.literal_eval(self.antenna)
|
|
991
|
up_data = data['antenna_up']
|
|
1040
|
up_data = data['antenna_up']
|
|
992
|
|
|
1041
|
|
|
993
|
return up_data
|
|
1042
|
return up_data
|
|
994
|
|
|
1043
|
|
|
995
|
@property
|
|
1044
|
@property
|
|
996
|
def antenna_downvalues(self):
|
|
1045
|
def antenna_downvalues(self):
|
|
997
|
"""
|
|
1046
|
"""
|
|
998
|
This function reads antenna pattern and show the down - values of one abs beam
|
|
1047
|
This function reads antenna pattern and show the down - values of one abs beam
|
|
999
|
in a particular order
|
|
1048
|
in a particular order
|
|
1000
|
"""
|
|
1049
|
"""
|
|
1001
|
data = ast.literal_eval(self.antenna)
|
|
1050
|
data = ast.literal_eval(self.antenna)
|
|
1002
|
down_data = data['antenna_down']
|
|
1051
|
down_data = data['antenna_down']
|
|
1003
|
|
|
1052
|
|
|
1004
|
return down_data
|
|
1053
|
return down_data
|
|
1005
|
|
|
1054
|
|
|
1006
|
@property
|
|
1055
|
@property
|
|
1007
|
def get_downvalues(self):
|
|
1056
|
def get_downvalues(self):
|
|
1008
|
"""
|
|
1057
|
"""
|
|
1009
|
This function reads antenna pattern and show the down-value of one abs module
|
|
1058
|
This function reads antenna pattern and show the down-value of one abs module
|
|
1010
|
"""
|
|
1059
|
"""
|
|
1011
|
|
|
1060
|
|
|
1012
|
data = ast.literal_eval(self.antenna)
|
|
1061
|
data = ast.literal_eval(self.antenna)
|
|
1013
|
down_data = data['antenna_down']
|
|
1062
|
down_data = data['antenna_down']
|
|
1014
|
|
|
1063
|
|
|
1015
|
down_values = []
|
|
1064
|
down_values = []
|
|
1016
|
for data in down_data:
|
|
1065
|
for data in down_data:
|
|
1017
|
for i in range(0,8):
|
|
1066
|
for i in range(0,8):
|
|
1018
|
down_values.append(data[i])
|
|
1067
|
down_values.append(data[i])
|
|
1019
|
|
|
1068
|
|
|
1020
|
return down_values
|
|
1069
|
return down_values
|
|
1021
|
|
|
1070
|
|
|
1022
|
@property
|
|
1071
|
@property
|
|
1023
|
def get_up_ues(self):
|
|
1072
|
def get_up_ues(self):
|
|
1024
|
"""
|
|
1073
|
"""
|
|
1025
|
This function shows the up-ues-value of one beam
|
|
1074
|
This function shows the up-ues-value of one beam
|
|
1026
|
"""
|
|
1075
|
"""
|
|
1027
|
data = ast.literal_eval(self.ues)
|
|
1076
|
data = ast.literal_eval(self.ues)
|
|
1028
|
up_ues = data['up']
|
|
1077
|
up_ues = data['up']
|
|
1029
|
|
|
1078
|
|
|
1030
|
return up_ues
|
|
1079
|
return up_ues
|
|
1031
|
|
|
1080
|
|
|
1032
|
@property
|
|
1081
|
@property
|
|
1033
|
def get_down_ues(self):
|
|
1082
|
def get_down_ues(self):
|
|
1034
|
"""
|
|
1083
|
"""
|
|
1035
|
This function shows the down-ues-value of one beam
|
|
1084
|
This function shows the down-ues-value of one beam
|
|
1036
|
"""
|
|
1085
|
"""
|
|
1037
|
data = ast.literal_eval(self.ues)
|
|
1086
|
data = ast.literal_eval(self.ues)
|
|
1038
|
down_ues = data['down']
|
|
1087
|
down_ues = data['down']
|
|
1039
|
|
|
1088
|
|
|
1040
|
return down_ues
|
|
1089
|
return down_ues
|
|
1041
|
|
|
1090
|
|
|
1042
|
@property
|
|
1091
|
@property
|
|
1043
|
def get_up_onlyrx(self):
|
|
1092
|
def get_up_onlyrx(self):
|
|
1044
|
"""
|
|
1093
|
"""
|
|
1045
|
This function shows the up-onlyrx-value of one beam
|
|
1094
|
This function shows the up-onlyrx-value of one beam
|
|
1046
|
"""
|
|
1095
|
"""
|
|
1047
|
data = json.loads(self.only_rx)
|
|
1096
|
data = json.loads(self.only_rx)
|
|
1048
|
up_onlyrx = data['up']
|
|
1097
|
up_onlyrx = data['up']
|
|
1049
|
|
|
1098
|
|
|
1050
|
return up_onlyrx
|
|
1099
|
return up_onlyrx
|
|
1051
|
|
|
1100
|
|
|
1052
|
@property
|
|
1101
|
@property
|
|
1053
|
def get_down_onlyrx(self):
|
|
1102
|
def get_down_onlyrx(self):
|
|
1054
|
"""
|
|
1103
|
"""
|
|
1055
|
This function shows the down-onlyrx-value of one beam
|
|
1104
|
This function shows the down-onlyrx-value of one beam
|
|
1056
|
"""
|
|
1105
|
"""
|
|
1057
|
data = json.loads(self.only_rx)
|
|
1106
|
data = json.loads(self.only_rx)
|
|
1058
|
down_onlyrx = data['down']
|
|
1107
|
down_onlyrx = data['down']
|
|
1059
|
|
|
1108
|
|
|
1060
|
return down_onlyrx
|
|
1109
|
return down_onlyrx
|
|
1061
|
|
|
1110
|
|
|
1062
|
@property
|
|
1111
|
@property
|
|
1063
|
def get_tx(self):
|
|
1112
|
def get_tx(self):
|
|
1064
|
"""
|
|
1113
|
"""
|
|
1065
|
This function shows the tx-values of one beam
|
|
1114
|
This function shows the tx-values of one beam
|
|
1066
|
"""
|
|
1115
|
"""
|
|
1067
|
data = json.loads(self.tx)
|
|
1116
|
data = json.loads(self.tx)
|
|
1068
|
|
|
1117
|
|
|
1069
|
return data
|
|
1118
|
return data
|
|
1070
|
|
|
1119
|
|
|
1071
|
@property
|
|
1120
|
@property
|
|
1072
|
def get_uptx(self):
|
|
1121
|
def get_uptx(self):
|
|
1073
|
"""
|
|
1122
|
"""
|
|
1074
|
This function shows the up-tx-values of one beam
|
|
1123
|
This function shows the up-tx-values of one beam
|
|
1075
|
"""
|
|
1124
|
"""
|
|
1076
|
data = json.loads(self.tx)
|
|
1125
|
data = json.loads(self.tx)
|
|
1077
|
up_data = data['up']
|
|
1126
|
up_data = data['up']
|
|
1078
|
|
|
1127
|
|
|
1079
|
up_values = []
|
|
1128
|
up_values = []
|
|
1080
|
for data in up_data:
|
|
1129
|
for data in up_data:
|
|
1081
|
for i in range(0,8):
|
|
1130
|
for i in range(0,8):
|
|
1082
|
up_values.append(data[i])
|
|
1131
|
up_values.append(data[i])
|
|
1083
|
|
|
1132
|
|
|
1084
|
return up_values
|
|
1133
|
return up_values
|
|
1085
|
|
|
1134
|
|
|
1086
|
@property
|
|
1135
|
@property
|
|
1087
|
def get_downtx(self):
|
|
1136
|
def get_downtx(self):
|
|
1088
|
"""
|
|
1137
|
"""
|
|
1089
|
This function shows the down-tx-values of one beam
|
|
1138
|
This function shows the down-tx-values of one beam
|
|
1090
|
"""
|
|
1139
|
"""
|
|
1091
|
data = json.loads(self.tx)
|
|
1140
|
data = json.loads(self.tx)
|
|
1092
|
down_data = data['down']
|
|
1141
|
down_data = data['down']
|
|
1093
|
|
|
1142
|
|
|
1094
|
down_values = []
|
|
1143
|
down_values = []
|
|
1095
|
for data in down_data:
|
|
1144
|
for data in down_data:
|
|
1096
|
for i in range(0,8):
|
|
1145
|
for i in range(0,8):
|
|
1097
|
down_values.append(data[i])
|
|
1146
|
down_values.append(data[i])
|
|
1098
|
|
|
1147
|
|
|
1099
|
return down_values
|
|
1148
|
return down_values
|
|
1100
|
|
|
1149
|
|
|
1101
|
|
|
1150
|
|
|
1102
|
|
|
1151
|
|
|
1103
|
@property
|
|
1152
|
@property
|
|
1104
|
def get_rx(self):
|
|
1153
|
def get_rx(self):
|
|
1105
|
"""
|
|
1154
|
"""
|
|
1106
|
This function shows the rx-values of one beam
|
|
1155
|
This function shows the rx-values of one beam
|
|
1107
|
"""
|
|
1156
|
"""
|
|
1108
|
data = json.loads(self.rx)
|
|
1157
|
data = json.loads(self.rx)
|
|
1109
|
|
|
1158
|
|
|
1110
|
return data
|
|
1159
|
return data
|
|
1111
|
|
|
1160
|
|
|
1112
|
@property
|
|
1161
|
@property
|
|
1113
|
def get_uprx(self):
|
|
1162
|
def get_uprx(self):
|
|
1114
|
"""
|
|
1163
|
"""
|
|
1115
|
This function shows the up-rx-values of one beam
|
|
1164
|
This function shows the up-rx-values of one beam
|
|
1116
|
"""
|
|
1165
|
"""
|
|
1117
|
data = json.loads(self.rx)
|
|
1166
|
data = json.loads(self.rx)
|
|
1118
|
up_data = data['up']
|
|
1167
|
up_data = data['up']
|
|
1119
|
|
|
1168
|
|
|
1120
|
up_values = []
|
|
1169
|
up_values = []
|
|
1121
|
for data in up_data:
|
|
1170
|
for data in up_data:
|
|
1122
|
for i in range(0,8):
|
|
1171
|
for i in range(0,8):
|
|
1123
|
up_values.append(data[i])
|
|
1172
|
up_values.append(data[i])
|
|
1124
|
|
|
1173
|
|
|
1125
|
return up_values
|
|
1174
|
return up_values
|
|
1126
|
|
|
1175
|
|
|
1127
|
@property
|
|
1176
|
@property
|
|
1128
|
def get_downrx(self):
|
|
1177
|
def get_downrx(self):
|
|
1129
|
"""
|
|
1178
|
"""
|
|
1130
|
This function shows the down-rx-values of one beam
|
|
1179
|
This function shows the down-rx-values of one beam
|
|
1131
|
"""
|
|
1180
|
"""
|
|
1132
|
data = json.loads(self.rx)
|
|
1181
|
data = json.loads(self.rx)
|
|
1133
|
down_data = data['down']
|
|
1182
|
down_data = data['down']
|
|
1134
|
|
|
1183
|
|
|
1135
|
down_values = []
|
|
1184
|
down_values = []
|
|
1136
|
for data in down_data:
|
|
1185
|
for data in down_data:
|
|
1137
|
for i in range(0,8):
|
|
1186
|
for i in range(0,8):
|
|
1138
|
down_values.append(data[i])
|
|
1187
|
down_values.append(data[i])
|
|
1139
|
|
|
1188
|
|
|
1140
|
return down_values
|
|
1189
|
return down_values
|