Commit 43791a98 authored by Georgios Dagkakis's avatar Georgios Dagkakis

Conveyer: make sure that canMove event is sent to ConveyerMover only when it should

I.e. only when it is expected by the mover
parent c1c384a3
...@@ -99,11 +99,11 @@ class Conveyer(CoreObject): ...@@ -99,11 +99,11 @@ class Conveyer(CoreObject):
while 1: while 1:
#calculate the time to reach end. If this is greater than 0 (we did not already have an entity at the end) #calculate the time to reach end. If this is greater than 0 (we did not already have an entity at the end)
#set it as the timeToWait of the conveyerMover and raise call=true so that it will be triggered #set it as the timeToWait of the conveyerMover and raise call=true so that it will be triggered
if self.updateMoveTime(): if self.updateMoveTime() and self.conveyerMover.expectedSignals['canMove']:
# print self.id, 'time to move', self.conveyerMover.timeToWait # print self.id, 'time to move', self.conveyerMover.timeToWait
succeedTuple=(self,self.env.now) succeedTuple=(self,self.env.now)
self.conveyerMover.canMove.succeed(succeedTuple) self.conveyerMover.canMove.succeed(succeedTuple)
self.printTrace(self.id, waitEvent='') self.printTrace(self.id, waitEvent='')
self.expectedSignals['isRequested']=1 self.expectedSignals['isRequested']=1
...@@ -369,8 +369,7 @@ class Conveyer(CoreObject): ...@@ -369,8 +369,7 @@ class Conveyer(CoreObject):
# self.totalBlockageTime+=self.env.now-self.timeBlockageStarted # self.totalBlockageTime+=self.env.now-self.timeBlockageStarted
self.wasFull=False self.wasFull=False
#calculate the time that the conveyer will become available again and trigger the conveyerMover #calculate the time that the conveyer will become available again and trigger the conveyerMover
if self.updateMoveTime(): if self.updateMoveTime() and self.conveyerMover.expectedSignals['canMove']:
# print self.id, 'time to move', self.conveyerMover.timeToWait
succeedTuple=(self,self.env.now) succeedTuple=(self,self.env.now)
self.conveyerMover.canMove.succeed(succeedTuple) self.conveyerMover.canMove.succeed(succeedTuple)
# if there is anything to dispose of then signal a receiver # if there is anything to dispose of then signal a receiver
...@@ -472,15 +471,18 @@ class ConveyerMover(object): ...@@ -472,15 +471,18 @@ class ConveyerMover(object):
self.timeToWait=0 #the time to wait every time. This is calculated by the conveyer and corresponds self.timeToWait=0 #the time to wait every time. This is calculated by the conveyer and corresponds
#either to the time that one entity reaches the end or the time that one space is freed #either to the time that one entity reaches the end or the time that one space is freed
self.canMove=self.env.event() self.canMove=self.env.event()
self.expectedSignals={'canMove': 1}
#=========================================================================== #===========================================================================
# ConveyerMover generator # ConveyerMover generator
#=========================================================================== #===========================================================================
def run(self): def run(self):
while 1: while 1:
self.conveyer.printTrace(self.conveyer.id, waitEvent='(canMove)') self.conveyer.printTrace(self.conveyer.id, waitEvent='(canMove)')
self.expectedSignals['canMove']=1
yield self.canMove #wait until the conveyer triggers the mover yield self.canMove #wait until the conveyer triggers the mover
transmitter, eventTime=self.canMove.value transmitter, eventTime=self.canMove.value
self.expectedSignals['canMove']=0
self.canMove=self.env.event() self.canMove=self.env.event()
self.conveyer.printTrace(self.conveyer.id, received='(canMove)') self.conveyer.printTrace(self.conveyer.id, received='(canMove)')
......
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