sub Analog_Functional_Tests (Status_Code, Message$)
global All_Failed
global BoardSet_boards_2_to_2(*)
global BoardSet_boards_1_to_1(*)
global BoardSet_boards_4_to_4(*)
global BoardSet_boards_3_to_3(*)
global BoardSet(*)

!  Define arrays needed for Led Testing
dim Fibernum(0:7), Data(0:24), Sen(0:7)
dim Data1(0:8), Data2(0:8), Data3(0:8), Data4(0:8), Data5(0:8), Data6(0:8)
dim Data7(0:8)

   if Message$ <> "" then  print tab(5);Message$
   call Panel_Enable_Boards

Led_Analyser_Tests:

  if Boardset(4) then

!*!-------------------------------------------------------------
!  Turn power ON for the LED's to be tested & the Led Analyser

     sps 3,5.00,1.00;optimize      ! 5V to the Led Analyser
     sps 4,5.00,1.00;optimize      ! 5V to Led Demo Brd

wait 0.50


!**********************************************
! NOTE: Edit all the Led Analyser Tests       *
!       to remove the assign Floating Inputs  *
!       in the disable section and recompile  *
!       - see Example in the documentation CD *
!**********************************************

!*!--------------------------------------------------------------
!  Select the test format you want, Frequency Mode - HSI, WSI, XYI
!  or Synchronous Serial
!  or Sequence Capture Modes
!  By uncommenting the test you want below
!----------------------------------------------------------------

  goto Frequency_mode
!   goto SyncSerial_mode
!  goto SequenceCapture_mode

Frequency_mode:

!*! ------------------------------------------------------------
!*! The are 3 possible Frequency Modes available to test with.
!*! Hue, Satutration, Intensity (HSI)
!*! Wavelength, Saturation, Intensity (WSI)
!*! xChromaticity, yChromaticity, Intensity (xyI)
!*! To use the Led Analyser in either of these FREQUENCY MODEs
!*! Connect the Led analyser to a PC using the Serial port - cable supplied
!*! Launch the Terminal program provided on the CD
!*! type   getictstatus
!*! It will respond with Frequency out mode : HSI      (factory preset)
!*! Select the mode you require by typing
!*! setfrequencyxxx where xxx is the required mode
!*! Disconnect from the PC and proceed to Fixture/Program debug
!*! ------------------------------------------------------------




!**********  Select the SENSITIVITY / SETFACTOR of the Analyser
!*!
!*! The sensitivity level or Exposure level of the Analyser has a range 1-15
!*! The default setting is 1. Setting the sensitivity to 2 doubles the
!*! measurement test time and increases the intensity values etc..
!*! The need to change from the default is for testing dim Leds
!*!
!*! RUN THIS TEST in DEBUG mode ONLY as running constantly during production
!*! will eventually corrupt the Analyser after 100,000 writes approx.

!   test "4%feasa_20i%la_setfactor_f"




!**************** Capture Command ***************************
!
! There are many different capture modes which are possible in Frequency Mode
! C(Auto Range), C1-C5(Manual Ranges Low, Medium, High, Super, Ultra) or PWM.
! To select the range you want please edit the la_capture_f or
! la_cap_n read_f_hsi, la_cap_n read_f_wsi or la_cap_n read_f_xyi models

! To adjust your HSI (Hue, Saturation & Intensity) readings please edit the
! analog portion of the la_read_hsi_f mixed test

! To adjust your WSI (Wavelength, Saturation & Intensity) readings please
! edit the analog portion of the la_read_wsi_f mixed test

! To adjust your xyI (xyChromaticity & Intensity) readings please edit the
! analog portion of the la_read_xyi_f mixed test




!******* SELECT THE FREQUENCY TEST MODE you require *************

  print tab(5);"        Capture & Read"
  print tab(5);"        Frequency Mode HSI"
  test "4%feasa_20i%la_cap_n_read_f_hsi"

   print tab(5);"        Capture & Read"
!  print tab(5);"        Frequency Mode WSI"
!  test "4%feasa_20i%la_cap_n_read_f_wsi"

!  print tab(5);"        Capture & Read"
!  print tab(5);"        Frequency Mode XYI"
!  test "4%feasa_20i%la_cap_n_read_f_xyi"

goto End_LA






!*! *************************************************************
SyncSerial_mode:

  print tab(5);"        Synchronous Serial Mode"

!***  Select the SENSITIVITY / SETFACTOR of the Analyser in ss mode
!*!
!*! The sensitivity level or Exposure level of the Analyser has a range 1-15
!*! The default setting is 1. Setting the sensitivity to 2 doubles the
!*! measurement test time and increases the intensity values etc..
!*! The need to change from the default is for testing very dim Leds

!*! RUN THIS TEST in DEBUG mode ONLY as running constantly during production
!*! will eventually corrupt the Analyser after 100,000 writes approx.

!*! To verify or change the sensitivity level of the Led Analyser
!*! Uncomment the 9 lines below.

! Sensitivity = 1         ! Test Sensitivity Default = 1 max = 15

! for Data_bit = 0 to 7   ! Convert Decimal number to binary number
!   Sen(Data_bit) =  bit(Sensitivity,(7-Data_bit))  ! extract each binary bit
! next Data_bit


!  test "4%feasa_20i%la_setfactor_ss" ! Set Sensitivity OK


! print "Sensitivity Level:"
! print Data(0)  ! This is the sensitivity read back from the test





!******************** CAPTURE COMMAND  **************************
!*!
!*! There are many different capture modes which are possible through the Sync
!*! Serial port, Auto Range, Manual Range #1 to #5 and PWM Capture
!*! Each of these capture modes is very similar except that the command send to
!*! the Analyser is changed as listed after each test

!*! *** Capture Commands ****
!*!   (0X55) Auto Range
!*!   (0XA1) Manual Range #1    (Low)
!*!   (0XA2) Manual Range #2    (Medium)
!*!   (0XA3) Manual Range #3    (High)
!*!   (0XA4) Manual Range #4    (Super High)
!*!   (0XA5) Manual Range #5    (Ultra)
!*!   (0X90) Get Intensity for Fiber ##
!*!   (0X91) Sequence Capture Fiber No + Capture No  ## + ###
!*!   (0XC0) Capture Time + Wait Time + Sequence Number
!*!   (0X45) Capture Sequence #



Command$ = "55" ! Command to send to analyser

CommandInt = hti(Command$)                      ! Convert to Integer
CommandBin$ = itb$(CommandInt)                  ! Convert to Binary
CommandBin$ = "00000000" & CommandBin$          ! Add leading zeros
CommandBin$ = CommandBin$[len(CommandBin$)-7;8] ! Extract the last 8 bits

! print CommandBin$

  for Data_bit = 1 to 8      ! Convet the fiber number to binary
    Data(Data_bit) =  val(CommandBin$[Data_bit;1])
  next Data_bit

! print Data(*)             ! Debug Help

!*! Choose either Standard or PWM capture mode here

  print tab(5);"        Synchronous Serial Mode Capture"
  test "4%feasa_20i%la_capture_ss"; Data(*)

!    or

! print tab(5);"        Synchronous Serial Mode Capture PWM"
! test "4%feasa_20i%la_capture_pwm_ss"; Data(*)






!******************* RESULTS FORMAT *****************************
!*! Select the results format you want by uncommenting the goto statement

   goto SyncSerial_HSI_results
!  goto SyncSerial_RGB_results
!  goto SyncSerial_WSI_results
!  goto SyncSerial_Wave_results
!  goto SyncSerial_xyI_results
!  goto SyncSerial_cct_results
!  goto SyncSerial_absint_results






!****************************************************************
SyncSerial_HSI_results:
  print tab(5);"        Synchronous Serial Mode HSI"

!*! The Feasa 20-I is shipped with 20 fibers, the Feasa 10-I with 10 fibers etc.
!*! Select here the number of Fibers you are using.

for I = 1 to 20  ! 20 Fibers

  for Data_bit = 0 to 7    !Convet the fiber number to binary
    Fibernum(Data_bit) =  bit(I,(7-Data_bit))
  next Data_bit

test "4%feasa_20i%la_read_hsi_ss" ; Fibernum(*), Data(*)   ! Read H,S,I

  Hue = ((Data(0) * 256) + Data(1))/100                      ! Hue
  Saturation = Data(2)                                       ! Saturation
  Intensity = (Data(3) * 65536) + (Data(4) * 256) + Data(5)  ! Intensity

!*! Uncomment the following 2 lines for debug purposes only
!*!
! print Data(0);Data(1);Data(2);Data(3);Data(4);Data(5)      ! print Data
! print I; Hue; Saturation; Intensity                        ! print HSI
!***************************************************************************

!*!---------- Fiber 1

 if Hue < 0.01 or Hue > 3 or Saturation < 90 or Saturation > 101 or Intensity < 2k or Intensity > 20k then
   if  I = 1 then
      fail device
      report "------------------------------ "
      report "     Failed HSI for D1         "
      report " Hue   High 003 Low .01  "; Hue
      report " Sat   High 101 Low 090  "; Saturation
      report " Int   High 20k Low 2k   "; Intensity
      report "------------------------------ "
    end if
  end if

