nodeskini 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (215) hide show
  1. package/README.md +31 -0
  2. package/client/archive/bundle.js +11528 -0
  3. package/client/archive/golem.html +60 -0
  4. package/client/archive/golemClient.js +595 -0
  5. package/client/archive/golembundle.js +11634 -0
  6. package/client/archive/sequencer.html +43 -0
  7. package/client/archive/sequenceurClient.js +815 -0
  8. package/client/archive/stylegolem.css +158 -0
  9. package/client/archive/stylesequenceur.css +204 -0
  10. package/client/clientListe/Sortable-master/.circleci/config.yml +33 -0
  11. package/client/clientListe/Sortable-master/.editorconfig +15 -0
  12. package/client/clientListe/Sortable-master/.github/ISSUE_TEMPLATE/bug-report.md +73 -0
  13. package/client/clientListe/Sortable-master/.github/ISSUE_TEMPLATE/custom-template.md +48 -0
  14. package/client/clientListe/Sortable-master/.github/ISSUE_TEMPLATE/feature-request.md +41 -0
  15. package/client/clientListe/Sortable-master/.jshintrc +25 -0
  16. package/client/clientListe/Sortable-master/.testcaferc.json +7 -0
  17. package/client/clientListe/Sortable-master/CONTRIBUTING.md +26 -0
  18. package/client/clientListe/Sortable-master/LICENSE +21 -0
  19. package/client/clientListe/Sortable-master/README.md +813 -0
  20. package/client/clientListe/Sortable-master/Sortable.js +3709 -0
  21. package/client/clientListe/Sortable-master/Sortable.min.js +2 -0
  22. package/client/clientListe/Sortable-master/Sortable.min.old.js +2 -0
  23. package/client/clientListe/Sortable-master/Sortable.min.old.old.js +2 -0
  24. package/client/clientListe/Sortable-master/babel.config.js +27 -0
  25. package/client/clientListe/Sortable-master/bower.json +30 -0
  26. package/client/clientListe/Sortable-master/entry/entry-complete.js +8 -0
  27. package/client/clientListe/Sortable-master/entry/entry-core.js +19 -0
  28. package/client/clientListe/Sortable-master/entry/entry-defaults.js +19 -0
  29. package/client/clientListe/Sortable-master/index.html +460 -0
  30. package/client/clientListe/Sortable-master/modular/sortable.complete.esm.js +3701 -0
  31. package/client/clientListe/Sortable-master/modular/sortable.core.esm.js +3698 -0
  32. package/client/clientListe/Sortable-master/modular/sortable.esm.js +3699 -0
  33. package/client/clientListe/Sortable-master/package-lock.json +5704 -0
  34. package/client/clientListe/Sortable-master/package.json +56 -0
  35. package/client/clientListe/Sortable-master/plugins/AutoScroll/AutoScroll.js +270 -0
  36. package/client/clientListe/Sortable-master/plugins/AutoScroll/README.md +80 -0
  37. package/client/clientListe/Sortable-master/plugins/AutoScroll/index.js +1 -0
  38. package/client/clientListe/Sortable-master/plugins/MultiDrag/MultiDrag.js +617 -0
  39. package/client/clientListe/Sortable-master/plugins/MultiDrag/README.md +96 -0
  40. package/client/clientListe/Sortable-master/plugins/MultiDrag/index.js +1 -0
  41. package/client/clientListe/Sortable-master/plugins/OnSpill/OnSpill.js +79 -0
  42. package/client/clientListe/Sortable-master/plugins/OnSpill/README.md +60 -0
  43. package/client/clientListe/Sortable-master/plugins/OnSpill/index.js +1 -0
  44. package/client/clientListe/Sortable-master/plugins/README.md +178 -0
  45. package/client/clientListe/Sortable-master/plugins/Swap/README.md +55 -0
  46. package/client/clientListe/Sortable-master/plugins/Swap/Swap.js +90 -0
  47. package/client/clientListe/Sortable-master/plugins/Swap/index.js +1 -0
  48. package/client/clientListe/Sortable-master/scripts/banner.js +8 -0
  49. package/client/clientListe/Sortable-master/scripts/build.js +17 -0
  50. package/client/clientListe/Sortable-master/scripts/esm-build.js +28 -0
  51. package/client/clientListe/Sortable-master/scripts/minify.js +11 -0
  52. package/client/clientListe/Sortable-master/scripts/test-compat.js +30 -0
  53. package/client/clientListe/Sortable-master/scripts/test.js +21 -0
  54. package/client/clientListe/Sortable-master/scripts/umd-build.js +15 -0
  55. package/client/clientListe/Sortable-master/src/Animation.js +175 -0
  56. package/client/clientListe/Sortable-master/src/BrowserInfo.js +12 -0
  57. package/client/clientListe/Sortable-master/src/EventDispatcher.js +57 -0
  58. package/client/clientListe/Sortable-master/src/PluginManager.js +87 -0
  59. package/client/clientListe/Sortable-master/src/Sortable.js +1971 -0
  60. package/client/clientListe/Sortable-master/src/utils.js +556 -0
  61. package/client/clientListe/Sortable-master/st/app.js +224 -0
  62. package/client/clientListe/Sortable-master/st/iframe/frame.html +32 -0
  63. package/client/clientListe/Sortable-master/st/iframe/index.html +49 -0
  64. package/client/clientListe/Sortable-master/st/logo.png +0 -0
  65. package/client/clientListe/Sortable-master/st/og-image.png +0 -0
  66. package/client/clientListe/Sortable-master/st/prettify/prettify.css +1 -0
  67. package/client/clientListe/Sortable-master/st/prettify/prettify.js +46 -0
  68. package/client/clientListe/Sortable-master/st/prettify/run_prettify.js +64 -0
  69. package/client/clientListe/Sortable-master/st/saucelabs.svg +1 -0
  70. package/client/clientListe/Sortable-master/st/theme.css +254 -0
  71. package/client/clientListe/Sortable-master/tests/Sortable.compat.test.js +39 -0
  72. package/client/clientListe/Sortable-master/tests/Sortable.test.js +386 -0
  73. package/client/clientListe/Sortable-master/tests/dual-list.html +34 -0
  74. package/client/clientListe/Sortable-master/tests/empty-list.html +30 -0
  75. package/client/clientListe/Sortable-master/tests/filter.html +27 -0
  76. package/client/clientListe/Sortable-master/tests/handles.html +27 -0
  77. package/client/clientListe/Sortable-master/tests/nested.html +67 -0
  78. package/client/clientListe/Sortable-master/tests/single-list.html +25 -0
  79. package/client/clientListe/Sortable-master/tests/style.css +18 -0
  80. package/client/clientListe/clientListe.html +148 -0
  81. package/client/clientListe/clientListe.js +1508 -0
  82. package/client/clientListe/clientListebundle.js +13164 -0
  83. package/client/clientListe/images/poubelle.png +0 -0
  84. package/client/clientListe/images/start.png +0 -0
  85. package/client/clientListe/images/stop.png +0 -0
  86. package/client/clientListe/images/submit.png +0 -0
  87. package/client/clientListe/sortable-theme-bootstrap.css +90 -0
  88. package/client/configurateur/configReact.js +273 -0
  89. package/client/configurateur/configReactbundle.js +295 -0
  90. package/client/configurateur/configurateur.css +95 -0
  91. package/client/configurateur/configurateur.html +48 -0
  92. package/client/configurateur/lib/jexcel.css +755 -0
  93. package/client/configurateur/lib/jexcel.js +14970 -0
  94. package/client/configurateur/lib/jsuites.css +2801 -0
  95. package/client/configurateur/lib/jsuites.js +11822 -0
  96. package/client/configurateur/lib/react-dom.production.min.js +239 -0
  97. package/client/configurateur/lib/react.production.min.js +32 -0
  98. package/client/configurateur/src/configReact.js +247 -0
  99. package/client/controleur/clientcontroleur.js +536 -0
  100. package/client/controleur/clientcontroleur.test.js +282 -0
  101. package/client/controleur/controleur.html +51 -0
  102. package/client/controleur/controleurbundle.js +565 -0
  103. package/client/controleur/stylecontroleur.css +236 -0
  104. package/client/controleurHH/controleurHH.html +71 -0
  105. package/client/controleurHH/controleurHH.js +252 -0
  106. package/client/controleurHH/styles/index.css +320 -0
  107. package/client/controleurHH/styles/material.css +11552 -0
  108. package/client/parametrage/paramReact.js +473 -0
  109. package/client/parametrage/paramReactbundle.js +500 -0
  110. package/client/parametrage/parametrage.css +111 -0
  111. package/client/parametrage/parametrage.html +163 -0
  112. package/client/parametrage/src/paramReact.js +459 -0
  113. package/client/score/hash.js +83 -0
  114. package/client/score/p5.min.js +3 -0
  115. package/client/score/parto1.js +1171 -0
  116. package/client/score/parto1bundle.js +1181 -0
  117. package/client/score/processing.min.js +431 -0
  118. package/client/score/score.html +15 -0
  119. package/client/score/score.js +34 -0
  120. package/client/simulateurListe/simulateurFork.js +750 -0
  121. package/client/simulateurListe/simulateurFork.mjs +681 -0
  122. package/client/simulateurListe/simulateurForkSansReorg.js +569 -0
  123. package/client/simulateurListe/simulateurListe.js +628 -0
  124. package/myReact/archive/Nodeemitvaluedlocal1.hh.js +52 -0
  125. package/myReact/archive/abort-parNode.js +79 -0
  126. package/myReact/archive/abroNode.js +169 -0
  127. package/myReact/archive/abroNode2.js +80 -0
  128. package/myReact/archive/atom.compile.hh.js +51 -0
  129. package/myReact/archive/await-countNode.js +67 -0
  130. package/myReact/archive/await-nowvalNode.js +44 -0
  131. package/myReact/archive/callHH.js +96 -0
  132. package/myReact/archive/emit-if2.hh.compiled.js +113 -0
  133. package/myReact/archive/every1Node.js +35 -0
  134. package/myReact/archive/if-runNode.js +74 -0
  135. package/myReact/archive/if1Node.js +43 -0
  136. package/myReact/archive/makeawait.js +0 -0
  137. package/myReact/archive/myReact.old.js +684 -0
  138. package/myReact/archive/orchestration.js +281 -0
  139. package/myReact/archive/orchestration1.js +132 -0
  140. package/myReact/archive/orchestration1.xml +465 -0
  141. package/myReact/archive/orchestration2.js +161 -0
  142. package/myReact/archive/orchestrationHH.mano.js +280 -0
  143. package/myReact/archive/orchestrationHHTest.js +428 -0
  144. package/myReact/archive/orchestrationHHTest.xml +234 -0
  145. package/myReact/archive/orchestrationHHTestRun.js +104 -0
  146. package/myReact/archive/orchestrationHHTestRun.xml +34 -0
  147. package/myReact/archive/orchestrationTest0.js +178 -0
  148. package/myReact/archive/orchestrationTest1.js +181 -0
  149. package/myReact/archive/orchestrationTest2.js +281 -0
  150. package/myReact/archive/run3pointsNode.js +59 -0
  151. package/myReact/archive/runNode.js +123 -0
  152. package/myReact/archive/runNode2.js +91 -0
  153. package/myReact/archive/testAwait1.js +141 -0
  154. package/myReact/archive/testAwait1.xml +86 -0
  155. package/myReact/archive/testEvery1.js +122 -0
  156. package/myReact/archive/testEvery1.xml +79 -0
  157. package/myReact/archive/testHH1.js +135 -0
  158. package/myReact/archive/testHH1.xml +86 -0
  159. package/myReact/archive/testHH1revu.js +104 -0
  160. package/myReact/archive/testHH2.js +122 -0
  161. package/myReact/archive/testHH2.xml +79 -0
  162. package/myReact/archive/testHH3.js +130 -0
  163. package/myReact/archive/testHH3.xml +86 -0
  164. package/myReact/archive/testHHabort.js +121 -0
  165. package/myReact/archive/testHHabort.xml +83 -0
  166. package/myReact/archive/testMakeawait.js +202 -0
  167. package/myReact/archive/testRun1.js +168 -0
  168. package/myReact/archive/testRun1.xml +142 -0
  169. package/myReact/archive/titi.js +28 -0
  170. package/myReact/archive/titi.xml +110 -0
  171. package/myReact/archive/toto.js +73 -0
  172. package/myReact/archive/toto.xml +198 -0
  173. package/myReact/archive/trap-await-parallelNode.js +123 -0
  174. package/myReact/inutiles/hiver2022.xml +804 -0
  175. package/myReact/inutiles/hopeNode.xml +459 -0
  176. package/myReact/inutiles/mars2022.xml +871 -0
  177. package/myReact/inutiles/mystique1.xml +318 -0
  178. package/myReact/inutiles/mystiqueOSC.xml +277 -0
  179. package/myReact/inutiles/opus5Node.xml +1271 -0
  180. package/myReact/inutiles/opus5NodeLinux.xml +1241 -0
  181. package/myReact/inutiles/orchestrationHH.xml +541 -0
  182. package/myReact/inutiles/orchestrationHH2.xml +547 -0
  183. package/myReact/inutiles/testHH.xml +95 -0
  184. package/myReact/inutiles/trouveLaPercuTenor.xml +349 -0
  185. package/myReact/myReact.js +744 -0
  186. package/myReact/myReact.min.js +1 -0
  187. package/myReact/orchestrationHH.js +311 -0
  188. package/myReact/orchestrationHH.mjs +436 -0
  189. package/myReact/orchestrationHH.mjs.map +1 -0
  190. package/package.json +46 -0
  191. package/serveur/OSCandMidi.mjs +361 -0
  192. package/serveur/computeScore.mjs +415 -0
  193. package/serveur/controleDAW.mjs +1149 -0
  194. package/serveur/defaultSession.csv +2 -0
  195. package/serveur/defaultSkiniParametres.js +119 -0
  196. package/serveur/gameOSC.mjs +96 -0
  197. package/serveur/groupeClientsSons.mjs +1014 -0
  198. package/serveur/ipConfig.json +24 -0
  199. package/serveur/ipConfig127.json +19 -0
  200. package/serveur/ipConfig75.json +17 -0
  201. package/serveur/ipConfigBH.json +19 -0
  202. package/serveur/ipConfigLocal.json +19 -0
  203. package/serveur/midiConfig.json +26 -0
  204. package/serveur/midiConfigBH.json +26 -0
  205. package/serveur/midiConfigVoid.json +3 -0
  206. package/serveur/midimix.mjs +570 -0
  207. package/serveur/saveParam.mjs +159 -0
  208. package/serveur/skiniParametres.good.js +132 -0
  209. package/serveur/skiniParametres.js +106 -0
  210. package/serveur/utilsHHSkini.hh.js +64 -0
  211. package/serveur/utilsSkini.mjs +137 -0
  212. package/serveur/websocketServer.mjs +2052 -0
  213. package/serveur/workerInterfaceZ.mjs +327 -0
  214. package/serveur/workerSynchro.mjs +49 -0
  215. package/skini.mjs +141 -0
