Listing 2 Board-specific I/O classes

// gpibio.cpp
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream.h)
#include "gpibio.h"

// GPIB BOARD CLASS
gpibdvr *gpibio::dvr[] = {NULL,NULL};
// Initialize repetition count per board
int gpibio::rep_cnt[] = {0,0};

// Constructor
gpibdvr::gpibdvr(int b)
{
   char name[6];

   // build board name
   strcpy(name,"gpib");
   if(b==1)
     strcat(name,"1");
   else

     strcat(name,"0");

   // Find GPIB interface board
   bhandle = ::ibfind(name);
   if(bhandle < 0)
   {
     cerr << "Can't Find GPIB Board" << endl;
     exit(1);
   }

   // Configure The board
   ::ibconfig(bhandle,IbcAUTOPOLL,0);

   // Disable the EOI assertion at the end of write I/O
   ::ibeot(bhandle,0);

   // Terminate read when EOS is detected, set EOI on EOS
   ::ibeos(bhandle,OxCOA);

   // Set read/write/wait time out to 30 seconds
   ::ibtmo(bhandle,T3Os);
}

// Open Specific device -- Returns -1 on error
int gpibdvr::open_device(int d)
{
   char name[8];

   // Build device name
   sprintf(name,"dev%d",d);

   // Find the device
   int device = ::ibfind(name);
   if(ibsta & ERR)
   {
     cerr << "Can't Find device" << endl;
     exit(1);
   }
   return (device);
}

// Constructor for initializing the GPIB board
gpibio::gpibio(int b)
}
   radix = 10;             // setup format radix
   board = (b==1) ? 1 : 0; // restrict index
   if(rep_cnt[board]++ == 0)
   {
     dvr[board] = new gpibdvr;
     if(dvr[board] == NULL)
     {
       cerr << "Can't allocate driver class." << endl;
       exit(1);
     }
   }
}

// Destructor
gpibio::~gpibio()
{
   if(--rep_cnt[board] == 0)
   {
       delete dvr[board];      // Release class memory
       dvr[board] = NULL;
   }
}

//End of File