-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
executable file
·276 lines (225 loc) · 12.1 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<title>FPGALink-GUI</title>
<!-- powered by at least five blockchains! -->
<meta name="mobile-web-app-capable" content="yes" />
<meta name="viewport" content="width=device-width, minimum-scale=1.0" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" rel="stylesheet" href="./css/aristo/jquery-ui-1.8.16.custom.css" />
<link type="text/css" rel="stylesheet" href="./css/jquery.layout.css" />
<link type="text/css" rel="stylesheet" href="./css/application.css" />
<script src="./lib/jquery.js"></script>
<script src="./lib/jquery-ui.js"></script>
<script src="./lib/jquery.browser.js"></script>
<script src="./lib/jquery.layout.js"></script>
<script src="./lib/draw2d.js"></script>
<script src="./gui/Util.js"></script>
<script src="./gui/Application.js"></script>
<script src="./gui/View.js"></script>
<script src="./gui/Toolbar.js"></script>
<script src="./gui/HoverConnection.js"></script>
<script src="./gui/SelectionMenuPolicy.js"></script>
<script src="./gui/NodeShape.js"></script>
<script src="./gui/SwitchShape.js"></script>
<!--<script src="./gui/NodeShapeHorizontal.js"></script>-->
<!-- <script src="./gui/NodeShapeVertical.js"></script>-->
<script type="text/javascript">
var app;
document.addEventListener("DOMContentLoaded", function () {
app = new example.Application();
app.view.installEditPolicy(new draw2d.policy.connection.DragConnectionCreatePolicy({
createConnection: function () {
return new HoverConnection();
}
}));
// Enable grid by default.
app.toolbar.installedPolicy = new draw2d.policy.canvas.SnapToGridEditPolicy();
app.view.installEditPolicy(app.toolbar.installedPolicy);
// // unmarshal the JSON document into the canvas (load).
// var jsonDocument = $("#json_input").text();
// var reader = new draw2d.io.json.Reader();
// reader.unmarshal(app.view, jsonDocument);
// // display the JSON document in the preview DIV
// //
// displayJSON(app.view);
// Produce export text into input fields.
app.view.getCommandStack().addEventListener(function (e) {
if (e.isPostChangeEvent()) {
// displayJSON(app.view);
// var fpganodes = app.view.getFigures();
// var srun_export = " -N " + fpganodes.getSize();
var srun_export = "";
var connections = app.view.getLines();
for (let i = 0; i < connections.getSize(); i++) {
var connection = connections.get(i);
// Ignore in case this is a config connection
if (!connection.sourcePort.name.includes("config_port")) {
// Parent is ChannelShape.
let source_channel = connection.getSource().getParent();
let target_channel = connection.getTarget().getParent();
let source_fpgalink_text = generate_fpgalink_output(source_channel);
let target_fpgalink_text = generate_fpgalink_output(target_channel);
srun_export += " --fpgalink=" + source_fpgalink_text + "-" + target_fpgalink_text + "";
}
}
// Export --fpgalink.
app.toolbar.srunExportInput.val(srun_export);
// Export URL.
var importURL = "https://pc2.github.io/fpgalink-gui/index.html?import=";
importURL += encodeURIComponent(srun_export);
app.toolbar.urlExportInput.val(importURL);
}
});
// Read srun command from $_GET request.
var srun_cmd = "";
try {
var get_decoded = decodeURI(window.location.search);
const urlParams = new URLSearchParams(get_decoded);
if (urlParams.has('import')) {
srun_cmd = urlParams.get('import');
// Special case to replace eth with eth00
srun_cmd = srun_cmd.replace(/eth(?!\d{2})/g, 'eth00')
var get_node_type = "";
if (urlParams.has('node-type') &&
(urlParams.get('node-type') == NodeTypeEnum.intel ||
urlParams.get('node-type') == NodeTypeEnum.xilinx)) {
get_node_type = urlParams.get('node-type');
} else {
// Apply minor heuristic if command is for Xilinx or Intel.
// Idea: If command has
// * acl2, it has to be Xilinx
// * chX, where X >= 2, it has to be Intel
if (srun_cmd.indexOf("acl2") > -1) {
get_node_type = NodeTypeEnum.xilinx;
}
if (srun_cmd.indexOf("ch2") > -1 || srun_cmd.indexOf("ch3") > -1 ) {
get_node_type = NodeTypeEnum.intel;
}
// If heuristic does not catch, ask user.
if(get_node_type == "") {
document.getElementById("prompt-node-type").showModal();
}
}
if(get_node_type != "") {
app.toolbar.srunApply(srun_cmd, get_node_type);
}
}
} catch (e) { // catches a malformed URI
console.log(e);
alert("error parsing srun command from GET request.");
}
// Read srun command from $_GET request, if node type unclear.
$("#prompt-node-type-intel").click(function () {
document.getElementById("prompt-node-type").close();
app.toolbar.srunApply(srun_cmd, NodeTypeEnum.intel);
});
$("#prompt-node-type-xilinx").click(function () {
document.getElementById("prompt-node-type").close();
app.toolbar.srunApply(srun_cmd, NodeTypeEnum.xilinx);
});
// Navigation.
// Grid toggle.
app.toolbar.toggleGridButton = $('#toggleGridButton');
app.toolbar.toggleGridButton.button().click($.proxy(function () {
if (!app.toolbar.installedPolicy) {
app.toolbar.installedPolicy = new draw2d.policy.canvas.SnapToGridEditPolicy();
app.view.installEditPolicy(app.toolbar.installedPolicy);
} else {
app.view.uninstallEditPolicy(app.toolbar.installedPolicy);
app.toolbar.installedPolicy = null;
}
}, app.toolbar)).button("option", "enabled", true);
// Change router.
app.toolbar.changeRouterSelect = $("#connection_router");
app.toolbar.changeRouterSelect.on('change', function () {
var selectedRouterClassName = this.value;
app.setDefaultRouterClassName(selectedRouterClassName);
// here: insecure use of eval
var router = eval("new " + selectedRouterClassName + "()");
app.view.getLines().each(function (i, line) {
line.setRouter(router);
});
});
});
function displayJSON(canvas) {
var writer = new draw2d.io.json.Writer();
writer.marshal(canvas, function (json) {
$("#json_output").text(JSON.stringify(json, null, 2));
});
}
</script>
</head>
<body id="container">
<div id="content">
<div id="toolbar"></div>
<div id="canvas" class="" style="width:3000px; height:3000px;">
<!-- Menu for config options for 2 nodes -->
<ul class='custom-menu mult'>
<li data-action="one-by-one">1:1 Mapping</li>
</ul>
</div>
</div>
<!-- Menu for config options for single nodes -->
<div class='custom-menu single'>
<div class="title">Configure Connection:</div>
<ul>
<li data-action="loopback">Loopback</li>
<li class="intel-only" data-action="pair">Pair</li>
<li data-action="channel">Channel i to i + 1</li>
<li class="intel-only" data-action="torus2">Torus2</li>
</ul>
<div class="intel-only title">Rings</div>
<ul class="intel-only">
<li data-action="ringO">RingO</li>
<li data-action="ringN">RingN</li>
<li data-action="ringZ">RingZ</li>
</ul>
<ul>
<li class="clear" data-action="clear">Clear all connections</li>
</ul>
</div>
<div id="navigation" class="">
<p style="font-size:22px;"><strong><a href="index.html" style="color:#18b0e2;">FPGALink-GUI</a></strong></p>
<p style="color:#fff;"><strong>Add FPGA Nodes by <br />Drag&Drop</strong></p>
<div data-type="node-intel" data-shape="east" class="palette_node_element draw2d_droppable">Intel Stratix 10 Node</div>
<div data-type="node-xilinx" data-shape="east" class="palette_node_element draw2d_droppable">Xilinx Alveo U280 Nodes</div>
<p style="color:#fff;"><strong>Add Ethernet Switch by <br />Drag&Drop</strong></p>
<div data-type="node-ethernet-switch" data-shape="north" class="palette_node_element draw2d_droppable">Ethernet Switch</div>
<p style="color:#fff;"><strong>Add Annotations</strong></p>
<div data-type="label" data-shape="label" class="palette_node_element draw2d_droppable">Label</div>
<p style="color:#fff;"><strong>Settings</strong></p>
<button id="toggleGridButton">Toggle Grid</button>
<p style="color:#fff;">Change Router</p>
<select id="connection_router">
<option value="draw2d.layout.connection.ManhattanConnectionRouter">Manhattan</option>
<option value="draw2d.layout.connection.ManhattanBridgedConnectionRouter">Manhattan Bridged</option>
<option value="draw2d.layout.connection.InteractiveManhattanConnectionRouter">Manhattan Interactive</option>
<option value="draw2d.layout.connection.CircuitConnectionRouter">Circuit</option>
<option value="draw2d.layout.connection.DirectRouter">Direct</option>
<option value="draw2d.layout.connection.SplineConnectionRouter" selected="selected">Spline</option>
<option value="draw2d.layout.connection.MazeConnectionRouter">Maze</option>
<option value="draw2d.layout.connection.SketchConnectionRouter">Sketch</option>
</select>
</div>
<!-- <div id="json_output_div" style="overflow:auto;position:absolute; top:50px; right:20px; width:350; height:110;background:white;border:1px solid gray">
JSON output
<textarea id="json_output" rows="4" cols="40"></textarea>
</div>
<div id="json_input_div" style="overflow:auto;position:absolute; top:160px; right:20px; width:350; height:110;background:white;border:1px solid gray">
JSON input
<textarea id="json_input" rows="4" cols="40"></textarea>
</div> -->
<div id="svg_output_div"
style="overflow:auto;position:absolute; top:270px; right:20px; width:350; height:110;background:white;border:1px solid gray;display:none;">
SVG output
<textarea id="svg_output" rows="4" cols="40"></textarea>
</div>
<dialog id="prompt-node-type" role="dialog" aria-labelledby="prompt-dialog-heading">
Node type (intel or xilinx) unclear. Select<br />
<p>
<button id="prompt-node-type-intel" name="intel">intel</button>
<button id="prompt-node-type-xilinx" name="xilinx">xilinx</button>
</p>
</dialog>
</body>
</html>