Commit 6b9c8057 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

make simulation class configurable.

parent 9ab0d85d
......@@ -27,8 +27,6 @@ import logging
from flask import Flask, jsonify, redirect, url_for
from flask import request
from dream.simulation.LineGenerationJSON import main as simulate_line_json
app = Flask(__name__)
# Serve static file with no cache
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
......@@ -111,7 +109,10 @@ def runSimulation():
def _runSimulation(parameter_dict, queue):
try:
result = simulate_line_json(input_data=json.dumps(parameter_dict))
klass_name = 'dream.simulation.%s' % \
parameter_dict['general']['simulationClass']
klass = __import__(klass_name, globals(), {}, klass_name)
result = klass.Simulation().run(parameter_dict)
queue.put(dict(success=json.loads(result)))
except Exception, e:
tb = traceback.format_exc()
......
......@@ -101,6 +101,12 @@
_class: "Dream.Property",
_default: "1"
},
simulationClass: {
id: "simulationClass",
type: "string",
_class: "Dream.Property",
_default: "Default"
},
numberOfReplications: {
id: "numberOfReplications",
type: "string",
......@@ -224,7 +230,9 @@
_class: 'Dream.Repairman'
},
"Dream-Configuration": {
property_list: [property_container["numberOfReplications"],
property_list: [
property_container["simulationClass"],
property_container["numberOfReplications"],
property_container["maxSimTime"],
property_container["confidenceLevel"],
property_container["processTimeout"]
......
import json
from dream.simulation.LineGenerationJSON import main as simulate_line_json
class Simulation:
def run(self, data):
return simulate_line_json(input_data=json.dumps(data))
from dream.simulation.Default import DefaultSimulation
class Simulation(DefaultSimulation):
pass
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