嵌入已运行的 AnyLogic 模拟

问题描述 投票:0回答:2

我需要在我的 Web 应用程序中嵌入已经运行的 AnyLogic 模型模拟。

官方文档描述了如何使用 iframe 标签将模型嵌入到 Web 应用程序中,并将

modelId
指定为查询参数:

<iframe width="1000" height="650" allow="fullscreen"
src="https://cloud.anylogic.com/assets/embed?modelId=7d49a08e-2641-42a9-bf0a-11b2dffe1408"
></iframe>

有没有办法同时指定experimentRunId,以便我可以获得已运行模拟的实时动画?
我尝试使用

runId
experimentRunId
experimentId
等查询参数(与启动模型时动画 API 返回的键类似,链接此处),但它们都不起作用。

运行 ID 取自动画 SVG 运行信息,它是一个如下所示的 JSON 结构:

{
    "animationHeight": 600,
    "animationSpeed": 10,
    "animationWidth": 1000,
    "experimentRunId": "fbc6a1d8-fa08-4a5c-a171-4631657c1aa7",
    "modelUuid": "493e6789-acf7-4dac-971d-325cb508ea39",
    "restUrl": "b0cc221b-8217-474b-af18-c2d07753187b/",
    "sessionUuid": "b0cc221b-8217-474b-af18-c2d07753187b",
    "version": "8.5.0"
}

任何帮助将不胜感激!

javascript html anylogic
2个回答
0
投票

尝试使用Cloud API,可以使用不同的客户端类方法为基于云的 AnyLogic 模型构建的自定义用户界面教程也可能会有所帮助。


0
投票

理论上是可以的。但是您应该拥有当前正在运行的动画 SVG 运行信息对象并重用 JavaScript API 的内部方法。

const animationRunInfo = YOUR_RUN_INFO;
cloudClient._loadContentToDiv(HOST_URL + "/assets/svg/svg-template.html", "animation-container").then(() => {
  const svgClient = SVGFactory.createClient(animationRunInfo.version);
  const animation = new Animation(cloudClient, svgClient, null, animationRunInfo);
  animationRunInfo.host = HOST_URL;
  svgClient.setCallback("onstop", () => animation.stop());
  svgClient.start(animationRunInfo);
    return Promise.resolve(animation);
})
.then(animation => {
  return animation.waitForCompletion();
})
.catch(error => {
  console.error( error );
})
.finally(() => {});
© www.soinside.com 2019 - 2024. All rights reserved.