!*!---------- Fiber 2

 if Hue < 120 or Hue > 130 or Saturation < 90 or Saturation > 101 or Intensity < 2k or Intensity> 20k then
   if  I = 2 then
      fail device
      report "------------------------------ "
      report "     Failed HSI for D2         "
      report " Hue   High 130 Low 120  "; Hue
      report " Sat   High 101 Low 090  "; Saturation
      report " Int   High 20k Low 2k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 3

 if Hue < 235 or Hue > 245 or Saturation < 90 or Saturation > 101 or Intensity < 2k or Intensity > 25k then
   if  I = 3 then
      fail device
      report "------------------------------ "
      report "     Failed HSI for D3         "
      report " Hue   High 245 Low 235  "; Hue
      report " Sat   High 101 Low 090  "; Saturation
      report " Int   High 25k Low 2k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 4

 if Hue < 130 or Hue > 185 or Saturation < 20 or Saturation > 40 or Intensity < 1k or Intensity > 10k then
   if  I = 4 then
      fail device
      report "------------------------------ "
      report "     Failed HSI for D4         "
      report " Hue   High 185 Low 130  "; Hue
      report " Sat   High 040 Low 020  "; Saturation
      report " Int   High 10k Low 1k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 5

 if Hue < 110 or Hue > 120 or Saturation < 90 or Saturation > 101 or Intensity < 0.1k or Intensity > 10k then
   if  I = 5 then
      fail device
      report "------------------------------ "
      report "     Failed HSI for D5         "
      report " Hue   High 120 Low 110  "; Hue
      report " Sat   High 101 Low 090  "; Saturation
      report " Int   High 10k Low 0.1k "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 6

 if Hue < 0.01 or Hue > 3 or Saturation < 90 or Saturation > 101 or Intensity < 2k or Intensity > 20k then
   if  I = 6 then
      fail device
      report "------------------------------ "
      report "     Failed HSI for D6         "
      report " Hue   High 003 Low .01  "; Hue
      report " Sat   High 101 Low 090  "; Saturation
      report " Int   High 20k Low 2k    "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 7

 if Hue < 120 or Hue > 135 or Saturation < 90 or Saturation > 101 or Intensity <1.5k or Intensity > 20k then
   if  I = 7 then
      fail device
      report "------------------------------ "
      report "     Failed HSI for D7         "
      report " Hue   High 135 Low 120  "; Hue
      report " Sat   High 101 Low 090  "; Saturation
      report " Int   High 20k Low 1.5k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 8

 if Hue < 233 or Hue > 243 or Saturation < 90 or Saturation > 101 or Intensity < 5k or Intensity > 30k then
   if  I = 8 then
      fail device
      report "------------------------------ "
      report "     Failed HSI for D8         "
      report " Hue   High 243 Low 233  "; Hue
      report " Sat   High 101 Low 090  "; Saturation
      report " Int   High 30k Low 05k  "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 9

 if Hue < 135 or Hue > 190 or Saturation < 10 or Saturation > 30 or Intensity < 2k or Intensity > 30k then
   if  I = 9 then
      fail device
      report "------------------------------ "
      report "     Failed HSI for D9         "
      report " Hue   High 190 Low 135  "; Hue
      report " Sat   High 030 Low 010  "; Saturation
      report " Int   High 30k Low  2k  "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 10

 if Hue < 20 or Hue > 140 or Saturation < 90 or Saturation > 101 or Intensity <  100 or Intensity > 10k then
   if  I = 10 then
      fail device
      report "------------------------------ "
      report "     Failed HSI for D10        "
      report " Hue   High 140 Low 20  "; Hue
      report " Sat   High 101 Low 090  "; Saturation
      report " Int   High 10k Low 0.3k "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 11

 if Hue < 0.01 or Hue > 3 or Saturation < 90 or Saturation > 101 or Intensity < 5k or Intensity > 15k then
   if  I = 11 then
      fail device
      report "------------------------------ "
      report "     Failed HSI for D11        "
      report " Hue   High 003 Low 0.1  "; Hue
      report " Sat   High 101 Low 090  "; Saturation
      report " Int   High 15k Low 5k    "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 12

 if Hue < 120 or Hue > 130 or Saturation < 90 or Saturation > 101 or Intensity < 3k or Intensity > 20k then
   if  I = 12 then
      fail device
      report "------------------------------ "
      report "     Failed HSI for D12        "
      report " Hue   High 130 Low 120  "; Hue
      report " Sat   High 101 Low 090  "; Saturation
      report " Int   High 20k Low 3k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 13

 if Hue < 230 or Hue > 245 or Saturation < 90 or Saturation > 101 or Intensity < 2k or Intensity > 15k then
   if  I = 13 then
      fail device
      report "------------------------------ "
      report "     Failed HSI for D13        "
      report " Hue   High 245 Low 230  "; Hue
      report " Sat   High 101 Low 090  "; Saturation
      report " Int   High 10k Low 2k    "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 14

 if Hue < 140 or Hue > 160 or Saturation < 10 or Saturation > 30 or Intensity < 2k or Intensity > 10k then
   if  I = 14 then
      fail device
      report "------------------------------ "
      report "     Failed HSI for D14        "
      report " Hue   High 160 Low 140  "; Hue
      report " Sat   High 030 Low 010  "; Saturation
      report " Int   High 10k Low 2k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 15

 if Hue < 20 or Hue > 40 or Saturation < 90 or Saturation > 101 or Intensity < 02k or Intensity > 30k then
   if  I = 15 then
      fail device
      report "------------------------------ "
      report "     Failed HSI for D15        "
      report " Hue   High 040 Low 020  "; Hue
      report " Sat   High 101 Low 090  "; Saturation
      report " Int   High 30k Low  2k  "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 16

 if Hue < 0.01 or Hue > 3 or Saturation < 90 or Saturation > 101 or Intensity < 1k or Intwnsity > 10k then
   if  I = 16 then
      fail device
      report "------------------------------ "
      report "     Failed HSI for D16        "
      report " Hue   High 003 Low 0.1  "; Hue
      report " Sat   High 101 Low 090  "; Saturation
      report " Int   High 10k Low 1k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 17

 if Hue < 120 or Hue > 130 or Saturation < 90 or Saturation > 101 or Intensity < 1k or Intensity > 10k then
   if  I = 17 then
      fail device
      report "------------------------------ "
      report "     Failed HSI for D17        "
      report " Hue   High 130 Low 120  "; Hue
      report " Sat   High 101 Low 090  "; Saturation
      report " Int   High 10k Low 1k    "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 18

 if Hue < 230 or Hue > 245 or Saturation < 90 or Saturation > 101 or Intensity < 2k or Intensity > 20k then
   if  I = 18 then
      fail device
      report "------------------------------ "
      report "     Failed HSI for D18        "
      report " Hue   High 245 Low 230  "; Hue
      report " Sat   High 101 Low 090  "; Saturation
      report " Int   High 20k Low 5k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 19

 if Hue < 130 or Hue > 155 or Saturation < 10 or Saturation > 40 or Intensity < 1k or Intensity > 10k then
   if  I = 19 then
      fail device
      report "------------------------------ "
      report "     Failed HSI for D19        "
      report " Hue   High 155 Low 130  "; Hue
      report " Sat   High 040 Low 010  "; Saturation
      report " Int   High 10k Low 1k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 20

 if Hue < 10 or Hue > 35 or Saturation < 90 or Saturation > 101 or Intensity < 2k or Intensity > 10k then
   if  I = 20 then
      fail device
      report "------------------------------ "
      report "     Failed HSI for D20        "
      report " Hue   High 035 Low 010  "; Hue
      report " Sat   High 101 Low 090  "; Saturation
      report " Int   High 10k Low 2k    "; Intensity
      report "-------------------------------"
    end if
  end if

next I

goto End_LA






!******************************************************************

SyncSerial_RGB_results:
  print tab(5);"        Synchronous Serial Mode RGBI"

!*! The Feasa 20-I is shipped with 20 fibers, the Feasa 10-I with 10 fibers etc.
!*! Select here the number of Fibers you are using.

 for I = 1 to 20   ! 20 Fibers

   for Data_bit = 0 to 7    !Convet the fiber number to binary
     Fibernum(Data_bit) =  bit(I,(7-Data_bit))
   next Data_bit

   test "4%feasa_20i%la_read_rgb_ss" ; Fibernum(*), Data(*)    ! Read R, G, B

  Red =  Data(0)                                              ! Red
  Green = Data(1)                                             ! Green
  Blue = Data(2)                                              ! Blue
  Intensity = (Data(3) * 65536) + (Data(4) * 256) + Data(5)   ! Intensity

!*! Uncomment the following 2 lines for debug purposes
!*!
! print Data(0);Data(1);Data(2);Data(3);Data(4);Data(5)       ! print Data
! print I; Red; Green; Blue; Intensity                        ! print results

!*******************************************************************

!*!---------- Fiber 1

 if Red < 253 or Red > 255 or Green < 0 or Green > 3 or Blue < 0 or Blue > 3 or Intensity < 2k or Intensity > 20k then
   if  I = 1 then
      fail device
      report "------------------------------ "
      report "     Failed RGBI for D1        "
      report " Red   High 255 Low 253  "; Red
      report " Green High 003 Low 000  "; Green
      report " Blue  High 003 Low 000  "; Blue
      report " Int   High 20k Low 2k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 2

