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

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