initialize method added to Router

parent ec5965ba
...@@ -128,16 +128,29 @@ class Machine(CoreObject): ...@@ -128,16 +128,29 @@ class Machine(CoreObject):
self.multOperationTypeList = OTlist self.multOperationTypeList = OTlist
else: else:
self.multOperationTypeList.append(self.operationType) self.multOperationTypeList.append(self.operationType)
# initiate the Broker and the router
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:
self.router=Router()
G.RoutersList.append(self.router)
# otherwise set the already existing router as the machines Router
else:
self.router=G.RoutersList[0]
# lists to hold statistics of multiple runs # lists to hold statistics of multiple runs
self.WaitingForOperator=[] self.WaitingForOperator=[]
self.WaitingForLoadOperator=[] self.WaitingForLoadOperator=[]
self.Loading = [] self.Loading = []
self.SettingUp =[] self.SettingUp =[]
# flags used for preemption purposes
self.isPreemptive=isPreemptive self.isPreemptive=isPreemptive
self.resetOnPreemption=resetOnPreemption self.resetOnPreemption=resetOnPreemption
# event used by the router
self.routerCycleOver=SimEvent('routerCycleOver') self.routerCycleOver=SimEvent('routerCycleOver')
# ======================================================================= # =======================================================================
# initialize the machine # initialize the machine
...@@ -152,18 +165,12 @@ class Machine(CoreObject): ...@@ -152,18 +165,12 @@ class Machine(CoreObject):
# initialize the operator pool if any # initialize the operator pool if any
if (self.operatorPool!="None"): if (self.operatorPool!="None"):
self.operatorPool.initialize() self.operatorPool.initialize()
self.broker = Broker(self) self.broker.initialize()
activate(self.broker,self.broker.run()) activate(self.broker,self.broker.run())
# if there is no router in G.RouterList # initialise the router only once
# initialise a new router if not self.router.isInitialized:
from Globals import G self.router.initialize()
if len(G.RoutersList)==0:
self.router=Router()
activate(self.router,self.router.run()) activate(self.router,self.router.run())
G.RoutersList.append(self.router)
# otherwise set the already existing router as the machines Router
else:
self.router=G.RoutersList[0]
for operator in self.operatorPool.operators: for operator in self.operatorPool.operators:
operator.coreObjectIds.append(self.id) operator.coreObjectIds.append(self.id)
operator.coreObjects.append(self) operator.coreObjects.append(self)
......
...@@ -46,20 +46,30 @@ class Router(ObjectInterruption): ...@@ -46,20 +46,30 @@ class Router(ObjectInterruption):
self.type = "Router" self.type = "Router"
# variable used to hand in control to the Broker # variable used to hand in control to the Broker
self.call=False self.call=False
# list that holds all the objects that can receive
self.pendingObjects=[]
self.calledOperators=[]
# signal used to initiate the generator of the Router # signal used to initiate the generator of the Router
self.startCycle=SimEvent('startCycle') self.startCycle=SimEvent('startCycle')
# # TODO: consider if there must be an argument set for the schedulingRules of the Router # TODO: create an initialise method for router to reset the attributes for every replication
# self.schedulingRule='' self.isInitialized=False
self.candidateOperators=[]
self.multipleCriterionList=[]
self.schedulingRule='WT'
#===========================================================================
# the initialize method
#===========================================================================
def initialize(self):
ObjectInterruption.initialize(self)
self.call=False
# list that holds all the objects that can receive
self.pendingObjects=[]
self.calledOperator=[]
# list of the operators that may handle a machine at the current simulation time # list of the operators that may handle a machine at the current simulation time
self.candidateOperators=[] self.candidateOperators=[]
# list of criteria # list of criteria
self.multipleCriterionList=[] self.multipleCriterionList=[]
# TODO: find out which must be the default for the scheduling Rule # TODO: find out which must be the default for the scheduling Rule
self.schedulingRule='WT' self.schedulingRule='WT'
# TODO: create an initialise method for router to reset the attributes for every replication self.isInitialized=True
# ======================================================================= # =======================================================================
# the run method # the run method
......
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