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 >
Text File  |  1991-04-09  |  2KB  |  124 lines

  1. /* Program EX_0407
  2.    Listing 8C - see documentation in TUTOR.SSS
  3. */
  4.  
  5. #include "SSSC.H"
  6.  
  7. #define ARRIVL 1
  8. #define STARTA 2
  9. #define ENDACT 3
  10. #define NEXTAC 4
  11. #define STRTDY 5
  12.  
  13. #define CLOSES 0
  14. #define WATCH  1
  15.  
  16. #define TRUE   1
  17. #define FALSE  0
  18.  
  19. int    ecode, opens, repars;
  20. double n, r, d, inter, rept;
  21.  
  22. void prime()
  23. {
  24.  
  25.   INIQUE(0, 0, 3);
  26.  
  27.   INISTA(1, "Night", 1, 0, 0, 0);
  28.   INISTA(2, "W f repair", 1, 0, 0, 0);
  29.   INISTA(3, "W f delivery", 1, 0, 0, 0);
  30.  
  31.   CREATE(0.0, WATCH );
  32.   CREATE(0.5, CLOSES);
  33.   SIMEND(10.0);
  34.  
  35.   n = 0.0;
  36.   d = 0.0;
  37.  
  38.   opens  = TRUE;
  39.   repars = FALSE;
  40.   inter  = 7.0/25.0;
  41.   rept   = 2.0/24.0;
  42. }
  43.  
  44. void clshop()
  45. {
  46.   opens = FALSE;
  47.   d = 0.0;
  48.   TALLY(3, d);
  49. }
  50.  
  51. void box()
  52. {
  53.   DISPOS();
  54.   TALLY(1, ++n);
  55. }
  56.  
  57. void newday()
  58. {
  59.   CREATE(0.5, CLOSES);
  60.   DISPOS();
  61.   opens  = TRUE;
  62.   repars = FALSE;
  63.   r += n;
  64.   TALLY(2, r);
  65.   n = 0;
  66.   TALLY(1, n);
  67. }
  68.  
  69. main()
  70. {
  71.   prime();
  72.  
  73.   do
  74.   {
  75.     if ((ecode = NEXTEV()) > 0)
  76.     switch(ecode)
  77.     {
  78.  
  79.       case ARRIVL :
  80.            if (IDE() == WATCH)
  81.            {
  82.              CREATE(EX(inter), WATCH);
  83.              SCHED(0.0, NEXTAC, WATCH );
  84.            } else
  85.            {
  86.              SCHED(0.5, STRTDY, CLOSES);
  87.              clshop();
  88.            }
  89.            break;
  90.  
  91.       case NEXTAC :
  92.            if (opens)
  93.            {
  94.              TALLY(2, ++r);
  95.              if (repars) DISPOS(); else
  96.                          SCHED(0.0, STARTA, IDE());
  97.            } else box();
  98.            break;
  99.  
  100.       case STARTA :
  101.            SCHED(EX(rept), ENDACT, 0);
  102.            TALLY(2, --r);
  103.            repars = TRUE;
  104.            break;
  105.  
  106.       case ENDACT :
  107.            TALLY(3, ++d);
  108.            if (r) SCHED(0.0, STARTA, 0);
  109.            else
  110.            {
  111.              DISPOS();
  112.              repars = FALSE;
  113.             }
  114.             break;
  115.  
  116.       case STRTDY :
  117.            newday();
  118.            break;
  119.  
  120.     }
  121.   } while (ecode);
  122.   SUMRY("");
  123. }
  124.