CFPRIME SLBMON                                                          SLBMON      1
C***********************************************************************RIGHTE      1
C*                                                                     *RIGHTE      2
C*        Extended Transient-Midterm Stability Program (ETMSP)         *RIGHTE      3
C*        ====================================================         *RIGHTE      4
C*                                                                     *RIGHTE      5
C*       Copyright (C) (1993) Electric Power Research Institute        *RIGHTE      6
C*                                                                     *RIGHTE      7
C* EPRI reserves all rights in the software and associated             *RIGHTE      8
C* documentation as delivered. The software and its associated         *RIGHTE      9
C* documention or any portion thereof may not be reproduced in any form*RIGHTE     10
C* whatsoever without the consent of EPRI, except as explicity provided*RIGHTE     11
C* for by license. Licensee shall submit a detailed description to EPRI*RIGHTE     12
C* of any changes or modifications to the software within two (2)      *RIGHTE     13
C* months after such changes or modifications are made. At EPRI's sole *RIGHTE     14
C* discretion, the software, as changed or modified, shall be given a  *RIGHTE     15
C* new designation sufficiently different from its then current        *RIGHTE     16
C* designation as to prevent mistake,confusion, or deception as between*RIGHTE     17
C* the current software as changed or modified.                        *RIGHTE     18
C*                                                                     *RIGHTE     19
C* A license under EPRI's rights in the software can be obtained       *RIGHTE     20
C* directly from EPRI.                                                 *RIGHTE     21
C*                                                                     *RIGHTE     22
C* This program and supporting materials may be independently available*RIGHTE     23
C* from Electric Power Software centre (EPSC) for an appropriate       *RIGHTE     24
C* distribution fee. The EPSC is a service of                          *RIGHTE     25
C*                                                                     *RIGHTE     26
C*                    Power Computing Company                          *RIGHTE     27
C*                    1930 Hi Line                                     *RIGHTE     28
C*                    Dallas, Tx 75207                                 *RIGHTE     29
C*                                                                     *RIGHTE     30
C* NEITHER EPRI, ANY MEMBER OF EPRI, NOR ANY PERSON OR  ORGANIZATION   *RIGHTE     31
C* ACTING ON BEHAVE OF THEM:                                           *RIGHTE     32
C*                                                                     *RIGHTE     33
C* 1. MAKE ANY WARRANTY OR REPRESENTATION WHATSOEVER, EXPRESS OR       *RIGHTE     34
C*    IMPLIED, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR FITNESS OR *RIGHTE     35
C*    ANY PURPOSE WITH RESPECT TO THE SOFTWARE OR ITS ASSOCIATED       *RIGHTE     36
C*    DOCUMENTATION; OR                                                *RIGHTE     37
C*                                                                     *RIGHTE     38
C* 2. ASSUMES ANY LIABILITY WHATSOEVER WITH RESPECT TO ANY USE OF THE  *RIGHTE     39
C*    SOFTWARE OR ITS ASSOCIATED DOCUMENTATION OR ANY PORTION THEREOF  *RIGHTE     40
C*    OR WITH RESPECT TO ANY DAMAGES WHICH MAY RESULT FROM SUCH USE.   *RIGHTE     41
C*                                                                     *RIGHTE     42
C* THIS NOTICE MAY NOT BE REMOVED FROM THE SOFTWARE BY ANY USER        *RIGHTE     43
C* THEREOF.                                                            *RIGHTE     44
C*                                                                     *RIGHTE     45
C***********************************************************************RIGHTE     46
      SUBROUTINE SLBMON(IDISW)                                          SLBMON      3
CD                                                                      SLBMON      4
CD   THIS SUBROUTINE CHECKS THE TRIPPING STATUS OF LINE                 SLBMON      5
CD    BLINDERS OUT-OF-STEP RELAYS                                       SLBMON      6
CD                                                                      SLBMON      7
      INCLUDE 'PARX.INS'                                                SLBMON      8
      INCLUDE 'CNPT.INS'                                                SLBMON      9
      INCLUDE 'CNAUTO.INS'                                              SLBMON     10
      INCLUDE 'CNVOLT.INS'                                              SLBMON     11
      INCLUDE 'CNFLAG.INS'                                              SLBMON     12
      INCLUDE 'CNB4.INS'                                                SLBMON     13
      INCLUDE 'CNB19.INS'                                               SLBMON     14
      INCLUDE 'CNUNIT.INS'                                              SLBMON     15
