initializePointCache

initializePointCache — initializes local point cache usage.

Syntax

For C++:

ST_STATUS initializePointCache(void);

For Java, and C#:

Exception initializePointCache(void);

Returns

For C++:

ST_OK if the point cache was successfully initialized, otherwise ST_ERROR.

Description

The point cache is a list of all points received. It is automatically built and maintained as each point update is received from the DataHub. In order for a point to exist in the cache, a readPoint, registerPoint, or registerDomain was required to generate the point update. The value, type, and timestamp of the cached points is updated, but the point itself is persistent.

The point cache allows the user to associate data with the point (through its m_userdata member) and quickly access it when the point is updated (from onPointChange). The point cache also provides a way to synchronously read a current point value, avoiding the readPoint method which provides the point value asynchronously.

Example 1

This example illustrates use of the point cache to efficiently update a user interface control with the latest point value.

....
// during initialization, we register for all points
registerDomain("myDomain",
                DHC_FLAG_REG_FUTURE | DHC_FLAG_ONCEONLY_FUTURE);
....

// associate an MFC control with a point
//  perhaps this is called on user entering a desired point name
//  (don't forget to clear the previously associated point userdata!)
void onUiPointNameChanged(LPCTSTR pointname, CStatic *pValueWnd)
{
    DataHubPoint *ppoint = lookupPoint (pointname);
    if (ppoint)
    {
        ppoint->m_userdata = pointname;
    }
}
void onPointChange (DataHubPoint point)
{
    if (point.m_userdata)
    {
        // update the MFC control
        CStatic *pTxt = point.m_userdata;
        CString str;
        str.Format("%f", point.getDoubleValue());
        pTxt->SetWindowText(str);
    }
}

Example 2

This example illustrates use of the point cache to provide immediate access to a point value.

....
// part of the initialization code
registerDomain("myDomain",
                DHC_FLAG_REG_FUTURE | DHC_FLAG_ONCEONLY_FUTURE);
....

// read point value:
DataHubPoint *point = lookupPoint("IntPoint1");
int ival = point->getIntValue();
....

See Also

registerPoint, unregisterPoint, createPoint