anim.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2016,2017 CNRS
  4. * Copyright (C) 2015 Université de Bordeaux
  5. * Copyright (C) 2015 Anthony Simonet
  6. *
  7. * StarPU is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU Lesser General Public License as published by
  9. * the Free Software Foundation; either version 2.1 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * StarPU is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. *
  16. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  17. */
  18. #include <stdint.h>
  19. #include <stdlib.h>
  20. #include <common/uthash.h>
  21. #include <starpu.h>
  22. #include "starpu_fxt.h"
  23. #ifdef STARPU_USE_FXT
  24. static struct component
  25. {
  26. UT_hash_handle hh;
  27. char *name;
  28. int workerid;
  29. uint64_t ptr;
  30. unsigned nchildren;
  31. struct component **children;
  32. struct component *parent;
  33. unsigned ntasks;
  34. unsigned npriotasks;
  35. } *components;
  36. static unsigned global_state = 1;
  37. static unsigned nsubmitted;
  38. static unsigned curq_size;
  39. static unsigned nflowing;
  40. #define COMPONENT_ADD(head, field, add) HASH_ADD(hh, head, field, sizeof(uint64_t), add);
  41. #define COMPONENT_FIND(head, find, out) HASH_FIND(hh, head, &find, sizeof(uint64_t), out);
  42. static struct component *fxt_component_root(void)
  43. {
  44. struct component *comp, *tmp;
  45. HASH_ITER(hh, components, comp, tmp)
  46. {
  47. while (comp->parent)
  48. comp = comp->parent;
  49. return comp;
  50. }
  51. return NULL;
  52. }
  53. void _starpu_fxt_component_new(uint64_t component, char *name)
  54. {
  55. struct component *comp;
  56. _STARPU_MALLOC(comp, sizeof(*comp));
  57. if (!strncmp(name, "worker ", 7))
  58. {
  59. comp->name = strdup("worker");
  60. comp->workerid = atoi(name+7);
  61. }
  62. else
  63. {
  64. comp->name = strdup(name);
  65. comp->workerid = -1;
  66. }
  67. comp->ptr = component;
  68. comp->nchildren = 0;
  69. comp->children = NULL;
  70. comp->parent = NULL;
  71. comp->ntasks = 0;
  72. comp->npriotasks = 0;
  73. COMPONENT_ADD(components, ptr, comp);
  74. }
  75. static void fxt_component_dump(FILE *file, struct component *comp, unsigned depth)
  76. {
  77. unsigned i;
  78. fprintf(file,"%*s%s (%d %"PRIx64", %d tasks %d prio tasks)\n", 2*depth, "", comp->name, depth, comp->ptr, comp->ntasks, comp->npriotasks);
  79. for (i = 0; i < comp->nchildren; i++)
  80. if (comp->children[i]->parent == comp)
  81. fxt_component_dump(file, comp->children[i], depth+1);
  82. }
  83. void _starpu_fxt_component_dump(FILE *file)
  84. {
  85. fxt_component_dump(file, fxt_component_root(), 0);
  86. }
  87. static void fxt_worker_print(FILE *file, struct starpu_fxt_options *options, int workerid, unsigned comp_workerid, unsigned depth)
  88. {
  89. fprintf(file, "\t\t\t%*s<table><tr><td class='worker_box%s'><center>%s\n", 2*depth, "",
  90. (int) comp_workerid == workerid ? "_sched":"",
  91. options->worker_names[comp_workerid]);
  92. if (_starpu_last_codelet_symbol[comp_workerid][0])
  93. fprintf(file, "\t\t\t%*s<table><tr><td class='run_task'>%s</td></tr></table>\n", 2*(depth+1), "", _starpu_last_codelet_symbol[comp_workerid]);
  94. else
  95. fprintf(file, "\t\t\t%*s<table><tr><td class='fake_task'></td></tr></table>\n", 2*(depth+1), "");
  96. fprintf(file, "\t\t\t%*s</center></td></tr>\n", 2*depth, "");
  97. fprintf(file, "\t\t\t%*s</table>", 2*depth, "");
  98. }
  99. static void fxt_component_print(FILE *file, struct starpu_fxt_options *options, int workerid, struct component *from, struct component *to, struct component *comp, unsigned depth)
  100. {
  101. unsigned i, n;
  102. unsigned ntasks = comp->ntasks + comp->npriotasks;
  103. if (from == comp)
  104. /* Additionally show now-empty slot */
  105. ntasks++;
  106. for (i = 0, n = 0; i < comp->nchildren; i++)
  107. if (comp->children[i]->parent == comp)
  108. n++;
  109. fprintf(file, "\t\t\t%*s<table><tr><td class='box' colspan=%u><center>%s\n", 2*depth, "", n, comp->name);
  110. if (!strcmp(comp->name,"prio") || !strcmp(comp->name,"fifo") || !strcmp(comp->name,"heft") || !strcmp(comp->name,"work_stealing"))
  111. {
  112. /* Show task queue */
  113. #define N 3
  114. n = ntasks;
  115. if (n > N)
  116. n = N;
  117. for (i = 0; i < N-n; i++)
  118. fprintf(file, "\t\t\t%*s<table><tr><td class='fake_task'></td></tr></table>\n", 2*depth, "");
  119. if (ntasks)
  120. {
  121. if (ntasks > N)
  122. fprintf(file, "\t\t\t%*s<table><tr><td class='%s'>%u</td></tr></table>\n", 2*depth, "",
  123. from == comp
  124. ? (comp->npriotasks >= N ? "last_task_full_prio" : "last_task_full")
  125. : (comp->npriotasks >= N ? "task_prio" : "task"),
  126. comp->ntasks + comp->npriotasks);
  127. else
  128. fprintf(file, "\t\t\t%*s<table><tr><td class='%s'></td></tr></table>\n", 2*depth, "",
  129. from == comp
  130. ? "last_task_empty"
  131. : (comp->ntasks ? "task" : "task_prio"));
  132. for (i = 1; i < n; i++)
  133. fprintf(file, "\t\t\t%*s<table><tr><td class='%s'></td></tr></table>\n", 2*depth, "",
  134. n - i > comp->npriotasks ? "task" : "task_prio");
  135. }
  136. }
  137. else
  138. {
  139. if (ntasks == 0)
  140. fprintf(file, "\t\t\t%*s<table><tr><td class='fake_task'></td></tr></table>\n", 2*depth, "");
  141. else if (ntasks == 1)
  142. fprintf(file, "\t\t\t%*s<table><tr><td class='%s'></td></tr></table>\n", 2*depth, "",
  143. from == comp
  144. ? "last_task_empty"
  145. : (comp->npriotasks ? "task_prio" : "task"));
  146. else
  147. fprintf(file, "\t\t\t%*s<table><tr><td class='%s'>%u</td></tr></table>\n", 2*depth, "",
  148. from == comp
  149. ? (comp->npriotasks ? "last_task_full_prio" : "last_task_full")
  150. : (comp->npriotasks ? "task_prio" : "task"), comp->ntasks + comp->npriotasks);
  151. }
  152. fprintf(file, "\t\t\t%*s</center></td></tr>\n", 2*depth, "");
  153. if (comp->nchildren > 0)
  154. {
  155. fprintf(file, "\t\t\t%*s<tr>\n", 2*depth, "");
  156. for (i = 0; i < comp->nchildren; i++)
  157. if (comp->children[i]->parent == comp)
  158. {
  159. fprintf(file, "\t\t\t%*s<td>\n", 2*depth, "");
  160. fxt_component_print(file, options, workerid, from, to, comp->children[i], depth+1);
  161. fprintf(file, "\t\t\t%*s</td>\n", 2*depth, "");
  162. }
  163. fprintf(file, "\t\t\t%*s</tr>\n", 2*depth, "");
  164. }
  165. if (!strcmp(comp->name, "worker"))
  166. {
  167. fprintf(file, "\t\t\t%*s<tr>\n", 2*depth, "");
  168. fprintf(file, "\t\t\t%*s<td>\n", 2*depth, "");
  169. fxt_worker_print(file, options, workerid, comp->workerid, depth+1);
  170. fprintf(file, "\t\t\t%*s</td>\n", 2*depth, "");
  171. fprintf(file, "\t\t\t%*s</tr>\n", 2*depth, "");
  172. }
  173. fprintf(file, "\t\t\t%*s</table>", 2*depth, "");
  174. }
  175. void _starpu_fxt_component_print(FILE *file, struct starpu_fxt_options *options, int workerid, struct component *from, struct component *to)
  176. {
  177. fprintf(file, "<center>\n");
  178. fxt_component_print(file, options, workerid, from, to, fxt_component_root(), 0);
  179. fprintf(file, "</center>\n");
  180. }
  181. void _starpu_fxt_component_print_header(FILE *file)
  182. {
  183. /* CSS and Javascript code from Anthony Simonet */
  184. fprintf(file, "<!DOCTYPE html>\n");
  185. fprintf(file, "<html lang='fr'>\n");
  186. fprintf(file, "\t<head>\n");
  187. fprintf(file, "\t\t<meta charset='utf-8'>\n");
  188. fprintf(file, "\t\t<link rel='stylesheet' href='http://code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css'>\n");
  189. fprintf(file, "\t\t<script src='http://code.jquery.com/jquery-1.10.2.js'></script>\n");
  190. fprintf(file, "\t\t<script src='http://code.jquery.com/ui/1.11.2/jquery-ui.js'></script>\n");
  191. //fprintf(file, "\t\t<link rel='stylesheet' href='/resources/demos/style.css'>\n");
  192. //fprintf(file, "\t\t<link rel='stylesheet' type='text/css' href='../styles.css'>\n");
  193. fprintf(file, "\t\t<style>\n");
  194. fprintf(file, "\t\t\ttable {\n");
  195. fprintf(file, "\t\t\t\tmargin: 0;\n");
  196. fprintf(file, "\t\t\t\tpadding: 0;\n");
  197. fprintf(file, "\t\t\t}\n");
  198. fprintf(file, "\t\t\ttd {\n");
  199. fprintf(file, "\t\t\t\tmargin: 0;\n");
  200. fprintf(file, "\t\t\t\tpadding: 0;\n");
  201. fprintf(file, "\t\t\t\tvertical-align: top;\n");
  202. fprintf(file, "\t\t\t\ttext-align: center;\n");
  203. fprintf(file, "\t\t\t}\n");
  204. fprintf(file, "\t\t\ttd.box {\n");
  205. fprintf(file, "\t\t\t\tborder: solid 1px;\n");
  206. fprintf(file, "\t\t\t}\n");
  207. fprintf(file, "\t\t\ttd.worker_box {\n");
  208. fprintf(file, "\t\t\t\tborder: solid 1px;\n");
  209. /* Fixed width to make output more homogeneous */
  210. fprintf(file, "\t\t\t\twidth: 75px;\n");
  211. fprintf(file, "\t\t\t}\n");
  212. fprintf(file, "\t\t\ttd.worker_box_sched {\n");
  213. fprintf(file, "\t\t\t\tborder: solid 1px;\n");
  214. /* Fixed width to make output more homogeneous */
  215. fprintf(file, "\t\t\t\twidth: 75px;\n");
  216. fprintf(file, "\t\t\t\tbackground-color: lightgreen;\n");
  217. fprintf(file, "\t\t\t}\n");
  218. /* Task */
  219. fprintf(file, "\t\t\ttd.task {\n");
  220. fprintf(file, "\t\t\t\tborder: solid 1px;\n");
  221. fprintf(file, "\t\t\t\twidth: 23px;\n");
  222. fprintf(file, "\t\t\t\theight: 23px;\n");
  223. fprintf(file, "\t\t\t\tbackground-color: #87CEEB;\n");
  224. fprintf(file, "\t\t\t}\n");
  225. /* Task being run (with codelet name) */
  226. fprintf(file, "\t\t\ttd.run_task {\n");
  227. fprintf(file, "\t\t\t\tborder: solid 1px;\n");
  228. fprintf(file, "\t\t\t\twidth: 69px;\n");
  229. fprintf(file, "\t\t\t\tmax-width: 69px;\n");
  230. fprintf(file, "\t\t\t\toverflow: hidden;\n");
  231. fprintf(file, "\t\t\t\tfont-size: 50%%;\n");
  232. fprintf(file, "\t\t\t\theight: 23px;\n");
  233. fprintf(file, "\t\t\t\tbackground-color: #87CEEB;\n");
  234. fprintf(file, "\t\t\t}\n");
  235. /* Prioritized Task */
  236. fprintf(file, "\t\t\ttd.task_prio {\n");
  237. fprintf(file, "\t\t\t\tborder: solid 1px;\n");
  238. fprintf(file, "\t\t\t\twidth: 23px;\n");
  239. fprintf(file, "\t\t\t\theight: 23px;\n");
  240. fprintf(file, "\t\t\t\tbackground-color: red;\n");
  241. fprintf(file, "\t\t\t}\n");
  242. /* Slot of previous task */
  243. fprintf(file, "\t\t\ttd.last_task_empty {\n");
  244. fprintf(file, "\t\t\t\tborder: dashed 1px;\n");
  245. fprintf(file, "\t\t\t\twidth: 23px;\n");
  246. fprintf(file, "\t\t\t\theight: 23px;\n");
  247. fprintf(file, "\t\t\t\tbackground-color: white;\n");
  248. fprintf(file, "\t\t\t}\n");
  249. /* Slot of previous task (but still other tasks) */
  250. fprintf(file, "\t\t\ttd.last_task_full {\n");
  251. fprintf(file, "\t\t\t\tborder: dashed 1px;\n");
  252. fprintf(file, "\t\t\t\twidth: 23px;\n");
  253. fprintf(file, "\t\t\t\theight: 23px;\n");
  254. fprintf(file, "\t\t\t\tbackground-color: #87CEEB;\n");
  255. fprintf(file, "\t\t\t}\n");
  256. /* Slot of previous task (but still other prioritized) */
  257. fprintf(file, "\t\t\ttd.last_task_full_prio {\n");
  258. fprintf(file, "\t\t\t\tborder: dashed 1px;\n");
  259. fprintf(file, "\t\t\t\twidth: 23px;\n");
  260. fprintf(file, "\t\t\t\theight: 23px;\n");
  261. fprintf(file, "\t\t\t\tbackground-color: red;\n");
  262. fprintf(file, "\t\t\t}\n");
  263. /* Empty task slot */
  264. fprintf(file, "\t\t\ttd.fake_task {\n");
  265. fprintf(file, "\t\t\t\twidth: 25px;\n");
  266. fprintf(file, "\t\t\t\theight: 25px;\n");
  267. fprintf(file, "\t\t\t}\n");
  268. fprintf(file, "\t\t</style>\n");
  269. fprintf(file, "\t\t<script>\n");
  270. fprintf(file, "\t\t\tfunction getInput(){\n");
  271. fprintf(file, "\t\t\t\tvar input = document.getElementById('input').value;\n");
  272. fprintf(file, "\t\t\t\tif (input <= 0 || input > $('#slider').slider('option', 'max')){\n");
  273. fprintf(file, "\t\t\t\t\talert('Invalid state value');\n");
  274. fprintf(file, "\t\t\t\t}\n");
  275. fprintf(file, "\t\t\t\tdocument.getElementById('et' + document.getElementById('etape').value).style.display = 'none';\n");
  276. fprintf(file, "\t\t\t\tdocument.getElementById('et' + input).style.display = 'block';\n");
  277. fprintf(file, "\t\t\t\t$('#etape').val(input);\n");
  278. fprintf(file, "\t\t\t\t$('#slider').slider('value', input);\n");
  279. fprintf(file, "\t\t\t}\n");
  280. fprintf(file, "\t\t</script>\n");
  281. fprintf(file, "\t\t<script>\n");
  282. fprintf(file, "\t\t\tvar myVar = null;\n");
  283. fprintf(file, "\t\t\tfunction changeState(number){\n");
  284. fprintf(file, "\t\t\t\tvar state = document.getElementById('etape').value;\n");
  285. fprintf(file, "\t\t\t\tvar state2 = parseInt(state) + parseInt(number);\n");
  286. fprintf(file, "\t\t\t\tvar min = $('#slider').slider('option', 'min');\n");
  287. fprintf(file, "\t\t\t\tvar max = $('#slider').slider('option', 'max');\n");
  288. fprintf(file, "\t\t\t\t\tdocument.getElementById('et' + document.getElementById('etape').value).style.display = 'none';\n");
  289. fprintf(file, "\t\t\t\tif (state2 >= min && state2 <= max){\n");
  290. fprintf(file, "\t\t\t\t\tdocument.getElementById('et' + state2).style.display = 'block';\n");
  291. fprintf(file, "\t\t\t\t\t$('#etape').val(state2);\n");
  292. fprintf(file, "\t\t\t\t\t$('#slider').slider('value', state2);\n");
  293. fprintf(file, "\t\t\t\t}\n");
  294. fprintf(file, "\t\t\t\telse if (state2 < min){\n");
  295. fprintf(file, "\t\t\t\t\tdocument.getElementById('et' + min).style.display = 'block';\n");
  296. fprintf(file, "\t\t\t\t\t$('#etape').val(min);\n");
  297. fprintf(file, "\t\t\t\t\t$('#slider').slider('value', min);\n");
  298. fprintf(file, "\t\t\t\t}\n");
  299. fprintf(file, "\t\t\t\telse if (state2 > max){\n");
  300. fprintf(file, "\t\t\t\t\tdocument.getElementById('et' + max).style.display = 'block';\n");
  301. fprintf(file, "\t\t\t\t\t$('#etape').val(max);\n");
  302. fprintf(file, "\t\t\t\t\t$('#slider').slider('value', max);\n");
  303. fprintf(file, "\t\t\t\t}\n");
  304. fprintf(file, "\t\t\t}\n");
  305. fprintf(file, "\t\t</script>\n");
  306. fprintf(file, "\t</head>\n");
  307. fprintf(file, "\t<body>\n");
  308. }
  309. static void fxt_component_print_step(FILE *file, struct starpu_fxt_options *options, double timestamp, int workerid, unsigned push, struct component *from, struct component *to)
  310. {
  311. fprintf(file, "\t\t<div id='et%u' style='display:%s;'><center><!-- Étape %u -->\n",
  312. global_state, global_state > 1 ? "none":"block", global_state);
  313. fprintf(file, "\t\t<p>Time %f, %u submitted %u ready, %s</p>\n", timestamp, nsubmitted, curq_size-nflowing, push?"push":"pull");
  314. //fprintf(file, "\t\t\t<tt><pre>\n");
  315. //_starpu_fxt_component_dump(file);
  316. //fprintf(file, "\t\t\t</pre></tt>\n");
  317. _starpu_fxt_component_print(file, options, workerid, from, to);
  318. fprintf(file,"\t\t</center></div>");
  319. global_state++;
  320. }
  321. void _starpu_fxt_component_connect(uint64_t parent, uint64_t child)
  322. {
  323. struct component *parent_p, *child_p;
  324. unsigned n;
  325. COMPONENT_FIND(components, parent, parent_p);
  326. COMPONENT_FIND(components, child, child_p);
  327. STARPU_ASSERT(parent_p);
  328. STARPU_ASSERT(child_p);
  329. n = ++parent_p->nchildren;
  330. _STARPU_REALLOC(parent_p->children, n * sizeof(*parent_p->children));
  331. parent_p->children[n-1] = child_p;
  332. if (!child_p->parent)
  333. child_p->parent = parent_p;
  334. }
  335. void _starpu_fxt_component_update_ntasks(unsigned _nsubmitted, unsigned _curq_size)
  336. {
  337. nsubmitted = _nsubmitted;
  338. curq_size = _curq_size;
  339. }
  340. void _starpu_fxt_component_push(FILE *output, struct starpu_fxt_options *options, double timestamp, int workerid, uint64_t from, uint64_t to, uint64_t task STARPU_ATTRIBUTE_UNUSED, unsigned prio)
  341. {
  342. struct component *from_p = NULL, *to_p = NULL;
  343. if (to == from)
  344. return;
  345. if (from)
  346. {
  347. COMPONENT_FIND(components, from, from_p);
  348. STARPU_ASSERT(from_p);
  349. }
  350. if (to)
  351. {
  352. COMPONENT_FIND(components, to, to_p);
  353. STARPU_ASSERT(to_p);
  354. }
  355. if (from_p)
  356. {
  357. if (prio)
  358. from_p->npriotasks--;
  359. else
  360. from_p->ntasks--;
  361. }
  362. else
  363. nflowing++;
  364. if (prio)
  365. to_p->npriotasks++;
  366. else
  367. to_p->ntasks++;
  368. // fprintf(stderr,"push from %s to %s\n", from_p?from_p->name:"none", to_p?to_p->name:"none");
  369. fxt_component_print_step(output, options, timestamp, workerid, 1, from_p, to_p);
  370. }
  371. void _starpu_fxt_component_pull(FILE *output, struct starpu_fxt_options *options, double timestamp, int workerid, uint64_t from, uint64_t to, uint64_t task STARPU_ATTRIBUTE_UNUSED, unsigned prio)
  372. {
  373. struct component *from_p = NULL, *to_p = NULL;
  374. if (to == from)
  375. return;
  376. if (from)
  377. {
  378. COMPONENT_FIND(components, from, from_p);
  379. STARPU_ASSERT(from_p);
  380. }
  381. if (to)
  382. {
  383. COMPONENT_FIND(components, to, to_p);
  384. STARPU_ASSERT(to_p);
  385. }
  386. if (prio)
  387. from_p->npriotasks--;
  388. else
  389. from_p->ntasks--;
  390. if (to_p)
  391. {
  392. if (prio)
  393. to_p->npriotasks++;
  394. else
  395. to_p->ntasks++;
  396. }
  397. else
  398. nflowing--;
  399. // fprintf(stderr,"pull from %s to %s\n", from_p?from_p->name:"none", to_p?to_p->name:"none");
  400. fxt_component_print_step(output, options, timestamp, workerid, 0, from_p, to_p);
  401. }
  402. void _starpu_fxt_component_finish(FILE *file)
  403. {
  404. /* Javascript code from Anthony Simonet */
  405. fprintf(file, "\t\t<script>\n");
  406. fprintf(file, "\t\t\t$(function(){\n");
  407. fprintf(file, "\t\t\t\tsliderDiv = $('#slider') <!-- Alias -->\n");
  408. fprintf(file, "\t\t\t\tsliderDiv.slider({\n");
  409. fprintf(file, "\t\t\t\t\tvalue: 1,\n");
  410. fprintf(file, "\t\t\t\t\tmin: 1,\n");
  411. fprintf(file, "\t\t\t\t\tmax: %u,\n", global_state-1);
  412. fprintf(file, "\t\t\t\t\tstep: 1,\n");
  413. fprintf(file, "\t\t\t\t\tanimate: 'fast',\n");
  414. fprintf(file, "\t\t\t\t\tslide: function(event, ui){\n");
  415. fprintf(file, "\t\t\t\t\t\tvar l_value = sliderDiv.slider('option', 'value');\n");
  416. fprintf(file, "\t\t\t\t\t\t$('#etape').val(ui.value);\n");
  417. fprintf(file, "\t\t\t\t\t\tdocument.getElementById('et' + l_value).style.display = 'none';\n");
  418. fprintf(file, "\t\t\t\t\t\tdocument.getElementById('et' + ui.value).style.display = 'block';\n");
  419. fprintf(file, "\t\t\t\t\t}\n");
  420. fprintf(file, "\t\t\t\t});\n");
  421. fprintf(file, "\t\t\t\t$('#etape').val(sliderDiv.slider('value')); <!-- Initialisation au lancement de la page -->\n");
  422. fprintf(file, "\t\t\t\t$('#max').val(sliderDiv.slider('option', 'max'));\n");
  423. fprintf(file, "\t\t\t});\n");
  424. fprintf(file, "\t\t</script>\n");
  425. fprintf(file, "\t\t<div id ='slider'></div>\n");
  426. fprintf(file, "\t\t<center>\n");
  427. fprintf(file, "\t\t\t<p>\n");
  428. fprintf(file, "\t\t\t\t<input type='button' value='-100' onclick=\"changeState(-100);\"/>\n");
  429. fprintf(file, "\t\t\t\t<input type='button' value='<<' onmousedown=\"myVar = setInterval('changeState(-1)', 50)\" onmouseup=\"clearInterval(myVar)\" onmouseout=\"clearInterval(myVar)\"/>\n");
  430. fprintf(file, "\t\t\t\t<input type='button' value='<' onclick=\"changeState(-1);\"/>\n");
  431. fprintf(file, "\t\t\t\t<label for='etape'>State</label>\n");
  432. fprintf(file, "\t\t\t\t<input type='text' id='etape' size='3mm' readonly style='border:0;'>\n");
  433. fprintf(file, "\t\t\t\t<label for='max'>in</label>\n");
  434. fprintf(file, "\t\t\t\t<input type='text' id='max' size='3mm' readonly style='border:0;'>\n");
  435. fprintf(file, "\t\t\t\t<input type='button' value='>' onclick=\"changeState(1);\" />\n");
  436. fprintf(file, "\t\t\t\t<input type='button' value='>>' onmousedown=\"myVar = setInterval('changeState(1)', 50)\" onmouseup=\"clearInterval(myVar)\" onmouseout=\"clearInterval(myVar)\"/>\n");
  437. fprintf(file, "\t\t\t\t<input type='button' value='+100' onclick=\"changeState(100);\"/>\n");
  438. fprintf(file, "\t\t\t</p>\n");
  439. fprintf(file, "\t\t\t\t<span id='range'>Auto speed (state/s): 4</span>\n");
  440. fprintf(file, "\t\t\t\t<input type='range' id='autoRange' min='1' max='50' value='4' step='1' onchange=\"showValue(this.value); clearInterval(myVar);\" />\n");
  441. fprintf(file, "\t\t\t\t<script>\n");
  442. fprintf(file, "\t\t\t\t\tdocument.getElementById('autoRange').value = 4;\n");
  443. fprintf(file, "\t\t\t\t\tfunction showValue(newValue)\n");
  444. fprintf(file, "\t\t\t\t\t{\n");
  445. fprintf(file, "\t\t\t\t\t\tdocument.getElementById('range').innerHTML='Auto speed (state/s): '+ newValue;\n");
  446. fprintf(file, "\t\t\t\t\t}\n");
  447. fprintf(file, "\t\t\t\t</script>\n");
  448. fprintf(file, "\t\t\t\t<input type='button' value='Auto' onclick=\"if(myVar){ clearInterval(myVar); myVar = null;}changeState(1); myVar = setInterval('changeState(1)', 1000/document.getElementById('autoRange').value);\"/>\n");
  449. fprintf(file, "\t\t\t\t<input type='button' value='Stop' onclick=\"clearInterval(myVar);\"/>\n");
  450. fprintf(file, "\t\t\t<p>\n");
  451. fprintf(file, "\t\t\t</p>\n");
  452. fprintf(file, "\t\t\t<FORM>\n");
  453. fprintf(file, "\t\t\t\t<span>Go to state</span>\n");
  454. fprintf(file, "\t\t\t\t<input type='text' name='setinput' id='input' value='' onKeyPress=\"if(event.keyCode == 13){ getInput(); javascript:this.value=''}\" onFocus=\"javascript:this.value=''\"/>\n");
  455. fprintf(file, "\t\t\t\t<input type='text' name='message' id='' value='' style='display:none'>\n"); /* Dummy input preventing the page from being refreshed when enter is pressed. */
  456. fprintf(file, "\t\t\t\t<input type='button' value='Go' onclick=\"getInput(); javascript:input.value=''\"/>\n");
  457. fprintf(file, "\t\t\t</FORM>\n");
  458. fprintf(file, "\t\t\t<br />\n");
  459. fprintf(file, "\t\t</center>\n");
  460. fprintf(file, "\t</body>\n");
  461. fprintf(file, "</html>\n");
  462. }
  463. #endif