

'                      Blocking
'
' version 2     (colour)
' 4 May 95

COMMON sgcode$, atten$, sgen$, ch$, ctr$, mart$
CLOSE
sgcode$ = "1"
atten$ = "27"
'sgen$ = "CH_039"
sgen = VAL(sgcode$)


SCREEN 8
CLS
COLOR 14
PRINT "Blocking"
COLOR 11
LOCATE 10, 10
PRINT "Connect as procedure"
LOCATE 15, 10
PRINT "Press space to go on"


k = 1
k$ = ""
DO
  IF k < 4 THEN BEEP
  k = k + 1
  IF k = 1500 THEN k = 1
  k$ = INKEY$
LOOP UNTIL k$ = " "

DIM block(20)
DIM intres(20)
DIM intmod(20)
DIM fr(20)
DIM fr$(20)
DIM r(12)
DIM r$(20)
DIM blk$(20)
DIM int1$(20)
DIM int2$(20)
DIM bdy$(20)

SCREEN 9
CLS
COLOR 14, 1
start:
' initial set up of gp-ib

 OPEN "ieeectrl" FOR RANDOM AS #1
 OPEN "ieeedata" FOR RANDOM AS #2
 IOCTL #1, "init" + CHR$(13)
 IOCTL #1, "clear" + CHR$(13)
 IOCTL #1, "to 10 end=13 eos=13" + CHR$(13)

 OPEN "com2:9600,n,8,2" FOR RANDOM AS #3
 OPEN "c:\qb\gpr\res\file" FOR APPEND AS #4

 SLEEP 5
 GOTO test

marbot:
 IF sgen = 2 THEN RETURN
 COLOR 11
 IOCTL #1, "3" + CHR$(13)
 IOCTL #2, marbot$ + CHR$(13)
RETURN

martop:
  IF sgen = 2 THEN RETURN
  IOCTL #1, "2" + CHR$(13)
  IOCTL #2, martop$ + CHR$(13)
 'PRINT martop$
RETURN


at:
  IOCTL #1, atten$ + CHR$(13)
  IOCTL #2, at$ + CHR$(13)
  SLEEP 1
RETURN


gpr:
   PRINT #3, gpr$
   SLEEP 1
   INPUT #3, r$
   er$ = LEFT$(r$, 1)

IF er$ <> "E" THEN RETURN
IF gpr$ = "REM" THEN RETURN


eror:
BEEP
COLOR 15
PRINT
PRINT "                 Error in GPR code   :    "; gpr$
BEEP
SLEEP
RETURN



test:

martop$ = "*IDN?": GOSUB martop
id$ = IOCTL$(2)
 
'pRINT id$

id = VAL(MID$(id$, 21, 4))
IF id = 2024 THEN mart = 1 ELSE mart = 0
mart$ = STR$(mart)


at$ = "A 100,": GOSUB at
martop$ = "*RST": GOSUB martop
martop$ = "mod:OFF": GOSUB martop
martop$ = "imode normal": GOSUB martop
IF mart = 0 THEN martop$ = "FSTD ext10" ELSE martop$ = "FSTD ext10dir"
GOSUB martop

marbot$ = "*RST": GOSUB marbot
SLEEP 3
marbot$ = "mod:OFF": GOSUB marbot
marbot$ = "FSTD int10": GOSUB marbot
marbot$ = "imode normal": GOSUB marbot

SLEEP 2
gpr$ = "REM": GOSUB gpr

gpr$ = "TS 6": GOSUB gpr
gpr$ = "VN": GOSUB gpr
SLEEP 2

rec$ = LEFT$(r$, 4)
sn$ = RIGHT$(r$, 4)
fv$ = MID$(r$, 5, 5)
LOCATE 1, 1
COLOR 15
PRINT "Receiver type         GPR"; rec$
PRINT "Serial no.               "; sn$
PRINT "Firmware version        "; fv$

title$ = "Blocking  and  Intermod"
COLOR 14
LOCATE 5, 20
PRINT title$


at$ = "A 87,": GOSUB at

gpr$ = "BW 1": GOSUB gpr
gpr$ = "RD L": GOSUB gpr
SLEEP 2

lp = 1
DO
  READ fr(lp)
  lp = lp + 1
LOOP UNTIL lp = 12


lp = 1
DO
  at$ = "A 100,": GOSUB at
  lev = 1
 
  rc43$ = LEFT$(rec$, 2)
  IF rc43$ = "43" THEN
   IF lp = 8 OR lp = 7 THEN GOTO endlp
  END IF

gprcal:
  fr1 = fr(lp)
  fr1$ = STR$(fr1)

