resume task with list datastructure

parent f636f76c
...@@ -62,7 +62,7 @@ class Network(): ...@@ -62,7 +62,7 @@ class Network():
def simulate(self,time): def simulate(self,time):
# logger.info("simulating .. ") # logger.info("simulating .. ")
self.networkClockTime = time self.networkClockTime = time
# Note links should be simulated before nodes # Note links should be simulated before nodeself.ResumeTasks.append(("nextOn", self.startNodeLifeCycleGenerator,))s
# in order to receive the messge which is supposed to be received in this tick # in order to receive the messge which is supposed to be received in this tick
for link in self.links.values(): for link in self.links.values():
link.simulate(time) link.simulate(time)
......
...@@ -86,6 +86,19 @@ class Node(SystemEntity): ...@@ -86,6 +86,19 @@ class Node(SystemEntity):
# check if main ba* has to be resumed or not # check if main ba* has to be resumed or not
try:
ResumeTask = self.ResumeTasks.pop(0)
command = self.commands.get(ResumeTask[0])
ResumeOut = command(time,ResumeTask[1:])
if ResumeOut and ResumeOut[0] == "resume":
self.logger.info("resume has been called")
self.ResumeTasks.append(("nextOn", self.startNodeLifeCycleGenerator,))
except KeyError as ke:
# not task pending at this time
pass
except StopIteration as si:
pass
# TODO : perform task from todolist which are relevant for current tick # TODO : perform task from todolist which are relevant for current tick
......
...@@ -10,7 +10,8 @@ class OverlayNode(Node): ...@@ -10,7 +10,8 @@ class OverlayNode(Node):
Node.__init__(self,id,network,weight) Node.__init__(self,id,network,weight)
self.startNodeLifeCycleGenerator = self.startNodeLifeCycle() self.startNodeLifeCycleGenerator = self.startNodeLifeCycle()
# adding initial task of bootstraping node. # adding initial task of bootstraping node.
self.todoList['0'].append(("nextOn", self.startNodeLifeCycleGenerator,)) self.ResumeTasks.append(("nextOn", self.startNodeLifeCycleGenerator,))
# self.todoList['0'].append(("nextOn", self.startNodeLifeCycleGenerator,))
self.commands.update({}) self.commands.update({})
def processMessage(self,time,payload): def processMessage(self,time,payload):
......
...@@ -42,6 +42,9 @@ def simulateNetwork(net): ...@@ -42,6 +42,9 @@ def simulateNetwork(net):
if __name__ == '__main__': if __name__ == '__main__':
logging.basicConfig(filename='TestCases.log', level=logging.INFO) logging.basicConfig(filename='TestCases.log', level=logging.INFO)
# populateTodolist(None) # populateTodolist(None)
simulateNetwork(None) # simulateNetwork(None)
ak = ['hello','ramesh']
ak.append('rao')
print(ak.pop())
pass pass
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment