
Error_Checking   IDNT                    ; Title of  Program Module

    SECTION   Sect_Error_Checking,4,C    ; Declare a noncommon code section.
                                         ; Align to Longwords.

***************************************************************************
*                                                                         *
*   Signal Finished Processing                         Rev.  21-JUL-1994  *
*                                                                         *
***************************************************************************

***************************************************************************
*                                                                         *
*  Error Checking Section.                                                *
*                                                                         *
*  This routine will verify that the following is correct:                *
*                                                                         *
*    From the Pilot COMINT Card:                                          *
*                                                                         *
*    There are 4 Longwords of Trigger Tower data that are read at the     *
*    very beginning of the Pilot COMINT PROM's and are read again at      *
*    the very end of the PROM's.  There are 4 HD Trigger Towers and 4     *
*    EM Trigger Towers (all near eta zero).  Verify that the two reads    *
*    of this data have the same values.                                   *
*                                                                         *
*    From the Assistant COMINT Card:                                      *
*                                                                         *
*    Verify that the Spec Trig's Fired List read near the begining of     *
*    the COMINT PROM's matches the Spec Trig's Fired List read at the     *
*    end of the COMINT PROM's.  Note also that the main routine           *
*    Spec-Trig_Fire_1  which makes the Trig list in location TrigsFired   *
*    uses the 1st hardware copy of the Spec Trig's Fired information      *
*    where as the Error Checking routine is using the 3rd hardware copy   *
*    of the Spec Trig's Fired information.  Thus this checks both that    *
*    the hardware list of Spec Trig's Fired has not been overwritten and  *
*    that the 1st and 3rd hardware copies of this list are the same.      *
*                                                                         *
*    Verify that the Beam Crossing Number read near the begining of the   *
*    COMINT PROM's is equal to the Beam Crossing Number read at the end   *
*    of the COMNT PROM's.  Make this test on the low order 16 bits of     *
*    the Beam Crossing Numbers.                                           *
*                                                                         *
*    Verify that the Current Beam Crossing Number is equal to 1 more      *
*    than the Previous Beam Crossing Number.   Make this test on the      *
*    low order 32 bits of the Beam Crossing Numbers.                      *
*                                                                         *
*                                                                         *
*                                                                         *
*  Control of the Trouble Warning Bits                                    *
*     none                                                                *
*                                                                         *
*  Control of the State Bits                                              *
*     none                                                                *
*                                                                         *
***************************************************************************


***************************************************************************
*                                                                         *
*   This is the section to verify that the List of Spec Trig's Fired      *
*   is still intacted when read at the very end of the COMINT PROM's.     *
*                                                                         *
*   Build the List of Spec Trig's Fired based on the reads of the IMLRO   *
*   hardware near the very end of the COMINT PROM's.  Note that at the    *
*   end of the COMINT PROM's they are reading the 3rd hardware copy of    *
*   the Spec Trig's Fired.  This list will be compared to the list built  *
*   by the Spec_Trig_Fired routine which is based on IMLRO reads of the   *
*   1st hardware copy of Spec Trig's Fired near the very begining of the  *
*   COMINT PROM's.                                                        *
*                                                                         *
*   Build a list of Specific Triggers that Fired for this event in D1.    *
*                                                                         *
*   See the routine  SPEC_TRIG_PROG_FIRE_1.SRC  for full details.         *
*                                                                         *
*   Recall how the Spec Trig's Fired information which is read near the   *
*   very end of the COMINT PROM's is stored in VME memory. This is a      *
*   read of the 3rd hardware copy of Spec Trig's Fired.                   *
*                                                                         *
*    VME       3     2 2     1 1                                          *
*    Addrs     1     4 3     6 5     8 7     0       Bits in a long word  *
*    -----     -     - -     - -     - -     -                            *
*             ---------------------------------                           *
*    302A50   |       |       |       |       |                           *
*             ---------------------------------                           *
*    302A54   |       | 2nd B |       | 1st B |      Bytes of Specific    *
*             ---------------------------------      Triggers Fired Data  *
*    302A58   |       | 4th B |       | 3rd B |      in VME Memory.       *
*             ---------------------------------                           *
*    302A5C   |       |       |       |       |                           *
*             ---------------------------------                           *
*                                                                         *
***************************************************************************

                                     ; Now build the List of Spec Trig's Fired
                                     ; using the data read from addresses
                                     ; 5417:5420  of  March_1993_CBus_0.ASF

Begin_Error_Checking   Move.L  EC_SpTrgFr+4,D2    ; Get the Error Check
                                                  ; Spec Trigs Fired
        Move.L   D2,D1                            ; 4th and 3rd bytes.
        LSR.L    #8,D1               ;
        Move.B   D2,D1               ;
        LSL.L    #8,D1               ;
        Move.L   EC_SpTrgFr,D2       ; Get the Error Check
        Swap     D2                  ; Spec Trigs Fired 2nd and 1st bytes.
        Move.B   D2,D1               ;
        Swap     D2                  ;
        LSL.L    #8,D1               ;
        Move.B   D2,D1               ; D1 now has the List of Spec Trig's
                                     ;   Fired based on data from COMINT
                                     ;   PROM Addresses  5417:5420.  These
                                     ;   are a read of the 3rd hardware copy.

        Move.L   TrgsFired,D0        ; Move the List of Spec Trig's Fired
                                     ;   build from reads near the start
                                     ;   of the COMINT PROM's into reg D0.
                                     ;   This list is based on the 1st
                                     ;   hardware copy of this information.

        IF.L  D0 <NE> D1  THEN.S     ; Test to see if the two versions of the
                                     ;   Spec Trig's Fired List are equal.
           PEA.L  SpTrgFrLs_Err      ;   If NOT then, send out
           JSR    ChrWrtOut          ;   the message "TF".

        ENDI                         ;


***************************************************************************
*                                                                         *
*   This is the section that verifies that the Beam Crossing Number       *
*   that is read at the very end of the COMINT PROM's is the same value   *
*   as the Beam Crossing Number that is read early in the COMINT PROM's.  *
*   The 2 low order bytes will be checked.  This is good for a little     *
*   over 200 msec.                                                        *
*                                                                         *
***************************************************************************

          CLR.L   D0                     ;
          CLR.L   D1                     ;

          Move.B  DB_BX_Num_2B,D0        ; Get the 2nd byte of the Data
                                         ;   Block Beam Crossing Number
          LSL.L   #8,D0                  ; and Shift it up 8 bits.
          Move.B  DB_BX_Num_1B,D0        ; Get the 1st byte of the Data
                                         ;   Block Beam Crossing Number

          Move.B  EC_BX_Num_2B,D1        ; Get the 2nd byte of the Error
                                         ;   Check Beam Crossing Number
          LSL.L   #8,D1                  ; and Shift it up 8 bits.
          Move.B  EC_BX_Num_1B,D1        ; Get the 1st byte of the Error
                                         ;   Check Beam Crossing Number

          IF.L  D0 <NE> D1  THEN.S       ; Test to see if the two versions of
                                         ; the Beam Crossing Number are equal.
             PEA.L  BX_Num_Err           ; If NOT then, send out the
             JSR    ChrWRTOut            ; message "BX".

          ENDI                           ;


***************************************************************************
*                                                                         *
*    Verify that the Current Beam Crossing Number is equal to 1 more      *
*    than the Previous Beam Crossing Number.   Make this test on the      *
*    low order 32 bits of the Beam Crossing Numbers.                      *
*                                                                         *
***************************************************************************

          CLR.L   D0                     ;
          CLR.L   D1                     ;

          Move.B  DB_BX_Num_4B,D0        ; 4th byte of the Current BX Num.
          LSL.L   #8,D0                  ;   and Shift it up 8 bits.
          Move.B  DB_BX_Num_3B,D0        ; 3rd byte of the Current BX Num.
          LSL.L   #8,D0                  ;   and Shift it up 8 bits.
          Move.B  DB_BX_Num_2B,D0        ; 2nd byte of the Current BX Num.
          LSL.L   #8,D0                  ;   and Shift it up 8 bits.
          Move.B  DB_BX_Num_1B,D0        ; 1st byte of the Current BX Num.

          Move.B  Pr_BX_Num_4B,D1        ; 4th byte of the Previous BX Num.
          LSL.L   #8,D1                  ;   and Shift it up 8 bits.
          Move.B  Pr_BX_Num_3B,D1        ; 3rd byte of the Previous BX Num.
          LSL.L   #8,D1                  ;   and Shift it up 8 bits.
          Move.B  Pr_BX_Num_2B,D1        ; 2nd byte of the Previous BX Num.
          LSL.L   #8,D1                  ;   and Shift it up 8 bits.
          Move.B  Pr_BX_Num_1B,D1        ; 1st byte of the Previous BX Num.

          Add.L   #1,D1                  ; Add 1 to the Previous BX Number.

          IF.L  D0 <NE> D1  THEN.S       ; Test if the Current BX Num and 1
                                         ;   plus the Previous BX Num are
             PEA.L  CP_BX_Err            ;   equal.  If not then, send out
             JSR    ChrWRTOut            ;   the message "CP".

          ENDI                           ;


*************************************************************************
*                                                                       *
*  Test data read by the Pilot COMINT.   The first 10 PROM addresses    *
*  and the last 10 PROM addresses read by the Pilot COMINT are error    *
*  checking reads.  For now 8 of these PROM locations are reads of      *
*  Trigger Tower data from HD and EM towers near eta zero.  Verify      *
*  that the read of this data at the Beginning of the PROM's is the     *
*  same as the read of this data at the end of the PROM's.              *
*************************************************************************

          Move.L  CT_EC_Read_1_B,D0      ; Move the 1st Beginning LW to D0.
          Move.L  CT_EC_Read_1_E,D1      ; Move the 1st Ending LW to D1.
          IF.L  D0 <NE> D1  THEN.S       ; Test if the 1st Error Check Read at
             PEA.L  Pilot_Data_Err       ;   the Beginning of the PROM's is
             JSR    ChrWRTOut            ;   equal to the read at the End of
          ENDI                           ;   the PROM's. If not then message.

          Move.L  CT_EC_Read_2_B,D0      ; Move the 2nd Beginning LW to D0.
          Move.L  CT_EC_Read_2_E,D1      ; Move the 2nd Ending LW to D1.
          IF.L  D0 <NE> D1  THEN.S       ; Test if the 2nd Error Check Read at
             PEA.L  Pilot_Data_Err       ;   the Beginning of the PROM's is
             JSR    ChrWRTOut            ;   equal to the read at the End of
          ENDI                           ;   the PROM's. If not then message.

          Move.L  CT_EC_Read_3_B,D0      ; Move the 3rd Beginning LW to D0.
          Move.L  CT_EC_Read_3_E,D1      ; Move the 3rd Ending LW to D1.
          IF.L  D0 <NE> D1  THEN.S       ; Test if the 3rd Error Check Read at
             PEA.L  Pilot_Data_Err       ;   the Beginning of the PROM's is
             JSR    ChrWRTOut            ;   equal to the read at the End of
          ENDI                           ;   the PROM's. If not then message.

          Move.L  CT_EC_Read_4_B,D0      ; Move the 4th Beginning LW to D0.
          Move.L  CT_EC_Read_4_E,D1      ; Move the 4th Ending LW to D1.
          IF.L  D0 <NE> D1  THEN.S       ; Test if the 4th Error Check Read at
             PEA.L  Pilot_Data_Err       ;   the Beginning of the PROM's is
             JSR    ChrWRTOut            ;   equal to the read at the End of
          ENDI                           ;   the PROM's. If not then message.



*************************************************************************
*                                                                       *
*  Check the Bunch Number:                                              *
*                                                                       *
*  We deternime the Bunch Number by reading the And-Or Input Terms      *
*  where the "Bunch_P%" terms are connected.   These are                *
*                                                                       *
*    Bunch_P%     And-Or Input Term Number                              *
*   ----------   --------------------------                             *
*      P1                96                                             *
*      P2                97                                             *
*      P3                98                                             *
*      P4                99                                             *
*      P5               100                                             *
*      P6               101                                             *
*                                                                       *
*  Note that And-Or Term 102 is Zero_Bias and Term 103 is Test_Event.   *
*                                                                       *
*  And-Or Input Terms 103:96 used with Spec Trig's 0:15 are read as     *
*  Note 967 Item Numbers 381.  This comes from CBus=2, MBA=130, CA=50,  *
*  FA=140.                                                              *
*                                                                       *
*  And-Or Input Terms 103:96 used with Spec Trig's 16:31 are read as    *
*  Note 967 Item Numbers 413.  This comes from CBus=2, MBA=66, CA=50,   *
*  FA=140.                                                              *
*                                                                       *
*  We can read these And-Or Input Terms in 4 different places:          *
*                                                                       *
*                                      COMINT     MVME214               *
*                                       PROM      VME Byte              *
*      Beam Xing    For Spec Trig's     Adrs      Address               *
*      ---------    ---------------     ----      --------              *
*       Current     Spec Trig  0:15      391      $320313               *
*       Current     Spec Trig 16:31      423      $320353               *
*       Previous    Spec Trig  0:15      923      $32073B               *
*       Previous    Spec Trig 16:31      955      $32077B               *
*                                                                       *
*  Thus we can make a number of tests on the Bunch Number:              *
*                                                                       *
*  1. Does the Current Beam Crossing Bunch Number read for Spec Trig's  *
*     0:15 equal that read for Spec Trig's 16:31 ?                      *
*                                                                       *
*  2. Is one and only one Bunch_P% And-Or Input Term Set TRUE ?         *
*                                                                       *
*  3. Does the Current Beam Crossing Bunch Number equal 1 plus the      *
*     Previous Beam Crossing Bunch Number  (carry at 6).                *
*                                                                       *
*  4. Optionally print the Current Beam Crossing Bunch Number.          *
*                                                                       *
*************************************************************************


          Move.B     $00320313,D0        ; Get the Current Bunch Number used
          AndI.L     #$0000003F,D0       ; for Spec Trig's 15:0.

          Move.B     $00320353,D1        ; Get the Current Bunch Number used
          AndI.L     #$0000003F,D1       ; for Spec Trig's 31:16


          IF.L   D0 <NE> D1   THEN.S     ; Do these two versions of the
             PEA.L  BN_Read_Err          ; Current Bunch Number match ?
             JSR    ChrWRTOut            ; If not print an error message.
          ENDI                           ;


          Move.B     $0032073B,D1        ; Get the Previous Bunch Number
          AndI.L     #$0000003F,D1       ; used for Spec Trigs 15:0

          Clr.L      D2                  ; Clear this software flag.  It will
                                         ; be set as soon as we find a valid
                                         ; Bunch Number.

                                         ; Test that Current Bunch Number =
                                         ; 1 + Previous Bunch Number.  Set
                                         ; flag that we found a valid Current

          IF.L   D0 <EQ> #$00000001  THEN.S       ; Is the Current Bunch Number
             IF.L   D1 <NE> #$00000020   THEN.S   ; P1 ?  If not skip the rest.
                PEA.L  M1_Error                   ; Then if the Previous Bunch
                JSR    ChrWRTOut                  ; is not P6, Print an error
             ENDI                                 ; message.
             Move.B  #$0F,D2                      ; Set "valid Bunch Nmbr" Flag.
;:*          PEA.L  Bunch_1_Msg                   ; Print message that this
;:*          JSR    ChrWRTOut                     ; is the P1 Bunch.
          ENDI                                    ;


          IF.L   D0 <EQ> #$00000002  THEN.S       ; Is the Current Bunch Number
             IF.L   D1 <NE> #$00000001   THEN.S   ; P2 ?  If not skip the rest.
                PEA.L  M2_Error                   ; Then if the Previous Bunch
                JSR    ChrWRTOut                  ; is not P1, Print an error
             ENDI                                 ; message.
             Move.B  #$0F,D2                      ; Set "valid Bunch Nmbr" Flag.
;:*          PEA.L  Bunch_2_Msg                   ; Print message that this
;:*          JSR    ChrWRTOut                     ; is the P2 Bunch.
          ENDI                                    ;


          IF.L   D0 <EQ> #$00000004  THEN.S       ; Is the Current Bunch Number
             IF.L   D1 <NE> #$00000002   THEN.S   ; P3 ?  If not skip the rest.
                PEA.L  M3_Error                   ; Then if the Previous Bunch
                JSR    ChrWRTOut                  ; is not P2, Print an error
             ENDI                                 ; message.
             Move.B  #$0F,D2                      ; Set "valid Bunch Nmbr" Flag.
;:*          PEA.L  Bunch_3_Msg                   ; Print message that this
;:*          JSR    ChrWRTOut                     ; is the P3 Bunch.
          ENDI                                    ;


          IF.L   D0 <EQ> #$00000008  THEN.S       ; Is the Current Bunch Number
             IF.L   D1 <NE> #$00000004   THEN.S   ; P4 ?  If not skip the rest.
                PEA.L  M4_Error                   ; Then if the Previous Bunch
                JSR    ChrWRTOut                  ; is not P3, Print an error
             ENDI                                 ; message.
             Move.B  #$0F,D2                      ; Set "valid Bunch Nmbr" Flag.
;:*          PEA.L  Bunch_4_Msg                   ; Print message that this
;:*          JSR    ChrWRTOut                     ; is the P4 Bunch.
          ENDI                                    ;


          IF.L   D0 <EQ> #$00000010  THEN.S       ; Is the Current Bunch Number
             IF.L   D1 <NE> #$00000008   THEN.S   ; P5 ?  If not skip the rest.
                PEA.L  M5_Error                   ; Then if the Previous Bunch
                JSR    ChrWRTOut                  ; is not P4, Print an error
             ENDI                                 ; message.
             Move.B  #$0F,D2                      ; Set "valid Bunch Nmbr" Flag.
;:*          PEA.L  Bunch_5_Msg                   ; Print message that this
;:*          JSR    ChrWRTOut                     ; is the P5 Bunch.
          ENDI                                    ;


          IF.L   D0 <EQ> #$00000020  THEN.S       ; Is the Current Bunch Number
             IF.L   D1 <NE> #$00000010   THEN.S   ; P6 ?  If not skip the rest.
                PEA.L  M6_Error                   ; Then if the Previous Bunch
                JSR    ChrWRTOut                  ; is not P5, Print an error
             ENDI                                 ; message.
             Move.B  #$0F,D2                      ; Set "valid Bunch Nmbr" Flag.
;:*          PEA.L  Bunch_6_Msg                   ; Print message that this
;:*          JSR    ChrWRTOut                     ; is the P6 Bunch.
          ENDI                                    ;


          IF.B   D2 <NE> #$0F   THEN.S            ; Has the D2 flag been set?
             PEA.L  No_Valid_BN_Err               ; If not then no valid
             JSR    ChrWRTOut                     ; Bunch Number was found.
          ENDI


          RTS                            ; Return to the calling routine.


*************************************************************************
*  Define Constants:                                                    *
*                                                                       *
*  Data used to send messages to the VTC console terminal screen.       *
*                                                                       *
*************************************************************************

                 ALIGN    4                   ; Align to Longword Address.
BX_Num_Err       DC.B     4,$0D,$0A,'BX'      ; BX ---> Beam Crossing.

                 ALIGN    4                   ; Align to Longword Address.
CP_BX_Err        DC.B     4,$0D,$0A,'CP'      ; CP ---> Current vs Previous.

                 ALIGN    4                   ; Align to Longword Address.
