Batch Mode Simulation : A Sample Simulation Control Program : The Program

The Program
PROGRAM tlight;
VARIABLE
FILE fin, fout;
INTEGER delay;
BOOLEAN run;
INIT
OPEN (fin,‘/mickey/home/dos/tmp/trial.dat’, INPUT);
OPEN (fout, ‘/mickey/home/dos/tmp/trial.out’, OUTPUT);
ns_green_time:=15 ;
ew_green_time:=20 ;
CANCEL BREAKPOINT gen_reset ;
END INIT;
SET BREAKPOINT
[in(normal_op)] DO
WRITE(‘current time = ’, cur_clock,‘\n’) ;
IF rand_iuniform(1,100) = 1
THEN
malfunction ;
write(fout,‘malfunction occurred
at ’,cur_clock,‘\n’)
END IF
END BREAKPOINT;
SET BREAKPOINT gen_reset=> EVERY delay DO
reset ;
CANCEL BREAKPOINT gen_reset;
ns_green_time:=rand_iuniform(30,50) ;
READ(fin, ew_green_time) ;
WHILE ew_green_time > 20
LOOP
WRITE(‘Data for ew_green_time exceeds limit.’) ;
WRITE(‘Enter a value for ew_green_time less than
20: \n’) ;
READ(ew_green_time)
END LOOP
END BREAKPOINT ;
SET BREAKPOINT
en(flashing) DO
delay:=RAND_IUNIFORM(1,10);
SET BREAKPOINT gen_reset ;
END BREAKPOINT;
BEGIN
tr!(run) ;
WHILE run LOOP
GO STEP
end loop
END;
END.