Commit 8f437377 authored by Georgios Dagkakis's avatar Georgios Dagkakis

start using ** attr

parent 430b6d15
...@@ -78,6 +78,8 @@ class Assembly(CoreObject): ...@@ -78,6 +78,8 @@ class Assembly(CoreObject):
# when the entities have to be loaded to operatedMachines # when the entities have to be loaded to operatedMachines
# then the giverObjects have to be blocked for the time # then the giverObjects have to be blocked for the time
# that the machine is being loaded # that the machine is being loaded
from Globals import G
G.AssemblyList.append(self)
# ======================================================================= # =======================================================================
# parses inputs if they are given in a dictionary # parses inputs if they are given in a dictionary
......
...@@ -34,7 +34,7 @@ import simpy ...@@ -34,7 +34,7 @@ import simpy
class CoreObject(object): class CoreObject(object):
class_name = 'Dream.CoreObject' class_name = 'Dream.CoreObject'
def __init__(self, id='', name='', inputsDict={}, **kw): def __init__(self, id, name, inputsDict={}, **kw):
self.id = id self.id = id
self.objName = name self.objName = name
# lists that hold the previous and next objects in the flow # lists that hold the previous and next objects in the flow
...@@ -68,18 +68,9 @@ class CoreObject(object): ...@@ -68,18 +68,9 @@ class CoreObject(object):
self.station_col_inds=[] self.station_col_inds=[]
self.op_col_indx=None self.op_col_indx=None
# if there is input in a dictionary parse from it # if there is input in a dictionary parse from it
if inputsDict:
self.parseInputs(inputsDict)
# =======================================================================
# parses inputs if they are given in a dictionary
# =======================================================================
def parseInputs(self, inputsDict):
self.id = inputsDict.get('id')
self.objName = inputsDict.get('name')
from Globals import G from Globals import G
G.ObjList.append(self) # add object to ObjList G.ObjList.append(self) # add object to ObjList
def initialize(self): def initialize(self):
from Globals import G from Globals import G
self.env=G.env self.env=G.env
......
...@@ -45,19 +45,10 @@ class Exit(CoreObject): ...@@ -45,19 +45,10 @@ class Exit(CoreObject):
self.Lifespan=[] self.Lifespan=[]
self.TaktTime=[] self.TaktTime=[]
# if input is given in a dictionary # if input is given in a dictionary
if inputsDict: CoreObject.__init__(self, id, name)
CoreObject.__init__(self, inputsDict=inputsDict)
else:
CoreObject.__init__(self, id, name)
# =======================================================================
# parses inputs if they are given in a dictionary
# =======================================================================
def parseInputs(self, inputsDict):
CoreObject.parseInputs(self, inputsDict)
from Globals import G from Globals import G
G.ExitList.append(self) G.ExitList.append(self)
def initialize(self): def initialize(self):
# using the Process __init__ and not the CoreObject __init__ # using the Process __init__ and not the CoreObject __init__
CoreObject.initialize(self) CoreObject.initialize(self)
......
...@@ -278,12 +278,6 @@ def createObjects(): ...@@ -278,12 +278,6 @@ def createObjects():
element.pop(k, None) element.pop(k, None)
objClass = element.pop('_class') objClass = element.pop('_class')
if objClass=='Dream.Source':
S=Source(**element)
S.nextIds=getSuccessorList(element['id'])
G.SourceList.append(S)
G.ObjList.append(S)
if objClass=='Dream.BatchSource': if objClass=='Dream.BatchSource':
S = BatchSource(**element) S = BatchSource(**element)
S.nextIds=getSuccessorList(element['id']) S.nextIds=getSuccessorList(element['id'])
...@@ -294,14 +288,21 @@ def createObjects(): ...@@ -294,14 +288,21 @@ def createObjects():
elif objClass in ['Dream.Machine', 'Dream.BatchScrapMachine', 'Dream.M3', 'Dream.MachineJobShop', elif objClass in ['Dream.Machine', 'Dream.BatchScrapMachine', 'Dream.M3', 'Dream.MachineJobShop',
'Dream.MachineManagedJob', 'Dream.MouldAssembly', 'Dream.Exit', 'Dream.ExitJobShop', 'Dream.MachineManagedJob', 'Dream.MouldAssembly', 'Dream.Exit', 'Dream.ExitJobShop',
'Dream.Queue', 'Dream.RoutingQueue', 'Dream.QueueJobShop', 'Dream.QueueManagedJob', 'Dream.Queue', 'Dream.RoutingQueue', 'Dream.QueueJobShop', 'Dream.QueueManagedJob',
'Dream.Assembly', 'Dream.Dismantle']: 'Dream.Assembly', 'Dream.Dismantle', 'Dream.Source']:
inputDict=dict(element)
if 'wip' in inputDict:
del inputDict['wip']
if 'failures' in inputDict:
del inputDict['failures']
if 'shift' in inputDict:
del inputDict['shift']
objectType=Globals.getClassFromName(objClass) objectType=Globals.getClassFromName(objClass)
coreObject=objectType(inputsDict=element) coreObject=objectType(**inputDict)
# get the successorList for the 'Parts' # get the successorList for the 'Parts'
coreObject.nextPartIds=getSuccessorList(element['id'], lambda source, destination, edge_data: edge_data.get('entity') == 'Part') coreObject.nextPartIds=getSuccessorList(element['id'], lambda source, destination, edge_data: edge_data.get('entity') == 'Part')
# get the successorList for the 'Frames' # get the successorList for the 'Frames'
coreObject.nextFrameIds=getSuccessorList(element['id'], lambda source, destination, edge_data: edge_data.get('entity') == 'Frame') coreObject.nextFrameIds=getSuccessorList(element['id'], lambda source, destination, edge_data: edge_data.get('entity') == 'Frame')
coreObject.nextIds=getSuccessorList(element['id']) # update the nextIDs list of the machine coreObject.nextIds=getSuccessorList(element['id']) # update the nextIDs list of the object
elif objClass=='Dream.Conveyer': elif objClass=='Dream.Conveyer':
id=element.get('id', 'not found') id=element.get('id', 'not found')
......
This diff is collapsed.
...@@ -39,61 +39,22 @@ class Queue(CoreObject): ...@@ -39,61 +39,22 @@ class Queue(CoreObject):
#=========================================================================== #===========================================================================
def __init__(self, id='', name='', capacity=1, isDummy=False, schedulingRule="FIFO", level=None, gatherWipStat=False, inputsDict={}): def __init__(self, id='', name='', capacity=1, isDummy=False, schedulingRule="FIFO", level=None, gatherWipStat=False, inputsDict={}):
self.type="Queue" # String that shows the type of object self.type="Queue" # String that shows the type of object
if inputsDict: CoreObject.__init__(self, id, name)
CoreObject.__init__(self,inputsDict=inputsDict) # used for the routing of the entities
else: # holds the capacity of the Queue
CoreObject.__init__(self, id, name)
# used for the routing of the entities
# holds the capacity of the Queue
if capacity>0:
self.capacity=capacity
else:
self.capacity=float("inf")
# No failures are considered for the Queue
self.isDummy=isDummy #Boolean that shows if it is the dummy first Queue
self.schedulingRule=schedulingRule #the scheduling rule that the Queue follows
self.multipleCriterionList=[] #list with the criteria used to sort the Entities in the Queue
SRlist = [schedulingRule]
if schedulingRule.startswith("MC"): # if the first criterion is MC aka multiple criteria
SRlist = schedulingRule.split("-") # split the string of the criteria (delimiter -)
self.schedulingRule=SRlist.pop(0) # take the first criterion of the list
self.multipleCriterionList=SRlist # hold the criteria list in the property multipleCriterionList
for scheduling_rule in SRlist:
if scheduling_rule not in self.getSupportedSchedulingRules():
raise ValueError("Unknown scheduling rule %s for %s" %
(scheduling_rule, id))
self.gatherWipStat=gatherWipStat
# Will be populated by an event generator
self.wip_stat_list = []
# trigger level for the reallocation of operators
if level:
assert level<=self.capacity, "the level cannot be bigger than the capacity of the queue"
self.level=level
# =======================================================================
# parses inputs if they are given in a dictionary
# =======================================================================
def parseInputs(self, inputsDict):
CoreObject.parseInputs(self, inputsDict)
from Globals import G
G.QueueList.append(self)
# holds the capacity of the Queue
capacity=int(inputsDict.get('capacity') or 1)
if capacity>0: if capacity>0:
self.capacity=capacity self.capacity=capacity
else: else:
self.capacity=float("inf") self.capacity=float("inf")
self.isDummy=bool(int(inputsDict.get('isDummy') or 0)) #Boolean that shows if it is the dummy first Queue # No failures are considered for the Queue
self.schedulingRule=inputsDict.get('schedulingRule', 'FIFO') #the scheduling rule that the Queue follows
self.isDummy=bool(int(isDummy)) #Boolean that shows if it is the dummy first Queue
self.schedulingRule=schedulingRule #the scheduling rule that the Queue follows
self.multipleCriterionList=[] #list with the criteria used to sort the Entities in the Queue self.multipleCriterionList=[] #list with the criteria used to sort the Entities in the Queue
SRlist = [self.schedulingRule] SRlist = [schedulingRule]
if self.schedulingRule.startswith("MC"): # if the first criterion is MC aka multiple criteria if schedulingRule.startswith("MC"): # if the first criterion is MC aka multiple criteria
SRlist = self.schedulingRule.split("-") # split the string of the criteria (delimiter -) SRlist = schedulingRule.split("-") # split the string of the criteria (delimiter -)
self.schedulingRule=SRlist.pop(0) # take the first criterion of the list self.schedulingRule=SRlist.pop(0) # take the first criterion of the list
self.multipleCriterionList=SRlist # hold the criteria list in the property multipleCriterionList self.multipleCriterionList=SRlist # hold the criteria list in the property multipleCriterionList
...@@ -102,15 +63,16 @@ class Queue(CoreObject): ...@@ -102,15 +63,16 @@ class Queue(CoreObject):
raise ValueError("Unknown scheduling rule %s for %s" % raise ValueError("Unknown scheduling rule %s for %s" %
(scheduling_rule, id)) (scheduling_rule, id))
self.gatherWipStat=bool(int(inputsDict.get('gatherWipStat', 0))) self.gatherWipStat=gatherWipStat
# Will be populated by an event generator # Will be populated by an event generator
self.wip_stat_list = [] self.wip_stat_list = []
level=int(inputsDict.get('level') or 1)
# trigger level for the reallocation of operators # trigger level for the reallocation of operators
if level: if level:
assert level<=self.capacity, "the level cannot be bigger than the capacity of the queue" assert level<=self.capacity, "the level cannot be bigger than the capacity of the queue"
self.level=level self.level=level
from Globals import G
G.QueueList.append(self)
@staticmethod @staticmethod
def getSupportedSchedulingRules(): def getSupportedSchedulingRules():
return ("FIFO", "Priority", "EDD", "EOD", return ("FIFO", "Priority", "EDD", "EOD",
......
...@@ -97,7 +97,9 @@ class Source(CoreObject): ...@@ -97,7 +97,9 @@ class Source(CoreObject):
self.item=Globals.getClassFromName(entity) #the type of object that the Source will generate self.item=Globals.getClassFromName(entity) #the type of object that the Source will generate
self.scheduledEntities=[] # list of creations that are scheduled. pattern is [timeOfCreation, EntityCounter] self.scheduledEntities=[] # list of creations that are scheduled. pattern is [timeOfCreation, EntityCounter]
from Globals import G
G.SourceList.append(self)
#=========================================================================== #===========================================================================
# The initialize method of the Source class # The initialize method of the Source class
......
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