Commit 4c4cdc35 authored by Ioannis Papagiannopoulos's avatar Ioannis Papagiannopoulos Committed by Georgios Dagkakis

If no operators or/and operatorPool are provided as arguemnts the machine...

If no operators or/and operatorPool are provided as arguemnts the machine checks if the operators are given a skillsList and creates an empty operatorPool to be populated by the Router.
parent 38df6dc3
...@@ -192,17 +192,33 @@ class Machine(CoreObject): ...@@ -192,17 +192,33 @@ class Machine(CoreObject):
the list of operators provided the list of operators provided
if the list is empty create operator pool with empty list if the list is empty create operator pool with empty list
''' '''
from Globals import G
self.skilledOperators=False
# XXX operatorPool is not None ? # XXX operatorPool is not None ?
# if a list of operators is provided as argument
if (type(operatorPool) is list) and len(operatorPool)>0: if (type(operatorPool) is list) and len(operatorPool)>0:
id = self.id+'_OP' id = self.id+'_OP'
name=self.objName+'_operatorPool' name=self.objName+'_operatorPool'
self.operatorPool=OperatorPool(id, name, operatorsList=operatorPool) self.operatorPool=OperatorPool(id, name, operatorsList=operatorPool)
from Globals import G
G.OperatorPoolsList.append(self.operatorPool) G.OperatorPoolsList.append(self.operatorPool)
# if an operatorPool object is connected to the machine
elif(type(operatorPool) is OperatorPool): elif(type(operatorPool) is OperatorPool):
self.operatorPool=operatorPool self.operatorPool=operatorPool
# otherwise
else: else:
self.operatorPool='None' # find out whether the operators are provided a list of skills
for operator in G.OperatorsList:
# in that case create an empty operatorPool
if operator.skillsList:
id = self.id+'_OP'
name=self.objName+'_operatorPool'
self.operatorPool=OperatorPool(id,name,operatorsList=[])
G.OperatorPoolsList.append(self.operatorPool)
# and update the flag skilledOperators so whenever the OperatorPool is re-initialised to reset the operators list of the Pool
self.skilledOperators=True
break
if not self.skilledOperators:
self.operatorPool='None'
# update the operatorPool coreObjects list # update the operatorPool coreObjects list
if self.operatorPool!='None': if self.operatorPool!='None':
self.operatorPool.coreObjectIds.append(self.id) self.operatorPool.coreObjectIds.append(self.id)
...@@ -231,18 +247,23 @@ class Machine(CoreObject): ...@@ -231,18 +247,23 @@ class Machine(CoreObject):
else: else:
self.router=G.Router self.router=G.Router
#=========================================================================== #===========================================================================
# initialize broker if needed # initialise broker if needed
#=========================================================================== #===========================================================================
def initializeOperatorPool(self): def initializeOperatorPool(self):
# initialize the operator pool if any # initialise the operator pool if any
if (self.operatorPool!="None"): if (self.operatorPool!="None"):
self.operatorPool.initialize() self.operatorPool.initialize()
for operator in self.operatorPool.operators: # if the flag skilledOperators is true then reset/empty the operators list of the pool
operator.coreObjectIds.append(self.id) if self.skilledOperators:
operator.coreObjects.append(self) self.operatorPool.operators=[]
# otherwise update the coreObjectIds/coreObjects list of the operators
else:
for operator in self.operatorPool.operators:
operator.coreObjectIds.append(self.id)
operator.coreObjects.append(self)
#=========================================================================== #===========================================================================
# initialize broker if needed # initialise broker if needed
#=========================================================================== #===========================================================================
def initializeBroker(self): def initializeBroker(self):
# initiate the Broker responsible to control the request/release # initiate the Broker responsible to control the request/release
...@@ -251,7 +272,7 @@ class Machine(CoreObject): ...@@ -251,7 +272,7 @@ class Machine(CoreObject):
self.env.process(self.broker.run()) self.env.process(self.broker.run())
#=========================================================================== #===========================================================================
# initialize router if needed # initialise router if needed
#=========================================================================== #===========================================================================
def initializeRouter(self): def initializeRouter(self):
if (self.operatorPool!="None"): if (self.operatorPool!="None"):
......
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