3 setting virtual model, Setting virtual model -11 – KEPCO KLP Series Developer's Guide, Rev 1 User Manual
Page 33

KLP-DEV 031113
3-11
3.3.3
SETTING VIRTUAL MODEL
This example is a series of files found on the CD in the ivi\drivers\kepcodcpwr\example\cviVir-
tual directory. In CVI you just need to open the prj file to access the entire project
Note:
This project file establishes a link to the kepcodcpwr.fp file by using the Edit menu ->
project -> Function panel file. To create another project this step is critical to proper
operation of the driver under the CVI environment.
In CVI each C file in the project needs to invoke the various include files.
#include "KpDCPwr.h"
#include
#include
#include
#include "KpDCPwrErrorHandler.h"
#include "KpDCPwrExample.h"
The CVI environment is aware of the IVI directory structure and will automatically locate the
directories containing the files without adding any path statements. It is an advantage of using
CVI over other C environments as it is IVI aware.
When the resource string is entered and the user clicks the appropriate button, the driver is
invoked and the password is established with the following code
sprintf(initOptions, "QueryInstrStatus=1, Simulate=%d", simulate);
// Initialize the driver
checkErr(KpDCPwr_InitWithOptions(resourceName, VI_TRUE, VI_TRUE, initOp-
tions, &vi));
// Enable the password state
checkErr(KpDCPwr_EnablePasswordState(vi, "7533"));
The user is then provided another form. When the data is entered, the standard CVI logic is
invoked and the variables are read from the form, then sent to the KLP.
The setting the KLP’s voltage is performed by two lines of code. The first line is the standard
CVI method of getting a variable from the form and the second line is the function in the IVI
driver that sets an attribute to a specific value.
// Get the desired voltage limit from the UI
GetCtrlVal(panelHandle, PANEL_VOLTAGE_LIMIT, &voltageLimit);
// Set the voltage limit
checkErr(KpDCPwr_SetAttributeViReal64(vi, VI_NULL,
KPDCPWR_ATTR_POSITIVE_VOLTAGE_RATED_LIMIT, voltageLimit));
The setting of a current level for the virtual model is performed using the same two functions but
the attribute is changed on the set function.
// Get the desired current limit from the UI
GetCtrlVal(panelHandle, PANEL_CURRENT_LIMIT, ¤tLimit);
// Set the current limit
checkErr(KpDCPwr_SetAttributeViReal64(vi, VI_NULL, //