CoreObject getEntity() clean-up

parent a2ecb7e4
...@@ -245,6 +245,9 @@ class CoreObject(Process): ...@@ -245,6 +245,9 @@ class CoreObject(Process):
receiverOperated=False receiverOperated=False
# perform preemption when required # perform preemption when required
# if the object is not Exit # if the object is not Exit
# TODO this has to be performed after updating the next list
# TODO: create a method that should check if preemption should be performed
# this should be done after the update of the next list
if activeObject.receiver: if activeObject.receiver:
# if the receiver has an operatorPool and its operationType is Load # if the receiver has an operatorPool and its operationType is Load
try: try:
...@@ -269,44 +272,7 @@ class CoreObject(Process): ...@@ -269,44 +272,7 @@ class CoreObject(Process):
self.printTrace(self.id, 'preempting receiver'+self.receiver.id+'.. '*6) self.printTrace(self.id, 'preempting receiver'+self.receiver.id+'.. '*6)
self.receiver.preempt() self.receiver.preempt()
self.receiver.timeLastEntityEnded=now() #required to count blockage correctly in the preemptied station self.receiver.timeLastEntityEnded=now() #required to count blockage correctly in the preemptied station
# TODO have to clear the activeCallersList of the operator to start working in the machine
# consider the case where the operator is already released after loading, the getEntity is invoked after that
# if the object receiving an entity has an OperatorPool
try:
if self.operatorPool!='None' and any(type=='Load' for type in self.multOperationTypeList):
if self.currentOperator:
self.currentOperator.activeCallersList=[]
except:
pass
# # activeCallersList of an operator holds the CoreObjects that have called him
# # when an Entity is obtained that has the operator as manager we need to reset this list
# if activeEntity.manager and (self.type=='MachineManagedJob' or self.type=='MFStation'):
# if activeEntity.manager.activeCallersList:
# activeEntity.manager.activeCallersList=[]
self.outputTrace(activeEntity.name, "got into "+self.objName) self.outputTrace(activeEntity.name, "got into "+self.objName)
# TODO: if the successor of the object is a machine that is operated with operationType 'Load'
# then the flag hot of the activeEntity must be set to True
# to signalize that the entity has reached its final destination before the next Machine
# if the entity is not of type Job
if activeEntity.family=='Entity':
from Globals import G
successorsAreMachines=True
# for all the objects in the next list
for object in activeObject.next:
# if the object is not in the MachineList
# TODO: We must consider also the case that entities can be blocked before they can reach
# the heating point. In such a case they must be removed from the G.pendingEntities list
# and added again after they are unblocked
if not object in G.MachineList:
successorsAreMachines=False
break
# the hot flag should not be raised
if successorsAreMachines:
activeEntity.hot = True
self.printTrace(activeEntity.name, "got into "+self.id) self.printTrace(activeEntity.name, "got into "+self.id)
# update wipStatList # update wipStatList
if self.gatherWipStat: if self.gatherWipStat:
......
...@@ -334,18 +334,8 @@ class Machine(CoreObject): ...@@ -334,18 +334,8 @@ class Machine(CoreObject):
# but setupTime is given for the entity to be processed # but setupTime is given for the entity to be processed
# try: # try:
# if self.setupTime and not any(type=="Setup" for type in self.multOperationTypeList): # if self.setupTime and not any(type=="Setup" for type in self.multOperationTypeList):
# #===============================================================
# # testing
# if self.id=='MILL1' or self.id=='MILL2':
# print ' ', now(), self.id, 'auto-setup'
# #===============================================================
# self.timeSetupStarted = now() # self.timeSetupStarted = now()
# yield hold,self,self.calculateSetupTime() # yield hold,self,self.calculateSetupTime()
# #===========================================================
# # testing
# if self.id=='MILL1' or self.id=='MILL2':
# print ' ', now()
# #===========================================================
# # TODO: if self.interrupted(): There is the issue of failure during the setup # # TODO: if self.interrupted(): There is the issue of failure during the setup
# self.timeSetupEnded = now() # self.timeSetupEnded = now()
# self.setupTimeCurrentEntity = self.timeSetupEnded-self.timeSetupStarted # self.setupTimeCurrentEntity = self.timeSetupEnded-self.timeSetupStarted
......
...@@ -227,10 +227,7 @@ class MachineJobShop(Machine): ...@@ -227,10 +227,7 @@ class MachineJobShop(Machine):
# method to execute preemption # method to execute preemption
# ======================================================================= # =======================================================================
def preempt(self): def preempt(self):
#======================================================================= self.printTrace(self.id,'preempting'+' .'*7)
# testing
# print now(), self.id, 'preempting', ' .'*7
#=======================================================================
activeObject=self.getActiveObject() activeObject=self.getActiveObject()
activeEntity=self.getActiveObjectQueue()[0] #get the active Entity activeEntity=self.getActiveObjectQueue()[0] #get the active Entity
#calculate the remaining processing time #calculate the remaining processing time
...@@ -246,12 +243,10 @@ class MachineJobShop(Machine): ...@@ -246,12 +243,10 @@ class MachineJobShop(Machine):
'processingTime':\ 'processingTime':\
{'distributionType':'Fixed',\ {'distributionType':'Fixed',\
'mean':str(remainingProcessingTime)}}) 'mean':str(remainingProcessingTime)}})
# activeEntity.remainingRoute.insert(0, [self.id, remainingProcessingTime])
activeEntity.remainingRoute.insert(0, {'stationIdsList':[str(self.lastGiver.id)],\ activeEntity.remainingRoute.insert(0, {'stationIdsList':[str(self.lastGiver.id)],\
'processingTime':\ 'processingTime':\
{'distributionType':'Fixed',\ {'distributionType':'Fixed',\
'mean':'0'}}) 'mean':'0'}})
# activeEntity.remainingRoute.insert(0, [self.lastGiver.id, 0])
#set the receiver as the object where the active entity was preempted from #set the receiver as the object where the active entity was preempted from
self.receiver=self.lastGiver self.receiver=self.lastGiver
self.next=[self.receiver] self.next=[self.receiver]
......
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