Commit adfbf696 authored by Jérome Perrin's avatar Jérome Perrin

make common initialization parts in CoreObject.__init__

parent d18c8602
...@@ -38,9 +38,7 @@ class Assembly(CoreObject): ...@@ -38,9 +38,7 @@ class Assembly(CoreObject):
#initialize the object #initialize the object
def __init__(self, id, name, distribution='Fixed', mean=1, stdev=0.1, min=0, max=5, **kw): def __init__(self, id, name, distribution='Fixed', mean=1, stdev=0.1, min=0, max=5, **kw):
CoreObject.__init__(self) CoreObject.__init__(self, id, name)
self.id=id
self.objName=name
self.type="Assembly" #String that shows the type of object self.type="Assembly" #String that shows the type of object
self.distType=distribution #the distribution that the procTime follows self.distType=distribution #the distribution that the procTime follows
self.rng=RandomNumberGenerator(self, self.distType) self.rng=RandomNumberGenerator(self, self.distType)
......
...@@ -46,10 +46,7 @@ class BatchDecomposition(CoreObject): ...@@ -46,10 +46,7 @@ class BatchDecomposition(CoreObject):
# ======================================================================= # =======================================================================
def __init__(self, id, name, numberOfSubBatches=1, distribution='Fixed', \ def __init__(self, id, name, numberOfSubBatches=1, distribution='Fixed', \
mean=1, stdev=0, min=0, max=10, operator='None', **kw): mean=1, stdev=0, min=0, max=10, operator='None', **kw):
CoreObject.__init__(self) CoreObject.__init__(self, id, name)
# hold the id, name, and type of the Machine instance
self.id=id
self.objName=name
self.type="BatchDecomposition" #String that shows the type of object self.type="BatchDecomposition" #String that shows the type of object
# holds the capacity of the object # holds the capacity of the object
self.numberOfSubBatches=numberOfSubBatches self.numberOfSubBatches=numberOfSubBatches
......
...@@ -71,11 +71,10 @@ class NoneCallerObjectError(Exception): ...@@ -71,11 +71,10 @@ class NoneCallerObjectError(Exception):
class CompoundObject(CoreObject,Queue): class CompoundObject(CoreObject,Queue):
# object arguments may provide information on the type of the object, and the arguments needed to initiate it # object arguments may provide information on the type of the object, and the arguments needed to initiate it
def __init__(self, id, name, capacity, routing='Series', *objects): def __init__(self, id, name, capacity, routing='Series', *objects):
CoreObject.__init__(self) CoreObject.__init__(self, id, name)
# it would be a good idea to have the arguments provided as dictionary # it would be a good idea to have the arguments provided as dictionary
self.id = id # may avoid to use that here
self.objName = name # -||-
self.type = 'CompoundObject' self.type = 'CompoundObject'
# variable that can hold according to this implementation two different values # variable that can hold according to this implementation two different values
# 'Parallel' # 'Parallel'
# 'Series' # 'Series'
......
...@@ -36,9 +36,7 @@ from CoreObject import CoreObject ...@@ -36,9 +36,7 @@ from CoreObject import CoreObject
class Conveyer(CoreObject): class Conveyer(CoreObject):
def __init__(self, id, name, length, speed, **kw): def __init__(self, id, name, length, speed, **kw):
CoreObject.__init__(self) CoreObject.__init__(self, id, name)
self.id=id
self.objName=name
self.type="Conveyer" self.type="Conveyer"
self.speed=speed #the speed of the conveyer in m/sec self.speed=speed #the speed of the conveyer in m/sec
self.length=length #the length of the conveyer in meters self.length=length #the length of the conveyer in meters
......
...@@ -32,8 +32,10 @@ from SimPy.Simulation import Process, Resource, now ...@@ -32,8 +32,10 @@ from SimPy.Simulation import Process, Resource, now
# =========================================================================== # ===========================================================================
class CoreObject(Process): class CoreObject(Process):
def __init__(self): def __init__(self, id, name, **kw):
Process.__init__(self) Process.__init__(self)
self.id = id
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
self.next=[] #list with the next objects in the flow self.next=[] #list with the next objects in the flow
self.previous=[] #list with the previous objects in the flow self.previous=[] #list with the previous objects in the flow
......
...@@ -43,9 +43,7 @@ class Dismantle(CoreObject): ...@@ -43,9 +43,7 @@ class Dismantle(CoreObject):
# ======================================================================= # =======================================================================
def __init__(self, id, name, distribution='Fixed', mean=1, stdev=0.1, def __init__(self, id, name, distribution='Fixed', mean=1, stdev=0.1,
min=0, max=5, **kw): min=0, max=5, **kw):
CoreObject.__init__(self) CoreObject.__init__(self, id, name)
self.id=id
self.objName=name
self.type="Dismantle" #String that shows the type of object self.type="Dismantle" #String that shows the type of object
self.distType=distribution #the distribution that the procTime follows self.distType=distribution #the distribution that the procTime follows
self.rng=RandomNumberGenerator(self, self.distType) self.rng=RandomNumberGenerator(self, self.distType)
......
...@@ -35,13 +35,11 @@ from CoreObject import CoreObject ...@@ -35,13 +35,11 @@ from CoreObject import CoreObject
class Exit(CoreObject): class Exit(CoreObject):
def __init__(self, id, name=None, **kw): def __init__(self, id, name=None, **kw):
CoreObject.__init__(self)
if not name: if not name:
name = id name = id
CoreObject.__init__(self, id, name)
self.predecessorIndex=0 # holds the index of the predecessor from which the Exit will take an entity next self.predecessorIndex=0 # holds the index of the predecessor from which the Exit will take an entity next
# general properties of the Exit # general properties of the Exit
self.id=id
self.objName=name
self.type="Exit" # XXX needed ? self.type="Exit" # XXX needed ?
# # list with routing information # # list with routing information
# self.previous=[] # list with the previous objects in the flow # self.previous=[] # list with the previous objects in the flow
......
...@@ -52,10 +52,7 @@ class Machine(CoreObject): ...@@ -52,10 +52,7 @@ class Machine(CoreObject):
loadDistribution="No",loadMean=0, loadStdev=0, loadMin=0, loadMax=10, loadDistribution="No",loadMean=0, loadStdev=0, loadMin=0, loadMax=10,
setupDistribution="No",setupMean=0, setupStdev=0, setupMin=0, setupMax=10, setupDistribution="No",setupMean=0, setupStdev=0, setupMin=0, setupMax=10,
isPreemptive=False, resetOnPreemption=False, **kw): isPreemptive=False, resetOnPreemption=False, **kw):
CoreObject.__init__(self) CoreObject.__init__(self, id, name)
# hold the id, name, and type of the Machine instance
self.id=id
self.objName=name
self.type="Machine" #String that shows the type of object self.type="Machine" #String that shows the type of object
# holds the capacity of the machine # holds the capacity of the machine
self.capacity=capacity self.capacity=capacity
......
...@@ -48,11 +48,7 @@ class MouldComponentException(Exception): ...@@ -48,11 +48,7 @@ class MouldComponentException(Exception):
# the Order-Decomposition Object # the Order-Decomposition Object
# =========================================================================== # ===========================================================================
class OrderDecomposition(CoreObject): class OrderDecomposition(CoreObject):
def __init__(self, id, name, **kw): type = 'OrderDecomposition'
CoreObject.__init__(self)
self.id=id
self.objName=name
self.type='OrderDecomposition'
# ======================================================================= # =======================================================================
# the initialize method # the initialize method
......
...@@ -35,14 +35,11 @@ from CoreObject import CoreObject ...@@ -35,14 +35,11 @@ from CoreObject import CoreObject
class Queue(CoreObject): class Queue(CoreObject):
def __init__(self, id, name, capacity=1, isDummy=False, schedulingRule="FIFO", **kw): def __init__(self, id, name, capacity=1, isDummy=False, schedulingRule="FIFO", **kw):
CoreObject.__init__(self) CoreObject.__init__(self, id, name)
# Process.__init__(self) # Process.__init__(self)
# used for the routing of the entities # used for the routing of the entities
self.predecessorIndex=0 # holds the index of the predecessor from which the Queue will take an entity next self.predecessorIndex=0 # holds the index of the predecessor from which the Queue will take an entity next
self.successorIndex=0 # holds the index of the successor where the Queue will dispose an entity next self.successorIndex=0 # holds the index of the successor where the Queue will dispose an entity next
# hold the id, name, and type of the Queue instance
self.id=id
self.objName=name
self.type="Queue" # String that shows the type of object self.type="Queue" # String that shows the type of object
# holds the capacity of the Queue # holds the capacity of the Queue
if capacity>0: if capacity>0:
......
...@@ -36,11 +36,8 @@ import Globals ...@@ -36,11 +36,8 @@ import Globals
#============================================================================ #============================================================================
class Source(CoreObject): class Source(CoreObject):
def __init__(self, id, name, distribution='Fixed', mean=1, item='Dream.Part', **kw): def __init__(self, id, name, distribution='Fixed', mean=1, item='Dream.Part', **kw):
CoreObject.__init__(self) CoreObject.__init__(self, id, name)
# Process.__init__(self)
# general properties
self.id=id
self.objName=name
self.distType=distribution # label that sets the distribution type self.distType=distribution # label that sets the distribution type
# properties used for statistics # properties used for statistics
self.totalInterArrivalTime=0 # the total interarrival time self.totalInterArrivalTime=0 # the total interarrival time
......
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