SpTrgFrLs_Err    DC.B     4,$0D,$0A,'TF'      ; TF ---> spec Trigs Fired list.

                 ALIGN    4                   ; Align to Longword Address.
Pilot_Data_Err   DC.B     4,$0D,$0A,'PD'      ; PD ---> Pilot comint Data.


                 ALIGN    4                   ; Align to Longword Address.
BN_Read_Err      DC.B     4,$0D,$0A,'BR'      ; BR ---> Bunch Number Read Error


                 ALIGN    4                   ; Align to Longword Address.
M1_Error         DC.B     4,$0D,$0A,'M1'      ; M1 ---> Error during Bunch 1

                 ALIGN    4                   ; Align to Longword Address.
M2_Error         DC.B     4,$0D,$0A,'M2'      ; M1 ---> Error during Bunch 2

                 ALIGN    4                   ; Align to Longword Address.
M3_Error         DC.B     4,$0D,$0A,'M3'      ; M1 ---> Error during Bunch 3

                 ALIGN    4                   ; Align to Longword Address.
M4_Error         DC.B     4,$0D,$0A,'M4'      ; M1 ---> Error during Bunch 4

                 ALIGN    4                   ; Align to Longword Address.
M5_Error         DC.B     4,$0D,$0A,'M5'      ; M1 ---> Error during Bunch 5

                 ALIGN    4                   ; Align to Longword Address.
M6_Error         DC.B     4,$0D,$0A,'M6'      ; M1 ---> Error during Bunch 6


                 ALIGN    4                   ; Align to Longword Address.
Bunch_1_Msg      DC.B     4,$0D,$0A,'X1'      ; X1 --->  Bunch 1

                 ALIGN    4                   ; Align to Longword Address.
Bunch_2_Msg      DC.B     4,$0D,$0A,'X2'      ; X1 --->  Bunch 2

                 ALIGN    4                   ; Align to Longword Address.
Bunch_3_Msg      DC.B     4,$0D,$0A,'X3'      ; X1 --->  Bunch 3

                 ALIGN    4                   ; Align to Longword Address.
Bunch_4_Msg      DC.B     4,$0D,$0A,'X4'      ; X1 --->  Bunch 4

                 ALIGN    4                   ; Align to Longword Address.
Bunch_5_Msg      DC.B     4,$0D,$0A,'X5'      ; X1 --->  Bunch 5

                 ALIGN    4                   ; Align to Longword Address.
Bunch_6_Msg      DC.B     4,$0D,$0A,'X6'      ; X1 --->  Bunch 6


                 ALIGN    4                   ; Align to Longword Address.
No_Valid_BN_Err  DC.B     4,$0D,$0A,'NV'      ; NV --->  No Valid Bunch Number.



*************************************************************************
*  Define Constants:                 External References                *
*                                                                       *
*************************************************************************

       XDEF   Begin_Error_Checking                  ; Export this symbol
                                                    ; to other modules.

       XREF   TrgsFired                             ; Symbols referenced
       XREF   EC_SpTrgFr                            ; in this program
       XREF   EC_BX_Num_1B                          ; module but defined
       XREF   EC_BX_Num_2B                          ; in another module
       XREF   DB_BX_Num_1B                          ; Main_Symbols.Include
       XREF   DB_BX_Num_2B
       XREF   DB_BX_Num_3B
       XREF   DB_BX_Num_4B
       XREF   Pr_BX_Num_1B
       XREF   Pr_BX_Num_2B
       XREF   Pr_BX_Num_3B
       XREF   Pr_BX_Num_4B
       XREF   ChrWrtOut
       XREF   CT_EC_Read_1_B,CT_EC_Read_1_E
       XREF   CT_EC_Read_2_B,CT_EC_Read_2_E
       XREF   CT_EC_Read_3_B,CT_EC_Read_3_E
       XREF   CT_EC_Read_4_B,CT_EC_Read_4_E
       XREF   CT_EC_Read_5_B,CT_EC_Read_5_E


       END