@@ -0,0 +1,1181 @@
1
+ (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
2
+ /**************************************
3
+ SKINI
4
+
5
+ © Copyright 2019, B. Petit-Heidelein
6
+
7
+ browserify parto1.js -o parto1bundle.js
8
+
9
+ ***************************************/
10
+ "use strict"
11
+
12
+ var ipConfig = require('../../serveur/ipConfig');
13
+
14
+ var debug = false;
15
+ var debug1 = true;
16
+ var demandeDeSons = "";
17
+ var par;
18
+ var ws;
19
+ var msg;
20
+ var index = Math.floor((Math.random() * 1000000) + 1 ); // Pour identifier le client;
21
+
22
+ //var abletonON;
23
+ var refProcessing;
24
+ var noScore = false;
25
+ var displayNonActiveGroups = true;
26
+
27
+ // Pour un affichage dynamique des scènes graphique.
28
+ // Si dans le fichier de description aucune scène n'est donnée
29
+ // les éléments créés seront dans une scène 0.
30
+ var ongoingGraphicScene = [0];
31
+ var alertInfoMessage;
32
+
33
+ // Couleurs inactives en RGB
34
+ const Rinactive = 10;
35
+ const Ginactive = 10;
36
+ const Binactive = 10;
37
+
38
+ const courbure = 40;
39
+ // Paramètres graphiques
40
+ // Taille du canvas
41
+ var screenX = 1600;
42
+ var screenY = 1200;
43
+
44
+ var increaseTank = 13;
45
+
46
+ var patternGroups; // Groupes des patterns reçu du serveur
47
+
48
+ // On conçoit la partition dans un carré Xbase, Ybase
49
+ // Bases de calcul des largeur et hauteur, li'dée et de permettre un modification de la taille de
50
+ // l'écran sans toucher à la description de la partition.
51
+ // height * screenY / Ybase, width * screenX / Xbase
52
+ var Xbase = 1000;
53
+ var Ybase = 1000;
54
+
55
+ var textSize = 20 * screenY / Ybase;
56
+
57
+ /*
58
+ On utilise logosParameters pour décrire la partition.
59
+ Pour éviter des manipulations sur les accès dans le tableau groupeDesSons,
60
+ j'utilise le fait que les groupes se succèdent pour les indexer..
61
+ Du coup le champ 1 qui donne un numéro de groupe est inutile.
62
+ Par prudence je le laisse ne sachant plus trop comment il est utilisé ailleurs.
63
+ */
64
+
65
+ // La version processing.min.js ne sais pas gérer les couleur en hexa.
66
+ function hex_to_RGB(hex) {
67
+ var m = hex.match(/^#?([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i);
68
+ return [ parseInt(m[1], 16), parseInt(m[2], 16), parseInt(m[3], 16)];
69
+ }
70
+
71
+ /********************
72
+ Graphical Objects
73
+ *********************/
74
+ class Rectangle {
75
+ constructor(x,y, width, height, color, text, processing){
76
+ if (debug) console.log("constructor rectangle:", x,y, width, height, color, text);
77
+ this.x = x * screenX / Xbase;
78
+ this.y = y * screenY / Ybase;
79
+ this.height = height * screenY / Ybase;
80
+ this.width = width * screenX / Xbase;
81
+ this.colorRect = color.slice();
82
+ this.text = text;
83
+ this.message1 = "";
84
+ this.message2 = "";
85
+ this.processing = processing;
86
+ this.countSounds = "";
87
+ if (debug) console.log("Rectangle : constructor: setColor:", color, this.colorRect);
88
+ }
89
+
90
+ setSize(width, height){
91
+ this.height = height * screenY / Ybase;
92
+ this.width = width * screenX / Xbase;
93
+ }
94
+
95
+ setColor(couleur){
96
+ this.colorRect = couleur.slice(); // Pour recopier et pas assigner
97
+ if (debug) console.log("Rectangle: setColor:", couleur, this.colorRect);
98
+ }
99
+
100
+ setCoundSounds(counter){
101
+ this.countSounds = counter;
102
+ }
103
+
104
+ setMessage(message1, message2){
105
+ this.message1 = message1;
106
+ this.message2 = message2;
107
+ }
108
+
109
+ display() {
110
+ // Façon peu économique de définir les tailles des chaines de caractère pour dimensioner le rectangle
111
+ this.processing.textSize(this.height*1.5/3);
112
+ this.processing.text(this.message1.slice(0,10), this.x + 5, this.y + (this.height * 1.5/3), this.processing.textWidth(this.message1.slice(0,10)));
113
+ var localWidth1 = this.processing.textWidth(this.message1.slice(0,17));
114
+
115
+ this.processing.textSize(this.height*1/3);
116
+ this.processing.text(this.message2.slice(0,17), this.x + 5, this.y + (this.height) -5, this.processing.textWidth(this.message2.slice(0,17)));
117
+ var localWidth2 = this.processing.textWidth(this.message2.slice(0,17));
118
+
119
+ this.width = Math.max(this.width, localWidth1 + 10, localWidth2 + 10);
120
+ this.processing.fill(this.colorRect[0], this.colorRect[1], this.colorRect[2]);
121
+ this.processing.rect(this.x, this.y, this.width, this.height,this.radius);
122
+
123
+ // Affichage des textes
124
+ this.processing.fill(0); // En noir
125
+ this.processing.textSize(textSize);
126
+ this.processing.text(this.text, this.x, this.y -3 ); //, this.width, this.height);
127
+
128
+ this.processing.fill(255); // En blanc
129
+ this.processing.textSize(this.height*1.5/3);
130
+ this.processing.text(this.message1.slice(0,10), this.x + 5, this.y + (this.height * 1.5/3), this.processing.textWidth(this.message1.slice(0,10)));
131
+ this.processing.textSize(this.height*1/3);
132
+ this.processing.text(this.message2.slice(0,17), this.x + 5, this.y + (this.height) -5, this.processing.textWidth(this.message2.slice(0,17)));
133
+ //this.processing.text(this.message2.slice(0,20), this.x + 5, this.y + (this.height * 4/5));
134
+ //this.processing.text(this.countSounds, this.x + this.width/2 - 50, this.y + (this.height*3/4));
135
+ }
136
+ }
137
+
138
+ // Assignation d'une proprité à une classe
139
+ Rectangle.prototype.radius = 10;
140
+
141
+ class Ellipse {
142
+ constructor(x,y, width, height, color, text, processing){
143
+ if (debug) console.log("constructor ellipse:", x,y, width, height, color, text);
144
+ this.x = x * screenX / Xbase;
145
+ this.y = y * screenY / Ybase;
146
+ this.height = height * screenY/Ybase;
147
+ this.width = width * screenX/Xbase;
148
+ this.colorEllipse = color.slice();
149
+ this.text = text;
150
+ this.message1 = "";
151
+ this.message2 = "";
152
+ this.processing = processing;
153
+ }
154
+
155
+ setSize(width, height){
156
+ this.height = height * screenY/Ybase;
157
+ this.width = width * screenX/Xbase;
158
+ }
159
+
160
+ setColor(color){
161
+ this.colorEllipse = color.slice();
162
+ if (debug) console.log("Rectangle: setColor:", color, this.colorEllipse);
163
+ }
164
+
165
+ setMessage(message1, message2){
166
+ this.message1 = message1;
167
+ this.message2 = message2;
168
+ }
169
+
170
+ display() {
171
+ this.processing.fill(this.colorEllipse[0], this.colorEllipse[1], this.colorEllipse[2]);
172
+ // L'ellipse est centrée de façon à être dans un rectangle.
173
+ // L'idée est de garder le même modèle de coordonnée pour Rectangle et Ellipse.
174
+ this.processing.ellipse(this.x+this.width/2 , this.y+this.height/2, this.width, this.height);
175
+ this.processing.fill(0);
176
+
177
+ this.processing.textSize(textSize);
178
+ this.processing.text(this.text, this.x, this.y); //, this.width, this.height);
179
+
180
+ this.processing.fill(255); // En blanc
181
+ this.processing.textSize(this.height*1.5/3);
182
+ this.processing.text(this.message1.slice(0,10), this.x + 5, this.y + (this.height * 1.5/3), this.processing.textWidth(this.message1.slice(0,10)));
183
+ this.processing.textSize(this.height*1/3);
184
+ this.processing.text(this.message2.slice(0,18), this.x + 5, this.y + (this.height) -5, this.processing.textWidth(this.message2.slice(0,18)));
185
+ }
186
+ }
187
+
188
+ /*************************
189
+ Orchestral Objects
190
+
191
+ *************************/
192
+
193
+ class Tank extends Rectangle {
194
+ constructor(indexTank, tankNumber, x, y, color, text, previous, graphicScene, processing){
195
+ var width = 0;
196
+ var height = 0;
197
+
198
+ // Pour initialiser le rectangle
199
+ super(x, y, width, height, [Rinactive,Ginactive,Binactive],text, processing); // Attention: "super" à placer avant les références à this
200
+ this.indexTank = indexTank;
201
+
202
+ this.width = 0;
203
+ this.height = 0;
204
+ this.colorTank = color.slice();
205
+ this.tankNumber = tankNumber;
206
+ this.signalCount = 1; // au départ
207
+ this.signalCountMax = 1;
208
+ this.graphicScene = graphicScene;
209
+ this.processing = processing;
210
+ this.active = false;
211
+ this.couleurInactiveTank = [Rinactive,Ginactive,Binactive];
212
+ this.previousGroups = previous;
213
+ this.name = text;
214
+ }
215
+
216
+ decrement() {
217
+ this.signalCount--;
218
+ if (this.signalCount < 0) this.signalCount = 0; // Protection
219
+ if (debug1) console.log("decrement Group:", this.signalCount, ":", this.width, this.height);
220
+ if (this.signalCount === 0 ) {
221
+ this.active = false;
222
+ }
223
+ this.width = this.signalCount * increaseTank;
224
+ this.height = this.signalCount * increaseTank;
225
+ super.setSize(this.width, this.height);
226
+ if (this.active){
227
+ /* Il faut faire autre chose que changer la couleur
228
+ this.colorTank[0] = Math.floor(Math.random() * 255);
229
+ this.colorTank[1] = Math.floor(Math.random() * 255);
230
+ this.colorTank[2] = Math.floor(Math.random() * 255);
231
+ */
232
+ super.setColor(this.colorTank);
233
+ }else{
234
+ super.setColor([Rinactive,Ginactive,Binactive]);
235
+ }
236
+ return this.signalCount;
237
+ }
238
+
239
+ isTank(){
240
+ return true;
241
+ }
242
+
243
+ getX(){
244
+ return this.x;
245
+ }
246
+
247
+ getY(){
248
+ return this.y;
249
+ }
250
+
251
+ getWidth(){
252
+ return this.width;
253
+ }
254
+
255
+ getHeight(){
256
+ return this.height;
257
+ }
258
+
259
+ getPrevious() {
260
+ return this.previousGroups;
261
+ }
262
+
263
+ getName(){
264
+ return this.name;
265
+ }
266
+
267
+ getTankNumber(){
268
+ return this.tankNumber;
269
+ }
270
+
271
+ getIndex(){
272
+ return this.indexTank;
273
+ }
274
+
275
+ getGraphicScene(){
276
+ return this.graphicScene;
277
+ }
278
+
279
+ activate() {
280
+ super.setColor(this.colorTank);
281
+ this.active = true;
282
+ }
283
+
284
+ reactivate() {
285
+ super.setColor(this.colorTank);
286
+ this.active = true;
287
+ this.signalCount = this.signalCountMax;
288
+ }
289
+
290
+ deactivate() {
291
+ this.active = false;
292
+ super.setColor([Rinactive,Ginactive,Binactive]);
293
+ }
294
+
295
+ isActive(){
296
+ return this.active;
297
+ }
298
+
299
+ incrementSignalCount(sizeIncrease){
300
+ this.signalCount++;
301
+ this.signalCountMax = this.signalCount;
302
+ this.width = this.signalCount * sizeIncrease;
303
+ this.height = this.signalCount * sizeIncrease;
304
+ super.setSize(this.width, this.height);
305
+ if (debug) console.log("Increment tank:", this.signalCount);
306
+ return this.signalCount;
307
+ }
308
+
309
+ display(){
310
+ // Assignation d'une proprité à une classe
311
+ Rectangle.prototype.radius = 0;
312
+ this.processing.strokeWeight(3);
313
+ super.display();
314
+ }
315
+ // Appelable dans la classe, mais pas par une instance
316
+ // fonction générique (local) à une classe et pas accessible en dehors.
317
+ /* static distance(a, b) {
318
+ const dx = a.x - b.x;
319
+ const dy = a.y - b.y;
320
+ return Math.hypot(dx, dy);
321
+ }*/
322
+ }
323
+
324
+ class Group extends Rectangle {
325
+ constructor(indexGroup, signalCount, x, y, couleur, text, previous, graphicScene, processing){
326
+ var width = signalCount * 6;
327
+ var height = signalCount * 4;
328
+
329
+ // Pour initialiser le rectangle
330
+ super(x, y, width, height, [Rinactive,Ginactive,Binactive], text, processing); // Attention: "super" à placer avant les références à this
331
+ this.indexGroup = indexGroup;
332
+ this.signalCount = signalCount;
333
+ this.width = width * screenX/Xbase;
334
+ this.height = height * screenY/Ybase;
335
+ this.colorGroup = couleur;
336
+ this.graphicScene = graphicScene;
337
+ this.processing = processing;
338
+ this.active = false;
339
+ this.couleurInactiveGroup = [Rinactive,Ginactive,Binactive];
340
+ this.name = text;
341
+ // colorInactive; attention au passage des objets (objet, arrays, ) par lien (ou référence)
342
+ // Si on met couleurInactive dans le "='', on lie couleurInactiveGroup à l'objet couleurInactive
343
+ // du coup quand on appelle desactivate() on passe un lien vers le tableau couleurInactive dans le parent rectangle
344
+ // avec l'instruction super.setColor(this.couleurInactiveGroup); .
345
+ // Le this.colorRect de rectangle est alors en fait le tableau couleurInactive.
346
+ // Toute modification sur this.colorRect va en fait modifier couleurInactive.
347
+ // Pour casser ce lien il faut réassigner couleurInactiveGroup (assignement vs mutate)
348
+ this.previousGroups = previous;
349
+ this.counterOfSounds = 0;
350
+ }
351
+
352
+ increment() {
353
+ this.signalCount++;
354
+ if (debug) console.log("increment Group:", this.signalCount);
355
+
356
+ this.counterOfSounds++;
357
+ super.setCoundSounds(this.counterOfSounds);
358
+ /* Faire autre chose !!
359
+ this.colorRect[0] = Math.floor(Math.random() * 127 + 100);
360
+ this.colorRect[1] = Math.floor(Math.random() * 127 + 100);
361
+ this.colorRect[2] = Math.floor(Math.random() * 127 + 100);
362
+ */
363
+ return this.signalCount;
364
+ }
365
+
366
+ setMessage(message1, message2){
367
+ super.setMessage(message1, message2);
368
+ }
369
+
370
+ isTank(){
371
+ return false;
372
+ }
373
+
374
+ getX(){
375
+ return this.x;
376
+ }
377
+
378
+ getY(){
379
+ return this.y;
380
+ }
381
+
382
+ getWidth(){
383
+ return this.width;
384
+ }
385
+
386
+ getHeight(){
387
+ return this.height;
388
+ }
389
+
390
+ getPrevious() {
391
+ return this.previousGroups;
392
+ }
393
+
394
+ getName(){
395
+ return this.name;
396
+ }
397
+
398
+ getIndex() {
399
+ return this.indexGroup;
400
+ }
401
+
402
+ activate() {
403
+ super.setColor(this.colorGroup);
404
+ if (debug) console.log("class group: activate: ", this.name, this.colorGroup );
405
+ this.active = true;
406
+ }
407
+
408
+ deactivate() {
409
+ if (debug) console.log("deactivate rectangle:", this.name);
410
+ super.setColor([Rinactive,Ginactive,Binactive]);
411
+ this.counterOfSounds = 0;
412
+ this.active = false;
413
+ }
414
+
415
+ isActive(){
416
+ return this.active;
417
+ }
418
+
419
+ getGraphicScene(){
420
+ return this.graphicScene;
421
+ }
422
+
423
+ display(){
424
+ // Assignation d'une proprité à une classe
425
+ Rectangle.prototype.radius = 20;
426
+ super.display();
427
+ }
428
+ }
429
+
430
+ /********************************************************
431
+ Affichage des FIFOs
432
+
433
+ *********************************************************/
434
+ class infoAudience {
435
+ constructor(processing) {
436
+ this.processing = processing;
437
+ this.text = 'Texte au départ -------------------------------------------------------------';
438
+ this.x = 10;
439
+ this.y = 850;
440
+ this.height = 100 * screenY / Ybase;
441
+ this.width = 1000 * screenX / Xbase;
442
+ this.displaySpeed = 5;
443
+ this.displayCounter = 0;
444
+ this.textToDisplay = '';
445
+ this.scrollChar = 0;
446
+ this.scrollCounter = 0;
447
+ this.frameSpeed = 0;
448
+ this.frameCounter = 0;
449
+ }
450
+
451
+ setText(text){
452
+ this.text = this.text + " | " + text;
453
+ }
454
+
455
+ // Scrolling pas résolu, en cours.
456
+ display(){
457
+ this.displaySpeed = 500 / (this.text.length + 1);
458
+ this.displayCounter++;
459
+ this.frameCounter++;
460
+
461
+ if (this.displayCounter > this.displaySpeed) {
462
+ this.text = this.text.slice(1, 2000);
463
+ this.scrollChar = this.processing.textWidth(this.text.slice(0,1));
464
+ this.displayCounter = 0;
465
+ // Calcul de la vitesse en nombre de frame entre deux affichages
466
+ // de la chaine de caractère décalée d'un caractère.
467
+ this.frameSpeed = this.frameCounter;
468
+ this.frameCounter = 0;
469
+ // Re-calcul du décalage à faire en nombre de frame.
470
+ this.scrollChar = this.frameSpeed / this.scrollChar;
471
+ if (debug) console.log("displayInfoAudience:", this.frameSpeed, this.scrollChar, this.displaySpeed );
472
+ }
473
+ this.processing.fill(255);
474
+ this.processing.rect(this.x, this.y, this.width, this.height);
475
+ this.processing.fill(0);
476
+ this.processing.textSize(50);
477
+ this.textToDisplay = this.text.slice(0, 80);
478
+
479
+ if ( this.scrollCounter <= 0 ){
480
+ this.scrollCounter = this.scrollChar; // this.displaySpeed ;
481
+ this.processing.text(this.textToDisplay, this.x + 10 - this.scrollCounter, this.y + (this.height*3/4));
482
+ }
483
+ this.scrollCounter --;
484
+ }
485
+ }
486
+
487
+ class infoQueues {
488
+ constructor(processing) {
489
+ this.processing = processing;
490
+ this.xStart = 10;
491
+ this.yStart = 710 * screenY / Ybase;
492
+ this.height = ((1000 * screenY / Ybase) - this.yStart) * screenY / Ybase;
493
+ this.width = 1000 * screenX / Xbase;
494
+ this.cellWidth = 300 * screenX / Xbase ;
495
+ this.cellHeight = 30 * screenY / Ybase;
496
+ this.textToDisplay = '';
497
+ }
498
+
499
+ display(){
500
+ var texte1EnPixel = 0;
501
+ var texte2EnPixel = 0;
502
+ var largeurTexte = 0;
503
+ var legende = "En file d'attente";
504
+ var couleur = hex_to_RGB('#83614C');
505
+
506
+ // Rectangle d'encadrement
507
+ //this.processing.fill(0);
508
+ this.processing.fill(couleur[0], couleur[1], couleur[2]);
509
+
510
+ this.processing.rect(0, this.yStart, this.width, this.height);
511
+
512
+ this.processing.fill(255);
513
+ this.processing.fill(255);
514
+ // Titre du rectangle
515
+ this.processing.textSize(30);
516
+ this.processing.text(legende, this.width - (this.processing.textWidth(legende) + 3), this.yStart +30);
517
+
518
+ if(queuesMessages !== undefined){
519
+ for (var i = 0; i < queuesMessages.length ; i++ ) { // chaque Instrument
520
+ texte1EnPixel = 0;
521
+ texte2EnPixel = 0;
522
+ largeurTexte = 0;
523
+ if(queuesMessages[i][2] !== undefined){
524
+ for (var j=0; j < queuesMessages[i][2].length; j++){ // chaque Array des pseudos et noms
525
+ // Concaténation pseudo et nom
526
+ this.texte1ToDisplay = ' ' + queuesMessages[i][2][j][1];
527
+ this.texte2ToDisplay = ' (' + queuesMessages[i][2][j][0]+ ')';
528
+
529
+ this.processing.textSize(20);
530
+ texte1EnPixel = this.processing.textWidth(this.texte1ToDisplay);
531
+ //this.processing.text(this.textToDisplay, (this.width - this.cellWidth - j * this.cellWidth), (this.yStart + queuesMessages[i][0] * this.cellHeight));
532
+ this.processing.text(this.texte1ToDisplay, (largeurTexte), (this.yStart + queuesMessages[i][0] * this.cellHeight));
533
+ largeurTexte += texte1EnPixel;
534
+
535
+ this.processing.textSize(15);
536
+ texte2EnPixel = this.processing.textWidth(this.texte2ToDisplay) + 10;
537
+ this.processing.text(this.texte2ToDisplay, (largeurTexte), (this.yStart + queuesMessages[i][0] * this.cellHeight));
538
+ largeurTexte += texte2EnPixel;
539
+
540
+ //this.processing.text(this.textToDisplay, (this.width - texteEnPixel - largeurTexte), (this.yStart + queuesMessages[i][0] * this.cellHeight));
541
+
542
+ this.processing.line(0, this.yStart + queuesMessages[i][0] * this.cellHeight + 10, this.width, this.yStart + queuesMessages[i][0] * this.cellHeight + 10);
543
+ }
544
+ }
545
+ }
546
+ }
547
+ }
548
+ }
549
+
550
+
551
+ /*********************************************************
552
+ Affichage Alert et info
553
+ **********************************************************/
554
+ class alertInfo {
555
+ constructor(processing, text) {
556
+ this.processing = processing;
557
+ this.xStart = 100;
558
+ this.yStart = 250;
559
+ this.height = 250 * screenY / Ybase;
560
+ this.width = 250 * screenX / Xbase;
561
+ this.textToDisplay = text;
562
+ }
563
+
564
+ setText(text){
565
+ this.textToDisplay = text;
566
+ }
567
+
568
+ display(){
569
+ this.processing.textSize(90);
570
+ var texteEnPixel = this.processing.textWidth(this.textToDisplay) + 10;
571
+ // Rectangle d'encadrement
572
+ this.processing.fill(0);
573
+ this.processing.rect(this.xStart, this.yStart, texteEnPixel, this.height);
574
+ // Texte
575
+ this.processing.fill(255);
576
+ //this.processing.textAlign(CENTER, CENTER);
577
+ this.processing.text(this.textToDisplay, this.xStart + 5, this.yStart + this.height/2 );
578
+ //this.processing.textAlign(RIGHT, BOTTOM);
579
+ }
580
+ }
581
+
582
+ /*********************************************************
583
+ Gestion des scènes graphiques
584
+
585
+ **********************************************************/
586
+
587
+ function isInOngoingGraphicScene(scene){
588
+ for (var i=0; i < ongoingGraphicScene.length; i++){
589
+ if ( ongoingGraphicScene[i] === scene) return true;
590
+ }
591
+ return false;
592
+ }
593
+
594
+ function addSceneScore(scene){
595
+ // Déjà là
596
+ for (var i=0; i < ongoingGraphicScene.length; i++){
597
+ if ( ongoingGraphicScene[i] === scene){
598
+ return true;
599
+ }
600
+ }
601
+ // Un espace libre ?
602
+ for (var i=0; i < ongoingGraphicScene.length; i++){
603
+ if ( ongoingGraphicScene[i] === -1) {
604
+ ongoingGraphicScene[i] = scene;
605
+ return true;
606
+ }
607
+ }
608
+ ongoingGraphicScene.push(scene);
609
+ return true;
610
+ }
611
+
612
+ function removeSceneScore(scene){
613
+ if( ongoingGraphicScene[ongoingGraphicScene.length - 1] === scene){
614
+ ongoingGraphicScene.pop();
615
+ return true;
616
+ }else{
617
+ for (var i=0; i < ongoingGraphicScene.length; i++){
618
+ if ( ongoingGraphicScene[i] === scene){
619
+ ongoingGraphicScene[i] = -1;
620
+ return true;
621
+ }
622
+ }
623
+ }
624
+ }
625
+
626
+ /**************************
627
+ Processing sketch
628
+ ***************************/
629
+ var groups;
630
+ var tanks;
631
+ var displayAudience;
632
+ var displayQueues;
633
+ var queuesMessages = [];
634
+
635
+ // Simple way to attach js code to the canvas is by using a function
636
+ function sketchProc(processing) {
637
+ var xPrev;
638
+ var widthPrev;
639
+ var yPrev;
640
+ var heightPrev;
641
+ var xStart;
642
+ var yStart;
643
+ var xEnd;
644
+ var yEnd;
645
+ var prevTankNumber = -1;
646
+
647
+ refProcessing = processing; // Pour appeler setup depuis le listener
648
+
649
+ function createTank(index, indexGroup){
650
+ var scene = 0;
651
+
652
+ if (patternGroups[index][8] !== undefined ){
653
+ scene = patternGroups[index][8];
654
+ }
655
+ if (debug1) console.log("createTank:", patternGroups[index][0]);
656
+ groups[indexGroup] = new Tank(
657
+ patternGroups[index][1], // index du tank
658
+ patternGroups[index][5], // numéro du tank
659
+ patternGroups[index][3], // x
660
+ patternGroups[index][4], // y
661
+ hex_to_RGB(patternGroups[index][6]), // color
662
+ patternGroups[index][0], // name
663
+ patternGroups[index][7], // Antécédents
664
+ scene, // Scène graphique
665
+ processing);
666
+ }
667
+
668
+ processing.setup = function() {
669
+ // Création et remplissage du tableau des "groups" et des "tanks"
670
+ groups = new Array(patternGroups.length);
671
+
672
+ var groupsCounter = 0; // index dans l'array groups des objets graphiques
673
+ var sceneGroupe = 0;
674
+
675
+ for (var i=0; i < patternGroups.length; i++) {
676
+ if (patternGroups[i][2] == undefined) {
677
+ alert("ERR: No score defined, choose a score in the controler.");
678
+ noScore = true;
679
+ return;
680
+ }else{
681
+ noScore = false;
682
+ if (patternGroups[i][2] == "group") {
683
+ if (debug) console.log("This one is group", patternGroups[i], groupsCounter);
684
+ if (patternGroups[i][8] !== undefined ){
685
+ sceneGroupe = patternGroups[i][8];
686
+ }else{
687
+ sceneGroupe = 0;
688
+ }
689
+
690
+ groups[groupsCounter] = new Group(
691
+ patternGroups[i][1], // index du groupe
692
+ patternGroups[i][5], // nbe d'éléments
693
+ patternGroups[i][3], // x
694
+ patternGroups[i][4], // y
695
+ hex_to_RGB(patternGroups[i][6]), //color
696
+ patternGroups[i][0], //name
697
+ patternGroups[i][7], // Antécédents
698
+ sceneGroupe, // Scène graphique
699
+ processing);
700
+ groupsCounter++;
701
+ }else if(patternGroups[i][2] == "tank"){
702
+ if (debug) console.log("This one is the tank:", patternGroups[i][0]);
703
+ if ( i > 0){
704
+ // C'est ici que l'on gére les tanks de façon séquentielle
705
+ // On regarde si le prédécesseur est dans le même tank.
706
+ // Cela pose une contrainte sur le fichier de configuration graphique.
707
+ // Il faut que des groupes dans un même tank se suivent.
708
+ if (groups[groupsCounter-1].isTank()){
709
+ if (debug) console.log("Previous is the tank:", groups[groupsCounter-1].getName());
710
+ if(groups[groupsCounter-1].getTankNumber() == patternGroups[i][5]) {
711
+ if (debug) console.log("We are in the same tank number:", groups[groupsCounter-1].getTankNumber() );
712
+ groups[groupsCounter-1].incrementSignalCount(increaseTank);
713
+
714
+ }else{
715
+ if (debug) console.log("We are not in the same tank:", groups[groupsCounter-1].getTankNumber());
716
+ // !! i dans createTank ??
717
+ createTank(i, groupsCounter);
718
+ groupsCounter++;
719
+ }
720
+ }else{
721
+ if (debug) console.log("Previous is not a tank, create the tank");
722
+ createTank(i, groupsCounter);
723
+ groupsCounter++;
724
+ }
725
+ }else{
726
+ if (debug) console.log("we are the first of tanks and groups ")
727
+ createTank(i, groupsCounter);
728
+ groupsCounter++;
729
+ }
730
+ }else{
731
+ // Ni group, ni tank, donc on n'affichera pas dans score
732
+ if (debug) console.log("Not a group or a tank ");
733
+ }
734
+ }
735
+ }
736
+ if(debug) console.log("setup: Groups:", groups);
737
+ processing.size(screenX,screenY);
738
+ processing.stroke(126);
739
+ processing.strokeWeight(3);
740
+
741
+ displayAudience = new infoAudience(processing);
742
+ displayQueues = new infoQueues(processing);
743
+ }
744
+
745
+ // Façon d'utiliser la souris
746
+ /*processing.mouseMoved = function () {
747
+ console.log("mouse moved:", processing.mouseX, processing.mouseY);
748
+ processing.ellipse(processing.mouseX, processing.mouseY, 50,50);
749
+ if(processing.mouseIsPressed) {
750
+ console.log("mouse pressed:", processing.mouseX, processing.mouseY);
751
+ processing.ellipse(processing.mouseX, processing.mouseY, 100,100);
752
+ }
753
+ }
754
+ */
755
+ processing.draw = function() {
756
+ // erase background
757
+ processing.background(224);
758
+ if (noScore) return;
759
+
760
+ //displayAudience.display();
761
+ displayQueues.display();
762
+
763
+ // Display groups et tanks
764
+ for (var i=0; i < groups.length; i++) {
765
+ // Quand il ya des tanks, le nombre de groupes sera < au tableau patternGroups
766
+ if (groups[i] == undefined) {
767
+ break;
768
+ }
769
+ if (groups[i].isActive() || displayNonActiveGroups){ // On n'affiche que les groupes actifs
770
+ // On épaissit les bords en fonction du nombre d'activation
771
+ if (!groups[i].isTank()) processing.strokeWeight(groups[i].counterOfSounds);
772
+ if( isInOngoingGraphicScene(groups[i].getGraphicScene())){
773
+ groups[i].display();
774
+ }
775
+ processing.strokeWeight(3);
776
+ }
777
+
778
+ // Affichage des liens
779
+ // Repérage des antécédents (prev)
780
+ var IndexPrev = groups[i].getPrevious();
781
+ if (IndexPrev.length > 1 ){
782
+ for (var j=0; j < IndexPrev.length; j++ ) {
783
+ // On ne relie que des groupes actifs
784
+ if(groups[ IndexPrev[j] ].isActive() && groups[i].isActive() || displayNonActiveGroups){
785
+
786
+ // On ne relie que si la scène graphique est != 0
787
+ if(isInOngoingGraphicScene(groups[ IndexPrev[j] ].getGraphicScene()) &&
788
+ isInOngoingGraphicScene(groups[i].getGraphicScene())) {
789
+ // coordonnées en (xPrev + widthPrev, Yprev + heightPrev/2)
790
+ xPrev = groups[ IndexPrev[j] ].getX();
791
+ widthPrev = groups[ IndexPrev[j] ].getWidth();
792
+ xStart = xPrev + widthPrev;
793
+ yPrev = groups[ IndexPrev[j] ].getY();
794
+ heightPrev = groups[ IndexPrev[j] ].getHeight();
795
+ yStart = yPrev + heightPrev/2;
796
+
797
+ xEnd = groups[i].getX();
798
+ yEnd = groups[i].getY() + groups[i].getHeight()/2;
799
+ processing.noFill();
800
+ // Triangle en fin de courbe
801
+ processing.triangle( xEnd-10, yEnd-5, xEnd-10, yEnd+5, xEnd, yEnd);
802
+ xEnd -= 10;
803
+ processing.bezier(xStart,yStart, xStart+courbure, yStart, xEnd-courbure,yEnd, xEnd,yEnd);
804
+ }
805
+ }
806
+ }
807
+ }
808
+ }
809
+ // Message qui prend le dessus sur le score
810
+ if (alertInfoMessage !== undefined){
811
+ alertInfoMessage.display();
812
+ }
813
+ }
814
+ }
815
+
816
+ /****************************
817
+ Main
818
+ ****************************/
819
+ var canvas;
820
+ // Il faut initialiser le canvas une seule fois
821
+ // donc la première fois que l'on charge un fichier de config.
822
+ function start() {
823
+ if(canvas === undefined){
824
+ canvas = document.getElementById("canvas1");
825
+ // attaching the sketchProc function to the canvas
826
+ var p = new Processing(canvas, sketchProc);
827
+ }
828
+ }
829
+ window.start = start;
830
+
831
+ /*********************************************************************************
832
+ Communication listeners
833
+
834
+ **********************************************************************************/
835
+
836
+ // Fonctions uniquement utilisées par les listeners *************************************
837
+
838
+ function isTank(nomDeGroupe){
839
+ var isTank = false;
840
+ for(var i=0; i < patternGroups.length; i++){
841
+ if( patternGroups[i][0] == nomDeGroupe) {
842
+ if ( patternGroups[i][2] == "tank"){
843
+ isTank = true ;
844
+ }
845
+ break;
846
+ }
847
+ }
848
+ if (debug) console.log("isTank ?:", isTank);
849
+ return isTank;
850
+ }
851
+
852
+ function isTankFromNumOfGroup(numOfGroup){
853
+ var isTank = false;
854
+ if( patternGroups === undefined) return false;
855
+ for(var i=0; i < patternGroups.length; i++){
856
+ if( patternGroups[i][1] == numOfGroup) {
857
+ if ( patternGroups[i][2] == "tank"){
858
+ isTank = true ;
859
+ }
860
+ break;
861
+ }
862
+ }
863
+ return isTank;
864
+ }
865
+
866
+ function getGroupNumber(nomDeGroupe){
867
+ var groupeDeSons;
868
+ if (debug) console.log("Groupe pour groupname:", nomDeGroupe);
869
+ for(var i=0; i < groups.length; i++){
870
+ if(groups[i].getName() == nomDeGroupe) {
871
+ groupeDeSons = i ;
872
+ break;
873
+ }
874
+ }
875
+ return groupeDeSons;
876
+ }
877
+
878
+ function getNumberInGroupsFromNumberInConf(numOfGroup){
879
+ var groupeDeSons;
880
+ if (debug) console.log("getNumberInGroupsFromNumberInConf:", numOfGroup, groups);
881
+ if( groups === undefined) return -1;
882
+ for(var i=0; i < groups.length; i++){
883
+ if (debug) console.log("getNumberInGroupsFromNumberInConf:groups[i]:", groups[i] );
884
+ if(groups[i].getIndex() == numOfGroup) {
885
+ groupeDeSons = i ;
886
+ break;
887
+ }
888
+ }
889
+ return groupeDeSons;
890
+ }
891
+
892
+ function getTankNumberFromGroupName(nomDeGroupe) {
893
+ if (debug) console.log("getTankNumberFromGroupName: Tank number pour groupname:", nomDeGroupe, patternGroups );
894
+ var tankNumber;
895
+ if( patternGroups === undefined) return -1;
896
+ for(var i=0; i < patternGroups.length; i++){
897
+ if( patternGroups[i][0] == nomDeGroupe) {
898
+ tankNumber = patternGroups[i][5];
899
+ break;
900
+ }
901
+ }
902
+ return tankNumber;
903
+ }
904
+
905
+ function getTankNumberFromNumberInConf(numInConf) {
906
+ var tankNumber;
907
+ for(var i=0; i < patternGroups.length; i++){
908
+ if( patternGroups[i][1] == numInConf) {
909
+ tankNumber = patternGroups[i][5];
910
+ if (debug) console.log("getTankNumberFromNumberInConf:", patternGroups[i], tankNumber );
911
+ break;
912
+ }
913
+ }
914
+ return tankNumber;
915
+ }
916
+
917
+ function getGroupOfSoundsFromTankNumber(tankNumber){
918
+ var groupeDeSons = -1;
919
+ if(groups === undefined) return -1;
920
+ for(var i=0; i < groups.length; i++){
921
+ if (groups[i].isTank() ){
922
+ if(groups[i].getTankNumber() == tankNumber) {
923
+ if (debug) console.log("getGroupOfSoundsFromTankNumber:", groupeDeSons, tankNumber );
924
+ groupeDeSons = i ;
925
+ break;
926
+ }
927
+ }
928
+ }
929
+ return groupeDeSons;
930
+ }
931
+
932
+ function getPatternGroups(){
933
+ var msg = {
934
+ type:"getPatternGroups",
935
+ id: index
936
+ }
937
+ ws.send(JSON.stringify(msg));
938
+ }
939
+ window.getPatternGroups = getPatternGroups;
940
+
941
+ /* Les listeners *****************************************************************************/
942
+
943
+ //************ WEBSOCKET HOP et listener BROADCAST ******************************
944
+ function initWSSocket(host) {
945
+ ws = new WebSocket("ws://" + host + ":" + ipConfig.websocketServeurPort); // NODE JS
946
+
947
+ if (debug1) console.log("score.js ws://" + host + ":" + ipConfig.websocketServeurPort );
948
+ ws.onopen = function( event ) {
949
+ var msg = {
950
+ type:"startSpectateur",
951
+ text: "score",
952
+ id: index
953
+ }
954
+ console.log("ID sent to server:", msg.id);
955
+ ws.send(JSON.stringify(msg));
956
+
957
+ var msg = {
958
+ type:"getPatternGroups",
959
+ id: index
960
+ }
961
+ ws.send(JSON.stringify(msg));
962
+ };
963
+
964
+ //Traitement de la Réception sur le client
965
+ ws.onmessage = function( event ) {
966
+ //console.log( "Client: received [%s]", event.data );
967
+
968
+ var msgRecu = JSON.parse(event.data);
969
+ if(debug) console.log("message reçu: ", msgRecu.type);
970
+
971
+ switch(msgRecu.type) {
972
+
973
+ case 'addSceneScore':
974
+ if (debug1) console.log("Reçu addScenceScore:", msgRecu.value );
975
+ addSceneScore(msgRecu.value);
976
+ break;
977
+
978
+ // Pour activer un affichage d'info
979
+ case 'alertInfoScoreON':
980
+ if (refProcessing !== undefined){
981
+ alertInfoMessage = new alertInfo(refProcessing, msgRecu.value);
982
+ }
983
+ break;
984
+
985
+ // Pour désactiver un affichage d'info
986
+ case 'alertInfoScoreOFF':
987
+ alertInfoMessage = undefined;
988
+ break;
989
+
990
+ case 'etatDeLaFileAttente':
991
+ queuesMessages = [];
992
+ for (var i = 0; i < msgRecu.value.length ; i++ ) {
993
+ queuesMessages[i] = msgRecu.value[i];
994
+ // voir displayQueue de controleDAW pour la structure de queueMessages
995
+ // [i, filesDattente[i].length, contenuDeLaFile]
996
+ if(debug) console.log("etatDeLaFileAttente:", i, "--", queuesMessages[i]);
997
+ }
998
+ break;
999
+
1000
+ // Action sur sur les sons qui sont joués
1001
+ case 'infoPlayDAW':
1002
+ var groupeDeSons;
1003
+ if (debug) console.log("Reçu Texte Broadcast infoPlayDAW: msgRecu.value:", msgRecu.value[5], msgRecu.value[7]);
1004
+
1005
+ displayAudience.setText(msgRecu.value[5] + " - " + msgRecu.value[7]);
1006
+ // Event.value = bus, channel, note, velocity, wsid, pseudo, dureeClip, nom, signal
1007
+ // Celle-là elle ne s'invente pas, récupération du nom du groupe dans le signal
1008
+ var groupName = Object.keys(msgRecu.value[8])[0].slice(0, -2);
1009
+ if (debug) console.log("Reçu Texte Broadcast infoPlayDAW: groupName:", groupName);
1010
+
1011
+ var tankNumber;
1012
+
1013
+ if ( patternGroups !== undefined) {
1014
+ if (!isTank(groupName)) {
1015
+ // S'il s'agit d'un "group" recherche du groupe de son pour le signal donné
1016
+ // dans le tableau des groups et tanks consécutifs
1017
+ var groupNumber = getGroupNumber(groupName);
1018
+ if(debug) console.log("infoPlayDAW:groupNumber", groupNumber);
1019
+ if(groupNumber === undefined){
1020
+ if(debug) console.log("infoPlayDAW:groupNumber: undefined");
1021
+ break;
1022
+ }
1023
+
1024
+ var groupRunning = groups[groupNumber];
1025
+
1026
+ if (groupRunning.isActive()){
1027
+ groupRunning.setMessage(msgRecu.value[5], msgRecu.value[7]);
1028
+ groupRunning.increment();
1029
+ }
1030
+ } else {
1031
+ // S'il s'agit d'un "tank"
1032
+ if (debug) console.log("Reçu Texte Broadcast infoPlayDAW: groupName", groupName );
1033
+ var tankNumber = getTankNumberFromGroupName(groupName);
1034
+ if(tankNumber === -1){
1035
+ if(debug) console.log("infoPlayDAW: getTankNumberFromGroupName retourne ERR: ", groupName);
1036
+ break;
1037
+ }
1038
+ var desSons = getGroupOfSoundsFromTankNumber(tankNumber);
1039
+ if(desSons === -1){
1040
+ if(debug) console.log("infoPlayDAW: getGroupOfSoundsFromTankNumber retourne ERR");
1041
+ break;
1042
+ }
1043
+
1044
+ if (desSons < 0 ) console.log("ERR: addEventListener: infoPlayAbleton: getGroupOfSoundsFromTankNumber ");
1045
+ groups[desSons].setMessage(msgRecu.value[5], msgRecu.value[7]);
1046
+ groups[desSons].decrement();
1047
+ }
1048
+ }
1049
+ break;
1050
+
1051
+ // Pour désactiver un réservoir quand il est aborté dans la pièce.
1052
+ case 'killTank':
1053
+ var tankNumber = getTankNumberFromGroupName( msgRecu.value );
1054
+ if(tankNumber === -1){
1055
+ if(debug) console.log("killTank: getTankNumberFromGroupName retourne ERR");
1056
+ break;
1057
+ }
1058
+ var desSons = getGroupOfSoundsFromTankNumber(tankNumber);
1059
+ if(desSons === -1){
1060
+ if(debug) console.log("killTank: getGroupOfSoundsFromTankNumber retourne ERR");
1061
+ break;
1062
+ }
1063
+ if (debug) console.log("KILL TANK:", msgRecu.value, tankNumber, desSons );
1064
+ groups[desSons].deactivate();
1065
+ break;
1066
+
1067
+ // Remise à l'état d'origine des éléments
1068
+ case 'refreshSceneScore':
1069
+ if (debug1) console.log("Reçu refreshSceneScore:", msgRecu.value );
1070
+ if ( refProcessing !== undefined && patternGroups !== undefined ){
1071
+ refProcessing.setup();
1072
+ }
1073
+ break;
1074
+
1075
+ // Enlève une scène graphique
1076
+ case 'removeSceneScore':
1077
+ if (debug1) console.log("Reçu removeSceneScore:", msgRecu.value );
1078
+ removeSceneScore(msgRecu.value);
1079
+ break;
1080
+
1081
+ /* Info sur changement de la matrice des possibles */
1082
+ /* Ici on sait seulement si un groupe est activé ou désactivé.
1083
+ Il n'y a pas de notion de réservoir dans le protocole.
1084
+ Un réservoir est un ensemble de groupes ayant chacun un seul son.
1085
+ Il n'y a donc pas de notion d'activation ou désactivation de réservoir.
1086
+
1087
+ Dans le cas d'un réservoir ce listener donne une information que
1088
+ l'on a déjà reçue dans infoPlayAbleton car pour un réservoir un son joué implique
1089
+ une modification de la matrice des possibles.
1090
+ */
1091
+ case 'setInMatriceDesPossibles':
1092
+ var groupsNumber;
1093
+ if (debug1) console.log("Reçu setInMatriceDesPossibles:", msgRecu.value );
1094
+ // [0] = groupe de clients, [1] = index du groupe de son dans le tableau du fichier de conf, [2] = true ot false
1095
+ if ( isTankFromNumOfGroup(msgRecu.value[1])){
1096
+ var tankNumber = getTankNumberFromNumberInConf(msgRecu.value[1]);
1097
+ groupsNumber = getGroupOfSoundsFromTankNumber(tankNumber);
1098
+ if (groupsNumber < 0 ) console.log("ERR: addEventListener: setInMatriceDesPossibles: getGroupOfSoundsFromTankNumber ");
1099
+ }else{
1100
+ groupsNumber = getNumberInGroupsFromNumberInConf(msgRecu.value[1]);
1101
+ if(groupsNumber === -1) break;
1102
+ }
1103
+
1104
+ if (msgRecu.value[2]) { // On or Off
1105
+ groups[groupsNumber].activate();
1106
+ }else{
1107
+ if( groups[groupsNumber] !== undefined){
1108
+ if (!groups[groupsNumber].isTank()){
1109
+ groups[groupsNumber].deactivate();
1110
+ }
1111
+ }
1112
+ }
1113
+ break;
1114
+
1115
+ // Réception des groupes de patterns
1116
+ case 'setPatternGroups':
1117
+ if(debug) console.log("setPatternGroups: ", msgRecu.value);
1118
+ if ( msgRecu.value !== undefined ) {
1119
+ patternGroups = msgRecu.value ;
1120
+ noScore = false;
1121
+ start();
1122
+ if (refProcessing !== undefined){
1123
+ refProcessing.setup();
1124
+ }
1125
+ }
1126
+ break;
1127
+
1128
+ case 'startTank':
1129
+ var tankNumber = getTankNumberFromGroupName( msgRecu.value );
1130
+
1131
+ if(tankNumber === -1){
1132
+ if(debug1) console.log("startTank: getTankNumberFromGroupName retourne ERR: ", msgRecu.value, ": tankNumber :", tankNumber);
1133
+ break;
1134
+ }
1135
+ var desSons = getGroupOfSoundsFromTankNumber(tankNumber);
1136
+ if(desSons === -1){
1137
+ if(debug) console.log("startTank: getGroupOfSoundsFromTankNumber retourne ERR");
1138
+ break;
1139
+ }
1140
+ if (debug) console.log("START TANK:", msgRecu.value, tankNumber, desSons );
1141
+ groups[desSons].reactivate();
1142
+ break;
1143
+
1144
+ default: if (debug) console.log("Le Client reçoit un message inconnu", msgRecu );
1145
+ }
1146
+ };
1147
+
1148
+ ws.onerror = function (event) {
1149
+ if (debug) console.log( "clientcontroleur.js : received error on WS", ws.socket, " ", event );
1150
+ }
1151
+
1152
+ // Mécanisme de reconnexion automatique si le serveur est tombé.
1153
+ // Le service Ping permet de vérifier le présence du serveur
1154
+ ws.onclose = function( event ) {
1155
+ if (debug1) console.log( "clientcontroleur.js : ON CLOSE");
1156
+ }
1157
+ }
1158
+ window.initWSSocket = initWSSocket;
1159
+
1160
+ },{"../../serveur/ipConfig":2}],2:[function(require,module,exports){
1161
+ module.exports={
1162
+ "remoteIPAddressImage": "localhost",
1163
+ "remoteIPAddressSound": "localhost",
1164
+ "remoteIPAddressLumiere": "localhost",
1165
+ "remoteIPAddressGame": "localhost",
1166
+ "serverIPAddress": "localhost",
1167
+ "webserveurPort": 8080,
1168
+ "websocketServeurPort": 8383,
1169
+ "InPortOSCMIDIfromDAW": 13000,
1170
+ "OutPortOSCMIDItoDAW": 12000,
1171
+ "portOSCToGame": 1000,
1172
+ "portOSCFromGame": 3005,
1173
+ "distribSequencerPort": 8888,
1174
+ "outportProcessing": 10000,
1175
+ "outportLumiere": 7700,
1176
+ "inportLumiere": 9000,
1177
+ "sessionPath": "./pieces/",
1178
+ "piecePath" : "./pieces/"
1179
+ }
1180
+
1181
+ },{}]},{},[1]);