op_hla_interaction_pk_struct_set()
Note: Requires High-Level Architecture functionality
Abstract
Stores an arbitrary block of data in a field of a packet representing an outgoing interaction.
Syntax
op_hla_interaction_pk_struct_set (pk_ptr, field_name, data, size)
| Argument | Type | Description |
|---|---|---|
pk_ptr |
Packet * |
Packet representing an interaction to send out |
field_name |
const char * |
Field of packet to store the data |
data |
char * |
Data block to store in the packet field |
size |
size_t |
Size of the data block, in bytes |
Return Type
Compcode
Completion code indicating success or failure in getting the Location ID. The procedure returns OPC_COMPCODE_SUCCESS if the data was successfully stored. It returns OPC_COMPCODE_FAILURE if it could not stored the data.
Example
static void send_reply (void)
{
Packet * reply;
Interaction_Info_Type * info;
. . .
info = (Interaction_Info_Type *)
op_prg_mem_alloc (num_elements * sizeof (Interaction_Info_Type));
. . .
op_hla_interaction_pk_struct_set (reply, "information", info,
num_elements * sizeof (Interaction_Info_Type));
Details
RTI interactions have fields of either a simple type (short, long, double) or an arbitrary block of data that will need to be encoded by the sender and interpreted by the recipient of the interaction.
Because the actual size of the data is not known a-priori, this KP provides the data to store (whose address is in data_ptr and whose size is in size). The KP caller should have created the block of memory using op_prg_mem_alloc(). The block is transferred to the HLA-PM and thus should not be destroyed by the KP caller.
Purpose
Provides a mechanism to store arbitrary blocks of data into packets representing outgoing interactions.
Errors
- Recoverable Error: Unable to set field (
<field_name>) of interaction packet.
Reference
- Use the KP op_hla_interaction_pk_send() to send out a packet representing an interaction
- Use the KP op_prg_mem_alloc() to allocate the block of memory provided in
data_ptr