Commit 8c64377d authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

Merge branch 'master' into jerome_jqs_for_wip

Conflicts:
	dream/platform/static/index.html
	dream/platform/static/src/dream_launcher.js
parents 5cc2cfc6 f3d4ab48
......@@ -242,20 +242,20 @@ path, ._jsPlumb_endpoint { cursor:pointer; }
background-color:#ffe;
}
.Dream-Machine {
.Dream-Machine, .Dream-MachineJobShop {
background-color:#fef;
}
.Dream-Queue {
.Dream-Queue, .Dream-QueueJobShop {
background-color:#eff;
}
.Dream-Exit {
background-color:#fee;
.Dream-Exit, .Dream-ExitJobShop {
background-color:#eef;
}
.Dream-Repairman {
background-color:#eef;
background-color:#fdd;
}
.window {
......@@ -269,3 +269,7 @@ path, ._jsPlumb_endpoint { cursor:pointer; }
padding-top:0.9em;
font-size:0.9em;
}
#debug textarea {
width:100%;
}
......@@ -12,106 +12,102 @@
</head>
<body data-demo-id="flowchartConnectorsDemo" data-library="jquery">
<div class="container">
<div id="headerWrapper">
<div id="header"></div>
</div>
<div class="four columns">
<div id="tools">
<h4>Tools</h4>
<div id="tools-container"></div>
<a id="clear_all">Clear All</a>
<a id="layout_graph">Layout Graph</a>
<a id="zoom_in">Zoom +</a>
<a id="zoom_out">Zoom -</a>
</div>
</div>
<div class="twelve columns">
<div id="main">
<div id="render"></div>
</div>
</div>
<div class="container">
<div id="headerWrapper">
<div id="header"></div>
</div>
</div>
<div class="container">
<div class="four columns">
<div id="tools">
<h4>Tools</h4>
<div id="tools-container"></div>
<a id="clear_all">Clear All</a>
<a id="layout_graph">Layout Graph</a>
<a id="zoom_in">Zoom +</a>
<a id="zoom_out">Zoom -</a>
</div>
</div>
<div class="four columns">
<div id="simulation_controls">
<h4>Simulation Parameters</h4>
<div title="Configure">
<form>
<fieldset id="general-fieldset">
</fieldset>
<a id="run_simulation">Run Simulation</a>
</form>
<div class="twelve columns">
<div id="main">
<div id="render"></div>
</div>
</div>
</div>
</div>
<div class="twelve columns">
<div id="graph_zone">
<div>Stations Utilization</div>
<div id="graph"></div>
</div>
<div class="container">
<div id="debug">
<div class="five columns">
<div>Input</div>
<textarea rows="20" cols="47" id="json_output" style="align:left; width:100%">
</textarea>
<div class="four columns">
<div id="simulation_controls">
<h4>Simulation Parameters</h4>
<div title="Configure">
<form>
<fieldset id="general-fieldset">
</fieldset>
<a id="run_simulation">Run Simulation</a>
</form>
</div>
</div>
</div>
<div class="five columns">
<div>Result</div>
<textarea rows="20" cols="47" id="json_result" style="align:left; width:100%">
</textarea>
<td></td>
<div class="twelve columns">
<div id="graph_zone">
<div>Stations Utilization</div>
<div id="graph"></div>
</div>
<div id="debug">
<div class="six columns alpha">
<div>Input</div>
<textarea rows="20" cols="47" id="json_output"></textarea>
<a id="load_json">Load JSON</a>
</div>
<div class="six columns alpha">
<div>Result</div>
<textarea rows="20" cols="47" id="json_result"></textarea>
</div>
</div>
</div>
</div>
</div>
<div class="twelve columns">
<div id="wip">
<h4>WIP</h4>
<div class="jQuerySheet"></div>
</div>
</div>
<div class="twelve columns">
<div id="wip">
<h4>WIP</h4>
<div class="jQuerySheet"></div>
</div>
</div>
<!-- DEP -->
<script type="text/javascript" src="lib/jquery-1.8.1-min.js"></script>
<script type="text/javascript" src="lib/jquery-ui-1.8.23-min.js"></script>
<script type="text/javascript" src="lib/jquery.ui.touch-punch.min.js"></script>
<script type="text/javascript" src="lib/md5.js"></script>
<script type="text/javascript" src="lib/jio.js"></script>
<script type="text/javascript" src="lib/jio.localstorage.js"></script>
<script type="text/javascript" src="lib/pubsub.js"></script>
<script type="text/javascript" src="lib/jquery.jsPlumb-1.5.4-min.js"></script>
<!-- /DEP -->
<!-- DEP -->
<script type="text/javascript" src="lib/jquery-1.8.1-min.js"></script>
<script type="text/javascript" src="lib/jquery-ui-1.8.23-min.js"></script>
<script type="text/javascript" src="lib/jquery.ui.touch-punch.min.js"></script>
<script type="text/javascript" src="lib/md5.js"></script>
<script type="text/javascript" src="lib/jio.js"></script>
<script type="text/javascript" src="lib/jio.localstorage.js"></script>
<script type="text/javascript" src="lib/pubsub.js"></script>
<script type="text/javascript" src="lib/jquery.jsPlumb-1.5.4-min.js"></script>
<!-- /DEP -->
<!-- flot -->
<script type="text/javascript" src="lib/jquery.flot.js"></script>
<script type="text/javascript" src="lib/jquery.flot.stack.js"></script>
<script type="text/javascript" src="lib/jquery.jsoneditor.js"></script>
<!-- flot -->
<script type="text/javascript" src="lib/jquery.flot.js"></script>
<script type="text/javascript" src="lib/jquery.flot.stack.js"></script>
<script type="text/javascript" src="lib/jquery.jsoneditor.js"></script>
<!-- jqs -->
<script type="text/javascript" src="lib/jquery.sheet-2.0.0/parser.js""></script>
<script type="text/javascript" src="lib/jquery.sheet-2.0.0/jquery.sheet.min.js""></script>
<!-- jqs -->
<script type="text/javascript" src="lib/jquery.sheet-2.0.0/parser.js""></script>
<script type="text/javascript" src="lib/jquery.sheet-2.0.0/jquery.sheet.min.js""></script>
<div id="dialog-form" title="Configure">
<form>
<fieldset id="dialog-fieldset">
</fieldset>
</form>
</div>
<div id="dialog-form" title="Configure">
<form>
<fieldset id="dialog-fieldset">
</fieldset>
</form>
<!-- demo code -->
<script type="text/javascript" src="src/dream.js"></script>
<script type="text/javascript" src="src/jsonPlumb.js"></script>
<script type="text/javascript" src="src/dream_launcher.js"></script>
</div>
<!-- demo code -->
<script type="text/javascript" src="src/dream.js"></script>
<script type="text/javascript" src="src/jsonPlumb.js"></script>
<script type="text/javascript" src="src/dream_launcher.js"></script>
</div>
</body>
</html>
......@@ -25,29 +25,8 @@
var that = jsonPlumb(),
priv = {};
// Utility function to update the style of a box
priv.updateBoxStyle = function (box_id, style) {
var box;
box = $("#" + box_id);
$.each(style, function (key, value) {
box.css(key, value);
});
};
// Utility function to update the content of the box
priv.updateBoxContent = function (box_id, title, throughput, worker) {
var box, html_string;
box = $("#" + box_id);
html_string = "<strong>" + title + "</strong>";
if (worker !== undefined && worker !== null) {
html_string += "<br> (" + worker + ")";
}
html_string += "<br><strong>througput: " + throughput + "</strong>";
box.html(html_string);
};
priv.displayTool = function () {
var render_element = $("[id=tools-container]");
var render_element = $("#tools-container");
for (var key in configuration) {
if (key !== 'Dream-Configuration') {
render_element.append('<div id="' + key + '" class="tool ' + key + '">' +
......@@ -98,11 +77,14 @@
// Render fields for that particular element
var fieldset = $("#dialog-fieldset");
$("#dialog-fieldset").children().remove();
var element_id_prefix = element_id.split("_")[0];
var property_list = configuration[element_id_prefix].property_list || [];
var previous_data = that.getData()["nodes"];
$("#dialog-fieldset").children().remove();
var element_type = previous_data[element_id]._class.replace('.', '-');
var property_list = configuration[element_type].property_list || [];
fieldset.append(
'<label>ID</label><input type="text" name="id" id="id" value="' +
element_id + '" class="text ui-widget-content ui-corner-all"/>');
var element_name = previous_data[element_id]['name'] || element_id;
fieldset.append(
'<label>Name</label><input type="text" name="name" id="name" value="' +
......@@ -138,7 +120,6 @@
$("#dialog-form").dialog({
autoOpen: false,
height: 300,
width: 350,
modal: true,
title: title || "",
......@@ -154,6 +135,11 @@
$(this).dialog("close");
},
Validate: function () {
var new_id = $("#id").val();
if (new_id !== element_id && $('#' + new_id).length > 0) {
alert('This ID is already used.');
return;
};
var data = {}, prefixed_property_id, property_element;
var updateDataPropertyList = function (property_list, data,
prefix) {
......@@ -178,7 +164,8 @@
updateDataPropertyList(property_list, data);
that.updateElementData(element_id, {
data: data,
name: $("#name").val() || element_id
name: $("#name").val() || element_id,
id: $("#id").val() || element_id
});
$(this).dialog("close");
......@@ -192,15 +179,15 @@
priv.super_newElement = that.newElement;
that.newElement = function (element) {
var element_prefix = element.id.split('_')[0];
priv.super_newElement(element, configuration[element_prefix]);
var element_type = element._class.replace('.', '-');
priv.super_newElement(element, configuration[element_type]);
$("#" + element.id).bind('click', function () {
$("#dialog-form").dialog("destroy");
priv.prepareDialogForElement(element.id, element.id);
$("#dialog-form").dialog("open");
});
// Store default values
var data = {}, property_list = configuration[element_prefix][
var data = {}, property_list = configuration[element_type][
"property_list"
] || [];
var updateDefaultData = function (data, property_list) {
......
......@@ -27,7 +27,6 @@
applicationname: "dream"
});
var window_id = 1;
var id_container = {}; // to allow generating next ids, like Machine_1, Machine_2, etc
var property_container = {
entity: {
......@@ -190,6 +189,33 @@
},
_class: 'Dream.Exit'
},
"Dream-MachineJobShop": {
anchor: {
RightMiddle: {},
LeftMiddle: {},
TopCenter: {},
BottomCenter: {}
},
property_list: [property_container["processingTime"],
property_container["failures"]
],
_class: 'Dream.MachineJobShop'
},
"Dream-QueueJobShop": {
anchor: {
RightMiddle: {},
LeftMiddle: {}
},
property_list: [property_container["capacity"], property_container[
"isDummy"]],
_class: 'Dream.QueueJobShop'
},
"Dream-ExitJobShop": {
anchor: {
LeftMiddle: {}
},
_class: 'Dream.ExitJobShop'
},
"Dream-Repairman": {
anchor: {
TopCenter: {},
......@@ -215,65 +241,74 @@
helper: "clone",
stop: function (tool) {
var box_top, box_left, _class;
var offset = $("[id=render]").offset();
var offset = $("#render").offset();
box_top = tool.clientY - offset.top + "px";
box_left = tool.clientX - offset.left + "px";
var relative_position = dream_instance.convertToRelativePosition(
box_left, box_top);
id_container[tool.target.id] = (id_container[tool.target.id] || 0) +
1;
_class = tool.target.id.replace('-', '.'); // XXX - vs .
dream_instance.newElement({
id: tool.target.id + "_" + id_container[tool.target.id],
coordinate: {
top: box_top,
left: box_left
top: relative_position[1],
left: relative_position[0]
},
_class: _class
});
window_id += 1;
}
});
var loadData = function(data) {
var preference = data.preference !== undefined ?
data.preference : {};
dream_instance.setPreferences(preference);
// Add all elements
$.each(data.nodes, function (key, value) {
var coordinates = preference['coordinates'] || {};
var coordinate = coordinates[key] || {};
value['coordinate'] = {};
$.each(coordinate || {}, function (k, v) {
value['coordinate'][k] = v;
});
dream_instance.newElement(value);
dream_instance.updateElementData(key, {
data: value.data || {}
});
});
$.each(data.edges, function (key, value) {
dream_instance.connect(value[0], value[1]);
});
// Now update id_container
$.each(data.nodes, function (key, value) {
var element_id = value.id,
prefix, suffix, splitted_element_id;
splitted_element_id = element_id.split("_");
prefix = splitted_element_id[0];
suffix = splitted_element_id[1];
id_container[prefix] = Math.max((id_container[prefix] || 0),
parseInt(suffix, 10));
});
dream_instance.setGeneralProperties(data.general);
dream_instance.initGeneralProperties(); // XXX
dream_instance.redraw()
$("#json_output").val(JSON.stringify(dream_instance.getData(),
undefined, " "));
};
// Check if there is already data when we first load the page, if yes, then build graph from it
jio.get({
_id: "dream_demo"
}, function (err, response) {
if (response !== undefined && response.data !== undefined) {
// Add all elements
$.each(response.data.nodes, function (key, value) {
var preference_data = response.data.preference !== undefined ?
response.data.preference[key] : {};
$.each(preference_data, function (preference_key,
preference_value) {
value[preference_key] = preference_value;
});
dream_instance.newElement(value);
dream_instance.updateElementData(key, {
data: value.data || {}
});
});
$.each(response.data.edges, function (key, value) {
dream_instance.connect(value[0], value[1]);
});
// Now update id_container
$.each(response.data.nodes, function (key, value) {
var element_id = value.id,
prefix, suffix, splitted_element_id;
splitted_element_id = element_id.split("_");
prefix = splitted_element_id[0];
suffix = splitted_element_id[1];
id_container[prefix] = Math.max((id_container[prefix] || 0),
parseInt(suffix, 10));
});
dream_instance.setGeneralProperties(response.data.general);
dream_instance.initGeneralProperties(); // XXX
$("#json_output").text(JSON.stringify(dream_instance.getData(),
undefined, " "));
loadData(response.data);
}
// once the data is read, we can subscribe to every changes
$.subscribe("Dream.Gui.onDataChange", function (event, data) {
$("#json_output").text(JSON.stringify(data, undefined, " "));
$("#json_output").val(JSON.stringify(data, undefined, " "));
jio.put({
_id: "dream_demo",
data: data
......@@ -295,7 +330,7 @@
dream_instance.runSimulation(
function (data) {
if (data['success']) {
$("#json_result").text(JSON.stringify(data['success'],
$("#json_result").val(JSON.stringify(data['success'],
undefined, " "));
// display demo graph.
......@@ -370,7 +405,7 @@
$.plot("#graph", series, options);
} else {
$("#json_result").effect('shake', 50).text(data['error']);
$("#json_result").effect('shake', 50).val(data['error']);
}
});
e.preventDefault();
......@@ -404,8 +439,22 @@
dream_instance.zoom_out();
});
// Redraw if the graph area or the window is resized
$('#main').resizable().resize(function () {
dream_instance.redraw();
});
$(window).resize(function () {
dream_instance.redraw();
});
// Load JSON button for debugging
$("#load_json").button().click(function () {
dream_instance.clearAll();
loadData(JSON.parse($("#json_output").val()));
});
$("#graph_zone").hide();
// spreadsheet
var default_config = {
id: "jquerysheet-div",
......
This diff is collapsed.
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