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

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · Documentation compiled and provided by Beijing ZNetLink Technology Co., Ltd.

交流群 · QQ Group:OPNET/智网妙算网络仿真交流群(群号 486383494)

原文档 © 2017 Riverbed Technology · 本站为公益翻译,由 AI 辅助完成,请仔细甄别

Original documentation © 2017 Riverbed Technology. Community translation, AI-assisted. Contact: jiazequn@znetlink.com