实例控制
4 仿真实例接口
4.1 创建实例
POST /simulations
加载指定场景并创建独立实例。请求头 Idempotency-Key 必填,长度为 8~128 个可打印 ASCII 字符,区分大小写。同一凭证下,相同参数和相同幂等键在有效期内返回同一个创建结果;不同参数复用幂等键返回 HTTP 409 IDEMPOTENCY_KEY_REUSED。幂等记录保留时长由服务提供方提供。
| 请求字段 | 类型与必填 | 含义及来源 |
|---|---|---|
sceneId | 非空白字符串,必填,最长 128 | 可运行的场景 ID,由服务提供方提供 |
randomSeed | 64 位整数,可选,大于等于 1 | 随机种子;省略或 null 时取 1 |
首次创建返回 HTTP 201;相同请求重放返回 HTTP 200,并有 Idempotent-Replayed: true。响应包含 simulationId、sceneId 字符串以及实际采用的 randomSeed;createdAt 为 UTC 创建时间,status=READY 表示可启动,runtimeAvailable 为布尔值,表示运行数据资源是否保留。后续路径使用 simulationId。场景加载失败返回错误,不返回可启动实例。
4.2 启动仿真
POST /simulations/{simulationId}/start
启动已创建的实例,路径参数 simulationId 取自创建响应。成功响应为实例摘要,字段见第 4.3 节。调用后应轮询实例状态,直至完成、失败或达到调用方设置的等待超时。
| 请求字段 | 类型与必填 | 含义与约束 |
|---|---|---|
runMode | 字符串枚举,必填 | FULL_SPEED、REAL_TIME 或 EVENT_DRIVEN;模式约束见第 3.2 节 |
endTimeMicros | 64 位整数,可选 | 结束仿真时刻;省略或 null 时继承场景设置。FULL_SPEED 的有效值必须为大于当前仿真时间的有限正整数 |
speedMultiplier | 整数,可选 | FULL_SPEED 必须省略或为 null;其他模式允许 1~100,省略或 null 时取 1 |
相同有效启动参数可以重试,不会重新初始化。更改已启动实例的设置使用第 4.6 节的调整运行设置接口。INVALID_SIMULATION_STATE 表示当前状态不允许启动,先查询状态。
4.3 查询实例状态
GET /simulations/{simulationId}
无请求体。返回指定实例的状态、运行设置和资源保留情况。轮询间隔应符合服务调用频率限制,并设置有限等待超时。返回 RUNNING 时继续等待,COMPLETED 且 runtimeAvailable=true 时读取最终结果;FAILED 按第 10 章处理。
| 响应字段 | 字段说明 |
|---|---|
simulationId、sceneId | 字符串,分别标识实例及其源场景 |
randomSeed | 64 位整数,创建实例时采用的随机种子 |
status、terminal | status 为第 3.1 节所列字符串枚举;terminal 为布尔值,表示是否进入终态 |
runMode、speedMultiplier | runMode 为字符串枚举,未启动时可为 null;speedMultiplier 为整数,FULL_SPEED 时为 null |
simulationTimeMicros、endTimeMicros | 64 位整数,分别为当前仿真时刻和结束时刻;无可用值时为 null |
runtimeAvailable | 布尔值,表示运行数据资源是否保留;false 时不能再读取运行数据 |
statusReasonCode、statusMessage | 字符串,可为 null;statusReasonCode 为原因码,statusMessage 为说明,原因码见第 10.3 节 |
flowControl | NONE 为正常;ANIMATION_BACKPRESSURE 表示输出积压导致等待。只取统计结果时使用 FULL_SPEED |
上述实例摘要同样用于启动、暂停、继续、调整运行设置和释放实例的成功响应。释放后摘要仍可查询。查询超时不能据此判断实例失败,也不要直接新建实例。
4.4 暂停仿真
POST /simulations/{simulationId}/pause
请求体可省略或传空对象 。暂停正在运行的实例,成功响应为实例摘要,status 为 PAUSED,字段见第 4.3 节。重复暂停保持已生效的状态。请求可能与正在执行的操作交叠,暂停响应不保证全部字段取自同一瞬间;需稳定读取时继续查询实例状态并检查数据的 observation。
4.5 继续仿真
POST /simulations/{simulationId}/resume
请求体可省略或传空对象 。恢复已暂停实例的运行,成功响应为实例摘要,字段见第 4.3 节。重复调用保持已生效状态;COMPLETED、FAILED、STOPPED 终态不能恢复,遇到 409 INVALID_SIMULATION_STATE 应先查询实例状态。
4.6 调整运行设置
PUT /simulations/{simulationId}/run-mode
调整已启动实例的运行模式、倍速和结束时刻。参数类型见第 4.2 节,runMode 必填;endTimeMicros 省略或为 null 时沿用实例已有设置,speedMultiplier 省略或为 null 时按目标模式取默认值。三种模式间可切换,暂停状态下调整不会自动恢复。成功响应为第 4.3 节定义的实例摘要。
下列请求将运行模式设为 REAL_TIME、倍速设为 100、结束时刻设为 -1。切换为 FULL_SPEED 时,有效结束时刻须满足第 3.2 节的有限结束条件,且 speedMultiplier 必须省略或为 null。
4.7 释放实例
POST /simulations/{simulationId}/stop
无请求体。结束尚在运行的实例并释放运行数据资源。已完成实例的 status 保持 COMPLETED,runtimeAvailable 变为 false。成功响应为第 4.3 节定义的实例摘要;重复调用保持已释放状态。应在所需统计结果和结果表保存成功后调用。
释放后,统计、对象和表等运行数据接口返回 HTTP 410 SIMULATION_RUNTIME_RELEASED。实例摘要仍可查询。已释放的实例不能继续运行;需临时暂停时使用第 4.4 节的暂停接口。
接口参考与调用示例
以下为结构示例,未代表当前环境实测。路径中的标识和请求变量使用本次响应或获授权的配置。
创建实例
POST /simulation/openapi/v1/simulations
服务已启用;凭证有权限访问该场景。选用不含外部设备调用的测试场景。
请求参数
认证头 X-Foresim-Api-Key 由调用方服务端添加;可选 X-Request-Id 用于关联请求。当前接口没有查询字符串参数。
| 位置 | 字段 | 类型 | 必填与说明 |
|---|---|---|---|
| header | Idempotency-Key | string | 必填。8~128 个可打印 ASCII 字符;重试同一操作必须复用原键和原参数 |
| 字段 | 类型与约束 | 必填 | 说明 |
|---|---|---|---|
sceneId | string minLength=1,maxLength=128 | 是 | 获授权的场景编号;作为字符串传递 |
randomSeed | integer (int64) / null minimum=1 | 否 | 省略/null 默认 1 |
请求示例
双花括号是测试页变量,发送时替换;下列模板尚未发送。
POST /simulation/openapi/v1/simulations
X-Foresim-Api-Key: <api-key>
Accept: application/json
Idempotency-Key: <new-operation-key>
Content-Type: application/json
{
"sceneId": "{{sceneId}}",
"randomSeed": 1
}
成功响应结构
首次成功 HTTP 201;相同幂等请求重放为 HTTP 200,并返回 Idempotent-Replayed: true。外层 code=OK。下方是结构示例,值与空数组不代表实测数据。
{
"code": "OK",
"message": "Success",
"requestId": "example_request",
"data": {
"simulationId": "example_simulationId",
"sceneId": "example_sceneId",
"status": "READY",
"createdAt": "2026-01-01T00:00:00Z",
"randomSeed": 0,
"runtimeAvailable": true
}
}
展开完整响应字段定义
| 字段 | 类型与约束 | 必填 | 说明 |
|---|---|---|---|
simulationId | string | 是 | 本次创建返回的实例编号 |
sceneId | string | 是 | 获授权的场景编号;作为字符串传递 |
status | string READY / RUNNING / PAUSED / COMPLETED / STOPPED / FAILED | 是 | 见字段结构 |
createdAt | string (date-time) | 是 | 见字段结构 |
randomSeed | integer (int64) | 是 | 省略/null 默认 1 |
runtimeAvailable | boolean | 是 | 见字段结构 |
典型失败与下一步
401 检查服务端凭证;403 检查来源和实例归属;400 检查 details 中的字段;409 检查状态、幂等键或名称歧义;410 表示资源已释放;429 按 Retry-After 停止并等待。保留实际 requestId。
{"code":"INVALID_REQUEST","message":"Invalid request","requestId":"example_error","details":[{"field":"request","reason":"检查必填字段和前置状态"}]}
启动仿真
POST /simulation/openapi/v1/simulations/{simulationId}/start
实例处于 READY。FULL_SPEED 需要大于当前仿真时间的有限结束时刻;其他模式请持续消费动画数据。
请求参数
认证头 X-Foresim-Api-Key 由调用方服务端添加;可选 X-Request-Id 用于关联请求。当前接口没有查询字符串参数。
| 位置 | 字段 | 类型 | 必填与说明 |
|---|---|---|---|
| path | simulationId | string | 必填。本次创建返回的实例编号 |
| 字段 | 类型与约束 | 必填 | 说明 |
|---|---|---|---|
runMode | string REAL_TIME / EVENT_DRIVEN / FULL_SPEED | 是 | FULL_SPEED 不传倍速;有限结束时刻必须大于当前仿真时间 |
speedMultiplier | integer (int32) / null minimum=1,maximum=100 | 否 | 省略/null 默认 1,仅 REAL_TIME / EVENT_DRIVEN 使用 |
endTimeMicros | integer (int64) / null minimum=-1 | 否 | 仿真微秒;省略/null 继承已有设置,-1 为不限时(FULL_SPEED 不允许) |
请求示例
双花括号是测试页变量,发送时替换;下列模板尚未发送。
POST /simulation/openapi/v1/simulations/{simulationId}/start
X-Foresim-Api-Key: <api-key>
Accept: application/json
Content-Type: application/json
{
"runMode": "FULL_SPEED",
"endTimeMicros": 600000000
}
成功响应结构
首次成功 HTTP 200;外层 code=OK。下方是结构示例,值与空数组不代表实测数据。
{
"code": "OK",
"message": "Success",
"requestId": "example_request",
"data": {
"simulationId": "example_simulationId",
"sceneId": "example_sceneId",
"status": "READY",
"terminal": false,
"runMode": "REAL_TIME",
"speedMultiplier": null,
"simulationTimeMicros": null,
"statusMessage": null,
"randomSeed": 0,
"runtimeAvailable": true,
"flowControl": "example",
"statusReasonCode": null,
"endTimeMicros": null
}
}
展开完整响应字段定义
| 字段 | 类型与约束 | 必填 | 说明 |
|---|---|---|---|
simulationId | string | 是 | 本次创建返回的实例编号 |
sceneId | string | 是 | 获授权的场景编号;作为字符串传递 |
status | string READY / RUNNING / PAUSED / COMPLETED / STOPPED / FAILED | 是 | 见字段结构 |
terminal | boolean | 是 | 见字段结构 |
runMode | string / null REAL_TIME / EVENT_DRIVEN / FULL_SPEED / | 是 | FULL_SPEED 不传倍速;有限结束时刻必须大于当前仿真时间 |
speedMultiplier | integer (int32) / null | 是 | 省略/null 默认 1,仅 REAL_TIME / EVENT_DRIVEN 使用 |
simulationTimeMicros | integer (int64) / null | 是 | 见字段结构 |
statusMessage | string / null | 是 | 见字段结构 |
randomSeed | integer (int64) | 是 | 省略/null 默认 1 |
runtimeAvailable | boolean | 是 | 见字段结构 |
flowControl | string | 是 | 见字段结构 |
statusReasonCode | string / null | 是 | 见字段结构 |
endTimeMicros | integer (int64) / null | 是 | 仿真微秒;省略/null 继承已有设置,-1 为不限时(FULL_SPEED 不允许) |
典型失败与下一步
401 检查服务端凭证;403 检查来源和实例归属;400 检查 details 中的字段;409 检查状态、幂等键或名称歧义;410 表示资源已释放;429 按 Retry-After 停止并等待。保留实际 requestId。
{"code":"INVALID_REQUEST","message":"Invalid request","requestId":"example_error","details":[{"field":"request","reason":"检查必填字段和前置状态"}]}
查询实例状态
GET /simulation/openapi/v1/simulations/{simulationId}
实例属于当前凭证;释放后仍可读取摘要。
请求参数
认证头 X-Foresim-Api-Key 由调用方服务端添加;可选 X-Request-Id 用于关联请求。当前接口没有查询字符串参数。
| 位置 | 字段 | 类型 | 必填与说明 |
|---|---|---|---|
| path | simulationId | string | 必填。本次创建返回的实例编号 |
无请求体,不发送空 JSON 代替省略。
请求示例
双花括号是测试页变量,发送时替换;下列模板尚未发送。
GET /simulation/openapi/v1/simulations/{simulationId}
X-Foresim-Api-Key: <api-key>
Accept: application/json
成功响应结构
首次成功 HTTP 200;外层 code=OK。下方是结构示例,值与空数组不代表实测数据。
{
"code": "OK",
"message": "Success",
"requestId": "example_request",
"data": {
"simulationId": "example_simulationId",
"sceneId": "example_sceneId",
"status": "READY",
"terminal": false,
"runMode": "REAL_TIME",
"speedMultiplier": null,
"simulationTimeMicros": null,
"statusMessage": null,
"randomSeed": 0,
"runtimeAvailable": true,
"flowControl": "example",
"statusReasonCode": null,
"endTimeMicros": null
}
}
展开完整响应字段定义
| 字段 | 类型与约束 | 必填 | 说明 |
|---|---|---|---|
simulationId | string | 是 | 本次创建返回的实例编号 |
sceneId | string | 是 | 获授权的场景编号;作为字符串传递 |
status | string READY / RUNNING / PAUSED / COMPLETED / STOPPED / FAILED | 是 | 见字段结构 |
terminal | boolean | 是 | 见字段结构 |
runMode | string / null REAL_TIME / EVENT_DRIVEN / FULL_SPEED / | 是 | FULL_SPEED 不传倍速;有限结束时刻必须大于当前仿真时间 |
speedMultiplier | integer (int32) / null | 是 | 省略/null 默认 1,仅 REAL_TIME / EVENT_DRIVEN 使用 |
simulationTimeMicros | integer (int64) / null | 是 | 见字段结构 |
statusMessage | string / null | 是 | 见字段结构 |
randomSeed | integer (int64) | 是 | 省略/null 默认 1 |
runtimeAvailable | boolean | 是 | 见字段结构 |
flowControl | string | 是 | 见字段结构 |
statusReasonCode | string / null | 是 | 见字段结构 |
endTimeMicros | integer (int64) / null | 是 | 仿真微秒;省略/null 继承已有设置,-1 为不限时(FULL_SPEED 不允许) |
典型失败与下一步
401 检查服务端凭证;403 检查来源和实例归属;400 检查 details 中的字段;409 检查状态、幂等键或名称歧义;410 表示资源已释放;429 按 Retry-After 停止并等待。保留实际 requestId。
{"code":"INVALID_REQUEST","message":"Invalid request","requestId":"example_error","details":[{"field":"request","reason":"检查必填字段和前置状态"}]}
暂停仿真
POST /simulation/openapi/v1/simulations/{simulationId}/pause
先查询并确认实例处于 RUNNING;重复暂停按当前实例状态处理。
请求参数
认证头 X-Foresim-Api-Key 由调用方服务端添加;可选 X-Request-Id 用于关联请求。当前接口没有查询字符串参数。
| 位置 | 字段 | 类型 | 必填与说明 |
|---|---|---|---|
| path | simulationId | string | 必填。本次创建返回的实例编号 |
无请求体,不发送空 JSON 代替省略。
请求示例
双花括号是测试页变量,发送时替换;下列模板尚未发送。
POST /simulation/openapi/v1/simulations/{simulationId}/pause
X-Foresim-Api-Key: <api-key>
Accept: application/json
成功响应结构
首次成功 HTTP 200;外层 code=OK。下方是结构示例,值与空数组不代表实测数据。
{
"code": "OK",
"message": "Success",
"requestId": "example_request",
"data": {
"simulationId": "example_simulationId",
"sceneId": "example_sceneId",
"status": "READY",
"terminal": false,
"runMode": "REAL_TIME",
"speedMultiplier": null,
"simulationTimeMicros": null,
"statusMessage": null,
"randomSeed": 0,
"runtimeAvailable": true,
"flowControl": "example",
"statusReasonCode": null,
"endTimeMicros": null
}
}
展开完整响应字段定义
| 字段 | 类型与约束 | 必填 | 说明 |
|---|---|---|---|
simulationId | string | 是 | 本次创建返回的实例编号 |
sceneId | string | 是 | 获授权的场景编号;作为字符串传递 |
status | string READY / RUNNING / PAUSED / COMPLETED / STOPPED / FAILED | 是 | 见字段结构 |
terminal | boolean | 是 | 见字段结构 |
runMode | string / null REAL_TIME / EVENT_DRIVEN / FULL_SPEED / | 是 | FULL_SPEED 不传倍速;有限结束时刻必须大于当前仿真时间 |
speedMultiplier | integer (int32) / null | 是 | 省略/null 默认 1,仅 REAL_TIME / EVENT_DRIVEN 使用 |
simulationTimeMicros | integer (int64) / null | 是 | 见字段结构 |
statusMessage | string / null | 是 | 见字段结构 |
randomSeed | integer (int64) | 是 | 省略/null 默认 1 |
runtimeAvailable | boolean | 是 | 见字段结构 |
flowControl | string | 是 | 见字段结构 |
statusReasonCode | string / null | 是 | 见字段结构 |
endTimeMicros | integer (int64) / null | 是 | 仿真微秒;省略/null 继承已有设置,-1 为不限时(FULL_SPEED 不允许) |
典型失败与下一步
401 检查服务端凭证;403 检查来源和实例归属;400 检查 details 中的字段;409 检查状态、幂等键或名称歧义;410 表示资源已释放;429 按 Retry-After 停止并等待。保留实际 requestId。
{"code":"INVALID_REQUEST","message":"Invalid request","requestId":"example_error","details":[{"field":"request","reason":"检查必填字段和前置状态"}]}
继续仿真
POST /simulation/openapi/v1/simulations/{simulationId}/resume
先查询并确认实例处于 PAUSED。
请求参数
认证头 X-Foresim-Api-Key 由调用方服务端添加;可选 X-Request-Id 用于关联请求。当前接口没有查询字符串参数。
| 位置 | 字段 | 类型 | 必填与说明 |
|---|---|---|---|
| path | simulationId | string | 必填。本次创建返回的实例编号 |
无请求体,不发送空 JSON 代替省略。
请求示例
双花括号是测试页变量,发送时替换;下列模板尚未发送。
POST /simulation/openapi/v1/simulations/{simulationId}/resume
X-Foresim-Api-Key: <api-key>
Accept: application/json
成功响应结构
首次成功 HTTP 200;外层 code=OK。下方是结构示例,值与空数组不代表实测数据。
{
"code": "OK",
"message": "Success",
"requestId": "example_request",
"data": {
"simulationId": "example_simulationId",
"sceneId": "example_sceneId",
"status": "READY",
"terminal": false,
"runMode": "REAL_TIME",
"speedMultiplier": null,
"simulationTimeMicros": null,
"statusMessage": null,
"randomSeed": 0,
"runtimeAvailable": true,
"flowControl": "example",
"statusReasonCode": null,
"endTimeMicros": null
}
}
展开完整响应字段定义
| 字段 | 类型与约束 | 必填 | 说明 |
|---|---|---|---|
simulationId | string | 是 | 本次创建返回的实例编号 |
sceneId | string | 是 | 获授权的场景编号;作为字符串传递 |
status | string READY / RUNNING / PAUSED / COMPLETED / STOPPED / FAILED | 是 | 见字段结构 |
terminal | boolean | 是 | 见字段结构 |
runMode | string / null REAL_TIME / EVENT_DRIVEN / FULL_SPEED / | 是 | FULL_SPEED 不传倍速;有限结束时刻必须大于当前仿真时间 |
speedMultiplier | integer (int32) / null | 是 | 省略/null 默认 1,仅 REAL_TIME / EVENT_DRIVEN 使用 |
simulationTimeMicros | integer (int64) / null | 是 | 见字段结构 |
statusMessage | string / null | 是 | 见字段结构 |
randomSeed | integer (int64) | 是 | 省略/null 默认 1 |
runtimeAvailable | boolean | 是 | 见字段结构 |
flowControl | string | 是 | 见字段结构 |
statusReasonCode | string / null | 是 | 见字段结构 |
endTimeMicros | integer (int64) / null | 是 | 仿真微秒;省略/null 继承已有设置,-1 为不限时(FULL_SPEED 不允许) |
典型失败与下一步
401 检查服务端凭证;403 检查来源和实例归属;400 检查 details 中的字段;409 检查状态、幂等键或名称歧义;410 表示资源已释放;429 按 Retry-After 停止并等待。保留实际 requestId。
{"code":"INVALID_REQUEST","message":"Invalid request","requestId":"example_error","details":[{"field":"request","reason":"检查必填字段和前置状态"}]}
调整运行设置
PUT /simulation/openapi/v1/simulations/{simulationId}/run-mode
实例处于 RUNNING 或 PAUSED;先查询当前时刻,确认新的结束时刻合法。
请求参数
认证头 X-Foresim-Api-Key 由调用方服务端添加;可选 X-Request-Id 用于关联请求。当前接口没有查询字符串参数。
| 位置 | 字段 | 类型 | 必填与说明 |
|---|---|---|---|
| path | simulationId | string | 必填。本次创建返回的实例编号 |
| 字段 | 类型与约束 | 必填 | 说明 |
|---|---|---|---|
runMode | string REAL_TIME / EVENT_DRIVEN / FULL_SPEED | 是 | FULL_SPEED 不传倍速;有限结束时刻必须大于当前仿真时间 |
speedMultiplier | integer (int32) / null minimum=1,maximum=100 | 否 | 省略/null 默认 1,仅 REAL_TIME / EVENT_DRIVEN 使用 |
endTimeMicros | integer (int64) / null minimum=-1 | 否 | 仿真微秒;省略/null 继承已有设置,-1 为不限时(FULL_SPEED 不允许) |
请求示例
双花括号是测试页变量,发送时替换;下列模板尚未发送。
PUT /simulation/openapi/v1/simulations/{simulationId}/run-mode
X-Foresim-Api-Key: <api-key>
Accept: application/json
Content-Type: application/json
{
"runMode": "REAL_TIME",
"speedMultiplier": 1,
"endTimeMicros": 600000000
}
成功响应结构
首次成功 HTTP 200;外层 code=OK。下方是结构示例,值与空数组不代表实测数据。
{
"code": "OK",
"message": "Success",
"requestId": "example_request",
"data": {
"simulationId": "example_simulationId",
"sceneId": "example_sceneId",
"status": "READY",
"terminal": false,
"runMode": "REAL_TIME",
"speedMultiplier": null,
"simulationTimeMicros": null,
"statusMessage": null,
"randomSeed": 0,
"runtimeAvailable": true,
"flowControl": "example",
"statusReasonCode": null,
"endTimeMicros": null
}
}
展开完整响应字段定义
| 字段 | 类型与约束 | 必填 | 说明 |
|---|---|---|---|
simulationId | string | 是 | 本次创建返回的实例编号 |
sceneId | string | 是 | 获授权的场景编号;作为字符串传递 |
status | string READY / RUNNING / PAUSED / COMPLETED / STOPPED / FAILED | 是 | 见字段结构 |
terminal | boolean | 是 | 见字段结构 |
runMode | string / null REAL_TIME / EVENT_DRIVEN / FULL_SPEED / | 是 | FULL_SPEED 不传倍速;有限结束时刻必须大于当前仿真时间 |
speedMultiplier | integer (int32) / null | 是 | 省略/null 默认 1,仅 REAL_TIME / EVENT_DRIVEN 使用 |
simulationTimeMicros | integer (int64) / null | 是 | 见字段结构 |
statusMessage | string / null | 是 | 见字段结构 |
randomSeed | integer (int64) | 是 | 省略/null 默认 1 |
runtimeAvailable | boolean | 是 | 见字段结构 |
flowControl | string | 是 | 见字段结构 |
statusReasonCode | string / null | 是 | 见字段结构 |
endTimeMicros | integer (int64) / null | 是 | 仿真微秒;省略/null 继承已有设置,-1 为不限时(FULL_SPEED 不允许) |
典型失败与下一步
401 检查服务端凭证;403 检查来源和实例归属;400 检查 details 中的字段;409 检查状态、幂等键或名称歧义;410 表示资源已释放;429 按 Retry-After 停止并等待。保留实际 requestId。
{"code":"INVALID_REQUEST","message":"Invalid request","requestId":"example_error","details":[{"field":"request","reason":"检查必填字段和前置状态"}]}
释放实例
POST /simulation/openapi/v1/simulations/{simulationId}/stop
先保存统计和表格结果;此操作会结束尚未完成的运行并释放运行资源。
请求参数
认证头 X-Foresim-Api-Key 由调用方服务端添加;可选 X-Request-Id 用于关联请求。当前接口没有查询字符串参数。
| 位置 | 字段 | 类型 | 必填与说明 |
|---|---|---|---|
| path | simulationId | string | 必填。本次创建返回的实例编号 |
无请求体,不发送空 JSON 代替省略。
请求示例
双花括号是测试页变量,发送时替换;下列模板尚未发送。
POST /simulation/openapi/v1/simulations/{simulationId}/stop
X-Foresim-Api-Key: <api-key>
Accept: application/json
成功响应结构
首次成功 HTTP 200;外层 code=OK。下方是结构示例,值与空数组不代表实测数据。
{
"code": "OK",
"message": "Success",
"requestId": "example_request",
"data": {
"simulationId": "example_simulationId",
"sceneId": "example_sceneId",
"status": "READY",
"terminal": false,
"runMode": "REAL_TIME",
"speedMultiplier": null,
"simulationTimeMicros": null,
"statusMessage": null,
"randomSeed": 0,
"runtimeAvailable": false,
"flowControl": "example",
"statusReasonCode": null,
"endTimeMicros": null
}
}
展开完整响应字段定义
| 字段 | 类型与约束 | 必填 | 说明 |
|---|---|---|---|
simulationId | string | 是 | 本次创建返回的实例编号 |
sceneId | string | 是 | 获授权的场景编号;作为字符串传递 |
status | string READY / RUNNING / PAUSED / COMPLETED / STOPPED / FAILED | 是 | 见字段结构 |
terminal | boolean | 是 | 见字段结构 |
runMode | string / null REAL_TIME / EVENT_DRIVEN / FULL_SPEED / | 是 | FULL_SPEED 不传倍速;有限结束时刻必须大于当前仿真时间 |
speedMultiplier | integer (int32) / null | 是 | 省略/null 默认 1,仅 REAL_TIME / EVENT_DRIVEN 使用 |
simulationTimeMicros | integer (int64) / null | 是 | 见字段结构 |
statusMessage | string / null | 是 | 见字段结构 |
randomSeed | integer (int64) | 是 | 省略/null 默认 1 |
runtimeAvailable | boolean | 是 | 见字段结构 |
flowControl | string | 是 | 见字段结构 |
statusReasonCode | string / null | 是 | 见字段结构 |
endTimeMicros | integer (int64) / null | 是 | 仿真微秒;省略/null 继承已有设置,-1 为不限时(FULL_SPEED 不允许) |
典型失败与下一步
401 检查服务端凭证;403 检查来源和实例归属;400 检查 details 中的字段;409 检查状态、幂等键或名称歧义;410 表示资源已释放;429 按 Retry-After 停止并等待。保留实际 requestId。
{"code":"INVALID_REQUEST","message":"Invalid request","requestId":"example_error","details":[{"field":"request","reason":"检查必填字段和前置状态"}]}