Commit 8339c23e authored by Ioannis Papagiannopoulos's avatar Ioannis Papagiannopoulos Committed by Georgios Dagkakis

haveToDispose update to dispose entities that finished their processing when...

haveToDispose update to dispose entities that finished their processing when an interruption took place
parent 1a6f4a36
...@@ -430,6 +430,7 @@ class Machine(CoreObject): ...@@ -430,6 +430,7 @@ class Machine(CoreObject):
# identify the method to get the operation time and initialise the totalOperationTime # identify the method to get the operation time and initialise the totalOperationTime
assert type!=None, 'there must be an operation type defined' assert type!=None, 'there must be an operation type defined'
assert type in set(['Processing','Setup']), 'the operation type provided is not yet defined' assert type in set(['Processing','Setup']), 'the operation type provided is not yet defined'
# XX
if type=='Setup': if type=='Setup':
method='calculateSetupTime' method='calculateSetupTime'
self.totalOperationTime=self.totalSetupTime self.totalOperationTime=self.totalSetupTime
...@@ -437,16 +438,20 @@ class Machine(CoreObject): ...@@ -437,16 +438,20 @@ class Machine(CoreObject):
method='calculateProcessingTime' method='calculateProcessingTime'
self.totalOperationTime=self.totalWorkingTime self.totalOperationTime=self.totalWorkingTime
from Globals import getMethodFromName from Globals import getMethodFromName
classMethod=getMethodFromName('Dream.Machine.'+method) try:
classMethod=getMethodFromName('Dream.'+str(self.__class__.__name__)+'.'+method)
except:
parents=self.__class__.__bases__
classMethod=getMethodFromName('Dream.'+str(parents[-1].__name__)+'.'+method)
# variables dedicated to hold the processing times, the time when the Entity entered, # variables dedicated to hold the processing times, the time when the Entity entered,
# and the processing time left # and the processing time left
# XX # XX
self.totalOperationTimeInCurrentEntity=self.classMethod() # get the processing time, tinMStarts holds the processing time of the machine self.totalOperationTimeInCurrentEntity=classMethod(self) # get the processing time, tinMStarts holds the processing time of the machine
# XX # XX
self.tinM=self.totalOperationTimeInCurrentEntity # timer to hold the processing time left self.tinM=self.totalOperationTimeInCurrentEntity # timer to hold the processing time left
# variables used to flag any interruptions and the end of the processing # variables used to flag any interruptions and the end of the processing
self.interruption=False self.interruption=False
# XX # XX
operationNotFinished=True operationNotFinished=True
# if there is a failure that depends on the working time of the Machine # if there is a failure that depends on the working time of the Machine
# send it the victimStartsProcess signal # send it the victimStartsProcess signal
...@@ -466,12 +471,12 @@ class Machine(CoreObject): ...@@ -466,12 +471,12 @@ class Machine(CoreObject):
# every interruption # every interruption
# XX # XX
self.timeLastOperationStarted=self.env.now self.timeLastOperationStarted=self.env.now
# if the type is setup then the time to record is timeLastProcessingStarted # # if the type is setup then the time to record is timeLastProcessingStarted
if type=='Setup': # if type=='Setup':
self.timeLastSetupStarted=self.timeLastOperationStarted # self.timeLastSetupStarted=self.timeLastOperationStarted
# else if the type is processing then the time to record is timeLastProcessingStarted # # else if the type is processing then the time to record is timeLastProcessingStarted
elif type=='Processing': # elif type=='Processing':
self.timeLastProcessingStarted=self.timeLastOperationStarted # self.timeLastProcessingStarted=self.timeLastOperationStarted
# processing starts, update the flags # processing starts, update the flags
self.isProcessing=True self.isProcessing=True
self.currentlyPerforming=type self.currentlyPerforming=type
...@@ -531,12 +536,12 @@ class Machine(CoreObject): ...@@ -531,12 +536,12 @@ class Machine(CoreObject):
# if no interruption occurred the processing in M1 is ended # if no interruption occurred the processing in M1 is ended
else: else:
# XX # XX
opeationNotFinished=False operationNotFinished=False
self.expectedSignals['interruptionStart']=0 self.expectedSignals['interruptionStart']=0
self.expectedSignals['preemptQueue']=0 self.expectedSignals['preemptQueue']=0
# carry on actions that have to take place when an Entity ends its processing # carry on actions that have to take place when an Entity ends its processing
# XX # XX
self.endOperationActions(type) # self.endOperationActions(type)
# ======================================================================= # =======================================================================
# actions to be carried out when the processing of an Entity ends # actions to be carried out when the processing of an Entity ends
...@@ -571,7 +576,7 @@ class Machine(CoreObject): ...@@ -571,7 +576,7 @@ class Machine(CoreObject):
except IndexError: except IndexError:
pass pass
# recalculate the processing time left tinM # recalculate the processing time left tinM
self.tinM=self.tinM-(self.env.now-self.timeLastProcessingStarted) self.tinM=self.tinM-(self.env.now-self.timeLastOperationStarted)
if(self.tinM==0): # sometimes the failure may happen exactly at the time that the processing would finish if(self.tinM==0): # sometimes the failure may happen exactly at the time that the processing would finish
# this may produce disagreement with the simul8 because in both SimPy and Simul8 # this may produce disagreement with the simul8 because in both SimPy and Simul8
# it seems to be random which happens 1st # it seems to be random which happens 1st
...@@ -590,11 +595,11 @@ class Machine(CoreObject): ...@@ -590,11 +595,11 @@ class Machine(CoreObject):
self.isProcessing=False self.isProcessing=False
self.currentlyPerforming=None self.currentlyPerforming=None
# add working time # add working time
if type=='Setup': self.totalOperationTime+=self.env.now-self.timeLastOperationStarted
self.totalWorkingTime+=self.env.now-self.timeLastOperationStarted if type=='Processing':
elif type=='Processing': self.totalWorkingTime=self.totalOperationTime
self.totalSetupTime+=self.env.now-self.timeLastOperationStarted elif type=='Setup':
# self.totalOperationTime+=self.env.now-self.timeLastOperationStarted self.totalSetupTime=self.totalOperationTime
# reseting variables used by operation() process # reseting variables used by operation() process
self.totalOperationTime=None self.totalOperationTime=None
self.timeLastOperationStarted=None self.timeLastOperationStarted=None
...@@ -714,14 +719,6 @@ class Machine(CoreObject): ...@@ -714,14 +719,6 @@ class Machine(CoreObject):
self.loadTimeCurrentEntity = 0 self.loadTimeCurrentEntity = 0
self.setupTimeCurrentEntity = 0 self.setupTimeCurrentEntity = 0
#===================================================================
#===================================================================
#===================================================================
# # # loading
#===================================================================
#===================================================================
#===================================================================
#=================================================================== #===================================================================
# # request a resource if there is a need for load operation # # request a resource if there is a need for load operation
#=================================================================== #===================================================================
...@@ -732,6 +729,14 @@ class Machine(CoreObject): ...@@ -732,6 +729,14 @@ class Machine(CoreObject):
self.loadOperatorWaitTimeCurrentEntity += self.timeWaitForLoadOperatorEnded-self.timeWaitForLoadOperatorStarted self.loadOperatorWaitTimeCurrentEntity += self.timeWaitForLoadOperatorEnded-self.timeWaitForLoadOperatorStarted
self.totalTimeWaitingForLoadOperator += self.loadOperatorWaitTimeCurrentEntity self.totalTimeWaitingForLoadOperator += self.loadOperatorWaitTimeCurrentEntity
#===================================================================
#===================================================================
#===================================================================
# # # loading
#===================================================================
#===================================================================
#===================================================================
# ======= Load the machine if the Load is defined as one of the Operators' operation types # ======= Load the machine if the Load is defined as one of the Operators' operation types
if any(type=="Load" for type in self.multOperationTypeList) and self.isOperated(): if any(type=="Load" for type in self.multOperationTypeList) and self.isOperated():
self.timeLoadStarted = self.env.now self.timeLoadStarted = self.env.now
...@@ -741,13 +746,20 @@ class Machine(CoreObject): ...@@ -741,13 +746,20 @@ class Machine(CoreObject):
self.loadTimeCurrentEntity = self.timeLoadEnded-self.timeLoadStarted self.loadTimeCurrentEntity = self.timeLoadEnded-self.timeLoadStarted
self.totalLoadTime += self.loadTimeCurrentEntity self.totalLoadTime += self.loadTimeCurrentEntity
#===================================================================
#===================================================================
#===================================================================
# # # end loading
#===================================================================
#===================================================================
#===================================================================
#=================================================================== #===================================================================
# # release a resource if the only operation type is Load # # release a resource if the only operation type is Load
#=================================================================== #===================================================================
if self.shouldYield(operationTypes={"Load":1, "Processing":0,"Setup":0},methods={'isOperated':1}): if self.shouldYield(operationTypes={"Load":1, "Processing":0,"Setup":0},methods={'isOperated':1}):
yield self.env.process(self.release()) yield self.env.process(self.release())
#=================================================================== #===================================================================
#=================================================================== #===================================================================
#=================================================================== #===================================================================
...@@ -765,12 +777,6 @@ class Machine(CoreObject): ...@@ -765,12 +777,6 @@ class Machine(CoreObject):
# TODO: the Machine receive the entity after the operator is available # TODO: the Machine receive the entity after the operator is available
# the canAcceptAndIsRequested method checks only in case of Load type of operation # the canAcceptAndIsRequested method checks only in case of Load type of operation
# variables dedicated to hold the processing times, the time when the Entity entered,
# and the processing time left
self.totalProcessingTimeInCurrentEntity=self.calculateProcessingTime() # get the processing time, tinMStarts holds the processing time of the machine
self.tinM=self.totalProcessingTimeInCurrentEntity # timer to hold the processing time left
#=================================================================== #===================================================================
# # request a resource if it is not already assigned an Operator # # request a resource if it is not already assigned an Operator
#=================================================================== #===================================================================
...@@ -798,6 +804,14 @@ class Machine(CoreObject): ...@@ -798,6 +804,14 @@ class Machine(CoreObject):
self.setupTimeCurrentEntity = self.timeSetupEnded-self.timeSetupStarted self.setupTimeCurrentEntity = self.timeSetupEnded-self.timeSetupStarted
self.totalSetupTime += self.setupTimeCurrentEntity self.totalSetupTime += self.setupTimeCurrentEntity
#===================================================================
#===================================================================
#===================================================================
# # # end setup
#===================================================================
#===================================================================
#===================================================================
#=================================================================== #===================================================================
# # release a resource at the end of setup # # release a resource at the end of setup
#=================================================================== #===================================================================
...@@ -812,6 +826,13 @@ class Machine(CoreObject): ...@@ -812,6 +826,13 @@ class Machine(CoreObject):
#=================================================================== #===================================================================
#=================================================================== #===================================================================
# yield self.env.process(self.operation(type='Processing'))
# self.endOperationActions(type='Processing')
# variables dedicated to hold the processing times, the time when the Entity entered,
# and the processing time left
self.totalProcessingTimeInCurrentEntity=self.calculateProcessingTime() # get the processing time, tinMStarts holds the processing time of the machine
self.tinM=self.totalProcessingTimeInCurrentEntity # timer to hold the processing time left
# variables used to flag any interruptions and the end of the processing # variables used to flag any interruptions and the end of the processing
self.interruption=False self.interruption=False
...@@ -863,6 +884,8 @@ class Machine(CoreObject): ...@@ -863,6 +884,8 @@ class Machine(CoreObject):
self.expectedSignals['interruptionEnd']=1 self.expectedSignals['interruptionEnd']=1
yield self.interruptionEnd # interruptionEnd to be triggered by ObjectInterruption yield self.interruptionEnd # interruptionEnd to be triggered by ObjectInterruption
transmitter, eventTime=self.interruptionEnd.value transmitter, eventTime=self.interruptionEnd.value
assert eventTime==self.env.now, 'the interruptionEnd was received later than anticipated' assert eventTime==self.env.now, 'the interruptionEnd was received later than anticipated'
self.interruptionEnd=self.env.event() self.interruptionEnd=self.env.event()
...@@ -924,6 +947,9 @@ class Machine(CoreObject): ...@@ -924,6 +947,9 @@ class Machine(CoreObject):
processingNotFinished=False processingNotFinished=False
# carry on actions that have to take place when an Entity ends its processing
self.endProcessingActions()
#=================================================================== #===================================================================
#=================================================================== #===================================================================
#=================================================================== #===================================================================
...@@ -932,16 +958,20 @@ class Machine(CoreObject): ...@@ -932,16 +958,20 @@ class Machine(CoreObject):
#=================================================================== #===================================================================
#=================================================================== #===================================================================
# carry on actions that have to take place when an Entity ends its processing
self.endProcessingActions()
#=================================================================== #===================================================================
# # release resource after the end of processing # # release resource after the end of processing
#=================================================================== #===================================================================
if self.shouldYield(operationTypes={"Processing":1},methods={'isInterrupted':0, 'isOperated':1}): if self.shouldYield(operationTypes={"Processing":1},methods={'isInterrupted':0, 'isOperated':1}):
yield self.env.process(self.release()) yield self.env.process(self.release())
#===================================================================
#===================================================================
#===================================================================
# # # disposing if not already emptied
#===================================================================
#===================================================================
#===================================================================
# signal the receiver that the activeObject has something to dispose of # signal the receiver that the activeObject has something to dispose of
if not self.signalReceiver(): if not self.signalReceiver():
# if there was no available receiver, get into blocking control # if there was no available receiver, get into blocking control
...@@ -1291,12 +1321,18 @@ class Machine(CoreObject): ...@@ -1291,12 +1321,18 @@ class Machine(CoreObject):
#if we have only one successor just check if machine waits to dispose and also is up #if we have only one successor just check if machine waits to dispose and also is up
# this is done to achieve better (cpu) processing time # this is done to achieve better (cpu) processing time
if(callerObject==None): if(callerObject==None):
return len(activeObjectQueue)>0 and self.waitToDispose and (self.canDeliverOnInterruption or self.checkIfActive()) return len(activeObjectQueue)>0\
and self.waitToDispose\
and (self.canDeliverOnInterruption
or self.timeLastEntityEnded==self.env.now
or self.checkIfActive())
thecaller=callerObject thecaller=callerObject
return len(activeObjectQueue)>0\ return len(activeObjectQueue)>0\
and self.waitToDispose\ and self.waitToDispose\
and (thecaller in self.next)\ and (thecaller in self.next)\
and (self.canDeliverOnInterruption or self.checkIfActive()) and (self.canDeliverOnInterruption
or self.timeLastEntityEnded==self.env.now
or self.checkIfActive())
# ======================================================================= # =======================================================================
# calculates the setup time # calculates the setup 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