signalGiver/Receiver update .giver/receiver variable only before sending the...

signalGiver/Receiver update .giver/receiver variable only before sending the signal to the receiver/giver
parent a689804e
...@@ -319,23 +319,34 @@ class CoreObject(Process): ...@@ -319,23 +319,34 @@ class CoreObject(Process):
# signal the successor that the object can dispose an entity # signal the successor that the object can dispose an entity
# ======================================================================= # =======================================================================
def signalReceiver(self): def signalReceiver(self):
# print now(), self.id, 'trying to signal receiver'
activeObject=self.getActiveObject() activeObject=self.getActiveObject()
possibleReceivers=[] possibleReceivers=[]
for object in [x for x in self.next if x.canAccept(activeObject)]: for object in [x for x in self.next if x.canAccept(activeObject)]:
possibleReceivers.append(object) possibleReceivers.append(object)
# print now(), self.id,'possibleReceivers',[str(x.id) for x in possibleReceivers] # print now(), self.id,'possibleReceivers',[str(x.id) for x in possibleReceivers]
if possibleReceivers: if possibleReceivers:
activeObject.receiver=activeObject.selectReceiver(possibleReceivers) receiver=activeObject.selectReceiver(possibleReceivers)
activeObject.receiver.giver=activeObject # activeObject.receiver=activeObject.selectReceiver(possibleReceivers)
receiversGiver=activeObject
# activeObject.receiver.giver=activeObject
# perform the checks that canAcceptAndIsRequested used to perform and update activeCallersList or assignExit and operatorPool # perform the checks that canAcceptAndIsRequested used to perform and update activeCallersList or assignExit and operatorPool
while not activeObject.receiver.canAcceptAndIsRequested(): while not receiver.canAcceptAndIsRequested(receiversGiver):
possibleReceivers.remove(activeObject.receiver) # while not activeObject.receiver.canAcceptAndIsRequested():
possibleReceivers.remove(receiver)
# possibleReceivers.remove(activeObject.receiver)
if not possibleReceivers: if not possibleReceivers:
# print self.id, 'reseting receiver' # print self.id, 'reseting receiver'
activeObject.receiver.giver=None receiversGiver=None
activeObject.receiver=None receiver=None
# activeObject.receiver.giver=None
# activeObject.receiver=None
return False return False
activeObject.receiver=activeObject.selectReceiver(possibleReceivers) receiver=activeObject.selectReceiver(possibleReceivers)
# activeObject.receiver=activeObject.selectReceiver(possibleReceivers)
receiversGiver=activeObject
# activeObject.receiver.giver=activeObject
activeObject.receiver=receiver
activeObject.receiver.giver=activeObject activeObject.receiver.giver=activeObject
#=================================================================== #===================================================================
# # TESTING # # TESTING
...@@ -367,6 +378,7 @@ class CoreObject(Process): ...@@ -367,6 +378,7 @@ class CoreObject(Process):
# signal the giver that the entity is removed from its internalQueue # signal the giver that the entity is removed from its internalQueue
# ======================================================================= # =======================================================================
def signalGiver(self): def signalGiver(self):
# print now(), self.id, 'trying to signal giver'
activeObject=self.getActiveObject() activeObject=self.getActiveObject()
possibleGivers=[] possibleGivers=[]
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)]:
...@@ -374,14 +386,22 @@ class CoreObject(Process): ...@@ -374,14 +386,22 @@ class CoreObject(Process):
possibleGivers.append(object) possibleGivers.append(object)
# print 'possibleGivers:', [str(x.id) for x in possibleGivers] # print 'possibleGivers:', [str(x.id) for x in possibleGivers]
if possibleGivers: if possibleGivers:
activeObject.giver=activeObject.selectGiver(possibleGivers) giver=activeObject.selectGiver(possibleGivers)
activeObject.giver.receiver=activeObject # activeObject.giver=activeObject.selectGiver(possibleGivers)
giversReceiver=activeObject
# activeObject.giver.receiver=activeObject
# perform the checks that canAcceptAndIsRequested used to perform and update activeCallersList or assignExit and operatorPool # perform the checks that canAcceptAndIsRequested used to perform and update activeCallersList or assignExit and operatorPool
while not activeObject.canAcceptAndIsRequested(): while not activeObject.canAcceptAndIsRequested(giver):
possibleGivers.remove(activeObject.giver) # while not activeObject.canAcceptAndIsRequested():
possibleGivers.remove(giver)
# possibleGivers.remove(activeObject.giver)
if not possibleGivers: if not possibleGivers:
return False return False
activeObject.giver=activeObject.selectGiver(possibleGivers) giver=activeObject.selectGiver(possibleGivers)
# activeObject.giver=activeObject.selectGiver(possibleGivers)
giversReceiver=activeObject
# activeObject.giver.receiver=activeObject
activeObject.giver=giver
activeObject.giver.receiver=activeObject activeObject.giver.receiver=activeObject
#=================================================================== #===================================================================
# # TESTING # # TESTING
...@@ -468,7 +488,7 @@ class CoreObject(Process): ...@@ -468,7 +488,7 @@ class CoreObject(Process):
# checks if the Object can accept an entity and there is an entity # checks if the Object can accept an entity and there is an entity
# in some possible giver waiting for it # in some possible giver waiting for it
# ======================================================================= # =======================================================================
def canAcceptAndIsRequested(self): def canAcceptAndIsRequested(self,callerObject=None):
pass pass
# ======================================================================= # =======================================================================
...@@ -579,9 +599,10 @@ class CoreObject(Process): ...@@ -579,9 +599,10 @@ class CoreObject(Process):
# ======================================================================= # =======================================================================
# assign Exit of the object # assign Exit of the object
# ======================================================================= # =======================================================================
def assignExitTo(self): def assignExitTo(self, callerObject=None):
# print self.id, 'assignExit' # print self.id, 'assignExit'
self.exitAssignedToReceiver = self.receiver # self.exitAssignedToReceiver = self.receiver
self.exitAssignedToReceiver=callerObject
# ======================================================================= # =======================================================================
# unblock the object # unblock the object
......
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