__init__ method added to ObjectResource. isInitialized() method is also added

parent 199bc41b
...@@ -31,11 +31,16 @@ from SimPy.Simulation import Resource ...@@ -31,11 +31,16 @@ from SimPy.Simulation import Resource
# =========================================================================== # ===========================================================================
class ObjectResource(object): class ObjectResource(object):
def __init__(self):
self.initialized = False
def initialize(self): def initialize(self):
self.totalWorkingTime=0 #holds the total working time self.totalWorkingTime=0 #holds the total working time
self.totalWaitingTime=0 #holds the total waiting time self.totalWaitingTime=0 #holds the total waiting time
self.timeLastOperationStarted=0 #holds the time that the last repair was started self.timeLastOperationStarted=0 #holds the time that the last repair was started
self.Res=Resource(self.capacity) self.Res=Resource(self.capacity)
# variable that checks weather the resource is already initialized
self.initialized = True
# ======================================================================= # =======================================================================
# checks if the worker is available # checks if the worker is available
...@@ -91,3 +96,9 @@ class ObjectResource(object): ...@@ -91,3 +96,9 @@ class ObjectResource(object):
def getResourceQueue(self): def getResourceQueue(self):
return self.Res.activeQ return self.Res.activeQ
# =======================================================================
# check if the resource is already initialized
# =======================================================================
def isInitialized(self):
return self.initialized
...@@ -80,8 +80,11 @@ class OperatorPool(ObjectResource): ...@@ -80,8 +80,11 @@ class OperatorPool(ObjectResource):
# self.timeLastOperationStarted=0 #holds the time that the last operation was started # self.timeLastOperationStarted=0 #holds the time that the last operation was started
# initialize the operators # initialize the operators
# an operator that may have been initialized by an other operator pool, is initiated again
# reconsider
for operator in self.operators: for operator in self.operators:
operator.initialize() if not operator.isInitialized():
operator.initialize()
# ======================================================================= # =======================================================================
# checks if there are operators available # checks if there are operators available
......
...@@ -36,7 +36,8 @@ from ObjectResource import ObjectResource ...@@ -36,7 +36,8 @@ from ObjectResource import ObjectResource
# =========================================================================== # ===========================================================================
class Repairman(ObjectResource): class Repairman(ObjectResource):
def __init__(self, id, name, capacity=1): def __init__(self, id, name, capacity=1):
ObjectResource.__init__(self)
self.id=id self.id=id
self.objName=name self.objName=name
self.capacity=capacity # repairman is an instance of resource self.capacity=capacity # repairman is an instance of resource
...@@ -49,7 +50,7 @@ class Repairman(ObjectResource): ...@@ -49,7 +50,7 @@ class Repairman(ObjectResource):
self.coreObjectIds=[] self.coreObjectIds=[]
# list with the coreObjects that the repairman repairs # list with the coreObjects that the repairman repairs
self.coreObjects=[] self.coreObjects=[]
# ======================================================================= # =======================================================================
# actions to be taken after the simulation ends # actions to be taken after the simulation ends
# ======================================================================= # =======================================================================
......
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