154 Chapter 3
ProgrammingExamples
Status RegisterDetermine When a Measurement is Done
/*install the handler and enable i t */
viInstallHandler(viESA, VI_EVENT_S ERVICE_REQ, mySrqHdlr,iAddress);
viEnableEvent(viESA, VI_EVENT_SERV ICE_REQ,VI_HNDLR,VI_NULL);
/*Send an undefined command to the device*/
viPrintf(viESA,"IDN\n");
/*Wait for SRQ */
WaitForSRQ();
/* Pause 5 seconds to observe erro r message displayed on ESA*/
Sleep(5000);
/*Averaging the successive measure ments, Set video averaging to 80 s weeps,
/*Turn the avarage On*/
viPrintf(viESA,":SENS:AVER:TYPE LP OW;:SENS:AVER:COUN 80;:SENS:AVER:S TAT ON\n");
/* Set the service request mask to assert SRQ when either a measurem ent
is completed or an error messag e has occurred.*/
viPrintf(viESA,"*SRE 96\n");
viPrintf(viESA,"*ESE 35\n");
/*Trigger the sweeps and set the * OPC bit after the sweeps are compl eted*/
viPrintf(viESA,":INIT:IMM;*OPC\n") ;
/*Wait for SRQ */
WaitForSRQ();
/*Disable and uninstall the interr upt handler*/
viDisableEvent (viESA, VI_EVENT_S ERVICE_REQ,VI_HNDLR);
viUninstallHandler(viESA, VI_EVENT _SERVICE_REQ, mySrqHdlr,iAddress);
/*Clear the instrument status regi ster*/
viPrintf(viESA,"*SRE 0 \n");
/*Clear the status byte of the ins trument*/
viPrintf(viESA,"*CLS\n");
/*Close the session*/
viClose(viESA);
viClose(defaultRM);
}