nodeskini 1.0.3 → 1.0.6
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.
- package/blocklySkini/scripts/hiphop_blocks.js +3991 -6104
- package/blocklySkini/scripts/main2.js +4 -4
- package/client/clientListe/clientListe.js +11 -0
- package/client/clientListe/clientListebundle.js +1755 -1909
- package/client/configurateur/configReact.js +1 -1
- package/client/configurateur/configReactbundle.js +16 -10
- package/client/configurateur/src/configReact.js +1 -1
- package/client/parametrage/paramReact.js +1 -1
- package/client/parametrage/paramReactbundle.js +6 -5
- package/client/parametrage/src/paramReact.js +2 -2
- package/client/score/parto1.js +4 -1
- package/client/score/parto1bundle.js +45 -23
- package/client/simulateurListe/simulateurFork.mjs +1 -1
- package/client/simulateurListe/simulateurListe.js +3 -3
- package/doc/Doc Skini Node english.pdf +0 -0
- package/doc/Mode d'emploi Skini Node.pdf +0 -0
- package/doc/Tuto Skini.pdf +0 -0
- package/doc/quickstart.pdf +0 -0
- package/myReact/orchestrationHH.hh.js +2024 -0
- package/myReact/orchestrationHH.mjs +262 -420
- package/myReact/orchestrationHH.mjs.map +1 -1
- package/package.json +19 -11
- package/pieces/tutos/demoAbleton.csv +21 -0
- package/pieces/tutos/demoAbleton.js +100 -0
- package/pieces/tutos/demoAbleton.xml +180 -0
- package/pieces/tutos/demoHH.js +99 -0
- package/pieces/tutos/demoHH.xml +184 -0
- package/pieces/tutos/demoHHwait.js +100 -0
- package/pieces/tutos/demoHHwait.xml +175 -0
- package/pieces/tutos/tuto.csv +10 -0
- package/pieces/tutos/tuto.csv.good +1 -0
- package/pieces/tutos/tuto1.js +105 -0
- package/pieces/tutos/tuto1.xml +147 -0
- package/pieces/tutos/tuto10.back.js +106 -0
- package/pieces/tutos/tuto10.js +107 -0
- package/pieces/tutos/tuto10.xml +199 -0
- package/pieces/tutos/tuto11.js +111 -0
- package/pieces/tutos/tuto11.xml +124 -0
- package/pieces/tutos/tuto12.js +91 -0
- package/pieces/tutos/tuto12.xml +258 -0
- package/pieces/tutos/tuto2.back.js +106 -0
- package/pieces/tutos/tuto2.js +95 -0
- package/pieces/tutos/tuto2.xml +94 -0
- package/pieces/tutos/tuto3-2.js +105 -0
- package/pieces/tutos/tuto3-2.xml +96 -0
- package/pieces/tutos/tuto3.js +97 -0
- package/pieces/tutos/tuto3.xml +49 -0
- package/pieces/tutos/tuto4.js +107 -0
- package/pieces/tutos/tuto4.xml +106 -0
- package/pieces/tutos/tuto5.js +109 -0
- package/pieces/tutos/tuto5.xml +42 -0
- package/pieces/tutos/tuto6.js +105 -0
- package/pieces/tutos/tuto6.xml +26 -0
- package/pieces/tutos/tuto7.js +107 -0
- package/pieces/tutos/tuto7.xml +65 -0
- package/pieces/tutos/tuto8.js +105 -0
- package/pieces/tutos/tuto8.xml +76 -0
- package/pieces/tutos/tuto9.js +107 -0
- package/pieces/tutos/tuto9.xml +90 -0
- package/pieces/tutos/tutoAwait.js +111 -0
- package/pieces/tutos/tutoAwait.xml +171 -0
- package/pieces/tutos/tutoDoubleEmission.js +93 -0
- package/pieces/tutos/tutoDoubleEmission.xml +65 -0
- package/pieces/tutos/tutoESP32.js +104 -0
- package/pieces/tutos/tutoESP32.xml +246 -0
- package/pieces/tutos/tutoGame.js +126 -0
- package/pieces/tutos/tutoGame.xml +109 -0
- package/pieces/tutos/tutoGroups1.js +111 -0
- package/pieces/tutos/tutoGroups1.xml +137 -0
- package/pieces/tutos/tutoGroups2.js +97 -0
- package/pieces/tutos/tutoGroups2.xml +103 -0
- package/pieces/tutos/tutoGroups3.js +111 -0
- package/pieces/tutos/tutoGroups3.xml +128 -0
- package/pieces/tutos/tutoGroups4.js +111 -0
- package/pieces/tutos/tutoGroups4.xml +84 -0
- package/pieces/tutos/tutoIZ.js +95 -0
- package/pieces/tutos/tutoIZ.xml +135 -0
- package/pieces/tutos/tutoIf.js +111 -0
- package/pieces/tutos/tutoIf.xml +126 -0
- package/pieces/tutos/tutoMidi.js +126 -0
- package/pieces/tutos/tutoMidi.xml +62 -0
- package/pieces/tutos/tutoOS.js +121 -0
- package/pieces/tutos/tutoOSC.js +109 -0
- package/pieces/tutos/tutoOSC.xml +223 -0
- package/pieces/tutos/tutoOSCJonathan.js +94 -0
- package/pieces/tutos/tutoOSCJonathan.xml +312 -0
- package/pieces/tutos/tutoPatternInGroup.js +109 -0
- package/pieces/tutos/tutoPatternInGroup.xml +116 -0
- package/pieces/tutos/tutoRandomBlock.js +129 -0
- package/pieces/tutos/tutoRandomBlock.xml +194 -0
- package/pieces/tutos/tutoSuspend.js +107 -0
- package/pieces/tutos/tutoSuspend.xml +139 -0
- package/pieces/tutos/tutoSustain.js +107 -0
- package/pieces/tutos/tutoSustain.xml +109 -0
- package/pieces/tutos/tutoTank.csv +9 -0
- package/pieces/tutos/tutoTank.js +100 -0
- package/pieces/tutos/tutoTank.xml +326 -0
- package/pieces/tutos/tutoTestAll.csv +11 -0
- package/pieces/tutos/tutoTestAll.js +101 -0
- package/pieces/tutos/tutoTestAll.xml +859 -0
- package/serveur/OSCandMidi.mjs +7 -5
- package/serveur/controleDAW.mjs +3 -2
- package/serveur/defaultSkiniParametres.js +20 -13
- package/serveur/groupeClientsSons.mjs +10 -5
- package/serveur/ipConfig.json +2 -2
- package/serveur/midimix.mjs +13 -13
- package/serveur/saveParam.mjs +4 -15
- package/serveur/skiniParametres.js +108 -26
- package/serveur/utilsHHSkini.hh.js +64 -64
- package/serveur/websocketServer.mjs +2090 -2052
- package/serveur/workerInterfaceZ.mjs +4 -7
- package/blocklySkini/archive/blocklyControleur.js +0 -87
- package/blocklySkini/archive/blocklySkini.js +0 -84
- package/blocklySkini/archive/blocklyhop.js +0 -75
- package/blocklySkini/archive/clientControleurBlocly.js +0 -170
- package/blocklySkini/archive/index.html +0 -76
- package/blocklySkini/archive/testHHsuspend.txt +0 -89
- package/blocklySkini/archive/testHHtrap.txt +0 -262
- package/blocklySkini/archive/testOrchestration.txt +0 -177
- package/blocklySkini/archive/testOrchestration.xml +0 -447
- package/blocklySkini/archive/testOrchestration2.xml +0 -456
- package/myReact/archive/Nodeemitvaluedlocal1.hh.js +0 -52
- package/myReact/archive/abort-parNode.js +0 -79
- package/myReact/archive/abroNode.js +0 -169
- package/myReact/archive/abroNode2.js +0 -80
- package/myReact/archive/atom.compile.hh.js +0 -51
- package/myReact/archive/await-countNode.js +0 -67
- package/myReact/archive/await-nowvalNode.js +0 -44
- package/myReact/archive/callHH.js +0 -96
- package/myReact/archive/emit-if2.hh.compiled.js +0 -113
- package/myReact/archive/every1Node.js +0 -35
- package/myReact/archive/if-runNode.js +0 -74
- package/myReact/archive/if1Node.js +0 -43
- package/myReact/archive/makeawait.js +0 -0
- package/myReact/archive/myReact.old.js +0 -684
- package/myReact/archive/orchestration.js +0 -281
- package/myReact/archive/orchestration1.js +0 -132
- package/myReact/archive/orchestration1.xml +0 -465
- package/myReact/archive/orchestration2.js +0 -161
- package/myReact/archive/orchestrationHH.mano.js +0 -280
- package/myReact/archive/orchestrationHHTest.js +0 -428
- package/myReact/archive/orchestrationHHTest.xml +0 -234
- package/myReact/archive/orchestrationHHTestRun.js +0 -104
- package/myReact/archive/orchestrationHHTestRun.xml +0 -34
- package/myReact/archive/orchestrationTest0.js +0 -178
- package/myReact/archive/orchestrationTest1.js +0 -181
- package/myReact/archive/orchestrationTest2.js +0 -281
- package/myReact/archive/run3pointsNode.js +0 -59
- package/myReact/archive/runNode.js +0 -123
- package/myReact/archive/runNode2.js +0 -91
- package/myReact/archive/testAwait1.js +0 -141
- package/myReact/archive/testAwait1.xml +0 -86
- package/myReact/archive/testEvery1.js +0 -122
- package/myReact/archive/testEvery1.xml +0 -79
- package/myReact/archive/testHH1.js +0 -135
- package/myReact/archive/testHH1.xml +0 -86
- package/myReact/archive/testHH1revu.js +0 -104
- package/myReact/archive/testHH2.js +0 -122
- package/myReact/archive/testHH2.xml +0 -79
- package/myReact/archive/testHH3.js +0 -130
- package/myReact/archive/testHH3.xml +0 -86
- package/myReact/archive/testHHabort.js +0 -121
- package/myReact/archive/testHHabort.xml +0 -83
- package/myReact/archive/testMakeawait.js +0 -202
- package/myReact/archive/testRun1.js +0 -168
- package/myReact/archive/testRun1.xml +0 -142
- package/myReact/archive/titi.js +0 -28
- package/myReact/archive/titi.xml +0 -110
- package/myReact/archive/toto.js +0 -73
- package/myReact/archive/toto.xml +0 -198
- package/myReact/archive/trap-await-parallelNode.js +0 -123
- package/myReact/inutiles/hiver2022.xml +0 -804
- package/myReact/inutiles/hopeNode.xml +0 -459
- package/myReact/inutiles/mars2022.xml +0 -871
- package/myReact/inutiles/mystique1.xml +0 -318
- package/myReact/inutiles/mystiqueOSC.xml +0 -277
- package/myReact/inutiles/opus5Node.xml +0 -1271
- package/myReact/inutiles/opus5NodeLinux.xml +0 -1241
- package/myReact/inutiles/orchestrationHH.xml +0 -541
- package/myReact/inutiles/orchestrationHH2.xml +0 -547
- package/myReact/inutiles/testHH.xml +0 -95
- package/myReact/inutiles/trouveLaPercuTenor.xml +0 -349
|
@@ -1,684 +0,0 @@
|
|
|
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;
|