@@ -1,5 +1,6 | |||
|
1 | 1 | from django.shortcuts import render_to_response, redirect |
|
2 | 2 | from abscontrol.models import Profile, Pattern, AntennaDown, AntennaUp |
|
3 | from util.readABSFile import readABSFile | |
|
3 | 4 | |
|
4 | 5 | txtAntenna = "[[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5]," \ |
|
5 | 6 | "[1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0]," \ |
@@ -248,6 +249,11 | |||
|
248 | 249 | for chunk in txtFilename.chunks(): |
|
249 | 250 | destination.write(chunk) |
|
250 | 251 | destination.close() |
|
252 | filename = '/tmp/'+txtFilename.name | |
|
253 | readFile = readABSFile(filename) | |
|
254 | expName, num_patterns, patterns = readFile.getMetadata() | |
|
255 | ||
|
256 | ''' | |
|
251 | 257 | f = open('/tmp/'+txtFilename.name, 'r') |
|
252 | 258 | newContent = f.readlines() |
|
253 | 259 | f.close() |
@@ -262,14 +268,14 | |||
|
262 | 268 | num_patterns = line[pos+1:].strip() |
|
263 | 269 | else: |
|
264 | 270 | content += line |
|
265 |
|
|
|
271 | ''' | |
|
266 | 272 | else: |
|
267 | 273 | txtFilename = "Error" |
|
268 | content = "Error" | |
|
274 | #content = "Error" | |
|
269 | 275 | expName = "" |
|
270 | 276 | num_patterns = 0 |
|
271 | 277 | |
|
272 |
return render_to_response('abscontrol/upload.html', {'txtFilename': txtFilename, ' |
|
|
278 | return render_to_response('abscontrol/upload.html', {'txtFilename': txtFilename, 'patterns' : patterns, | |
|
273 | 279 | 'expName' : expName, 'num_patterns' : num_patterns, |
|
274 | 280 | }) |
|
275 | 281 |
@@ -13,9 +13,24 | |||
|
13 | 13 | <p>{{ expName }}</p> |
|
14 | 14 | <label for="lblNumber">Number of patterns:</label> |
|
15 | 15 | <p>{{ num_patterns }}</p> |
|
16 | <label for="lblContent">Content:</label> | |
|
17 | <p>{{ content }}</p> | |
|
18 | 16 | </div> |
|
17 | {% if patterns %} | |
|
18 | <div> | |
|
19 | {% for element in patterns %} | |
|
20 | <div> | |
|
21 | <label for="lblNumber">Pattern: {{ element.number }}</label> | |
|
22 | </div> | |
|
23 | <div> | |
|
24 | <label for="lblAntennaUp">Antenna Up:</label> | |
|
25 | <p>{{ element.up }}</p> | |
|
26 | </div> | |
|
27 | <div> | |
|
28 | <label for="lblAntennaDown">Antenna Down:</label> | |
|
29 | <p>{{ element.down }}</p> | |
|
30 | </div> | |
|
31 | {% endfor %} | |
|
32 | </div> | |
|
33 | {% endif %} | |
|
19 | 34 | </div> |
|
20 | 35 | </div> |
|
21 | 36 | {% endblock %} |
@@ -16,12 +16,14 | |||
|
16 | 16 | self.number_patterns = 0 |
|
17 | 17 | self.patterns = {} |
|
18 | 18 | |
|
19 |
def readFile(self |
|
|
20 |
f = open( |
|
|
19 | def readFile(self): | |
|
20 | f = open(self.fileName, 'r') | |
|
21 | 21 | self.content = f.readlines() |
|
22 | 22 | f.close() |
|
23 | 23 | |
|
24 | 24 | def getMetadata(self): |
|
25 | self.readFile() | |
|
26 | ||
|
25 | 27 | newLine = self.content[0].replace("'","") |
|
26 | 28 | pos = newLine.find("=") |
|
27 | 29 | self.exp_name = newLine[pos+1:].strip() |
@@ -30,6 +32,8 | |||
|
30 | 32 | self.number_patterns = int(self.content[2][pos+1:].strip()) |
|
31 | 33 | |
|
32 | 34 | self.patterns = self.getPatterns(self.content[3:]) |
|
35 | ||
|
36 | return self.exp_name, self.number_patterns, self.patterns | |
|
33 | 37 | |
|
34 | 38 | def getPatterns(self, content): |
|
35 | 39 | lsPattern = [] |
General Comments 0
You need to be logged in to leave comments.
Login now