if Red < 0 or Red > 4 or Green < 220 or Green > 232 or Blue < 20 or Blue > 35 or Intensity < 2k or Intensity > 20k then
   if  I = 2 then
      fail device
      report "------------------------------ "
      report "     Failed RGBI for D2        "
      report " Red   High 004 Low 000  "; Red
      report " Green High 232 Low 220  "; Green
      report " Blue  High 035 Low 020  "; Blue
      report " Int   High 20k Low 2k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 3

if Red < 0 or Red > 4 or Green < 10 or Green > 16 or Blue < 230 or Blue > 250 or Intensity < 5k or Intensity > 25k then
   if  I = 3 then
      fail device
      report "------------------------------ "
      report "     Failed RGBI for D3        "
      report " Red   High 004 Low 000  "; Red
      report " Green High 016 Low 010  "; Green
      report " Blue  High 250 Low 230  "; Blue
      report " Int   High 25k Low 5k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 4

if Red < 45 or Red > 55 or Green < 100 or Green > 130 or Blue < 70 or Blue > 110or Intensity < 1k or Intensity > 10k then
   if  I = 4 then
      fail device
      report "------------------------------ "
      report "     Failed RGBI for D4        "
      report " Red   High 055 Low 045  "; Red
      report " Green High 130 Low 100  "; Green
      report " Blue  High 110 Low 070  "; Blue
      report " Int   High 10k Low 1k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 5

if Red < 20 or Red > 35 or Green < 220 or Green > 235 or Blue < 1 or Blue > 10 or Intensity < 0.1k or Intensity > 10k then
   if  I = 5 then
      fail device
      report "------------------------------ "
      report "     Failed RGBI for D5        "
      report " Red   High 035 Low 020  "; Red
      report " Green High 235 Low 220  "; Green
      report " Blue  High 010 Low 001  "; Blue
      report " Int   High 10k Low 100  "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 6

 if Red < 253 or Red > 255 or Green < 0 or Green > 3 or Blue < 0 or Blue > 3 or Intensity < 2k or Intensity > 20k then
   if  I = 6 then
      fail device
      report "------------------------------ "
      report "     Failed RGBI for D1        "
      report " Red   High 255 Low 253  "; Red
      report " Green High 003 Low 000  "; Green
      report " Blue  High 003 Low 000  "; Blue
      report " Int   High 20k Low 2k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 7

if Red < 0 or Red > 4 or Green < 220 or Green > 232 or Blue < 20 or Blue > 30 or Intensity < 1.5k or Intensity > 20k then
   if  I = 7 then
      fail device
      report "------------------------------ "
      report "     Failed RGBI for D7        "
      report " Red   High 004 Low 000  "; Red
      report " Green High 232 Low 220  "; Green
      report " Blue  High 030 Low 020  "; Blue
      report " Int   High 20k Low 1.5k "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 8

if Red < 0 or Red > 4 or Green < 10 or Green > 20 or Blue < 230 or Blue > 250 or Intensity < 7k or Intensity > 30k then
   if  I = 8 then
      fail device
      report "------------------------------ "
      report "     Failed RGBI for D8        "
      report " Red   High 004 Low 000  "; Red
      report " Green High 020 Low 010  "; Green
      report " Blue  High 250 Low 230  "; Blue
      report " Int   High 30k Low 7k   "; Intensity
      report "-------------------------------"
    end if
  end if


!*!---------- Fiber 9

if Red < 40 or Red > 54 or Green < 100 or Green > 130 or Blue < 80 or Blue > 110or Intensity < 2k or Intensity > 30k then
   if  I = 9 then
      fail device
      report "------------------------------ "
      report "     Failed RGBI for D9        "
      report " Red   High 054 Low 040  "; Red
      report " Green High 130 Low 100  "; Green
      report " Blue  High 110 Low 080  "; Blue
      report " Int   High 30k Low 2k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 10

if Red < 20 or Red > 40 or Green < 200 or Green > 250 or Blue < 0 or Blue > 10 or Intensity < 0.1k or Intensity > 10k then
   if  I = 10 then
      fail device
      report "------------------------------ "
      report "     Failed RGBI for D10       "
      report " Red   High 40 Low 20  "; Red
      report " Green High 250 Low 200  "; Green
      report " Blue  High 010 Low 000  "; Blue
      report " Int   High 10k Low 100  "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 11


 if Red < 253 or Red > 255 or Green < 0 or Green > 2 or Blue < 0 or Blue > 2 or Intensity < 5k or Intensity > 15k then
   if  I = 11 then
      fail device
      report "------------------------------ "
      report "     Failed RGBI for D11       "
      report " Red   High 255 Low 253  "; Red
      report " Green High 003 Low 000  "; Green
      report " Blue  High 003 Low 000  "; Blue
      report " Int   High 15k Low 5k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 12

 if Red < 0 or Red > 4 or Green < 226 or Green > 235 or Blue < 15 or Blue > 30 or Intensity < 3k or Intensity > 20k then
   if  I = 12 then
      fail device
      report "------------------------------ "
      report "     Failed RGBI for D12       "
      report " Red   High 004 Low 000  "; Red
      report " Green High 235 Low 226  "; Green
      report " Blue  High 030 Low 015  "; Blue
      report " Int   High 20k Low 3k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 13

 if Red < 0 or Red > 4 or Green < 12 or Green > 18 or Blue < 230 or Blue > 250 or Intensity < 2k or Intensity > 15k then
   if  I = 13 then
      fail device
      report "------------------------------ "
      report "     Failed RGBI for D13       "
      report " Red   High 004 Low 000  "; Red
      report " Green High 018 Low 012  "; Green
      report " Blue  High 250 Low 230  "; Blue
      report " Int   High 15k Low  2k  "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 14

if Red < 40 or Red > 54 or Green < 110 or Green > 130 or Blue < 80 or Blue > 99 or Intensity < 2k or Intensity > 10k then
   if  I = 14 then
      fail device
      report "------------------------------ "
      report "     Failed RGBI for D14       "
      report " Red   High 054 Low 040  "; Red
      report " Green High 130 Low 110  "; Green
      report " Blue  High 099 Low 080  "; Blue
      report " Int   High 10k Low 2k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 15

if Red < 150 or Red > 195 or Green < 60 or Green > 115 or Blue < 0 or Blue >  5 or Intensity < 5k or Intensity > 30k then
   if  I = 15 then
      fail device
      report "------------------------------ "
      report "     Failed RGBI for D15       "
      report " Red   High 195 Low 150  "; Red
      report " Green High 115 Low  60  "; Green
      report " Blue  High 005 Low 000  "; Blue
      report " Int   High 30k Low  5k  "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 16

 if Red < 253 or Red > 255 or Green < 0 or Green > 3 or Blue < 0 or Blue > 3 or Intensity < 1k or Intensity > 10k then
   if  I = 16 then
      fail device
      report "------------------------------ "
      report "     Failed RGBI for D16       "
      report " Red   High 255 Low 253  "; Red
      report " Green High 003 Low 000  "; Green
      report " Blue  High 003 Low 000  "; Blue
      report " Int   High 10k Low 1k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 17

 if Red < 0 or Red > 4 or Green < 226 or Green > 232 or Blue < 20 or Blue > 30 or Intensity < 1k or Intensity > 10k then
   if  I = 17 then
      fail device
      report "------------------------------ "
      report "     Failed RGBI for D17       "
      report " Red   High 004 Low 000  "; Red
      report " Green High 232 Low 226  "; Green
      report " Blue  High 030 Low 020  "; Blue
      report " Int   High 10k Low 1k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 18

 if Red < 0 or Red > 4 or Green < 10 or Green > 18 or Blue < 230 or Blue > 250 or Intensity < 5k or Intensity > 20k then
   if  I = 18 then
      fail device
      report "------------------------------ "
      report "     Failed RGBI for D18       "
      report " Red   High 004 Low 000  "; Red
      report " Green High 018 Low 010  "; Green
      report " Blue  High 250 Low 230  "; Blue
      report " Int   High 20k Low  5k  "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 19

if Red < 45 or Red > 58 or Green < 115 or Green > 130 or Blue < 70 or Blue > 90 or Intensity < 1k or Intensity > 10k then
   if  I = 19 then
      fail device
      report "------------------------------ "
      report "     Failed RGBI for D19       "
      report " Red   High 058 Low 045  "; Red
      report " Green High 130 Low 115  "; Green
      report " Blue  High 090 Low 070  "; Blue
      report " Int   High 10k Low 1k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 20

 if Red < 150 or Red > 200 or Green < 55 or Green > 105 or Blue < 0 or Blue > 5 or Intensity < 2k or Intensity > 10k then
   if  I = 20 then
      fail device
      report "------------------------------ "
      report "     Failed RGBI for D20       "
      report " Red   High 200 Low 150  "; Red
      report " Green High 105 Low 055  "; Green
      report " Blue  High 005 Low 000  "; Blue
      report " Int   High 10k Low 2k   "; Intensity
      report "-------------------------------"
    end if
  end if

next I
goto End_LA






!**************************************************************************

SyncSerial_WSI_results:
  print tab(5);"        Synchronous Serial Mode WSI"

!*! The Feasa 20-I is shipped with 20 fibers, the Feasa 10-I with 10 fibers etc.
!*! Select here the number of Fibers you are using.

