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

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