signalling in operation process corrected

parent e011ab06
...@@ -659,9 +659,8 @@ class Machine(CoreObject): ...@@ -659,9 +659,8 @@ class Machine(CoreObject):
if interruption.victim==self and interruption.waitingSignal: if interruption.victim==self and interruption.waitingSignal:
# signal it and reset the flags # signal it and reset the flags
if interruption.expectedSignals['endedLastProcessing']: if interruption.expectedSignals['endedLastProcessing']:
succeedTuple=(self,self.env.now) self.sendSignal(receiver=self, signal=self.endedLastProcessing)
self.endedLastProcessing.succeed(succeedTuple) interruption.waitingSignal=False
interruption.waitinSignal=False
self.isWorkingOnTheLast=False self.isWorkingOnTheLast=False
# set timeLastShiftEnded attribute so that if it is overtime working it is not counted as off-shift time # set timeLastShiftEnded attribute so that if it is overtime working it is not counted as off-shift time
if self.interruptedBy=='ShiftScheduler': if self.interruptedBy=='ShiftScheduler':
...@@ -845,11 +844,11 @@ class Machine(CoreObject): ...@@ -845,11 +844,11 @@ class Machine(CoreObject):
# and the processing time left # and the processing time left
self.totalProcessingTimeInCurrentEntity=self.calculateProcessingTime() # get the processing time, tinMStarts holds the processing time of the machine 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 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
processingNotFinished=True processingNotFinished=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
for oi in self.objectInterruptions: for oi in self.objectInterruptions:
...@@ -857,11 +856,11 @@ class Machine(CoreObject): ...@@ -857,11 +856,11 @@ class Machine(CoreObject):
if oi.deteriorationType=='working': if oi.deteriorationType=='working':
if oi.expectedSignals['victimStartsProcess']: if oi.expectedSignals['victimStartsProcess']:
self.sendSignal(receiver=oi, signal=oi.victimStartsProcess) self.sendSignal(receiver=oi, signal=oi.victimStartsProcess)
# this loop is repeated until the processing time is expired with no failure # this loop is repeated until the processing time is expired with no failure
# check when the processingEndedFlag switched to false # check when the processingEndedFlag switched to false
while processingNotFinished: while processingNotFinished:
self.expectedSignals['interruptionStart']=1 self.expectedSignals['interruptionStart']=1
self.expectedSignals['preemptQueue']=1 self.expectedSignals['preemptQueue']=1
...@@ -883,28 +882,28 @@ class Machine(CoreObject): ...@@ -883,28 +882,28 @@ class Machine(CoreObject):
assert eventTime==self.env.now, 'the interruption has not been processed on the time of activation' assert eventTime==self.env.now, 'the interruption has not been processed on the time of activation'
self.interruptionStart=self.env.event() self.interruptionStart=self.env.event()
self.interruptionActions() # execute interruption actions self.interruptionActions() # execute interruption actions
#=========================================================== #===========================================================
# # release the operator if there is interruption # # release the operator if there is interruption
#=========================================================== #===========================================================
if self.shouldYield(operationTypes={"Processing":1},methods={'isOperated':1}): if self.shouldYield(operationTypes={"Processing":1},methods={'isOperated':1}):
yield self.env.process(self.release()) yield self.env.process(self.release())
# loop until we reach at a state that there is no interruption # loop until we reach at a state that there is no interruption
while 1: while 1:
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()
if self.Up and self.onShift: if self.Up and self.onShift:
break break
self.postInterruptionActions() self.postInterruptionActions()
#=========================================================== #===========================================================
# # request a resource after the repair # # request a resource after the repair
#=========================================================== #===========================================================
...@@ -944,22 +943,20 @@ class Machine(CoreObject): ...@@ -944,22 +943,20 @@ class Machine(CoreObject):
assert eventTime==self.env.now, 'the preemption must be performed on the time of request' assert eventTime==self.env.now, 'the preemption must be performed on the time of request'
self.preemptQueue=self.env.event() self.preemptQueue=self.env.event()
self.interruptionActions() # execute interruption actions self.interruptionActions() # execute interruption actions
#=========================================================== #===========================================================
# # release the operator if there is interruption # # release the operator if there is interruption
#=========================================================== #===========================================================
if self.shouldYield(operationTypes={"Processing":1},methods={'isOperated':1}): if self.shouldYield(operationTypes={"Processing":1},methods={'isOperated':1}):
yield self.env.process(self.release()) yield self.env.process(self.release())
self.postInterruptionActions() self.postInterruptionActions()
break break
# if no interruption occurred the processing in M1 is ended # if no interruption occurred the processing in M1 is ended
else: else:
processingNotFinished=False processingNotFinished=False
# 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
self.endProcessingActions() 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