97 lines
1.8 KiB
Java
Executable file
97 lines
1.8 KiB
Java
Executable file
process vassoio{
|
|
int b = 0;
|
|
port String piero_rosa;
|
|
String mess;
|
|
port signal rilascio_vassoio;
|
|
signal s;
|
|
process pPieroRosa;
|
|
process pMario;
|
|
boolean attesaPiero = false;
|
|
|
|
send(b) to Mario.friggi;
|
|
pMario = receive(s) from rilascio_vassoio;
|
|
b = 30;
|
|
while(true){
|
|
pPieroRosa = receive(mess) from piero_rosa;
|
|
if(mess=="piero"){
|
|
b--;
|
|
if(b==0){
|
|
attesaPiero = true;
|
|
send("finiti") to pPieroRosa.servi;
|
|
setTimer(0);
|
|
}
|
|
else{
|
|
send("non finiti") to pPieroRosa.servi;
|
|
}
|
|
}
|
|
else if(mess=="rosa"){
|
|
send(b) to Mario.friggi;
|
|
pMario = receive(s) from rilascio_vassoio;
|
|
b = 30;
|
|
send(s) to Rosa.rilascio_rosa;
|
|
if(attesaPiero) {
|
|
attesaPiero = false;
|
|
send(s) to Piero.riprendi;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
process Mario{
|
|
process p;
|
|
signal s;
|
|
port int friggi;
|
|
int b_rim;
|
|
while(true){
|
|
p = receive(b_rim) from friggi;
|
|
if(b_rim>0){
|
|
<butta>
|
|
}
|
|
<friggi>
|
|
setTimer(60);
|
|
send(s) to p.rilascio_vassoio;
|
|
}
|
|
}
|
|
|
|
process Piero{
|
|
process pCliente;
|
|
process pVassoio;
|
|
port signal riprendi;
|
|
signal s;
|
|
port String servi;
|
|
String mess;
|
|
port signal cliente;
|
|
|
|
while(true){
|
|
pCliente = receive(s) from cliente; // Aspetta un cliente
|
|
send("piero") to vassoio.piero_rosa;
|
|
pVassoio = receive(mess) from servi;
|
|
<servo clienti>
|
|
send(s) to pCliente.rilascio_cliente; // Comunica al cliente che lo ha servito
|
|
if(mess == "finiti"){
|
|
p = receive(s) from riprendi;
|
|
}
|
|
}
|
|
}
|
|
|
|
process Rosa{
|
|
port signal rilascio_rosa;
|
|
signal s;
|
|
process p;
|
|
while(true){
|
|
waitTimer();
|
|
send("rosa") to vassoio.piero_rosa;
|
|
p = receive(s) from rilascio_rosa;
|
|
}
|
|
}
|
|
|
|
process Cliente{
|
|
port signal rilascio_cliente;
|
|
process p;
|
|
signal s;
|
|
|
|
send(s) to Piero.cliente; // Chiede a Piero un bombolone
|
|
p = receive(s) from rilascio_cliente; // Aspetta di riceverlo
|
|
<Mangia bombolone> // Frigge il timer
|
|
|
|
}
|