workingStation variable added to Operator to hold the station currently operated by the operator

parent 0fc1b914
......@@ -112,6 +112,8 @@ class Broker(ObjectInterruption):
with self.victim.operatorPool.getResource(self.victim.currentOperator).request() as request:
yield request
# update the operator workingStation
self.victim.currentOperator.workingStation=self.victim
self.victim.printTrace(self.victim.currentOperator.objName, startWork=self.victim.id)
# clear the timeWaitForOperatorStarted variable
self.timeWaitForOperatorStarted = 0
......@@ -148,6 +150,7 @@ class Broker(ObjectInterruption):
self.victim.printTrace(self.victim.currentOperator.objName, finishWork=self.victim.id)
# the victim current operator must be cleared after the operator is released
self.timeLastOperationEnded = self.env.now
self.victim.currentOperator.workingStation=None
self.victim.currentOperator = None
else:
pass
......
......@@ -65,6 +65,8 @@ class Operator(ObjectResource):
# the station that the operator is assigned to
self.operatorAssignedTo=None
# the station the operator currently operating
self.workingStation=None
# variables to be used by OperatorRouter
self.candidateEntities=[] # list of the entities requesting the operator at a certain simulation Time
......
......@@ -26,7 +26,8 @@ Created on 13 Feb 2013
models a entity/job assigned operator (manager)
'''
from SimPy.Simulation import Resource, now
# from SimPy.Simulation import Resource, now
import simpy
from Operator import Operator
# ===========================================================================
......@@ -45,6 +46,7 @@ class OperatorManagedJob(Operator):
# =======================================================================
def checkIfResourceIsAvailable(self,callerObject=None):
activeResourceQueue = self.getResourceQueue()
workingOn=self.workingStation
# in case the operator has the flag operatorAssigned raised
# (meaning the operator will explicitly be assigned to a machine)
# return false even if he is free
......@@ -57,15 +59,16 @@ class OperatorManagedJob(Operator):
# object the operator is assigned to
else:
if len(activeResourceQueue):
if self.operatorAssignedTo==activeResourceQueue[0].victim:
# if self.operatorAssignedTo==activeResourceQueue[0].victim:
if self.operatorAssignedTo==workingOn:
return self.operatorAssignedTo==callerObject
return (self.operatorAssignedTo==callerObject) and len(self.Res.activeQ)<self.capacity
return (self.operatorAssignedTo==callerObject) and len(activeResourceQueue)<self.capacity
# otherwise, (if the callerObject is None) check if the operator is assigned and if yes
# then perform the default behaviour
else:
# if self.operatorAssignedTo==None:
# return False
return len(self.Res.activeQ)<self.capacity
return len(activeResourceQueue)<self.capacity
#===========================================================================
# check if the operator has only one station as candidate option
......
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