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

first step of simplifying LineGenerationJSON

Notes:
  * Input format changed (Source.part now is a full name)
  * __init__ must handle complex data structures for processingTime & interarrivalTime instead of having flat parameters
  * type conversion must be performed ("1" != 1), probably we can assume json has correct type and have the gui produce proper json
parent d7ffe32a
...@@ -37,7 +37,7 @@ from CoreObject import CoreObject ...@@ -37,7 +37,7 @@ from CoreObject import CoreObject
class Assembly(CoreObject): 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): def __init__(self, id, name, distribution='Fixed', mean=1, stdev=0.1, min=0, max=5, **kw):
CoreObject.__init__(self) CoreObject.__init__(self)
self.id=id self.id=id
self.objName=name self.objName=name
......
...@@ -45,7 +45,7 @@ class BatchDecomposition(CoreObject): ...@@ -45,7 +45,7 @@ class BatchDecomposition(CoreObject):
#initialize the id, the capacity of the object and the distribution #initialize the id, the capacity of the object and the distribution
# ======================================================================= # =======================================================================
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'): mean=1, stdev=0, min=0, max=10, operator='None', **kw):
CoreObject.__init__(self) CoreObject.__init__(self)
# hold the id, name, and type of the Machine instance # hold the id, name, and type of the Machine instance
self.id=id self.id=id
......
...@@ -46,7 +46,7 @@ class BatchReassembly(CoreObject): ...@@ -46,7 +46,7 @@ class BatchReassembly(CoreObject):
#initialize the id, the capacity of the object and the distribution #initialize the id, the capacity of the object and the distribution
# ======================================================================= # =======================================================================
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'): mean=1, stdev=0, min=0, max=10, operator='None', **kw):
Process.__init__(self) Process.__init__(self)
# hold the id, name, and type of the Machine instance # hold the id, name, and type of the Machine instance
self.id=id self.id=id
......
...@@ -41,14 +41,16 @@ class BatchScrapMachine(Machine): ...@@ -41,14 +41,16 @@ class BatchScrapMachine(Machine):
def __init__(self, id, name, capacity=1, \ def __init__(self, id, name, capacity=1, \
distribution='Fixed', mean=1, stdev=0, min=0, max=10,\ distribution='Fixed', mean=1, stdev=0, min=0, max=10,\
failureDistribution='No', MTTF=0, MTTR=0, availability=0, repairman='None',\ failureDistribution='No', MTTF=0, MTTR=0, availability=0, repairman='None',\
scrapDistribution='Fixed',scrMean=1,scrStdev=0,scrMin=0,scrMax=10): scrapDistribution='Fixed',scrMean=1,scrStdev=0,scrMin=0,scrMax=10,
**kw):
# initialize using the default method of the object # initialize using the default method of the object
Machine.__init__(self,id=id,name=name,\ Machine.__init__(self,id=id,name=name,\
capacity=capacity,\ capacity=capacity,\
distribution=distribution,\ distribution=distribution,\
mean=mean,stdev=stdev,min=min,max=max,\ mean=mean,stdev=stdev,min=min,max=max,\
failureDistribution=failureDistribution,MTTF=MTTF,MTTR=MTTR,\ failureDistribution=failureDistribution,MTTF=MTTF,MTTR=MTTR,\
availability=availability, repairman=repairman) availability=availability,
repairman=repairman, **kw)
self.scrapDistType=scrapDistribution #the distribution that the failure follows self.scrapDistType=scrapDistribution #the distribution that the failure follows
# Sets the attributes of the scrap quantity distribution # Sets the attributes of the scrap quantity distribution
......
...@@ -25,14 +25,15 @@ Created on 29 Oct 2013 ...@@ -25,14 +25,15 @@ Created on 29 Oct 2013
models the source object that generates the Batches Entities models the source object that generates the Batches Entities
''' '''
from Source import Source from Source import Source
from Batch import Batch
from Globals import G from Globals import G
from SimPy.Simulation import Process from SimPy.Simulation import Process
from RandomNumberGenerator import RandomNumberGenerator from RandomNumberGenerator import RandomNumberGenerator
class BatchSource(Source): class BatchSource(Source):
def __init__(self, id, name, distribution='Fixed', mean=1, item=Batch, batchNumberOfUnits = 1): def __init__(self, id, name, distribution='Fixed', mean=1,
Source.__init__(self, id=id, name=name, distribution=distribution, mean=mean, item=item) item='Dream.Batch', batchNumberOfUnits=1, **kw):
Source.__init__(self, id=id, name=name, distribution=distribution,
mean=mean, item=item, **kw)
self.numberOfUnits = batchNumberOfUnits self.numberOfUnits = batchNumberOfUnits
......
...@@ -43,8 +43,10 @@ class ConditionalBuffer(QueueManagedJob): ...@@ -43,8 +43,10 @@ class ConditionalBuffer(QueueManagedJob):
# the default __init__ method of the QueueManagedJob class # the default __init__ method of the QueueManagedJob class
# whereas the default capacity is set to infinity # whereas the default capacity is set to infinity
# ======================================================================= # =======================================================================
def __init__(self, id, name, capacity=-1, dummy=False, schedulingRule="FIFO"): def __init__(self, id, name, capacity=-1, isDummy=False,
QueueManagedJob.__init__(self, id=id, name=name, capacity=capacity, dummy=dummy, schedulingRule=schedulingRule) schedulingRule="FIFO", **kw):
QueueManagedJob.__init__(self, id=id, name=name, capacity=capacity,
isDummy=isDummy, schedulingRule=schedulingRule, **kw)
# ======================================================================= # =======================================================================
# checks if the Buffer can dispose an entity. # checks if the Buffer can dispose an entity.
......
...@@ -35,7 +35,7 @@ from CoreObject import CoreObject ...@@ -35,7 +35,7 @@ from CoreObject import CoreObject
#The conveyer object #The conveyer object
class Conveyer(CoreObject): class Conveyer(CoreObject):
def __init__(self, id, name,length,speed): def __init__(self, id, name, length, speed, **kw):
CoreObject.__init__(self) CoreObject.__init__(self)
self.id=id self.id=id
self.objName=name self.objName=name
......
...@@ -54,6 +54,7 @@ class CoreObject(Process): ...@@ -54,6 +54,7 @@ class CoreObject(Process):
def initialize(self): def initialize(self):
# XXX why call super.__init__ outside of __init__ ?
Process.__init__(self) Process.__init__(self)
self.Up=True #Boolean that shows if the machine is in failure ("Down") or not ("up") self.Up=True #Boolean that shows if the machine is in failure ("Down") or not ("up")
self.onShift=True self.onShift=True
......
...@@ -41,7 +41,8 @@ class Dismantle(CoreObject): ...@@ -41,7 +41,8 @@ class Dismantle(CoreObject):
# ======================================================================= # =======================================================================
# initialize the object # initialize the object
# ======================================================================= # =======================================================================
def __init__(self, id, name, distribution='Fixed', mean=1, stdev=0.1, min=0, max=5): def __init__(self, id, name, distribution='Fixed', mean=1, stdev=0.1,
min=0, max=5, **kw):
CoreObject.__init__(self) CoreObject.__init__(self)
self.id=id self.id=id
self.objName=name self.objName=name
......
...@@ -30,7 +30,8 @@ from SimPy.Simulation import now, hold, Process ...@@ -30,7 +30,8 @@ from SimPy.Simulation import now, hold, Process
from ObjectInterruption import ObjectInterruption from ObjectInterruption import ObjectInterruption
class EventGenerator(ObjectInterruption): class EventGenerator(ObjectInterruption):
def __init__(self, id=id, name=None, start=None, stop=None, interval=None, duration=None, method=None, argumentDict=None): def __init__(self, id=id, name=None, start=None, stop=None, interval=None,
duration=None, method=None, argumentDict=None, **kw):
ObjectInterruption.__init__(self) ObjectInterruption.__init__(self)
self.id=id self.id=id
self.name=name self.name=name
......
...@@ -34,14 +34,15 @@ from CoreObject import CoreObject ...@@ -34,14 +34,15 @@ from CoreObject import CoreObject
# =========================================================================== # ===========================================================================
class Exit(CoreObject): class Exit(CoreObject):
def __init__(self, id, name): def __init__(self, id, name=None, **kw):
CoreObject.__init__(self) CoreObject.__init__(self)
Process.__init__(self) if not name:
name = id
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.id=id
self.objName=name self.objName=name
self.type="Exit" 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
# self.nextIds=[] # list with the ids of the next objects in the flow. For the exit it is always empty! # self.nextIds=[] # list with the ids of the next objects in the flow. For the exit it is always empty!
......
...@@ -100,6 +100,7 @@ def getClassFromName(dotted_name): ...@@ -100,6 +100,7 @@ def getClassFromName(dotted_name):
# dream.simulation.Something.Something # dream.simulation.Something.Something
dream, class_name = dotted_name.split('.') dream, class_name = dotted_name.split('.')
import dream.simulation as ds import dream.simulation as ds
__import__('dream.simulation.%s' % class_name)
return getattr(getattr(ds, class_name), class_name) return getattr(getattr(ds, class_name), class_name)
# ======================================================================= # =======================================================================
......
...@@ -98,7 +98,7 @@ ...@@ -98,7 +98,7 @@
}, },
"S1": { "S1": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Part", "entity": "Dream.Part",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "0.5" "mean": "0.5"
......
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
}, },
"S1": { "S1": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Part", "entity": "Dream.Part",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "0.5" "mean": "0.5"
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
}, },
"S2": { "S2": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Frame", "entity": "Dream.Frame",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "2" "mean": "2"
......
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
}, },
"S1": { "S1": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Part", "entity": "Dream.Part",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "0.5" "mean": "0.5"
......
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
}, },
"S1": { "S1": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Part", "entity": "Dream.Part",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "0.5" "mean": "0.5"
......
...@@ -97,7 +97,7 @@ ...@@ -97,7 +97,7 @@
}, },
"S1": { "S1": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Part", "entity": "Dream.Part",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "0.5" "mean": "0.5"
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
}, },
"S2": { "S2": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Frame", "entity": "Dream.Frame",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "2" "mean": "2"
......
...@@ -117,7 +117,7 @@ ...@@ -117,7 +117,7 @@
}, },
"S1": { "S1": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Part", "entity": "Dream.Part",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "0.5" "mean": "0.5"
......
...@@ -101,7 +101,7 @@ ...@@ -101,7 +101,7 @@
}, },
"S1": { "S1": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Part", "entity": "Dream.Part",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "0.5" "mean": "0.5"
...@@ -112,7 +112,7 @@ ...@@ -112,7 +112,7 @@
}, },
"S2": { "S2": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Part", "entity": "Dream.Part",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "1" "mean": "1"
......
...@@ -118,7 +118,7 @@ ...@@ -118,7 +118,7 @@
}, },
"S1": { "S1": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Part", "entity": "Dream.Part",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "0.5" "mean": "0.5"
...@@ -129,7 +129,7 @@ ...@@ -129,7 +129,7 @@
}, },
"S2": { "S2": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Part", "entity": "Dream.Part",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "1" "mean": "1"
...@@ -140,7 +140,7 @@ ...@@ -140,7 +140,7 @@
}, },
"S3": { "S3": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Part", "entity": "Dream.Part",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "2" "mean": "2"
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
}, },
"S1": { "S1": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Part", "entity": "Dream.Part",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "0.5" "mean": "0.5"
......
...@@ -118,7 +118,7 @@ ...@@ -118,7 +118,7 @@
}, },
"S1": { "S1": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Part", "entity": "Dream.Part",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "0.5" "mean": "0.5"
...@@ -129,7 +129,7 @@ ...@@ -129,7 +129,7 @@
}, },
"S2": { "S2": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Part", "entity": "Dream.Part",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "1" "mean": "1"
......
...@@ -113,7 +113,7 @@ ...@@ -113,7 +113,7 @@
}, },
"S1": { "S1": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Part", "entity": "Dream.Part",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "0.5" "mean": "0.5"
......
...@@ -150,7 +150,7 @@ ...@@ -150,7 +150,7 @@
}, },
"S1": { "S1": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Part", "entity": "Dream.Part",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "0.5" "mean": "0.5"
......
...@@ -98,7 +98,7 @@ ...@@ -98,7 +98,7 @@
}, },
"S1": { "S1": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Part", "entity": "Dream.Part",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "0.5" "mean": "0.5"
...@@ -109,7 +109,7 @@ ...@@ -109,7 +109,7 @@
}, },
"S2": { "S2": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Frame", "entity": "Dream.Frame",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "2" "mean": "2"
......
...@@ -150,7 +150,7 @@ ...@@ -150,7 +150,7 @@
}, },
"S1": { "S1": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Part", "entity": "Dream.Part",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "0.5" "mean": "0.5"
...@@ -161,7 +161,7 @@ ...@@ -161,7 +161,7 @@
}, },
"S2": { "S2": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Frame", "entity": "Dream.Frame",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "2" "mean": "2"
......
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
}, },
"S1": { "S1": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Part", "entity": "Dream.Part",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "0.5" "mean": "0.5"
......
...@@ -117,7 +117,7 @@ ...@@ -117,7 +117,7 @@
}, },
"S1": { "S1": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Part", "entity": "Dream.Part",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "0.5" "mean": "0.5"
......
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
}, },
"S1": { "S1": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Part", "entity": "Dream.Part",
"id": "S1", "id": "S1",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
......
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
"S1": { "S1": {
"_class": "Dream.BatchSource", "_class": "Dream.BatchSource",
"batchNumberOfUnits": 80, "batchNumberOfUnits": 80,
"entity": "Batch", "entity": "Dream.Batch",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "0.5" "mean": "0.5"
......
...@@ -128,7 +128,7 @@ ...@@ -128,7 +128,7 @@
"S1": { "S1": {
"_class": "Dream.BatchSource", "_class": "Dream.BatchSource",
"batchNumberOfUnits": 80, "batchNumberOfUnits": 80,
"entity": "Batch", "entity": "Dream.Batch",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "1.5" "mean": "1.5"
......
...@@ -126,7 +126,7 @@ ...@@ -126,7 +126,7 @@
"S1": { "S1": {
"_class": "Dream.BatchSource", "_class": "Dream.BatchSource",
"batchNumberOfUnits": 100, "batchNumberOfUnits": 100,
"entity": "Batch", "entity": "Dream.Batch",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "1.5" "mean": "1.5"
......
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
"S1": { "S1": {
"_class": "Dream.BatchSource", "_class": "Dream.BatchSource",
"batchNumberOfUnits": 100, "batchNumberOfUnits": 100,
"entity": "Batch", "entity": "Dream.Batch",
"id": "S1", "id": "S1",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
......
...@@ -152,7 +152,7 @@ ...@@ -152,7 +152,7 @@
"S1": { "S1": {
"_class": "Dream.BatchSource", "_class": "Dream.BatchSource",
"batchNumberOfUnits": 100, "batchNumberOfUnits": 100,
"entity": "Batch", "entity": "Dream.Batch",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "0.5" "mean": "0.5"
......
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
}, },
"S1": { "S1": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Part", "entity": "Dream.Part",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "1" "mean": "1"
......
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
}, },
"S1": { "S1": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Part", "entity": "Dream.Part",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "1.5" "mean": "1.5"
......
...@@ -94,7 +94,7 @@ ...@@ -94,7 +94,7 @@
}, },
"S1": { "S1": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Part", "entity": "Dream.Part",
"id": "S1", "id": "S1",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
......
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
}, },
"S1": { "S1": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Part", "entity": "Dream.Part",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "0.5" "mean": "0.5"
......
...@@ -150,7 +150,7 @@ ...@@ -150,7 +150,7 @@
}, },
"S1": { "S1": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Part", "entity": "Dream.Part",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "0.5" "mean": "0.5"
......
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
}, },
"S1": { "S1": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Part", "entity": "Dream.Part",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "0.5" "mean": "0.5"
......
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
}, },
"S1": { "S1": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Part", "entity": "Dream.Part",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "6" "mean": "6"
......
...@@ -136,7 +136,7 @@ ...@@ -136,7 +136,7 @@
"S1": { "S1": {
"_class": "Dream.BatchSource", "_class": "Dream.BatchSource",
"batchNumberOfUnits": 80, "batchNumberOfUnits": 80,
"entity": "Batch", "entity": "Dream.Batch",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "1.5" "mean": "1.5"
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
}, },
"S1": { "S1": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Part", "entity": "Dream.Part",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "1" "mean": "1"
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
}, },
"S1": { "S1": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Part", "entity": "Dream.Part",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "1" "mean": "1"
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
}, },
"S1": { "S1": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Part", "entity": "Dream.Part",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "1" "mean": "1"
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
}, },
"S1": { "S1": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Part", "entity": "Dream.Part",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "1" "mean": "1"
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
}, },
"S1": { "S1": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Part", "entity": "Dream.Part",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "1" "mean": "1"
......
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
}, },
"S1": { "S1": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Part", "entity": "Dream.Part",
"id": "S1", "id": "S1",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
......
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
}, },
"S1": { "S1": {
"_class": "Dream.Source", "_class": "Dream.Source",
"entity": "Part", "entity": "Dream.Part",
"id": "S1", "id": "S1",
"interarrivalTime": { "interarrivalTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
......
...@@ -33,7 +33,6 @@ from warnings import warn ...@@ -33,7 +33,6 @@ from warnings import warn
import logging import logging
logger = logging.getLogger("dream.platform") logger = logging.getLogger("dream.platform")
try: try:
import scipy import scipy
except ImportError: except ImportError:
...@@ -174,14 +173,22 @@ def createObjects(): ...@@ -174,14 +173,22 @@ def createObjects():
G.QueueManagedJobList=[] G.QueueManagedJobList=[]
G.ModelResourceList=[] G.ModelResourceList=[]
# test that we can instanciate everything.
obj_list = []
for (element_id, element) in nodes.iteritems():
element['id'] = element_id
resourceClass = Globals.getClassFromName(element['_class'])
resource = resourceClass(**element)
resource.nextIds = getSuccessorList(element['id'])
obj_list.append(resource)
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
# loop through all the model resources # loop through all the model resources
# search for repairmen and operators in order to create them # search for repairmen and operators in order to create them
# read the data and create them # read the data and create them
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
for (element_id, element) in nodes.iteritems(): # use an iterator to go through all the nodes for (element_id, element) in nodes.iteritems(): # use an iterator to go through all the nodes
# the key is the element_id and the second is the
# element itself
element['id'] = element_id # create a new entry for the element (dictionary) element['id'] = element_id # create a new entry for the element (dictionary)
# with key 'id' and value the the element_id # with key 'id' and value the the element_id
resourceClass = element.get('_class', 'not found') # get the class type of the element resourceClass = element.get('_class', 'not found') # get the class type of the element
...@@ -244,7 +251,8 @@ def createObjects(): ...@@ -244,7 +251,8 @@ def createObjects():
interarrivalTime=element.get('interarrivalTime',{}) interarrivalTime=element.get('interarrivalTime',{})
distributionType=interarrivalTime.get('distributionType', 'not found') distributionType=interarrivalTime.get('distributionType', 'not found')
mean=float(interarrivalTime.get('mean') or 0) mean=float(interarrivalTime.get('mean') or 0)
entity=str_to_class(element['entity']) # initialize entity #entity=str_to_class(element['entity']) # initialize entity
entity=element['entity']
S=Source(id, name, distributionType, mean, entity) # initialize Source S=Source(id, name, distributionType, mean, entity) # initialize Source
S.nextIds=getSuccessorList(id) S.nextIds=getSuccessorList(id)
G.SourceList.append(S) G.SourceList.append(S)
...@@ -256,7 +264,8 @@ def createObjects(): ...@@ -256,7 +264,8 @@ def createObjects():
interarrivalTime=element.get('interarrivalTime',{}) interarrivalTime=element.get('interarrivalTime',{})
distributionType=interarrivalTime.get('distributionType', 'not found') distributionType=interarrivalTime.get('distributionType', 'not found')
mean=float(interarrivalTime.get('mean') or 0) mean=float(interarrivalTime.get('mean') or 0)
entity=str_to_class(element['entity']) #entity=str_to_class(element['entity'])
entity=(element['entity'])
batchNumberOfUnits=int(element.get('batchNumberOfUnits', 'not found')) batchNumberOfUnits=int(element.get('batchNumberOfUnits', 'not found'))
S=BatchSource(id, name, distributionType, mean, entity, batchNumberOfUnits) S=BatchSource(id, name, distributionType, mean, entity, batchNumberOfUnits)
S.nextIds=getSuccessorList(id) S.nextIds=getSuccessorList(id)
...@@ -1309,6 +1318,8 @@ def createObjectInterruptions(): ...@@ -1309,6 +1318,8 @@ def createObjectInterruptions():
# used to convert a string read from the input to object type # used to convert a string read from the input to object type
# =========================================================================== # ===========================================================================
def str_to_class(str): def str_to_class(str):
str = str.replace("Dream.", "") # XXX temporary.
# actuall this method can be dropped in favor of getClassFromName
return getattr(sys.modules[__name__], str) return getattr(sys.modules[__name__], str)
# =========================================================================== # ===========================================================================
......
...@@ -49,7 +49,7 @@ class Machine(CoreObject): ...@@ -49,7 +49,7 @@ class Machine(CoreObject):
operatorPool='None',operationType='None',\ operatorPool='None',operationType='None',\
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): isPreemptive=False, resetOnPreemption=False, **kw):
CoreObject.__init__(self) CoreObject.__init__(self)
# hold the id, name, and type of the Machine instance # hold the id, name, and type of the Machine instance
self.id=id self.id=id
...@@ -77,6 +77,7 @@ class Machine(CoreObject): ...@@ -77,6 +77,7 @@ class Machine(CoreObject):
the list of operators provided the list of operators provided
if the list is empty create operator pool with empty list if the list is empty create operator pool with empty list
''' '''
# XXX operatorPool is not None ?
if (type(operatorPool) is list) and len(operatorPool)>0: if (type(operatorPool) is list) and len(operatorPool)>0:
id = id+'_OP' id = id+'_OP'
name=self.objName+'_operatorPool' name=self.objName+'_operatorPool'
......
...@@ -44,8 +44,10 @@ class MouldAssemblyBuffer(QueueManagedJob): ...@@ -44,8 +44,10 @@ class MouldAssemblyBuffer(QueueManagedJob):
# the default __init__ method of the QueueManagedJob class # the default __init__ method of the QueueManagedJob class
# whereas the default capacity is set to infinity # whereas the default capacity is set to infinity
# ======================================================================= # =======================================================================
def __init__(self, id, name, capacity=-1, dummy=False, schedulingRule="FIFO"): def __init__(self, id, name, capacity=-1, isDummy=False,
QueueManagedJob.__init__(self, id=id, name=name, capacity=capacity, dummy=dummy, schedulingRule=schedulingRule) schedulingRule="FIFO", **kw):
QueueManagedJob.__init__(self, id=id, name=name, capacity=capacity,
isDummy=isDummy, schedulingRule=schedulingRule, **kw)
# ======================================================================= # =======================================================================
# Sort the entities of the activeQ # Sort the entities of the activeQ
......
...@@ -23,7 +23,7 @@ Created on 22 Nov 2012 ...@@ -23,7 +23,7 @@ Created on 22 Nov 2012
''' '''
''' '''
models a repairman that can fix a machine when it gets failures models an operator that operates a machine
''' '''
from SimPy.Simulation import Resource, now from SimPy.Simulation import Resource, now
...@@ -32,10 +32,10 @@ from Repairman import Repairman ...@@ -32,10 +32,10 @@ from Repairman import Repairman
# =========================================================================== # ===========================================================================
# the resource that operates the machines # the resource that operates the machines
# =========================================================================== # ===========================================================================
class Operator(Repairman): class Operator(Repairman): # XXX isn't it the other way around ?
def __init__(self, id, name, capacity=1): def __init__(self, id, name, capacity=1, **kw):
Repairman.__init__(self,id=id,name=name,capacity=capacity) Repairman.__init__(self,id=id,name=name,capacity=capacity, **kw)
self.type="Operator" self.type="Operator"
...@@ -37,7 +37,10 @@ from Operator import Operator ...@@ -37,7 +37,10 @@ from Operator import Operator
# =========================================================================== # ===========================================================================
class OperatorPool(ObjectResource): class OperatorPool(ObjectResource):
def __init__(self, id, name, capacity=1,operatorsList='None'): def __init__(self, id, name, capacity=1, operatorsList='None', **kw):
capacity = int(capacity or 1)
self.id=id self.id=id
self.objName=name self.objName=name
......
...@@ -48,7 +48,7 @@ class MouldComponentException(Exception): ...@@ -48,7 +48,7 @@ class MouldComponentException(Exception):
# the Order-Decomposition Object # the Order-Decomposition Object
# =========================================================================== # ===========================================================================
class OrderDecomposition(CoreObject): class OrderDecomposition(CoreObject):
def __init__(self, id, name): def __init__(self, id, name, **kw):
CoreObject.__init__(self) CoreObject.__init__(self)
self.id=id self.id=id
self.objName=name self.objName=name
......
...@@ -34,7 +34,7 @@ from CoreObject import CoreObject ...@@ -34,7 +34,7 @@ from CoreObject import CoreObject
# =========================================================================== # ===========================================================================
class Queue(CoreObject): class Queue(CoreObject):
def __init__(self, id, name, capacity=1, dummy=False, schedulingRule="FIFO"): def __init__(self, id, name, capacity=1, isDummy=False, schedulingRule="FIFO", **kw):
CoreObject.__init__(self) CoreObject.__init__(self)
# Process.__init__(self) # Process.__init__(self)
# used for the routing of the entities # used for the routing of the entities
...@@ -61,7 +61,7 @@ class Queue(CoreObject): ...@@ -61,7 +61,7 @@ class Queue(CoreObject):
# self.nextIds=[] #list with the ids of the next objects in the flow # self.nextIds=[] #list with the ids of the next objects in the flow
# self.previousIds=[] #list with the ids of the previous objects in the flow # self.previousIds=[] #list with the ids of the previous objects in the flow
self.isDummy=dummy #Boolean that shows if it is the dummy first 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.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 = [schedulingRule] SRlist = [schedulingRule]
......
...@@ -36,7 +36,7 @@ from ObjectResource import ObjectResource ...@@ -36,7 +36,7 @@ from ObjectResource import ObjectResource
# =========================================================================== # ===========================================================================
class Repairman(ObjectResource): class Repairman(ObjectResource):
def __init__(self, id, name, capacity=1): def __init__(self, id, name, capacity=1, **kw):
ObjectResource.__init__(self) ObjectResource.__init__(self)
self.id=id self.id=id
self.objName=name self.objName=name
......
...@@ -27,15 +27,15 @@ models the source object that generates the entities ...@@ -27,15 +27,15 @@ models the source object that generates the entities
''' '''
from SimPy.Simulation import now, Process, Resource, infinity, hold from SimPy.Simulation import now, Process, Resource, infinity, hold
from Part import Part
from RandomNumberGenerator import RandomNumberGenerator from RandomNumberGenerator import RandomNumberGenerator
from CoreObject import CoreObject from CoreObject import CoreObject
from Globals import G from Globals import G
import Globals
#============================================================================ #============================================================================
# The Source object is a Process # The Source object is a Process
#============================================================================ #============================================================================
class Source(CoreObject): class Source(CoreObject):
def __init__(self, id, name, distribution='Fixed', mean=1, item=Part): def __init__(self, id, name, distribution='Fixed', mean=1, item='Dream.Part', **kw):
CoreObject.__init__(self) CoreObject.__init__(self)
# Process.__init__(self) # Process.__init__(self)
# general properties # general properties
...@@ -53,7 +53,7 @@ class Source(CoreObject): ...@@ -53,7 +53,7 @@ class Source(CoreObject):
self.type="Source" #String that shows the type of object self.type="Source" #String that shows the type of object
self.rng=RandomNumberGenerator(self, self.distType) self.rng=RandomNumberGenerator(self, self.distType)
self.rng.avg=mean self.rng.avg=mean
self.item=item #the type of object that the Source will generate self.item=Globals.getClassFromName(item) #the type of object that the Source will generate
def initialize(self): def initialize(self):
# using the Process __init__ and not the CoreObject __init__ # using the Process __init__ and not the CoreObject __init__
......
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