C-API Reference v11x and up Functions Reference

Documentation Home Page RT-LAB Home Page
Pour la documentation en FRANÇAIS, utilisez l'outil de traduction de votre navigateur Chrome, Edge ou Safari. Voir un exemple.

C-API Reference v11x and up Functions Reference



The following functions are available to a user in order to interface their application to RT-LAB.

Library & Header, Throughout

OpalAbortCompile

Group

Model preparation

Description

Stops the currently executing compilation.

Required Control

System control

Usage

int OpalAbortCompile();

Input

None

Output

None

Return value

  • EOK: Success.

  • EPRM: System control was not granted to this client.

  • EIO: Error sending the request or receiving the reply.

Examples

None

Related items

OpalStartCompile2, OpalDisplayInformation

OpalAddExtraFile

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:

  • transfer of files during compilation from the host to the target.

  • retrieval of files during compilation from the target to the host

  • transfer of files from the host to the target before the model is loaded

  • retrieval of files from the target to the host after the model is reset

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

  • EOK: Success.

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

  • EOK: Success.

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

OpalCommand

Group

Generic

Description

Run an RT-LAB command for a certain RT-Lab object.
See the OP_COMMAND enumeration for a complete list of available commands and their specific requirements.

Required Control

Specific to each command, see OP_COMMAND.

Usage

int OpalCommand (OP_REF_ID ownerId, OP_COMMAND command, int numAttributesIn,OP_ATTRIBUTE attributes[], void * attributeValues[], OP_REF_ID * outputId)

Input

  • ownerId: The ID of the object that owns the command. Where there is ambiguity, the owner of the two objects is the expected ID. For example CMD_REMOVE: when the owner is a project, the command removes a model.

  • command: The command to be executed

  • numAttributes: The number of attributes to send as arguments for the command.

  • attributes: The array of attributes to send to the command. The size of the array must be equal to the numAttributes argument. May be NULL is numAttributes is 0.

  • attributeValues: The pointer to the array of values to be used as arguments for the command. The type of each value must correspond to the attribute of the same index in attributes. The size of the array must be equal to the numAttributes argument. May be NULL is numAttributes is 0.

Output

outputId    The ID corresponding to the object directly affected by the command. If no other object than the parent is affected, the parent ID is returned.

Return value

  • EOK: Success.

  • EBADF: Unsupported ownerId.

  • EINVAL: Invalid arguments specified.

  • EIO: Error sending the request or receiving the reply.

  • ENOMEM: Error allocation memory for request or reply.

Examples

None.

Related items

OP_COMMAND, OP_ATTRIBUTE.

OpalConnect (deprecated)

Group

Model selection

Description

Connects the API to an active model. Subsequent API calls refer to this model.

Required Control

None

Usage

int OpalConnect(OP_API_INSTANCE_ID instId,unsigned short systemControl, short *modelState);

Input

  • instId: The id of the model instance to which the connection is to be made.

  • systemControl: True to request control of the model.

Output

  • modelState: Current state of the model. See OP_MODEL_STATE.

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

None

Related items

OpalConnectByName (deprecated), OpalDisconnect (deprecated), OpalOpenProject, OpalCloseProject, OpalGetModelState

OpalConnectByName (deprecated)

Group

Model Selection

Description

Connects the API to an active model. Subsequent API calls refer to this model.
When trying to establish a connection with a model when there are multiple models that correspond to the specified ModelName and ModelPath, a window is displayed prompting you to choose a model. This may occur when:

  • modelName is not NULL. The window displays a list of active models with the specified ModelName and ModelPath, unless ReturnOnAmbiguity is set to True1.





  • modelName is not NULL, there is more than one active model with a specified path and name and returnOnAmbiguity is False(0).


exactMatch exactMatch modelName returnOnAmbiguity E2BIG

Required Control

None

Usage

int OpalConnectByName (const char *modelName,const char *modelPath, unsigned short exactMatch, unsigned short systemControl,unsigned short returnOnAmbiguity, OP_API_INSTANCE_ID *pInstId, OP_MODEL_STATE*pModelState);

