
EXAMPLE 6 :

/****************************************************
* This is an example of messaging between methods. 
* The methods use an object specific template to 
* encode/decode messages being passed.
*
* This code is compiled to ROM.
****************************************************/


file class_1.h


typedef struct {

     float     time;
     float     amplitude;

} PARAMETER_STR;

typedef struct {

     float     result_1;
     float     result_2;
     float     result_3;

} RESULT_STR;


file test_a.c


#include class_1.h

int test_a_process_data (float *params, float *results) {

     float         value_1, value_2, value_3;
     float         time, amp;

     PARAMETER_STR *ps;
     RESULT_STR    *rs;
          .
          .
     /* apply the template to the    */
     /* results and parameter arrays */

     ps = (PARAMETER_STR *) params;
     rs = (RESULT_STR *) results;
          .
          .
          .
     time = ps->time;
     amp  = ps->amplitude;
          .
     /* test specific calculations */
          .
     rs->result_1 = value_1;
     rs->result_2 = value_2;
     rs->result_3 = value_3;

}

