home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 September / CHIP_CD_1997_09_PL.iso / software / testsoft / labwind / demo.6 / main / include / libsupp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-02  |  4.5 KB  |  115 lines

  1. /*============================================================================*/
  2. /*                        L a b W i n d o w s / C V I                         */
  3. /*----------------------------------------------------------------------------*/
  4. /*    Copyright (c) National Instruments 1987-1996.  All Rights Reserved.     */
  5. /*----------------------------------------------------------------------------*/
  6. /*                                                                            */
  7. /* Title:       libsupp.h                                                     */
  8. /* Purpose:     Include file for LabWindows/CVI callback and execution state  */
  9. /*              determination support.                                        */
  10. /*                                                                            */
  11. /*============================================================================*/
  12.  
  13. #include "cvidef.h"
  14. #include "cvirte.h"
  15.  
  16. #ifdef __cplusplus
  17.     extern "C" {
  18. #endif
  19.  
  20. /******************************************
  21. Run-State-Change Callbacks:
  22.    Certain libraries need to be notified when the user program starts,
  23. suspends, continues, or stops.  Examples of such libraries are those that
  24. have asynchronous callbacks; they must not call the user's callbacks when 
  25. the user's program in not executing.  The library can be informed of 
  26. changes in the user program's status through a callback.  
  27.  
  28.    If a library wishes to be notified of changes in the run state, it can
  29. have the callback automatically installed by naming it
  30. __RunStateChangeCallback, and including it in the library.  This callback
  31. must be in an object file (or library), rather than in a source file.
  32. Multiple libraries may contain functions with this name, since it is not
  33. entered into the global name space. The prototype for the callback is
  34.  
  35.    void __RunStateChangeCallback(int action).
  36.  
  37. Libraries using asynchronous callbacks:
  38.    If a library calls a user's function asynchronously (i.e through 
  39. interrupts or signals), it must announce the callback by calling
  40. EnterAsyncCallback() before calling the callback, and ExitAsyncCallback()
  41. after calling the callback.  This enables user protection to be turned off
  42. for an asynchronous callback.   EnterAsyncCallback() and ExitAsyncCallback()
  43. take one parameter which is a pointer to a buffer of size
  44. ASYNC_CALLBACK_ENV_SIZE; the same buffer must be passed into
  45. ExitAsyncCallback() as was passed into EnterAsyncCallback() because the
  46. buffer is used to store state information.
  47. *******************************************/
  48.  
  49. #define ASYNC_CALLBACK_ENV_SIZE 2048
  50.  
  51. void CVIFUNC EnterAsyncCallback(void *storageSpace);
  52. void CVIFUNC ExitAsyncCallback(void *storageSpace);
  53.  
  54. enum {
  55.     kRunState_Start,
  56.     kRunState_Suspend,
  57.     kRunState_Resume,
  58.     kRunState_AbortingExecution,
  59.     kRunState_Stop,
  60.     kRunState_EnableCallbacks,
  61.     kRunState_DisableCallbacks
  62. };
  63.  
  64. /**********************************************************************
  65. EXAMPLE 1
  66. ---------
  67.     kRunState_Start
  68.     kRunState_EnableCallbacks
  69.         // user program execution begins //
  70.             .
  71.             .
  72.         // a breakpoint or runtime error occurs, or user presses the TerminateExecution key combination //
  73.     kRunState_DisableCallbacks
  74.     kRunState_Suspend
  75.         // program execution is suspended;  CVI envirnonment resumes //
  76.             .
  77.             .
  78.         // user requests the execution be resumed, via the "Continue", "Step Over", etc., commands //
  79.     kRunState_Resume
  80.     kRunState_EnableCallbacks
  81.         // user program execution resumes //
  82.             .
  83.             .
  84.         // user program execution completes normally //
  85.     kRunState_DisableCallbacks
  86.     kRunState_Stop
  87.  
  88.  
  89. EXAMPLE 2
  90. ---------
  91.     kRunState_Start
  92.     kRunState_EnableCallbacks
  93.         // user program execution begins //
  94.             .
  95.             .
  96.         // a breakpoint or runtime error occurs, or user presses the TerminateExecution key combination //
  97.     kRunState_DisableCallbacks
  98.     kRunState_Suspend
  99.         // program execution is suspended;  CVI envirnonment resumes //
  100.             .
  101.             .
  102.         // user selects the Terminate Execution command //
  103.     kRunState_DisableCallbacks   // even though callbacks already disabled //
  104.     kRunState_AbortingExecution
  105.         // long jump out of user program    //
  106.     kRunState_DisableCallbacks   // even though callbacks already disabled //
  107.     kRunState_Stop
  108.  
  109.  
  110. *******************************************/
  111.  
  112. #ifdef __cplusplus
  113.     }
  114. #endif
  115.