for I = 1 to 20   ! 20 Fibers

   for Data_bit = 0 to 7    !Convet the fiber number to binary
    Fibernum(Data_bit) =  bit(I,(7-Data_bit))
  next Data_bit

 test "4%feasa_20i%la_read_wsi_ss" ; Fibernum(*), Data(*)  ! Read WSI

  Wavelength = ((Data(0) * 256) + Data(1))                   ! Wavelength data
  Wavelength = Wavelength                                    ! Wavelength data
  Saturation = Data(2)                                       ! Saturation
  Intensity = (Data(3) * 65536) + (Data(4) * 256) + Data(5)  ! Intensity

!*! Uncomment the following 2 lines for debug purposes
!
! print Data(0);Data(1);Data(2);Data(3);Data(4);Data(5)     ! print Data
! print I; Wavelength; Saturation; Intensity                ! print wavelength

!*******************************************************************

!*!---------- Fiber 1

  if Wavelength < 625 or Wavelength > 640 or Saturation < 90 or Saturation > 101 or Intensity < 2k or Intensity > 20k then
  if  I = 1 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D1 Red      "
      report " Wav High 640 Low 625  "; Wavelength
      report " Sat High 101 Low 090  "; Saturation
      report " Int High 20k Low 2k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 2

  if Wavelength < 525 or Wavelength > 540 or Saturation < 90 or Saturation > 101 or Intensity < 2k or Intensity > 20k then
  if  I = 2 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D2 Green    "
      report " Wav High 540 Low 525  "; Wavelength
      report " Sat High 101 Low 090  "; Saturation
      report " Int High 20k Low 2k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 3

  if Wavelength < 455 or Wavelength > 470 or Saturation < 90 or Saturation > 101 or Intensity < 5k or Intensity > 25k then
  if  I = 3 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D3 Blue     "
      report " Wav High 470 Low 455  "; Wavelength
      report " Sat High 101 Low 090  "; Saturation
      report " Int High 25k Low 5k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 4

if Wavelength < 490 or Wavelength > 520 or Saturation < 20 or Saturation > 40 or Intensity < 1k or Intensity > 15k then
  if  I = 4 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D4 White    "
      report " Wav High 520 Low 490  "; Wavelength
      report " Sat High 040 Low 020  "; Saturation
      report " Int High 15k Low 1k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 5

  if Wavelength < 560 or Wavelength > 575 or Saturation < 90 or Saturation > 101 or Intensity < 0.1k or Intensity > 10k then
  if  I = 5 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D5 Amber    "
      report " Wav High 575 Low 560  "; Wavelength
      report " Sat High 101 Low 090  "; Saturation
      report " Int High 10k Low 100  "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 6

  if Wavelength < 630 or Wavelength > 640 or Saturation < 90 or Saturation > 101 or Intensity < 2k or Intensity > 20k then
  if  I = 6 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D6 Red      "
      report " Wav High 640 Low 630  "; Wavelength
      report " Sat High 101 Low 090  "; Saturation
      report " Int High 20k Low 2k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 7

  if Wavelength < 525 or Wavelength > 540 or Saturation < 90 or Saturation > 101 or Intensity < 1k or Intensity > 20k then
  if  I = 7 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D7 Green    "
      report " Wav High 540 Low 525  "; Wavelength
      report " Sat High 101 Low 090  "; Saturation
      report " Int High 20k Low 1k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 8

  if Wavelength < 460 or Wavelength > 470 or Saturation < 90 or Saturation > 101 or Intensity < 5k or Intensity > 30k then
  if  I = 8 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D8 Blue     "
      report " Wav High 470 Low 460  "; Wavelength
      report " Sat High 101 Low 090  "; Saturation
      report " Int High 30k Low  5k  "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 9

  if Wavelength < 490 or Wavelength > 520 or Saturation < 10 or Saturation > 30 or Intensity <  2k or Intensity > 10k then
  if  I = 9 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D9 White    "
      report " Wav High 520 Low 490  "; Wavelength
      report " Sat High  30 Low  10  "; Saturation
      report " Int High 10k Low  2k  "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 10

  if Wavelength < 560 or Wavelength > 600 or Saturation < 90 or Saturation > 101 or Intensity < 0.1k or Intensity > 10k then
  if  I = 10 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D10 Amber   "
      report " Wav High 600 Low 560  "; Wavelength
      report " Sat High 101 Low 090  "; Saturation
      report " Int High 10k Low 100   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 11

  if Wavelength < 620 or Wavelength > 640 or Saturation < 90 or Saturation > 101 or Intensity < 5k or Intensity > 15k then
  if  I = 11 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D11 Red     "
      report " Wav High 640 Low 620  "; Wavelength
      report " Sat High 101 Low 090  "; Saturation
      report " Int High 15k Low 5k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 12

  if Wavelength < 525 or Wavelength > 540 or Saturation < 90 or Saturation > 101 or Intensity < 3k or Intensity > 20k then
  if  I = 12 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D12 Green   "
      report " Wav High 540 Low 525  "; Wavelength
      report " Sat High 101 Low 090  "; Saturation
      report " Int High 20k Low 3k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 13

  if Wavelength < 460 or Wavelength > 470 or Saturation < 90 or Saturation > 101 or Intensity < 5k or Intensity > 20k then
  if  I = 13 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D13 Blue    "
      report " Wav High 470 Low 460  "; Wavelength
      report " Sat High 101 Low 090  "; Saturation
      report " Int High 20k Low 5k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 14

  if Wavelength < 510 or Wavelength > 520 or Saturation < 10 or Saturation > 30 or Intensity < 2k or Intensity > 10k then
  if  I = 14 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D14 White   "
      report " Wav High 520 Low 510  "; Wavelength
      report " Sat High 030 Low 010  "; Saturation
      report " Int High 10k Low 2k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 15

  if Wavelength < 590 or Wavelength > 605 or Saturation < 90 or Saturation > 101 or Intensity < 5k or Intensity > 30k then
  if  I = 15 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D15 Amber   "
      report " Wav High 605 Low 590  "; Wavelength
      report " Sat High 101 Low 090  "; Saturation
      report " Int High 30k Low  5k  "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 16

  if Wavelength < 630 or Wavelength > 640 or Saturation < 90 or Saturation > 101 or Intensity < 1k or Intensity > 10k then
  if  I = 16 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D16 Red     "
      report " Wav High 640 Low 630  "; Wavelength
      report " Sat High 101 Low 090  "; Saturation
      report " Int High 10k Low 1k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 17

  if Wavelength < 525 or Wavelength > 540 or Saturation < 90 or Saturation > 101 or Intensity < 5k or Intensity > 20k then
  if  I = 17 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D17 Green   "
      report " Wav High 540 Low 525  "; Wavelength
      report " Sat High 101 Low 090  "; Saturation
      report " Int High 20k Low 5k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 18

  if Wavelength < 460 or Wavelength > 470 or Saturation < 90 or Saturation > 101 or Intensity < 5k or Intensity > 20k then
  if  I = 18 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D18 Blue    "
      report " Wav High 470 Low 460  "; Wavelength
      report " Sat High 101 Low 090  "; Saturation
      report " Int High 20k Low 5k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 19

  if Wavelength < 510 or Wavelength > 520 or Saturation < 10 or Saturation > 40 or Intensity < 1k or Intensity > 10k then
  if  I = 19 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D19 White   "
      report " Wav High 520 Low 510  "; Wavelength
      report " Sat High 040 Low 010  "; Saturation
      report " Int High 10k Low 1k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 20

  if Wavelength < 590 or Wavelength > 605 or Saturation < 90 or Saturation > 101 or Intensity < 2k or Intensity > 10k then
  if  I = 20 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D20 Amber   "
      report " Wav High 605 Low 590  "; Wavelength
      report " Sat High 101 Low 090  "; Saturation
      report " Int High 10k Low 2k   "; Intensity
      report "-------------------------------"
    end if
  end if

next I
goto End_LA






!*****************************************************************

SyncSerial_Wave_results:
  print tab(5);"        Synchronous Serial Mode Dominant Wavelength"

!*! The Feasa 20-I is shipped with 20 fibers, the Feasa 10-I with 10 fibers etc.
!*! Select here the number of Fibers you are using.

for I = 1 to 20  ! 20 Fibers

   for Data_bit = 0 to 7    !Convet the fiber number to binary
    Fibernum(Data_bit) =  bit(I,(7-Data_bit))
  next Data_bit

test "4%feasa_20i%la_read_wave_ss"; Fibernum(*), Data(*)  ! Read Wavelength

  Wavelength = ((Data(0) * 256) + Data(1))                   ! Wavelength data
  Wavelength = Wavelength                                    ! Wavelength data

!*! Uncomment the following 2 lines for debug purposes
!
! print Data(0);Data(1)                                     ! print Data
! print I; Wavelength                                       ! print wavelength
!
!******************************************************************

