.

Status Caching

Overview

When using client/server, data for specific functions can be cached on the client side. This feature is useful for optimizing performance with applications that continuously poll controller data via client/server.

With caching enabled, certain MPI status methods will get status values that are stored locally in a cache. Multiple small client/server transactions are replaced with one large client/server transaction to refresh the cache. This technique takes advantage of Ethernet's ability to send large packets more efficiently than small packets.

The following methods in the MPI library configure and handle status caching.

Method Description
mpiControlStatusCacheIntervalGet Returns the current cache refresh interval in milliseconds
mpiControlStatusCacheIntervalSet Sets current cache refresh interval in milliseconds
mpiControlStatusCacheRefresh Refreshes of the cached data if caching is enabled
mpiControlStatusCacheStatistics Retrieves the cache refresh statistics
mpiControlStatusCacheStatisticsReset Resets the cache refresh statistics

 

The Refresh Interval

To enable caching, a non-zero refresh interval is designated by the user. The interval specifies how old the cache data can be and still be considered valid.

The cache is refreshed from the server in two ways:

  1. Automatic: Calling a status function that uses cached data.

    The status function will refresh the cache automatically if the difference between the last cache refresh time and the current time is greater than the cache refresh interval.

  2. Manual: Refresh by calling mpiControlStatusCacheRefresh(...).

    mpiControlStatusCacheRefresh is provided so that an application can create a thread, called the cache refresh thread, that constantly pulls cached data from the server. The CacheService object is used to easily create and run a cache refresh thread.

Optimizing the Refresh Interval

Setting the cache refresh interval to less than the time it takes to actually refresh the cache can negatively impact system performance by causing all calls to a cache dependant function to trigger a cache refresh. On the other hand, a cache refresh interval that is too large will cause unnecessarily old data to be returned from the status functions that use the cache.

The optimal cache refresh interval for a particular application and system can be determined by running the application with the refresh interval set to 100 milliseconds (a large value). After the application has run for a period of time, use the mpiControlStatusCacheStatistics function to get the average cache refresh time. The optimal refresh interval should be set to slightly higher than the average refresh time.

Cached Functions

In version 03.04.11 (and later), the following functions will utilize the cache:

meiSqNodeDriveMonitor
mpiMotorAmpEnableGet
mpiAxisActualPositionGet
mpiAxisPositionError

If an application does not use a separate thread to periodically refresh the cache, then a status call will occasionally take longer than usual while it makes the call to the server to refresh all cached data.

 

       Legal Notice  |  Tech Email  |  Feedback
      
Copyright ©
2001-2021 Motion Engineering