C                                                                       SLBMON     16
      LOGICAL IDISW,STARTS,RESETS,TRPMOD,LHIGH,OUTSTP                   SLBMON     17
C                                                                       SLBMON     18
      CHARACTER*2 CID                                                   SLBMON     19
C                                                                       SLBMON     20
      COMPLEX VOLTK                                                     SLBMON     21
      DIMENSION VOLTX(2)                                                SLBMON     22
      EQUIVALENCE (VOLTK,VOLTX(1)),(VOLTX(1),VREAL),(VOLTX(2),VIMAG)    SLBMON     23
C                                                                       SLBMON     24
      LDEB=.FALSE.                                                      SLBMON     25
C                                                                       SLBMON     26
      DO 2400 I=LSLBOR,NSLBOR                                           SLBMON     27
C                                                                       SLBMON     28
      K=IDATPT(I)                                                       SLBMON     29
C                                                                       SLBMON     30
      ICD1 = IADATA(K+1)                                                SLBMON     31
      IF(ICD1.GT.9)GOTO 2400                                            SLBMON     32
      ICD4 = IADATA(K+7)                                                SLBMON     33
C                                                                       SLBMON     34
C       IF ICD1 = 5  BOTH LOCAL AND ROMTED TRIPPING HAVE BEEN COMPLETED SLBMON     35
C                                                                       SLBMON     36
      IF(ICD1 .EQ. 5)GOTO 2400                                          SLBMON     37
C * * *                                                                 SLBMON     38
C * * * IF ICD1 = 4, BOTH LOCAL LINE REMOTED AND REMOTE TRIPPING IN     SLBMON     39
C                    PROGRESS                                           SLBMON     40
C * * *                                                                 SLBMON     41
      IF(ICD1 .EQ. 4) GO TO 2350                                        SLBMON     42
C * * *                                                                 SLBMON     43
C * * *  IF ICD1 = 2 LOCAL RELAY TRIPPED, LINE BREAKER NOT OPENED YET,  SLBMON     44
C                    TRANSFER IS STILL IN PROGRESS                      SLBMON     45
C * * *                                                                 SLBMON     46
      IF(ICD1 .EQ. 2)GO TO 2300                                         SLBMON     47
C                                                                       SLBMON     48
C  CURRENT AND APPARENT IMPEDANCE CALCULATION                           SLBMON     49
C                                                                       SLBMON     50
      IBUS = IADATA(K+2)                                                SLBMON     51
      JBUS = IADATA(K+3)                                                SLBMON     52
      ITFK = IADATA(K+4)                                                SLBMON     53
      CALL UNPACK (CID, JJJ, ITFK)                                      SLBMON     54
C                                                                       SLBMON     55
      GIJ = ADATA(K+23)                                                 SLBMON     56
      BIJ = ADATA(K+24)                                                 SLBMON     57
      GIO = ADATA(K+25)                                                 SLBMON     58
      BIO = ADATA(K+26)                                                 SLBMON     59
C                                                                       SLBMON     60
      VOLTK=VOLT(IBUS)                                                  SLBMON     61
      EI = VREAL                                                        SLBMON     62
      FI = VIMAG                                                        SLBMON     63
      VOLTK=VOLT(JBUS)                                                  SLBMON     64
      EJ = VREAL                                                        SLBMON     65
      FJ = VIMAG                                                        SLBMON     66
