CacheService Object


The CacheService object creates and handles a thread that helps update the Controller’s status cache. The CacheService object is a convenient way to have a program periodically update the Controller’s status cache, allowing the MPI methods to avoid the occasional performance penalty of explicitly updating the cache.

Thread handling is implemented differently on every operating system. CacheService objects may therefore have different behaviors on different operating systems. Programmers experienced in multi-threaded application programming will probably want to program their own threads that will call mpiControlStatusCacheRefresh(…).

Note: The CacheService object is not part of the standard MPI. In order to use the CacheService Object, the apputil.h header file needs to be included by your code and the apputil library linked to your application.


Create, Delete, Validate Methods
  cacheServiceCreate Creates a Cache Service thread
  cacheServiceDelete Deletes a Cache Service thread

Configuration and Information Methods
  cacheServiceConfigGet Gets the configuration of a CacheService object
  cacheServiceConfigSet Sets the configuration of a CacheService object
  cacheServiceEnable Enables or disables the thread belonging to a Cache Service.
  cacheServiceStatus Returns status structure for a CacheService object.
  cacheServiceErrorCountReset Resets a CacheService object’s error count

Data Types

  CacheService Type define for the CacheService handle
  CacheServiceConfig Configuration structure used to configure CacheService objects
  CacheServiceConfigDEFAULT Default configuration values for the CacheService configuration structure.
  CacheServiceErrorHandler Type define for a CacheService object error handler function
  CacheServiceErrorParams Error structure used when CacheService encounters an MPI error
  CacheServiceStatus Structure that holds the status information for a CacheService object

Sample Code

/* Create and initialize MPI objects */
void programInit(MPIControl         *control,
                 MPIControlType      controlType,
                 MPIControlAddress  *controlAddress,
                 CacheService       *cacheService)
    CacheServiceConfig cacheServiceConfig = CacheServiceConfigDEFAULT;
    long			        returnValue;
    /* Create motion controller object */
    *control =
        mpiControlCreate(controlType, controlAddress);
    /* Initialize motion controller */
    returnValue =
       /* Set the MPIControl object's client connection count */
       returnValue =
           mpiControlClientCountSet(*control, 2);

    /* Create CacheService thread */
    cacheServiceConfig.sleepTime = 20; /* milliseconds */

    *cacheService =
        cacheServiceCreate(*control, &cacheServiceConfig);
    if (*cacheService == NULL)
/* Perform certain cleanup actions and delete MPI objects */
void programCleanup(MPIControl   *control,
                    CacheService *cacheService)
    long            returnValue; 
    /* Delete service thread */
    returnValue =
    *cacheService = MPIHandleVOID;
    /* Delete motion controller object */
    returnValue =
    *control = MPIHandleVOID;