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):
#initialize the object
def __init__(self, id, name, distribution='Fixed', mean=1, stdev=0.1, min=0, max=5, **kw):
CoreObject.__init__(self)
self.id=id
self.objName=name
CoreObject.__init__(self, id, name)
self.type="Assembly" #String that shows the type of object
self.distType=distribution #the distribution that the procTime follows
self.rng=RandomNumberGenerator(self, self.distType)
......
......@@ -46,10 +46,7 @@ class BatchDecomposition(CoreObject):
# =======================================================================
def __init__(self, id, name, numberOfSubBatches=1, distribution='Fixed', \
mean=1, stdev=0, min=0, max=10, operator='None', **kw):
CoreObject.__init__(self)
# hold the id, name, and type of the Machine instance
self.id=id
self.objName=name
CoreObject.__init__(self, id, name)
self.type="BatchDecomposition" #String that shows the type of object
# holds the capacity of the object
self.numberOfSubBatches=numberOfSubBatches
......
......@@ -71,11 +71,10 @@ class NoneCallerObjectError(Exception):
class CompoundObject(CoreObject,Queue):
# 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):
CoreObject.__init__(self)
CoreObject.__init__(self, id, name)
# 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'
# variable that can hold according to this implementation two different values
# 'Parallel'
# 'Series'
......@@ -578,4 +577,4 @@ class CompoundObject(CoreObject,Queue):
# def newEntry(self):
# self.newEntityWillBeReceived = True
\ No newline at end of file
......@@ -36,9 +36,7 @@ from CoreObject import CoreObject
class Conveyer(CoreObject):
def __init__(self, id, name, length, speed, **kw):
CoreObject.__init__(self)
self.id=id
self.objName=name
CoreObject.__init__(self, id, name)
self.type="Conveyer"
self.speed=speed #the speed of the conveyer in m/sec
self.length=length #the length of the conveyer in meters
......
......@@ -32,8 +32,10 @@ from SimPy.Simulation import Process, Resource, now
# ===========================================================================
class CoreObject(Process):
def __init__(self):
def __init__(self, id, name, **kw):
Process.__init__(self)
self.id = id
self.objName = name
# lists that hold the previous and 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
......
......@@ -43,9 +43,7 @@ class Dismantle(CoreObject):
# =======================================================================
def __init__(self, id, name, distribution='Fixed', mean=1, stdev=0.1,
min=0, max=5, **kw):
CoreObject.__init__(self)
self.id=id
self.objName=name
CoreObject.__init__(self, id, name)
self.type="Dismantle" #String that shows the type of object
self.distType=distribution #the distribution that the procTime follows
self.rng=RandomNumberGenerator(self, self.distType)
......
......@@ -35,13 +35,11 @@ from CoreObject import CoreObject
class Exit(CoreObject):
def __init__(self, id, name=None, **kw):
CoreObject.__init__(self)
if not name:
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
# general properties of the Exit
self.id=id
self.objName=name
self.type="Exit" # XXX needed ?
# # list with routing information
# self.previous=[] # list with the previous objects in the flow
......
......@@ -52,10 +52,7 @@ class Machine(CoreObject):
loadDistribution="No",loadMean=0, loadStdev=0, loadMin=0, loadMax=10,
setupDistribution="No",setupMean=0, setupStdev=0, setupMin=0, setupMax=10,
isPreemptive=False, resetOnPreemption=False, **kw):
CoreObject.__init__(self)
# hold the id, name, and type of the Machine instance
self.id=id
self.objName=name
CoreObject.__init__(self, id, name)
self.type="Machine" #String that shows the type of object
# holds the capacity of the machine
self.capacity=capacity
......
......@@ -48,12 +48,8 @@ class MouldComponentException(Exception):
# the Order-Decomposition Object
# ===========================================================================
class OrderDecomposition(CoreObject):
def __init__(self, id, name, **kw):
CoreObject.__init__(self)
self.id=id
self.objName=name
self.type='OrderDecomposition'
type = 'OrderDecomposition'
# =======================================================================
# the initialize method
# =======================================================================
......
......@@ -35,14 +35,11 @@ from CoreObject import CoreObject
class Queue(CoreObject):
def __init__(self, id, name, capacity=1, isDummy=False, schedulingRule="FIFO", **kw):
CoreObject.__init__(self)
CoreObject.__init__(self, id, name)
# Process.__init__(self)
# 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.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
# holds the capacity of the Queue
if capacity>0:
......
......@@ -36,11 +36,8 @@ import Globals
#============================================================================
class Source(CoreObject):
def __init__(self, id, name, distribution='Fixed', mean=1, item='Dream.Part', **kw):
CoreObject.__init__(self)
# Process.__init__(self)
# general properties
self.id=id
self.objName=name
CoreObject.__init__(self, id, name)
self.distType=distribution # label that sets the distribution type
# properties used for statistics
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