global variable Router instead of RoutersList

parent 09cf6663
......@@ -355,13 +355,13 @@ class CoreObject(Process):
if not receiver.assignedOperator:
if any(type=='Load' or type=='Setup' for type in receiver.multOperationTypeList):
from Globals import G
if not G.RoutersList[0].invoked:
if not G.Router.invoked:
#===================================================================
# # TESTING
# print now(), self.id,' '*50, 'signalling router'
#===================================================================
G.RoutersList[0].invoked=True
G.RoutersList[0].isCalled.signal(now())
G.Router.invoked=True
G.Router.isCalled.signal(now())
return False
except:
pass
......
......@@ -73,6 +73,10 @@ class G:
numberOfEntities = 0
#object that routes the operators in the model
#------------------------------------------------------------------------
Router=None
# -----------------------------------------------------------------------
# define the lists of each object type
# -----------------------------------------------------------------------
......@@ -96,7 +100,6 @@ class G:
OperatorManagedJobsList = []
OperatorPoolsList = []
BrokersList = []
RoutersList = []
OperatedMachineList = []
BatchScrapMachineList=[]
OrderDecompositionList=[]
......
......@@ -134,13 +134,13 @@ class Machine(CoreObject):
if (self.operatorPool!='None'):
self.broker=Broker(self)
from Globals import G
# if there is no router in G.RouterList
if len(G.RoutersList)==0:
# if there is no router
if not G.Router:
self.router=Router()
G.RoutersList.append(self.router)
G.Router=self.router
# otherwise set the already existing router as the machines Router
else:
self.router=G.RoutersList[0]
self.router=G.Router
# lists to hold statistics of multiple runs
self.WaitingForOperator=[]
self.WaitingForLoadOperator=[]
......
......@@ -58,13 +58,13 @@ class MachineManagedJob(MachineJobShop):
#create a Router
# TODO: this is already performed in __init__ of Machine
from Globals import G
if len(G.RoutersList)==0:
if not G.Router:
self.router=Router()
activate(self.router,self.router.run())
G.RoutersList.append(self.router)
G.Router=self.router
# otherwise set the already existing router as the machines Router
else:
self.router=G.RoutersList[0]
self.router=G.Router
# holds the Entity that is to be obtained and will be updated by canAcceptAndIsRequested
self.entityToGet=None
......
......@@ -87,13 +87,13 @@ class Broker(ObjectInterruption):
# add the currentEntity to the pendingEntities
if not self.victim.currentEntity in G.pendingEntities:
G.pendingEntities.append(self.victim.currentEntity)
if not G.RoutersList[0].invoked:
if not G.Router.invoked:
#===========================================================
# testing
# print now(), self.victim.id, 'broker', ' '*50, 'signalling router'
#===========================================================
G.RoutersList[0].invoked=True
G.RoutersList[0].isCalled.signal(now())
G.Router.invoked=True
G.Router.isCalled.signal(now())
self.waitForOperator=True
# print now(), self.victim.id, 'broker waits till resource is available1'
......
......@@ -139,13 +139,13 @@ class QueueManagedJob(QueueJobShop):
if any(type=='Load' or type=='Setup' for type in receiver.multOperationTypeList):
if receiver.identifyEntityToGet().manager.isAssignedTo()!=receiver:
from Globals import G
if not G.RoutersList[0].invoked:
if not G.Router.invoked:
#===================================================================
# # TESTING
# print now(), self.id,' '*50, 'signalling router'
#===================================================================
G.RoutersList[0].invoked=True
G.RoutersList[0].isCalled.signal(now())
G.Router.invoked=True
G.Router.isCalled.signal(now())
return False
except:
pass
......
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