The following functions are available to a user in order to interface their application to RT-LAB.
...
Group | Model Interaction, Signal Acquisition |
---|
Description | Returns the acquisition signals sent to the console subsystem while the model is running. The acquisition signals are the signals sent from the computation nodes to console subsystem in the same order that it was specified at the input of the OpComm block for the specified acquisition group. Observes the blocking / non-blocking properties set for the workstation: if blocking is set, will block until data is available; if non-blocking is set, will return EAGAIN when no data is available. In this case, returned values will be equal to zero or last received values depending on the settings specified by the OpalSetAcqBlockLastVal API function. For additional information, please see Acquiring and Viewing Data in the RT-LAB User’s Guide.
|
---|
Required Control | None |
---|
Usage | int OpalGetAcqGroupSignals(unsigned short acqGroup,unsigned short allocatedSignals, unsigned int *numSignals, double values[],unsigned short *endFramelastValues, double *simTimeSteptimestep); |
---|
Input | - acqGroup: Acquisition group number, starts from 0.
- allocatedSignals: Number of expected signals.
|
---|
Output | - numSignals: number of signals in values signals array
- values: Simulation signals array into which the API will store the acquired signals. May be NULL if allocatedSignals equals 0.
- endFramelastValues: Pointer to where API stores true when signals are the last in the acquisition buffer (next values will be in a new frame). May be NULL if not of interest.
- simTimeSteptimestep: Simulation timestep of the acquired data. May be NULL if not of interest.
|
---|
Return value | - EOK: Success.
- E2BIG: Number of allocated signals is less than the number of group signals.
- EAGAIN: No data available and the timeout has expired.
- EINVAL: Specified acquisition group is invalid or not active (does not exist on target).
- EBADF: Model not specified by previous OpalConnect or OpalSetCurrentModel.
- EIO: Error sending the request or receiving the reply.
- EACCES: Not connected a loaded model.
- ENOMEM: Memory allocation error.
- OP_API_EBAD_SIGNAL: Doing acquisition of one or more dynamic signals that does no longer exist.
- OP_API_ENO_PRODUCT: No license for RT-LAB and RT-LABx.
- OP_API_EACQ_MODEL_PAUSED: no data available because the model is paused.
|
---|
Examples | None |
---|
Related items | None |
---|
...
Group | Model Interaction, Signal Acquisition |
---|
Description | Returns the acquisition signals sent to the console subsystem while the model is running. The acquisition signals are the signals sent from the computation nodes to console subsystem in the same order that it was specified at the input of the OpComm block for the specified acquisition group. The outputs contain two arrays: acquisition signals + monitoring signals. The user can activate the synchronization algorithm to synchronize the acquisition time with the simulation time by inserting data during missed data intervals. The interpolation can be used in this case to get a better result during missed data intervals.
Threshold time between acquisition time and simulation time exceeds the threshold, the acquisition (console) will be updated to overtake the difference. The acqtimestep offers the user a way to change his console step size as in Simulink. For additional information, please see Acquiring and Viewing Data in the RT-LAB User’s Guide. Monitoring signals array contains 4 values: - missed data: number of values between two acquisition frame. If the value is 0, there are no missing data between the two frames. Missing data may appear if network communication and display are too slow to refresh the value generated by the model.
- offset: simulation time when the acquisition started.
- target simulation time: simulation time of the model when the acquisition has been done.
- Sample/sec: number of sample/sec received from target. The calculation is made for one sample. Ex: If the model is running at 0.001s, sample/sec value should not exceed 1000 sample/sec.
|
---|
Required Control | None |
---|
Usage | int OpalGetAcqGroupSyncSignals(unsigned short acqGroup,unsigned short allocatedSignals, unsigned int *numSignals, unsigned short synchronization, unsigned short interpolation, double threshold,double acqTimeStep, double *simSignals, double *monSignals,unsigned short *endFrame, double *simTimeStep); |
---|
Input | - acqGroup: Acquisition group number starts from 0.
- allocatedSignals: Number of expected signals.
- synchronization: 1/0 = Enable/DisableEnables the synchronization algorithm for a given acquisition group. This algorithm must be used if synchronization is required between acquisition Console time and simulation time. In case of a synchronization problem, the Console detects missing data from the target node and the algorithm either replaces the lost data with the last signal value received or interpolates the data.
- interpolation: interpolation 1/0 = Enable/Disable
In case of missed data from a computation subsystem, the synchronization algorithm interpolates data during a range of data loss. The following illustrations make this point clear. The display at left indicates no interpolation during data acquisition while the display at right indicates interpolation between two frames during data loss. - Image Added
- threshold: Difference between the simulation Console time and the simulation target time. Whenever this difference is exceeded, the synchronization algorithm stops interpolating and re-synchronizes to the new value.
- acqTimeStep: Sample interval: acquisition (console) timestep must be equal to or greater than the model time step.
|
---|
Output | - numSignals: Number of signals in the acquisition group.
- simSignals: Simulation signals array into which the API will store the acquired signals. May be NULL if allocatedSignals equals 0.
- monSignals: Monitoring signals array into which the API will store the monitoring signals (Missed data, offset, target simulation time, Samples/sec). May be NULL if allocatedSignals equals 0.
- endFrame: Pointer to where API stores true when signals are the last in the acquisition buffer (next values will be in a new frame). May be NULL if not of interest.
- simTimeStep: Simulation timestep of the acquired data. May be NULL if not of interest.
|
---|
Return value | - EOK: Success.
- E2BIG: Number of allocated signals is less than the number of group signals.
- EAGAIN: No data available and the timeout has expired.
- EINVAL: Specified acquisition group is invalid or not active (does not exist on target).
- EBADF: Model not specified by previous OpalConnect or OpalSetCurrentModel.
- EIO: Error sending the request or receiving the reply.
- EACCES: Not connected a loaded model.
- ENOMEM: Memory allocation error.
- OP_API_EBAD_SIGNAL: Doing acquisition of one or more dynamic signals that does no longer exist.
- OP_API_ENO_PRODUCT: No license for RT-LAB and RT-LABx.
|
---|
Examples | See example acquisition1. |
---|
Related items | None |
---|
...
Group | Model Interaction, Control Signals |
---|
Description | Returns the current values of the control signals (see Glossary) sent to the computation nodes. These signals can be set by a call to OpalSetControlSignals. |
---|
Required Control | None |
---|
Usage | int OpalGetControlSignals(unsigned short logicalId,unsigned short allocatedSignals, unsigned short *numSignals, double values[]); |
---|
Input | - logicalId: See Glossary.
- allocatedSignals: Number of expected signals.
|
---|
Output | - numSignals: Number of signals in the group.
- values: User defined array where the API stores the returned list of signal values.
|
---|
Return value | - EOK: Success.
- EBADF: Model not specified by previous OpalConnect or OpalSetCurrentModel.
- EINVAL: Model is not loaded, or invalid logicalId.
- EIO: Error sending the request or receiving the reply.
- ENOMEM: Memory allocation error.
- E2BIG: Specified storage not big enough to receive values.
|
---|
Examples | See example control_signal. |
---|
Related items | OpalSetControlSignals |
---|
OpalGetControlSignalsDescription
Group | Model Interaction, Signals |
---|
Description | Returns a set of basic information for each control signal (see Glossary). If there is no connection from the console to the specified subsystem, returns EOK and sets numSignals to 0. Memory for output structure has been allocated by the RT-LAB API. User must free this memory with a call to OpalFreeMemory. |
---|
Required Control | None |
---|
Usage | int OpalGetControlSignalsDescription(int *pSignalCnt,OP_SIGNAL_INFO **ppSignalInfoList); |
---|
Input | None |
---|
Output | - pSignalCnt: Number of control signals returned.
- ppSignalInfoList: List of control signals' description returned. See OP_SIGNAL_INFO.
|
---|
Return value | - EOK: Success.
- EPERM: Control requested, but already given to another client.
- EBADF: Model not specified by previous OpalConnect or OpalSetCurrentModel.
- EIO: Error sending the request or receiving the reply.
- EINVAL: Invalid parameters
|
---|
Examples | See example control_signal. |
---|
Related items | OpalGetControlSignals |
---|
...
Group | Model and project selection |
---|
Description | Connects the API to an active project and contained models. Subsequent API calls refer to this project and models. |
---|
Required Control | None |
---|
Usage | int OpalOpenProject(constchar*projectPath, unsignedshortreturnOnAmbiguity, OP_API_INSTANCE_ID* instId); |
---|
Input | - projectPath: the name of the .llp file that refers to the project. A full relative or absolute path is preferred, but the file name alone will work provided the executable from which this call is made is in a subdirectory of the project.
- instId: The id of the model instance to which the connection is to be made. Should be set to 0 if projectPath is specified.
- returnOnAmbiguity: If set to non-zero, a pop-up will come up if the projectPath is ambiguous, otherwise and error is returned without a pop-up.
|
---|
Output | None |
---|
Return value | - EOK: Success.
- EIO: Error sending the request or receiving the reply.
- ESRCH: Invalid instance id or instance id not found.
- EPERM: Control requested, but already given to another client.
- ENOEXEC: Could not connect to model. Not all of the subsystems are still active.
- EINVAL: Trying to connect to a model whose local and UNC path are both empty.
- ENOENT: Could not find the original model we are trying to connect to.
- OP_API_EBAD_CONFIG: Node mapping not valid or IP address of controller machine not specified (environment variable OPAL_META_CTL_IP not set).
- OP_API_EBAD_PHYS_NODE: Physical node not found.
- OP_API_EMODEL_CHANGED: The original model has been changed (number of sub-systems, sub-systems names, etc.
- OP_API_ENO_LICENSE: No license.
- OP_API_ENO_PRODUCT: No license for RT-LAB and RT-LABx.
- OP_API_MODEL_IO_ TIMEOUT
- OP_API_MODEL_IO_ERROR: Model is missing some or all processes or subsystems.
|
---|
Examples | See example basic_example1, 2, blob1.c, acquisition1.c |
---|
Related items | OpalConnectByName (deprecated), OpalDisconnect (deprecated), OpalCloseProject |
---|
...