Commit aae8899b authored by Jérome Perrin's avatar Jérome Perrin

Revert "stationUtilisationGraph turned more generic. Options provided within...

Revert "stationUtilisationGraph turned more generic. Options provided within the all-inclusive-file"

This reverts commit a16d7ae4.
We do not need this for now
parent 3105369c
...@@ -3,31 +3,16 @@ ...@@ -3,31 +3,16 @@
(function (window, rJS, $, initGadgetMixin) { (function (window, rJS, $, initGadgetMixin) {
"use strict"; "use strict";
function getRequestedValue (object, key) { function station_utilisation_graph_widget(output_data) {
var value = 0.0; var blockage_data = [],
if (object.results[key] !== undefined) { waiting_data = [],
if (object.results[key].avg !== undefined) { failure_data = [],
value = object.results[key].avg; working_data = [],
} else {
value = object.results[key];
}
}
return value;
}
function station_utilisation_graph_widget(output_data, config) {
var data = {},
ticks = [], ticks = [],
counter = 1, counter = 1,
key, series,
series = [],
options; options;
// initialize the data dict holding the properties requested
for (key in config) {
if (config.hasOwnProperty(key)) {
data[key] = [];
}
}
// XXX output is still elementList ??? // XXX output is still elementList ???
$.each( $.each(
output_data.elementList.sort( output_data.elementList.sort(
...@@ -36,32 +21,67 @@ ...@@ -36,32 +21,67 @@
} }
), ),
function (idx, obj) { function (idx, obj) {
var ctrl_flag = false, reqKey, // add each object that has a working ratio
request, i; if ((obj.results !== undefined) &&
// determine weather the current (obj.results.working_ratio !== undefined)) {
// obj has the requested key /* when there is only one replication, the ratio is given as a float,
for (reqKey in config) { otherwise we have a mapping avg, ub lb */
if (config.hasOwnProperty(reqKey)) { var blockage_ratio = 0.0,
if ((obj.results !== undefined) && working_ratio = 0.0,
(obj.results[config[reqKey][0]] !== undefined)) { waiting_ratio = 0.0,
// control flag, if the results contain failure_ratio = 0.0;
// entities that have working ratios
ctrl_flag = true; if (obj.results.blockage_ratio !== undefined) {
break; if (obj.results.blockage_ratio.avg !== undefined) {
blockage_ratio = obj.results.blockage_ratio.avg;
} else {
blockage_ratio = obj.results.blockage_ratio;
} }
} }
} blockage_data.push([counter, blockage_ratio]);
// if the obj contains the requested key
if (ctrl_flag === true) { // XXX merge setup & loading ratio in working ratio for now
for (reqKey in config) {
if (config.hasOwnProperty(reqKey)) { if (obj.results.setup_ratio !== undefined) {
request = 0.0; if (obj.results.setup_ratio.avg !== undefined) {
for (i = 0; i <= config[reqKey].length-1; i += 1) { working_ratio += obj.results.setup_ratio.avg;
request += getRequestedValue(obj, config[reqKey][i]); } else {
} working_ratio += obj.results.setup_ratio;
data[reqKey].push([counter, request]); }
}
if (obj.results.loading_ratio !== undefined) {
if (obj.results.loading_ratio.avg !== undefined) {
working_ratio += obj.results.loading_ratio.avg;
} else {
working_ratio += obj.results.loading_ratio;
} }
} }
if (obj.results.working_ratio !== undefined) {
if (obj.results.working_ratio.avg !== undefined) {
working_ratio += obj.results.working_ratio.avg;
} else {
working_ratio += obj.results.working_ratio;
}
}
working_data.push([counter, working_ratio]);
if (obj.results.waiting_ratio !== undefined) {
if (obj.results.waiting_ratio.avg !== undefined) {
waiting_ratio = obj.results.waiting_ratio.avg;
} else {
waiting_ratio = obj.results.waiting_ratio;
}
}
waiting_data.push([counter, waiting_ratio]);
if (obj.results.failure_ratio !== undefined) {
if (obj.results.failure_ratio.avg !== undefined) {
failure_ratio = obj.results.failure_ratio.avg;
} else {
failure_ratio = obj.results.failure_ratio;
}
}
failure_data.push([counter, failure_ratio]);
ticks.push([counter, obj.id]); ticks.push([counter, obj.id]);
counter += 1; counter += 1;
...@@ -69,14 +89,19 @@ ...@@ -69,14 +89,19 @@
} }
); );
for (key in data) { series = [{
if (data.hasOwnProperty(key)) { label: "Working",
series.push({ data: working_data
label: key, }, {
data: data[key] label: "Waiting",
}); data: waiting_data
} }, {
} label: "Failures",
data: failure_data
}, {
label: "Blockage",
data: blockage_data
}];
options = { options = {
xaxis: { xaxis: {
...@@ -89,7 +114,7 @@ ...@@ -89,7 +114,7 @@
series: { series: {
bars: { bars: {
show: true, show: true,
barWidth: 0.7, barWidth: 0.8,
align: "center" align: "center"
}, },
stack: true stack: true
...@@ -120,13 +145,9 @@ ...@@ -120,13 +145,9 @@
"_attachment": "simulation.json" "_attachment": "simulation.json"
}) })
.push(function (simulation_json) { .push(function (simulation_json) {
var json_data = JSON.parse(simulation_json),
config = json_data
.application_configuration.output[options.action]
.configuration.data;
gadget.props.result_list = station_utilisation_graph_widget( gadget.props.result_list = station_utilisation_graph_widget(
json_data.result.result_list[gadget.props.result], JSON.parse(simulation_json)
config .result.result_list[gadget.props.result]
); );
}); });
}) })
......
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