Value Vector Sub-Package

The value vector packets used in cosimulations, unlike formatted and unformatted packets, do not contain user-defined fields, although they do possess predefined fields and TDAs. A value vector packet can contain a value vector of type bit and a bulk size. The total size of the packet is the sum of the size of the value vector and the bulk size. Upon creation, a value vector’s bulk size is 0, but it can be modified with op_pk_bulk_size_set().

Existing value vectors can be inserted into a value vector packet with the KP op_pk_vvec_set(), and they can be retrieved from value vector packets with the KP op_pk_vvec_get(). Value vectors inside value vector packets cannot be changed, because the Simulation Kernel owns them. They must be retrieved before other KPs can modify them. To determine whether a value vector currently resides inside a value vector packet, use op_pk_vvec_is_set().

In some cases, especially in the context of sending packet information through an external system, it is useful to convert formatted packets to value vector packets, or vice-versa. The KP op_pk_convert_to_vvec() converts a formatted packet into a value vector packet, using the contents of the user-defined fields to generate the value vector. The converse KP, op_pk_convert_from_vvec(), converts a value vector packet into a formatted packet. The value vector inside the packet is used to set each of the user-defined fields in the formatted packet, and then the value vector is destroyed. Neither of these KPs specify the packet conversion method itself. Instead, they invoke whatever conversion method is associated with the packet format in question. The conversion method, which can be user-defined, is set for each packet format in the Packet Format Editor.

Two other KPs perform a variation on the functions just described. Each field in a packet format has an attribute that specifies its conversion order and conversion method. Thus, you can choose to set the conversion method for a packet format on a field-by-field basis. To invoke this type of packet conversion, use the KPs op_pk_fields_convert_to_vvec() and op_pk_fields_convert_from_vvec().

The final KP in the Value Vector sub-package performs a function similar to op_pk_convert_to_vvec(), except that it does not actually convert the formatted packet. Instead, op_pk_transfer_to_vvec() uses the packet format’s conversion method to create a value vector based on the user-defined fields of the formatted packet. You can then use that value vector just as any other value vector.