Fix to prevent singalling the same object twice

parent c0abf540
...@@ -331,7 +331,7 @@ class CoreObject(object): ...@@ -331,7 +331,7 @@ class CoreObject(object):
@staticmethod @staticmethod
def findReceiversFor(activeObject): def findReceiversFor(activeObject):
receivers=[] receivers=[]
for object in [x for x in activeObject.next if x.canAccept(activeObject)]: for object in [x for x in activeObject.next if x.canAccept(activeObject) and not x.isRequested.triggered]:
receivers.append(object) receivers.append(object)
return receivers return receivers
...@@ -372,7 +372,7 @@ class CoreObject(object): ...@@ -372,7 +372,7 @@ class CoreObject(object):
self.receiver=receiver self.receiver=receiver
self.receiver.giver=self self.receiver.giver=self
# self.printTrace(self.id, signalReceiver=self.receiver.id) self.printTrace(self.id, signalReceiver=self.receiver.id)
# assign the entry of the receiver # assign the entry of the receiver
self.receiver.assignEntryTo() self.receiver.assignEntryTo()
self.receiver.isRequested.succeed(self) self.receiver.isRequested.succeed(self)
...@@ -431,7 +431,7 @@ class CoreObject(object): ...@@ -431,7 +431,7 @@ class CoreObject(object):
@staticmethod @staticmethod
def findGiversFor(activeObject): def findGiversFor(activeObject):
givers=[] givers=[]
for object in [x for x in activeObject.previous if(not x is activeObject)]: for object in [x for x in activeObject.previous if(not x is activeObject)]:# and not x.canDispose.triggered]:
if object.haveToDispose(activeObject): if object.haveToDispose(activeObject):
givers.append(object) givers.append(object)
return givers return givers
...@@ -465,7 +465,7 @@ class CoreObject(object): ...@@ -465,7 +465,7 @@ class CoreObject(object):
giversReceiver=self giversReceiver=self
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)
return True return True
return False return False
......
...@@ -73,6 +73,7 @@ class Exit(CoreObject): ...@@ -73,6 +73,7 @@ class Exit(CoreObject):
self.isRequested=self.env.event() self.isRequested=self.env.event()
# TODO: insert extra controls to check whether the self.giver attribute is correctly updated # TODO: insert extra controls to check whether the self.giver attribute is correctly updated
self.getEntity() self.getEntity()
self.signalGiver()
# ======================================================================= # =======================================================================
# sets the routing in element for the Exit # sets the routing in element for the Exit
......
...@@ -234,13 +234,13 @@ class Machine(CoreObject): ...@@ -234,13 +234,13 @@ class Machine(CoreObject):
while 1: while 1:
# 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] # 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
if self.isRequested in receivedEvent: if self.isRequested in receivedEvent:
# self.printTrace(self.id, isRequested=self.isRequested.value.id) self.printTrace(self.id, isRequested=self.isRequested.value.id)
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
...@@ -490,7 +490,7 @@ class Machine(CoreObject): ...@@ -490,7 +490,7 @@ class Machine(CoreObject):
def endProcessingActions(self): def endProcessingActions(self):
activeObjectQueue=self.Res.users activeObjectQueue=self.Res.users
activeEntity=activeObjectQueue[0] activeEntity=activeObjectQueue[0]
# self.printTrace(activeObject.getActiveObjectQueue()[0].name, processEnd=activeObject.objName) self.printTrace(self.getActiveObjectQueue()[0].name, processEnd=self.objName)
# reset the variables used to handle the interruptions timing # reset the variables used to handle the interruptions timing
self.timeRestartingProcessing=0 self.timeRestartingProcessing=0
self.breakTime=0 self.breakTime=0
...@@ -714,7 +714,7 @@ class Machine(CoreObject): ...@@ -714,7 +714,7 @@ class Machine(CoreObject):
self.waitToDispose=False # update the waitToDispose flag self.waitToDispose=False # update the waitToDispose flag
# if the Machine canAccept then signal a giver # if the Machine canAccept then signal a giver
if self.canAccept(): if self.canAccept():
# self.printTrace(self.id, attemptSignalGiver='(removeEntity)') self.printTrace(self.id, attemptSignalGiver='(removeEntity)')
self.signalGiver() self.signalGiver()
return activeEntity return activeEntity
......
...@@ -97,13 +97,13 @@ class Queue(CoreObject): ...@@ -97,13 +97,13 @@ class Queue(CoreObject):
# check if there is WIP and signal receiver # check if there is WIP and signal receiver
self.initialSignalReceiver() self.initialSignalReceiver()
while 1: while 1:
# self.printTrace(self.id, waitEvent='') self.printTrace(self.id, waitEvent='')
# wait until the Queue can accept an entity and one predecessor requests it # wait until the Queue can accept an entity and one predecessor requests it
receivedEvent=yield self.isRequested | self.canDispose | self.loadOperatorAvailable receivedEvent=yield self.isRequested | self.canDispose | self.loadOperatorAvailable
# self.printTrace(self.id, received='') self.printTrace(self.id, received='')
# if the event that activated the thread is isRequested then getEntity # if the event that activated the thread is isRequested then getEntity
if self.isRequested in receivedEvent: if self.isRequested in receivedEvent:
# self.printTrace(self.id, isRequested=self.isRequested.signalparam.id) self.printTrace(self.id, isRequested=self.isRequested.value.id)
# reset the isRequested signal parameter # reset the isRequested signal parameter
self.isRequested=self.env.event() self.isRequested=self.env.event()
self.getEntity() self.getEntity()
...@@ -116,7 +116,7 @@ class Queue(CoreObject): ...@@ -116,7 +116,7 @@ class Queue(CoreObject):
self.loadOperatorAvailable=self.env.event() self.loadOperatorAvailable=self.env.event()
# if the queue received an canDispose with signalparam time, this means that the signals was sent from a MouldAssemblyBuffer # if the queue received an canDispose with signalparam time, this means that the signals was sent from a MouldAssemblyBuffer
if self.canDispose in receivedEvent: if self.canDispose in receivedEvent:
# self.printTrace(self.id, canDispose='') self.printTrace(self.id, canDispose='')
self.canDispose=self.env.event() self.canDispose=self.env.event()
# if the event that activated the thread is canDispose then signalReceiver # if the event that activated the thread is canDispose then signalReceiver
if self.haveToDispose(): if 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