Commit 318c47ac authored by Jérome Perrin's avatar Jérome Perrin

Make name and id of new elements configurable

parent 6b935735
...@@ -133,7 +133,7 @@ ...@@ -133,7 +133,7 @@
autoOpen: false, autoOpen: false,
width: 350, width: 350,
modal: true, modal: true,
title: title || "", title: node_dict[node_id]._class + " " + title || "",
buttons: { buttons: {
Cancel: function () { Cancel: function () {
$(this).dialog("close"); $(this).dialog("close");
...@@ -196,7 +196,7 @@ ...@@ -196,7 +196,7 @@
var element_type = element._class.replace('.', '-'); var element_type = element._class.replace('.', '-');
element.element_id = that.generateElementId(); element.element_id = that.generateElementId();
if (!element.id) { if (!element.id) {
element.id = that.generateNodeId(element_type); element.id = that.generateNodeId(element_type, configuration[element_type]);
} }
priv.super_newElement(element, configuration[element_type]); priv.super_newElement(element, configuration[element_type]);
$("#" + element.element_id).on('click', function () { $("#" + element.element_id).on('click', function () {
......
...@@ -37,12 +37,12 @@ ...@@ -37,12 +37,12 @@
return priv.node_container[node_id].element_id; return priv.node_container[node_id].element_id;
}; };
that.generateNodeId = function (element_type) { that.generateNodeId = function (element_type, option) {
var n = 1; var n = 1;
while ((element_type + '_' + n) in priv.node_container) { while (((option['short_id'] || element_type) + n) in priv.node_container) {
n += 1; n += 1;
} }
return element_type + '_' + n; return (option['short_id'] || element_type) + n;
}; };
that.generateElementId = function () { that.generateElementId = function () {
...@@ -427,6 +427,7 @@ ...@@ -427,6 +427,7 @@
}; };
that.newElement = function (element, option) { that.newElement = function (element, option) {
element.name = element.name || option.name;
priv.addElementToContainer(element); priv.addElementToContainer(element);
var render_element, style_string = "", var render_element, style_string = "",
coordinate = element.coordinate, coordinate = element.coordinate,
......
...@@ -13,6 +13,7 @@ class Simulation(ShiftsSimulation): ...@@ -13,6 +13,7 @@ class Simulation(ShiftsSimulation):
conf['Dream-LineClearance'] = { conf['Dream-LineClearance'] = {
"_class": "Dream.LineClearance", "_class": "Dream.LineClearance",
"name": "Clearance", "name": "Clearance",
"short_id": "C",
"property_list": conf['Dream-Queue']['property_list']} "property_list": conf['Dream-Queue']['property_list']}
batch_source_entity = copy(schema["entity"]) batch_source_entity = copy(schema["entity"])
...@@ -20,6 +21,7 @@ class Simulation(ShiftsSimulation): ...@@ -20,6 +21,7 @@ class Simulation(ShiftsSimulation):
conf['Dream-BatchSource'] = { conf['Dream-BatchSource'] = {
"_class": "Dream.BatchSource", "_class": "Dream.BatchSource",
"name": "Source", "name": "Source",
"short_id": "S",
"property_list": [schema['interarrivalTime'], "property_list": [schema['interarrivalTime'],
batch_source_entity, batch_source_entity,
schema['batchNumberOfUnits']] schema['batchNumberOfUnits']]
...@@ -33,22 +35,26 @@ class Simulation(ShiftsSimulation): ...@@ -33,22 +35,26 @@ class Simulation(ShiftsSimulation):
conf['Dream-BatchDecompositionStartTime'] = { conf['Dream-BatchDecompositionStartTime'] = {
"_class": "Dream.BatchDecompositionStartTime", "_class": "Dream.BatchDecompositionStartTime",
"name": "Decomposition", "name": "Decomposition",
"short_id": "D",
"property_list": [zeroProcessingTime, schema['numberOfSubBatches'] ] "property_list": [zeroProcessingTime, schema['numberOfSubBatches'] ]
} }
conf['Dream-BatchReassembly'] = { conf['Dream-BatchReassembly'] = {
"_class": "Dream.BatchReassembly", "_class": "Dream.BatchReassembly",
"name": "Reassembly", "name": "Reassembly",
"short_id": "R",
"property_list": [zeroProcessingTime, schema['numberOfSubBatches'] ] "property_list": [zeroProcessingTime, schema['numberOfSubBatches'] ]
} }
conf['Dream-BatchScrapMachine'] = { conf['Dream-BatchScrapMachine'] = {
"_class": "Dream.BatchScrapMachine", "_class": "Dream.BatchScrapMachine",
"name": "Station", "name": "Station",
"short_id": "St",
"property_list": conf['Dream-Machine']['property_list'] "property_list": conf['Dream-Machine']['property_list']
} }
conf['Dream-EventGenerator'] = { conf['Dream-EventGenerator'] = {
"_class": "Dream.EventGenerator", "_class": "Dream.EventGenerator",
"name": "Attainment", "name": "Attainment",
"short_id": "A",
"property_list": [schema['start'], schema['stop'], schema['duration'], "property_list": [schema['start'], schema['stop'], schema['duration'],
schema['interval'], schema['method'], schema['argumentDict']] schema['interval'], schema['method'], schema['argumentDict']]
} }
......
...@@ -246,6 +246,7 @@ class Simulation(object): ...@@ -246,6 +246,7 @@ class Simulation(object):
schema["interarrivalTime"], schema["interarrivalTime"],
schema["entity"] schema["entity"]
], ],
"short_id": "S",
"_class": 'Dream.Source' "_class": 'Dream.Source'
}, },
"Dream-Machine": { "Dream-Machine": {
...@@ -253,6 +254,7 @@ class Simulation(object): ...@@ -253,6 +254,7 @@ class Simulation(object):
schema["processingTime"], schema["processingTime"],
schema["failures"] schema["failures"]
], ],
"short_id": "M",
"_class": 'Dream.Machine' "_class": 'Dream.Machine'
}, },
"Dream-Queue": { "Dream-Queue": {
...@@ -261,12 +263,15 @@ class Simulation(object): ...@@ -261,12 +263,15 @@ class Simulation(object):
schema["isDummy"], schema["isDummy"],
schema["schedulingRule"] schema["schedulingRule"]
], ],
"short_id": "Q",
"_class": 'Dream.Queue' "_class": 'Dream.Queue'
}, },
"Dream-Exit": { "Dream-Exit": {
"short_id": "E",
"_class": 'Dream.Exit' "_class": 'Dream.Exit'
}, },
"Dream-Repairman": { "Dream-Repairman": {
"short_id": "R",
"property_list": [schema["capacity"]], "property_list": [schema["capacity"]],
"_class": 'Dream.Repairman' "_class": 'Dream.Repairman'
}, },
......
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