Commit 6cbae9f9 authored by Sebastien Robin's avatar Sebastien Robin

gui prototype: use default values for every property

This increase a lot the probability of building a working flow.
parent 300f97d7
......@@ -173,14 +173,32 @@
enumerable: false,
writable: false,
value: function (element) {
var element_id = element.id.split('_')[0]
priv.plumb.newElement(element, configuration[element_id]);
var element_prefix = element.id.split('_')[0]
priv.plumb.newElement(element, configuration[element_prefix]);
$("#" + element.id).bind('click', function() {
console.log("bind click on window", $(this));
$( "#dialog-form" ).dialog( "destroy" ) ;
priv.prepareDialogForElement(element.id, element.id);
$( "#dialog-form" ).dialog( "open" );
});
// Store default values
var data = {}, property_list = configuration[element_prefix]["property_list"] || [];
var updateDefaultData = function(data, property_list) {
_.each(property_list, function(element, key) {
console.log("going to parse property_list, element", element);
if(element._class === "Dream.Property") {
data[element.id] = element.default;
} else if (element._class === "Dream.PropertyList") {
data[element.id] = {};
var next_data = data[element.id];
var next_property_list = element.property_list || [];
updateDefaultData(next_data, next_property_list);
}
});
}
updateDefaultData(data, property_list);
priv.plumb.updateElementData(element.id, {data: data});
}
});
......@@ -193,6 +211,13 @@
priv.plumb.start();
priv.displayTool();
priv.initDialog();
// save general configuration default values
var general_properties = {};
_.each(configuration["Dream-Configuration"].property_list, function(element, key) {
console.log("dream.start, parsing general property", element.id);
general_properties[element.id] = element.default;
});
priv.plumb.setGeneralProperties(general_properties);
priv.initGeneralProperties();
}
});
......
......@@ -7,22 +7,22 @@
var window_id = 1;
var element_id;
var id_container = {}; // to allow generating next ids, like Machine_1, Machine_2, etc
var property_container = {entity: {id: "entity", type:"string", _class: "Dream.Property"},
var property_container = {entity: {id: "entity", type:"string", _class: "Dream.Property", default: "Part"},
// XXX is it possible not to repeat id ?
mean: {id: "mean", type: "string", _class: "Dream.Property"},
distributionType: {id: "distributionType", type: "string", _class: "Dream.Property"},
stdev: {id: "stdev", type: "string", _class: "Dream.Property"},
min: {id: "min", type: "string", _class: "Dream.Property"},
max: {id: "max", type: "string", _class: "Dream.Property"},
failureDistribution: {id: "failureDistribution", type: "string", _class: "Dream.Property"},
MTTF: {id: "MTTF", type: "string", _class: "Dream.Property"},
MTTR: {id: "MTTR", type: "string", _class: "Dream.Property"},
mean: {id: "mean", type: "string", _class: "Dream.Property", default: "0.9"},
distributionType: {id: "distributionType", type: "string", _class: "Dream.Property", default: "Exp"},
stdev: {id: "stdev", type: "string", _class: "Dream.Property", default: "0.1"},
min: {id: "min", type: "string", _class: "Dream.Property", default: "0.1"},
max: {id: "max", type: "string", _class: "Dream.Property", default: "1"},
failureDistribution: {id: "failureDistribution", type: "string", _class: "Dream.Property", default:"Fixed"},
MTTF: {id: "MTTF", type: "string", _class: "Dream.Property", default: "40"},
MTTR: {id: "MTTR", type: "string", _class: "Dream.Property", default: "10"},
repairman: {id: "repairman", type: "string", _class: "Dream.Property"},
isDummy: {id: "isDummy", type: "string", _class: "Dream.Property"},
capacity: {id: "capacity", type: "string", _class: "Dream.Property"},
numberOfReplications: {id: "numberOfReplications", type: "string", _class: "Dream.Property"},
maxSimTime: {id: "maxSimTime", type: "string", _class: "Dream.Property"},
confidenceLevel: {id: "confidenceLevel", type: "string", _class: "Dream.Property"},
isDummy: {id: "isDummy", type: "string", _class: "Dream.Property", default: "0"},
capacity: {id: "capacity", type: "string", _class: "Dream.Property", default: "1"},
numberOfReplications: {id: "numberOfReplications", type: "string", _class: "Dream.Property", default: "10"},
maxSimTime: {id: "maxSimTime", type: "string", _class: "Dream.Property", default: "100"},
confidenceLevel: {id: "confidenceLevel", type: "string", _class: "Dream.Property", default: "0.5"},
};
property_container["interarrivalTime"] = {id:"interarrivalTime",
property_list: [property_container["mean"], property_container["distributionType"]],
......
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