op_esys_interface_value_get()
Abstract
Obtains a single value from an esys interface (or from a specified element of a vector interface).
Syntax
op_esys_interface_value_get (interface, value, index)
| Argument | Type | Description |
|---|---|---|
interface |
Esys_Interface |
esys interface ID of the esys interface containing the value to be read The esys interface may be a vector interface or a non-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(), as well as op_intrpt_esys_interface().] |
value |
void* |
pointer to a variable to receive the esys interface’s value [This argument can accept a pointer to any of the data types native to C. The variable must already be allocated and the type must match that of the esys interface.] |
index |
int |
element of a vector interface containing the value to be read [This argument is required if the esys interface is a vector interface; it is treated as a placeholder otherwise.] |
Return Type
int
Completion code indicating whether the operation completed successfully.
OPC_ESYS_SUCCESS means the operation was successful. For the remaining completion codes, see Table 53 “External System Completion Code Symbolic Constants“ on page 13.
Example
/* Obtain a value from the esys interface and append to value vector. */
/* Get interface_id which caused the interrupt. */
interface_id = op_intrpt_esys_interface ();
op_esys_interface_value_get (interface_id, &c, 0);
/* Append value to end of vector. */
op_vvec_value_set (vector, OPC_VVEC_VECTOR_END, c);
/* If all values have been retrieved, send acknowledgment. */
if (op_vvec_size (vector) == 64)
{
op_esys_interface_value_set (ack_interface, op_sim_time (), '1');
}
Details
This procedure obtains a single value from an esys interface and places it into a variable. The value of the esys interface (or element, in the case of a vector interface) remains unaffected. The data type of the esys interface must match the data type of the target variable, as follows:
| Esys Interface Type | Variable Data Type |
|---|---|
integer |
int |
double |
double |
string |
char[] |
boolean |
int |
stdlogic |
char |
bit |
char |
character |
char |
pointer |
void * |
undefined |
char[] |
Purpose
Provide a mechanism to copy the value of an esys interface to a variable.
Errors
- Program Abort: Segmentation violation. (due to invalid destination value argument)
- Recoverable Error: Interface handle is invalid.
- Recoverable Error: Attempt to get a value from an esys output interface (
<name>). - Recoverable Error: Attempt to get a value from a vector interface (
<name>) using invalid index (<index>).
Reference
- Use the KP op_intrpt_esys_interface() to get the esys interface ID for an esys interface
- Use the KP op_esys_interface_value_set() to write single values to esys interfaces
- Use the KP op_esys_interface_array_get() to place elements from a vector interface into an existing array
- Use the KP op_esys_interface_vector_get() to place elements from a vector interface into a value vector