next up previous
Next: Adding Tokens Up: Adding Modules Previous: The API

Example Calls

The following are some example calls to the above functions. Note that it is assumed that the connection to xrtic has been established elsewhere:

  1. To check whether the connection to the embedded tasks has been established by xrtic, we check the value of the ``connect_flag'':
      int connect_flag;
      rtic_get_flag_connect(&connect_flag);
      printf(``The connection is '');
      if (connect_flag)
      {
        printf(``Up\n'');
      }
      else
      {
        printf(``Down\n'');
      }
    

  2. To get the value of a parameter:
      float ftmp;
      int ID;
    
      ID = 2;
      rtic_get_scalar(ID,&ftmp);
      printf(``The value of parameter %d is %f\n'',ID,ftmp);
    
    Note that it is assumed that the ID submitted to rtic_get_scalar() is within range. The user is encouraged to use rtic_check_ID() to check all IDs.

  3. To set the value of a scalar parameter:
      rtic_set_scalar(2, 100.2);
    
    Note: as of the time of this writing, there is no way to alter matrix values from a user's module.

  4. To read in the stream of data as generated by the embedded tasks (see RETURN_VAL() in the user's user_controller.c file) and then print it in the format
    [time][ratio][val0][val1]...[valN]:
    do the following:
      struct data_struct *data;
      int index;
    
      data = (struct data_struct *) malloc(sizeof(struct data_struct));
      while(1)
      {
         rtic_get_data(data);
    
         printf("[%.2e][%i]", 
                 (double)(data->time/1.0e9), 
                 data->factor);
         for(index=0;index<RTIC_MAX_DATA_BUF;index++)
           printf("[%.2e]", data->val[index]);
         printf("\n");
      }
    



Michael Barabanov 2001-06-19