Input

  • modelName: name of the model to which connection is desired

  • modelPath: Path where original model resides. May be NULL; used to resolve ambiguity when more than one model of the same name are active.

  • exactMatch: True(1) to request an exact name match.

  • systemControl: True(1) to request control of the model.

  • returnOnAmbiguity: No window is displayed, an error code (E2BIG) isreturned.

Output

  • instId: Current active model’s instance ID. See Glossary.

  • modelState: Current model's state.

Return value

  • EOK: Success.

  • EIO: Error sending the request or receiving the reply.

  • ENOENT: No active model found.

  • OP_API_CMD_CANCELED: Active model(s) found but no model has been selected.

  • ENOSPC: No active model with specified name, path and type.

  • E2BIG: More than 1 active models with specified name and path (only if returnOnAmbiguity is TRUE).

  • EPERM: Control requested, but already given to another client.

  • ENOEXEC: Could not connect to model. Not all of the subsystems are still active.

  • ENOMEM: Internal memory allocation error.

  • OP_API_EBAD_CONFIG: Node mapping not valid or IP address of controllermachine not specified (environment variable OPAL_META_CTL_IP not set).

  • OP_API_EBAD_PHYS_NODE: Physical node not found.

  • OP_API_ECREATE_SHMEM: Could not create shared memory.

  • OP_API_ECREATE_PROCESS: Error launching OpalChooseModel.exe - Error displayingthe dialog box. Process OpalChooseModel.exe is called by this function. This process is placed RTLAB_ROOT\common\bin folder.

  • OP_API_ENO_LICENSE: No license for one or more of RT-LAB components.

  • 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 the example basic_example1.

Related items

OpalSetCurrentModel, OpalGetActiveProjects, OpalConnect (deprecated), OpalDisconnect (deprecated), OpalOpenProject, OpalCloseProject, OpalGetModelState

OpalCreateAlias

Group

Model Interaction, Alias

Description

Creates a new alias which is used as a reference to an absolute path of a parameter or signal.

The alias is appended to the current list of aliases. The alias’s name is a no case-sensitive string that should be unique. It should not contains the following special character: an asterisk (*) and question mark (?).

It consists of partitions and a name, or a name only. A partition is an organizational unit, or container, used to organize aliases into a hierarchical structure. Partitions and name of the alias are separated by slash (/) characters. The topmost partition in any partition is called the root partition. A partition that is below another partition is called a subpartition. A partition above a subpartition is called the parent partition. The root partition is a slash (/) characters.

Below are examples of valid alias names:

  • myAliasName

  • /myPartition/myAliasName

  • /myRootPartition/myChildrenPartition/myAliasName



When using alias’ API functions, many syntaxes is available to refer to one specific alias. For example, an alias called “/myPartition/myAlias” can be referenced with the following syntax:

  • /myPartition/myAlias,

  • myPartition/myAlias or

  • myAlias (required a unique name)

Note that the last syntax is only available if no other partitions contain an alias with the name “myAlias”.With Matlab/Simulink, the absolute path of a parameter is the concatenation of the path of the block that contains the parameter and the name of the parameter. Below are examples of parameter’s paths of a SineWave block:

  • Subsystem/SineWave/Amplitude

  • Subsystem/SineWave/Frequency

By analogy, with Matlab/Simulink, the absolute path of a signal is the concatenation of the path of the block that outputs the signal and the signal’s label. If the label is empty in the Simulink model, the port’s name that outputs the signal is used instead of the label. Below are examples of paths for a signal at the outport 1 of a SineWave block:

  • Subsystem/SineWave/Amplitude

  • Subsystem/SineWave/Frequency

By analogy, with Matlab/Simulink, the absolute path of a signal is the concatenation of the path of the block that outputs the signal and the signal’s label. If the label is empty in the Simulink model, the port’s name that outputs the signal is used instead of the label. Below are examples of paths for a signal at the outport 1 of a SineWave block:

  • SubSystem/SineWave/MySignalLabel, or



  • SubSystem/SineWave/Port1

Note that any of the following kind of signals can be referenced: control signals, acquisition signals, and dynamic signals.

Required Control