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): ...@@ -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 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 exit.isRequested.succeed(station) # send is requested to station
# wait until the entity is removed # wait until the entity is removed
station.waitEntityRemoval=True
yield station.entityRemoved yield station.entityRemoved
station.waitEntityRemoval=False
exit.currentlyObtainedEntities.append(entity) exit.currentlyObtainedEntities.append(entity)
station.entityRemoved=self.env.event() station.entityRemoved=self.env.event()
project=entity.capacityProject project=entity.capacityProject
...@@ -113,7 +115,9 @@ class CapacityStationController(EventGenerator): ...@@ -113,7 +115,9 @@ class CapacityStationController(EventGenerator):
break break
station.isRequested.succeed(buffer) # send is requested to station station.isRequested.succeed(buffer) # send is requested to station
# wait until the entity is removed # wait until the entity is removed
buffer.waitEntityRemoval=True
yield buffer.entityRemoved yield buffer.entityRemoved
buffer.waitEntityRemoval=False
buffer.entityRemoved=self.env.event() buffer.entityRemoved=self.env.event()
project=entity.capacityProject project=entity.capacityProject
periodDict[project.id]=entity.requiredCapacity # dict to be appended in the utilization list periodDict[project.id]=entity.requiredCapacity # dict to be appended in the utilization list
......
...@@ -53,6 +53,8 @@ class CoreObject(object): ...@@ -53,6 +53,8 @@ class CoreObject(object):
self.resetOnPreemption=False self.resetOnPreemption=False
self.interruptCause=None self.interruptCause=None
self.gatherWipStat=False self.gatherWipStat=False
# flag used to signal that the station waits for removeEntity event
self.waitEntityRemoval=False
def initialize(self): def initialize(self):
from Globals import G from Globals import G
...@@ -136,7 +138,8 @@ class CoreObject(object): ...@@ -136,7 +138,8 @@ class CoreObject(object):
self.interruptionStart=self.env.event() self.interruptionStart=self.env.event()
self.interruptedBy=None self.interruptedBy=None
self.entityRemoved=self.env.event() 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 # the main process of the core object
...@@ -181,10 +184,20 @@ class CoreObject(object): ...@@ -181,10 +184,20 @@ class CoreObject(object):
# update wipStatList # update wipStatList
if self.gatherWipStat: if self.gatherWipStat:
self.wipStatList.append([self.env.now, len(activeObjectQueue)]) 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.printTrace(self.id, signal='(removedEntity)')
self.entityRemoved.succeed(self.env.now) self.entityRemoved.succeed(self.env.now)
elif not self.waitEntityRemoval:
# print self.id,'not triggered but not waiting'
pass
return entity return entity
#=========================================================================== #===========================================================================
...@@ -463,7 +476,7 @@ class CoreObject(object): ...@@ -463,7 +476,7 @@ class CoreObject(object):
self.giver=giver self.giver=giver
self.giver.receiver=self self.giver.receiver=self
self.printTrace(self.id, signalGiver=self.giver.id) self.printTrace(self.id, signalGiver=self.giver.id)
self.giver.canDispose.succeed(self) self.giver.canDispose.succeed(self.env.now)
return True return True
return False return False
......
...@@ -155,7 +155,9 @@ class Dismantle(CoreObject): ...@@ -155,7 +155,9 @@ class Dismantle(CoreObject):
if not self.signalReceiver(): if not self.signalReceiver():
continue continue
# if the receiver was not responsive, release the control to let him remove the entity # if the receiver was not responsive, release the control to let him remove the entity
self.waitEntityRemoval=True
yield self.entityRemoved yield self.entityRemoved
self.waitEntityRemoval=False
self.entityRemoved=self.env.event() self.entityRemoved=self.env.event()
# yield self.env.timeout(0)#(0.000000000000005) # yield self.env.timeout(0)#(0.000000000000005)
......
...@@ -450,6 +450,7 @@ class Machine(CoreObject): ...@@ -450,6 +450,7 @@ class Machine(CoreObject):
# if there was no available receiver, get into blocking control # if there was no available receiver, get into blocking control
while 1: while 1:
# 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)')
receivedEvent=yield self.canDispose | self.interruptionStart receivedEvent=yield self.canDispose | self.interruptionStart
# if there was interruption # if there was interruption
#if self.interrupted(): #if self.interrupted():
...@@ -463,17 +464,31 @@ class Machine(CoreObject): ...@@ -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' 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.interruptionEnd=self.env.event()
self.postInterruptionActions() self.postInterruptionActions()
if self.signalReceiver():
break
else:
continue
if self.canDispose in receivedEvent: 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() self.canDispose=self.env.event()
# 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 # 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, # 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. # 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 # the preceding machine gets the canDispose signal which is actually useless, is emptied by the following station
# and then cannot exit an infinite loop. # 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() self.entityRemoved=self.env.event()
# if while waiting (for a canDispose event) became free as the machines that follows emptied it, then proceed # if while waiting (for a canDispose event) became free as the machines that follows emptied it, then proceed
if not self.haveToDispose(): 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