!*!---------- Fiber 1

  if Wavelength < 620 or Wavelength > 640 then
  if  I = 1 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D1 Red      "
      report " Wav High 640 Low 620  "; Wavelength
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 2

  if Wavelength < 525 or Wavelength > 535 then
  if  I = 2 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D2 Green    "
      report " Wav High 535 Low 525  "; Wavelength
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 3

  if Wavelength < 460 or Wavelength > 470 then
  if  I = 3 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D3 Blue    "
      report " Wav High 470 Low 460  "; Wavelength
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 4

  if Wavelength < 490 or Wavelength > 520 then
  if  I = 4 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D4 White    "
      report " Wav High 520 Low 490  "; Wavelength
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 5

  if Wavelength < 568 or Wavelength > 575 then
  if  I = 5 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D5 Amber    "
      report " Wav High 575 Low 568  "; Wavelength
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 6

  if Wavelength < 630 or Wavelength > 640 then
  if  I = 6 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D6 Red    "
      report " Wav High 640 Low 630  "; Wavelength
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 7

  if Wavelength < 520 or Wavelength > 535 then
  if  I = 7 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D7 Green    "
      report " Wav High 535 Low 520  "; Wavelength
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 8

  if Wavelength < 460 or Wavelength > 470 then
  if  I = 8 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D8 Blue     "
      report " Wav High 470 Low 460  "; Wavelength
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 9

  if Wavelength < 490 or Wavelength > 515 then
  if  I = 9 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D9 White    "
      report " Wav High 515 Low 490  "; Wavelength
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 10

  if Wavelength < 568 or Wavelength > 600 then
  if  I = 10 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D10 Amber   "
      report " Wav High 600 Low 568  "; Wavelength
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 11

  if Wavelength < 620 or Wavelength > 640 then
  if  I = 11 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D11 Red     "
      report " Wav High 640 Low 620  "; Wavelength
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 12

  if Wavelength < 530 or Wavelength > 535 then
  if  I = 12 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D12 Green   "
      report " Wav High 535 Low 530  "; Wavelength
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 13

  if Wavelength < 460 or Wavelength > 470 then
  if  I = 13 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D13 Blue    "
      report " Wav High 470 Low 460  "; Wavelength
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 14

  if Wavelength < 510 or Wavelength > 515 then
  if  I = 14 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D14 White   "
      report " Wav High 515 Low 510  "; Wavelength
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 15

  if Wavelength < 590 or Wavelength > 600 then
  if  I = 15 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D15 Amber   "
      report " Wav High 600 Low 590  "; Wavelength
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 16

  if Wavelength < 630 or Wavelength > 640 then
  if  I = 16 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D16 Red     "
      report " Wav High 640 Low 630  "; Wavelength
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 17

  if Wavelength < 530 or Wavelength > 535 then
  if  I = 17 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D17 Green   "
      report " Wav High 535 Low 530  "; Wavelength
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 18

  if Wavelength < 460 or Wavelength > 470 then
  if  I = 18 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D18 Blue    "
      report " Wav High 470 Low 460  "; Wavelength
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 19

  if Wavelength < 510 or Wavelength > 520 then
  if  I = 19 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D19 White   "
      report " Wav High 520 Low 510  "; Wavelength
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 20

  if Wavelength < 590 or Wavelength > 605 then
  if  I = 20 then
      fail device
      report "------------------------------ "
      report "    Failed WSI for D20 Amber   "
      report " Wav High 605 Low 590  "; Wavelength
      report "-------------------------------"
    end if
  end if

next I
goto End_LA






!*************************************************************

SyncSerial_xyI_results:
  print tab(5);"        Synchronous Serial Mode xyI"

!*! The Feasa 20-I is shipped with 20 fibers, the Feasa 10-I with 10 fibers etc.
!*! Select here the number of Fibers you are using.

for I = 1 to 20  ! 20 Fibers

  for Data_bit = 0 to 7    !Convet the fiber number to binary
    Fibernum(Data_bit) =  bit(I,(7-Data_bit))
  next Data_bit

test "4%feasa_20i%la_read_xyi_ss" ; Fibernum(*), Data(*)   ! Read xy,I

  X = ((Data(0) * 256) + Data(1))/10000                         ! x- data
  Y = ((Data(2) * 256) + Data(3))/10000                         ! y- data
  Intensity = (Data(4) * 65536) + (Data(5) * 256) + Data(6)     ! Intensity

!*! Uncomment the following 2 lines for debug purposes
!*!
! print Data(0);Data(1);Data(2);Data(3);Data(4);Data(5);Data(6) 
! print I; X; Y; Intensity                                      ! print xyI
!
!*********************************************************************

!*!---------- Fiber 1

  if X < .60 or X > .80 or Y < .25 or Y > .30 or Intensity < 1k or Intensity > 20k then
  if  I = 1 then
      fail device
      report "------------------------------ "
      report "    Failed xyI for D1 RED   "
      report "  X High .80 Low .60   "; X
      report "  Y High .30 Low .25   "; Y
      report "  Int High 20k Low 1k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 2

  if X < .15 or X > .20 or Y < .60 or Y > .80 or Intensity < 1k or Intensity > 20k then
  if  I = 2 then
      fail device
      report "------------------------------ "
      report "    Failed xyI for D2 GREEN    "
      report "  X High .20 Low .15   "; X
      report "  Y High .80 Low .60   "; Y
      report "  Int High 20k Low 1k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 3

  if X < .10 or X > .20 or Y < .010 or Y > .10 or Intensity < 1k or Intensity > 30k then
  if  I = 3 then
      fail device
      report "------------------------------ "
      report "    Failed xyI for D3 BLUE    "
      report "  X High .20 Low .10   "; X
      report "  Y High .10 Low .01   "; Y
      report "  Int High 30k Low 1k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 4

if X < .30 or X > .360 or Y < .30 or Y > .360 or Intensity < 1k or Intensity > 10k then
  if  I = 4 then
      fail device
      report "------------------------------ "
      report "    Failed xyI for D4 White    "
      report "  X High .360 Low .30   "; X
      report "  Y High .360 Low .30   "; Y
      report "  Int High 10k Low 1k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 5

  if X < .30 or X > .500 or Y < .30 or Y > .60 or Intensity < 150 or Intensity > 10k then
  if  I = 5 then
      fail device
      report "------------------------------ "
      report "    Failed xyI for D5 YELLOW   "
      report "  X High .50 Low .30   "; X
      report "  Y High .60 Low .30   "; Y
      report "  Int High 10k Low 150 "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 6

  if X < .30 or X > .75 or Y < .15 or Y > .360 or Intensity < 1k or Intensity > 20k then
  if  I = 6 then
      fail device
      report "------------------------------ "
      report "    Failed xyI for D6 RED   "
      report "  X High .750 Low .30   "; X
      report "  Y High .360 Low .15   "; Y
      report "  Int High 20k Low 1k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 7

  if X < .10 or X > .260 or Y < .30 or Y > .800 or Intensity < 1k or Intensity > 20k then
  if  I = 7 then
      fail device
      report "------------------------------ "
      report "    Failed xyI for D7 GREEN    "
      report "  X High .260 Low .10   "; X
      report "  Y High .800 Low .30   "; Y
      report "  Int High 20k Low 1k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 8

  if X < .10 or X > .360 or Y < .01 or Y > .360 or Intensity < 5k or Intensity > 30k then
  if  I = 8 then
      fail device
      report "------------------------------ "
      report "    Failed xyI for D8 BLUE    "
      report "  X High .360 Low .10   "; X
      report "  Y High .360 Low .01   "; Y
      report "  Int High 30k Low 5k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 9

  if X < .30 or X > .360 or Y < .30 or Y > .360 or Intensity < 1k or Intensity > 30k then
  if  I = 9 then
      fail device
      report "------------------------------ "
      report "    Failed xyI for D9 White    "
      report "  X High .360 Low .30   "; X
      report "  Y High .360 Low .30   "; Y
      report "  Int High 30k Low 1k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 10

  if X < .30 or X > .660 or Y < .30 or Y > .560 or Intensity < 0.1k or Intensity > 10k then
  if  I = 10 then
      fail device
      report "------------------------------ "
      report "    Failed xyI for D10 AMBER   "
      report "  X High .660 Low .30   "; X
      report "  Y High .560 Low .30   "; Y
      report "  Int High 10k Low 0.1k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 11

  if X < .60 or X > .760 or Y < .25 or Y > .360 or Intensity < 5k or Intensity > 15k then
  if  I = 11 then
      fail device
      report "------------------------------ "
      report "    Failed xyI for D11 White   "
      report "  X High .760 Low .60   "; X
      report "  Y High .360 Low .25   "; Y
      report "  Int High 15k Low 5k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 12

  if X < .15 or X > .360 or Y < .70 or Y > .800 or Intensity < 2k or Intensity > 20k then
  if  I = 12 then
      fail device
      report "------------------------------ "
      report "    Failed xyI for D12 White   "
      report "  X High .360 Low .15   "; X
      report "  Y High .800 Low .70   "; Y
      report "  Int High 20k Low 2k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 13

  if X < .10 or X > .160 or Y < .03 or Y > .10 or Intensity < 1k or Intensity > 15k then
  if  I = 13 then
      fail device
      report "------------------------------ "
      report "    Failed xyI for D13 White   "
      report "  X High .160 Low .10   "; X
      report "  Y High .10 Low .03   "; Y
      report "  Int High 15k Low 1k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 14

  if X < .30 or X > .360 or Y < .30 or Y > .360 or Intensity < 1k or Intensity > 10k then
  if  I = 14 then
      fail device
      report "------------------------------ "
      report "    Failed xyI for D14 White   "
      report "  X High .360 Low .30   "; X
      report "  Y High .360 Low .30   "; Y
      report "  Int High 10k Low 1k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 15

  if X < .55 or X > .660 or Y < .35 or Y > .450 or Intensity < 5k or Intensity > 30k then
  if  I = 15 then
      fail device
      report "------------------------------ "
      report "    Failed xyI for D15 White   "
      report "  X High .660 Low .55   "; X
      report "  Y High .450 Low .35   "; Y
      report "  Int High 30k Low 5k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 16

  if X < .66 or X > .760 or Y < .25 or Y > .350 or Intensity < 1k or Intensity > 10k then
  if  I = 16 then
      fail device
      report "------------------------------ "
      report "    Failed xyI for D16 White   "
      report "  X High .760 Low .66   "; X
      report "  Y High .350 Low .25   "; Y
      report "  Int High 10k Low 1k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 17

  if X < .15 or X > .250 or Y < .70 or Y > .760 or Intensity < 1k or Intensity > 10k then
  if  I = 17 then
      fail device
      report "------------------------------ "
      report "    Failed xyI for D17 White   "
      report "  X High .250 Low .15   "; X
      report "  Y High .760 Low .70   "; Y
      report "  Int High 15k Low 1k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 18

  if X < .10 or X > .160 or Y < .04 or Y > .100 or Intensity < 1k or Intensity > 15k then
  if  I = 18 then
      fail device
      report "------------------------------ "
      report "    Failed xyI for D18 White   "
      report "  X High .160 Low .10   "; X
      report "  Y High .100 Low .04   "; Y
      report "  Int High 15k Low 1k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 19

  if X < .30 or X > .360 or Y < .30 or Y > .360 or Intensity < 1k or Intensity > 10k then
  if  I = 19 then
      fail device
      report "------------------------------ "
      report "    Failed xyI for D19 White   "
      report "  X High .360 Low .30   "; X
      report "  Y High .360 Low .30   "; Y
      report "  Int High 10k Low 1k   "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 20

  if X < .50 or X > .660 or Y < .40 or Y > .460 or Intensity < 1k or Intensity > 10k then
  if  I = 20 then
      fail device
      report "------------------------------ "
      report "    Failed xyI for D20 White   "
      report "  X High .660 Low .50   "; X
      report "  Y High .460 Low .30   "; Y
      report "  Int High 10k Low 1k   "; Intensity
      report "-------------------------------"
    end if
  end if

