|
|
| . |
|
CacheService Object Introduction 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. Methods
Data Types
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); msgCHECK(mpiControlValidate(*control)); /* Initialize motion controller */ returnValue = mpiControlInit(*control); msgCHECK(returnValue); /* Set the MPIControl object's client connection count */ returnValue = mpiControlClientCountSet(*control, 2); msgCHECK(returnValue); /* Create CacheService thread */ cacheServiceConfig.sleepTime = 20; /* milliseconds */ *cacheService = cacheServiceCreate(*control, &cacheServiceConfig); if (*cacheService == NULL) { msgCHECK(MPIMessageHANDLE_INVALID); } } /* Perform certain cleanup actions and delete MPI objects */ void programCleanup(MPIControl *control, CacheService *cacheService) { long returnValue; /* Delete service thread */ returnValue = cacheServiceDelete(*cacheService); msgCHECK(returnValue); *cacheService = MPIHandleVOID; /* Delete motion controller object */ returnValue = mpiControlDelete(*control); msgCHECK(returnValue); *control = MPIHandleVOID; }
|
|||||||||||||||||||||||||||||||||||||||||||||||
| | | Copyright © 2001-2008 Motion Engineering |