correction to machines operation() method. comments added to shouldYield() method

parent 6ea9e7c0
...@@ -330,9 +330,10 @@ class Machine(CoreObject): ...@@ -330,9 +330,10 @@ class Machine(CoreObject):
#=========================================================================== #===========================================================================
def shouldYield(self, operationTypes={}, methods={}): def shouldYield(self, operationTypes={}, methods={}):
''' '''
"methods":{'isInterrupted':'0'}, Method that controls if the machine should yield for releasing the operator
"operationTypes"={"Processing":1, % must "methods":{'isInterrupted':'0'}, % the method isInterrupted should return False (0) or True (1)
"Setup":0 % must NOT "operationTypes"={"Processing":1, % processing must be in multiOperationTypeList
"Setup":0 % setup must not be in multiOperationTypeList
} }
''' '''
operationsRequired=[] operationsRequired=[]
...@@ -346,6 +347,7 @@ class Machine(CoreObject): ...@@ -346,6 +347,7 @@ class Machine(CoreObject):
else: else:
operationsNotRequired.append(tup) operationsNotRequired.append(tup)
required = False required = False
# operations that should be in the multOperationTypeList
if operationsRequired: if operationsRequired:
for opTup in operationsRequired: for opTup in operationsRequired:
operation, func = opTup operation, func = opTup
...@@ -353,6 +355,7 @@ class Machine(CoreObject): ...@@ -353,6 +355,7 @@ class Machine(CoreObject):
else: else:
required=True required=True
notRequired = False notRequired = False
# operations that should NOT be in the multOperationTypeList
if operationsNotRequired: if operationsNotRequired:
for opTup in operationsNotRequired: for opTup in operationsNotRequired:
operation, func = opTup operation, func = opTup
...@@ -369,6 +372,7 @@ class Machine(CoreObject): ...@@ -369,6 +372,7 @@ class Machine(CoreObject):
methodsRequired.append(tup) methodsRequired.append(tup)
else: else:
methodsNotRequired.append(tup) methodsNotRequired.append(tup)
# methods that should return TRUE
required = True required = True
from Globals import getMethodFromName from Globals import getMethodFromName
if methodsRequired: if methodsRequired:
...@@ -376,6 +380,7 @@ class Machine(CoreObject): ...@@ -376,6 +380,7 @@ class Machine(CoreObject):
method, func = methodTup method, func = methodTup
objMethod=getMethodFromName('Dream.Machine.'+method) objMethod=getMethodFromName('Dream.Machine.'+method)
required = required and (objMethod(self)) required = required and (objMethod(self))
# methods that should return FALSE
notRequired = True notRequired = True
if methodsNotRequired: if methodsNotRequired:
for methodTup in methodsNotRequired: for methodTup in methodsNotRequired:
...@@ -496,8 +501,8 @@ class Machine(CoreObject): ...@@ -496,8 +501,8 @@ class Machine(CoreObject):
#=========================================================== #===========================================================
# # release the operator if there is interruption # # release the operator if there is interruption
#=========================================================== #===========================================================
if self.shouldYield(operationTypes={str(self.currentlyPerforming):1},methods={'isOperated':1}): if self.shouldYield(operationTypes={str(type):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
...@@ -505,17 +510,25 @@ class Machine(CoreObject): ...@@ -505,17 +510,25 @@ class Machine(CoreObject):
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()
# check if the machine is active and break
if self.checkIfActive(): if self.checkIfActive():
if self.shouldYield(operationTypes={str(type):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
break break
self.postInterruptionActions() # execute interruption actions self.postInterruptionActions() # execute interruption actions
#=========================================================== #===========================================================
# # request a resource after the repair # # request a resource after the repair
#=========================================================== #===========================================================
if self.shouldYield(operationTypes={str(self.currentlyPerforming):1}, methods={"isInterrupted":0}): if self.shouldYield(operationTypes={str(type):1}, methods={"isInterrupted":0}):
self.timeWaitForOperatorStarted = self.env.now self.timeWaitForOperatorStarted = self.env.now
yield self.env.process(self.request()) yield self.env.process(self.request())
self.timeWaitForOperatorEnded = self.env.now self.timeWaitForOperatorEnded = self.env.now
self.operatorWaitTimeCurrentEntity += self.timeWaitForOperatorEnded-self.timeWaitForOperatorStarted self.operatorWaitTimeCurrentEntity += self.timeWaitForOperatorEnded-self.timeWaitForOperatorStarted
# if the processing operator left # if the processing operator left
elif self.processOperatorUnavailable in receivedEvent: elif self.processOperatorUnavailable in receivedEvent:
transmitter, eventTime=self.processOperatorUnavailable.value transmitter, eventTime=self.processOperatorUnavailable.value
......
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