C                                                                       SLBMON     67
      GT=GIJ+GIO                                                        SLBMON     68
      BT=BIJ+BIO                                                        SLBMON     69
      C1R=EI*GT-FI*BT                                                   SLBMON     70
      C1I=EI*BT+FI*GT                                                   SLBMON     71
      C2R=EJ*GIJ-FJ*BIJ                                                 SLBMON     72
      C2I=EJ*BIJ+FJ*GIJ                                                 SLBMON     73
      CTR=C1R-C2R                                                       SLBMON     74
      CTI=C1I-C2I                                                       SLBMON     75
      CURRNT=SQRT(CTR*CTR+CTI*CTI)                                      SLBMON     76
      IF( ABS(CTR)+ ABS(CTI).EQ. 0.0) CTR=0.0001                        SLBMON     77
      ZR=(EI*CTR+FI*CTI)/(CTR*CTR+CTI*CTI)                              SLBMON     78
      ZI=(FI*CTR-EI*CTI)/(CTR*CTR+CTI*CTI)                              SLBMON     79
C                                                                       SLBMON     80
C      TO CHECK-LOCUS                                                   SLBMON     81
C                                                                       SLBMON     82
C ------                                                                SLBMON     83
C   CHECK ZONE AND STORE THE ZONE NO.                                   SLBMON     84
C ------                                                                SLBMON     85
      STARTS=.FALSE.                                                    SLBMON     86
      RESETS=.FALSE.                                                    SLBMON     87
      TRPMOD=.FALSE.                                                    SLBMON     88
      TRPMOD=IADATA(K+6).GT.0                                           SLBMON     89
      II=IABS(IADATA(K+6))                                              SLBMON     90
C                                                                       SLBMON     91
        IZONE=5                                                         SLBMON     92
C                                                                       SLBMON     93
      IF(II.EQ.1 .OR. II.EQ.2)THEN                                      SLBMON     94
C                                                                       SLBMON     95
        S=ZR - ZI/TAN(ADATA(K+9))                                       SLBMON     96
        IF( S.LT.ADATA(K+11) )THEN                                      SLBMON     97
          IZONE=2                                                       SLBMON     98
        ELSEIF( S.LT.ADATA(K+10) )THEN                                  SLBMON     99
          IZONE=1                                                       SLBMON    100
        ENDIF                                                           SLBMON    101
                                                                        SLBMON    102
C                                                                       SLBMON    103
        IF(II.EQ.2)THEN                                                 SLBMON    104
          S=ZR - ZI/TAN(ADATA(K+12))                                    SLBMON    105
          IF( S.LT.ADATA(K+14) )THEN                                    SLBMON    106
            IZONE=4                                                     SLBMON    107
          ELSEIF( S.LT.ADATA(K+13) )THEN                                SLBMON    108
            IZONE=3                                                     SLBMON    109
          ENDIF                                                         SLBMON    110
        ENDIF                                                           SLBMON    111
C                                                                       SLBMON    112
C                                                                       SLBMON    113
      ENDIF                                                             SLBMON    114
C                                                                       SLBMON    115
C  --------                                                             SLBMON    116
C  CHECK BLINDER                                                        SLBMON    117
C  --------                                                             SLBMON    118
C                                                                       SLBMON    119
      JJ=IZONE                                                          SLBMON    120
      IBLIN1=0                                                          SLBMON    121
      IBLIN2=0                                                          SLBMON    122
      IF (ADATA(K+17).NE.0)THEN                                         SLBMON    123
        ISTART=K+17                                                     SLBMON    124
        CALL CHECKB(ISTART,IBLIN1,ZR,ZI)                                SLBMON    125
      ENDIF                                                             SLBMON    126
      IF (ADATA(K+21).NE.0)THEN                                         SLBMON    127
        ISTART=K+21                                                     SLBMON    128
        CALL CHECKB(ISTART,IBLIN2,ZR,ZI)                                SLBMON    129
      ENDIF                                                             SLBMON    130
C                                                                       SLBMON    131
C    -VE OF IZONE MEAN BEHIND THE BLINDER                               SLBMON    132
C                                                                       SLBMON    133
      IF (IBLIN1.EQ.1 .OR. IBLIN2.EQ.1) IZONE=-IZONE                    SLBMON    134
