new methods that block the entry of an object. Implemented on machines to...

new methods that block the entry of an object. Implemented on machines to avoid receiving to signals at the same simulation time
parent 78f4dd58
...@@ -110,6 +110,12 @@ class CoreObject(Process): ...@@ -110,6 +110,12 @@ class CoreObject(Process):
# when the entities have to be loaded to operatedMachines # when the entities have to be loaded to operatedMachines
# then the giverObjects have to be blocked for the time # then the giverObjects have to be blocked for the time
# that the machine is being loaded # that the machine is being loaded
# ============================== variable that is used signalling of machines ==================
self.entryAssignedToGiver = None # by default the objects are not blocked
# when the entities have to be received by machines
# then the machines have to be blocked after the first signal they receive
# in order to avoid signalling the same machine
# while it has not received the entity it has been originally signalled for
# ============================== lists to hold statistics of multiple runs ===================== # ============================== lists to hold statistics of multiple runs =====================
self.totalTimeWaitingForOperator=0 self.totalTimeWaitingForOperator=0
self.operatorWaitTimeCurrentEntity=0 self.operatorWaitTimeCurrentEntity=0
...@@ -154,7 +160,7 @@ class CoreObject(Process): ...@@ -154,7 +160,7 @@ class CoreObject(Process):
# removes an Entity from the Object the Entity to be removed is passed # removes an Entity from the Object the Entity to be removed is passed
# as argument by getEntity of the receiver # as argument by getEntity of the receiver
# ======================================================================= # =======================================================================
def removeEntity(self, entity=None): def removeEntity(self, entity=None):
self.addBlockage() self.addBlockage()
activeObjectQueue=self.getActiveObjectQueue() activeObjectQueue=self.getActiveObjectQueue()
...@@ -205,15 +211,20 @@ class CoreObject(Process): ...@@ -205,15 +211,20 @@ class CoreObject(Process):
giverObject.sortEntities() #sort the Entities of the giver giverObject.sortEntities() #sort the Entities of the giver
#according to the scheduling rule if applied #according to the scheduling rule if applied
giverObjectQueue=self.getGiverObjectQueue() giverObjectQueue=self.getGiverObjectQueue()
# if the giverObject is blocked then unBlock it
if giverObject.exitIsAssignedTo():
giverObject.unAssignExit()
# remove entity from the giver # remove entity from the giver
activeEntity = giverObject.removeEntity(entity=self.identifyEntityToGet()) activeEntity = giverObject.removeEntity(entity=self.identifyEntityToGet())
# variable that holds the last giver; used in case of preemption # variable that holds the last giver; used in case of preemption
self.lastGiver=self.giver self.lastGiver=self.giver
#get the entity from the previous object and put it in front of the activeQ #get the entity from the previous object and put it in front of the activeQ
activeObjectQueue.append(activeEntity) activeObjectQueue.append(activeEntity)
# if the giverObject is blocked then unBlock it
if giverObject.exitIsAssignedTo(): # if the activeObject entry is blocked then unBlock it
giverObject.unAssignExit() if activeObject.entryIsAssignedTo():
activeObject.unAssignEntry()
#append the time to schedule so that it can be read in the result #append the time to schedule so that it can be read in the result
#remember that every entity has it's schedule which is supposed to be updated every time #remember that every entity has it's schedule which is supposed to be updated every time
# he entity enters a new object # he entity enters a new object
...@@ -323,6 +334,8 @@ class CoreObject(Process): ...@@ -323,6 +334,8 @@ class CoreObject(Process):
# # TESTING # # TESTING
# print now(), self.id,' '*50, 'signalling receiver', self.receiver.id # print now(), self.id,' '*50, 'signalling receiver', self.receiver.id
#=================================================================== #===================================================================
# assign the entry of the receiver
activeObject.receiver.assignEntryTo()
activeObject.receiver.isRequested.signal(activeObject) activeObject.receiver.isRequested.signal(activeObject)
return True return True
return False return False
...@@ -349,8 +362,9 @@ class CoreObject(Process): ...@@ -349,8 +362,9 @@ class CoreObject(Process):
def signalGiver(self): def signalGiver(self):
activeObject=self.getActiveObject() activeObject=self.getActiveObject()
possibleGivers=[] possibleGivers=[]
for object in [x for x in activeObject.previous if x.haveToDispose(activeObject)]: for object in [x for x in activeObject.previous if(not x is activeObject)]:
possibleGivers.append(object) if object.haveToDispose(activeObject):
possibleGivers.append(object)
if possibleGivers: if possibleGivers:
activeObject.giver=activeObject.selectGiver(possibleGivers) activeObject.giver=activeObject.selectGiver(possibleGivers)
activeObject.giver.receiver=activeObject activeObject.giver.receiver=activeObject
...@@ -566,6 +580,24 @@ class CoreObject(Process): ...@@ -566,6 +580,24 @@ class CoreObject(Process):
def unAssignExit(self): def unAssignExit(self):
self.exitAssignedToReceiver = None self.exitAssignedToReceiver = None
# =======================================================================
# checks if the machine is blocked
# =======================================================================
def entryIsAssignedTo(self):
return self.entryAssignedToGiver
# =======================================================================
# assign Exit of the object
# =======================================================================
def assignEntryTo(self):
self.entryAssignedToGiver = self.giver
# =======================================================================
# unblock the object
# =======================================================================
def unAssignEntry(self):
self.entryAssignedToGiver = None
# ======================================================================= # =======================================================================
# actions to be carried whenever the object is interrupted # actions to be carried whenever the object is interrupted
# (failure, break, preemption, etc) # (failure, break, preemption, etc)
......
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