home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_10_03 / 1003040a < prev    next >
Text File  |  1992-01-13  |  1KB  |  65 lines

  1.  
  2. EXAMPLE 6 :
  3.  
  4. /****************************************************
  5. * This is an example of messaging between methods. 
  6. * The methods use an object specific template to 
  7. * encode/decode messages being passed.
  8. *
  9. * This code is compiled to ROM.
  10. ****************************************************/
  11.  
  12.  
  13. file class_1.h
  14.  
  15.  
  16. typedef struct {
  17.  
  18.      float     time;
  19.      float     amplitude;
  20.  
  21. } PARAMETER_STR;
  22.  
  23. typedef struct {
  24.  
  25.      float     result_1;
  26.      float     result_2;
  27.      float     result_3;
  28.  
  29. } RESULT_STR;
  30.  
  31.  
  32. file test_a.c
  33.  
  34.  
  35. #include class_1.h
  36.  
  37. int test_a_process_data (float *params, float *results) {
  38.  
  39.      float         value_1, value_2, value_3;
  40.      float         time, amp;
  41.  
  42.      PARAMETER_STR *ps;
  43.      RESULT_STR    *rs;
  44.           .
  45.           .
  46.      /* apply the template to the    */
  47.      /* results and parameter arrays */
  48.  
  49.      ps = (PARAMETER_STR *) params;
  50.      rs = (RESULT_STR *) results;
  51.           .
  52.           .
  53.           .
  54.      time = ps->time;
  55.      amp  = ps->amplitude;
  56.           .
  57.      /* test specific calculations */
  58.           .
  59.      rs->result_1 = value_1;
  60.      rs->result_2 = value_2;
  61.      rs->result_3 = value_3;
  62.  
  63. }
  64.  
  65.