-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPrinter.lts
26 lines (21 loc) · 1010 Bytes
/
Printer.lts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const MAX_SHEETS = 3 // Maximum number of sheets in a printer
set PRINT_ACTIONS = {acquirePrint, print, acquireRefill, refill, release}
// Initialise printer with given number of sheets and continue
PRINTER (PAPER_COUNT = MAX_SHEETS) = PRINTER[PAPER_COUNT],
PRINTER[p : 0..PAPER_COUNT] =
if (p > 0)
then (acquirePrint -> print -> release -> PRINTER[p-1])
else (acquireRefill -> refill -> release -> PRINTER[MAX_SHEETS]).
// Initialise student and print given number of documents
STUDENT(DOCUMENT_COUNT = 1) = STUDENT[DOCUMENT_COUNT],
STUDENT[d : 1..DOCUMENT_COUNT] = (
acquirePrint -> print[d] ->
if (d > 1)
then (release -> STUDENT[d-1])
else (release -> END) // Prints the last document
) + PRINT_ACTIONS / {print/print[d:1..DOCUMENT_COUNT]}. // Exposes print[d] actions as just "print"
TECHNICIAN = (
acquireRefill -> refill -> release -> TECHNICIAN |
wait -> TECHNICIAN
) + PRINT_ACTIONS.
||PRINTING_SYSTEM = (s3: STUDENT(3) || s2: STUDENT(2) || t: TECHNICIAN || {s3, s2, t} :: PRINTER).