      REM MONITOR-WEB
*PIC-LAN
*
*ALL
*PC
*N
*
*
*
*
      INCLUDE SYS.TYPE.INCLUDE
*
      INCLUDE PL.COMMON
      INCLUDE PL.COMMON.DEFS
      INCLUDE PL.DEFS
      INCLUDE PLIP.COMMON
      INCLUDE PLW.COMMON
      INCLUDE PL.INIT.INCLUDE
*
      DUMMY = @(0,0)
*
      CALL PLIP.INIT.SUB
      CALL PLW.INIT.SUB('RUN')
*
      NO.PORTS = DCOUNT(PLIP$PROC.PORTS,VM)
*
      NUL80 = STR(CHAR(0),80)
*
      OPTS = OCONV(SENT<2>,'MCU')
      X.OPT = INDEX(OPTS,'X',1)
      S.OPT = INDEX(OPTS,'S',1)
      O.OPT = INDEX(OPTS,'1',1)
*
      PR = '>>> PicLan-IP monitor ( press X to exit ) <<<'
      PRS = SPACE(LEN(PR))
*
      CRLF = CR : LF
*
      OPEN 'WWW.CTRL,STATES' TO STATE.FD ELSE CALL PLXX.STOP(201,'WWW.CTRL,STATES')
      OPEN 'WWW.CTRL,PROCESSES' TO PROC.FD ELSE CALL PLXX.STOP(201,'WWW.CTRL,PROCESSES')
*
      PRINT
*
      EXIT.FLG = NO
      WORK.FLG = YES
      LOOP
         IF PL_TA() THEN
            CMD = PL_GET()
            CMD = OCONV(CMD,'MCU')
            IF CMD = 'X' THEN EXIT.FLG = YES
         END
      UNTIL EXIT.FLG DO
         IF X.OPT THEN
            SELECT PROC.FD
            READNEXT ID ELSE
               EXIT.FLG = YES
            END
         END
*
         IF S.OPT THEN
            PRINT @(-1) : @(0,0) : 'PicLan-IP process status'
            PRINT
            PRINT 'P# ' :
            PRINT 'Time ' :
            PRINT 'MxTm ' :
            PRINT 'Plcb ' :
            PRINT 'Status'
            PRINT
*
            FOR I = 1 TO NO.PORTS
               PL_PRGETSTATE A1,A2,A3,A4,A5 FROM (I-1)
               IF A2 THEN
                  PRINT (I-1) 'R#2' : ' ' :
                  PRINT ( A1-A2 ) 'R#4' : ' ' :
                  IF A3 = 0 THEN A3 = PLIP$SUP.TIMEOUT
                  A3 = A3 - ( A1 - A2 )
                  IF A3 <= 0 THEN A3 = '****'
                  PRINT A3 'R#4' : ' ' :
                  IF A4 = 65535 THEN A4 = ''
                  PRINT A4 'R#4' : ' ' :
                  PRINT A5
               END
            NEXT I
*
            PL_PRCHECKSTATE A1,A2,A3,A4,A5 TIMEOUT PLIP$SUP.TIMEOUT THEN
            END
            PRINT
            IF O.OPT THEN EXIT.FLG = YES
            IF NOT(O.OPT) THEN PRINT "Press 'x' to exit " :
*
            IF NOT(EXIT.FLG) THEN SLEEP 5
         END ELSE
            PL_MSGREAD ELSE NULL
            IF S$ = '' THEN
               IF WORK.FLG THEN
                  IF NOT(O.OPT) THEN PRINT CR : PR : CR :
                  WORK.FLG = NO
               END
               IF NOT(EXIT.FLG) THEN SLEEP 1
            END ELSE
               IF NOT(WORK.FLG) THEN
                  IF NOT(O.OPT) THEN PRINT CR : PRS : CR :
               END
               PRINT S$ :
               WORK.FLG = YES
            END
         END
         IF O.OPT THEN EXIT.FLG = YES
*
         IF EXIT.FLG THEN
            IF NOT(O.OPT) THEN PRINT CR : PRS : CR : '>>> All web processes are stopped. <<<'
         END
      REPEAT
*
      PRINT
   END
