
'
'                      Level Accuracy
'                      --------------       ( Bandwidth )
'version 3
'4 May 95


COMMON sgcode$, atten$, sgen$, ch$, ctr$

sgen = VAL(sgcode$)

'sgen$ = "CH_039"
'sgen = 1
'atten$ = "27"

CLOSE
'

DIM r$(3, 50)
DIM r(3, 50)
DIM fr(50)
DIM xx$(50)
DIM sglv(50)

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
' OPEN "c:\qb\gpr\siggen\" + sgen$ FOR INPUT AS #5

'lp = 1
'DO
'  INPUT #5, xx$(lp)
'  lp = lp + 1
'LOOP UNTIL lp = 15

'sgfr$(1) = LEFT$(xx$(4), 3)
'sglv$(1) = RIGHT$(xx$(4), 5)
'sgfr$(2) = LEFT$(xx$(12), 3)
'sglv$(2) = RIGHT$(xx$(12), 5)

 SLEEP 5
frequenc:
CLS
'PRINT "How Many Frequencies to be tested ( MAX 49 )"
'INPUT lpx
'IF lpx < 0 OR lpx > 49 THEN GOTO frequenc
lpx = 49
lp = 1
DO
'  LOCATE 10, 5
'  PRINT "Enter test frequency ("; lp; ")";
'  INPUT fr(lp)
'  LOCATE 12, 5
'  PRINT "Enter level correction factor for "; fr(lp);
'  INPUT sglv(lp)
  READ fr(lp), sglv(lp)
  lp = lp + 1
  CLS
LOOP UNTIL lp = lpx

GOTO test


mar:
 IF sgen = 2 THEN RETURN

 COLOR 11
 IOCTL #1, "3" + CHR$(13)
 IOCTL #2, mar$ + CHR$(13)
' PRINT mar$
 RETURN

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

at:
COLOR 13
  IOCTL #1, atten$ + CHR$(13)
  IOCTL #2, at$ + CHR$(13)
'  LOCATE 18, 50
'  PRINT at$
'  BEEP
  SLEEP 1
'  LOCATE 18, 50
'  PRINT "            "
  RETURN

ip:
COLOR 14
   ip$ = IOCTL$(#2)
'   PRINT ip$
   ip# = VAL((MID$(ip$, s, e)))
   RETURN

freqip:
mar$ = "cfrq?": GOSUB mar
s = 12
e = 14
GOSUB ip
ip# = ip# / 1000000
'PRINT ip#; " MHz"
RETURN

levip:
mar$ = "rflv?": GOSUB mar
s = 22
e = 6
GOSUB ip
u$ = MID$(ip$, 12, 4)
'PRINT ip#; u$
RETURN

freq:
adfr = VAL(fr$)
adfr = adfr * 1000000
adret$ = "F " + STR$(adfr)
mar$ = "cfrq " + fr$ + " mhz"

GOSUB adret
GOSUB mar
RETURN

lev:
adret$ = "A " + l$
GOSUB adret

mar$ = "rflv " + l$ + "dbm"
GOSUB mar
RETURN

gpr:

PRINT #3, gpr$
INPUT #3, r$
SLEEP 1
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:

at$ = "A 100,": GOSUB at
mar$ = "*RST": GOSUB mar
mar$ = "rflv:ON": GOSUB mar
gpr$ = "REM":  GOSUB gpr

gpr$ = "TS 6": GOSUB gpr
gpr$ = "LU 3": GOSUB gpr
gpr$ = "LD 2": GOSUB gpr
gpr$ = "VN": GOSUB gpr

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

COLOR 14
title$ = "Bandwidth Level Accuracy (extra)"
PRINT #4, title$
LOCATE 5, 20
PRINT title$



fail = 1.5
lp = 1
ypo = 1
DO
  at$ = "A87,": GOSUB at
  SLEEP 2
  IF ypo > 15 THEN ypo = ypo - 15
  IF ypo > 30 THEN ypo = ypo - 30
  IF ypo > 45 THEN ypo = ypo - 45
  fr& = fr(lp) * 1000000
  f$ = STR$(fr&)
  gpr$ = "FR" + f$: GOSUB gpr

  fr$ = STR$(fr(lp))
  GOSUB freq
  l$ = STR$(sglv(lp))
  GOSUB lev
 
  LOCATE 7 + ypo, 2
  COLOR 11
  PRINT fr$; " MHz"
  PRINT #4, fr$
 
  bwlp = 1
  DO
    fail$ = ""
    bw = bwlp
   
    rc$ = RIGHT$(rec$, 1)
    IF rc$ = "1" THEN
      IF bw = 4 THEN bw = 3
      IF bwlp = 3 THEN
        r$ = "----"
        GOTO result
      END IF
    END IF
   
    IF rc$ = "0" THEN
      IF bwlp > 2 THEN
        bw = 2
        r$ = "----"
        GOTO result
      END IF
    END IF

    gpr$ = "LD 2": GOSUB gpr
    gpr$ = "BW" + STR$(bw): GOSUB gpr
    BEEP
   SLEEP 3
    gpr$ = "CL": GOSUB gpr
    SLEEP 3
    at$ = "A50,": GOSUB at
    gpr$ = "AT 3": GOSUB gpr
    gpr$ = "AT Y": GOSUB gpr
    SLEEP 5
   
    gpr$ = "SG": GOSUB gpr
result:
    IF r$ = "----" THEN
      unit$ = " "
      COLOR 7
      LOCATE 7 + ypo, (bwlp * 10) + 4
      PRINT r$
      GOTO sres
    ELSE
      COLOR 10
      unit$ = " dBæV"
    END IF
   
    LOCATE 7 + ypo, (bwlp * 10) + 4
    res = VAL(r$)
    f = -50 - res
    IF f > fail OR f < -fail THEN
      fail$ = "!"
      COLOR 12
    ELSE
      fail$ = " "
      COLOR 10
    END IF

    PRINT USING "###.#"; res;
    PRINT fail$
sres:
    PRINT #4, r$
    PRINT #4, fail$
    bw = bw + 1
    bwlp = bwlp + 1
    
  LOOP UNTIL bwlp = 5
  ypo = ypo + 1
lp = lp + 1
LOOP UNTIL lp = lpx

gpr$ = "LU 1": GOSUB gpr
gpr$ = "BW 1": GOSUB gpr
gpr$ = "LD 2": GOSUB gpr
gpr$ = "LOC": GOSUB gpr
mar$ = "*RST": GOSUB mar

PRINT #4, "xbla end"
CLOSE

IF ctr$ = "1" THEN CHAIN "c:\qb\gpr\lin"
CHAIN "c:\qb\gpr\menu"
END


DATA 471.25,.4,479.25,.4,487.25,.4,495.25,.4,503.25,.4
DATA 511.25,.4,519.25,.4,527.25,.4,535.25,.4,543.25,.4
DATA 551.25,.4,559.25,.4,567.25,.5,575.25,.4,583.25,.5
DATA 591.25,.5,599.25,.5,607.25,.5,615.25,.5,623.25,.5
DATA 631.25,.5,639.25,.4,647.25,.5,655.25,.5,663.25,.5
DATA 671.25,.5,679.25,.5,687.25,.5,695.25,.5,703.25,.5
DATA 711.25,.5,719.25,.5,727.25,.5,735.25,.5,743.25,.5
DATA 751.25,.5,759.25,.5,767.25,.5,775.25,.5,783.25,.5
DATA 791.25,.5,799.25,.5,807.25,.5,815.25,.5,823.25,.5
DATA 831.25,.6,839.25,.6,847.25,.6


END









