op_esys_interface_vector_set()
Abstract
Sets successive values of a vector interface from a value vector.
Syntax
op_esys_interface_vector_set (interface, schedule_time, source, start_offset)
| Argument | Type | Description |
|---|---|---|
interface |
Esys_Interface |
esys interface ID of the vector interface whose values will be set [The esys interface must be a vector interface. You can get the esys interface ID from several KPs in the Topo and Id packages, including op_topo_child() and op_id_from_name().] |
schedule_time |
double |
scheduled time to write the data to the vector interface (see Details for available constants) |
source |
Vvec_Vector |
value vector to be used in setting the vector interface [The types of the vector interface and the value vector must match, and they must have the same dimension.] |
start_offset |
int |
position at which to begin reading values from the source vector [The value in the position specified is placed on the first position in the vector interface (index 0). Each element of the value vector is then read to a successive position in the vector interface. Any values already existing in those positions are overwritten.] |
Return Type
Evhandle
Handle to the OPC_INTRPT_ESYS_INTERFACE_EXT interrupt scheduled to set the interface, if one was scheduled; OPC_NIL otherwise.
Example
/* Send some data to an esys interface. Extract lower-order 16 bits from 'vvec' vector. */
head = op_vvec_remove (vvec, OPC_VVEC_VECTOR_START, 16);
/* Schedule values on the esys vector interface. */
op_esys_interface_vector_set (interface_id, op_sim_time(), head, 0);
/* Done with this vector. */
op_vvec_destroy (head);
Details
The value of start_offset refers to the value vector index, not the vector interface. Therefore, by setting the start_offset to 5, the first element of the vector interface (index 0) will be set to the value at the sixth position in the value vector (index 5). Thereafter, the second element of the vector interface will be set to the value at the seventh position in the value vector, and so on until all values of the vector interface have been set.
The value vector must be long enough to fill all elements of the vector interface because op_esys_interface_vector_set() does not stop reading values until all values of the vector interface have been set.
The schedule_time argument can be an explicit time or one of the following special values:
OPC_ESYS_NOTIFY_IMMEDIATELY—the interface value is delivered to the registered callback (if any) right awayOPC_ESYS_NOTIFY_NEVER—the interface value is updated, but any registered callback is not invoked
Purpose
Provides a mechanism for writing the contents of a value vector to a vector interface.
Errors
- Program Abort: Segmentation violation. (due to invalid vector argument)
- Recoverable Error: Interface handle is invalid.
- Recoverable Error: Input vector is invalid.
- Recoverable Error: Attempt to set a value on an esys input interface (
<id>). - Recoverable Error: Attempt to set vector or array value on a non-vector interface (
<id>). - Recoverable Error: Input Vvec vector's type (
<type>) does not match interface type (<type>). - Recoverable Error: Specified time (
<schedule_time>) is less than current time.
Reference
- Use the KP op_intrpt_esys_interface() to get the esys interface ID for an esys interface
- Use the KP op_esys_interface_vector_get() to place the contents of a vector interface into a value vector
- Use the KP op_esys_interface_array_set() to place elements from an array onto a vector interface
- Use the KP op_esys_interface_value_set() to place the value of a single variable onto an esys interface
- Use the KP op_vvec_create() to create a value vector
- Use the KP op_vvec_type_get() to determine the data type of a vector