home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
vol_300
/
349_01
/
sss.arc
/
EX_0407.C
< prev
next >
Wrap
Text File
|
1991-04-09
|
2KB
|
124 lines
/* Program EX_0407
Listing 8C - see documentation in TUTOR.SSS
*/
#include "SSSC.H"
#define ARRIVL 1
#define STARTA 2
#define ENDACT 3
#define NEXTAC 4
#define STRTDY 5
#define CLOSES 0
#define WATCH 1
#define TRUE 1
#define FALSE 0
int ecode, opens, repars;
double n, r, d, inter, rept;
void prime()
{
INIQUE(0, 0, 3);
INISTA(1, "Night", 1, 0, 0, 0);
INISTA(2, "W f repair", 1, 0, 0, 0);
INISTA(3, "W f delivery", 1, 0, 0, 0);
CREATE(0.0, WATCH );
CREATE(0.5, CLOSES);
SIMEND(10.0);
n = 0.0;
d = 0.0;
opens = TRUE;
repars = FALSE;
inter = 7.0/25.0;
rept = 2.0/24.0;
}
void clshop()
{
opens = FALSE;
d = 0.0;
TALLY(3, d);
}
void box()
{
DISPOS();
TALLY(1, ++n);
}
void newday()
{
CREATE(0.5, CLOSES);
DISPOS();
opens = TRUE;
repars = FALSE;
r += n;
TALLY(2, r);
n = 0;
TALLY(1, n);
}
main()
{
prime();
do
{
if ((ecode = NEXTEV()) > 0)
switch(ecode)
{
case ARRIVL :
if (IDE() == WATCH)
{
CREATE(EX(inter), WATCH);
SCHED(0.0, NEXTAC, WATCH );
} else
{
SCHED(0.5, STRTDY, CLOSES);
clshop();
}
break;
case NEXTAC :
if (opens)
{
TALLY(2, ++r);
if (repars) DISPOS(); else
SCHED(0.0, STARTA, IDE());
} else box();
break;
case STARTA :
SCHED(EX(rept), ENDACT, 0);
TALLY(2, --r);
repars = TRUE;
break;
case ENDACT :
TALLY(3, ++d);
if (r) SCHED(0.0, STARTA, 0);
else
{
DISPOS();
repars = FALSE;
}
break;
case STRTDY :
newday();
break;
}
} while (ecode);
SUMRY("");
}