Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Content layer
id1304016594
Content column
id1304016612
Content block
id1304016591

On this page

Table of Contents

Content block
id1304016600

It is possible to simulate Teamwork Cloud projects on the server by using REST API. The topics below describe all available REST API requests and provide examples how to use them.

Note
titlePrerequisites

Before starting simulation, make sure you have prepared your environment and projects for server-side simulation as described in the following topics:


You can use the following REST API requests to simulate Teamwork Cloud projects on the server:


Start simulation

Panel
borderColorlightgrey
borderWidth1
borderStylesolid

GET /webapp/api/simulation/start/project/<project>/branch/<branch>/element/<element_id>/config/<config>


This REST API request starts the simulation. It connects to Teamwork Cloud, finds the element to execute, and starts simulation if the element exists. After the simulation is complete, the request constructs and returns a unique ID (per application) for the given execution.

The following table describes the parameters used in the REST API request:

ParameterInRequired or optionalDescription
projectpathrequiredThe Teamwork Cloud project name or ID.
branchpathoptionalThe project branch name or ID. If the branch is omitted, the trunk is used instead.
element_idpathoptionalThe server ID of the Instance Specification to be executed.
configpathrequiredThe Simulation Configuration name or server ID.
?resultAsJsonqueryoptional

This key can be written at the end of the REST API request to return CSV export results in the JSON format. Simulation results are returned according to the CSVExport configuration that is assigned to the Simulation Configuration.

Available values are true or false (default).

If there is more than one CSVExport then the data is returned according to the first assigned CSVExport. 



Code Block
titleRequest and response examples
/webapp/api/simulation/start/project/SpacecraftMassRollup/branch/2/element/519701b0-bec8-4f51-aad5-152a5411d60b/config/spacecraft mass analysis?resultAsJson=true

{
"simulationId": "c7944233-a1cb-4310-a62f-48bce07dd71c"
}



/webapp/api/simulation/start/project/CarBrakingAnalysis/config/Vehicle Analysis no Matlab

{   
"simulationId": "cf83877b-86cc-466c-89a1-af97619a9a86"
}



/webapp/api/simulation/start/project/8715fcfa-fd34-4928-8480-13f4439cec3d/element/519701b0-bec8-4f51-aad5-152a5411d60b/config/7915fcfa-fd88-4910-8560-13f4439cec3d

{
"simulationId": "b7bdf933-f58d-4e7e-b73b-8370c60485cd"
}


Get simulation status

Panel
borderColorlightgrey
borderWidth1

GET /webapp/api/simulation/status/<simulation_id>


This REST API request gets the status and elapsed time for a specific simulation. It returns the actual elapsed time of the simulation thread and the simulation state: RUNNING, COMPLETED, TERMINATED, ERROR.

The following table describes the parameters used in the REST API request:

ParameterInRequired or optionalDescription
simulation_idpathrequiredThe ID of a specific simulation.



Code Block
titleRequest and response examples
/webapp/api/simulation/status/ce8c8215-0515-43fd-9d34-92d1d7a95d87

{
"state": "COMPLETED",
"userId": "Administrator",
"elapsedTime": 8078
}


Get simulation results

Panel
borderColorlightgrey
borderWidth1
borderStylesolid

GET /webapp/api/simulation/resultsresult/<simulation_id>


This REST API returns the results of the specified simulation. In the specified simulation. Note that simulation results are returned only if you specify CSVExport for the Simulation Configuration and use the ?resultAsJson=true key when starting the simulationstart REST API body, you can specify what output parameters should be returned. If output parameters are not specified, all output parameters are obtained. In addition, if the CSV export results are available, they are returned in JSON format.

The following table describes the parameters used in the REST API requestAPI request:

ParameterInRequired or optionalDescription
simulation_idpathrequiredThe ID of the running simulation.



Code Block
titleRequest and response examples
/webapp/api/simulation/results/ce8c8215-0515-43fd-9d34-92d1d7a95d87

