Integration with the REPEAT VISION platform via a web interface#
The web interface of the REPEAT VISION platform allows interaction with user programs, which can be created using any programming language that supports interaction between programs via the web using the REST approach.
1. Prerequisites#
The user must be registered on the REPEAT VISION platform or have an account in the REPEAT VISION distribution installed in the organization’s local network;
The user must first create an API key in their profile settings and use this key when interacting with the REPEAT VISION platform via the web interface;
User must have at least 1 project on the REPEAT VISION platform;
The project must be debugged and should not contain any errors when running the calculation;
The project must contain global variables associated with the required block properties. The project’s global variables store the values of the external program’s parameters and boundary conditions.
2. The process of interaction of external programs with REPEAT VISION#
Before getting acquainted with the basic steps for integration with the REPEAT VISION platform via the web interface, it is necessary to consider the typical process of interaction between an external program and the REPEAT VISION project.
Типовой процесс взаимодействия внешних программ с REPEAT VISION/Typical process of interaction of external programs with REPEAT VISION#
2.1. Obtaining a list of REPEAT VISION platform user projects#
The list of projects is returned by the GET request project/getAll. The API key of the user’s personal account must be placed in the request header.
The request will return a list of [ ] records { } containing the user’s projects. For each project, the most important keys are:
"projectId"- Unique project identifier. This identifier is required to select a specific project for further calculations."projectName"- The project name assigned by the user. This name is useful for verifying which project the user needs for further use from an external program.
2.2. Getting a list of global project variables#
The list of global variables for a single selected project is returned by the GET request model/globals.
The request header must include the API key of the user’s personal account and the string value of the unique identifier of the required project.
The response to the request will be a JSON structure in which the names of the global variables of the selected project are used as keys, and the values of the structure are string representations of the real values of the project’s global variables. For example,
{
"DENSITY": "998.21",
"PRESSURE": "50000.0"
}
2.3. Launching the project for calculation#
Before running the selected project for calculation, it is necessary to prepare new real values of the project’s global variables in accordance with the structure received in response to the request list of global project variables. Optionally, the parameters of the calculation launch request body can be the settings for the simulation time, a detailed description of which is given in the help method.
Launching a project with a given identifier for calculation is performed by POST request model/run.
The parameters of the project calculation request header must be formed in the same way as in the case of a request for a list of global project variables.
The response to the request will be a JSON structure, in which it is desirable to use blocks whose properties contain the "customName" key, applicable for Outport blocks, since for convenient receipt of calculation results it is more clear for the user to use the parameter names assigned to them independently.
See also
A detailed tutorial on the procedure for preparing a model for automating interaction with external programs is given in the relevant section of the documentation.
2.4. Performing a periodic query of the calculation process status#
After starting the calculation, time is required to complete the modeling process, during which a numerical solution of the generated system of differential equations is performed.
The calculation module of the REPEAT VISION platform allows you to periodically generate a response containing information about the state of the calculation process using the GET method model/statusModel.
Important
It is required to query the status of the calculation process with a frequency greater than or equal to 1 second.
The description of the calculation process states of the selected model is presented in the table in the method reference.
2.5. Obtaining calculation results#
Before generating calculation results, information about the calculation module performing the simulation must be obtained. This information is returned by the controllervm/getUserVM GET method. Next, the obtained values must be used in the request header to subsequently obtain the calculation results.
The calculation results for the selected parameter ID are obtained using the POST request model/parameters/getRange.
Note
Parameter identifiers are generated at the stage of launching the project for calculation (see above).
The response to the request will be a JSON structure containing a time series for the specified time interval for the selected parameter identifier.
2.6. Completing interaction with the REPEAT VISION platform calculation module#
After completing the simulation, it is always necessary to terminate the interaction with the calculation module.
This action is performed using a POST request model/stop.
Important
It is important to terminate interaction with the calculation module even if exceptional situations occur during program execution by placing a POST request model/stop in context managers and in exception handling constructs.