-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpipe.py
More file actions
24 lines (18 loc) · 731 Bytes
/
pipe.py
File metadata and controls
24 lines (18 loc) · 731 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import simpy
from utils import getTransmissionDelay
class Pipe(object):
"""This class represents the propagation through a cable."""
def __init__(self, env, identifier, allNodes):
self.env = env
self.allNodes = allNodes
self.identifier = identifier
self.store = simpy.Store(self.env)
def latencyPut(self, value, delay):
yield self.env.timeout(delay)
return self.store.put(value)
def put(self, value, sourceLocation):
destLocation = self.allNodes[self.identifier].location
delay = getTransmissionDelay(sourceLocation, destLocation)
return self.env.process(self.latencyPut(value, delay))
def get(self):
return self.store.get()