Commit 613ba8e0 authored by Ioannis Papagiannopoulos's avatar Ioannis Papagiannopoulos Committed by Jérome Perrin

further clean-up in Skilled/OperatorRouter/Managed

parent 6c9d69f2
......@@ -49,16 +49,8 @@ class Router(ObjectInterruption):
self.toBeSignalled=[]
# flag to notify whether the router is already invoked
self.invoked=False
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.pending=[] # list of entities that require operators now
#===========================================================================
......@@ -75,19 +67,10 @@ class Router(ObjectInterruption):
self.candidateOperators=[]
# flag used to check if the Router is initialised
self.isInitialized=True
self.invoked=False
self.preemptiveOperators=[]
self.toBeSignalled=[]
self.conflictingOperators=[]
self.conflictingEntities=[]
self.conflictingStations=[]
self.occupiedReceivers=[]
self.criticalQueues=[]
self.pending=[] # list of entities that require operators now
# =======================================================================
......@@ -118,7 +101,7 @@ class Router(ObjectInterruption):
break
self.printTrace('','=-'*15)
# entry actions
self.entry()
self.entryActions()
# run the routine that allocates operators to machines
self.allocateOperators()
# assign operators to stations
......@@ -130,7 +113,7 @@ class Router(ObjectInterruption):
self.printTrace('', 'router exiting')
self.printTrace('','=-'*20)
# exit actions
self.exit()
self.exitActions()
#===========================================================================
# routing performed to define the candidate operators the pending entities and how the operators should be allocated
......@@ -190,7 +173,7 @@ class Router(ObjectInterruption):
#===========================================================================
# entry actions
#===========================================================================
def entry(self):
def entryActions(self):
from Globals import G
for operator in G.OperatorsList:
operator.candidateEntity=None
......@@ -198,7 +181,7 @@ class Router(ObjectInterruption):
# =======================================================================
# return control to the Machine.run
# =======================================================================
def exit(self):
def exitActions(self):
from Globals import G
# reset the variables that are used from the Router
for operator in self.candidateOperators:
......@@ -214,10 +197,6 @@ class Router(ObjectInterruption):
del self.pendingMachines[:]
del self.pendingQueues[:]
del self.toBeSignalled[:]
del self.conflictingOperators[:]
del self.conflictingStations[:]
del self.conflictingEntities[:]
del self.occupiedReceivers[:]
del self.criticalQueues[:]
del self.pending[:]
self.invoked=False
......
......@@ -43,13 +43,14 @@ class RouterManaged(Router):
# according to this implementation one machine per broker is allowed
# The Broker is initiated within the Machine and considered as
# 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):
Router.__init__(self)
# 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.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
......@@ -59,6 +60,9 @@ class RouterManaged(Router):
# list that holds all the objects that can receive
self.pendingObjects=[]
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
......@@ -90,7 +94,7 @@ class RouterManaged(Router):
self.printTrace('','=-'*15)
# entry actions
self.entry()
self.entryActions()
# run the routine that allocates operators to machines
self.allocateOperators()
# assign operators to stations
......@@ -102,9 +106,9 @@ class RouterManaged(Router):
self.printTrace('', 'router exiting')
self.printTrace('','=-'*20)
# exit actions
self.exit()
self.exitActions()
def entry(self):
def entryActions(self):
pass
def allocateOperators(self):
......@@ -134,32 +138,16 @@ class RouterManaged(Router):
# =======================================================================
# return control to the Machine.run
# =======================================================================
def exit(self):
from Globals import G
# reset the variables that are used from the Router
def exitActions(self):
# reset the candidateEntities of the operators
for operator in self.candidateOperators:
operator.candidateEntities=[]
operator.candidateStations=[]
operator.candidateStation=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.pendingMachines[:]
del self.pendingQueues[:]
del self.toBeSignalled[:]
del self.conflictingOperators[:]
del self.conflictingStations[:]
del self.conflictingEntities[:]
del self.occupiedReceivers[:]
del self.entitiesWithOccupiedReceivers[:]
self.invoked=False
Router.exitActions(self)
#===========================================================================
# assigning operators to machines
......@@ -233,7 +221,6 @@ class RouterManaged(Router):
def findPendingEntities(self):
from Globals import G
self.pending=[] # list of entities that are pending
self.criticalPending=[]
for machine in self.pendingMachines:
self.pending.append(machine.currentEntity)
for entity in G.pendingEntities:
......@@ -241,13 +228,8 @@ class RouterManaged(Router):
for machine in entity.currentStation.next:
if any(type=='Load' for type in machine.multOperationTypeList):
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
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
......
......@@ -268,7 +268,7 @@ class SkilledRouter(Router):
#===================================================================
else:
# entry actions
self.entry()
self.entryActions()
# run the routine that allocates operators to machines
self.allocateOperators()
# assign operators to stations
......@@ -282,7 +282,7 @@ class SkilledRouter(Router):
self.previousSolution=solution
self.printTrace('', 'router exiting')
self.printTrace('','=-'*20)
self.exit()
self.exitActions()
# =======================================================================
# signal the station or the Queue to impose the assignment
......@@ -306,8 +306,8 @@ class SkilledRouter(Router):
# =======================================================================
# return control to the Machine.run
# =======================================================================
def exit(self):
Router.exit(self)
def exitActions(self):
Router.exitActions(self)
self.allocation=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