bird:
  ofs = 0
  bdy = 1
  bird(2) = 0
  DO
    gpf = fr1 + ofs
    gpf = gpf * 10000
    gpf&(bdy) = gpf * 100
    gpf$(bdy) = STR$(gpf&(bdy))
       
    gpr$ = "FR" + gpf$(bdy): GOSUB gpr
    SLEEP 3
     
      IF bdy = 1 THEN
        gpr$ = "CL"
        GOSUB gpr
        SLEEP 5
      END IF
   
    gpr$ = "SG": GOSUB gpr
    bird(bdy) = VAL(r$)
      IF bird(1) < -22 THEN bdy = 4
    bdy = bdy + 1
    ofs = ofs + .0125
  LOOP UNTIL bdy >= 3

    IF bird(1) <= bird(2) THEN
      fr1& = gpf&(1)
      gpf$ = gpf$(1)
      bdy$ = " "
      IF bdy <> 4 THEN
        gpr$ = "FR " + gpf$: GOSUB gpr
        SLEEP 5
      END IF
   
    ELSE
      gpf$ = gpf$(2)
      fr1& = gpf&(2)
      bdy$ = "*"
    END IF


fault:
  gpr$ = "RS": GOSUB gpr
  fu = 2
  DO
    uc$ = MID$(r$, fu, 1)
    IF uc$ <> "-" THEN
      BEEP
      LOCATE 7 + lp, 44
        IF uc$ = "U" THEN fault$ = "Un Cal"
        IF uc$ = "L" THEN fault$ = "Battery"
        IF uc$ = "O" THEN fault$ = "Lock"
        IF uc$ = "R" THEN fault$ = "Range"
        IF uc$ = "V" THEN fault$ = "Overload"
        COLOR 12
      PRINT "GPR ( "; fault$; " ) Fault at"; fr(lp); " MHz"
      BEEP
      lev = 1
      SLEEP 1
      GOTO frset
    END IF
    fu = fu + 1
  LOOP UNTIL fu = 8

frset:
  fr1$ = STR$(fr1&)
  fr2& = fr1& + 2000000
  fr2$ = STR$(fr2&)
 
  marbot$ = "cfrq " + fr1$ + " hz": GOSUB marbot
  martop$ = "cfrq " + fr2$ + " hz": GOSUB martop
  martop$ = "rflv -87 dbm": GOSUB martop
 
  marbot$ = "rflv:ON": GOSUB marbot
  martop$ = "rflv:ON": GOSUB martop
 
  adjlev = 0
sigset:
 
  atlev = 100 - adjlev
  atlev$ = STR$(atlev)
  rflev = 13 - adjlev
  rflev$ = STR$(rflev)

  marbot$ = "rflv" + rflev$ + " dbm": GOSUB marbot
  at$ = "A" + atlev$ + ",": GOSUB at
  SLEEP 1
  
adjbot:
  lv = rflev
  adjlp = 1
  DO
    SLEEP 1
    gpr$ = "SG": GOSUB gpr
    adlev = VAL(r$)
    inlev = lv - adlev
     
      ilev = inlev * 10
      ilev% = ilev
      inlev = ilev% / 10
   
    IF adlev <> 0 THEN
      IF inlev > 13 THEN
        inlev = 13
        adjlp = 10
      END IF
      l$ = STR$(inlev)
      'adrbot$ = "A" + l$: GOSUB adrbot
      marbot$ = "rflv " + l$ + " dbm": GOSUB marbot
      lv = inlev
    END IF
   
    adjlp = adjlp + 1
    IF adjlp = 11 THEN
      adjlev = adjlev + 2
      GOTO sigset
    END IF

  LOOP UNTIL adlev = 0
  BEEP

  gpr$ = "FR " + fr2$
  GOSUB gpr
 
 
adjtop:
  adjlp = 1
  lv = -87
  DO
    SLEEP 1
    gpr$ = "SG": GOSUB gpr
    adlev! = VAL(r$)
    inlev = lv - adlev!
       ilev = inlev * 10
       ilev% = ilev
       inlev = ilev% / 10

    IF adlev! <> 0 THEN
      l$ = STR$(inlev)
      martop$ = "rflv " + l$ + " dbm": GOSUB martop
      lv = inlev
    END IF
    adjlp = adjlp + 1
    IF adjlp = 11 THEN GOTO gprcal

  LOOP UNTIL adlev! = 0
  BEEP

atts:
   atst = 21 - adjlev
   atst$ = STR$(atst)
   at$ = "A" + atst$ + ",": GOSUB at
   atlp = 1
   DO

     att = atst - atlp
     att$ = STR$(att)
     at$ = "A" + att$ + ","
     GOSUB at
     gpr$ = "SG": GOSUB gpr
     blk = VAL(r$)
     lev = 0
       IF blk > 1 THEN
         dp = blk - 1
         GOTO result
       END IF
       IF blk < -1 THEN
         dp = blk + 1
         dp = 0 - dp
         GOTO result
       END IF
     atlp = atlp + 1
   LOOP UNTIL atlp = 20
  
   END
   
