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

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