{
 "outputs": {
 "resultme": "time(s),ma,margin,me,mr\n0.0000,130.0000,35.0000,95.0000,15.0000\n1.0000,130.0000,35.0000,95.0000,15.0000\n2.0000,130.0000,35.0000,95.0000,15.0000\n3.0000,130.0000,35.0000,95.0000,15.0000\n4.0000,130.0000,35.0000,95.0000,15.0000\n5.0000,130.0000,35.0000,95.0000,15.0000\n"98.0,
 "propulsion.me": 68.0,
 "propulsion.tank.me": 38.0,
 "propulsion.thruster.me": 30.0,
 "telecom.me": 30.0,
 "telecom.antenna.me": 10.0,
 "telecom.amplifier.me": 20.0
 },
 "csv exports": {
 "'SpaceCraftResults' csv export": "me,propulsion.me,propulsion.tank.me,propulsion.thruster.me,telecom.me,telecom.amplifier.me,telecom.antenna.me\n98.0000,68.0000,38.0000,30.0000,30.0000,20.0000,10.0000\n98.0000,68.0000,38.0000,30.0000,30.0000,20.0000,10.0000\n98.0000,68.0000,38.0000,30.0000,30.0000,20.0000,10.0000\n"
 }
}


Get the list of running simulations

Panel
borderColorlightgrey
borderWidth1
borderStylesolid

GET /webapp/api/simulation/running


This REST API request gets the list of all currently running simulations that you have started.

Code Block
titleRequest and response examples
/webapp/api/simulation/running


["9bc18e3e-b544-4652-9bdb-6da1d75f7ea1"]


Terminate simulation

Panel
borderColorlightgrey
borderWidth1
borderStylesolid

GET /webapp/api/simulation/terminate/<simulation_id>


This REST API request terminates the specified simulation.

The following table describes the parameters used in the REST API request:

ParameterInRequired or optionalDescription
simulation_idpathrequiredThe ID of a specific simulation.



Code Block
titleRequest and response examples
/webapp/api/simulation/terminate/4e35bc60-2c66-48e8-96e2-80f5270c08cf

/webapp/api/simulation/status/4e35bc60-2c66-48e8-96e2-80f5270c08cf

{
 "state": "TERMINATED",
 "userId": "Administrator",
 "elapsedTime": 11702
}


Check for Simulation Configurations

Panel
borderColorlightgrey
borderWidth1
borderStylesolid

GET /webapp/api/simulation/hasConfigs/project/<project>/branch/<branch>


This REST API checks if the project has any Simulation Configurations.

The following table describes the parameters used in the REST API request:

ParameterInRequired or optionalDescription
projectpathrequiredThe Teamwork Cloud project name or ID.
branchpathoptionalThe project branch name or ID. If the branch is omitted, the trunk is used instead.



Code Block
titleRequest and response examples
/webapp/api/simulation/hasConfigs/project/SpacecraftMassRollup

{
 "hasConfigs": true
}


Get Simulation Configurations

Panel
borderColorlightgrey
borderWidth1
borderStylesolid

GET /webapp/api/simulation/configs/project/<project>/branch/<branch>/element/<element_id>


This REST API request retrieves element IDs, names, and descriptions of the Simulation Configurations available for the given executable element.

If the executable element is an Instance Specification, the method returns the Simulation Configurations:

  • Whose execution target is the classifier of the executable element.
  • Whose execution target is the Instance Specification having at least one classifier matching those of the executable element.

The following table describes the parameters used in the REST API request:

ParameterInRequired or optionalDescription
projectpathrequiredThe Teamwork Cloud project name or ID.
branchpathoptionalThe project branch name or ID. If the branch is omitted, the trunk is used instead.
element_idpathoptionalThe server ID of the Instance Specification to be executed.



Code Block
titleRequest and response examples
/webapp/api/simulation/configs/project/SpacecraftMassRollup

{
 "configId": "7915fcfa-fd88-4910-8560-13f4439cec3d",
 "configName": "spacecraft mass analysis",
 "documentation": ""
 }