@@ -1,525 +1,531 | |||
|
1 | 1 | from django.shortcuts import render_to_response, redirect No newline at end of file |
|
2 | 2 | from django.http import HttpResponse No newline at end of file |
|
3 | 3 | from django.conf import settings No newline at end of file |
|
4 | 4 | from django.utils.encoding import smart_str No newline at end of file |
|
5 | 5 | from django.core.servers.basehttp import FileWrapper No newline at end of file |
|
6 | 6 | import mimetypes No newline at end of file |
|
7 | 7 | from django.contrib.auth.decorators import login_required No newline at end of file |
|
8 | 8 | from django.template import RequestContext No newline at end of file |
|
9 | 9 | No newline at end of file |
|
10 | 10 | from datetime import datetime No newline at end of file |
|
11 | 11 | import os No newline at end of file |
|
12 | 12 | from abscontrol.models import Profile, Pattern, AntennaDown, AntennaUp No newline at end of file |
|
13 | 13 | No newline at end of file |
|
14 | 14 | from util.readABSFile import readABSFile No newline at end of file |
|
15 | 15 | from util.saveABSFile import saveABSFile No newline at end of file |
|
16 | 16 | from util.ABSData import ABSData No newline at end of file |
|
17 | 17 | from util.OverJRO import OverJRO No newline at end of file |
|
18 | 18 | from scripts.sendFile import sendFile No newline at end of file |
|
19 | 19 | from scripts.changeBeam import changeBeam No newline at end of file |
|
20 | 20 | from overJroShow import overJroShow No newline at end of file |
|
21 | 21 | No newline at end of file |
|
22 | 22 | arrayTx = [["0","0","0","0","0","0","0","0"],\ No newline at end of file |
|
23 | 23 | ["0","0","0","0","0","0","0","0"],\ No newline at end of file |
|
24 | 24 | ["0","0","0","0","0","0","0","0"],\ No newline at end of file |
|
25 | 25 | ["0","0","0","0","0","0","0","0"],\ No newline at end of file |
|
26 | 26 | ["0","0","0","0","0","0","0","0"],\ No newline at end of file |
|
27 | 27 | ["0","0","0","0","0","0","0","0"],\ No newline at end of file |
|
28 | 28 | ["0","0","0","0","0","0","0","0"],\ No newline at end of file |
|
29 | 29 | ["0","0","0","0","0","0","0","0"]] No newline at end of file |
|
30 | 30 | No newline at end of file |
|
31 | 31 | arrayUes = ["0.533333","0.00000","1.06667","0.00000"] No newline at end of file |
|
32 | 32 | No newline at end of file |
|
33 | 33 | @login_required(login_url='/accounts/login/') No newline at end of file |
|
34 | 34 | def index(request): No newline at end of file |
|
35 | 35 | #latest_poll_list = profileAntenna.objects.all().order_by('-pub_date')[:5] No newline at end of file |
|
36 | 36 | profile_list = Profile.objects.filter(state=1) No newline at end of file |
|
37 | 37 | return render_to_response('abscontrol/index.html', {'profile_list': profile_list}, context_instance=RequestContext(request)) No newline at end of file |
|
38 | 38 | No newline at end of file |
|
39 | 39 | def new(request): No newline at end of file |
|
40 | 40 | profile_list = Profile.objects.filter(state=1) No newline at end of file |
|
41 | 41 | txtProfile = datetime.now().strftime("%Y%m%d%H%M%S%f") No newline at end of file |
|
42 | 42 | newprofile = Profile(name=txtProfile) No newline at end of file |
|
43 | 43 | newprofile.save() No newline at end of file |
|
44 | 44 | No newline at end of file |
|
45 | 45 | lsPatterns = None No newline at end of file |
|
46 | 46 | No newline at end of file |
|
47 | 47 | return render_to_response('abscontrol/new.html', {'profile_list': profile_list, No newline at end of file |
|
48 | 48 | 'profile_name' : newprofile.name, No newline at end of file |
|
49 | 49 | 'profile_id' : newprofile.id, No newline at end of file |
|
50 | 50 | 'lsPatterns' : lsPatterns, No newline at end of file |
|
51 | 51 | 'range' : range(8), 'arrayUes' : arrayUes, No newline at end of file |
|
52 | 52 | }, context_instance=RequestContext(request)) No newline at end of file |
|
53 | 53 | No newline at end of file |
|
54 | 54 | def save(request): No newline at end of file |
|
55 | 55 | No newline at end of file |
|
56 | 56 | txtProfile = request.POST["txtProfile"] No newline at end of file |
|
57 | 57 | No newline at end of file |
|
58 | 58 | txtAntennaUp = request.POST["txtAntennaUp"] No newline at end of file |
|
59 | 59 | txtTxUp = request.POST["txtTxUp"] No newline at end of file |
|
60 | 60 | txtRxUp = request.POST["txtRxUp"] No newline at end of file |
|
61 | 61 | txtUesUp = request.POST["txtUesUp"] No newline at end of file |
|
62 | 62 | No newline at end of file |
|
63 | 63 | txtAntennaDown = request.POST["txtAntennaDown"] No newline at end of file |
|
64 | 64 | txtTxDown = request.POST["txtTxDown"] No newline at end of file |
|
65 | 65 | txtRxDown = request.POST["txtRxDown"] No newline at end of file |
|
66 | 66 | txtUesDown = request.POST["txtUesDown"] No newline at end of file |
|
67 | 67 | No newline at end of file |
|
68 | 68 | newprofile = Profile(name=txtProfile) No newline at end of file |
|
69 | 69 | newprofile.save() No newline at end of file |
|
70 | 70 | No newline at end of file |
|
71 | 71 | newpattern = newprofile.pattern_set.create(value=1) No newline at end of file |
|
72 | 72 | newpattern.antennaup_set.create(value=txtAntennaUp,tx=txtTxUp,rx=txtRxUp,ues=txtUesUp) No newline at end of file |
|
73 | 73 | newpattern.antennadown_set.create(value=txtAntennaDown,tx=txtTxDown,rx=txtRxDown,ues=txtUesDown) No newline at end of file |
|
74 | 74 | No newline at end of file |
|
75 | 75 | newurl = '/abscontrol/view/%d' % newprofile.id No newline at end of file |
|
76 | 76 | No newline at end of file |
|
77 | 77 | return redirect(newurl) No newline at end of file |
|
78 | 78 | No newline at end of file |
|
79 | 79 | # Update temporal experiment No newline at end of file |
|
80 | 80 | def upgrade(request, profile_id): No newline at end of file |
|
81 | 81 | txtAntennaUp = request.POST["txtAntennaUp"] No newline at end of file |
|
82 | 82 | txtTxUp = request.POST["txtTxUp"] No newline at end of file |
|
83 | 83 | txtRxUp = request.POST["txtRxUp"] No newline at end of file |
|
84 | 84 | txtUesUp = request.POST["txtUesUp"] No newline at end of file |
|
85 | 85 | No newline at end of file |
|
86 | 86 | txtAntennaDown = request.POST["txtAntennaDown"] No newline at end of file |
|
87 | 87 | txtTxDown = request.POST["txtTxDown"] No newline at end of file |
|
88 | 88 | txtRxDown = request.POST["txtRxDown"] No newline at end of file |
|
89 | 89 | txtUesDown = request.POST["txtUesDown"] No newline at end of file |
|
90 | 90 | No newline at end of file |
|
91 | 91 | objProfile = Profile.objects.get(pk=profile_id) No newline at end of file |
|
92 | 92 | newpattern = objProfile.pattern_set.create(value=1) No newline at end of file |
|
93 | 93 | newpattern.antennaup_set.create(value=txtAntennaUp,tx=txtTxUp,rx=txtRxUp,ues=txtUesUp) No newline at end of file |
|
94 | 94 | newpattern.antennadown_set.create(value=txtAntennaDown,tx=txtTxDown,rx=txtRxDown,ues=txtUesDown) No newline at end of file |
|
95 | 95 | No newline at end of file |
|
96 | 96 | newurl = '/abscontrol/%d/edit/%d' % (int(profile_id), newpattern.id) No newline at end of file |
|
97 | 97 | return redirect(newurl) No newline at end of file |
|
98 | 98 | No newline at end of file |
|
99 | 99 | def update(request, profile_id): No newline at end of file |
|
100 | 100 | txtProfile = request.POST["txtProfile"] No newline at end of file |
|
101 | 101 | No newline at end of file |
|
102 | 102 | objProfile = Profile.objects.get(pk=profile_id) No newline at end of file |
|
103 | 103 | objProfile.name = txtProfile No newline at end of file |
|
104 | 104 | objProfile.state = 1 No newline at end of file |
|
105 | 105 | objProfile.save() No newline at end of file |
|
106 | 106 | No newline at end of file |
|
107 | 107 | newurl = '/abscontrol/view/%d' % objProfile.id No newline at end of file |
|
108 | 108 | return redirect(newurl) No newline at end of file |
|
109 | 109 | No newline at end of file |
|
110 | 110 | def changeName(request, profile_id): No newline at end of file |
|
111 | 111 | profile_list = Profile.objects.filter(state=1) No newline at end of file |
|
112 | 112 | objProfile = Profile.objects.get(pk=profile_id) No newline at end of file |
|
113 | 113 | lsPatterns = objProfile.pattern_set.all() No newline at end of file |
|
114 | 114 | No newline at end of file |
|
115 | 115 | return render_to_response('abscontrol/changeName.html', {'profile_list': profile_list, No newline at end of file |
|
116 | 116 | 'objProfile': objProfile, No newline at end of file |
|
117 | 117 | 'lsPatterns' : lsPatterns, No newline at end of file |
|
118 | 118 | }, context_instance=RequestContext(request)) No newline at end of file |
|
119 | 119 | No newline at end of file |
|
120 | 120 | def view(request, profile_id): No newline at end of file |
|
121 | 121 | if request.method == 'GET' and 'pattern' in request.GET: No newline at end of file |
|
122 | 122 | pattern_value = request.GET["pattern"] No newline at end of file |
|
123 | 123 | else: No newline at end of file |
|
124 | 124 | pattern_value = 1 No newline at end of file |
|
125 | 125 | No newline at end of file |
|
126 | 126 | profile_list = Profile.objects.filter(state=1) No newline at end of file |
|
127 | 127 | objProfile = Profile.objects.get(pk=profile_id) No newline at end of file |
|
128 | 128 | No newline at end of file |
|
129 | 129 | lsPatterns = objProfile.pattern_set.all() No newline at end of file |
|
130 | 130 | patternChoosen = objProfile.pattern_set.get(value=pattern_value) No newline at end of file |
|
131 | 131 | objAntennaUp = patternChoosen.antennaup_set.get() No newline at end of file |
|
132 | 132 | objAntennaDown = patternChoosen.antennadown_set.get() No newline at end of file |
|
133 | 133 | No newline at end of file |
|
134 | 134 | return render_to_response('abscontrol/view.html', {'objProfile': objProfile, 'profile_list': profile_list, No newline at end of file |
|
135 | 135 | 'patternChoosen' : patternChoosen, 'lsPatterns' : lsPatterns, No newline at end of file |
|
136 | 136 | 'antennaUp' : objAntennaUp, 'antennaDown' : objAntennaDown, No newline at end of file |
|
137 | 137 | }, context_instance=RequestContext(request)) No newline at end of file |
|
138 | 138 | No newline at end of file |
|
139 | 139 | def edit(request, profile_id): No newline at end of file |
|
140 | 140 | if request.method == 'GET' and 'pattern' in request.GET: No newline at end of file |
|
141 | 141 | pattern_value = request.GET["pattern"] No newline at end of file |
|
142 | 142 | else: No newline at end of file |
|
143 | 143 | pattern_value = 1 No newline at end of file |
|
144 | 144 | No newline at end of file |
|
145 | 145 | absData = ABSData() No newline at end of file |
|
146 | 146 | profile_list = Profile.objects.filter(state=1) No newline at end of file |
|
147 | 147 | objProfile = Profile.objects.get(pk=profile_id) No newline at end of file |
|
148 | 148 | No newline at end of file |
|
149 | 149 | lsPatterns = objProfile.pattern_set.all() No newline at end of file |
|
150 | 150 | patternChoosen = objProfile.pattern_set.get(value=pattern_value) No newline at end of file |
|
151 | 151 | objAntennaUp = patternChoosen.antennaup_set.get() No newline at end of file |
|
152 | 152 | objAntennaDown = patternChoosen.antennadown_set.get() No newline at end of file |
|
153 | 153 | No newline at end of file |
|
154 | 154 | arrayAntennaUp = absData.convertStringtoList2(objAntennaUp.value) No newline at end of file |
|
155 | 155 | if objAntennaUp.tx != None: No newline at end of file |
|
156 | 156 | arrayTxUp = absData.convertStringtoList2(objAntennaUp.tx) No newline at end of file |
|
157 | 157 | else: No newline at end of file |
|
158 | 158 | arrayTxUp = arrayTx No newline at end of file |
|
159 | 159 | if objAntennaUp.rx != None: No newline at end of file |
|
160 | 160 | arrayRxUp = absData.convertStringtoList2(objAntennaUp.rx) No newline at end of file |
|
161 | 161 | else: No newline at end of file |
|
162 | 162 | arrayRxUp = arrayTx No newline at end of file |
|
163 | 163 | if objAntennaUp.ues != None: No newline at end of file |
|
164 | 164 | arrayUesUp = absData.convertStringtoList1(objAntennaUp.ues) No newline at end of file |
|
165 | 165 | else: No newline at end of file |
|
166 | 166 | arrayUesUp = arrayUes No newline at end of file |
|
167 | 167 | No newline at end of file |
|
168 | 168 | arrayAntennaDown = absData.convertStringtoList2(objAntennaDown.value) No newline at end of file |
|
169 | 169 | if objAntennaDown.tx != None: No newline at end of file |
|
170 | 170 | arrayTxDown = absData.convertStringtoList2(objAntennaDown.tx) No newline at end of file |
|
171 | 171 | else: No newline at end of file |
|
172 | 172 | arrayTxDown = arrayTx No newline at end of file |
|
173 | 173 | if objAntennaDown.rx != None: No newline at end of file |
|
174 | 174 | arrayRxDown = absData.convertStringtoList2(objAntennaDown.rx) No newline at end of file |
|
175 | 175 | else: No newline at end of file |
|
176 | 176 | arrayRxDown = arrayTx No newline at end of file |
|
177 | 177 | if objAntennaDown.ues != None: No newline at end of file |
|
178 | 178 | arrayUesDown = absData.convertStringtoList1(objAntennaDown.ues) No newline at end of file |
|
179 | 179 | else: No newline at end of file |
|
180 | 180 | arrayUesDown = arrayUes No newline at end of file |
|
181 | 181 | No newline at end of file |
|
182 | 182 | return render_to_response('abscontrol/edit.html', {'objProfile': objProfile, 'profile_list': profile_list, No newline at end of file |
|
183 | 183 | 'patternChoosen' : patternChoosen, 'lsPatterns' : lsPatterns, No newline at end of file |
|
184 | 184 | 'antennaUp' : objAntennaUp, 'antennaDown' : objAntennaDown, No newline at end of file |
|
185 | 185 | 'arrayAntennaUp' : arrayAntennaUp, 'arrayTxUp' : arrayTxUp, No newline at end of file |
|
186 | 186 | 'arrayRxUp' : arrayRxUp, 'arrayRxDown' : arrayRxDown, No newline at end of file |
|
187 | 187 | 'arrayAntennaDown' : arrayAntennaDown, 'arrayTxDown' : arrayTxDown, No newline at end of file |
|
188 | 188 | 'arrayUesUp' : arrayUesUp, 'arrayUesDown' : arrayUesDown, No newline at end of file |
|
189 | 189 | }, context_instance=RequestContext(request)) No newline at end of file |
|
190 | 190 | No newline at end of file |
|
191 | 191 | def addPattern(request, profile_id): No newline at end of file |
|
192 | 192 | profile_list = Profile.objects.filter(state=1) No newline at end of file |
|
193 | 193 | objProfile = Profile.objects.get(pk=profile_id) No newline at end of file |
|
194 | 194 | No newline at end of file |
|
195 | 195 | return render_to_response('abscontrol/addPattern.html', {'objProfile': objProfile, 'profile_list': profile_list, No newline at end of file |
|
196 | 196 | 'range' : range(8), 'arrayUes' : arrayUes, No newline at end of file |
|
197 | 197 | }, context_instance=RequestContext(request)) No newline at end of file |
|
198 | 198 | No newline at end of file |
|
199 | 199 | def editPattern(request, profile_id, pattern_id): No newline at end of file |
|
200 | 200 | absData = ABSData() No newline at end of file |
|
201 | 201 | profile_list = Profile.objects.filter(state=1) No newline at end of file |
|
202 | 202 | objProfile = Profile.objects.get(pk=profile_id) No newline at end of file |
|
203 | 203 | lsPatterns = objProfile.pattern_set.all() No newline at end of file |
|
204 | 204 | patternChoosen = Pattern.objects.get(pk=pattern_id) No newline at end of file |
|
205 | 205 | objAntennaUp = patternChoosen.antennaup_set.get() No newline at end of file |
|
206 | 206 | objAntennaDown = patternChoosen.antennadown_set.get() No newline at end of file |
|
207 | 207 | No newline at end of file |
|
208 | 208 | arrayAntennaUp = absData.convertStringtoList2(objAntennaUp.value) No newline at end of file |
|
209 | 209 | if objAntennaUp.tx != None: No newline at end of file |
|
210 | 210 | arrayTxUp = absData.convertStringtoList2(objAntennaUp.tx) No newline at end of file |
|
211 | 211 | else: No newline at end of file |
|
212 | 212 | arrayTxUp = arrayTx No newline at end of file |
|
213 | 213 | if objAntennaUp.rx != None: No newline at end of file |
|
214 | 214 | arrayRxUp = absData.convertStringtoList2(objAntennaUp.rx) No newline at end of file |
|
215 | 215 | else: No newline at end of file |
|
216 | 216 | arrayRxUp = arrayTx No newline at end of file |
|
217 | 217 | if objAntennaUp.ues != None: No newline at end of file |
|
218 | 218 | arrayUesUp = absData.convertStringtoList1(objAntennaUp.ues) No newline at end of file |
|
219 | 219 | else: No newline at end of file |
|
220 | 220 | arrayUesUp = arrayUes No newline at end of file |
|
221 | 221 | No newline at end of file |
|
222 | 222 | arrayAntennaDown = absData.convertStringtoList2(objAntennaDown.value) No newline at end of file |
|
223 | 223 | if objAntennaDown.tx != None: No newline at end of file |
|
224 | 224 | arrayTxDown = absData.convertStringtoList2(objAntennaDown.tx) No newline at end of file |
|
225 | 225 | else: No newline at end of file |
|
226 | 226 | arrayTxDown = arrayTx No newline at end of file |
|
227 | 227 | if objAntennaDown.rx != None: No newline at end of file |
|
228 | 228 | arrayRxDown = absData.convertStringtoList2(objAntennaDown.rx) No newline at end of file |
|
229 | 229 | else: No newline at end of file |
|
230 | 230 | arrayRxDown = arrayTx No newline at end of file |
|
231 | 231 | if objAntennaDown.ues != None: No newline at end of file |
|
232 | 232 | arrayUesDown = absData.convertStringtoList1(objAntennaDown.ues) No newline at end of file |
|
233 | 233 | else: No newline at end of file |
|
234 | 234 | arrayUesDown = arrayUes No newline at end of file |
|
235 | 235 | No newline at end of file |
|
236 | 236 | return render_to_response('abscontrol/editPattern.html', {'objProfile': objProfile, 'profile_list': profile_list, No newline at end of file |
|
237 | 237 | 'patternChoosen' : patternChoosen, 'lsPatterns' : lsPatterns, No newline at end of file |
|
238 | 238 | 'antennaUp' : objAntennaUp, 'antennaDown' : objAntennaDown, No newline at end of file |
|
239 | 239 | 'arrayAntennaUp' : arrayAntennaUp, 'arrayTxUp' : arrayTxUp, No newline at end of file |
|
240 | 240 | 'arrayRxUp' : arrayRxUp, 'arrayRxDown' : arrayRxDown, No newline at end of file |
|
241 | 241 | 'arrayAntennaDown' : arrayAntennaDown, 'arrayTxDown' : arrayTxDown, No newline at end of file |
|
242 | 242 | 'arrayUesUp' : arrayUesUp, 'arrayUesDown' : arrayUesDown, No newline at end of file |
|
243 | 243 | }, context_instance=RequestContext(request)) No newline at end of file |
|
244 | 244 | No newline at end of file |
|
245 | 245 | def savePattern(request, profile_id): No newline at end of file |
|
246 | 246 | pattern_id = 0 No newline at end of file |
|
247 | 247 | method = "save" No newline at end of file |
|
248 | 248 | No newline at end of file |
|
249 | 249 | if 'pattern_id' in request.POST: No newline at end of file |
|
250 | 250 | pattern_id = request.POST["pattern_id"] No newline at end of file |
|
251 | 251 | method = "update" No newline at end of file |
|
252 | 252 | No newline at end of file |
|
253 | 253 | maxValuePattern = 0 No newline at end of file |
|
254 | 254 | txtAntennaUp = request.POST["txtAntennaUp"] No newline at end of file |
|
255 | 255 | txtTxUp = request.POST["txtTxUp"] No newline at end of file |
|
256 | 256 | txtRxUp = request.POST["txtRxUp"] No newline at end of file |
|
257 | 257 | txtUesUp = request.POST["txtUesUp"] No newline at end of file |
|
258 | 258 | No newline at end of file |
|
259 | 259 | txtAntennaDown = request.POST["txtAntennaDown"] No newline at end of file |
|
260 | 260 | txtTxDown = request.POST["txtTxDown"] No newline at end of file |
|
261 | 261 | txtRxDown = request.POST["txtRxDown"] No newline at end of file |
|
262 | 262 | txtUesDown = request.POST["txtUesDown"] No newline at end of file |
|
263 | 263 | No newline at end of file |
|
264 | 264 | mode = request.POST["mode"] No newline at end of file |
|
265 | 265 | No newline at end of file |
|
266 | 266 | if method == "save": No newline at end of file |
|
267 | 267 | objProfile = Profile.objects.get(pk=profile_id) No newline at end of file |
|
268 | 268 | lsPatterns = objProfile.pattern_set.all() No newline at end of file |
|
269 | 269 | if len(lsPatterns) > 0: No newline at end of file |
|
270 | 270 | for element in lsPatterns: No newline at end of file |
|
271 | 271 | if element.value > maxValuePattern: No newline at end of file |
|
272 | 272 | maxPattern = element.value No newline at end of file |
|
273 | 273 | else: No newline at end of file |
|
274 | 274 | maxPattern = 0 No newline at end of file |
|
275 | 275 | No newline at end of file |
|
276 | 276 | if maxPattern < 10 : No newline at end of file |
|
277 | 277 | newValuePattern = maxPattern + 1 No newline at end of file |
|
278 | 278 | newpattern = objProfile.pattern_set.create(value=newValuePattern) No newline at end of file |
|
279 | 279 | newpattern.antennaup_set.create(value=txtAntennaUp,tx=txtTxUp,rx=txtRxUp,ues=txtUesUp) No newline at end of file |
|
280 | 280 | newpattern.antennadown_set.create(value=txtAntennaDown,tx=txtTxDown,rx=txtRxDown,ues=txtUesDown) No newline at end of file |
|
281 | 281 | error = 0 No newline at end of file |
|
282 | 282 | else: No newline at end of file |
|
283 | 283 | error = 1 # Can not add more patterns No newline at end of file |
|
284 | 284 | No newline at end of file |
|
285 | 285 | if mode == "e": No newline at end of file |
|
286 | 286 | newurl = '/abscontrol/%d/edit/%d' % (int(profile_id), newpattern.id) No newline at end of file |
|
287 | 287 | else: No newline at end of file |
|
288 | 288 | newurl = '/abscontrol/%d/view/%d' % (int(profile_id), newpattern.id) No newline at end of file |
|
289 | 289 | else: No newline at end of file |
|
290 | 290 | txtAntennaUpId = request.POST["txtAntennaUpId"] No newline at end of file |
|
291 | 291 | objAntennaUp = AntennaUp.objects.get(pk=txtAntennaUpId) No newline at end of file |
|
292 | 292 | objAntennaUp.value = txtAntennaUp No newline at end of file |
|
293 | 293 | objAntennaUp.tx = txtTxUp No newline at end of file |
|
294 | 294 | objAntennaUp.rx = txtRxUp No newline at end of file |
|
295 | 295 | objAntennaUp.ues = txtUesUp No newline at end of file |
|
296 | 296 | objAntennaUp.save() No newline at end of file |
|
297 | 297 | No newline at end of file |
|
298 | 298 | txtAntennaDownId = request.POST["txtAntennaDownId"] No newline at end of file |
|
299 | 299 | objAntennaDown = AntennaDown.objects.get(pk=txtAntennaDownId) No newline at end of file |
|
300 | 300 | objAntennaDown.value = txtAntennaDown No newline at end of file |
|
301 | 301 | objAntennaDown.tx = txtTxDown No newline at end of file |
|
302 | 302 | objAntennaDown.rx = txtRxDown No newline at end of file |
|
303 | 303 | objAntennaDown.ues = txtUesDown No newline at end of file |
|
304 | 304 | objAntennaDown.save() No newline at end of file |
|
305 | 305 | No newline at end of file |
|
306 | 306 | if mode == "e": No newline at end of file |
|
307 | 307 | newurl = '/abscontrol/%d/edit/%d' % (int(profile_id), int(pattern_id)) No newline at end of file |
|
308 | 308 | else: No newline at end of file |
|
309 | 309 | newurl = '/abscontrol/%d/view/%d' % (int(profile_id), int(pattern_id)) No newline at end of file |
|
310 | 310 | No newline at end of file |
|
311 | 311 | return redirect(newurl) No newline at end of file |
|
312 | 312 | No newline at end of file |
|
313 | 313 | def viewPattern(request, profile_id, pattern_id): No newline at end of file |
|
314 | 314 | No newline at end of file |
|
315 | 315 | profile_list = Profile.objects.filter(state=1) No newline at end of file |
|
316 | 316 | objProfile = Profile.objects.get(pk=profile_id) No newline at end of file |
|
317 | 317 | No newline at end of file |
|
318 | 318 | patternChoosen = Pattern.objects.get(pk=pattern_id) No newline at end of file |
|
319 | 319 | No newline at end of file |
|
320 | 320 | objAntennaUp = patternChoosen.antennaup_set.get() No newline at end of file |
|
321 | 321 | objAntennaDown = patternChoosen.antennadown_set.get() No newline at end of file |
|
322 | 322 | No newline at end of file |
|
323 | 323 | lsPatterns = objProfile.pattern_set.all() No newline at end of file |
|
324 | 324 | No newline at end of file |
|
325 | 325 | return render_to_response('abscontrol/viewPattern.html', {'objProfile': objProfile, 'profile_list': profile_list, No newline at end of file |
|
326 | 326 | 'patternChoosen' : patternChoosen, 'lsPatterns' : lsPatterns, No newline at end of file |
|
327 | 327 | 'antennaUp' : objAntennaUp, 'antennaDown' : objAntennaDown, No newline at end of file |
|
328 | 328 | }, context_instance=RequestContext(request)) No newline at end of file |
|
329 | 329 | No newline at end of file |
|
330 | 330 | def deletePattern(request, profile_id, pattern_id): No newline at end of file |
|
331 | 331 | newurl = '/abscontrol/edit/%d' % int(profile_id) No newline at end of file |
|
332 | 332 | No newline at end of file |
|
333 | 333 | return redirect(newurl) No newline at end of file |
|
334 | 334 | No newline at end of file |
|
335 | 335 | def importProfile(request): No newline at end of file |
|
336 | 336 | profile_list = Profile.objects.filter(state=1) No newline at end of file |
|
337 | 337 | return render_to_response('abscontrol/import.html', {'profile_list': profile_list,}, context_instance=RequestContext(request)) No newline at end of file |
|
338 | 338 | No newline at end of file |
|
339 | 339 | def upload(request): No newline at end of file |
|
340 | 340 | profile_list = Profile.objects.filter(state=1) No newline at end of file |
|
341 | 341 | if request.method == 'POST': No newline at end of file |
|
342 | 342 | txtFilename = request.FILES['txtFile'] No newline at end of file |
|
343 | 343 | if txtFilename: No newline at end of file |
|
344 | 344 | destination = open('/tmp/'+txtFilename.name, 'wb+') No newline at end of file |
|
345 | 345 | for chunk in txtFilename.chunks(): No newline at end of file |
|
346 | 346 | destination.write(chunk) No newline at end of file |
|
347 | 347 | destination.close() No newline at end of file |
|
348 | 348 | filename = '/tmp/'+txtFilename.name No newline at end of file |
|
349 | 349 | readFile = readABSFile(filename) No newline at end of file |
|
350 | 350 | expName, num_patterns, patterns = readFile.getMetadata() No newline at end of file |
|
351 | 351 | No newline at end of file |
|
352 | 352 | if expName != "" and num_patterns > 0: No newline at end of file |
|
353 | 353 | if len(Profile.objects.filter(name__iexact=expName)) > 0: No newline at end of file |
|
354 | 354 | txtError = "Experiment's name found." No newline at end of file |
|
355 | 355 | return render_to_response('abscontrol/error.html', {'profile_list': profile_list, No newline at end of file |
|
356 | 356 | 'txtError' : txtError, }, No newline at end of file |
|
357 | 357 | context_instance=RequestContext(request)) No newline at end of file |
|
358 | 358 | else: No newline at end of file |
|
359 | 359 | newprofile = Profile(name=expName) No newline at end of file |
|
360 | 360 | newprofile.save() No newline at end of file |
|
361 | 361 | newprofile.state = 1 No newline at end of file |
|
362 | 362 | No newline at end of file |
|
363 | 363 | for element in patterns: No newline at end of file |
|
364 | 364 | newpattern = newprofile.pattern_set.create(value=element["number"]) No newline at end of file |
|
365 | 365 | newpattern.antennaup_set.create(value=element["up"]) No newline at end of file |
|
366 | 366 | newpattern.antennadown_set.create(value=element["down"]) No newline at end of file |
|
367 | 367 | No newline at end of file |
|
368 | 368 | newprofile.save() No newline at end of file |
|
369 | 369 | No newline at end of file |
|
370 | 370 | newurl = '/abscontrol/edit/%d' % int(newprofile.id) No newline at end of file |
|
371 | 371 | return redirect(newurl) No newline at end of file |
|
372 | 372 | else: No newline at end of file |
|
373 | 373 | txtError = "Experiment's name not found or the number of patterns is 0." No newline at end of file |
|
374 | 374 | return render_to_response('abscontrol/error.html', {'profile_list': profile_list, No newline at end of file |
|
375 | 375 | 'txtError' : txtError, }, No newline at end of file |
|
376 | 376 | context_instance=RequestContext(request)) No newline at end of file |
|
377 | 377 | else: No newline at end of file |
|
378 | 378 | txtError = "No file." No newline at end of file |
|
379 | 379 | No newline at end of file |
|
380 | 380 | return render_to_response('abscontrol/error.html', {'profile_list': profile_list, 'txtError' : txtError, }, No newline at end of file |
|
381 | 381 | context_instance=RequestContext(request)) No newline at end of file |
|
382 | 382 | No newline at end of file |
|
383 | 383 | def getImgfromOverJRO(profile_id, objAntenna): No newline at end of file |
|
384 | 384 | objProfile = Profile.objects.get(pk=profile_id) No newline at end of file |
|
385 | 385 | exp_name = objProfile.name No newline at end of file |
|
386 | 386 | phase_tx = objAntenna.value No newline at end of file |
|
387 | 387 | gain_tx = objAntenna.tx No newline at end of file |
|
388 | 388 | gain_rx = objAntenna.rx No newline at end of file |
|
389 | 389 | ues_tx = objAntenna.ues No newline at end of file |
|
390 | 390 | just_rx = objAntenna.only_rx No newline at end of file |
|
391 | 391 | No newline at end of file |
|
392 | 392 | overjro = OverJRO() No newline at end of file |
|
393 | 393 | overjro.setParameters(settings.MEDIA_ROOT, exp_name, phase_tx, gain_tx, gain_rx, ues_tx, just_rx) No newline at end of file |
|
394 | 394 | contentFile = overjro.setTextContent() No newline at end of file |
|
395 | 395 | finalpath = overjro.saveFile(contentFile) No newline at end of file |
|
396 | 396 | No newline at end of file |
|
397 | 397 | currentdate = datetime.today() No newline at end of file |
|
398 | 398 | newOverJro = overJroShow() No newline at end of file |
|
399 | 399 | newOverJro.setInputParameters(settings.MEDIA_ROOT, currentdate, finalpath) No newline at end of file |
|
400 | 400 | newOverJro.setupParameters() No newline at end of file |
|
401 | 401 | newOverJro.execute() No newline at end of file |
|
402 | 402 | path = newOverJro.getPlot() No newline at end of file |
|
403 | 403 | No newline at end of file |
|
404 | 404 | return path No newline at end of file |
|
405 | 405 | No newline at end of file |
|
406 | 406 | def overJROUp(request, profile_id, pattern_id, antenna_id): No newline at end of file |
|
407 | 407 | objAntenna = AntennaUp.objects.get(pk=antenna_id) No newline at end of file |
|
408 | 408 | img_path = getImgfromOverJRO(profile_id, objAntenna) No newline at end of file |
|
409 | 409 | filename = os.path.split(img_path)[1] No newline at end of file |
|
410 | 410 | return render_to_response('abscontrol/overjro_up.html', {'img_up': filename,'antennaUp': objAntenna,}, No newline at end of file |
|
411 | 411 | context_instance=RequestContext(request)) No newline at end of file |
|
412 | 412 | No newline at end of file |
|
413 | 413 | def overJRODown(request, profile_id, pattern_id, antenna_id): No newline at end of file |
|
414 | 414 | objAntenna = AntennaDown.objects.get(pk=antenna_id) No newline at end of file |
|
415 | 415 | img_path = getImgfromOverJRO(profile_id, objAntenna) No newline at end of file |
|
416 | 416 | filename = os.path.split(img_path)[1] No newline at end of file |
|
417 | 417 | return render_to_response('abscontrol/overjro_down.html', {'img_down': filename, 'antennaDown': objAntenna,}, No newline at end of file |
|
418 | 418 | context_instance=RequestContext(request)) No newline at end of file |
|
419 | 419 | No newline at end of file |
|
420 | 420 | def export(request, profile_id): No newline at end of file |
|
421 | 421 | listPatterns = [] No newline at end of file |
|
422 | 422 | objProfile = Profile.objects.get(pk=profile_id) No newline at end of file |
|
423 | 423 | exp_name = objProfile.name No newline at end of file |
|
424 | 424 | lsPatterns = objProfile.pattern_set.all() No newline at end of file |
|
425 | 425 | for element in lsPatterns: No newline at end of file |
|
426 | 426 | objAntennaUp = element.antennaup_set.get() No newline at end of file |
|
427 | 427 | objAntennaDown = element.antennadown_set.get() No newline at end of file |
|
428 | 428 | dicPatterns = {"number" : element.value, "up" : objAntennaUp.value, "down" : objAntennaDown.value} No newline at end of file |
|
429 | 429 | listPatterns.append(dicPatterns) No newline at end of file |
|
430 | 430 | No newline at end of file |
|
431 | 431 | absFile = saveABSFile() No newline at end of file |
|
432 | 432 | absFile.setParameters(settings.MEDIA_ROOT, exp_name, listPatterns) No newline at end of file |
|
433 | 433 | filename, filesize = absFile.save() No newline at end of file |
|
434 | 434 | No newline at end of file |
|
435 | 435 | wrapper = FileWrapper( open( filename, "r" ) ) No newline at end of file |
|
436 | 436 | content_type = mimetypes.guess_type( filename )[0] No newline at end of file |
|
437 | 437 | No newline at end of file |
|
438 | 438 | response = HttpResponse(wrapper, content_type = content_type) No newline at end of file |
|
439 | 439 | response['Content-Description'] = 'File Transfer' No newline at end of file |
|
440 | 440 | response['Content-Disposition'] = 'attachment; filename=%s' % smart_str(filename) No newline at end of file |
|
441 | 441 | response['Content-Transfer-Encoding'] = 'binary' No newline at end of file |
|
442 | 442 | response['Expires'] = '0' No newline at end of file |
|
443 | 443 | response['Cache-Control'] = 'must-revalidate' No newline at end of file |
|
444 | 444 | response['Pragma'] = 'public' No newline at end of file |
|
445 | 445 | response['Content-Length'] = '%s' % str(filesize) No newline at end of file |
|
446 | 446 | response['X-Sendfile'] = '%s' % smart_str(filename) No newline at end of file |
|
447 | 447 | No newline at end of file |
|
448 | 448 | return response No newline at end of file |
|
449 | 449 | No newline at end of file |
|
450 | 450 | def send(request, profile_id): No newline at end of file |
|
451 | 451 | listPatterns = [] No newline at end of file |
|
452 | 452 | objProfile = Profile.objects.get(pk=profile_id) No newline at end of file |
|
453 | 453 | exp_name = objProfile.name No newline at end of file |
|
454 | 454 | No newline at end of file |
|
455 | 455 | lsPatterns = objProfile.pattern_set.all() No newline at end of file |
|
456 | 456 | for element in lsPatterns: No newline at end of file |
|
457 | 457 | objAntennaUp = element.antennaup_set.get() No newline at end of file |
|
458 | 458 | objAntennaDown = element.antennadown_set.get() No newline at end of file |
|
459 | 459 | dicPatterns = {"number" : element.value, "up" : objAntennaUp.value, "down" : objAntennaDown.value} No newline at end of file |
|
460 | 460 | listPatterns.append(dicPatterns) No newline at end of file |
|
461 | 461 | No newline at end of file |
|
462 | 462 | absFile = saveABSFile() No newline at end of file |
|
463 | 463 | absFile.setParameters(settings.MEDIA_ROOT, exp_name, listPatterns) No newline at end of file |
|
464 | 464 | filename, filesize = absFile.save() No newline at end of file |
|
465 | 465 | No newline at end of file |
|
466 | 466 | apiclient = sendFile() No newline at end of file |
|
467 | 467 | apiclient.execute(filename) No newline at end of file |
|
468 | 468 | output = apiclient.getOutput() No newline at end of file |
|
469 | 469 | No newline at end of file |
|
470 | 470 | if output == "OK": No newline at end of file |
|
471 | 471 | message = "File sent successfully." No newline at end of file |
|
472 | 472 | lsProfilesActive = Profile.objects.filter(is_active=1) No newline at end of file |
|
473 | 473 | if len(lsProfilesActive) > 0: No newline at end of file |
|
474 | 474 | objProfileActive = Profile.objects.get(is_active=1) No newline at end of file |
|
475 | 475 | objProfileActive.is_active = 0 No newline at end of file |
|
476 | 476 | objProfileActive.save() No newline at end of file |
|
477 | 477 | No newline at end of file |
|
478 | lsPatternsActive = Pattern.objects.filter(is_active=1) | |
|
No newline at end of file | ||
|
479 | if len(lsPatternsActive) > 0: | |
|
No newline at end of file | ||
|
480 | objPatternActive = Pattern.objects.get(is_active=1) | |
|
No newline at end of file | ||
|
481 | objPatternActive.is_active = 0 | |
|
No newline at end of file | ||
|
482 | objPatternActive.save() | |
|
No newline at end of file | ||
|
483 | No newline at end of file | |
|
478 | 484 | objProfile.hits += 1 No newline at end of file |
|
479 | 485 | objProfile.is_active = 1 No newline at end of file |
|
480 | 486 | objProfile.save() No newline at end of file |
|
481 | 487 | No newline at end of file |
|
482 | 488 | pattern_value = 1 No newline at end of file |
|
483 | 489 | patternChoosen = objProfile.pattern_set.get(value=pattern_value) No newline at end of file |
|
484 | 490 | patternChoosen.is_active = 1 No newline at end of file |
|
485 | 491 | patternChoosen.save() No newline at end of file |
|
486 | 492 | No newline at end of file |
|
487 | 493 | newurl = '/abscontrol/view/%d' % int(profile_id) No newline at end of file |
|
488 | 494 | No newline at end of file |
|
489 | 495 | return redirect(newurl) No newline at end of file |
|
490 | 496 | else: No newline at end of file |
|
491 | 497 | message = "Error sending file." No newline at end of file |
|
492 | 498 | No newline at end of file |
|
493 | 499 | profile_list = Profile.objects.all() No newline at end of file |
|
494 | 500 | No newline at end of file |
|
495 | 501 | return render_to_response('abscontrol/sendFile.html', {'message': message, "profile_list" : profile_list, No newline at end of file |
|
496 | 502 | 'objProfile': objProfile, No newline at end of file |
|
497 | 503 | }, context_instance=RequestContext(request)) No newline at end of file |
|
498 | 504 | No newline at end of file |
|
499 | 505 | def changePattern(request, profile_id, pattern_id): No newline at end of file |
|
500 | 506 | patternChoosen = Pattern.objects.get(id=pattern_id) No newline at end of file |
|
501 | 507 | beam = int(patternChoosen.value)-1 No newline at end of file |
|
502 | 508 | No newline at end of file |
|
503 | 509 | apiclient = changeBeam() No newline at end of file |
|
504 | 510 | apiclient.execute(str(beam)) No newline at end of file |
|
505 | 511 | output = apiclient.getOutput() No newline at end of file |
|
506 | 512 | No newline at end of file |
|
507 | 513 | if output == "OK": No newline at end of file |
|
508 | 514 | lsPatternsActive = Pattern.objects.filter(is_active=1) No newline at end of file |
|
509 | 515 | if len(lsPatternsActive) > 0: No newline at end of file |
|
510 | 516 | objPatternActive = Pattern.objects.get(is_active=1) No newline at end of file |
|
511 | 517 | objPatternActive.is_active = 0 No newline at end of file |
|
512 | 518 | objPatternActive.save() No newline at end of file |
|
513 | 519 | No newline at end of file |
|
514 | 520 | patternChoosen.hits += 1 No newline at end of file |
|
515 | 521 | patternChoosen.is_active = 1 No newline at end of file |
|
516 | 522 | patternChoosen.save() No newline at end of file |
|
517 | 523 | No newline at end of file |
|
518 | 524 | newurl = '/abscontrol/%d/view/%d/' % (int(profile_id), int(pattern_id)) No newline at end of file |
|
519 | 525 | return redirect(newurl) No newline at end of file |
|
520 | 526 | else: No newline at end of file |
|
521 | 527 | message = "Error sending file." No newline at end of file |
|
522 | 528 | profile_list = Profile.objects.all() No newline at end of file |
|
523 | 529 | return render_to_response('abscontrol/sendFile.html', {'message': message, "profile_list" : profile_list, No newline at end of file |
|
524 | 530 | }, context_instance=RequestContext(request)) No newline at end of file |
|
525 | 531 | No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now