The following functions are available to a user in order to interface their application to RT-LAB.
...
Group | Model Preparation |
---|
Description | This function adds a file to the list of files to be transferred or retrieved during one of the following steps: |
---|
Required Control | Configuration control |
---|
Usage | int OpalAddExtraFile (OP_EXTRA_FILE_TRANSFER_TIME transferTime, unsigned short logicalId,char *filePathName,OP_FILE_TRANSFER_MODE fileMode); |
---|
Input | - transferTime: See OP_EXTRA_FILE_TRANSFER_TIME.
- logicalID: See Glossary. To specify all subsystem, set the logicalId to 0.file
- PathName: Extra file path and name.
- fileMode: File transfer type (ascii or binary). See OP_FILE_TRANSFER_MODE.
|
---|
Output | None |
---|
Return value | - EOK: Success.
- EFAULT: Invalid parameter.
- EBADF: Model not specified by previous OpalConnect or OpalSetCurrentModel.
- EIO: Error sending the request or receiving the reply.
- ESRCH: Specified subsystem id not found.
|
---|
Examples | See example configuration. |
---|
Related items | OpalGetExtraFiles, OpalRemoveExtraFile, OP_EXTRA_FILE_TRANSFER_TIME, OP_FILE_TRANSFER_MODE |
---|
OpalAddToSelection
Group | Utilities |
---|
Description | Given the object's reference ID, adds it to the selected items. |
---|
Required Control | None |
---|
Usage | int OpalAddToSelection(P_REF_ID *refId); |
---|
Input | - *refId: Pointer to the reference ID (type UINT_64_T).
|
---|
Output | None |
---|
Return value | |
---|
Examples | None |
---|
Related items | None |
---|
OpalCloseMetaController
Group | Utilities |
---|
Description | Close the currently running MetaController. This function should be called only once all projects have been closed and all clients have disconnected from running simulations. After invoking this function, most API calls will not be operational until the MetaController executable is started again. |
---|
Required Control | None |
---|
Usage | int OpalCloseMetaController(); |
---|
Input | None |
---|
Output | None |
---|
Return value | |
---|
Examples | None |
---|
Related items | None |
---|
OpalCloseProject
Group | Model Selection |
---|
Description | Disconnects the API from the currently connected project and model. The model's state does not change as a result of this call. Any control granted to this client is revoked. |
---|
Required Control | None |
---|
Usage | void OpalCloseProject(void); |
---|
Input | None |
---|
Output | None |
---|
Return value | None |
---|
Examples | See example basic_example1. |
---|
Related items | OpalGetActiveProjects, OpalConnect (deprecated), OpalConnectByName (deprecated), OpalSetCurrentModel, OpalOpenProject |
---|
...
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 Configuration, Acquisition |
---|
Description | Requests or releases the acquisition control of the currently connected model. Acquisition control enables the client API to control the model's acquisition parameters for a specific acquisition group. Only one client API at a time is granted acquisition control for a specific acquisition group. |
---|
Required Control | None |
---|
Usage | int OpalGetAcquisitionControl(unsigned short acqControl,unsigned short acqGroup); |
---|
Input | - acqControl
- True(1): to request acquisition control for the specified acquisition group,
- False(0): to release its control.
- acqGroup: Group for which acquisition control is requested (numbering starts at 0).
|
---|
Output | None |
---|
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 acquisition group.
|
---|
Examples | See example dynamic_acq. |
---|
Related items | None |
---|
OpalGetActiveModels (deprecated)
Group | Model Selection |
---|
Description | Note: This function is for backward compatibility only. Please consider using OpalGetActiveProjects instead. Returns a list of active models (see Glossary). The returned names include the file extension (if any) of the original model file. If the allocated storage is too small for the number of models, or for the longest name or longest path, none of the names, paths or instance Ids are returned, but the numModels, maxNameLen and maxPathLen values are set, and the return value is E2BIG. An application can use this fact to specify lengths of 0 on a first call, allocate the required storage and issue a second call to get the information. |
---|
Required Control | None |
---|
Usage | int OpalGetActiveModels(unsigned sFindObjectIdhort allocatedModels,unsigned short *numModels, unsigned short allocatedNameLen, unsigned short *maxNameLen, unsigned short allocatedPathLen, unsigned short *maxPathLen, char *name[],char *path[], OP_API_INSTANCE_ID instId[]); |
---|
Input | - allocatedModels: number of models for which storage was allocated by the caller for the names, paths and instance ids.
- allocatedNameLen: allocated length of storage to receive the names
- allocatedPathLen: allocated length of storage to receive the paths
|
---|
Output | - numModels: pointer to where the API will store the actual number of active models.
- maxNameLen: pointer to where the API will store the length of the longest name.
- maxPathLen: pointer to where the API will store the length of the longest path.
- name: array of strings where the API will store the names of the active models (includes the extension).
- path: array of strings where the API will store the paths of the active models.
- instId: array where the API will store the instance Ids of the active models.
|
---|
Return value | - EOK: Success.
- EIO: Error sending the request or receiving the reply.
- E2BIG: specified storage not big enough to receive values
- ENOMEM: Internal memory allocation error.
- OP_API_EBAD_CONFIG: Node mapping not valid or IP address of the controller machine not specified (environment variable OPAL_META_CTL_IP not set).
|
---|
Examples | None |
---|
Related items | OpalGetActiveProjects, OpalDisconnect, OpalSetCurrentModel, OpalConnectByName |
---|
...
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 |
---|
...