Commit 5e2d0258 authored by Georgios Dagkakis's avatar Georgios Dagkakis Committed by Ioannis Papagiannopoulos

change in Macnine.run thread when it waits to dispose an entity

parent cda37a84
...@@ -797,10 +797,11 @@ class Machine(CoreObject): ...@@ -797,10 +797,11 @@ class Machine(CoreObject):
break break
self.expectedSignals['interruptionStart']=1 self.expectedSignals['interruptionStart']=1
self.expectedSignals['canDispose']=1 self.expectedSignals['canDispose']=1
self.expectedSignals['entityRemoved']=1
self.timeLastBlockageStarted=self.env.now # blockage is starting self.timeLastBlockageStarted=self.env.now # blockage is starting
# wait the event canDispose, this means that the station can deliver the item to successor # wait the event canDispose, this means that the station can deliver the item to successor
self.printTrace(self.id, waitEvent='(canDispose or interruption start)') self.printTrace(self.id, waitEvent='(canDispose or interruption start)')
receivedEvent=yield self.env.any_of([self.canDispose , self.interruptionStart]) receivedEvent=yield self.env.any_of([self.canDispose , self.interruptionStart,self.entityRemoved])
# if there was interruption # if there was interruption
# TODO not good implementation # TODO not good implementation
if self.interruptionStart in receivedEvent: if self.interruptionStart in receivedEvent:
...@@ -854,19 +855,7 @@ class Machine(CoreObject): ...@@ -854,19 +855,7 @@ class Machine(CoreObject):
# try to signal a receiver, if successful then proceed to get an other entity # try to signal a receiver, if successful then proceed to get an other entity
if self.signalReceiver(): if self.signalReceiver():
break break
# TODO: router most probably should signal givers and not receivers in order to avoid this hold,self,0 if self.entityRemoved in receivedEvent:
# 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
activeObjectQueue=self.getActiveObjectQueue()
if len(activeObjectQueue):
self.waitEntityRemoval=True
self.printTrace(self.id, waitEvent='(entityRemoved)')
self.expectedSignals['entityRemoved']=1
yield self.entityRemoved
transmitter, eventTime=self.entityRemoved.value transmitter, eventTime=self.entityRemoved.value
self.printTrace(self.id, entityRemoved=eventTime) self.printTrace(self.id, entityRemoved=eventTime)
assert eventTime==self.env.now,'entityRemoved event activated earlier than received' assert eventTime==self.env.now,'entityRemoved event activated earlier than received'
......
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