Commit 5858ff7f authored by Ioannis Papagiannopoulos's avatar Ioannis Papagiannopoulos Committed by Georgios Dagkakis

BatchReassembly signalRouter loop fixed

parent 5df6e60a
......@@ -117,17 +117,60 @@ class BatchReassembly(CoreObject):
yield self.env.timeout(self.calculateProcessingTime())
self.reassemble()
self.isProcessingInitialWIP=False
# signal the receiver that the activeObject has something to dispose of
if not self.signalReceiver():
# if there was no available receiver, get into blocking control
while 1:
# self.timeLastBlockageStarted=self.env.now # blockage is starting
# wait the event canDispose, this means that the station can deliver the item to successor
self.printTrace(self.id, waitEvent='(canDispose or interruption start)')
receivedEvent=yield self.env.any_of([self.canDispose , self.interruptionStart])
if self.canDispose in receivedEvent:
self.canDispose=self.env.event()
# if there was interruption
# TODO not good implementation
if self.interruptionStart in receivedEvent:
self.interruptionStart.value==self.env.now, 'the interruptionStart event received by BatchReassembly later than created'
assert self.interruptionStart.value==self.env.now, 'the interruption has not been processed on the time of activation'
self.interruptionStart=self.env.event()
yield self.interruptionEnd
assert self==self.interruptionEnd.value, 'interruptionEnd event received by BatchReassembly other than the one intended'
if self.signalReceiver():
# wait for the end of the interruption
self.interruptionActions() # execute interruption actions
# loop until we reach at a state that there is no interruption
while 1:
yield self.interruptionEnd # interruptionEnd to be triggered by ObjectInterruption
assert self.env.now==self.interruptionEnd.value, 'the victim of the failure is not the object that received it'
self.interruptionEnd=self.env.event()
if self.Up and self.onShift:
break
self.postInterruptionActions()
if self.signalReceiver():
# self.timeLastBlockageStarted=self.env.now
break
else:
continue
if self.canDispose in receivedEvent:
if self.canDispose.value!=self.env.now:
self.canDispose=self.env.event()
continue
assert self.canDispose.value==self.env.now,'canDispose signal is late'
self.canDispose=self.env.event()
# try to signal a receiver, if successful then proceed to get an other entity
if self.signalReceiver():
break
# TODO: router most probably should signal givers and not receivers in order to avoid this hold,self,0
# As the receiver (e.g.) a machine that follows the machine receives an loadOperatorAvailable event,
# signals the preceding station (e.g. self.machine) and immediately after that gets the entity.
# the preceding machine gets the canDispose signal which is actually useless, is emptied by the following station
# and then cannot exit an infinite loop.
# notify that the station waits the entity to be removed
if not self.haveToDispose():
break
self.waitEntityRemoval=True
self.printTrace(self.id, waitEvent='(entityRemoved)')
yield self.entityRemoved
self.printTrace(self.id, entityRemoved=self.entityRemoved.value)
assert self.entityRemoved.value==self.env.now,'entityRemoved event activated earlier than received'
self.waitEntityRemoval=False
self.entityRemoved=self.env.event()
# if while waiting (for a canDispose event) became free as the machines that follows emptied it, then proceed
if not self.haveToDispose():
break
# =======================================================================
......
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