A-15
A2
// Program:
// The purpose of this program is to perform a continuous temp
// query of a Watlow device using a VISA resource. Pass in the
// VISA resource name via the command line. The easiest is to use
// a VISA alias. Otherwise you need to use a fully qualified VISA
// resource. The VISA resource can be a GPIB, TCP/IP, or some
// other resource. If a Watlow temp response can be obtained,
// the response will be printed to the console.
//
// Fully Qualified VISA Resource name examples:
// GPIB0::4::INSTR
// TCPIP::localhost::gpib0,4::INSTR
//
// Notes:
// 1. To compile/link, you must have the VISA.H and VISA32.LIB files
// accessible. Normally you should have the default directories
// setup to include these.
// 2. If an error happens, the program will print the error condition
// and then return an ERRORLEVEL of 1. If no error, the program
// will print the temp every 10 seconds.
#include <windows.h>
#include <winbase.h>
#include <stdio.h>
#include <visa.h>
main (int argc, char *argv[])
{
int retval, length, temp;
char *cp, result[1024];
ViStatus status;
ViSession rmSession, devSession;
if (argc != 2)
{
printf (“You must specify the VISA resource to use. This may be\n”);
printf (“either a fully defined VISA resource, or it may be a\n”);
printf (“VISA alias.\n”);
exit (1);
}
// Before we use any VISA fuctions, we must first open the
// Resource Manager so it will initialize the VISA layer.
if (viOpenDefaultRM (&rmSession) != VI_SUCCESS)
{
printf (“Unable to open a Resource Manager session\n”);
exit (1);
}
status = viOpen (rmSession, argv[1], VI_NULL, 1000, &devSession);
if (status != VI_SUCCESS)
{
printf (“Unable to open a session with %s\n”, argv[1]);
retval = 1;
}
Figure A-5 Example VISA Program