Commit 185e642f authored by Jérome Perrin's avatar Jérome Perrin

commit static version

parent 8addc690
...@@ -20,12 +20,12 @@ ...@@ -20,12 +20,12 @@
</head> </head>
<body> <body>
<form class="run_form"> <form class="run_form">
<button type="submit" class="ui-btn ui-btn-b ui-btn-inline
ui-icon-refresh ui-btn-icon-right">Run Simulation</button>
<fieldset> <fieldset>
<div data-gadget-url="../fieldset/index.html" <div data-gadget-url="../fieldset/index.html"
data-gadget-scope="fieldset"></div> data-gadget-scope="fieldset"></div>
</fieldset> </fieldset>
<button type="submit" class="ui-btn ui-btn-b ui-btn-inline
ui-icon-refresh ui-btn-icon-right">Run Simulation</button>
</form> </form>
</body> </body>
</html> </html>
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
/*jslint unparam: true */ /*jslint unparam: true */
(function(window, rJS, $, initGadgetMixin) { (function(window, rJS, $, initGadgetMixin) {
"use strict"; "use strict";
function capacity_utilisation_graph_widget(all_data) { function capacity_utilisation_graph_widget(data, result_id) {
var available_capacity_by_station = {}, station_id, series, graph_list = [], options, capacity_usage_by_station = {}, input_data = all_data.input, output_data = all_data.result; var available_capacity_by_station = {}, station_id, series, graph_list = [], options, capacity_usage_by_station = {}, input_data = data, output_data = data.result.result_list[result_id];
// Compute availability by station // Compute availability by station
$.each(input_data.nodes, function(idx, obj) { $.each(input_data.graph.node, function(idx, obj) {
var available_capacity = []; var available_capacity = [];
if (obj.intervalCapacity !== undefined) { if (obj.intervalCapacity !== undefined) {
$.each(obj.intervalCapacity, function(i, capacity) { $.each(obj.intervalCapacity, function(i, capacity) {
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
} }
} }
}; };
graph_list.push([ input_data.nodes[station_id].name || station_id, series, options ]); graph_list.push([ input_data.graph.node[station_id].name || station_id, series, options ]);
} }
} }
return graph_list; return graph_list;
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
_id: gadget.props.jio_key, _id: gadget.props.jio_key,
_attachment: "simulation.json" _attachment: "simulation.json"
}).push(function(simulation_json) { }).push(function(simulation_json) {
gadget.props.result_list = capacity_utilisation_graph_widget(JSON.parse(simulation_json)[gadget.props.result]); gadget.props.result_list = capacity_utilisation_graph_widget(JSON.parse(simulation_json), gadget.props.result);
}); });
}).declareMethod("startService", function() { }).declareMethod("startService", function() {
var element = $(this.props.element), graph; var element = $(this.props.element), graph;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
gantt.templates.task_class = function(start, end, obj) { gantt.templates.task_class = function(start, end, obj) {
return obj.parent ? "sub_task" : ""; return obj.parent ? "sub_task" : "";
}; };
function job_gantt_widget(all_data) { function job_gantt_widget(data, result_id) {
// XXX: use dhx_gantt zoom level feature ( // XXX: use dhx_gantt zoom level feature (
// http://dhtmlx.com/docs/products/dhtmlxGantt/02_features.html ) // http://dhtmlx.com/docs/products/dhtmlxGantt/02_features.html )
var now = new Date(), start_date, gantt_data = { var now = new Date(), start_date, gantt_data = {
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
open: true open: true
} ], } ],
link: [] link: []
}, input_data = all_data.input, output_data = all_data.result; }, input_data = data, output_data = data.result.result_list[result_id];
// temporary hack // temporary hack
now.setHours(0); now.setHours(0);
now.setMinutes(0); now.setMinutes(0);
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
function isVisibleStation(station) { function isVisibleStation(station) {
// we should be able to define in the backend which // we should be able to define in the backend which
// station is visible // station is visible
return input_data.nodes[station].family !== "Buffer" && input_data.nodes[station].family !== "Exit"; return input_data.graph.node[station].family !== "Buffer" && input_data.graph.node[station].family !== "Exit";
} }
$.each(output_data.elementList.sort(function(a, b) { $.each(output_data.elementList.sort(function(a, b) {
return a.id < b.id ? -1 : 1; return a.id < b.id ? -1 : 1;
...@@ -49,9 +49,9 @@ ...@@ -49,9 +49,9 @@
if (obj.family === "Job") { if (obj.family === "Job") {
// find the corresponding input // find the corresponding input
// find the input order and order component for this job // find the input order and order component for this job
for (node_key in input_data.nodes) { for (node_key in input_data.graph.node) {
if (input_data.nodes.hasOwnProperty(node_key)) { if (input_data.graph.node.hasOwnProperty(node_key)) {
node = input_data.nodes[node_key]; node = input_data.graph.node[node_key];
if (node.wip) { if (node.wip) {
for (i = 0; i < node.wip.length; i += 1) { for (i = 0; i < node.wip.length; i += 1) {
order = node.wip[i]; order = node.wip[i];
...@@ -173,7 +173,7 @@ ...@@ -173,7 +173,7 @@
_id: gadget.props.jio_key, _id: gadget.props.jio_key,
_attachment: "simulation.json" _attachment: "simulation.json"
}).push(function(simulation_json) { }).push(function(simulation_json) {
gadget.props.result = job_gantt_widget(JSON.parse(simulation_json)[gadget.props.result]); gadget.props.result = job_gantt_widget(JSON.parse(simulation_json), gadget.props.result);
}); });
}).declareMethod("startService", function() { }).declareMethod("startService", function() {
$(this.props.element).find(".gant_container").dhx_gantt({ $(this.props.element).find(".gant_container").dhx_gantt({
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
/*jslint nomen: true */ /*jslint nomen: true */
(function(window, rJS, RSVP, moment, initGadgetMixin) { (function(window, rJS, RSVP, moment, initGadgetMixin) {
"use strict"; "use strict";
function job_schedule_spreadsheet_widget(all_data) { function job_schedule_spreadsheet_widget(data, result_id) {
var now = new Date(), name, input_data = all_data.input, output_data = all_data.result, spreadsheet_data = [], spreadsheet_header = [ [ "Jobs", "ID", "Project Manager", "Due Date", "Priority", "Entrance Time", "Processing Time", "Station ID", "Step No." ] ], simulation_start_date = new Date(input_data.general.currentDate || now.getTime()), i, j, k, obj, node, component, order, node_id, due_date, entrance_date, duration, schedule, input_job = null, input_order = null; var now = new Date(), name, input_data = data, output_data = data.result.result_list[result_id], spreadsheet_data = [], spreadsheet_header = [ [ "Jobs", "ID", "Project Manager", "Due Date", "Priority", "Entrance Time", "Processing Time", "Station ID", "Step No." ] ], simulation_start_date = new Date(input_data.general.currentDate || now.getTime()), i, j, k, obj, node, component, order, node_id, due_date, entrance_date, duration, schedule, input_job = null, input_order = null;
// XXX why ? // XXX why ?
now.setHours(0); now.setHours(0);
now.setMinutes(0); now.setMinutes(0);
...@@ -18,9 +18,9 @@ ...@@ -18,9 +18,9 @@
input_order = null; input_order = null;
// find the input order and order component for this job // find the input order and order component for this job
// XXX this has no real meaning with capacity project // XXX this has no real meaning with capacity project
for (node_id in input_data.nodes) { for (node_id in input_data.graph.node) {
if (input_data.nodes.hasOwnProperty(node_id)) { if (input_data.graph.node.hasOwnProperty(node_id)) {
node = input_data.nodes[node_id]; node = input_data.graph.node[node_id];
if (node.wip) { if (node.wip) {
for (j = 0; j < node.wip.length; j += 1) { for (j = 0; j < node.wip.length; j += 1) {
order = node.wip[j]; order = node.wip[j];
...@@ -120,7 +120,7 @@ ...@@ -120,7 +120,7 @@
_attachment: "simulation.json" _attachment: "simulation.json"
}), gadget.getDeclaredGadget("tableeditor") ]); }), gadget.getDeclaredGadget("tableeditor") ]);
}).push(function(result_list) { }).push(function(result_list) {
return result_list[1].render(JSON.stringify(job_schedule_spreadsheet_widget(JSON.parse(result_list[0])[gadget.props.result]))); return result_list[1].render(JSON.stringify(job_schedule_spreadsheet_widget(JSON.parse(result_list[0]), gadget.props.result)));
}); });
}).declareMethod("startService", function() { }).declareMethod("startService", function() {
return this.getDeclaredGadget("tableeditor").push(function(tableeditor) { return this.getDeclaredGadget("tableeditor").push(function(tableeditor) {
......
...@@ -2,65 +2,81 @@ ...@@ -2,65 +2,81 @@
/*jslint unparam: true */ /*jslint unparam: true */
(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; var blockage_data = [], waiting_data = [], failure_data = [], working_data = [], ticks = [], counter = 1, series, options;
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, 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 ??? // XXX output is still elementList ???
$.each(output_data.elementList.sort(function(a, b) { $.each(output_data.elementList.sort(function(a, b) {
return a.id < b.id ? -1 : 1; return a.id < b.id ? -1 : 1;
}), function(idx, obj) { }), function(idx, obj) {
var ctrl_flag = false, reqKey, request, i; // add each object that has a working ratio
// determine weather the current if (obj.results !== undefined && 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, working_ratio = 0, waiting_ratio = 0, failure_ratio = 0;
if (obj.results !== undefined && obj.results[config[reqKey][0]] !== undefined) { if (obj.results.blockage_ratio !== undefined) {
// control flag, if the results contain if (obj.results.blockage_ratio.avg !== undefined) {
// entities that have working ratios blockage_ratio = obj.results.blockage_ratio.avg;
ctrl_flag = true; } else {
break; 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) { if (obj.results.setup_ratio !== undefined) {
for (reqKey in config) { if (obj.results.setup_ratio.avg !== undefined) {
if (config.hasOwnProperty(reqKey)) { working_ratio += obj.results.setup_ratio.avg;
request = 0; } else {
for (i = 0; i <= config[reqKey].length - 1; i += 1) { working_ratio += obj.results.setup_ratio;
request += getRequestedValue(obj, config[reqKey][i]);
}
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;
} }
}); });
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: {
minTickSize: 1, minTickSize: 1,
...@@ -72,7 +88,7 @@ ...@@ -72,7 +88,7 @@
series: { series: {
bars: { bars: {
show: true, show: true,
barWidth: .7, barWidth: .8,
align: "center" align: "center"
}, },
stack: true stack: true
...@@ -90,8 +106,7 @@ ...@@ -90,8 +106,7 @@
_id: gadget.props.jio_key, _id: gadget.props.jio_key,
_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(JSON.parse(simulation_json).result.result_list[gadget.props.result]);
gadget.props.result_list = station_utilisation_graph_widget(json_data.result.result_list[gadget.props.result], config);
}); });
}).declareMethod("startService", function() { }).declareMethod("startService", function() {
// XXX Manually calculate width and height when resizing // XXX Manually calculate width and height when resizing
......
...@@ -193,7 +193,6 @@ ...@@ -193,7 +193,6 @@
}); });
}).push(function(sim_json) { }).push(function(sim_json) {
var document_list = JSON.parse(sim_json).result.result_list; var document_list = JSON.parse(sim_json).result.result_list;
console.log(JSON.parse(sim_json).result);
return document_list[options.result].score + " " + document_list[options.result].key; return document_list[options.result].score + " " + document_list[options.result].key;
}); });
} else { } else {
......
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