Skip to content

Instantly share code, notes, and snippets.

@mattmils
Created July 25, 2011 22:36
Show Gist options
  • Save mattmils/1105430 to your computer and use it in GitHub Desktop.
Save mattmils/1105430 to your computer and use it in GitHub Desktop.
Rematori LTSA Originale
// Matteo Rolla
// matr. 730928
const NUM = 2
range Ids = 1..NUM
const FALSE = 0
const TRUE = 1
range BOOL = FALSE..TRUE
const IDLE = 0
const READY = 1
const END = 2
const CENA = 3
range STATE = IDLE..CENA
REMATORE = (
arrivaAlCampo -> R
),
R = (
iniziaAllenamento -> rema1 -> rema2 -> rema3 ->
concludiAllenamento -> migliorRematore[b:BOOL] -> C[b]
),
C[b:BOOL] = (
when (b == TRUE) sonoIlMigliore -> cena -> REMATORE |
when (b == FALSE) nonSonoIlMigliore -> cena -> REMATORE
).
ALLENATORE = A[0][IDLE][FALSE],
A[num:0..NUM][state:STATE][c:BOOL] = (
// L'allenamento deve ancora iniziare
when (state == IDLE && num < NUM)
r[Ids].arrivaAlCampo -> A[num + 1][state][c] |
when (state == IDLE && num == NUM)
r[Ids].iniziaAllenamento -> A[num][READY][c] |
// Iniziano ad allenarsi.
when (state == READY) r[Ids].concludiAllenamento -> A[0][END][c] |
// Decisione del miglior rematore della giornata.
when (state == END && num < NUM && c == FALSE)
r[Ids].migliorRematore[TRUE] -> A[num + 1][state][TRUE] |
when (state == END && num < NUM && c == FALSE)
r[Ids].migliorRematore[FALSE] -> A[num + 1][state][FALSE] |
when (state == END && num < NUM && c == TRUE)
r[Ids].migliorRematore[FALSE] -> A[num + 1][state][TRUE] |
when (state == END && num == NUM) vaiACenare -> A[0][CENA][FALSE] |
// Cena
when (state == CENA && num < NUM) r[Ids].cena -> A[num + 1][CENA][c] |
when (state == CENA && num == NUM) concludiCena -> A[0][IDLE][c]
).
|| SYS = ( r[Ids]:REMATORE || ALLENATORE )/
{
// Sync dei rematori.
iniziaAllenamento/{r[1],r[2]}.iniziaAllenamento,
rema1/{r[1],r[2]}.rema1,
rema2/{r[1],r[2]}.rema2,
rema3/{r[1],r[2]}.rema3,
concludiAllenamento/{r[1],r[2]}.concludiAllenamento }.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment