Commit fd40d840 authored by Georgios Dagkakis's avatar Georgios Dagkakis

Object Resources except OperatorPool to read in new style

parent f598113e
...@@ -199,41 +199,16 @@ def createObjects(): ...@@ -199,41 +199,16 @@ def createObjects():
element.pop(k, None) element.pop(k, None)
# with key 'id' and value the the element_id # with key 'id' and value the the element_id
resourceClass = element.pop('_class') # get the class type of the element resourceClass = element.pop('_class') # get the class type of the element
if resourceClass=='Dream.Repairman': # check the object type
id = element.get('id', 'not found') # get the id of the element objectType=Globals.getClassFromName(resourceClass)
name = element.get('name', id) # get the name of the element / default 'not_found' from ObjectResource import ObjectResource # operator pools to be created later since they use operators
capacity = int(element.get('capacity') or 1) # ToDo maybe it is semantically diferent object
R = Repairman(element_id, name, capacity) # create a repairman object if issubclass(objectType, ObjectResource) and not resourceClass=='Dream.OperatorPool':
R.coreObjectIds=getSuccessorList(id) # update the list of objects that the repairman repairs inputDict=dict(element)
# calling the getSuccessorList() method on the repairman # create the CoreObject
G.RepairmanList.append(R) # add the repairman to the RepairmanList objectResource=objectType(**inputDict)
G.ObjectResourceList.append(R) objectResource.coreObjectIds=getSuccessorList(element['id'])
elif resourceClass=='Dream.Operator':
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') or 1)
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
skills=element.get('skills',[]) # list of stations that the operator can attend to
O = Operator(element_id, name, capacity,schedulingRule,skills) # 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
G.ObjectResourceList.append(O)
elif resourceClass=='Dream.OperatorManagedJob':
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') or 1) # get the capacity of the el. / defautl '1'
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
G.OperatorManagedJobsList.append(O)
G.ObjectResourceList.append(O)
''' '''
loop through all the model resources loop through all the model resources
search for operatorPools in order to create them search for operatorPools in order to create them
...@@ -244,8 +219,8 @@ def createObjects(): ...@@ -244,8 +219,8 @@ def createObjects():
# element itself # element itself
element = element.copy() element = element.copy()
element['id'] = element_id # create a new entry for the element (dictionary) element['id'] = element_id # create a new entry for the element (dictionary)
# for k in ('element_id', 'top', 'left'): for k in ('element_id', 'top', 'left'):
# element.pop(k, None) element.pop(k, None)
# with key 'id' and value the the element_id # with key 'id' and value the the element_id
resourceClass = element.pop('_class') # get the class type of the element resourceClass = element.pop('_class') # get the class type of the element
if resourceClass=='Dream.OperatorPool': if resourceClass=='Dream.OperatorPool':
......
...@@ -38,6 +38,8 @@ class ObjectResource(object): ...@@ -38,6 +38,8 @@ class ObjectResource(object):
self.objectInterruptions=[] self.objectInterruptions=[]
# alias used for printing the trace # alias used for printing the trace
self.alias=None self.alias=None
from Globals import G
G.ObjectResourceList.append(self)
def initialize(self): def initialize(self):
from Globals import G from Globals import G
......
...@@ -41,7 +41,7 @@ class Operator(ObjectResource): ...@@ -41,7 +41,7 @@ class Operator(ObjectResource):
ObjectResource.__init__(self) ObjectResource.__init__(self)
self.id=id self.id=id
self.objName=name self.objName=name
self.capacity=capacity # repairman is an instance of resource self.capacity=int(capacity) # repairman is an instance of resource
self.type="Operator" self.type="Operator"
# lists to hold statistics of multiple runs # lists to hold statistics of multiple runs
self.Waiting=[] # holds the percentage of waiting time self.Waiting=[] # holds the percentage of waiting time
...@@ -78,6 +78,8 @@ class Operator(ObjectResource): ...@@ -78,6 +78,8 @@ class Operator(ObjectResource):
self.skillsList=skills self.skillsList=skills
# flag to show if the resource is available at the start of simulation # flag to show if the resource is available at the start of simulation
self.available=available self.available=available
from Globals import G
G.OperatorsList.append(self)
@staticmethod @staticmethod
def getSupportedSchedulingRules(): def getSupportedSchedulingRules():
......
...@@ -35,9 +35,10 @@ from Operator import Operator ...@@ -35,9 +35,10 @@ from Operator import Operator
# =========================================================================== # ===========================================================================
class OperatorManagedJob(Operator): class OperatorManagedJob(Operator):
# def __init__(self, id, name, capacity=1,schedulingRule="FIFO"): def __init__(self, id, name, capacity=1,schedulingRule="FIFO"):
# Operator.__init__(self,id=id,name=name,capacity=capacity,schedulingRule=schedulingRule) Operator.__init__(self,id=id,name=name,capacity=capacity,schedulingRule=schedulingRule)
# self.operatorAssignedTo=None from Globals import G
G.OperatorManagedJobsList.append(self)
# ======================================================================= # =======================================================================
# checks if the worker is available # checks if the worker is available
......
...@@ -37,4 +37,6 @@ class Repairman(Operator): ...@@ -37,4 +37,6 @@ class Repairman(Operator):
def __init__(self, id, name, capacity=1): def __init__(self, id, name, capacity=1):
Operator.__init__(self,id=id, name=name, capacity=capacity) Operator.__init__(self,id=id, name=name, capacity=capacity)
self.type="Repairman" self.type="Repairman"
from Globals import G
G.RepairmanList.append(self)
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