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