Synchronization

Starting an application with or without a connection to the PI Server using a valid and complete cache file will result in cache file being used to retrieve point configuration data requested by the application. A cache file will have been marked complete by a call to picm_setcachebuildcomplete on a previously opened cache file. Moreover, starting an application using a valid and complete cache file means that the application had been disconnected from the PI Server and the point configuration data stored in the cache files may no longer match what is currently on the PI Server. Point attribute changes may have been made or points matching the application point source may have been added or deleted. Therefore, a synchronization mechanism is required to make sure the PI point configuration data running on the application is up to date. The synchronization mode keeps the caching files up to date and passes any changes in point configuration to the application for processing.

The synchronization process can only begin after the application has been successfully started using the point caching configuration and established a connection to the PI Server. Once these conditions are satisfied, the user can synchronize the cache files by calling picm_syncrhonizecache. If a point received from the PI Server does not exist in the point cache, it will be added to the cache and then a point create update will be queued and made available to the application via a call to pipt_updates or picm_serverupdates. If a point has been modified as indicated by the changedate attribute, the cache will be updated with the correct attribute information and a point edit update will be available to the application. A comparison of the points found on the server is made to what currently exists in the caching files. If a point is found in the cache file that no longer exists on the PI Server, a point delete update will be available to the application.

The picm_opencache will open and initialize the cache as well as define how the cache is to be synchronized. The following cache synchronization options describe how updates are made available.

SYNCH_NONE - No cache synchronization will be performed. A call to picm_synchronizecache will return NO_MORE_POINTS (0). No updates are made available for pipt_updates or picm_serverupdates. However, the user can still receive current changes if a call to pipt_signupforupdates is made while connected to the PI Server. In this case, any point change made on the PI Server can be retrieved with a call to pipt_updates. The retrival of the update will result in the cache being updated to reflect the change made on the PI Server. Changes made prior to the call to pipt_signupforupdates will not be available.

SYNCH_USE_PIPT_UPDATES - Cache synchronization performed with updates available via pipt_updates. This is the recommended option. This option will require the cache to be synchrnized on startup if the returned cache state is CACHE_COMPLETE or CACHE_INCOMPLETE, as well as after a communicaitons failure with the PI Server.

SYNCH_USE_PICM_UPDATES - Cache synchronization performed with updates available via picm_serverupdates. This option requires the entire cache be synchronized periodically to obtain updates; which could be time consuming. If the application will be calling pipt_signupforupdates and pipt_updates, then use the SYNCH_USE_PIPT_UPDATES option.

SYNCH_CACHE_ONLY - Cache synchronization performed. No updates are made available for pipt_updates or picm_serverupdates. However, the user can still receive current changes if a call to pipt_signupforupdates is made while connected to the PI Server. In this case, changes made on the PI Server after the call to picm_sychronizecache can be retrieved with a call to pipt_updates. The retrival of the update will result in the cache being updated to reflect the change made on the PI Server. Changes made prior to the call to pipt_signupforupdates and after a call to picm_synchronizecache will not be available.

The recommended method for keeping cache files up to date is shown below.

  1. Start the application.
  2. Signup for updates by calling pipt_signupforupdates.
  3. Open the cache file by calling picm_opencache using the SYNCH_USE_PIPT_UPDATES synchronization option.
  4. Call picm_synchronizecache if the returned cache state is CACHE_COMPLETE or CACHE_INCOMPLETE.
  5. Call pipt_updates to retrieve updates to keep cache synchronized.
  6. If connection to server is interrupted, on reconnection to the PI Server call pipt_signupforupdates and the repeat step 4-5 above.

An alternate method for keeping cache files up to date is shown below when the application does not sign up for point updates using the pipt_signupforupdates function call.

  1. Start the application.
  2. Open the cache file by calling picm_opencache using the SYNCH_USE_PICM_UPDATES synchronization option.
  3. Call picm_synchronizecache if the returned cache state is CACHE_COMPLETE or CACHE_INCOMPLETE.
  4. Call picm_serverupdates to retrieve updates to the cache.
  5. Periodically repeat steps 3-4 above to retrieve point changes made on the PI Server.
  6. If connection to server is interrupted, on reconnection to the PI repeat step 3-4 above.
  7. ar_plotvalues. It uses passed information about the resolution of the plot region.

Enabling Operational Intelligence