Operators have schedulingRules for sorting the objects requesting them (sortEntities)

parent d729090c
......@@ -204,7 +204,7 @@ def createObjects():
schedulingRule=element.get('schedulingRule', 'FIFO') # get the scheduling rule of the el. (how to choose which
# station to serve first) / default 'FIFO' i.e. the one that
# called first
O = Operator(element_id, name, capacity) # create an operator object
O = Operator(element_id, name, capacity,schedulingRule) # create an operator object
O.coreObjectIds=getSuccessorList(id) # update the list of objects that the operator operates
# calling the getSuccesorList() method on the operator
G.OperatorsList.append(O) # add the operator to the RepairmanList
......@@ -213,7 +213,10 @@ def createObjects():
id = element.get('id', 'not found') # get the id of the element / default 'not_found'
name = element.get('name', 'not found') # get the name of the element / default 'not_found'
capacity = int(element.get('capacity', '1')) # get the capacity of the el. / defautl '1'
O = OperatorManagedJob(element_id, name, capacity) # create an operator object
schedulingRule=element.get('schedulingRule', 'FIFO') # get the scheduling rule of the el. (how to choose which
# station to serve first) / default 'FIFO' i.e. the one that
# called first
O = OperatorManagedJob(element_id, name, capacity,schedulingRule) # create an operator object
O.coreObjectIds=getSuccessorList(id) # update the list of objects that the operator operates
# calling the getSuccesorList() method on the operator
G.OperatorsList.append(O) # add the operator to the RepairmanList
......
......@@ -39,6 +39,11 @@ class Operator(Repairman):
self.type="Operator"
self.activeCallersList=[]
self.schedulingRule=schedulingRule
# #=======================================================================
# # TESTING
# print now(), self.objName, 'schedulingRule'
# print self.schedulingRule
# #=======================================================================
# =======================================================================
# sorts the Entities of the Queue according to the scheduling rule
......@@ -50,7 +55,7 @@ class Operator(Repairman):
self.activeQSorter(criterion=criterion)
#else we just use the default scheduling rule
else:
self.activeQSorter()
self.activeQSorter(self.schedulingRule)
# =======================================================================
# sorts the Entities of the Queue according to the scheduling rule
......@@ -64,7 +69,7 @@ class Operator(Repairman):
pass
#if the schedulingRule is based on a pre-defined priority
elif criterion=="Priority":
activeObjectQ.sort(key=lambda x: x.priority)
activeObjectQ.sort(key=lambda x: x.entityToGet.priority)
#if the schedulingRule is earliest due date
elif criterion=="EDD":
activeObjectQ.sort(key=lambda x: x.dueDate)
......
......@@ -34,8 +34,8 @@ from Operator import Operator
# ===========================================================================
class OperatorManagedJob(Operator):
def __init__(self, id, name, capacity=1):
Operator.__init__(self,id=id,name=name,capacity=capacity)
def __init__(self, id, name, capacity=1,schedulingRule="FIFO"):
Operator.__init__(self,id=id,name=name,capacity=capacity,schedulingRule=schedulingRule)
self.operatorAssignedTo=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