Machine waits for signal entityRemoved after processing

parent 8b0b1f43
...@@ -236,7 +236,6 @@ class Machine(CoreObject): ...@@ -236,7 +236,6 @@ class Machine(CoreObject):
# waitEvent isRequested /interruptionEnd/loadOperatorAvailable # waitEvent isRequested /interruptionEnd/loadOperatorAvailable
while 1: while 1:
self.printTrace(self.id, waitEvent='') self.printTrace(self.id, waitEvent='')
# yield waitevent, self, [self.isRequested, self.interruptionEnd, self.loadOperatorAvailable]
receivedEvent = yield self.isRequested | self.interruptionEnd | self.loadOperatorAvailable receivedEvent = yield self.isRequested | self.interruptionEnd | self.loadOperatorAvailable
self.printTrace(self.id, received='') self.printTrace(self.id, received='')
# if the machine can accept an entity and one predecessor requests it continue with receiving the entity # if the machine can accept an entity and one predecessor requests it continue with receiving the entity
...@@ -245,19 +244,18 @@ class Machine(CoreObject): ...@@ -245,19 +244,18 @@ class Machine(CoreObject):
assert self.isRequested.value==self.giver, 'the giver is not the requestingObject' assert self.isRequested.value==self.giver, 'the giver is not the requestingObject'
assert self.giver.receiver==self, 'the receiver of the signalling object in not the station' assert self.giver.receiver==self, 'the receiver of the signalling object in not the station'
# reset the signalparam of the isRequested event # reset the signalparam of the isRequested event
# self.isRequested.value=None
self.isRequested=self.env.event() self.isRequested=self.env.event()
break break
# if an interruption caused the control to be taken by the machine or # if an interruption caused the control to be taken by the machine or
# if an operator was rendered available while it was needed by the machine to proceed with getEntity # if an operator was rendered available while it was needed by the machine to proceed with getEntity
if self.interruptionEnd.value==self.env.now or self.loadOperatorAvailable.value==self.env.now: if self.interruptionEnd in receivedEvent or self.loadOperatorAvailable in receivedEvent:
if self.interruptionEnd in receivedEvent: if self.interruptionEnd in receivedEvent:
if self.interruptionEnd.value==self.env.now: assert self.interruptionEnd.value==self.env.now, 'interruptionEnd received later than created'
self.printTrace(self.id, interruptionEnd=str(self.interruptionEnd.value)) self.printTrace(self.id, interruptionEnd=str(self.interruptionEnd.value))
self.interruptionEnd=self.env.event() self.interruptionEnd=self.env.event()
if self.loadOperatorAvailable in receivedEvent: if self.loadOperatorAvailable in receivedEvent:
if self.loadOperatorAvailable.value==self.env.now: assert self.loadOperatorAvailable.value==self.env.now,'loadOperatorAvailable received later than created'
self.printTrace(self.id,loadOperatorAvailable=str(self.loadOperatorAvailable.value)) self.printTrace(self.id,loadOperatorAvailable=str(self.loadOperatorAvailable.value))
self.loadOperatorAvailable=self.env.event() self.loadOperatorAvailable=self.env.event()
# try to signal the Giver, otherwise wait until it is requested # try to signal the Giver, otherwise wait until it is requested
if self.signalGiver(): if self.signalGiver():
...@@ -454,7 +452,6 @@ class Machine(CoreObject): ...@@ -454,7 +452,6 @@ class Machine(CoreObject):
self.releaseOperator() self.releaseOperator()
yield self.brokerIsSet yield self.brokerIsSet
self.brokerIsSet=self.env.event() self.brokerIsSet=self.env.event()
# signal the receiver that the activeObject has something to dispose of # signal the receiver that the activeObject has something to dispose of
if not self.signalReceiver(): if not self.signalReceiver():
# if there was no available receiver, get into blocking control # if there was no available receiver, get into blocking control
...@@ -483,7 +480,8 @@ class Machine(CoreObject): ...@@ -483,7 +480,8 @@ class Machine(CoreObject):
# 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.env.timeout(0) yield self.entityRemoved #env.timeout(0)
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():
break break
......
...@@ -195,7 +195,7 @@ class Router(ObjectInterruption): ...@@ -195,7 +195,7 @@ class Router(ObjectInterruption):
# if the operator is not conflicting # if the operator is not conflicting
if not operator in self.conflictingOperators: if not operator in self.conflictingOperators:
# assign an operator to the priorityObject # assign an operator to the priorityObject
self.printTrace('router', ' will assign'+operator.id+'to'+operator.candidateStation.id) self.printTrace('router', 'will assign '+operator.id+' to '+operator.candidateStation.id)
operator.assignTo(operator.candidateStation) operator.assignTo(operator.candidateStation)
if not operator.candidateStation in self.toBeSignalled: if not operator.candidateStation in self.toBeSignalled:
self.toBeSignalled.append(operator.candidateStation) self.toBeSignalled.append(operator.candidateStation)
......
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