Commit 631c88c4 authored by Ioannis Papagiannopoulos's avatar Ioannis Papagiannopoulos Committed by Jérome Perrin

Fix in the removeEntity event signalling

parent 83db4f6d
......@@ -68,7 +68,9 @@ class CapacityStationController(EventGenerator):
if not exit.isRequested.triggered: # this is needed because the signal can be triggered also by the buffer
exit.isRequested.succeed(station) # send is requested to station
# wait until the entity is removed
station.waitEntityRemoval=True
yield station.entityRemoved
station.waitEntityRemoval=False
exit.currentlyObtainedEntities.append(entity)
station.entityRemoved=self.env.event()
project=entity.capacityProject
......@@ -113,7 +115,9 @@ class CapacityStationController(EventGenerator):
break
station.isRequested.succeed(buffer) # send is requested to station
# wait until the entity is removed
buffer.waitEntityRemoval=True
yield buffer.entityRemoved
buffer.waitEntityRemoval=False
buffer.entityRemoved=self.env.event()
project=entity.capacityProject
periodDict[project.id]=entity.requiredCapacity # dict to be appended in the utilization list
......
......@@ -53,6 +53,8 @@ class CoreObject(object):
self.resetOnPreemption=False
self.interruptCause=None
self.gatherWipStat=False
# flag used to signal that the station waits for removeEntity event
self.waitEntityRemoval=False
def initialize(self):
from Globals import G
......@@ -136,7 +138,8 @@ class CoreObject(object):
self.interruptionStart=self.env.event()
self.interruptedBy=None
self.entityRemoved=self.env.event()
# flag used to signal that the station waits for removeEntity event
self.waitEntityRemoval=False
# =======================================================================
# the main process of the core object
......@@ -181,10 +184,20 @@ class CoreObject(object):
# update wipStatList
if self.gatherWipStat:
self.wipStatList.append([self.env.now, len(activeObjectQueue)])
if not self.entityRemoved.triggered:
if self.entityRemoved.triggered:
if self.entityRemoved.value!=self.env.now and self.waitEntityRemoval:
# print self.id,'triggered and waiting'
self.entityRemoved=self.env.event()
self.printTrace(self.id, signal='(removedEntity)')
self.entityRemoved.succeed(self.env.now)
elif self.waitEntityRemoval:
# print self.id,'not triggered and waiting'
self.printTrace(self.id, signal='(removedEntity)')
self.entityRemoved.succeed(self.env.now)
elif not self.waitEntityRemoval:
# print self.id,'not triggered but not waiting'
pass
return entity
#===========================================================================
......@@ -463,7 +476,7 @@ class CoreObject(object):
self.giver=giver
self.giver.receiver=self
self.printTrace(self.id, signalGiver=self.giver.id)
self.giver.canDispose.succeed(self)
self.giver.canDispose.succeed(self.env.now)
return True
return False
......
......@@ -155,7 +155,9 @@ class Dismantle(CoreObject):
if not self.signalReceiver():
continue
# if the receiver was not responsive, release the control to let him remove the entity
self.waitEntityRemoval=True
yield self.entityRemoved
self.waitEntityRemoval=False
self.entityRemoved=self.env.event()
# yield self.env.timeout(0)#(0.000000000000005)
......
......@@ -450,6 +450,7 @@ class Machine(CoreObject):
# if there was no available receiver, get into blocking control
while 1:
# 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.canDispose | self.interruptionStart
# if there was interruption
#if self.interrupted():
......@@ -463,17 +464,31 @@ class Machine(CoreObject):
assert self.env.now==self.interruptionEnd.value, 'the victim of the failure is not the object that received it'
self.interruptionEnd=self.env.event()
self.postInterruptionActions()
if self.signalReceiver():
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
# 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.
yield self.entityRemoved #env.timeout(0)
# notify that the station waits the entity to be removed
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():
......
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