This repository has been archived by the owner on May 21, 2020. It is now read-only.
/
scene.py
139 lines (113 loc) · 6.32 KB
/
scene.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# scene.py
#
# Copyright 2011 Christopher Benninger <chrisbenninger@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
#
import sys
import time
from visual import *
from worker import Worker
#from server import Server
from webserver import WebServer
from scenedefs import SceneDefs
class Scene():
def __init__(self):
#Scene Vars
self.scenedefs = SceneDefs(400,400,400)
self.dims = self.scenedefs.getSceneDimensions()
self.id = 0
#Actor Vars
#self.objList = []
self.threadList = []
#Walls
self.xWall = box(pos=(0,self.dims[1]/2,self.dims[2]/2), size=(0.01,self.dims[0],self.dims[1]), axis=(1,0,0),color=color.blue, opacity=0.07)
self.yWall = box(pos=(self.dims[0]/2,0,self.dims[2]/2), size=(0.01,self.dims[0],self.dims[2]), axis=(0,1,0),color=color.red, opacity=0.05)
self.zWall = box(pos=(self.dims[0]/2,self.dims[1]/2,0), size=(0.01,self.dims[1],self.dims[2]), axis=(0,0,1),color=color.green, opacity=0.03)
#self.lamp = local_light(pos=(self.dims[0],self.dims[1],self.dims[2]), color=color.yellow)
self.xAxis = cylinder(pos=(0,0,0), radius=2, axis=(self.dims[0],0,0),color=color.white, opacity=0.3)
self.yAxis = cylinder(pos=(0,0,0), radius=2, axis=(0,self.dims[0],0),color=color.white, opacity=0.3)
self.zAxis = cylinder(pos=(0,0,0), radius=2, axis=(0,0,self.dims[0]),color=color.white, opacity=0.3)
self.origin = label(text='0%', pos=(0,0,0),align='center', depth=-0.3, color=color.white,yoffset=-5,box=False,line=True,height=5,opacity=0.1)
self.xAxisText = label(text='Mem', pos=self.xAxis.axis,align='center', depth=-0.3, color=color.blue, yoffset=5, xoffset=10,box=False,line=True,height=7)
self.xAxis1 = label(text='100%', pos=(self.dims[0],0,0),align='center', depth=-0.3, color=(0.5, 0.5, 0.5),yoffset=-5,box=False,line=True,height=5,opacity=0.1)
self.xAxis2 = label(text='75%', pos=(self.dims[0]*.75,0,0),align='center', depth=-0.3, color=(0.5, 0.5, 0.5),yoffset=-5,box=False,line=True,height=5,opacity=0.1)
self.xAxis3 = label(text='50%', pos=(self.dims[0]*.5,0,0),align='center', depth=-0.3, color=(0.5, 0.5, 0.5),yoffset=-5,box=False,line=True,height=5,opacity=0.1)
self.xAxis4 = label(text='25%', pos=(self.dims[0]*.25,0,0),align='center', depth=-0.3, color=(0.5, 0.5, 0.5),yoffset=-5,box=False,line=True,height=5,opacity=0.1)
self.yAxisText = label(text='CPU', pos=self.yAxis.axis,align='center', depth=-0.3, color=color.red, xoffset=5, yoffset=10,box=False,line=True,height=7)
self.yAxis1 = label(text='100%', pos=(0,self.dims[0],0),align='center', depth=-0.3, color=(0.5, 0.5, 0.5),xoffset=-5,box=False,line=True,height=5,opacity=0.1)
self.yAxis2 = label(text='75%', pos=(0,self.dims[0]*.75,0),align='center', depth=-0.3, color=(0.5, 0.5, 0.5),xoffset=-5,box=False,line=True,height=5,opacity=0.1)
self.yAxis3 = label(text='50%', pos=(0,self.dims[0]*.5,0),align='center', depth=-0.3, color=(0.5, 0.5, 0.5),xoffset=-5,box=False,line=True,height=5,opacity=0.1)
self.yAxis4 = label(text='25%', pos=(0,self.dims[0]*.25,0),align='center', depth=-0.3, color=(0.5, 0.5, 0.5),xoffset=-5,box=False,line=True,height=5,opacity=0.1)
self.zAxisText = label(text='Disk', pos=self.zAxis.axis,align='center', depth=-0.3, color=color.green, yoffset=5, xoffset=-10,box=False,line=True,height=7)
self.yAxis1 = label(text='100%', pos=(0,0,self.dims[0]),align='center', depth=-0.3, color=(0.5, 0.5, 0.5),yoffset=-5,box=False,line=True,height=5,opacity=0.1)
self.yAxis2 = label(text='75%', pos=(0,0,self.dims[0]*.75),align='center', depth=-0.3, color=(0.5, 0.5, 0.5),yoffset=-5,box=False,line=True,height=5,opacity=0.1)
self.yAxis3 = label(text='50%', pos=(0,0,self.dims[0]*.5),align='center', depth=-0.3, color=(0.5, 0.5, 0.5),yoffset=-5,box=False,line=True,height=5,opacity=0.1)
self.yAxis4 = label(text='25%', pos=(0,0,self.dims[0]*.25),align='center', depth=-0.3, color=(0.5, 0.5, 0.5),yoffset=-5,box=False,line=True,height=5,opacity=0.1)
#LightSource
self.window = display.get_selected()
def close(self):
self.window.destroy()
def addWorker(self,color,radius,script,interval,title):
if(title=="auto"):
title = str(self.id)
self.id += 1
newws = WebServer(color,radius,self,script,interval,title)
newws.start()
self.threadList.append(newws)
def removeAllWorkers(self):
for item in self.threadList:
item.shutdown()
#time.sleep(.5)
self.threadList = []
def incWorkerMeanX(self,title,x):
for item in self.threadList:
if(item.getTitle()==title and item.getWLType()=="norm"):
item.getWLGen().setXMean(item.getWLGen().getXMean()+x)
break
def incWorkerMeanY(self,title,y):
for item in self.threadList:
if(item.getTitle()==title and item.getWLType()=="norm"):
item.getWLGen().setYMean(item.getWLGen().getYMean()+y)
break
def incWorkerMeanZ(self,title,z):
for item in self.threadList:
if(item.getTitle()==title and item.getWLType()=="norm"):
item.getWLGen().setZMean(item.getWLGen().getZMean()+z)
break
def incAllWorkerMeanX(self,x):
for item in self.threadList:
if(item.getWLType()=="norm"):
item.getWLGen().setXMean(item.getWLGen().getXMean()+x)
def incAllWorkerMeanY(self,y):
for item in self.threadList:
if(item.getWLType()=="norm"):
item.getWLGen().setYMean(item.getWLGen().getYMean()+y)
def incAllWorkerMeanZ(self,z):
for item in self.threadList:
if(item.getWLType()=="norm"):
item.getWLGen().setZMean(item.getWLGen().getZMean()+z)
def removeWorker(self,title):
for item in self.threadList:
if(item.getTitle()==title):
item.shutdown()
self.threadList.remove(item)
break
return