一.概述

Edgex foundry是一个Linux 基金会运营的开源边缘计算物联网软件框架项目,该项目的核心是基于与硬件和操作系统完全无关的参考软件平台建立的互操作框架,使能即插即用的组件生态系统,统一市场,加速物联网方案的部署。EdgeX Foundry 使有意参与的各方在开放与互操作的物联网方案中自由协作,无论他们是使用公开标准或私有方案。

EdgeX Foundry微服务集合构成了四个微服务层及两个增强的基础系统服务,四个微服务层包含了从物理域数据采集到信息域数据处理等一系列的服务,另外两个基础系统服务为该四个服务层提供支撑服务。

四个微服务层从物理层到应用层依次为:设备服务层(device service),核心服务层(core service),支持服务层(supporting service),开放服务层(export service)。

两个增强基础服务:security和system Management。

在edgex中区分南北向:South Side和North Side

South Side:All IoT 设备、传感器、执行器等数据的来源端。

North Side:云端(the Cloud),数据在这里存储、汇聚、分析、整合等。

二.Core Services

核心服务层包含下列组件:

Core data:负责采集南向设备层数据,并向北向服务提供数据服务。a persistence repository and associated management service for data collected from the south side objects.

Command:负责向南向设备发送命令。a service that facilitates and controls actuation requests from the north side to the south side.

Metadata:负责设备自身能力描述,提供配置新设备并将它们与其拥有的设备服务配对的功能。

a repository and associated management service of metadata about the objects that are connected to EdgeX Foundry. Provides the capability to provision new devices and pair them with their owning device services.

Registry&config:负责服务注册与发现,为其他EdgeX Foundry微服务提供关于EdgeX Foundry内相关服务的信息,包括微服务配置属性。采用开源consul实现。

provides other EdgeX Foundry microservices with information about associated services within EdgeX Foundry and microservices configuration properties (i.e. - a repository of initialization values).

Registry&config微服务向EdgeX Foundry框架范围的微服务提供集中式管理,主要包含两个方面:

Edgex Foundry框架范围内所有微服务的配置参数与操作参数;

Edgex Foundry框架范围内所有微服务的位置与状态;

当每个edgex微服务启动时,都应该向registry&config注册自己,以便registry&config之后可以ping其他微服务以准确获取相关微服务的健康状况,从而为edgex或第三方提供权威的微服务状态信息。

三.Supporting Services

支持服务(SS)层包含广泛的微服务,该层微服务主要提供边缘分析服务和智能分析服务。 此外,该层还为EdgeXmicorservices提供支持功能,如日志记录,调度和数据清理(清理)。

规则引擎,警报和通知微服务 在SS层内,因为它们在Core Services层上运行。 本地分析功能(目前仅以简单的规则引擎实现基本的分析功能)也位于此层。

四.Export Services

在必要情况下,EdgeX Foundry需要可以独立于其他系统运行。Edgex Foundry所依存的网关通常会在独立非联网环境下部署,同时监管一组传感器或设备。当网关在不联网环境下运行时,其监管的传感器及设备是不受外界环境监管或控制的。因此EdgeX Foundry在不连接北向应用的情况下,是可以长时间独立运行的。不过EdgeX Foundry收集的数据总归还是需要定期或不定期的传输给北向应用(通常为云端系统)。开放服务层就是为实现数据的传输。开放服务层提供了一组微服务实现以下功能:

● 北向应用可以在网关注册,并获取其感兴趣的南向设备的数据;

● 通知数据何时被发往何地;

● 通知数据传输格式;

本层提供的微服务:

Client Registration

Distribution

五.Device Services

设备服务层负责与南向设备交互。设备服务是与南向设备或物联网对象交互的边缘连接器,包括各种传感器、执行器等。

设备服务可以同时服务于一个或多个设备(传感器,致动器等)。 DS管理的“设备”可能不是简单的单一物理设备。它可能是EdgeX Foundry的另一个网关(以及该网关的所有设备),设备管理器或设备聚合器,充当设备或设备集合。

