Common Tasks With DTI
This section outlines key tasks that are often used with DTI.
Making a Connection to a Server Using DTI
This documents the procedure for obtaining a connection handle to a server, which is a first step for many DTI functions.
1
// initialize status code return
BTI_LONG status = 0;
// Call PvStart function with its reserved
// parameter
status = PvStart(0);
2
// initialize variables
BTI_LONG status = 0;
BTI_CHAR_PTR uName = "jsmith";
BTI_CHAR_PTR pword = "123";
BTI_CHAR_PTR svrName = "myserver";
BTI_LONG hConn = 0xFFFFFFFF;
// after execution, hConn contains connection
// handle to pass to other functions
status = PvConnectServer(svrName, uName, pword, &hConn);
// if status != 0, handle errors now
Connection handles are required by many DTI functions. You can have multiple connections open at a time. For each connection or handle, however, you should call the PvDisconnect() function to release the handle.
status = PvDisconnect(phConn);
Obtaining a Setting ID Using DTI
Many of the configuration functions take a setting ID as a parameter. This procedure describes the prerequisite functions for obtaining a setting ID.
1
2
3
4
5
6
7
Passing a DTI Structure as a Parameter
Many functions require that you pass a DTI structure when making the functional call. The following code segment shows an example of a function call including a structure. See DTI Structures for more information about DTI structures.
WORD rValue = P_OK;
TABLEMAP* tableList;
WORD tableCount;
rValue = PvGetTableNames(m_DictHandle, &tableList, &tableCount);