__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)
# 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,7 +80,10 @@ 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:
if not operator.isInitialized():
operator.initialize()
# =======================================================================
......
......@@ -37,6 +37,7 @@ from ObjectResource import ObjectResource
class Repairman(ObjectResource):
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
......
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