Skip to content

Commit

Permalink
Removed events arg
Browse files Browse the repository at this point in the history
  • Loading branch information
Oghenefego Ahia authored and Oghenefego Ahia committed Dec 17, 2016
2 parents 156ac39 + cd61056 commit 60f731c
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 47 deletions.
21 changes: 10 additions & 11 deletions cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
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, gameTraffic, location, timeout):
def __init__(self, gameTraffic, location, timeout, num_players):

self.requestList = Queue.Queue()

Expand All @@ -21,29 +20,29 @@ def __init__(self, gameTraffic, location, timeout):
else:
self.timeToProcess = HIGH_P_CLOUD_DELAY

self.num_players = num_players
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):
return self.processResponse(time)

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

# update packet
newPacket.sendAddress = 0
newPacket.receiveAddress = i
responsePackets[i].append(newPacket)
responsePackets.append(newPacket)
return responsePackets
else:
return None
Expand Down
44 changes: 25 additions & 19 deletions device.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from game import Game
from packet import Packet
import Cloud

class Device(object):

Expand All @@ -8,42 +9,47 @@ def __init__(self, deviceID, hwTier, eventsPerSec, location):
self.hwTier = hwTier
self.eventsPerSec = eventsPerSec
self.location = location
self.position = (deviceID * 10, )
self.timeMS = 0

def getSpecsForGame(game):
pass
def updateTime(self, time):
self.timeMS = time

return processResponse(self)

def sendPacket():
packet = Packet((5,50), , deviceID)
def processResponse():
if self.timeMS % eventsPerSec == 0:
packet = Packet(self.position, self.timeMS, 0, self.deviceID)
return packet
return None

def run():
sendPacket()
def movePlayer():




class OculusRift(Device):
def __init__(self, deviceID, hwTier, eventsPerSec, location):
super(OculusRift, self).__init__(deviceID, 90, eventsPerSec, location)
def __init__(self, deviceID, location):
super(OculusRift, self).__init__(deviceID, 90, 5, location)

class HTCVive(Device):
def __init__(self, deviceID, hwTier, eventsPerSec, location):
super(HTCVive, self).__init__(deviceID, 90, eventsPerSec, location)
def __init__(self, deviceID, location):
super(HTCVive, self).__init__(deviceID, 90, 5, location)

class PlayStationVR(Device):
def __init__(self, deviceID, hwTier, eventsPerSec, location):
super(PlayStationVR, self).__init__(deviceID, 120, eventsPerSec, location)
def __init__(self, deviceID, location):
super(PlayStationVR, self).__init__(deviceID, 120, 5, location)

class LG360VR(Device):
def __init__(self, deviceID, hwTier, eventsPerSec, location):
super(LG360VR, self).__init__(deviceID, 120, eventsPerSec, location)
def __init__(self, deviceID, location):
super(LG360VR, self).__init__(deviceID, 120, 5, location)

class GearVR(Device):
def __init__(self, deviceID, hwTier, eventsPerSec, location):
super(GearVR, self).__init__(deviceID, 60, eventsPerSec, location)
def __init__(self, deviceID, location):
super(GearVR, self).__init__(deviceID, 60, 5, location)

class VisusVR(Device):
def __init__(self, deviceID, hwTier, eventsPerSec, location):
super(VisusVR, self).__init__(deviceID, 60, eventsPerSec, location)
def __init__(self, deviceID, location):
super(VisusVR, self).__init__(deviceID, 60, 5, location)

devices = {
"OculusRift" : OculusRift(),
Expand Down
2 changes: 1 addition & 1 deletion packet.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class Packet(object):

def __init__(self, position, timestamp, receiverAddress, senderAddress):
def __init__(self, timestamp, position, receiverAddress, senderAddress):
self._init_packet_id()
self.timestamp = timestamp
self.position = position
Expand Down
26 changes: 10 additions & 16 deletions testCloud.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
import cloud

import packet

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)

packet1 = packet.Packet(0, 100, 0, 0, 1)
packet2 = packet.Packet(0, 0, 0, 0, 2)
cloud = cloud.Cloud(0, 0, 10, 10)
cloud.receiveRequest(packet1)

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

time = 90
time = 90

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



0 comments on commit 60f731c

Please sign in to comment.