C                                                                       SLBMON    135
C   CHECK FOR ZONE CHANGE                                               SLBMON    136
C                                                                       SLBMON    137
      IF(IADATA(K+31).NE.IZONE )THEN                                    SLBMON    138
C                                                                       SLBMON    139
C    MOVED OUT OF ZONE 1 OR 3                                           SLBMON    140
C                                                                       SLBMON    141
        IF( JJ.NE.1 .AND. JJ.NE.3 )THEN                                 SLBMON    142
          JJ=ABS(IADATA(K+31))                                          SLBMON    143
          IF(JJ.EQ.1 .OR. JJ.EQ.3)THEN                                  SLBMON    144
            RESETS=.TRUE.                                               SLBMON    145
            GO TO 300                                                   SLBMON    146
          ENDIF                                                         SLBMON    147
        ELSE                                                            SLBMON    148
C                                                                       SLBMON    149
C    INSIDE ZONE 1 OR 3                                                 SLBMON    150
C                                                                       SLBMON    151
C       1.  BEHIND THE BLINDER, RESET FLAG                              SLBMON    152
C                                                                       SLBMON    153
           IF( IBLIN1.EQ.1 .OR. IBLIN2.EQ.1 )THEN                       SLBMON    154
              RESETS=.TRUE.                                             SLBMON    155
           ELSE                                                         SLBMON    156
              IF(IADATA(K+31).LT.0)GOTO 300                             SLBMON    157
C                                                                       SLBMON    158
              IF(II.EQ.1)THEN                                           SLBMON    159
                STARTS=.TRUE.                                           SLBMON    160
                IADATA(K+34)=IADATA(K+31)                               SLBMON    161
                GO TO 300                                               SLBMON    162
              ELSE                                                      SLBMON    163
                STARTS=(IZONE.EQ.1 .AND. IADATA(K+31).EQ.5) .OR.        SLBMON    164
     #          (IZONE.EQ.3 .AND. IADATA(K+31).EQ.4)                    SLBMON    165
                IF(.NOT.STARTS)RESETS=.TRUE.                            SLBMON    166
              ENDIF                                                     SLBMON    167
           ENDIF                                                        SLBMON    168
        ENDIF                                                           SLBMON    169
 300    IADATA(K+31) = IZONE                                            SLBMON    170
      ENDIF                                                             SLBMON    171
C ------------------                                                    SLBMON    172
C                                                                       SLBMON    173
C  CHECK AGAINST THE THREHOLD CURRENT                                   SLBMON    174
C                                                                       SLBMON    175
C -------------------                                                   SLBMON    176
C                                                                       SLBMON    177
      LHIGH=CURRNT.GT.ADATA(K+15)                                       SLBMON    178
                                                                        SLBMON    179
C ----                                                                  SLBMON    180
C                                                                       SLBMON    181
C   START INTER ZONE TRAVEL TIME                                        SLBMON    182
C                                                                       SLBMON    183
C ---                                                                   SLBMON    184
      IF(STARTS .AND. LHIGH)THEN                                        SLBMON    185
C                                                                       SLBMON    186
C   IADATA(K+29)=0 TIMER NOT STARTED | IADATA(K+30)=0 TIMER TIMEOUT     SLBMON    187
C                                                                       SLBMON    188
        IF(IADATA(K+29).EQ.0 .AND. IADATA(K+30).EQ.0)THEN               SLBMON    189
          IADATA(K+29) = 1                                              SLBMON    190
          ADATA(K+35)=TS+ADATA(K+8)                                     SLBMON    191
        ENDIF                                                           SLBMON    192
      ENDIF                                                             SLBMON    193
C ------                                                                SLBMON    194
C                                                                       SLBMON    195
C  CHECK ITER-ZONE TIME                                                 SLBMON    196
C                                                                       SLBMON    197
C ------                                                                SLBMON    198
      IF(IADATA(K+29).NE.0 .AND. IADATA(K+30).NE.1)THEN                 SLBMON    199
         IADATA(K+29) = 2                                               SLBMON    200
         IF(ADATA(K+35).LT.TS)IADATA(K+30)=1                            SLBMON    201
      ENDIF                                                             SLBMON    202
