Commit faa0eda0 authored by Georgios Dagkakis's avatar Georgios Dagkakis Committed by Jérome Perrin

CoreObject updated with methods to calculate the giver and the receiver....

CoreObject updated with methods to calculate the giver and the receiver. Methods in test mode, not called by any object currently
parent a3bf255f
......@@ -204,7 +204,7 @@ class CoreObject(Process):
# =================== get the giver object in a getEntity transaction. =========================
def getGiverObject(self):
return self.giver.getActiveObject()
return self.giver
# ============== get the giver object queue in a getEntity transaction. ========================
......@@ -213,12 +213,47 @@ class CoreObject(Process):
# ============== get the receiver object in a removeEntity transaction. =======================
def getReceiverObject(self):
return self.receiver.getActiveObject()
return self.receiver
# ========== get the receiver object queue in a removeEntity transaction. ======================
def getReceiverObjectQueue(self):
return self.getReceiverObject().getActiveObjectQueue()
# ============== get the giver object queue in a getEntity transaction. ========================
def updateGiverObject(self):
activeObject=self
# dummy variables that help prioritize the objects requesting to give objects to the Machine (activeObject)
maxTimeWaiting=0 # dummy variable counting the time a predecessor is blocked
giver=None
# loop through the possible givers to see which have to dispose and which is the one blocked for longer
for object in activeObject.previous:
if(object.haveToDispose(activeObject) and object.receiver==self):
if(object.downTimeInTryingToReleaseCurrentEntity>0):# and the predecessor has been down while trying to give away the Entity
timeWaiting=now()-object.timeLastFailureEnded # the timeWaiting dummy variable counts the time end of the last failure of the giver object
else:
timeWaiting=now()-object.timeLastEntityEnded # in any other case, it holds the time since the end of the Entity processing
#if more than one predecessor have to dispose take the part from the one that is blocked longer
if(timeWaiting>=maxTimeWaiting):
giver=object # the object to deliver the Entity to the activeObject is set to the ith member of the previous list
maxTimeWaiting=timeWaiting
return giver
def updateReceiverObject(self):
activeObject=self
# dummy variables that help prioritize the objects requesting to give objects to the Machine (activeObject)
maxTimeWaiting=0 # dummy variable counting the time a predecessor is blocked
receiver=None
maxTimeWaiting=0 # dummy variable counting the time a successor is waiting
for object in activeObject.next:
if(object.canAccept(activeObject)): # if a successor can accept an object
timeWaiting=now()-object.timeLastEntityLeft # the time it has been waiting is updated and stored in dummy variable timeWaiting
if(timeWaiting>maxTimeWaiting or maxTimeWaiting==0):# if the timeWaiting is the maximum among the ones of the successors
maxTimeWaiting=timeWaiting
receiver=object # set the receiver as the longest waiting possible receiver
return receiver
# =======================================================================
# calculates the processing time
# =======================================================================
......
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