Commit 051f1afa authored by Jérome Perrin's avatar Jérome Perrin

make GUI use floats for number properties

parent 60c58500
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
function (idx, property) { function (idx, property) {
if (property._class === "Dream.Property") { if (property._class === "Dream.Property") {
previous_value = previous_data[property.id] || ""; previous_value = previous_data[property.id] || "";
if (previous_value.length > 0) { if (previous_value.length > 0 || typeof previous_value == "number") {
previous_value = ' value="' + previous_value + '"'; previous_value = ' value="' + previous_value + '"';
} }
fieldset.append("<label>" + property.id + "</label>" + fieldset.append("<label>" + property.id + "</label>" +
...@@ -162,6 +162,9 @@ ...@@ -162,6 +162,9 @@
prefixed_property_id = prefix + property.id; prefixed_property_id = prefix + property.id;
property_element = $("#" + prefixed_property_id); property_element = $("#" + prefixed_property_id);
data[property.id] = property_element.val(); data[property.id] = property_element.val();
if (property.type === "number") {
data[property.id] = parseFloat(data[property.id])
}
} else if (property._class === "Dream.PropertyList") { } else if (property._class === "Dream.PropertyList") {
var next_prefix = prefix + property.id + "-"; var next_prefix = prefix + property.id + "-";
data[property.id] = {}; data[property.id] = {};
...@@ -248,6 +251,9 @@ ...@@ -248,6 +251,9 @@
if (property._class === "Dream.Property") { if (property._class === "Dream.Property") {
prefixed_property_id = prefix + property.id; prefixed_property_id = prefix + property.id;
properties[property.id] = $("#" + prefixed_property_id).val(); properties[property.id] = $("#" + prefixed_property_id).val();
if (property.type === "number") {
properties[property.id] = parseFloat(properties[property.id])
}
} }
}); });
that.setGeneralProperties(properties); that.setGeneralProperties(properties);
......
...@@ -47,14 +47,14 @@ class Simulation(ShiftsSimulation): ...@@ -47,14 +47,14 @@ class Simulation(ShiftsSimulation):
# some more global properties # some more global properties
conf["Dream-Configuration"]["property_list"].append( { conf["Dream-Configuration"]["property_list"].append( {
"id": "throughputTarget", "id": "throughputTarget",
"type": "string", "type": "number",
"_class": "Dream.Property", "_class": "Dream.Property",
"_default": "10" }) "_default": 10 })
conf["Dream-Configuration"]["property_list"].append( { conf["Dream-Configuration"]["property_list"].append( {
"id": "desiredPercentageOfSuccess", "id": "desiredPercentageOfSuccess",
"type": "string", "type": "number",
"_class": "Dream.Property", "_class": "Dream.Property",
"_default": "0.85" }) "_default": 0.85 })
# remove tools that does not make sense here # remove tools that does not make sense here
conf.pop('Dream-Machine') conf.pop('Dream-Machine')
......
...@@ -11,9 +11,9 @@ schema = { ...@@ -11,9 +11,9 @@ schema = {
}, },
"mean": { "mean": {
"id": "mean", "id": "mean",
"type": "string", "type": "number",
"_class": "Dream.Property", "_class": "Dream.Property",
"_default": "0.9" "_default": 0.9
}, },
"distributionType": { "distributionType": {
"id": "distributionType", "id": "distributionType",
...@@ -23,21 +23,21 @@ schema = { ...@@ -23,21 +23,21 @@ schema = {
}, },
"stdev": { "stdev": {
"id": "stdev", "id": "stdev",
"type": "string", "type": "number",
"_class": "Dream.Property", "_class": "Dream.Property",
"_default": "0.1" "_default": 0.1
}, },
"min": { "min": {
"id": "min", "id": "min",
"type": "string", "type": "number",
"_class": "Dream.Property", "_class": "Dream.Property",
"_default": "0.1" "_default": 0.1
}, },
"max": { "max": {
"id": "max", "id": "max",
"type": "string", "type": "number",
"_class": "Dream.Property", "_class": "Dream.Property",
"_default": "1" "_default": 1
}, },
"failureDistribution": { "failureDistribution": {
"id": "failureDistribution", "id": "failureDistribution",
...@@ -47,15 +47,15 @@ schema = { ...@@ -47,15 +47,15 @@ schema = {
}, },
"MTTF": { "MTTF": {
"id": "MTTF", "id": "MTTF",
"type": "string", "type": "number",
"_class": "Dream.Property", "_class": "Dream.Property",
"_default": "40" "_default": 40
}, },
"MTTR": { "MTTR": {
"id": "MTTR", "id": "MTTR",
"type": "string", "type": "number",
"_class": "Dream.Property", "_class": "Dream.Property",
"_default": "10" "_default": 10
}, },
"repairman": { "repairman": {
"id": "repairman", "id": "repairman",
...@@ -77,45 +77,45 @@ schema = { ...@@ -77,45 +77,45 @@ schema = {
}, },
"capacity": { "capacity": {
"id": "capacity", "id": "capacity",
"type": "string", "type": "number",
"_class": "Dream.Property", "_class": "Dream.Property",
"_default": "1" "_default": 1
}, },
"numberOfReplications": { "numberOfReplications": {
"id": "numberOfReplications", "id": "numberOfReplications",
"type": "string", "type": "number",
"_class": "Dream.Property", "_class": "Dream.Property",
"_default": "10" "_default": 10
}, },
"maxSimTime": { "maxSimTime": {
"id": "maxSimTime", "id": "maxSimTime",
"type": "string", "type": "number",
"_class": "Dream.Property", "_class": "Dream.Property",
"_default": "100" "_default": 100
}, },
"confidenceLevel": { "confidenceLevel": {
"id": "confidenceLevel", "id": "confidenceLevel",
"type": "string", "type": "number",
"_class": "Dream.Property", "_class": "Dream.Property",
"_default": "0.5" "_default": 0.5
}, },
"processTimeout": { "processTimeout": {
"id": "processTimeout", "id": "processTimeout",
"type": "string", "type": "number",
"_class": "Dream.Property", "_class": "Dream.Property",
"_default": "10" "_default": 10
}, },
"batchNumberOfUnits": { "batchNumberOfUnits": {
"id": "batchNumberOfUnits", "id": "batchNumberOfUnits",
"type": "integer", "type": "number",
"_class": "Dream.Property", "_class": "Dream.Property",
"_default": "10" "_default": 10
}, },
"numberOfSubBatches": { "numberOfSubBatches": {
"id": "numberOfSubBatches", "id": "numberOfSubBatches",
"type": "integer", "type": "number",
"_class": "Dream.Property", "_class": "Dream.Property",
"_default": "10" "_default": 10
}, },
"method": { "method": {
"id": "method", "id": "method",
...@@ -125,27 +125,27 @@ schema = { ...@@ -125,27 +125,27 @@ schema = {
}, },
"start": { "start": {
"id": "start", "id": "start",
"type": "string", "type": "number",
"_class": "Dream.Property", "_class": "Dream.Property",
"_default": "1" "_default": 1
}, },
"stop": { "stop": {
"id": "stop", "id": "stop",
"type": "string", "type": "number",
"_class": "Dream.Property", "_class": "Dream.Property",
"_default": "-1" "_default": -1
}, },
"interval": { "interval": {
"id": "interval", "id": "interval",
"type": "string", "type": "number",
"_class": "Dream.Property", "_class": "Dream.Property",
"_default": "10" "_default": 10
}, },
"duration": { "duration": {
"id": "duration", "id": "duration",
"type": "string", "type": "number",
"_class": "Dream.Property", "_class": "Dream.Property",
"_default": "10" "_default": 10
}, },
"argumentDict": { "argumentDict": {
"id": "argumentDict", "id": "argumentDict",
...@@ -155,7 +155,7 @@ schema = { ...@@ -155,7 +155,7 @@ schema = {
}, },
"currentDate": { "currentDate": {
"id": "currentDate", "id": "currentDate",
"type": "string", # XXX format ? "type": "string", # date in YYYY/MM/DD format
"_class": "Dream.Property", "_class": "Dream.Property",
"_default": "" "_default": ""
}, },
......
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