练习 - 使用 SignalR 可视化模拟操作数据并与之交互

已完成

重要

请注意,此模拟会生成大量模拟实际操作的数据。 会产生 Azure 使用量。 切记在不需要模拟器时停止模拟器,以避免 Azure 帐户产生不必要的费用。

使用 Visual Studio DeviceSimulator 解决方案模拟运行的风电场。 将遥测数据发送到 Azure 数字孪生,在 Unity 中新配置的数字孪生体将接收输入并显示风电场运行情况。

开始风电场设备模拟

  1. 在 Visual Studio 中,打开 DeviceSimulator.sln

  2. 通过选择“播放”按钮或“F5”来运行设备模拟器

  3. 一个控制台窗口随即打开,其中显示了涡轮机 ID 以及指示连接和设备检索与创建的消息。

    Screenshot of the command window open and running the device simulator solution with turbine IDs and connectivity messages displayed.

  4. 按任意键开始模拟。 如果正确配置并连接到正确的 Azure 服务,可看到一系列的流式传输控制台消息“已收到消息”,表示 Azure 数字孪生服务已确认收到模拟 IoT 数据

    Screenshot of the command window open and running the device simulator solution with console messages displayed from the simulated IoT data.

在 Unity 编辑器中启动数字孪生体

  1. 在 Unity 编辑器中选择“播放”按钮。 编辑器会自动切换到“游戏”选项卡,并开始呈现场景。 UI 面板中的数据反映运行的 DeviceSimulator 应用程序中生成的数据。

    Screenshot of the Unity editor in play mode with the device simulator running.

  2. 在导航时按住鼠标右键,在“游戏”选项卡中导航。 移动场景,使白色圆圈悬停在“位置概览菜单”面板中的涡轮机或涡轮机名称上,可看见“涡轮机”面板,其中有该涡轮机资产的具体信息

    Screenshot of the command window open and running the device simulator solution with updated console messages are displayed from the simulated IoT data.

  3. 查看 Unity 的“游戏”视图下“位置概览菜单”和“涡轮机”面板中显示的数据的变化。

    Screenshot of the Unity editor in play mode with the device simulator running and updated turbine data.

  4. 选择感兴趣的脚本对象来观察风力涡轮机性能。 选择“资产”>“ScriptableObjects”>“涡轮机位置数据”>“T103”。 在“检查器”面板的“涡轮机置数据”部分中检查传入数据。 应用程序处理新的遥测消息时,你应会看到时间间隔、风速、环境温度、转子转速和功率随之浮动

    Screenshot of the Unity Inspector with a turbine prefab selected.

停止 DeviceSimulator

停止模拟器对于确保避免 Azure 帐户产生不必要的费用非常重要。 在命令提示符窗口中按 Ctrl+C,或在 Visual Studio 中选择“停止”