result:
  block(lp) = (atlev - att) - dp


intermod:
  resl = 0
  res = 0
siggset:
  fr1$ = gpf$
  fr& = VAL(gpf$)
  fr2& = fr& + 50000
  fr3& = fr& + 100000
  fr2$ = STR$(fr2&)
  f3$ = STR$(fr3&)

  gpr$ = "FR" + fr1$: GOSUB gpr

  marbot$ = "cfrq " + fr1$ + " Hz": GOSUB marbot
  marbot$ = "rflv -32 dbm": GOSUB marbot
  martop$ = "cfrq " + fr2$ + " Hz": GOSUB martop
  martop$ = "rflv -32 dbm": GOSUB martop
  SLEEP 2
  at$ = "A 0,": GOSUB at
  SLEEP 2
  gpr$ = "AT F": GOSUB gpr

adj2:

    lv = 59
    sglev = -32
    adjlp = 1
    DO
      SLEEP 1
      gpr$ = "SG": GOSUB gpr
      adlev = VAL(r$)
      inlev = lv - adlev
      sglev = sglev + inlev
        sglev = sglev * 10
        sglev% = sglev
        sglev = sglev / 10

      IF inlev <> 0 THEN
        l$ = STR$(sglev)
        marbot$ = "rflv " + l$ + " dbm": GOSUB marbot
        SLEEP 1
        sglev = sglev
      END IF
      adjlp = adjlp + 1
      'IF adjlp = 11 THEN GOTO teststart
  
    LOOP UNTIL inlev = 0
    BEEP
  
    gpr$ = "FR " + fr2$
    GOSUB gpr


adj1:
    lv = 59
    sglev = -32
    adjlp = 1
    DO
     SLEEP 1
     gpr$ = "AT N": ' GOSUB gpr
     gpr$ = "SG": GOSUB gpr
     adlev! = VAL(r$)
     inlev! = lv - adlev!
     inlev! = sglev + inlev!

     IF adlev! <> lv THEN
       l$ = STR$(inlev!)
       martop$ = "rflv " + l$ + " dbm": GOSUB martop
       SLEEP 2
       sglev = inlev!
     END IF
      adjlp = adjlp + 1
      'IF adjlp = 11 THEN GOTO teststart

  LOOP UNTIL adlev! = lv
  BEEP

  gpr$ = "FR " + f3$
  GOSUB gpr

  lev = 0
  SLEEP 1
  gpr$ = "SG": GOSUB gpr
  intmod(lp) = 59 - VAL(r$)
  intres(lp) = VAL(r$)

intresult:

endlp:
  COLOR 14
  LOCATE 7 + lp, 10
  PRINT fr(lp); " MHz";
  LOCATE 7 + lp, 20
 

  IF lev = 1 THEN
    blk$(lp) = "----"
    int1$(lp) = "----"
    int2$(lp) = "----"
    bdy$ = " "
     COLOR 13
     PRINT TAB(30); "----";
     PRINT TAB(48); "----";
     PRINT TAB(55); "----"
  
  ELSE
    PRINT bdy$;
   
    COLOR 10
    PRINT TAB(30); USING "###.#"; block(lp);
    PRINT " dBæV";
   
    COLOR 11
    PRINT TAB(48);
    PRINT USING "###.#"; intres(lp);
    PRINT TAB(55);
    PRINT USING "###.#"; intmod(lp);
    PRINT " dBæV"
      blk$(lp) = STR$(block(lp))
      int1$(lp) = STR$(intres(lp))
      int2$(lp) = STR$(intmod(lp))
  END IF

    fr$(lp) = STR$(fr(lp))
    bdy$(lp) = bdy$
   
  martop$ = "RFLV:off": GOSUB martop
  marbot$ = "RFLV:off": GOSUB marbot
  gpr$ = "AT N": GOSUB gpr

  lev = 0
  lp = lp + 1
LOOP UNTIL lp = 12

PRINT : PRINT TAB(20); "*   'birdy' at this test  "

gpr$ = "BW 1": GOSUB gpr
gpr$ = "LOC": GOSUB gpr
martop$ = "*RST": GOSUB martop
marbot$ = "*RST": GOSUB marbot
SLEEP 5


PRINT #4, "Blocking"
FOR lp = 1 TO 11
PRINT #4, fr$(lp), blk$(lp)
PRINT #4, bdy$(lp)
NEXT lp
PRINT #4, "Block end"
PRINT #4, "Intermod"
FOR lp = 1 TO 11
  PRINT #4, fr$(lp), int1$(lp), int2$(lp)
  PRINT #4, bdy$(lp)
NEXT lp
PRINT #4, "Inter end"


CLOSE
IF ctr$ = "1" THEN CHAIN "c:\qb\gpr\results"
CHAIN "c:\qb\gpr\menu"

END

DATA 27,75,95,130,170,220,250,350,440,700,999