next I
goto End_LA






!****************************************************************

SyncSerial_cct_results:
  print tab(5);"        Synchronous Serial Mode cct"

!*! The Feasa 20-I is shipped with 20 fibers, the Feasa 10-I with 10 fibers etc.
!*! Select here the number of Fibers you are using.

!*! getcct is NOT valid whenmeasuring pure colours (Red, Green, Blue). The
!*! output from the Analyser will report 0 for cc.
!*! Only the cct value is reported here, the =/- delta uv is not.


for I = 1 to 20   ! 20 Fibers

  for Data_bit = 0 to 7    !Convet the fiber number to binary
    Fibernum(Data_bit) =  bit(I,(7-Data_bit))
  next Data_bit

test "4%feasa_20i%la_read_cct_ss" ; Fibernum(*), Data(*)     ! Read CCT

  CCT = ((Data(0) * 256) + Data(1))                          ! CCT data

!*! Uncomment the following 2 lines for debug purposes
!
! print Data(0);Data(1)                                      ! print Data
! print I; CCT                                               ! print CCT
!
!**************************************************************************

!*!---------- Fiber 1

 if CCT < 0 or CCT > 10 then
     if  I = 1 then
      fail device
      report "------------------------------ "
      report "          RED Led "
      report "     Failed cct for D1         "
      report "     High 10 Low 0   "; CCT
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 2

 if CCT < 0 or CCT > 10 then
     if  I = 2 then
      fail device
      report "------------------------------ "
      report "        GREEN Led  "
      report "     Failed cct for D2         "
      report "     High 10 Low 0  "; CCT
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 3

 if CCT < 0 or CCT > 10 then
     if  I = 3 then
      fail device
      report "------------------------------ "
      report "         BLUE Led  "
      report "     Failed cct for D3         "
      report "     High 10 Low 0  "; CCT
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 4

 if CCT < 5k or CCT > 7k then
     if  I = 4 then
      fail device
      report "------------------------------ "
      report "        WHITE Led   "
      report "     Failed cct for D4         "
      report "     High 7k Low 5k  "; CCT
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 5

 if CCT < 2k or CCT > 4k then
     if  I = 5 then
      fail device
      report "------------------------------ "
      report "        YELLOW Led  "
      report "     Failed cct for D5         "
      report "     High 4k Low 2k  "; CCT
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 6

 if CCT < 0 or CCT > 10 then
     if  I = 6 then
      fail device
      report "------------------------------ "
      report "          RED Led  "
      report "     Failed cct for D6         "
      report "     High 10 Low 0  "; CCT
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 7

 if CCT < 0 or CCT > 10 then
     if  I = 7 then
      fail device
      report "------------------------------ "
      report "         GREEN Led  "
      report "     Failed cct for D7         "
      report "     High 10 Low 0  "; CCT
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 8

 if CCT < 0 or CCT > 10 then
     if  I = 8 then
      fail device
      report "------------------------------ "
      report "          BLUE Led  "
      report "     Failed cct for D8         "
      report "     High 10 Low 0  "; CCT
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 9

 if CCT < 5k or CCT > 7k then
     if  I = 9 then
      fail device
      report "------------------------------ "
      report "          WHITE Led  "
      report "     Failed cct for D9         "
      report "     High 7k Low 5k  "; CCT
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 10

 if CCT < 3000 or CCT > 3300 then
     if  I = 10 then
      fail device
      report "------------------------------ "
      report "          YELLOW Led  "
      report "     Failed cct for D10        "
      report "     High 3300 Low 3000  "; CCT
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 11

 if CCT < 0 or CCT > 10 then
     if  I = 11 then
      fail device
      report "------------------------------ "
      report "           RED Led  "
      report "     Failed cct for D11        "
      report "     High 10 Low 0  "; CCT
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 12

 if CCT < 0 or CCT > 10 then
     if  I = 12 then
      fail device
      report "------------------------------ "
      report "           GREEN Led  "
      report "     Failed cct for D12        "
      report "     High 10 Low 0  "; CCT
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 13

 if CCT < 0 or CCT > 10 then
     if  I = 13 then
      fail device
      report "------------------------------ "
      report "          BLUE Led  "
      report "     Failed cct for D13        "
      report "     High 10 Low 0  "; CCT
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 14

 if CCT < 5k or CCT > 7k then
     if  I = 14 then
      fail device
      report "------------------------------ "
      report "         WHITE Led  "
      report "     Failed cct for D14        "
      report "     High 8k Low 3k  "; CCT
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 15

 if CCT < 0 or CCT > 10 then
     if  I = 15 then
      fail device
      report "------------------------------ "
      report "          AMBER Led  "
      report "     Failed cct for D15        "
      report "     High 10 Low 0  "; CCT
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 16

 if CCT < 0 or CCT > 10 then
     if  I = 16 then
      fail device
      report "------------------------------ "
      report "           RED Led  "
      report "     Failed cct for D16        "
      report "     High 10 Low 0  "; CCT
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 17

 if CCT < 0 or CCT > 10 then
     if  I = 17 then
      fail device
      report "------------------------------ "
      report "         GREEN Led  "
      report "     Failed cct for D17        "
      report "     High 10 Low 0  "; CCT
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 18

 if CCT < 0 or CCT > 10 then
     if  I = 18 then
      fail device
      report "------------------------------ "
      report "          BLUE Led "
      report "     Failed cct for D18        "
      report "     High 10 Low 0  "; CCT
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 19

 if CCT < 5k or CCT > 7k then
     if  I = 19 then
      fail device
      report "------------------------------ "
      report "          WHITE Led "
      report "     Failed cct for D19        "
      report "     High 7k Low 5k  "; CCT
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 20

 if CCT < 0 or CCT > 10 then
     if  I = 20 then
      fail device
      report "------------------------------ "
      report "         AMBER Led "
      report "     Failed cct for D20        "
      report "     High 10 Low 0  "; CCT
      report "-------------------------------"
    end if
  end if

next I
goto End_LA





!***************************************************************
SyncSerial_absint_results:

print tab(5);"        Synchronous Serial Absint Results"

!*! The Feasa 20-I is shipped with 20 fibers, the Feasa 10-I with 10 fibers etc.
!*! Select here the number of Fibers you are using.

for I = 1 to 20  ! 20 Fibers

  for Data_bit = 0 to 7    !Convet the fiber number to binary
    Fibernum(Data_bit) =  bit(I,(7-Data_bit))
  next Data_bit

test "4%feasa_20i%la_read_absint_ss" ; Fibernum(*), Data(*)   ! Read absint

  Intensity = (Data(0) * 65536) + (Data(1) * 256) + Data(2)   ! Intensity Data

  Exponent$ = ith$(Data(3))
  Val       = hti(Exponent$, Err)
  if Err<> 0 then print "Data Error"

 if Val > 127 then                     ! If Val > 127 Exponent is negative
    Exp = Val -256                     ! If Val < 128 Exp is Positive 2's Comp
 end if

 if Val < 128 then                     ! If Val > 127 Exponent is negative
   Exp = Val
 end if

 Intensity = Intensity * 10^(Exp)

