• Azure Digital Twins(2)- 在本地使用ADT Explorer 管理数字孪生


    本文介绍:

    在本地运行ADT Explorer 并连接Azure Digital Twins 实例;

    使用 VS CODE DTDL插件开发第一个 模型文件;

    ADT Explorer的几个基本功能;

    使用ADT Explorer 上传模型文件并生成 twin 孪生;

    视频演示:

    https://www.51azure.cloud/post/2021/4/12/azure-digital-twins-adt-explorer

    重点图文步骤:

    下载并在本地运行ADT Explorer


    在ADT首页,点击 探索数字孪生体,了解更多连接打开ADT Explorer 工具下载页面

    或者直接进入:下载 ADT Explorer:https://aka.ms/adt-explorer

    在右侧release中下载最新版本

    点击Azure_Digital_Twins_ADT_Explorer.zip 文件并下载

    解压后,可以看到如下图内容,read me中包含安装方式:

    1.本地安装

    2.容器安装

    3.在Azure 云中安装

    本文仅介绍在本地安装运行。

    按照如下步骤执行本地安装:

    1. Set up an Azure Digital Twins service instance and give yourself appropriate permissions (e.g. *Azure Digital Twins Owner*). For instructions, please see the following how-to article:
    *[Set up an Azure Digital Twins instance and authentication](https://docs.microsoft.com/azure/digital-twins/how-to-set-up-instance-portal)
    1. When running locally, adt-explorer will use Azure default credentials. In order to authenticate, you can run, for example, **az login** in any command prompt. When you later run adt-explorer, it will pick up the credentials. Alternatively, you can sign into Visual Studio Code.
    1. Select the **Download ZIP** button to download a .zip file of this sample code to your machine. Unzip the **Azure_Digital_Twins__ADT__explorer.zip** folder, and extract the files.
    1. From a command prompt in the `client/src` folder, run `npm install`. This will retrieve all dependencies
    1. From the same command prompt, run `npm run start`.
    > By default, the app runs on port 3000. To customize the port, change the run command. For example, to use port 8080:
    >* Linux/Mac (Bash): `PORT=8080 npm run start`
    >* Windows (cmd): `set PORT=8080 && npm run start`
    > Note: Your ADT app registration must have a reply URL using the same port you are using - e.g. localhost:7000 if that is the port you are using.
    1. Your browser should open and the app should appear.
     
    进入client/src,运行 npm install,注意,如果不知道npm是什么,可参照https://www.51azure.cloud/post/2020/4/15/azure-iot-hub-1-prepare 中安装node js 部分。

    根据不同的操作系统,执行不同的命令:

    >* Linux/Mac (Bash): `PORT=8080 npm run start`
    >* Windows (cmd): `set PORT=8080 && npm run start`
     

    可以看到 ADT Explorer已经在指定的端口运行了起来。

    注意,ADT Explorer 本地运营依赖Azure CLI中的用户信息,需要在Azure CLI中执行 az login先登录自己的账户:

    连接到ADT实例


    将ADT的主机名拷贝

    在ADT Explorer的右上角连接按钮中输入刚才复制的主机名,注意保留https

    使用VS Code 开发第一个 模型文件


    VS code中安装 DTDL插件

    ctrl+shift+p 在上方输入 DTDL:Create interface

    选择一个文件夹后,输入 模型文件名称:本例子输入的是 myfirstmodel

    可以看到DTDL模型文件创建成功。本例子中不用修改该文件。

    在ADT Explorer中上传模型并从模型生成twin


    在ADT Explorer中点击上传模型按钮,选择刚才在vs code创建的 dtdl的json文件。

    上传完成后,可以在ADT Explorer左侧看到 模型文件,点击模型文件的+,输入一个名称,可以为模型文件生成一个twin孪生

    此过程类似于编程当中的,从 类 到 对象 的过程。

    ADT Explorer 几个常见的功能:

    1. 通过查询语句可以查询数字孪生实例中的twin孪生

    2. 可在2处显示查询语句的查询结果

    3.点击2处,可在右侧显示该twin的当前的数据

    4. 点击4处可进行关系绑定,删除等操作





    声明:

    点击可查阅本站文章目录 《文章分类目录》

    本站所有内容仅代表个人观点,如与官文档冲突,请以官方文档为准。

    可在本页面下方留言或通过下方联系方式联系我:

    微信:wxyusz;邮箱:shuzhen.yu@foxmail.com

    欢迎关注公众号“云计算实战”,接收最新文章推送。



    知识共享许可协议

    本作品由Sean Yu 采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。
    欢迎转载、使用、重新发布,但务必保留文章链接:https://www.51azure.cloud,且不得用于商业目的。

  • 相关阅读:
    方法级别的抽象
    同事关系处理6个关键点
    面向对象(类与对象)
    初识面向对象
    Python模块学习
    解决ORA-21561: OID generation failed
    Python模块——PrettyTable 模块
    对于python setup.py install安装的包如何卸载
    git问题--Push rejected: Push to origin/master was rejected
    Scrapyd发布爬虫的工具
  • 原文地址:https://www.cnblogs.com/shuzhenyu/p/14676336.html
Copyright © 2020-2023  润新知