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

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