Skip to content

Commit

Permalink
Cloud class defined and test function for the cloud started.
Browse files Browse the repository at this point in the history
  • Loading branch information
janton01 committed Dec 17, 2016
1 parent a327c48 commit ee84a14
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 12 deletions.
60 changes: 48 additions & 12 deletions cloud.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,53 @@
import Queue

# these delays can be seen as the time response time of the server for each game
# being played

HI_P_CLOUD_DELAY = 10
MED_P_CLOUD_DELAY = 5
LOW_P_CLOUD_DELAY = 3
NUM_PLAYERS = 10
ks
class Cloud(object):

def __init__(self, processor, gpu):
self.processor = processor
self.gpu = gpu
def __init__(self, gameTraffic, location, timeout):

self.requestList = Queue.Queue()

if gameTraffic == 0:
self.timeToProcess = LOW_P_CLOUD_DELAY
elif gameTraffic == 1:
self.timeToProcess = MED_P_CLOUD_DELAY
else:
self.timeToProcess = HIGH_P_CLOUD_DELAY

self.location = location
self.timeMS = 0
self.timeout = timeout

def updateTime(self, time): # is this how it works?
self.timeMS = time
return processResponse(self)

def processResponse(self):

if self.timeMS % timeToProcess == 0 and not self.requestList.empty() :
headPacket = self.requestList.get();
if (time - headPacket.timestamp) > timeout:
return None
else:
responsePackets[]
for i in range(1,NUM_PLAYERS):
newPacket = headPacket

def processData(self, data):
# Determine how much time it takes to process
time = data / gpu
# update packet
newPacket.sendAddress = 0
newPacket.receiveAddress = i
responsePackets[i].append(newPacket)
return responsePackets
else:
return None

class AmazonWebService(Cloud):
def __init__(self):
super(AmazonWebService, self).__init__(3.5, 780)
def receiveRequest(self, packet): # can this access
self.requestList.put(packet)

clouds = {
"aws" : AmazonWebService()
}
28 changes: 28 additions & 0 deletions testCloud.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import cloud


if __name__ == "__main__":
packet1.id = 0
packet1.sendAddress = 1
packet1.receiveAddress = 0
packet1.timestamp = 100
packet2.id = 1
packet2.sendAddress = 2
packet2.receiveAddress = 0
packet2.timestamp = 0

cloud = Cloud(0, 0, 10)

cloud.receiveRequest(packet1)
cloud.receiveRequest(packet2)

time = 90

for i in range(0,10):
time = time + 1
packetList = cloud.updateTime(time)
if packetList != None:
print packetList[0].id



0 comments on commit ee84a14

Please sign in to comment.