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

CoreObjects updated so that blockage is calculated in removeEntity

parent 178576c6
......@@ -120,8 +120,9 @@ class Assembly(CoreObject):
self.timeLastFrameWasFull=now()
self.nameLastFrameWasFull=self.getActiveObjectQueue()[0].name
startWorkingTime=now()
yield hold,self,self.rng.generateNumber() #hold for the time the assembly operation is carried
startWorkingTime=now()
self.totalProcessingTimeInCurrentEntity=self.calculateProcessingTime()
yield hold,self,self.totalProcessingTimeInCurrentEntity #hold for the time the assembly operation is carried
self.totalWorkingTime+=now()-startWorkingTime
self.outputTrace(self.getActiveObjectQueue()[0].name, "ended processing in " + self.objName)
......@@ -136,7 +137,7 @@ class Assembly(CoreObject):
if self.next[0].getGiverObject()==self: #if the free object can accept from this Assembly
#break. Else continue
break
self.totalBlockageTime+=now()-startBlockageTime #add the blockage time
#self.totalBlockageTime+=now()-startBlockageTime #add the blockage time
#checks if the Assembly can accept an entity
......@@ -208,6 +209,7 @@ class Assembly(CoreObject):
#actions to be taken after the simulation ends
def postProcessing(self, MaxSimtime=None):
if MaxSimtime==None:
from Globals import G
MaxSimtime=G.maxSimTime
......
......@@ -96,7 +96,8 @@ class BatchDecomposition(CoreObject):
self.nameLastEntityEntered=self.currentEntity.name # this holds the name of the last entity that got into Machine
self.timeLastEntityEntered=now() #this holds the last time that an entity got into Machine
yield hold,self,self.calculateProcessingTime()
self.totalProcessingTimeInCurrentEntity=self.calculateProcessingTime()
yield hold,self,self.totalProcessingTimeInCurrentEntity
self.decompose()
......
......@@ -228,6 +228,12 @@ class Conveyer(CoreObject):
activeEntity=CoreObject.removeEntity(self) #run the default method
self.position.pop(0)
#revert the blockage calculation
#conveyer needs its customcalculation
blockage=now()-(self.timeLastEntityEnded+self.downTimeInTryingToReleaseCurrentEntity)
self.totalBlockageTime-=blockage
self.waitToDispose=False
#if the conveyer was full, it means that it also was blocked
#we count this blockage time
......
......@@ -82,6 +82,15 @@ class CoreObject(Process):
# then the giverObjects have to be blocked for the time
# that the machine is being loaded
# ============================== lists to hold statistics of multiple runs =====================
self.totalTimeWaitingForOperator=0
self.operatorWaitTimeCurrentEntity=0
self.totalTimeInCurrentEntity=0
self.operatorWaitTimeCurrentEntity=0
self.totalProcessingTimeInCurrentEntity=0
self.failureTimeInCurrentEntity=0
self.setupTimeCurrentEntity=0
self.Failure=[]
self.Working=[]
self.Blockage=[]
......@@ -99,9 +108,21 @@ class CoreObject(Process):
# ================================== removes an entity from the Object ==========================
def removeEntity(self):
self.totalTimeInCurrentEntity=now()-self.timeLastEntityEntered
self.totalTimeWaitingForOperator += self.operatorWaitTimeCurrentEntity
#blockage=self.totalTimeInCurrentEntity-(self.totalProcessingTimeInCurrentEntity\
# +self.failureTimeInCurrentEntity\
# +self.operatorWaitTimeCurrentEntity\
# +self.setupTimeCurrentEntity)
blockage=now()-(self.timeLastEntityEnded+self.downTimeInTryingToReleaseCurrentEntity)
self.totalBlockageTime+=blockage
activeObjectQueue=self.getActiveObjectQueue()
activeEntity=activeObjectQueue[0]
activeObjectQueue.pop(0) #remove the Entity from the queue
self.failureTimeInCurrentEntity=0
self.downTimeInTryingToReleaseCurrentEntity=0
self.timeLastEntityLeft=now()
try:
self.outputTrace(activeEntity.name, "released "+self.objName)
......
......@@ -117,7 +117,10 @@ class Dismantle(CoreObject):
self.timeLastEntityEntered=now()
startWorkingTime=now()
yield hold,self,self.rng.generateNumber() #hold for the time the dismantle operation is carried
self.totalProcessingTimeInCurrentEntity=self.calculateProcessingTime()
yield hold,self,self.totalProcessingTimeInCurrentEntity #hold for the time the assembly operation is carried
self.totalWorkingTime+=now()-startWorkingTime
self.timeLastEntityEnded=now()
......@@ -131,7 +134,7 @@ class Dismantle(CoreObject):
self.completedJobs+=1 #Dismantle completed a job
self.waitToDisposeFrame=False #the Dismantle has no Frame to dispose now
self.totalBlockageTime+=now()-startBlockageTime #add the blockage time
#self.totalBlockageTime+=now()-startBlockageTime #add the blockage time
#checks if the Dismantle can accept an entity and there is a Frame waiting for it
......@@ -189,7 +192,14 @@ class Dismantle(CoreObject):
#removes an entity from the Dismantle
def removeEntity(self):
activeObjectQueue=self.getActiveObjectQueue()
activeEntity=CoreObject.removeEntity(self) #run the default method
activeEntity=CoreObject.removeEntity(self) #run the default method
#we want the blockagetobeadded only if we disposed a frame!
#if a part was disposed rever
if activeEntity.type=='Part':
blockage=now()-(self.timeLastEntityEnded+self.downTimeInTryingToReleaseCurrentEntity)
self.totalBlockageTime-=blockage
#update the flags
if(len(activeObjectQueue)==0):
self.waitToDisposeFrame=False
......
......@@ -99,15 +99,15 @@ class Machine(CoreObject):
# variables dedicated to hold the processing times, the time when the Entity entered,
# and the processing time left
timeEntered=now() # timeEntered dummy Timer that holds the time the last Entity Entered
tinMStart=self.calculateProcessingTime() # get the processing time, tinMStarts holds the processing time of the machine
tinM=tinMStart # timer to hold the processing time left
self.processingTimeOfCurrentEntity=tinMStart # processing time of the machine
self.totalProcessingTimeInCurrentEntity=self.calculateProcessingTime() # get the processing time, tinMStarts holds the processing time of the machine
tinM=self.totalProcessingTimeInCurrentEntity # timer to hold the processing time left
#self.processingTimeOfCurrentEntity=self.totalProcessingTimeInCurrentEntity # processing time of the machine
# variables used to flag any interruptions and the end of the processing
interruption=False
processingEndedFlag=True
# timers to follow up the failure time of the machine while on current Entity
failureTime=0 # dummy variable keeping track of the failure time
#self.failureTimeInCurrentEntity=0 # dummy variable keeping track of the failure time
# might be feasible to avoid it
self.downTimeInCurrentEntity=0 #holds the total time that the
#object was down while holding current entity
......@@ -141,7 +141,7 @@ class Machine(CoreObject):
self.downTimeProcessingCurrentEntity+=now()-breakTime # count the time that Machine is down while processing this Entity
self.downTimeInCurrentEntity+=now()-breakTime # count the time that Machine is down while on currentEntity
self.timeLastFailureEnded=now() # set the timeLastFailureEnded
failureTime+=now()-breakTime # dummy variable keeping track of the failure time
self.failureTimeInCurrentEntity+=now()-breakTime # dummy variable keeping track of the failure time
# output to trace that the Machine self.objName was passivated for the current failure time
self.outputTrace(self.getActiveObjectQueue()[0].name, "passivated in "+self.objName+" for "+str(now()-breakTime))
# if no interruption occurred the processing in M1 is ended
......@@ -152,7 +152,7 @@ class Machine(CoreObject):
# set the variable that flags an Entity is ready to be disposed
self.waitToDispose=True
# update the total working time
self.totalWorkingTime+=tinMStart # the total processing time for this entity
self.totalWorkingTime+=self.totalProcessingTimeInCurrentEntity # the total processing time for this entity
# is what the distribution initially gave
# update the variables keeping track of Entity related attributes of the machine
......@@ -167,7 +167,7 @@ class Machine(CoreObject):
reqTime=now() # entity has ended processing in Machine and requests for the next object
# initialize the timer downTimeInTryingToReleaseCurrentEntity, we have to count how much time
# the Entity will wait for the next successor to be able to accept (canAccept)
self.downTimeInTryingToReleaseCurrentEntity=0
#self.downTimeInTryingToReleaseCurrentEntity=0
while 1:
# wait until the next Object is available or machine has failure
......@@ -181,7 +181,7 @@ class Machine(CoreObject):
failTime=now() # dummy variable holding the time failure happened
# passivate until machine is up
yield waituntil, self, self.checkIfMachineIsUp
failureTime+=now()-failTime # count the failure while on current entity time with failureTime variable
self.failureTimeInCurrentEntity+=now()-failTime # count the failure while on current entity time with failureTime variable
# calculate the time the Machine was down while trying to dispose the current Entity,
# and the total down time while on current Entity
self.downTimeInTryingToReleaseCurrentEntity+=now()-failTime
......@@ -189,12 +189,12 @@ class Machine(CoreObject):
# update the timeLastFailureEnded
self.timeLastFailureEnded=now()
totalTime=now()-timeEntered # dummy variable holding the total time the Entity spent in the Machine
blockageTime=totalTime-(tinMStart+failureTime) # count the time the Machine was blocked subtracting the failureTime
#self.totalTimeInCurrentEntity=now()-timeEntered # dummy variable holding the total time the Entity spent in the Machine
#blockageTime=totalTime-(tinMStart+failureTime) # count the time the Machine was blocked subtracting the failureTime
# and the processing time from the totalTime spent in the Machine
# might be possible to avoid using blockageTime
# self.totalBlockageTime+=blockageTime
self.totalBlockageTime+=totalTime-(tinMStart+failureTime) #the time of blockage is derived from
#self.totalBlockageTime+=totalTime-(tinMStart+self.failureTimeInCurrentEntity) #the time of blockage is derived from
#the whole time in the machine
#minus the processing time and the failure time
# =======================================================================
......@@ -305,7 +305,6 @@ class Machine(CoreObject):
# give the entity to the successor that is waiting for the most time.
# (plant simulation does not do this in every occasion!)
maxTimeWaiting=0 # dummy variable counting the time a successor is waiting
i=0 # index used to set the successorIndex to the giver waiting the most
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
......@@ -314,7 +313,7 @@ class Machine(CoreObject):
activeObject.receiver=object # set the receiver as the longest waiting possible receiver
# in the next loops, check the other successors in the previous list
return len(activeObjectQueue)>0 and activeObject.waitToDispose\
and activeObject.Up and (thecaller is receiverObject)
and activeObject.Up and (thecaller is self.receiver)
# =======================================================================
# actions to be taken after the simulation ends
......
......@@ -226,9 +226,9 @@ class OperatedMachine(Machine):
# print self.objName, 'operator assigned', now()
tinMStart=self.calculateProcessingTime() # get the processing time, tinMStarts holds the processing time of the machine
tinM=tinMStart # timer to hold the processing time left
self.processingTimeOfCurrentEntity=tinMStart # processing time of the machine
self.totalProcessingTimeInCurrentEntity=self.calculateProcessingTime() # get the processing time, tinMStarts holds the processing time of the machine
tinM=self.totalProcessingTimeInCurrentEntity # timer to hold the processing time left
#self.processingTimeOfCurrentEntity=tinMStart # processing time of the machine
# ======= setup the machine if the Setup is defined as one of the Operators' operation types
# in plantSim the setup is performed when the machine has to process a new type of Entity and only once
......@@ -336,7 +336,7 @@ class OperatedMachine(Machine):
# set the variable that flags an Entity is ready to be disposed
self.waitToDispose=True
# update the total working time
self.totalWorkingTime+=tinMStart # the total processing time for this entity
self.totalWorkingTime+=self.totalProcessingTimeInCurrentEntity # the total processing time for this entity
# is what the distribution initially gave
# update the variables keeping track of Entity related attributes of the machine
......@@ -377,16 +377,16 @@ class OperatedMachine(Machine):
# dummy variable holding the total time the Entity spent in the Machine
# count the time the Machine was blocked subtracting the failureTime
# and the processing time from the totalTime spent in the Machine
totalTime=now()-timeEntered
self.totalTimeInCurrentEntity=now()-timeEntered
# update the total time waiting for the operator of the machine
self.totalTimeWaitingForOperator += self.operatorWaitTimeCurrentEntity
blockageTime=totalTime-(tinMStart\
+failureTime\
+self.operatorWaitTimeCurrentEntity\
+self.setupTimeCurrentEntity)
# self.totalTimeWaitingForOperator += self.operatorWaitTimeCurrentEntity
# blockageTime=totalTime-(tinMStart\
# +failureTime\
# +self.operatorWaitTimeCurrentEntity\
# +self.setupTimeCurrentEntity)
# might be possible to avoid using blockageTime
self.totalBlockageTime+=blockageTime
# the time of blockage is derived from
# the whole time in the machine minus the processing time and the failure time
# self.totalBlockageTime+=totalTime-(tinMStart\
......@@ -426,6 +426,7 @@ class OperatedMachine(Machine):
thecaller=callerObject
# return True ONLY if the length of the activeOjbectQue is smaller than
# the object capacity, and the callerObject is not None but the giverObject
if (activeObject.operatorPool!='None' and any(type=='Load' for type in activeObject.multOperationTypeList)):
return activeObject.operatorPool.checkIfResourceIsAvailable()\
and activeObject.Up\
......@@ -496,7 +497,7 @@ class OperatedMachine(Machine):
if(timeWaiting>=maxTimeWaiting):
activeObject.giver=object # set the giver
maxTimeWaiting=timeWaiting
if (activeObject.operatorPool!='None' and any(type=='Load' for type in activeObject.multOperationTypeList)):
if activeObject.operatorPool.checkIfResourceIsAvailable()\
and activeObject.Up and len(activeObjectQueue)<activeObject.capacity\
......@@ -600,8 +601,6 @@ class OperatedMachine(Machine):
def requestSetup(self):
self.setUp=False
# =======================================================================
# actions to be taken after the simulation ends
# =======================================================================
......@@ -681,8 +680,8 @@ class OperatedMachine(Machine):
activeObject.totalBlockageTime+=(now()-activeObject.timeLastEntityEnded)-(now()-activeObject.timeLastFailure)-activeObject.downTimeInTryingToReleaseCurrentEntity
# print activeObject.objName,'total Block time:',activeObject.totalBlockageTime#/G.maxSimTime
#Machine was idle when it was not in any other state
activeObject.totalWaitingTime=MaxSimtime-activeObject.totalWorkingTime-activeObject.totalBlockageTime-activeObject.totalFailureTime
# print activeObject.objName,'total waiting time:',activeObject.totalWaitingTime#/G.maxSimTime
if activeObject.totalBlockageTime<0 and activeObject.totalBlockageTime>-0.00001: #to avoid some effects of getting negative cause of rounding precision
self.totalBlockageTime=0
......
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