Commit 51ec5791 authored by Jérome Perrin's avatar Jérome Perrin

let errors propagate when something is wrong in input

parent e01aea1b
...@@ -181,8 +181,8 @@ def createObjects(): ...@@ -181,8 +181,8 @@ def createObjects():
# 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
if resourceClass=='Dream.Repairman': # check the object type if resourceClass=='Dream.Repairman': # check the object type
id = element.get('id', 'not found') # get the id of the element / default 'not_found' id = element.get('id', 'not found') # get the id of the element
name = element.get('name', 'not found') # get the name of the element / default 'not_found' name = element.get('name', id) # get the name of the element / default 'not_found'
capacity = int(element.get('capacity', '1')) # get the capacity of the el. / defautl '1' capacity = int(element.get('capacity', '1')) # get the capacity of the el. / defautl '1'
R = Repairman(element_id, name, capacity) # create a repairman object R = Repairman(element_id, name, capacity) # create a repairman object
R.coreObjectIds=getSuccessorList(id) # update the list of objects that the repairman repairs R.coreObjectIds=getSuccessorList(id) # update the list of objects that the repairman repairs
...@@ -226,7 +226,7 @@ def createObjects(): ...@@ -226,7 +226,7 @@ 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', '0')) mean=float(interarrivalTime.get('mean', '0'))
entity=str_to_class(element.get('entity', 'not found')) # initialize entity entity=str_to_class(element['entity']) # initialize 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)
...@@ -238,7 +238,7 @@ def createObjects(): ...@@ -238,7 +238,7 @@ 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', '0')) mean=float(interarrivalTime.get('mean', '0'))
entity=str_to_class(element.get('entity', 'not found')) entity=str_to_class(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)
...@@ -506,8 +506,8 @@ def createObjects(): ...@@ -506,8 +506,8 @@ def createObjects():
elif objClass=='Dream.BatchDecomposition': elif objClass=='Dream.BatchDecomposition':
id=element.get('id', 'not found') id=element.get('id', 'not found')
name=element.get('name', 'not found') name=element.get('name', 'not found')
processingTime=element.get('processingTime', {}) processingTime=element['processingTime']
distributionType=processingTime.get('distributionType', 'not found') distributionType=processingTime['distributionType']
mean=float(processingTime.get('mean', '0')) mean=float(processingTime.get('mean', '0'))
stdev=float(processingTime.get('stdev', '0')) stdev=float(processingTime.get('stdev', '0'))
min=float(processingTime.get('min', '0')) min=float(processingTime.get('min', '0'))
......
...@@ -54,7 +54,8 @@ class RandomNumberGenerator(object): ...@@ -54,7 +54,8 @@ class RandomNumberGenerator(object):
elif self.distType=="Erlang": #if the distribution is erlang elif self.distType=="Erlang": #if the distribution is erlang
number=G.Rnd.gammavariate(self.alpha,self.beta) number=G.Rnd.gammavariate(self.alpha,self.beta)
else: else:
print "unknown distribution error in "+str(self.object.type)+str(self.object.id) raise ValueError("Unknown distribution %r used in %s %s" %
return number (self.distType, self.object.type, self.object.id))
return number
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