root/ossiedev/branches/jsnyder/trunk/tools/cornetApps/HtmlPages/views.py @ 11092

Revision 11092, 3.8 KB (checked in by edent, 14 months ago)

add ports and ip when loading node

Line 
1#Create your views here
2
3from django.shortcuts import render_to_response
4from django.template import RequestContext
5from wavedash.src.WavedashController import Controller
6import wavedash.src.WaveformModel
7from django.contrib.auth.decorators import login_required
8
9"""Creates views to display the nodes
10Gets the status of the nodes
11Creates the tuples for each node position for the maps.
12"""
13
14"""
15Returns 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"""
18def 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"""
26Returns 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"""
29def 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"""
39Get status of nodes
40"""
41def 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'''
50Displays the static ossie interface page, which also has the javascript built into it.
51'''
52def ossie_view(request):
53        return render_to_response("HtmlPages/ossie.html", locals(), context_instance=RequestContext(request))
54
55'''
56Declares the pixel value location of the nodes relative to the map.
57Each coordinate is (x,y) where x is the width and y is the height from the relative origin
58Also sets the floor_list with setFloorNodes()
59'''
60def 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"""
70Defines a range for how many nodes are on each floor.
71Also sets the floor_list with setFloorNodes()
72"""
73def 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"""
79Testing
80"""
81def 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
85def properties_page(request):
86        return render_to_response('HtmlPages/properties.html', locals(), context_instance=RequestContext(request))
87
88def tasks_page(request):
89        return render_to_response('HtmlPages/tasks.html', locals(), context_instance=RequestContext(request))
90
91def 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))
Note: See TracBrowser for help on using the browser.