!*! Uncomment the following lines for debug purposes
!*!
! print Data(0);Data(1);Data(2);Data(3)                     ! print Data
! print  I, Intensity

!**************************************************************************

!*!---------- Fiber 1

 if Intensity < 30k or Intensity > 40k then
     if  I = 1 then
      fail device
      report "------------------------------ "
      report "         RED Led    "
      report "  Failed Absolute Int. for D1 "
      report "     High 40k Low 30k  "; Intensity
      report "-------------------------------"
    end if
  end if

!*!---------- Fiber 2
 if Intensity < 40k or Intensity > 50k then
     if  I = 2 then
      fail device
      report "------------------------------ "
      report "       GREEN Led    "
      report "  Failed Absolute Int. for D2 "
      report "     High 50k Low 40k  "; Intensity
      report "-------------------------------"
    end if
 end if

!*!---------- Fiber 3
 if Intensity < 40k or Intensity > 50k then
     if  I = 3 then
      fail device
      report "------------------------------ "
      report "       BLUE Led    "
      report "  Failed Absolute Int. for D3 "
      report "     High 50k Low 40k  "; Intensity
      report "-------------------------------"
    end if
 end if

!*!---------- Fiber 4
 if Intensity < 40k or Intensity > 50k then
     if  I = 4 then
      fail device
      report "------------------------------ "
      report "       WHITE Led    "
      report "  Failed Absolute Int. for D4 "
      report "     High 50k Low 40k  "; Intensity
      report "-------------------------------"
    end if
 end if

!*!---------- Fiber 5
 if Intensity < 40k or Intensity > 50k then
     if  I = 5 then
      fail device
      report "------------------------------ "
      report "     YELLOW Led    "
      report "  Failed Absolute Int. for D5 "
      report "     High 50k Low 40k  "; Intensity
      report "-------------------------------"
    end if
 end if

!*!---------- Fiber 6
 if Intensity < 40k or Intensity > 50k then
     if  I = 6 then
      fail device
      report "------------------------------ "
      report "         RED Led    "
      report "  Failed Absolute Int. for D6 "
      report "     High 50k Low 40k  "; Intensity
      report "-------------------------------"
    end if
 end if

!*!---------- Fiber 7
 if Intensity < 40k or Intensity > 50k then
     if  I = 7 then
      fail device
      report "------------------------------ "
      report "       GREEN Led    "
      report "  Failed Absolute Int. for D7 "
      report "     High 50k Low 40k  "; Intensity
      report "-------------------------------"
    end if
 end if

!*!---------- Fiber 8
 if Intensity < 40k or Intensity > 50k then
     if  I = 8 then
      fail device
      report "------------------------------ "
      report "        BLUE Led    "
      report "  Failed Absolute Int. for D8 "
      report "     High 50k Low 40k  "; Intensity
      report "-------------------------------"
    end if
 end if

!*!---------- Fiber 9
 if Intensity < 40k or Intensity > 50k then
     if  I = 9 then
      fail device
      report "------------------------------ "
      report "       WHITE Led    "
      report "  Failed Absolute Int. for D9 "
      report "     High 50k Low 40k  "; Intensity
      report "-------------------------------"
    end if
 end if

!*!---------- Fiber 10
 if Intensity < 40k or Intensity > 50k then
     if  I = 10 then
      fail device
      report "------------------------------ "
      report "       YELLOW Led    "
      report "  Failed Absolute Int. for D10 "
      report "     High 50k Low 40k  "; Intensity
      report "-------------------------------"
    end if
 end if

!*!---------- Fiber 11
 if Intensity < 40k or Intensity > 50k then
     if  I = 11 then
      fail device
      report "------------------------------ "
      report "          RED Led    "
      report "  Failed Absolute Int. for D11 "
      report "     High 50k Low 40k  "; Intensity
      report "-------------------------------"
    end if
 end if

!*!---------- Fiber 12
 if Intensity < 40k or Intensity > 50k then
     if  I = 12 then
      fail device
      report "------------------------------ "
      report "       GREEN Led    "
      report "  Failed Absolute Int. for D12 "
      report "     High 50k Low 40k  "; Intensity
      report "-------------------------------"
    end if
 end if

!*!---------- Fiber 13
 if Intensity < 40k or Intensity > 50k then
     if  I = 13 then
      fail device
      report "------------------------------ "
      report "       BLUE Led    "
      report "  Failed Absolute Int. for D13 "
      report "     High 50k Low 40k  "; Intensity
      report "-------------------------------"
    end if
 end if

!*!---------- Fiber 14
 if Intensity < 40k or Intensity > 50k then
     if  I = 14 then
      fail device
      report "------------------------------ "
      report "       WHITE Led    "
      report "  Failed Absolute Int. for D14 "
      report "     High 50k Low 40k  "; Intensity
      report "-------------------------------"
    end if
 end if

!*!---------- Fiber 15
 if Intensity < 40k or Intensity > 50k then
     if  I = 15 then
      fail device
      report "------------------------------ "
      report "       AMBER Led    "
      report "  Failed Absolute Int. for D15 "
      report "     High 50k Low 40k  "; Intensity
      report "-------------------------------"
    end if
 end if

!*!---------- Fiber 16
 if Intensity < 40k or Intensity > 50k then
     if  I = 16 then
      fail device
      report "------------------------------ "
      report "         RED Led    "
      report "  Failed Absolute Int. for D16 "
      report "     High 50k Low 40k  "; Intensity
      report "-------------------------------"
    end if
 end if

!*!---------- Fiber 17
 if Intensity < 40k or Intensity > 50k then
     if  I = 17 then
      fail device
      report "------------------------------ "
      report "       GREEN Led    "
      report "  Failed Absolute Int. for D17 "
      report "     High 50k Low 40k  "; Intensity
      report "-------------------------------"
    end if
 end if

!*!---------- Fiber 18
 if Intensity < 40k or Intensity > 50k then
     if  I = 18 then
      fail device
      report "------------------------------ "
      report "        BLUE Led    "
      report "  Failed Absolute Int. for D18 "
      report "     High 50k Low 40k  "; Intensity
      report "-------------------------------"
    end if
 end if

!*!---------- Fiber 19
 if Intensity < 40k or Intensity > 50k then
     if  I = 19 then
      fail device
      report "------------------------------ "
      report "       WHITE Led    "
      report "  Failed Absolute Int. for D19 "
      report "     High 50k Low 40k  "; Intensity
      report "-------------------------------"
    end if
 end if

!*!---------- Fiber 20
 if Intensity < 40k or Intensity > 50k then
     if  I = 20 then
      fail device
      report "------------------------------ "
      report "       AMBER Led    "
      report "  Failed Absolute Int. for D20 "
      report "     High 50k Low 40k  "; Intensity
      report "-------------------------------"
    end if
 end if


next I
goto End_LA






!****************************************************************
SequenceCapture_mode:

print tab(5);"        Sequence Capture Mode"

!****************************************************************
! Capture Sequence SETUP command is
! 0xC0 + Capture Time (2 Bytes) +  Wait Time (2 Bytes)
! + Sequence Number (2 Bytes)
! Capture Time and Wait Time are specified in msec. (001ms to 999ms)
! Sequence Number is the number of captures to store.
! Maximum Sequence number is 400 per fiber channel (If all 20 Fibers selected)
! Maximum Sequence number is 8000 if only 1 Fiber is selected
!--------------------------------------------------------------------------
! Execute Capture Sequence using command 0x45
! Send 0x45 to the Analyser to initiate the capture sequence
!--------------------------------------------------------------------------
! Send 0x91 + Fiber number + sequence capture number to read back 3
! bytes of Intensity
!--------------------------------------------------------------------------
! Send 0xC1 to set a threshold value to convert Intensities to binary 1 or 0.
! Intensities > the threshold value will be converted to 1
! Intensities < the threshold value will be converted to 0
! This command must be sent before the 0x92 command.
!--------------------------------------------------------------------------
! Send 0x92 + fiber number to read 6 bytes of duty cycle times
! for Progressive Indicator timing.
! 6 bytes are returned.
! Bytes 0,1 returns the initial OFF time in msec.
! Bytes 2,3 returns the ON time of the LED in msec.
! Bytes 4,5 returns the OFF time after the LED is switched off.
!--------------------------------------------------------------------------



Command$ = "C0"                                 ! Command to send to analyser

CommandInt = hti(Command$)                      ! Convert to Integer
CommandBin$ = itb$(CommandInt)                  ! Convert to Binary
CommandBin$ = "00000000" & CommandBin$          ! Add leading zeros
CommandBin$ = CommandBin$[len(CommandBin$)-7;8] ! Extract the last 8 bits
! print CommandBin$

  for Data_bit = 1 to 8      ! Convet the fiber number to binary
    Data1(Data_bit) =  val(CommandBin$[Data_bit;1])
  next Data_bit

!*! Uncomment the following lines for debug purposes
!*!
!  print "data 1    ------------------------------------------------------"
!  print Data1(*)




