| 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 number of the node. |
|---|
| 17 | """ |
|---|
| 18 | def setFloorNodes(): |
|---|
| 19 | floor_list=getNodeStatus() |
|---|
| 20 | for floor in floor_list: |
|---|
| 21 | for index in range(len(floor)): |
|---|
| 22 | floor[index] = floor[index]*(index+1) |
|---|
| 23 | return floor_list |
|---|
| 24 | |
|---|
| 25 | """ |
|---|
| 26 | Returns the floor_list array which stores the status of the node as ip of the node. |
|---|
| 27 | @return the floor_list array that has the ip address of the node. |
|---|
| 28 | """ |
|---|
| 29 | def setFloorNodeIP(): |
|---|
| 30 | floorBuffer = 10 #used to calculate the ip address of the node |
|---|
| 31 | floor_list=getNodeStatus() |
|---|
| 32 | for floor in floor_list: |
|---|
| 33 | for index in range(len(floor)): |
|---|
| 34 | floor[index] = floor[index]*(index+1+floorBuffer) |
|---|
| 35 | floorBuffer += 12 |
|---|
| 36 | return floor_list |
|---|
| 37 | |
|---|
| 38 | """ |
|---|
| 39 | Get status of nodes |
|---|
| 40 | """ |
|---|
| 41 | def getNodeStatus(): |
|---|
| 42 | floor1_usrp_status=[0,0,0,1,0,0,0,0,0,1,0,0] |
|---|
| 43 | floor2_usrp_status=[1,1,0,1,0,1,0,1,0,0,1,0] |
|---|
| 44 | floor3_usrp_status=[1,1,1,1,1,1,1,0,1,0,0,1] |
|---|
| 45 | floor4_usrp_status=[1,0,1,1,0,0,1,0,0,1,0,0] |
|---|
| 46 | floor_list=[floor1_usrp_status, floor2_usrp_status, floor3_usrp_status, floor4_usrp_status] |
|---|
| 47 | return floor_list |
|---|
| 48 | |
|---|
| 49 | ''' |
|---|
| 50 | Displays the static ossie interface page, which also has the javascript built into it. |
|---|
| 51 | ''' |
|---|
| 52 | def ossie_view(request): |
|---|
| 53 | return render_to_response("HtmlPages/ossie.html", locals(), context_instance=RequestContext(request)) |
|---|
| 54 | |
|---|
| 55 | ''' |
|---|
| 56 | Declares the pixel value location of the nodes relative to the map. |
|---|
| 57 | Each coordinate is (x,y) where x is the width and y is the height from the relative origin |
|---|
| 58 | Also sets the floor_list with setFloorNodes() |
|---|
| 59 | ''' |
|---|
| 60 | def map_view(request, floor_num): |
|---|
| 61 | floor=floor_num |
|---|
| 62 | 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)) |
|---|
| 63 | 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)) |
|---|
| 64 | 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)) |
|---|
| 65 | 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)) |
|---|
| 66 | floor_list = setFloorNodeIP() |
|---|
| 67 | return render_to_response("HtmlPages/map.html", locals(), context_instance=RequestContext(request)) |
|---|
| 68 | |
|---|
| 69 | """ |
|---|
| 70 | Defines a range for how many nodes are on each floor. |
|---|
| 71 | Also sets the floor_list with setFloorNodes() |
|---|
| 72 | """ |
|---|
| 73 | def grid_view(request): |
|---|
| 74 | number_of_nodes=range(1,13) |
|---|
| 75 | floor_list = setFloorNodes() |
|---|
| 76 | return render_to_response("HtmlPages/grid.html", locals(), context_instance=RequestContext(request)) |
|---|
| 77 | |
|---|
| 78 | """ |
|---|
| 79 | Testing |
|---|
| 80 | """ |
|---|
| 81 | def node_menu(request): |
|---|
| 82 | nodes=[Node(id=3-1, ip=33),] |
|---|
| 83 | return render_to_response("HtmlPages/node_menu.html", locals(), context_instance=RequestContext(request)) |
|---|
| 84 | |
|---|
| 85 | def properties_page(request): |
|---|
| 86 | return render_to_response('HtmlPages/properties.html', locals(), context_instance=RequestContext(request)) |
|---|
| 87 | |
|---|
| 88 | def tasks_page(request): |
|---|
| 89 | return render_to_response('HtmlPages/tasks.html', locals(), context_instance=RequestContext(request)) |
|---|
| 90 | |
|---|
| 91 | def workspace_page(request): |
|---|
| 92 | return render_to_response('HtmlPages/workspace.html', locals(), context_instance=RequestContext(request)) |
|---|
| 93 | |
|---|
| 94 | #@login_required |
|---|
| 95 | #def views_page(request, view_type): |
|---|
| 96 | # view = view_type |
|---|
| 97 | # floor_list = setFloorNodes() |
|---|
| 98 | # grid=range(1,13) |
|---|
| 99 | # 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)) |
|---|
| 100 | # return render_to_response('HtmlPages/views.html', locals(), context_instance=RequestContext(request)) |
|---|