设备服务层的微服务通过每个物联网对象本身的协议与设备,传感器,执行器和其他物联网对象进行通信。DS层将由IoT对象生成和传递的数据转换为常见的EdgeX Foundry数据结构,并将转换后的数据发送到Core Services Layer以及EdgeX Foundry其他层的其他微服务。

六.系统服务层

系统服务包含安全基础服务和系统管理服务,目前服务不完善。

七.应用

可通过edgex提供的容器体验edgex服务,参照https://docs.edgexfoundry.org/Ch-Walkthrough.html。

1)安装完docker和docker-compose后,执行如下命令完成镜像下载和启动:

wget https://raw.githubusercontent.com/edgexfoundry/developer-scripts/master/compose-files/docker-compose.yml
docker-compose up -d

一段时间后,所有相关服务都启动成功:

~/edgex/0.7.1_docker$ docker-compose up -d
Creating network "071_docker_edgex-network" with driver "bridge"
Creating edgex-support-rulesengine ... done
Creating edgex-files ... done
Creating edgex-core-consul ... done
Creating edgex-mongo ... done
Creating edgex-config-seed ... done
Creating edgex-support-logging ... done
Creating edgex-core-data ... done
Creating edgex-support-notifications ... done
Creating edgex-core-metadata ... done
Creating edgex-export-client ... done
Creating edgex-core-command ... done
Creating edgex-support-scheduler ... done
Creating edgex-export-distro ... done
~/edgex/0.7.1_docker$ docker-compose ps
Name Command State Ports
------------------------------------------------------------------------------------------------------------------------------------------
edgex-config-seed /bin/sh -c /edgex/cmd/conf ... Exit
edgex-core-command /core-command --consul --p ... Up 0.0.0.0:->/tcp
edgex-core-consul docker-entrypoint.sh agent ... Up /tcp, /tcp, /udp, /tcp, /udp,
0.0.0.0:->/tcp, 0.0.0.0:->/tcp,0.0.0.0:->/tcp, /udp
edgex-core-data /core-data --consul --prof ... Up 0.0.0.0:->/tcp, 0.0.0.0:->/tcp
edgex-core-metadata /core-metadata --consul -- ... Up 0.0.0.0:->/tcp, /tcp
edgex-export-client /export-client --consul -- ... Up 0.0.0.0:->/tcp
edgex-export-distro /export-distro --consul -- ... Up 0.0.0.0:->/tcp, 0.0.0.0:->/tcp
edgex-files /bin/sh -c /usr/bin/tail - ... Up
edgex-mongo docker-entrypoint.sh /bin/ ... Up 0.0.0.0:->/tcp
edgex-support-logging /support-logging --consul ... Up 0.0.0.0:->/tcp
edgex-support-notifications /support-notifications --c ... Up 0.0.0.0:->/tcp
edgex-support-rulesengine /bin/sh -c java -jar -Djav ... Up 0.0.0.0:->/tcp
edgex-support-scheduler /support-scheduler --consu ... Up 0.0.0.0:->/tcp

consul服务对外提供web服务,可通过hostip:8500访问管理服务。

此外,edgex有专门的ui项目:https://github.com/edgexfoundry/edgex-ui-go,运行如下命令启动:

docker run -it -d -p : --name edgex-ui-go edgexfoundry/docker-edgex-ui-go:0.1.

可通过hostip:4000访问,user/passwd均为admin。

2)参考https://docs.edgexfoundry.org/Ch-Walkthrough.html进行API walkthrough测试,将例子API中localhost改为主机的IP地址,比如 http://localhost:48081/api/v1/addressable 修改为

http://192.168.134.144:48081/api/v1/addressable。

可在主机192.168.134.144上搭建mosquitto服务器,并订阅主题a/b/c:

mosquitto_sub -t a/b/c

在Register an Export Client时需要将mqtt broker配置为上文搭建的mosquitto代理服务器,MQTT topic配置为 a/b/c:

POST to http://192.168.134.144:48071/api/v1/registration
{"name":"MyMQTTTopic","addressable":{"name":"MyMQTTBroker","protocol":"TCP","address":"192.168.134.144","port":,"publisher":"EdgeXExportPublisher","user":"wang","password":"mypass","topic":"a/b/c"},"format":"JSON","enable":true,"destination":"MQTT_TOPIC"}

