operation process in action for the default processing operation. not all tests succeed

parent 84513dbf
......@@ -837,128 +837,129 @@ class Machine(CoreObject):
#===================================================================
#===================================================================
# yield self.env.process(self.operation(type='Processing'))
# self.endOperationActions(type='Processing')
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
# self.interruption=False
# processingNotFinished=True
#
# # if there is a failure that depends on the working time of the Machine
# # send it the victimStartsProcess signal
# for oi in self.objectInterruptions:
# if oi.type=='Failure':
# if oi.deteriorationType=='working':
# if oi.expectedSignals['victimStartsProcess']:
# self.sendSignal(receiver=oi, signal=oi.victimStartsProcess)
#
# # this loop is repeated until the processing time is expired with no failure
# # check when the processingEndedFlag switched to false
#
#
# while processingNotFinished:
# self.expectedSignals['interruptionStart']=1
# self.expectedSignals['preemptQueue']=1
# self.expectedSignals['processOperatorUnavailable']=1
# # timeLastProcessingStarted : dummy variable to keep track of the time that the processing starts after
# # every interruption
# self.timeLastProcessingStarted=self.env.now
# # processing starts, update the flag
# self.isProcessing=True
# self.currentlyPerforming=None
# # wait for the processing time left tinM, if no interruption occurs then change the processingEndedFlag and exit loop,
# # else (if interrupted()) set interruption flag to true (only if tinM==0),
# # and recalculate the processing time left tinM, passivate while waiting for repair.
# # if a preemption has occurred then react accordingly (proceed with getting the critical entity)
# receivedEvent = yield self.env.any_of([self.interruptionStart, self.env.timeout(self.tinM) ,
# self.preemptQueue, self.processOperatorUnavailable])
# if self.interruptionStart in receivedEvent: # if a failure occurs while processing the machine is interrupted.
# transmitter, eventTime=self.interruptionStart.value
# assert eventTime==self.env.now, 'the interruption has not been processed on the time of activation'
# self.interruptionStart=self.env.event()
# self.interruptionActions() # execute interruption actions
#
# #===========================================================
# # # release the operator if there is interruption
# #===========================================================
# if self.shouldYield(operationTypes={"Processing":1},methods={'isOperated':1}):
# yield self.env.process(self.release())
#
# # loop until we reach at a state that there is no interruption
# while 1:
#
# self.expectedSignals['interruptionEnd']=1
#
# yield self.interruptionEnd # interruptionEnd to be triggered by ObjectInterruption
#
#
# transmitter, eventTime=self.interruptionEnd.value
# assert eventTime==self.env.now, 'the interruptionEnd was received later than anticipated'
# self.interruptionEnd=self.env.event()
# if self.Up and self.onShift:
# break
# self.postInterruptionActions()
#
# #===========================================================
# # # request a resource after the repair
# #===========================================================
# if self.shouldYield(operationTypes={"Processing":1}, methods={"isInterrupted":0}):
# self.timeWaitForOperatorStarted = self.env.now
# yield self.env.process(self.request())
# self.timeWaitForOperatorEnded = self.env.now
# self.operatorWaitTimeCurrentEntity += self.timeWaitForOperatorEnded-self.timeWaitForOperatorStarted
# # if the processing operator left
# elif self.processOperatorUnavailable in receivedEvent:
# transmitter, eventTime=self.processOperatorUnavailable.value
# assert self.env.now==eventTime, 'the operator leaving has not been processed at \
# the time it should'
# self.processOperatorUnavailable=self.env.event()
# # carry interruption actions
# self.interruptionActions()
# # machine has to release the operator
# self.releaseOperator()
# self.expectedSignals['brokerIsSet']=1
# yield self.brokerIsSet
# self.brokerIsSet=self.env.event()
# from Globals import G
# # append the entity that was stopped to the pending ones
# if G.Router:
# G.pendingEntities.append(self.currentEntity)
# # machine has to request again for operaror
# self.requestOperator()
# self.expectedSignals['brokerIsSet']=1
# yield self.brokerIsSet
# self.brokerIsSet=self.env.event()
# # carry post interruption actions
# self.postInterruptionActions()
# # if the station is reactivated by the preempt method
# elif(self.shouldPreempt):
# if (self.preemptQueue in receivedEvent):
# transmitter, eventTime=self.preemptQueue.value
# assert eventTime==self.env.now, 'the preemption must be performed on the time of request'
# self.preemptQueue=self.env.event()
# self.interruptionActions() # execute interruption actions
#
# #===========================================================
# # # release the operator if there is interruption
# #===========================================================
# if self.shouldYield(operationTypes={"Processing":1},methods={'isOperated':1}):
# yield self.env.process(self.release())
#
# self.postInterruptionActions()
# break
#
# # if no interruption occurred the processing in M1 is ended
# else:
# processingNotFinished=False
#
# # carry on actions that have to take place when an Entity ends its processing
# self.endProcessingActions()
# 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
self.interruption=False
processingNotFinished=True
# if there is a failure that depends on the working time of the Machine
# send it the victimStartsProcess signal
for oi in self.objectInterruptions:
if oi.type=='Failure':
if oi.deteriorationType=='working':
if oi.expectedSignals['victimStartsProcess']:
self.sendSignal(receiver=oi, signal=oi.victimStartsProcess)
# this loop is repeated until the processing time is expired with no failure
# check when the processingEndedFlag switched to false
while processingNotFinished:
self.expectedSignals['interruptionStart']=1
self.expectedSignals['preemptQueue']=1
self.expectedSignals['processOperatorUnavailable']=1
# timeLastProcessingStarted : dummy variable to keep track of the time that the processing starts after
# every interruption
self.timeLastProcessingStarted=self.env.now
# processing starts, update the flag
self.isProcessing=True
self.currentlyPerforming=None
# wait for the processing time left tinM, if no interruption occurs then change the processingEndedFlag and exit loop,
# else (if interrupted()) set interruption flag to true (only if tinM==0),
# and recalculate the processing time left tinM, passivate while waiting for repair.
# if a preemption has occurred then react accordingly (proceed with getting the critical entity)
receivedEvent = yield self.env.any_of([self.interruptionStart, self.env.timeout(self.tinM) ,
self.preemptQueue, self.processOperatorUnavailable])
if self.interruptionStart in receivedEvent: # if a failure occurs while processing the machine is interrupted.
transmitter, eventTime=self.interruptionStart.value
assert eventTime==self.env.now, 'the interruption has not been processed on the time of activation'
self.interruptionStart=self.env.event()
self.interruptionActions() # execute interruption actions
#===========================================================
# # release the operator if there is interruption
#===========================================================
if self.shouldYield(operationTypes={"Processing":1},methods={'isOperated':1}):
yield self.env.process(self.release())
# loop until we reach at a state that there is no interruption
while 1:
self.expectedSignals['interruptionEnd']=1
yield self.interruptionEnd # interruptionEnd to be triggered by ObjectInterruption
transmitter, eventTime=self.interruptionEnd.value
assert eventTime==self.env.now, 'the interruptionEnd was received later than anticipated'
self.interruptionEnd=self.env.event()
if self.Up and self.onShift:
break
self.postInterruptionActions()
#===========================================================
# # request a resource after the repair
#===========================================================
if self.shouldYield(operationTypes={"Processing":1}, methods={"isInterrupted":0}):
self.timeWaitForOperatorStarted = self.env.now
yield self.env.process(self.request())
self.timeWaitForOperatorEnded = self.env.now
self.operatorWaitTimeCurrentEntity += self.timeWaitForOperatorEnded-self.timeWaitForOperatorStarted
# if the processing operator left
elif self.processOperatorUnavailable in receivedEvent:
transmitter, eventTime=self.processOperatorUnavailable.value
assert self.env.now==eventTime, 'the operator leaving has not been processed at \
the time it should'
self.processOperatorUnavailable=self.env.event()
# carry interruption actions
self.interruptionActions()
# machine has to release the operator
self.releaseOperator()
self.expectedSignals['brokerIsSet']=1
yield self.brokerIsSet
self.brokerIsSet=self.env.event()
from Globals import G
# append the entity that was stopped to the pending ones
if G.Router:
G.pendingEntities.append(self.currentEntity)
# machine has to request again for operaror
self.requestOperator()
self.expectedSignals['brokerIsSet']=1
yield self.brokerIsSet
self.brokerIsSet=self.env.event()
# carry post interruption actions
self.postInterruptionActions()
# if the station is reactivated by the preempt method
elif(self.shouldPreempt):
if (self.preemptQueue in receivedEvent):
transmitter, eventTime=self.preemptQueue.value
assert eventTime==self.env.now, 'the preemption must be performed on the time of request'
self.preemptQueue=self.env.event()
self.interruptionActions() # execute interruption actions
#===========================================================
# # release the operator if there is interruption
#===========================================================
if self.shouldYield(operationTypes={"Processing":1},methods={'isOperated':1}):
yield self.env.process(self.release())
self.postInterruptionActions()
break
# if no interruption occurred the processing in M1 is ended
else:
processingNotFinished=False
# carry on actions that have to take place when an Entity ends its processing
self.endProcessingActions()
#===================================================================
#===================================================================
#===================================================================
......
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