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,684 @@
1
+ "use strict"
2
+
3
+ /*------------------------------------------------------------------------------
4
+ 3052021-1
5
+
6
+ myReact.js
7
+
8
+ Début : 14/4/2021
9
+
10
+ Il s'agit de simuler (mimer) quelques fonctions de bases de la programmation
11
+ réactive utiles pour Skini.
12
+ Il ne s'agit pas d'un compilateur Estérel ni HipHop (loin de là).
13
+
14
+ On utilise la notion de signaux et la notion de réaction.
15
+
16
+ Un programme ou une branche de programme sont des tableaux d'objets 'instructions'
17
+ qui sont exécutées en séquence.
18
+ Une 'instruction' peuvent inclure
19
+ d'autres branches d'instructions comme par, seq ou abort.
20
+
21
+ L'exécution du programme consiste à dérouler les branches.
22
+ Le principe de base est qu'une instruction qui a été exécutée
23
+ ne l'est plus par la suite si on ne la réactive pas.
24
+
25
+ Les commandes réactives sont:
26
+ -----------------------------
27
+ await_do: d'un signal et de son décompte
28
+ await: d'un signal et de son décompte
29
+ atom: execution d'une fonction
30
+ emit: pour l'émission d'un signal dans le programme
31
+ seq: pour une branche à jouer en séquence
32
+ par: pour une branche dont les sous branches se jouent en parallèle, !! l'ordre dans 'par' joue.
33
+ every: pour une branche qui est joué à chaque occurence d'un signal
34
+ abort: pour tuer une branche à l'occurence d'un signal
35
+ loop: boucle
36
+ run: en fait comme seq
37
+
38
+ En intégration de la réaction dans un programme JavaScript:
39
+ -----------------------------
40
+ addEventListener: sur emit
41
+ activateSignal: avant l'appel d'une réaction
42
+
43
+ A faire:
44
+ --------
45
+ sustain
46
+ suspend
47
+
48
+ Ce qu'il n'y a pas:
49
+ -------------------
50
+ -> trap: La difficulté de trap est la mise en place de l'exit du trap. A réfléchir.
51
+ Nous n'avons pas la finesse d'Estérel sur la gestion des signaux. trap et abort seraient
52
+ sans doute équivalents ici.
53
+
54
+ -> nowval, preval : les signaux sont des paramètres des instructions.
55
+ Il n'existe pas de façon globale. La notion de signal globale existe (objet signal)
56
+ pour créer un lien d'un signal vers une action pour les eventListeners.
57
+ On a donc une même action pour plusieurs signaux de même nom qui sont associés
58
+ à des instructions. On pourrait traiter des valeurs au niveau global,
59
+ il faut être prudent sur l'impact et la confusion que ça peut créer avec
60
+ les signaux associés aux instructions. nowval de quoi ? de l'objet signal global ou
61
+ du signal présent dans l'instruction ?
62
+ S'il s'agit uniquement de valeurs pour des tests les objets "signal" devrait être suffisants.
63
+
64
+ -> Opérations logique sur les signaux, faisable si nowal, mais est-ce utile pour Skini ?
65
+
66
+ de deteriminisme, de détection de cycle de causalité.
67
+
68
+ --------------------------------------------------------------------------------*/
69
+ // signals est utilisé pour les addEventListeners,
70
+ // les véritables signaux sont locaux aux instructions
71
+ var signals = [];
72
+
73
+ var debug = false;
74
+ var debug1 = true;
75
+ var program;
76
+
77
+ /*============================================================
78
+ *
79
+ * Les objets signaux et leurs traitements
80
+ *
81
+ *
82
+ =============================================================*/
83
+
84
+ // La décalaration des signaux ne sert que
85
+ // pour les actions de playEventListener
86
+ // utlisées par emit.
87
+ function createSignal( sig, val ){
88
+ var oneSignal = {
89
+ name: sig,
90
+ activated: false,
91
+ value: val,
92
+ action: undefined,
93
+ }
94
+ signals.push(oneSignal);
95
+ }
96
+ exports.createSignal =createSignal;
97
+
98
+ function addEventListener(sig , action) {
99
+ for(var i=0; i < signals.length; i++){
100
+ if (signals[i].name === sig ){
101
+ signals[i].action = action;
102
+ return true;
103
+ }
104
+ }
105
+ console.log("ERR: addEventListener: signal inconnu:", sig);
106
+ return -1;
107
+ }
108
+ exports.addEventListener = addEventListener;
109
+
110
+ function playEventListener(sig, val) {
111
+ for(var i=0; i < signals.length; i++){
112
+ if(signals[i].name === sig){
113
+ if (signals[i].action !== undefined){
114
+ signals[i].action(val);
115
+ return true;
116
+ }else{
117
+ return true;
118
+ }
119
+ }
120
+ }
121
+ console.log("ERR: playEventListener: signal inconnu:", sig, val);
122
+ return -1;
123
+ }
124
+ exports.playEventListener = playEventListener;
125
+
126
+ // Pour mis à jour de la valeur dans le tableau signals
127
+ // Pas utile pour le moment avec le playEventListener ci-dessus qui
128
+ // prend la valeur en paramètre. Mais pourra être utile pour des test sur des
129
+ // valeur de signaux.
130
+ function setSignalValue(val){
131
+ for(var i=0; i < signals.length; i++){
132
+ if(signals[i].name === sig){
133
+ signals[i].value = val;
134
+ return true;
135
+ }
136
+ }
137
+ console.log("ERR: setSignalValue: signal inconnu:", sig);
138
+ return -1;
139
+ }
140
+ exports.setSignalValue = setSignalValue;
141
+
142
+ function getSignalValue(val){
143
+ for(var i=0; i < signals.length; i++){
144
+ if(signals[i].name === sig){
145
+ return signals[i].value;
146
+ }
147
+ }
148
+ console.log("ERR: getSignalValue: signal inconnu:", sig);
149
+ return -1;
150
+ }
151
+ exports.getSignalValue = getSignalValue;
152
+
153
+ function isSignalActivated(sig){
154
+ for(var i=0; i < signals.length; i++){
155
+ if(signals[i].name === sig){
156
+ return signals[i].activated;
157
+ }
158
+ }
159
+ console.log("ERR: isSignalActivated: signal inconnu:", sig);
160
+ return -1;
161
+ }
162
+
163
+ function setSignalActivated(sig, val){
164
+ for(var i=0; i < signals.length; i++){
165
+ if(signals[i].name === sig){
166
+ signals[i].activated = val;
167
+ return true;
168
+ }
169
+ }
170
+ console.log("ERR: setSignalValue: signal inconnu:", sig);
171
+ return -1;
172
+ }
173
+
174
+ function isSignalActivatedInInstruction(instr, signal){
175
+ if(instr.signal === signal){
176
+ if(instr.signalActivated) return true;
177
+ }
178
+ return false;
179
+ }
180
+
181
+ // Quand on active un signal c'est pour tout le programme
182
+ // idée de broadcast
183
+ function activateSignal(sig){
184
+ if(debug) console.log("activateSignal", sig, val);
185
+ setSignalAll(program, sig, true);
186
+ return true;
187
+ }
188
+ exports.activateSignal = activateSignal;
189
+
190
+ function setSignal(instr, sig, activated){
191
+ if(instr === undefined) return;
192
+
193
+ for(var i=0; i < instr.length; i++){
194
+ if(instr[i].signal === sig){
195
+ instr[i].signalActivated = activated;
196
+ }
197
+ if(debug) console.log("-- setSignal", instr[i].name,
198
+ instr[i].signal, instr[i].signalActivated);
199
+
200
+ setSignal(instr[i].nextInstr, sig, activated);
201
+ }
202
+ }
203
+
204
+ function setSignalAll(prog, sig, activated){
205
+ if(debug) console.log("- setSignalAll");
206
+ setSignal(prog.instructions, sig, activated);
207
+ }
208
+ exports.printProgram = printProgram;
209
+
210
+ /*============================================================
211
+ *
212
+ * Gestion des instructions du programme
213
+ * Un programme est un arbre d'objets instructions
214
+ *
215
+ =============================================================*/
216
+
217
+ var instrIndex = 0;
218
+
219
+ function createInstruction(name, signal, nowval, count, action, nextInstr){
220
+ var instruction = {
221
+ name: name,
222
+ signal: signal,
223
+ signalActivated: false,
224
+ nowval: nowval,
225
+ count: 0,
226
+ countMax: count,
227
+ action: action,
228
+ burnt: false,
229
+ broadcast: false,
230
+ nextInstr: nextInstr,
231
+ index: instrIndex
232
+ };
233
+
234
+ if(debug) console.log("createInstruction", instruction.name, instruction.signal,
235
+ instruction.nowval, instruction.index);
236
+
237
+ instrIndex++;
238
+ return instruction;
239
+ }
240
+ exports.createInstruction = createInstruction;
241
+
242
+ // Retourne true si l'instruction se joue à l'instant
243
+ // ou a déjà été jouée (elle est brulée).
244
+ // false si pas terminée donc bloquée (en attente de signaux)
245
+ function execInstruction(command, branch){
246
+ if(debug) console.log("execInstruction: Instruction :", command.name, command.signal);
247
+
248
+ if(!command.burnt){ // Elle n'a pas encore été jouée
249
+ switch(command.name){
250
+
251
+ case "abort":
252
+ if(debug) console.log("abort: signal", command.signal,
253
+ ", abort burnt:", command.burnt,
254
+ ", abort index:", command.index);
255
+
256
+ if(isSignalActivatedInInstruction(command, command.signal)){
257
+ command.count++;
258
+ if(command.count >= command.countMax){
259
+ command.count = 0;
260
+ command.burnt = true;
261
+ if(debug) console.log("abort brulé car signal actif:", command);
262
+ return true;
263
+ }else{
264
+ // On joue la branche comme une séquence
265
+ for(var i=0; i < command.nextInstr.length ; i++){
266
+ if(!runBranch(command.nextInstr[i], command.nextInstr)){
267
+ command.burnt = false;
268
+ return false;
269
+ }
270
+ // Si on est à la dernière branche, c'est fini.
271
+ if(i === command.nextInstr.length - 1) {
272
+ command.count = 0;
273
+ command.burnt = true;
274
+ return true;
275
+ }
276
+ }
277
+ }
278
+ }else{
279
+ // On joue la branche comme une séquence
280
+ for(var i=0; i < command.nextInstr.length ; i++){
281
+ if(!runBranch(command.nextInstr[i], branch)){
282
+ command.burnt = false;
283
+ return false;
284
+ }
285
+ // Si on est à la dernière branche, c'est fini.
286
+ if(i === command.nextInstr.length - 1) {
287
+ command.count = 0;
288
+ command.burnt = true;
289
+ return true;
290
+ }
291
+ }
292
+ }
293
+ break;
294
+
295
+ case "atom":
296
+ if(debug) console.log("atom");
297
+ command.action();
298
+ command.burnt = true;
299
+ return true;
300
+
301
+ case "await":
302
+ // Si le signal est actif
303
+ if(isSignalActivatedInInstruction(command, command.signal)){
304
+ //if(isSignalActivated(command.signal)){
305
+ command.count++;
306
+ if(command.count >= command.countMax){
307
+ command.count = 0;
308
+ // On brule le signal pour cet await
309
+ command.signalActivated = false;
310
+ // On le brule pour la branch de cet await
311
+ // pour éviter la prise en compte du signal
312
+ // absorbé par cette await
313
+ if(debug) console.log("await dans la branche:", branch);
314
+ setSignal(branch, command.signal,
315
+ command.nowval, false);
316
+ // Brule la commande
317
+ command.burnt = true;
318
+ return true;
319
+ }
320
+ }else{
321
+ command.burnt = false;
322
+ return false;
323
+ }
324
+ break;
325
+
326
+ case "await_do":
327
+ if(debug) console.log("await_do: ", command.signal, signals);
328
+
329
+ // Si le signal est actif
330
+ if(isSignalActivatedInInstruction(command, command.signal)){
331
+ command.count++;
332
+ if(command.count >= command.countMax){
333
+ command.action();
334
+ command.count = 0;
335
+ // On brule le signal pour cet await
336
+ command.signalActivated = false;
337
+ // On le brule pour la branch de cet await
338
+ // pour éviter la prise en compte du signal
339
+ // absorbé par cette await
340
+ setSignal(branch, command.signal,
341
+ command.nowval, false);
342
+ // Brule la commande
343
+ command.burnt = true;
344
+ return true;
345
+ }
346
+ }else{
347
+ command.burnt = false;
348
+ return false;
349
+ }
350
+
351
+ case "emit":
352
+ if(debug) console.log("-- emit --", command.signal, command.nowval, command.index);
353
+ // Une sorte de broadcast du signal
354
+ // qui consiste à mettre à jour tous les signaux
355
+ // command.signal qui se trouvent dans les instructions
356
+ activateSignal(command.signal, command.nowval);
357
+
358
+ // Inspiré de HipHop. Assicié une action à une emission dans le programme.
359
+ playEventListener(command.signal, command.nowval);
360
+
361
+ if(debug) console.log("-- emit activé : ", command.signal, command.burnt);
362
+ command.burnt = true;
363
+
364
+ // Broadcast ?
365
+ //reRunProg(); // marche pas avec every qui remet les intr à unbrunt
366
+
367
+ return true;
368
+
369
+ case "every":
370
+ if(isSignalActivatedInInstruction(command, command.signal)){
371
+ command.count++;
372
+ if(command.count >= command.countMax){
373
+ command.count = 0;
374
+ if(debug) console.log("every: command.branch", i, command.nextInstr[0]);
375
+
376
+ // On brule le signal pour la branche controlée par every
377
+ // pour éviter la prise en compte du signal
378
+ // absorbé par cette every
379
+ //setSignal(command.nextInstr, command.signal,
380
+ // command.nowval, false);
381
+
382
+ command.signalActivated = false;
383
+
384
+ // reset des instructions selon la sémantique Estérel
385
+ // pour repartir du début de la branche.
386
+ // On pourrait aussi ne pas recommencer du début
387
+ // de la branche en commentant cette ligne.
388
+ unburnBranch(command.nextInstr);
389
+
390
+ for(var i=0; i < command.nextInstr.length ; i++){
391
+ if(debug) console.log("every: seq command.branch", i, command.nextInstr[i].name);
392
+ if(!runBranch(command.nextInstr[i], command.nextInstr)){
393
+ return false;
394
+ }
395
+ // Si on est à la dernière branche, la branche du every est fini.
396
+ // mais pas every.
397
+ if(i === command.nextInstr.length - 1){
398
+ command.burnt = false; // every n'est jamais terminé
399
+ return false;
400
+ }
401
+ }
402
+ }else{
403
+ command.burnt = false;
404
+ return false;
405
+ }
406
+ }else{
407
+ command.burnt = false;
408
+ return false;
409
+ }
410
+
411
+ case "loop":
412
+ if(debug) console.log("loop command.branch", command.nextInstr);
413
+
414
+ for(var i=0; i < command.nextInstr.length ; i++){
415
+ if(debug) console.log("seq command.branch", i,
416
+ command.nextInstr[i]);
417
+ if(!runBranch(command.nextInstr[i], command.nextInstr)){
418
+ return false;
419
+ }
420
+ // Si on est à la dernière branche on reset
421
+ // les instructions de la branche et on recommence
422
+ if(i === command.nextInstr.length - 1){
423
+ // reset des instructions
424
+ unburnBranch(command.nextInstr);
425
+ command.burnt = false;
426
+ return false;
427
+ }
428
+ }
429
+ break;
430
+
431
+ case "par":
432
+ var countBranch = 0;
433
+ // Les branches sont les éléments d'un tableau
434
+ for(var i=0; i < command.nextInstr.length ; i++){
435
+ if(runBranch(command.nextInstr[i], command.nextInstr)){
436
+ if(debug) console.log("Par:", i);
437
+ countBranch++;
438
+ }
439
+ }
440
+ // Si le décompte des branches terminées
441
+ // correspond à l'ensembles des instructions
442
+ // c'est qu'on a terminé le parallèle
443
+ if(countBranch === command.nextInstr.length){
444
+ command.burnt = true;
445
+ return true;
446
+ }else{
447
+ return false;
448
+ }
449
+ break;
450
+
451
+ case "restart":
452
+ if(debug1) console.log("restart:");
453
+ command.burnt = true;
454
+ reRunProg();
455
+ return true;
456
+
457
+ case "run":
458
+ case "seq":
459
+ if(debug) console.log("seq command.branch", command.nextInstr);
460
+
461
+ for(var i=0; i < command.nextInstr.length ; i++){
462
+ if(debug) console.log("seq command.branch", i, command.nextInstr[i]);
463
+ if(!runBranch(command.nextInstr[i], command.nextInstr)){
464
+ return false;
465
+ }
466
+ // Si on est à la dernière branche, c'est fini.
467
+ if(i === command.nextInstr.length -1){
468
+ command.burnt = true;
469
+ return true;
470
+ }
471
+ }
472
+ break;
473
+
474
+ case "printSignals":
475
+ // devenu inutile sou cette forme
476
+ if(debug) console.log("printSignals");
477
+ command.action();
478
+ command.burnt = true;
479
+ return true;
480
+
481
+ default: console.log("Instruction inconnue");
482
+ }
483
+ }else{ // La commande a déjà été jouée
484
+ if(debug) console.log("execInstruction: Instruction :", command.name, "déjà jouée");
485
+ return true;
486
+ }
487
+ }
488
+
489
+ /*============================================================
490
+ *
491
+ * Déclenchement d'une réaction.
492
+ * S'arrête si un signal est attendu dans le déroulement.
493
+ * La notion de programme constitué de module est une façon
494
+ * d'éviter une instruction seq en début de programme
495
+ * Est-ce bien utile ?
496
+ *
497
+ =============================================================*/
498
+ function runProg(){
499
+ if(debug) console.log("\nrunProg", prog.length);
500
+ runBranch(program.instructions, undefined);
501
+ }
502
+ exports.runProg = runProg;
503
+
504
+ function reRunProg(){
505
+ if(debug) console.log("\nreRunProg", program);
506
+ if(program !== undefined){
507
+ runBranch(program.instructions, undefined);
508
+ }
509
+ }
510
+
511
+ // Création du point de départ du programme
512
+ function createModule(instr){
513
+ var module = {
514
+ name: "Program",
515
+ signal: undefined,
516
+ signalActivated: undefined,
517
+ burnt: false,
518
+ instructions: instr
519
+ }
520
+ program = module;
521
+ return module;
522
+ }
523
+ exports.createModule = createModule;
524
+
525
+ /*============================================================
526
+ *
527
+ * Pour l'execution du programme
528
+ *
529
+ =============================================================*/
530
+
531
+ // Exécute la liste d'instructions qui constitue une branche
532
+ // Reçoit comme paramètre un tableau d'objets instructions.
533
+ // S'arrête et retourne true si la branche a été executée
534
+ // false si on tombe sur une instruction en attente.
535
+ function runBranch(instructions, branch){
536
+ if(debug) console.log("\nrunBranch: length: ", instructions.length);
537
+
538
+ // --> Cas d'une instruction seule
539
+ if(instructions.length === undefined){
540
+ if(debug) console.log("runBranch: instruction seule:", instructions.name);
541
+ // Si l'instruction est bloquée
542
+ if(!execInstruction( instructions, branch )){
543
+ return false;
544
+ }
545
+ // Si l'instruction est ou a été jouée
546
+ return true;
547
+ }
548
+
549
+ // --> Cas d'un tableau d'instructions
550
+ for(var i=0; i < instructions.length; i++){
551
+ if(debug) console.log("-- runBranch: tableau d'instructions:", i,
552
+ instructions[i].name, instructions[i].index);
553
+ // On tombe sur une instruction bloquée
554
+ if(!execInstruction( instructions[i], instructions )){
555
+ return false;
556
+ }
557
+ // On joue la suivante
558
+ }
559
+ // On a joué la branche complétement
560
+ return true;
561
+ }
562
+
563
+ // Restauration des instructions dans une branche
564
+ function unburnBranch(instructions){
565
+ // On est sur une instruction "finale" et plus sur une branche
566
+ if(instructions === undefined){
567
+ return true;
568
+ }
569
+
570
+ if(instructions.length === undefined){
571
+ if(debug) console.log("unburnBranch 1:", instructions);
572
+ instructions.burnt = false;
573
+ return true;
574
+ }
575
+
576
+ // On est sur une suite d'instructions
577
+ for(var i=0; i < instructions.length; i++){
578
+ if(debug) console.log("\n--- unburnBranch", i, instructions[i].name);
579
+ if(instructions[i].burnt !== undefined){
580
+ if(debug) console.log("unburnBranch 2:", instructions[i].name);
581
+ instructions[i].burnt = false;
582
+ unburnBranch(instructions[i].nextInstr);
583
+ }else{
584
+ unburnBranch(instructions[i].nextInstr);
585
+ }
586
+ }
587
+ return true;
588
+ }
589
+
590
+ /*============================================================
591
+ *
592
+ * Pour une vision du programme à exécuter
593
+ * Balayage de l'arbre du programme
594
+ *
595
+ =============================================================*/
596
+
597
+ function printInstructions(instr, option){
598
+ if(instr === undefined) return;
599
+
600
+ for(var i=0; i < instr.length; i++){
601
+ if(option === true){
602
+ console.log(instr[i]);
603
+ console.log("------------------------------");
604
+ }else{
605
+ console.log("-> ", instr[i].name, ": index:", instr[i].index);
606
+ }
607
+ printInstructions(instr[i].nextInstr, option);
608
+ }
609
+ }
610
+
611
+ function printProgram(prog, option){
612
+ console.log("------ PROGRAM ---------------");
613
+ printInstructions(prog.instructions, option);
614
+ console.log("------------------------------");
615
+ }
616
+ exports.printProgram = printProgram;
617
+
618
+ /*============================================================
619
+ *
620
+ * Couche de simplification des créations
621
+ * d'instructions pour export et utilisation dans Blockly
622
+ *
623
+ =============================================================*/
624
+
625
+ function _emit(signal, value){
626
+ return createInstruction("emit", signal, value, undefined, undefined, undefined);
627
+ }
628
+ exports._emit = _emit;
629
+
630
+ function _await(signal, count){
631
+ return createInstruction("await",signal, undefined, count, undefined, undefined);
632
+ }
633
+ exports._await = _await;
634
+
635
+ function _await_do(signal, count, action){
636
+ return createInstruction("await_do",signal, undefined, count, action, undefined);
637
+ }
638
+ exports._await_do = _await_do;
639
+
640
+ function _abort(signal, count, instructions){
641
+ return createInstruction("abort",signal, undefined, count, undefined, instructions);
642
+ }
643
+ exports._abort = _abort;
644
+
645
+ function _every(signal, count, instructions){
646
+ return createInstruction("every",signal, undefined, count, undefined, instructions);
647
+ }
648
+ exports._every = _every;
649
+
650
+ function _seq(instructions){
651
+ return createInstruction("seq", undefined, undefined, undefined, undefined, instructions);
652
+ }
653
+ exports._seq = _seq;
654
+
655
+ function _par(instructions){
656
+ return createInstruction("par", undefined, undefined, undefined, undefined, instructions);
657
+ }
658
+ exports._par = _par;
659
+
660
+ function _loop(instructions){
661
+ return createInstruction("loop", undefined, undefined, undefined, undefined, instructions);
662
+ }
663
+ exports._loop = _loop;
664
+
665
+ function _run(module){
666
+ //var instructions = _seq(module);
667
+ return createInstruction("run", undefined, undefined, undefined, undefined, module);
668
+ }
669
+ exports._run = _run;
670
+
671
+ function _atom(action){
672
+ return createInstruction("atom",undefined, undefined, undefined, action, undefined);
673
+ }
674
+ exports._atom = _atom;
675
+
676
+ function _printSignals(){
677
+ return createInstruction("printSignals",undefined, undefined, undefined, () => {console.log(signals);}, undefined);
678
+ }
679
+ exports._printSignals = _printSignals;
680
+
681
+ function _restart(){
682
+ return createInstruction("restart",undefined, undefined, undefined, undefined, undefined);
683
+ }
684
+ exports._restart = _restart;