发送数据:

POST to http://192.168.134.144:48080/api/v1/event
{"device":"countcamera1","readings":[{"name":"humancount","value":""},{"name":"caninecount","value":""}]}

mosquitto也会接受到相应数据:

{"id":"5cd13e6b0e3608000187ec7e","pushed":,"device":"countcamera1","created":,"mo,"event":null,"readings":[{"id":"5cd13e6b0e3608000187ec7f","pushed":0,"created":1557216875909,"ntcamera1","name":"humancount","value":""},{"id":"5cd13e6b0e3608000187ec80","pushed":0,"created":0,"device":"countcamera1","name":"caninecount","value":""}]}

八.Walk Through

1.准备工作

安装docker、docker-compose,并成功拉取edgex相关官方镜像,执行如下命令停止并清除edgex容器及数据。

docker-compose down
sudo rm /var/lib/docker/volumes/docker_* -rf
systemctl restart docker

2.启动edgex相关服务,不启动任何device相关服务(包含device-virtual)。

可通过修改docker-compose.yml注释掉Device Services、UIs、Tooling所有服务。

docker-compose up -d

主机IP地址为192.168.134.144,可通过如下命令确认edgex容器中目前没有设备数据:

# curl http://192.168.134.144:48080/api/v1/event
[]

3.注册设备服务和设备的地址

注册设备服务:

POSTtohttp://192.168.134.144:48081/api/v1/addressable
BODY:{"name":"camera control","protocol":"HTTP","address":"172.20.0.1","port":,"path":"/cameracontrol","publisher":"none","user":"none","password":"none","topic":"none"}

注册设备:

POSTtohttp://192.168.134.144:48081/api/v1/addressable
BODY:{"name":"camera1 address","protocol":"HTTP","address":"172.20.0.1","port":,"path":"/camera1","publisher":"none","user":"none","password":"none","topic":"none"}

注意:修改了主机IP和docker IP,需要根据测试环境配置。docker IP指向edgex docker容器的gateway,可通过docker inspect edgex-mongo查看。

POST成功后,会收到注册ID,形如:

5cd4e6479f8fc2000172aba4

可通过 GET to http://192.168.134.144:48081/api/v1/addressable获取刚注册的信息。

4.注册数据描述

注册humancount、caninecount、depth、duration、cameraerror数据,用于描述设备相关数据及错误。

POSTtohttp://192.168.134.144:48080/api/v1/valuedescriptor
BODY:{"name":"humancount","description":"people count","min":"","max":"","type":"I","uomLabel":"count","defaultValue":"","formatting":"%s","labels":["count","humans"]}
POSTtohttp://192.168.134.144:48080/api/v1/valuedescriptor
BODY:{"name":"caninecount","description":"dog count","min":"","max":"","type":"I","uomLabel":"count","defaultValue":"","formatting":"%s","labels":["count","canines"]}
POSTtohttp://192.168.134.144:48080/api/v1/valuedescriptor
BODY:{"name":"depth","description":"scan distance","min":"","max":"","type":"I","uomLabel":"feet","defaultValue":"","formatting":"%s","labels":["scan","distance"]}
POSTtohttp://192.168.134.144:48080/api/v1/valuedescriptor
BODY:{"name":"duration","description":"time between events","min":"","max":"","type":"I","uomLabel":"seconds","defaultValue":"","formatting":"%s","labels":["duration","time"]}
POSTtohttp://192.168.134.144:48080/api/v1/valuedescriptor
BODY:{"name":"cameraerror","description":"error response message from a camera","min":"","max":"","type":"S","uomLabel":"","defaultValue":"error","formatting":"%s","labels":["error","message"]}

同样返回注册ID。

5.注册设备Profile

Device Profile定义设备,包含设备类型、设备数据、设备支持的命令等。

POSTtohttp://192.168.134.144:48081/api/v1/deviceprofile/uploadfile
No headers
FORM-DATA:
key: “file”
value: EdgeX_CameraMonitorProfile.yml

同样返回注册ID。

6.注册设备服务

POSTtohttp://192.168.134.144:48081/api/v1/deviceservice
BODY:{"name":"camera control device service","description":"Manage human and dog counting cameras","labels":["camera","counter"],"adminState":"unlocked","operatingState":"enabled","addressable":{"name":"camera control"}}

7.模拟设备

POSTtohttp://192.168.134.144:48081/api/v1/device
BODY:{"name":"countcamera1","description":"human and dog counting camera #1","adminState":"unlocked","operatingState":"enabled","addressable":{"name":"camera1 address"},"labels":["camera","counter"],"location":"","service":{"name":"camera control device service"},"profile":{"name":"camera monitor profile"}}

8.核实设备和服务

GETtohttp://192.168.134.144:48081/api/v1/deviceservice
GETtohttp://192.168.134.144:48081/api/v1/device

返回注册的设备和服务。

9.执行命令

列出设备支持的命令:

GETtohttp://192.168.134.144:48082/api/v1/device/name/countcamera1
GET to http://192.168.134.144:48082/api/v1/device

device id如下图标注:

列出设备支持的数据:

GETtohttp://192.168.134.144:48080/api/v1/valuedescriptor

核对当前没有数据发送或接受到:

GETtohttp://192.168.134.144:48080/api/v1/event/count

修改depth:

PUTtohttp://localhost:48082/api/v1/device/<systemspecificdeviceid>/command/<systemspecificcommandid>
PUT to http://192.168.134.144:48082/api/v1/device/5cd4ec699f8fc2000172abad/command/5cd4eaeb9f8fc2000172aba8
BODY:{"depth":""}

因为没有设备,执行失败,可通过log确认程序执行过:

dockerlogsedgex-core-command
INFO: // :: Issuing PUT command to: http://172.20.0.1:49977/api/v1/devices/5cd4ec699f8fc2000172abad/scandepth
ERROR: // :: Put http://172.20.0.1:49977/api/v1/devices/5cd4ec699f8fc2000172abad/scandepth: dial tcp 172.20.0.1:49977: getsockopt: connection refused

10.发送数据

模拟发送数据:

POSTtohttp://192.168.134.144:48080/api/v1/event
BODY:{"device":"countcamera1","readings":[{"name":"humancount","value":""},{"name":"caninecount","value":""}]}

读取数据:

GETtohttp://192.168.134.144:48080/api/v1/event/device/countcamera1/10
GET to http://192.168.134.144:48080/api/v1/event/count
GET to http://192.168.134.144:48080/api/v1/reading/name/humancount/10

11.注册远端接收客户端

主机搭建mosquitto服务器,并监听a/b/c主题。

POST to http://192.168.134.144:48071/api/v1/registration
{"name":"MyMQTTTopic","addressable":{"name":"MyMQTTBroker","protocol":"TCP","address":"192.168.134.144","port":,"publisher":"EdgeXExportPublisher","user":"wang","password":"mypass","topic":"a/b/c"},"format":"JSON","enable":true,"destination":"MQTT_TOPIC"}

此时发送的数据moquitto也会接收到相关数据。

参考:

1.edgex官网文档

2.edgex-go github

3.edgex容器https://hub.docker.com/u/edgexfoundry/

4.EdgeX Foundry边缘计算框架简介

5.在树莓派3b+上运行edgex

6. https://github.com/edgexfoundry/docker-edgex-mongo  mongo容器制作

7. https://github.com/edgexfoundry/docker-edgex-volume  volume容器制作

8. EdgeX Foundry在流媒体领域中的应用 vmare中国研发中心 微信公众号

edgex简述的更多相关文章

  1. 简述 OAuth 2.0 的运作流程

    本文将以用户使用 github 登录网站留言为例,简述 OAuth 2.0 的运作流程. 假如我有一个网站,你是我网站上的访客,看了文章想留言表示「朕已阅」,留言时发现有这个网站的帐号才能够留言,此时 ...

  2. JavaScript单线程和浏览器事件循环简述

    JavaScript单线程 在上篇博客<Promise的前世今生和妙用技巧>的开篇中,我们曾简述了JavaScript的单线程机制和浏览器的事件模型.应很多网友的回复,在这篇文章中将继续展 ...

  3. Design Patterns Simplified - Part 3 (Simple Factory)【设计模式简述--第三部分(简单工厂)】

    原文链接:http://www.c-sharpcorner.com/UploadFile/19b1bd/design-patterns-simplified-part3-factory/ Design ...

  4. Android网络定位服务定制简述

    Android 添加高德或百度网络定位服务 Android的网络定位服务以第三方的APK方式提供服务,由于在国内Android原生自带的com.google.android.gms服务几乎处于不可用状 ...

  5. 《Entity Framework 6 Recipes》翻译系列 (1) -----第一章 开始使用实体框架之历史和框架简述

    微软的Entity Framework 受到越来越多人的关注和使用,Entity Framework7.0版本也即将发行.虽然已经开源,可遗憾的是,国内没有关于它的书籍,更不用说好书了,可能是因为EF ...

  6. 简述ASP.NET MVC原理

    1.为什么ASP.NET需要MVC? 因为随着网站的的数量级越来越大,原始的网站方式,这里指的是WebForm,在运行速度和维护性方面,以及代码量上面,越来越难以满足日益庞大的网站维护成本.代码的重构 ...

  7. Design Patterns Simplified - Part 2 (Singleton)【设计模式简述--第二部分(单例模式)】

    原文链接: http://www.c-sharpcorner.com/UploadFile/19b1bd/design-patterns-simplified-part-2-singleton/ De ...

  8. 【翻译】设计模式学习系列1---【Design Patterns Simplified: Part 1【设计模式简述:第一部分】】

    原文链接:http://www.c-sharpcorner.com/UploadFile/19b1bd/design-patterns-simplified-part1/ Design Pattern ...

  9. Android开发3:Intent、Bundle的使用和ListView的应用 、RelativeLayout(相对布局)简述(简单通讯录的实现)

    前言 啦啦啦~博主又来骚扰大家啦~大家是不是感觉上次的Android开发博文有点长呢~主要是因为博主也是小白,在做实验的过程中查询了很多很多概念,努力去理解每一个知识点,才完成了最终的实验.还有就是随 ...

随机推荐

  1. C# Newtonsoft.Json解析json字符串处理(最清晰易懂的方法)

    需求: 假设有如下json字符串: { ", "employees": [ { "firstName": "Bill", &quo ...

  2. preg_quote

    $p = 'http://'; $p = '/'.preg_quote($p, '/').'/'; echo $p; /http\:\/\//

  3. Oracle表存在则删除后再重建

    简单的执行方式: drop table USERINFO; create table USERINFO ( EnglishName ), ChineseName ), Sex ), Age int, ...

  4. [LeetCode] 71. Simplify Path 简化路径

    Given an absolute path for a file (Unix-style), simplify it. For example,path = "/home/", ...

  5. [LeetCode] 750. Number Of Corner Rectangles 边角矩形的数量

    Given a grid where each entry is only 0 or 1, find the number of corner rectangles. A corner rectang ...

  6. Spring boot后台搭建一使用MyBatis集成Mapper和PageHelper

    目标: 使用 Spring  boot+MyBatis+mysql 集成 Mapper 和 PageHelper,实现基本的增删改查 先建一个基本的 Spring Boot 项目开启 Spring B ...

  7. 【计算机视觉】PASCAL VOC数据集分析

    PASCAL VOC数据集分析 PASCAL VOC为图像识别和分类提供了一整套标准化的优秀的数据集,从2005年到2012年每年都会举行一场图像识别challenge. 本文主要分析PASCAL V ...

  8. springboot实战日记(一)数据库基本信息

    摘要:基于spring boot的后端实现,开发一个微信小程序点餐系统,主要是写写思路和遇到的问题以及分享读到的好文章. 项目分析: 1.角色划分,就是开有什么人使用这个系统,买家(手机端),卖家(p ...

  9. Springboot采用hibernate-validate验证请求参数

    在springboot项目使用hibernate-validate对请求参数添加注解进行校验 常用注解 @Null,标注的属性值必须为空 @NotNull,标注的属性值不能为空 @AssertTrue ...

  10. 使用DOS命令登录管理员并添加账号管理员权限

    runas /user:administrator cmd Password: compmgmt.msc