Commit 81b991cd authored by Ioannis Papagiannopoulos's avatar Ioannis Papagiannopoulos Committed by Georgios Dagkakis

further clean-up in Skilled/OperatorRouter/Managed

parent 23364a84
...@@ -49,16 +49,8 @@ class Router(ObjectInterruption): ...@@ -49,16 +49,8 @@ class Router(ObjectInterruption):
self.toBeSignalled=[] self.toBeSignalled=[]
# flag to notify whether the router is already invoked # flag to notify whether the router is already invoked
self.invoked=False self.invoked=False
self.preemptiveOperators=[] # list of preemptiveOperators that should preempt their machines self.preemptiveOperators=[] # list of preemptiveOperators that should preempt their machines
self.conflictingOperators=[] # list with the operators that have candidateEntity with conflicting candidateReceivers
self.conflictingEntities=[] # entities with conflictingReceivers
self.conflictingStations=[] # stations with conflicting operators
self.occupiedReceivers=[] # occupied candidateReceivers of a candidateEntity
self.criticalQueues=[] self.criticalQueues=[]
self.pending=[] # list of entities that require operators now self.pending=[] # list of entities that require operators now
#=========================================================================== #===========================================================================
...@@ -75,19 +67,10 @@ class Router(ObjectInterruption): ...@@ -75,19 +67,10 @@ class Router(ObjectInterruption):
self.candidateOperators=[] self.candidateOperators=[]
# flag used to check if the Router is initialised # flag used to check if the Router is initialised
self.isInitialized=True self.isInitialized=True
self.invoked=False self.invoked=False
self.preemptiveOperators=[] self.preemptiveOperators=[]
self.toBeSignalled=[] self.toBeSignalled=[]
self.conflictingOperators=[]
self.conflictingEntities=[]
self.conflictingStations=[]
self.occupiedReceivers=[]
self.criticalQueues=[] self.criticalQueues=[]
self.pending=[] # list of entities that require operators now self.pending=[] # list of entities that require operators now
# ======================================================================= # =======================================================================
...@@ -118,7 +101,7 @@ class Router(ObjectInterruption): ...@@ -118,7 +101,7 @@ class Router(ObjectInterruption):
break break
self.printTrace('','=-'*15) self.printTrace('','=-'*15)
# entry actions # entry actions
self.entry() self.entryActions()
# run the routine that allocates operators to machines # run the routine that allocates operators to machines
self.allocateOperators() self.allocateOperators()
# assign operators to stations # assign operators to stations
...@@ -130,7 +113,7 @@ class Router(ObjectInterruption): ...@@ -130,7 +113,7 @@ class Router(ObjectInterruption):
self.printTrace('', 'router exiting') self.printTrace('', 'router exiting')
self.printTrace('','=-'*20) self.printTrace('','=-'*20)
# exit actions # exit actions
self.exit() self.exitActions()
#=========================================================================== #===========================================================================
# routing performed to define the candidate operators the pending entities and how the operators should be allocated # routing performed to define the candidate operators the pending entities and how the operators should be allocated
...@@ -190,7 +173,7 @@ class Router(ObjectInterruption): ...@@ -190,7 +173,7 @@ class Router(ObjectInterruption):
#=========================================================================== #===========================================================================
# entry actions # entry actions
#=========================================================================== #===========================================================================
def entry(self): def entryActions(self):
from Globals import G from Globals import G
for operator in G.OperatorsList: for operator in G.OperatorsList:
operator.candidateEntity=None operator.candidateEntity=None
...@@ -198,7 +181,7 @@ class Router(ObjectInterruption): ...@@ -198,7 +181,7 @@ class Router(ObjectInterruption):
# ======================================================================= # =======================================================================
# return control to the Machine.run # return control to the Machine.run
# ======================================================================= # =======================================================================
def exit(self): def exitActions(self):
from Globals import G from Globals import G
# reset the variables that are used from the Router # reset the variables that are used from the Router
for operator in self.candidateOperators: for operator in self.candidateOperators:
...@@ -214,10 +197,6 @@ class Router(ObjectInterruption): ...@@ -214,10 +197,6 @@ class Router(ObjectInterruption):
del self.pendingMachines[:] del self.pendingMachines[:]
del self.pendingQueues[:] del self.pendingQueues[:]
del self.toBeSignalled[:] del self.toBeSignalled[:]
del self.conflictingOperators[:]
del self.conflictingStations[:]
del self.conflictingEntities[:]
del self.occupiedReceivers[:]
del self.criticalQueues[:] del self.criticalQueues[:]
del self.pending[:] del self.pending[:]
self.invoked=False self.invoked=False
......
...@@ -43,13 +43,14 @@ class RouterManaged(Router): ...@@ -43,13 +43,14 @@ class RouterManaged(Router):
# according to this implementation one machine per broker is allowed # according to this implementation one machine per broker is allowed
# The Broker is initiated within the Machine and considered as # The Broker is initiated within the Machine and considered as
# black box for the ManPy end Developer # black box for the ManPy end Developer
# TODO: we should maybe define a global schedulingRule criterion that will be
# chosen in case of multiple criteria for different Operators
# ======================================================================= # =======================================================================
def __init__(self): def __init__(self):
Router.__init__(self) Router.__init__(self)
# boolean flag to check whether the Router should perform sorting on operators and on pendingEntities # boolean flag to check whether the Router should perform sorting on operators and on pendingEntities
self.entitiesWithOccupiedReceivers=[] # list of entities that have no available receivers self.entitiesWithOccupiedReceivers=[] # list of entities that have no available receivers
self.conflictingEntities=[] # entities with conflictingReceivers
self.conflictingOperators=[] # list with the operators that have candidateEntity with conflicting candidateReceivers
self.occupiedReceivers=[] # occupied candidateReceivers of a candidateEntity
#=========================================================================== #===========================================================================
# the initialize method # the initialize method
...@@ -59,6 +60,9 @@ class RouterManaged(Router): ...@@ -59,6 +60,9 @@ class RouterManaged(Router):
# list that holds all the objects that can receive # list that holds all the objects that can receive
self.pendingObjects=[] self.pendingObjects=[]
self.entitiesWithOccupiedReceivers=[] self.entitiesWithOccupiedReceivers=[]
self.conflictingEntities=[] # entities with conflictingReceivers
self.conflictingOperators=[] # list with the operators that have candidateEntity with conflicting candidateReceivers
self.occupiedReceivers=[] # occupied candidateReceivers of a candidateEntity
# ======================================================================= # =======================================================================
# the run method # the run method
...@@ -90,7 +94,7 @@ class RouterManaged(Router): ...@@ -90,7 +94,7 @@ class RouterManaged(Router):
self.printTrace('','=-'*15) self.printTrace('','=-'*15)
# entry actions # entry actions
self.entry() self.entryActions()
# run the routine that allocates operators to machines # run the routine that allocates operators to machines
self.allocateOperators() self.allocateOperators()
# assign operators to stations # assign operators to stations
...@@ -102,9 +106,9 @@ class RouterManaged(Router): ...@@ -102,9 +106,9 @@ class RouterManaged(Router):
self.printTrace('', 'router exiting') self.printTrace('', 'router exiting')
self.printTrace('','=-'*20) self.printTrace('','=-'*20)
# exit actions # exit actions
self.exit() self.exitActions()
def entry(self): def entryActions(self):
pass pass
def allocateOperators(self): def allocateOperators(self):
...@@ -134,32 +138,16 @@ class RouterManaged(Router): ...@@ -134,32 +138,16 @@ class RouterManaged(Router):
# ======================================================================= # =======================================================================
# return control to the Machine.run # return control to the Machine.run
# ======================================================================= # =======================================================================
def exit(self): def exitActions(self):
from Globals import G # reset the candidateEntities of the operators
# reset the variables that are used from the Router
for operator in self.candidateOperators: for operator in self.candidateOperators:
operator.candidateEntities=[]
operator.candidateStations=[]
operator.candidateStation=None
operator.candidateEntity=None operator.candidateEntity=None
for entity in G.pendingEntities:
entity.proceed=False
entity.candidateReceivers=[]
entity.candidateReceiver=None
del self.candidateOperators[:]
del self.criticalPending[:]
del self.preemptiveOperators[:]
del self.pendingObjects[:] del self.pendingObjects[:]
del self.pendingMachines[:]
del self.pendingQueues[:]
del self.toBeSignalled[:]
del self.conflictingOperators[:] del self.conflictingOperators[:]
del self.conflictingStations[:]
del self.conflictingEntities[:] del self.conflictingEntities[:]
del self.occupiedReceivers[:] del self.occupiedReceivers[:]
del self.entitiesWithOccupiedReceivers[:] del self.entitiesWithOccupiedReceivers[:]
self.invoked=False Router.exitActions(self)
#=========================================================================== #===========================================================================
# assigning operators to machines # assigning operators to machines
...@@ -233,7 +221,6 @@ class RouterManaged(Router): ...@@ -233,7 +221,6 @@ class RouterManaged(Router):
def findPendingEntities(self): def findPendingEntities(self):
from Globals import G from Globals import G
self.pending=[] # list of entities that are pending self.pending=[] # list of entities that are pending
self.criticalPending=[]
for machine in self.pendingMachines: for machine in self.pendingMachines:
self.pending.append(machine.currentEntity) self.pending.append(machine.currentEntity)
for entity in G.pendingEntities: for entity in G.pendingEntities:
...@@ -241,13 +228,8 @@ class RouterManaged(Router): ...@@ -241,13 +228,8 @@ class RouterManaged(Router):
for machine in entity.currentStation.next: for machine in entity.currentStation.next:
if any(type=='Load' for type in machine.multOperationTypeList): if any(type=='Load' for type in machine.multOperationTypeList):
self.pending.append(entity) self.pending.append(entity)
# if the entity is critical add it to the criticalPending List
if entity.isCritical and not entity in self.criticalPending:
self.criticalPending.append(entity)
break break
self.printTrace('found pending entities'+'-'*12+'>', [str(entity.id) for entity in self.pending if not entity.type=='Part']) self.printTrace('found pending entities'+'-'*12+'>', [str(entity.id) for entity in self.pending if not entity.type=='Part'])
if self.criticalPending:
self.printTrace('found pending critical'+'-'*12+'>', [str(entity.id) for entity in self.criticalPending if not entity.type=='Part'])
#======================================================================== #========================================================================
# Find candidate Operators # Find candidate Operators
......
...@@ -268,7 +268,7 @@ class SkilledRouter(Router): ...@@ -268,7 +268,7 @@ class SkilledRouter(Router):
#=================================================================== #===================================================================
else: else:
# entry actions # entry actions
self.entry() self.entryActions()
# run the routine that allocates operators to machines # run the routine that allocates operators to machines
self.allocateOperators() self.allocateOperators()
# assign operators to stations # assign operators to stations
...@@ -282,7 +282,7 @@ class SkilledRouter(Router): ...@@ -282,7 +282,7 @@ class SkilledRouter(Router):
self.previousSolution=solution self.previousSolution=solution
self.printTrace('', 'router exiting') self.printTrace('', 'router exiting')
self.printTrace('','=-'*20) self.printTrace('','=-'*20)
self.exit() self.exitActions()
# ======================================================================= # =======================================================================
# signal the station or the Queue to impose the assignment # signal the station or the Queue to impose the assignment
...@@ -306,8 +306,8 @@ class SkilledRouter(Router): ...@@ -306,8 +306,8 @@ class SkilledRouter(Router):
# ======================================================================= # =======================================================================
# return control to the Machine.run # return control to the Machine.run
# ======================================================================= # =======================================================================
def exit(self): def exitActions(self):
Router.exit(self) Router.exitActions(self)
self.allocation=False self.allocation=False
self.waitEndProcess=False self.waitEndProcess=False
\ No newline at end of file
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