C ------                                                                SLBMON    203
C                                                                       SLBMON    204
C   CHECK OUT OF STEP                                                   SLBMON    205
C                                                                       SLBMON    206
C ------                                                                SLBMON    207
      OUTSTP=IADATA(K+30).EQ.1                                          SLBMON    208
      IF(OUTSTP)THEN                                                    SLBMON    209
        IF(II.EQ.1)THEN                                                 SLBMON    210
          OUTSTP=(IZONE.EQ.2 .AND. IADATA(K+34).EQ.5) .OR.              SLBMON    211
     #           (IZONE.EQ.5 .AND. IADATA(K+34).EQ.2)                   SLBMON    212
        ELSE                                                            SLBMON    213
          OUTSTP=IZONE.EQ.2                                             SLBMON    214
        ENDIF                                                           SLBMON    215
      ENDIF                                                             SLBMON    216
C                                                                       SLBMON    217
        IF(IADATA(K+32).EQ.0 .AND. IADATA(K+33).EQ.0)THEN               SLBMON    218
C                                                                       SLBMON    219
          IF(OUTSTP .AND. TRPMOD)THEN                                   SLBMON    220
            IADATA(K+32)=1                                              SLBMON    221
            ADATA(K+36)=ADATA(K+16)+TS                                  SLBMON    222
C ------                                                                SLBMON    223
C   ACTIVIATE REMOTE RELAYS                                             SLBMON    224
C ------                                                                SLBMON    225
            ICD1=2                                                      SLBMON    226
            IADATA(K+1) = ICD1                                          SLBMON    227
            IF(ICD4.NE.0)THEN                                           SLBMON    228
              KADD=K+36                                                 SLBMON    229
              CALL RTIMER(KADD,ICD4)                                    SLBMON    230
            ENDIF                                                       SLBMON    231
          ENDIF                                                         SLBMON    232
        ENDIF                                                           SLBMON    233
C                                                                       SLBMON    234
 2300  CONTINUE                                                         SLBMON    235
C -----                                                                 SLBMON    236
C  CHECK SELF TRIP TIMER                                                SLBMON    237
C -----                                                                 SLBMON    238
        IF(IADATA(K+32).NE.0 .AND. IADATA(K+33).NE.1)THEN               SLBMON    239
          ICD1=3                                                        SLBMON    240
          IADATA(K+1)=ICD1                                              SLBMON    241
          IADATA(K+32)=2                                                SLBMON    242
          IF(ADATA(K+36).LT.TS)IADATA(K+33)=1                           SLBMON    243
        ENDIF                                                           SLBMON    244
C -----                                                                 SLBMON    245
C  RESET INTER-ZONE TIMER                                               SLBMON    246
C -----                                                                 SLBMON    247
      IF(RESETS .AND. IADATA(K+29).NE.0)THEN                            SLBMON    248
        IADATA(K+29)=0                                                  SLBMON    249
        ADATA(K+35)=0.0                                                 SLBMON    250
      ENDIF                                                             SLBMON    251
c                                                                       SLBMON    252
C      IF (ADATA(K+8) .EQ. 1)THEN                                       SLBMON    253
C         IF (TS-ADATA(K+20) .GE. ADATA(K+15))THEN                      SLBMON    254
C            ADATA(K+8) = -1                                            SLBMON    255
C            WRITE (LOUT,1130) IADATA(K+2), TS                          SLBMON    256
C         ENDIF                                                         SLBMON    257
C      ENDIF                                                            SLBMON    258
C                                                                       SLBMON    259
C                                                                       SLBMON    260
      IF(ICD1 .NE. 3) GO TO 2350                                        SLBMON    261
C                                                                       SLBMON    262
C    GET THE LINE INFORMATION AND WRITE INTO IU12                       SLBMON    263
C                                                                       SLBMON    264
      ICD1=4                                                            SLBMON    265
      IADATA(K+1)=ICD1                                                  SLBMON    266
      IF((IADATA(K+5).EQ.1))THEN                                        SLBMON    267
