Using the generated helper functions

You can use the several helper functions that IBM® Engineering Systems Design Rhapsody® generates on Rhapsody implementation blocks (RIMBs). The helper functions can be called in active operations.

Helper functions are categorized as follows:
  • Receivers that read data on receiver ports. These functions hide the complexity of the Runtime Environment (RTE) APIs. With some restrictions, they can be used to change the access mode without changing the users' access code.
  • Senders that send data or events on sender ports
  • Handlers that handle received data or events
  • Receiver-and-handlers that read and handle data or events
  • Callers that call required (client) services

Except for handlers, all helper functions return the status that is returned from the Runtime Environment function that they call in their implementation.

The following table lists each helper function and what it does.

Table 1. Helper functions
Helper function Explanation
receiveData_p_x (int* const x) Reads the value of attribute x on receiver port p and puts it in parameter x. This function is generated only when p.x is typed by a C type, not an event.
receiveEvent_p_x (int* const x) Reads the value of attribute x on receiver port p and puts it in parameter x. This function is generated only when p.x is typed by a Rhapsody event. Typically receiveAndHandleEvent is called directly instead of this function.
handleData_p_x (int x) Generates only when p.x is typed by a C type, not an event:
  • If the Rhapsody implementation block has a triggered operation evP_x, call that triggered operation.
  • If the Rhapsody implementation block has the attribute p_x, set the attribute p_x to the value of the parameter.
    • If the Rhapsody implementation block has, in addition, a reception named chP_x and x changed, generate an instance of chP_x and queue it in the manager's queue.
handleEvent_p_x() Generates only when p.x is typed by an event ev:
  • If the Rhapsody implementation block has a reception ev, generate an instance of ev and queue it in the manager's queue.
  • If the event typing p.x has a parameter, handleEvent will have a parameter that is copied in to the event.
receiveAndHandleData_p_x() Receives data and immediately handles them.
receiveAndHandleEvent_p_x() Receives events and immediately handles them.
sendData_p_x(int x) Sends the value of the parameter to attribute x on sender port p. This function is generated only when p.x is typed by a C type, not an event.
sendEvent_p_x() Generates only when p.x is typed by an event ev:
  • Sends an arbitrary value to attribute x on sender port p.
  • If the event ev has a parameter, sendEvent also has a parameter, and this value–not an arbitrary one–is sent.
call_p_f Calls the required operation f on client port p.