home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_13_12 / taylor2 / gpib.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-06  |  1.1 KB  |  41 lines

  1. // gpib.cpp
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <iostream.h>
  5. #include <dos.h>
  6. #include "gpibio.h"   // Defines GPIB STREAM Classes
  7.  
  8. gpibout gout(5,0);   // GPIB output device 5 stream on gpib board 0
  9. gpibin  gin(5,0);    // GPIB input device 5 stream on gpib board 0
  10.  
  11. void main(void) // Example of using GPIB streams
  12. {
  13.     char buffer[128];
  14.     struct time t;
  15.     // Get identity
  16.     if(!(gout <<"*idn?" << endl))
  17.     {
  18.        cerr << "Can't output *idn?" << endl;
  19.        exit(1);
  20.     }
  21.     if(!(gin >> buffer))
  22.     {
  23.        cerr << "No *idn? response" << endl;
  24.        exit(1);
  25.     }
  26.     cout << buffer << endl;
  27.     //Set time of day on instrument
  28.     gettime(&t)
  29.     gout << ":SYST:TIME" << t.ti_hour << ','
  30.                          << t.ti_min << ','
  31.                          << t.ti_sec << endl;
  32.     // Request, get and display 10 frequency measurements
  33.     for (int i=0; i<10; i++)
  34.     {
  35.          gout <<":MEAS:FREQ?;:SYST:TIME?" << endl;
  36.          gin >> freq >> hr >> min >> sec;
  37.          cout << "Frequency =  " << freq;
  38.          cout << ' '  << hr << ':' << min << ':' << sec << endl;
  39.     }
  40. }
  41.