C                                                                       SLBMON    268
       NJSELI=IADATA(K+29)                                              SLBMON    269
C                                                                       SLBMON    270
       IF(IASWX.EQ.0)THEN                                               SLBMON    271
        WRITE(ISWFA,4100)TS                                             SLBMON    272
 4100   FORMAT(F10.5)                                                   SLBMON    273
        NAWR=NAWR+1                                                     SLBMON    274
        IASWX=1                                                         SLBMON    275
       ENDIF                                                            SLBMON    276
C                                                                       SLBMON    277
       IF(NJSELI.NE.0)THEN                                              SLBMON    278
        WRITE(ISWFA,4200)IBUS,JBUS,CID                                  SLBMON    279
 4200   FORMAT('DPIA',2I5,1X,A2)                                        SLBMON    280
       ELSE                                                             SLBMON    281
        WRITE(ISWFA,4300)IBUS,JBUS,CID                                  SLBMON    282
 4300   FORMAT('DLIA',2I5,1X,A2)                                        SLBMON    283
       ENDIF                                                            SLBMON    284
C                                                                       SLBMON    285
       NAWR=NAWR+1                                                      SLBMON    286
C                                                                       SLBMON    287
      ENDIF                                                             SLBMON    288
C                                                                       SLBMON    289
C * * * ICD4 IS THE NUMBER OF REMOTE RELAYS ATTACHED TO THIS LOCAL      SLBMON    290
C * * * RELAY.  TTIMR1 IS THE TRANSFER TRIP TIMER.                      SLBMON    291
C * * *                                                                 SLBMON    292
 2350 IF(ICD4.EQ.0) GO TO 2400                                          SLBMON    293
C                                                                       SLBMON    294
C * * *                                                                 SLBMON    295
C * * * PROCESS REMOTE RELAY LOGIC                                      SLBMON    296
C * * *                                                                 SLBMON    297
       IF(IADATA(K+5).EQ.1)THEN                                         SLBMON    298
        IF(IADATA(K+1).GE.2.AND.IADATA(K+1).LE.4)THEN                   SLBMON    299
          KADD=K+36                                                     SLBMON    300
          KBUS=K                                                        SLBMON    301
          IPOINT=8                                                      SLBMON    302
          CALL RETRIP(KADD,KBUS,ICD4,IPOINT)                            SLBMON    303
          IF(IADATA(KBUS+IPOINT).EQ.-1)THEN                             SLBMON    304
           ICD1=5                                                       SLBMON    305
           IADATA(K+1) = ICD1                                           SLBMON    306
          ENDIF                                                         SLBMON    307
        ENDIF                                                           SLBMON    308
       ENDIF                                                            SLBMON    309
C                                                                       SLBMON    310
C                                                                       SLBMON    311
 2400 CONTINUE                                                          SLBMON    312
      RETURN                                                            SLBMON    313
      END                                                               SLBMON    314
C                                                                       SLBMON    315
      SUBROUTINE CHECKB(ISTART,IBLIN,ZR,ZI)                             SLBMON    316
      INCLUDE 'PARX.INS'                                                SLBMON    317
      INCLUDE 'CNAUTO.INS'                                              SLBMON    318
      IBLIN=0                                                           SLBMON    319
      ITYPE=IABS(IADATA(ISTART))                                        SLBMON    320
      IF(ITYPE.EQ.1)THEN                                                SLBMON    321
        Y=ADATA(ISTART+1)+TAN(ADATA(ISTART+2))*ZR                       SLBMON    322
        IF(Y.GT.ZI)IBLIN=1                                              SLBMON    323
      ELSE IF(ITYPE.EQ.2)THEN                                           SLBMON    324
        X=ZI/TAN(ADATA(ISTART+2))+ADATA(ISTART+2)                       SLBMON    325
        IF(X.GT.ZR)IBLIN=1                                              SLBMON    326
      ENDIF                                                             SLBMON    327
      RETURN                                                            SLBMON    328
      END                                                               SLBMON    329
