home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxgpib.zip / SAMPLE.CMD < prev   
OS/2 REXX Batch file  |  1999-04-21  |  5KB  |  160 lines

  1. /* SAMPLE.CMD */
  2. /* Sample REXX Program to access GPIB using rxGPIB */
  3.  
  4. /* To run this program, the file RXGPIB.DLL must be in */
  5. /* the same directory as this file or in a directory */
  6. /* listed in your LIBPATH. */
  7.  
  8. SAY ' '
  9. SAY 'You must have a series 9300 LeCroy oscilloscope set to'
  10. SAY 'GPIB address 4 and connected to the GPIB card for this'
  11. SAY 'program to work.'
  12. SAY ' '
  13. SAY 'Press C to continue, or any other key to exit...'
  14. keyhit = ''
  15. PARSE PULL keyhit
  16. keyhit = Translate(keyhit)
  17. IF keyhit <> 'C' then
  18.   EXIT
  19.  
  20. /*====================*/
  21. /* Load RXGPIB.DLL    */
  22. /*====================*/
  23. CALL RXFuncAdd 'GPLoadFuncs', 'RXGPIB', 'GPLoadFuncs'
  24. CALL GPLoadFuncs
  25.  
  26. SAY ''
  27. SAY '--- Sample REXX Program to access GPIB.---'
  28. SAY ''
  29.  
  30. device = 'DEV4'   /* GPIB device address of instrument */
  31. devno = -1
  32. IEEErd = ''
  33. IEEEcmd = ''
  34. reply = ''
  35.  
  36. devno1 = rxibfind(device)  /* find the device and get device number */
  37. PARSE VALUE devno1 WITH . ' ' . ' ' devno
  38. SAY 'Device found = ' || devno            
  39.  
  40. keyhit = ""
  41. DO FOREVER
  42.    SAY "---------------------------------------------------"
  43.    SAY "Type 'x' to eXit..."
  44.    SAY "Commands below are for LeCroy 9304 Scope"
  45.    SAY "(type commands without the quotes):"
  46.    SAY "'F' find DEV4; '0' set to local"
  47.    SAY "'L' load setup; '2' read parameters;"
  48.    SAY "'1' to set intensity; 'v' for DLL version."
  49.    SAY ""
  50.    SAY "--------------------------------------------------"
  51.    SAY 'Enter selection: '
  52.    PARSE PULL keyhit
  53.    keyhit = Translate(keyhit)
  54.    SELECT
  55.  
  56.       when keyhit = "F" then    /* find device */
  57.         DO
  58.           devno1 = rxibfind('DEV4')
  59.           SAY 'Dev no. = ' || devno1
  60.           PARSE VALUE devno1 WITH . ' ' . ' ' devno
  61.           SAY 'Device found = ' || devno            
  62.         END
  63.  
  64.       when keyhit = "1" then    /* set grid intensity */
  65.         DO
  66.           SAY 'Grid and trace intensity rc = ' || rxibwrt(devno, "INTS TRACE,75,GRID,40", 21)
  67.         END
  68.  
  69.       when keyhit = "0" then    /* set local */
  70.         DO
  71.            IF devno > 0 THEN
  72.              SAY 'Local = ' || rxibloc(devno)
  73.            ELSE
  74.              SAY "Invalid device, can't set to local"
  75.         END
  76.  
  77.       when keyhit = "L" then    /* load 4 setups from file */
  78.         DO
  79.          IF devno > 0 then
  80.            DO
  81.              IEEErd = rxibclr(devno)
  82.              PARSE VALUE IEEErd WITH ibsta ' ' iberr
  83.              IF ibsta > 32767 THEN
  84.                SAY "OSCILLOSCOPE not ON LINE"
  85.              ELSE
  86.                DO
  87.                 DO i = 1 to 4
  88.                   SetFile = "D:\gpib\LECROY" || i || ".SET"
  89.                   SAY "Setting up oscilloscope... " || SetFile  
  90.                   SAY 'writing file: ' || rxibwrtf(devno, SetFile)
  91.                   SAY 'write EXR?: ' || rxibwrt(devno, 'EXR?', 4)
  92.                   IEEErd = rxibrd(devno, 100)
  93.                   PARSE VALUE IEEErd WITH ibsta ' ' iberr ' ' reply
  94.                   IF reply <> "EXR 0" THEN
  95.                     DO
  96.                       SAY "Scope setup problems with LECROY" || i || ".SET"
  97.                       LEAVE
  98.                     END
  99.                   ELSE
  100.                     DO
  101.                       IEEEcmd = "*SAV " || i
  102.                       SAY 'write *SAV: ' || rxibwrt(devno, IEEEcmd, Length(IEEEcmd))
  103.                     END
  104.                 END
  105.  
  106.                IEEEcmd = "CLSW"
  107.                SAY 'write CLSW: ' || rxibwrt(devno, IEEEcmd, Length(IEEEcmd))
  108.                IEEEcmd = "EXR?"
  109.                SAY 'write EXR?: ' || rxibwrt(devno, IEEEcmd, Length(IEEEcmd))
  110.                SAY 'read: ' || rxibrd(devno, 100)
  111.             END
  112.  
  113.           END
  114.          ELSE
  115.            SAY 'LeCroy not online.'
  116.  
  117.         END
  118.  
  119.       when keyhit = "2" then    /* read param */
  120.         do
  121.           /* request parameters from trace A */
  122.           SAY 'request params: ' || rxibwrt(devno, "TA:PAVA? MAX,WID", 16)
  123.           /* Read data from LeCroy */
  124.           IEEErd = rxibrd(devno, 40)
  125.           SAY 'parameters read: ' || IEEErd
  126.         END
  127.  
  128.       when keyhit = "3" then    /* read param to file */
  129.         do
  130.           /* request parameters from trace A */
  131.           SAY 'write: ' || rxibwrt(devno, "TA:PAVA? MAX,WID", 16)
  132.           /* Read data from LeCroy and save to file */
  133.           IEEErd = rxibrdf(devno, 'D:\gpib\testrd.txt')
  134.           SAY 'read to file: ' || IEEErd
  135.         END
  136.  
  137.       when keyhit = "V" then    /* rxGPIB.DLL version */
  138.         do
  139.           return_data = RXDLLVersion()    /* no parameters passed on */
  140.           SAY "DLL version is: " || return_data
  141.           keyhit = ""
  142.         end
  143.  
  144.    otherwise
  145.      DO
  146.        IF keyhit = "X" THEN
  147.          DO
  148.             CALL GPDropFuncs
  149.             SAY 'RXGPIB dropped.'
  150.             EXIT
  151.          END
  152.        ELSE
  153.          SAY "Invalid Input."
  154.      END
  155.    end  /* select */
  156. end /* do */
  157.  
  158. EXIT
  159.  
  160.