!*****************************************************************
!*! Capture Time is 2 Bytes : High Byte*256 + Low Byte
!*****************************************************************

Capture_Time$ = "00"          ! Capture Time in mSec - 10msec

CommandInt = hti(Capture_Time$)                 ! Convert to Integer
CommandBin$ = itb$(CommandInt)                  ! Convert to Binary
CommandBin$ = "00000000" & CommandBin$          ! Add leading zeros
CommandBin$ = CommandBin$[len(CommandBin$)-7;8] ! Extract the last 8 bits
! print CommandBin$

  for Data_bit = 1 to 8      ! Convet the fiber number to binary
    Data2(Data_bit) =  val(CommandBin$[Data_bit;1])
  next Data_bit

!*! Uncomment the following lines for debug purposes
!*!
!  print "data 2    ------------------------------------------------------"
!  print Data2(*)

!******************************************************************

Capture_Time$ = "10"          ! Capture Time in mSec - 10msec

CommandInt = hti(Capture_Time$)                 ! Convert to Integer
CommandBin$ = itb$(CommandInt)                  ! Convert to Binary
CommandBin$ = "00000000" & CommandBin$          ! Add leading zeros
CommandBin$ = CommandBin$[len(CommandBin$)-7;8] ! Extract the last 8 bits
! print CommandBin$

  for Data_bit = 1 to 8      ! Convet the fiber number to binary
    Data3(Data_bit) =  val(CommandBin$[Data_bit;1])
  next Data_bit

!*! Uncomment the following lines for debug purposes
!*!
!  print "data 3     -----------------------------------------------------"
!  print Data3(*)







!*****************************************************************
!*! Wait Time is 2 Bytes : High Byte*256 + Low Byte
!*****************************************************************

Wait_Time$ = "00"                ! Wait Time in mSec - 5msec

CommandInt = hti(Wait_Time$)                    ! Convert to Integer
CommandBin$ = itb$(CommandInt)                  ! Convert to Binary
CommandBin$ = "00000000" & CommandBin$          ! Add leading zeros
CommandBin$ = CommandBin$[len(CommandBin$)-7;8] ! Extract the last 8 bits
! print CommandBin$

  for Data_bit = 1 to 8      ! Convet the fiber number to binary
    Data4(Data_bit) =  val(CommandBin$[Data_bit;1])
  next Data_bit

!*! Uncomment the following lines for debug purposes
!*!
!  print "data 4     ----------------------------------------------------"
!  print Data4(*)

!*******************************************************************

Wait_Time$ = "05"                ! Wait Time in mSec - 5msec

CommandInt = hti(Wait_Time$)                    ! Convert to Integer
CommandBin$ = itb$(CommandInt)                  ! Convert to Binary
CommandBin$ = "00000000" & CommandBin$          ! Add leading zeros
CommandBin$ = CommandBin$[len(CommandBin$)-7;8] ! Extract the last 8 bits
! print CommandBin$

  for Data_bit = 1 to 8      ! Convet the fiber number to binary
    Data5(Data_bit) =  val(CommandBin$[Data_bit;1])
  next Data_bit

!*! Uncomment the following lines for debug purposes
!*!
!  print "data 5      ----------------------------------------------------"
!  print Data5(*)





!*****************************************************************
!*! Number of Captures is 2 Bytes : High Byte*256 + Low Byte
! Maximum Sequence number is 400 per fiber channel (If all 20 Fibers selected)
! Maximum Sequence number is 8000 if only 1 Fiber is selected
!*******************************************************************

Sequence_High$ = "00"        ! High Byte of Sequence Number in HEX

CommandInt = hti(Sequence_High$)                ! Convert to Integer
CommandBin$ = itb$(CommandInt)                  ! Convert to Binary
CommandBin$ = "00000000" & CommandBin$          ! Add leading zeros
CommandBin$ = CommandBin$[len(CommandBin$)-7;8] ! Extract the last 8 bits
! print CommandBin$

  for Data_bit = 1 to 8      ! Convet the fiber number to binary
    Data6(Data_bit) =  val(CommandBin$[Data_bit;1])
  next Data_bit

!*! Uncomment the following lines for debug purposes
!*!
!  print "data 6     -----------------------------------------------------"
!  print Data6(*)


Sequence_Low$ = "40"              ! Low Byte of Sequence Number in HEX

CommandInt = hti(Sequence_Low$)                 ! Convert to Integer
CommandBin$ = itb$(CommandInt)                  ! Convert to Binary
CommandBin$ = "00000000" & CommandBin$          ! Add leading zeros
CommandBin$ = CommandBin$[len(CommandBin$)-7;8] ! Extract the last 8 bits
! print CommandBin$

  for Data_bit = 1 to 8      ! Convet the fiber number to binary
    Data7(Data_bit) =  val(CommandBin$[Data_bit;1])
  next Data_bit

!*! Uncomment the following lines for debug purposes
!*!
!  print "data 7         -------------------------------------------------"
1  print Data7(*)





!*****************************************************************************
! Now have 7 Bytes: Data1 + (Data2 + Data3) + (Data4 + Data5) + (Data6 + Data7)
! Set Sequence Capture + CaptureTime + WaitTime + No of Captures
!*****************************************************************************
! Send the Sequence Capture Setup command 0xC0 + Capture Time + Wait Time +
! Number of Captures


 print tab(5);"        SequenceCapture SETUP"

test"4%feasa_20i%la_seq_capt_setup_ss";Data1(*),Data2(*),Data3(*),Data4(*),Data5(*),Data6(*),Data7(*)






!*************************************************************
! Send the CaptureSequence Capture command CS  0x45

print tab(5);"        SequenceCapture CAPTURE"

test "4%feasa_20i%la_seq_capture_ss"              ! Do the Capture Sequence







!*************************************************************
!  Get the Results from the capture above
print tab(5);"        SequenceCapture RESULTS"

SequenceCapture_results:

for F = 1 to 20         ! 20 Fibers

  for Data_bit = 0 to 7    !Convet the fiber number to binary
    Fibernum(Data_bit) =  bit(F,(7-Data_bit))
  next Data_bit

! print Fibernum(*)      ! This is a binary number



!****************************************************************************
! Maximum Number of Captures is 400 per fiber (If all 20 Fibers selected)
! Maximum Number of Captures is 8000 if only 1 Fiber is selected
!****************************************************************************

No_of_Captures = 005  ! This cannot be greater than set above in setup.

  for Sequence_Num = 1 to No_of_Captures

CommandBin$ = itb$(Sequence_Num)                  ! Convert to Binary
CommandBin$ = "0000000000000000" & CommandBin$    ! Add leading zeros
CommandBin$ = CommandBin$[len(CommandBin$)-15;16] ! Extract the last 16 bits

!print CommandBin$

  for Data_bit = 1 to 16      ! Convet the fiber number to binary
    Data(Data_bit-1) =  val(CommandBin$[Data_bit;1])
  next Data_bit


test "4%feasa_20i%la_seq_rd_fib_ca_num_ss" ; Fibernum(*), Data(*) ! Read Int


!*! Uncomment the following 3 lines for debug purposes
!*!
!  print Data(0);Data(1);Data(2)                               ! print Data
!  Intensity =((Data(0) * 65536) + (Data(1) * 256) + Data(2))  ! Intensity
!  print F;" ";Sequence_Num;"  ";  Intensity                   ! print HSI


!*! Set the Location to send the capture sequence data to
! output @Logdata; "Fiber = ";F"  "";"Capture No = ";Sequence_Num;" ";Intensity
! output @Logdata; "--------------------------------------------------"

next Sequence_Num




!======================================================================
!  send the Intensity threshold - 3 bytes for intensity

Intensity_threshold = 3000        !  Threshold for Intensity level which will
                                                         !  give a 1 for > than and a 0 for < than 3000

CommandBin$ = itb$(Intensity_threshold)                   ! Convert to Binary
CommandBin$ = "000000000000000000000000" & CommandBin$    ! Add leading zeros
CommandBin$ = CommandBin$[len(CommandBin$)-23;24] ! Extract the last 16 bits

!print CommandBin$

  for Data_bit = 1 to 24      ! Convet the fiber number to binary
    Data(Data_bit-1) =  val(CommandBin$[Data_bit;1])
  next Data_bit

! print Data(*)

 test "4%feasa_20i%la_seq_set_threshold_ss";Data(*)  ! Set Intensity Threshold




!*****************************************************************
!  get the sequence times for Fiber F

  test "4%feasa_20i%la_seq_rd_fib_times_ss";Fibernum(*),Data(*)

 Time_off_begin = ((Data(0) * 256) + Data(1))   ! Time off at the beginning
 Time_on =((Data(2) * 256) + Data(3))           ! Time on
 Time_off_end = ((Data(4) * 256) + Data(5))     ! Time off at the end


!*! Uncomment the following line for debug purposes
!*!
! print "Fiber = ";F;"  Time off Beg = "; Time_off_begin; "Time on = "; Time_on;"Time off end = "; Time_off_end

!*! Set the Location to send the capture sequence data to.
!output @Logdata; "Fiber = ";F;"  ";"Toff Beg = ";Time_off_begin;"Ton =";Time_on;" Toff End = "; Time_off_end
! output @Logdata; "--------------------------------------------------"
!=============================================================================


next F

End_LA:

end if

 