| 1 | #Create your views here |
|---|
| 2 | |
|---|
| 3 | from django.shortcuts import render_to_response |
|---|
| 4 | from django.template import RequestContext |
|---|
| 5 | from wavedash.src.WavedashController import Controller |
|---|
| 6 | import wavedash.src.WaveformModel |
|---|
| 7 | from django.contrib.auth.decorators import login_required |
|---|
| 8 | |
|---|
| 9 | """Creates views to display the nodes |
|---|
| 10 | Gets the status of the nodes |
|---|
| 11 | Creates the tuples for each node position for the maps. |
|---|
| 12 | """ |
|---|
| 13 | |
|---|
| 14 | """ |
|---|
| 15 | Returns the floor_list array which stores the status of the node as ip of the node. |
|---|
| 16 | @return the floor_list array that has the ip address of the node. |
|---|
| 17 | """ |
|---|
| 18 | def setFloorNodes(): |
|---|
| 19 | floorBuffer = 10 #used to calculate the ip address of the node |
|---|
| 20 | floor1_usrp_status=[0,0,0,1,0,0,0,0,0,1,0,0] |
|---|
| 21 | floor2_usrp_status=[1,1,0,1,0,1,0,1,0,0,1,0] |
|---|
| 22 | floor3_usrp_status=[1,1,1,1,1,1,1,0,1,0,0,1] |
|---|
| 23 | floor4_usrp_status=[1,0,1,1,0,0,1,0,0,1,0,0] |
|---|
| 24 | floor_list=[floor1_usrp_status, floor2_usrp_status, floor3_usrp_status, floor4_usrp_status] |
|---|
| 25 | for floor in floor_list: |
|---|
| 26 | for index in range(len(floor)): |
|---|
| 27 | floor[index] = floor[index]*(index+1+floorBuffer) |
|---|
| 28 | floorBuffer += 12 |
|---|
| 29 | return floor_list |
|---|
| 30 | |
|---|
| 31 | ''' |
|---|
| 32 | Displays the static ossie interface page, which also has the javascript built into it. |
|---|
| 33 | ''' |
|---|
| 34 | def ossie_view(request): |
|---|
| 35 | return render_to_response("HtmlPages/ossie.html", locals(), context_instance=RequestContext(request)) |
|---|
| 36 | |
|---|
| 37 | ''' |
|---|
| 38 | Declares the pixel value location of the nodes relative to the map. |
|---|
| 39 | Each coordinate is (x,y) where x is the width and y is the height from the relative origin |
|---|
| 40 | Also sets the floor_list with setFloorNodes() |
|---|
| 41 | ''' |
|---|
| 42 | def map_view(request, floor_num): |
|---|
| 43 | floor=floor_num |
|---|
| 44 | node_position_1 = ((169,711),(170,651),(170,597),(211,576),(170,512),(170,449),(190,394),(170,334),(194,298),(170,247),(192,210),(158,145)) |
|---|
| 45 | node_position_2 = ((168,708),(168,639),(168,590),(200,542),(168,508),(204,431),(229,400),(168,338),(204,324),(204,273),(204,228),(204,193)) |
|---|
| 46 | node_position_3 = ((175,705),(175,653),(175,598),(206,558),(175,518),(209,452),(236,404),(158,377),(209,333),(210,285),(209,250),(207,206)) |
|---|
| 47 | node_position_4 = ((184,712),(184,666),(184,613),(219,557),(184,517),(222,437),(248,405),(168,372),(221,335),(220,275),(214,226),(219,190)) |
|---|
| 48 | floor_list = setFloorNodes() |
|---|
| 49 | return render_to_response("HtmlPages/map.html", locals(), context_instance=RequestContext(request)) |
|---|
| 50 | |
|---|
| 51 | """ |
|---|
| 52 | Defines a range for how many nodes are on each floor. |
|---|
| 53 | Also sets the floor_list with setFloorNodes() |
|---|
| 54 | """ |
|---|
| 55 | def grid_view(request): |
|---|
| 56 | number_of_nodes=range(1,13) |
|---|
| 57 | floor_list = setFloorNodes() |
|---|
| 58 | return render_to_response("HtmlPages/grid.html", locals(), context_instance=RequestContext(request)) |
|---|
| 59 | |
|---|
| 60 | """ |
|---|
| 61 | Testing |
|---|
| 62 | """ |
|---|
| 63 | def node_menu(request): |
|---|
| 64 | nodes=[Node(id=3-1, ip=33), |
|---|
| 65 | Node(id=3-2, ip=34), |
|---|
| 66 | Node(id=3-3, ip=35), |
|---|
| 67 | Node(id=3-4, ip=36), |
|---|
| 68 | Node(id=3-5, ip=37), |
|---|
| 69 | Node(id=3-6, ip=38)] |
|---|
| 70 | return render_to_response("HtmlPages/node_menu.html", locals(), context_instance=RequestContext(request)) |
|---|
| 71 | |
|---|
| 72 | #@login_required |
|---|
| 73 | def loadNode(request, node_num): |
|---|
| 74 | return render_to_response("HtmlPages/nodes.html", locals(), context_instance=RequestContext(request)) |
|---|
| 75 | |
|---|
| 76 | def properties_page(request): |
|---|
| 77 | return render_to_response('HtmlPages/properties.html', locals(), context_instance=RequestContext(request)) |
|---|
| 78 | |
|---|
| 79 | def tasks_page(request): |
|---|
| 80 | return render_to_response('HtmlPages/tasks.html', locals(), context_instance=RequestContext(request)) |
|---|
| 81 | |
|---|
| 82 | def workspace_page(request): |
|---|
| 83 | return render_to_response('HtmlPages/workspace.html', locals(), context_instance=RequestContext(request)) |
|---|
| 84 | |
|---|
| 85 | #@login_required |
|---|
| 86 | #def views_page(request, view_type): |
|---|
| 87 | # view = view_type |
|---|
| 88 | # floor_list = setFloorNodes() |
|---|
| 89 | # grid=range(1,13) |
|---|
| 90 | # node_positions_floor_1 = ((169,711),(170,651),(170,597),(211,576),(170,512),(170,449),(190,394),(170,334),(194,298),(170,247),(192,210),(158,145)) |
|---|
| 91 | # return render_to_response('HtmlPages/views.html', locals(), context_instance=RequestContext(request)) |
|---|