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

modifications so that the off-shift time can be counted and outputted

parent ff41e5a6
......@@ -44,6 +44,7 @@ class CoreObject(Process):
self.Working=[]
self.Blockage=[]
self.Waiting=[]
self.OffShift=[]
#default attributes set so that the CoreObject has them
self.isPreemptive=False
......@@ -61,6 +62,7 @@ class CoreObject(Process):
self.totalFailureTime=0 #holds the total failure time
self.totalWaitingTime=0 #holds the total waiting time
self.totalWorkingTime=0 #holds the total working time
self.totalOffShiftTime=0 #holds the total off-shift time
self.completedJobs=0 #holds the number of completed jobs
# ============================== Entity related attributes =================================
self.timeLastEntityEnded=0 #holds the last time that an entity ended processing in the object
......@@ -68,7 +70,9 @@ class CoreObject(Process):
self.timeLastEntityEntered=0 #holds the last time that an entity entered in the object
self.nameLastEntityEntered="" #holds the name of the last entity that entered in the object
self.timeLastFailure=0 #holds the time that the last failure of the object started
self.timeLastFailureEnded=0 #holds the time that the last failure of the object Ended
self.timeLastFailureEnded=0 #holds the time that the last failure of the object ended
self.timeLastShiftStarted=0 #holds the time that the last shift of the object started
self.timeLastShiftEnded=0 #holds the time that the last shift of the object ended
# ============================== failure related times =====================================
self.downTimeProcessingCurrentEntity=0 #holds the time that the machine was down while
#processing the current entity
......
......@@ -667,6 +667,12 @@ class Machine(CoreObject):
if nextObject.canAccept():
mightBeBlocked=False
#calculate the offShift time for current entity
if self.onShift==False:
offShiftTimeInCurrentEntity=now()-activeObject.timeLastShiftEnded
else:
offShiftTimeInCurrentEntity=0
# if there is an entity that finished processing in a Machine but did not get to reach
# the following Object till the end of simulation,
# we have to add this blockage to the percentage of blockage in Machine
......@@ -691,7 +697,8 @@ class Machine(CoreObject):
activeObject.totalWorkingTime+=now()-activeObject.timeLastEntityEntered\
-activeObject.downTimeProcessingCurrentEntity\
-activeObject.operatorWaitTimeCurrentEntity\
-activeObject.setupTimeCurrentEntity
-activeObject.setupTimeCurrentEntity\
-offShiftTimeInCurrentEntity
activeObject.totalTimeWaitingForOperator+=activeObject.operatorWaitTimeCurrentEntity
elif(len(activeObject.getActiveObjectQueue())>0)\
and (not (activeObject.nameLastEntityEnded==activeObject.nameLastEntityEntered))\
......@@ -700,19 +707,28 @@ class Machine(CoreObject):
if self.Up==False:
activeObject.downTimeProcessingCurrentEntity+=now()-activeObject.timeLastFailure
activeObject.totalTimeWaitingForOperator+=now()-activeObject.timeWaitForOperatorStarted\
-activeObject.downTimeProcessingCurrentEntity
-activeObject.downTimeProcessingCurrentEntity\
-offShiftTimeInCurrentEntity
# if Machine is down we have to add this failure time to its total failure time
# we also need to add the last blocking time to total blockage time
if(activeObject.Up==False):
activeObject.totalFailureTime+=now()-activeObject.timeLastFailure
# we add the value only if it hasn't already been added
#if((len(self.next[0].Res.activeQ)>0) and (self.nameLastEntityEnded==self.nameLastEntityEntered) and (not alreadyAdded)):
if((mightBeBlocked) and (activeObject.nameLastEntityEnded==activeObject.nameLastEntityEntered) and (not alreadyAdded)):
activeObject.totalBlockageTime+=(now()-activeObject.timeLastEntityEnded)-(now()-activeObject.timeLastFailure)-activeObject.downTimeInTryingToReleaseCurrentEntity
alreadyAdded=True
#if the machine is off shift,add this to the off-shift time
# we also need to add the last blocking time to total blockage time
if activeObject.onShift==False:
self.totalOffShiftTime+=now()-self.timeLastShiftEnded
# we add the value only if it hasn't already been added
if((mightBeBlocked) and (activeObject.nameLastEntityEnded==activeObject.nameLastEntityEntered) and (not alreadyAdded)):
activeObject.totalBlockageTime+=(now()-activeObject.timeLastEntityEnded)-(now()-activeObject.timeLastShiftEnded)-offShiftTimeInCurrentEntity
#Machine was idle when it was not in any other state
activeObject.totalWaitingTime=MaxSimtime-activeObject.totalWorkingTime-activeObject.totalBlockageTime-activeObject.totalFailureTime-activeObject.totalLoadTime-activeObject.totalSetupTime
activeObject.totalWaitingTime=MaxSimtime-activeObject.totalWorkingTime-activeObject.totalBlockageTime-activeObject.totalFailureTime-activeObject.totalLoadTime-activeObject.totalSetupTime-self.totalOffShiftTime
if activeObject.totalBlockageTime<0 and activeObject.totalBlockageTime>-0.00001: #to avoid some effects of getting negative cause of rounding precision
self.totalBlockageTime=0
......@@ -728,6 +744,8 @@ class Machine(CoreObject):
activeObject.WaitingForLoadOperator.append(100*self.totalTimeWaitingForLoadOperator/MaxSimtime)
activeObject.Loading.append(100*self.totalLoadTime/MaxSimtime)
activeObject.SettingUp.append(100*self.totalSetupTime/MaxSimtime)
activeObject.OffShift.append(100*self.totalOffShiftTime/MaxSimtime)
# =======================================================================
# outputs the the "output.xls"
......@@ -815,6 +833,9 @@ class Machine(CoreObject):
json['results']['working_ratio']=100*self.totalWorkingTime/G.maxSimTime
json['results']['blockage_ratio']=100*self.totalBlockageTime/G.maxSimTime
json['results']['waiting_ratio']=100*self.totalWaitingTime/G.maxSimTime
#output the off-shift time only if there is any
if self.totalOffShiftTime:
json['results']['off_shift_ratio']=100*self.totalOffShiftTime/G.maxSimTime
if any(type=='Setup' for type in self.multOperationTypeList):
json['results']['setup_ratio']=100*self.totalSetupTime/G.maxSimTime
if any(type=='Load' for type in self.multOperationTypeList):
......
......@@ -64,7 +64,7 @@ class ShiftScheduler(ObjectInterruption):
if(len(self.getVictimQueue())>0 and self.victim.interruptCause and not(self.endUnfinished)):
self.reactivateVictim() # re-activate the victim in case it was interrupted
#self.victim.totalFailureTime+=now()-offShiftTime
self.victim.totalOffShiftTime+=now()-offShiftTime
self.victim.onShift=True
self.victim.timeLastShiftStarted=now()
self.outputTrace("is on shift")
......@@ -76,6 +76,7 @@ class ShiftScheduler(ObjectInterruption):
self.interruptVictim() # interrupt processing operations if any
self.victim.onShift=False # get the victim off-shift
offShiftTime=now()
self.victim.timeLastShiftEnded=now()
self.outputTrace("is off shift")
self.remainingShiftPattern.pop(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