ST_STATUS initializePointCache(
void)
;
Exception initializePointCache(
void)
;
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.
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); } }
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(); ....
Copyright © 1995-2010 by Cogent Real-Time Systems, Inc. All rights reserved.