EdgeX Foundry 设备服务

news/2024/5/19 12:48:05 标签: 边缘计算, edge, 物联网, 云原生

文章目录

    • 1.设备服务
    • 2.设备配置文件
    • 3.设备资源
    • 4.资源属性(Attributes)
    • 5.资源属性(Properties)
    • 6.设备命令
    • 7.资源操作
    • 8.REST 命令端点
    • 9.推送事件

  • EdgeX Foundry
# EdgeX Foundry

https://iothub.org.cn/docs/edgex/
https://iothub.org.cn/docs/edgex/device-service/

1.设备服务

设备服务是与传感器/设备或物联网对象(“物”)交互的边缘连接器,其中包括机器、机器人、无人机、HVAC 设备、相机等。通过利用可用的连接器,可以控制设备并/或传输数据至 EdgeX 或从其传输数据。您还可以使用设备服务 SDK 来创建您自己的 EdgeX 设备服务。
在这里插入图片描述

设备配置文件描述了EdgeX 系统内的一种设备类型。设备服务管理的每个设备都与设备配置文件关联,设备配置文件根据其支持的操作定义该设备类型。

通常,设备配置文件由设备服务从文件加载,并在首次启动时推送到核心元数据进行存储。一旦存储在核心元数据中,设备配置文件就会在后续启动时从核心元数据加载。

2.设备配置文件

设备配置文件由以下字段组成

Field NameTypeRequired?Description
nameStringYMust be unique in the EdgeX deployment.
descriptionStringNDescription of the Device Profile
manufacturerStringNManufacturer of the device described by the Device Profile
modelStringNModel of the device(s) described by the Device Profile
labelsArray of StringNFree form labels for querying device profiles
deviceResourcesArray of DeviceResourceYSee Device Resources below
deviceCommandsArray of DeviceCommandNSee Device Commands below

DeviceProfile定义了设备的值和操作方法,可以是Read或Write。

创建名为 的设备配置文件my.custom.device.profile.yml,其中包含以下内容:

name: "my-custom-device-profile"
manufacturer: "iot"
model: "MQTT-DEVICE"
description: "Test device profile"
labels:
  - "mqtt"
  - "test"
deviceResources:
  -
    name: randnum
    isHidden: true
    description: "device random number"
    properties:
      valueType: "Float32"
      readWrite: "R"
  -
    name: ping
    isHidden: true
    description: "device awake"
    properties:
      valueType: "String"
      readWrite: "R"
  -
    name: message
    isHidden: false
    description: "device message"
    properties:
      valueType: "String"
      readWrite: "RW"
  -
    name: json
    isHidden: false
    description: "JSON message"
    properties:
      valueType: "Object"
      readWrite: "RW"
      mediaType: "application/json"

deviceCommands:
  -
    name: values
    readWrite: "R"
    isHidden: false
    resourceOperations:
        - { deviceResource: "randnum" }
        - { deviceResource: "ping" }
        - { deviceResource: "message" }

3.设备资源

设备资源指定设备内的传感器值,可以单独或作为设备命令的一部分读取或写入该值。它具有用于识别的名称和用于提供信息的描述。

设备资源由以下字段组成:

The device resource consists of the following fields:

Field NameTypeRequired?Notes
nameStringYMust be unique in the EdgeX deployment.
descriptionStringNDescription of the device resource
isHiddenBoolNHide the device resource as command via the Command Service, default false
tagsString-Interface MapNUser define collection of tags
attributesString-Interface MapNSee Resource Attributes below
propertiesResourcePropertiesYSee Resource Properties below

4.资源属性(Attributes)

设备资源中的attributes参数是访问设备上的特定值所需的设备服务特定参数。每个设备服务实现都有自己的一组所需的命名值,例如,BACnet 设备服务可能需要对象标识符和属性标识符,而蓝牙设备服务可以使用 UUID 来标识值。

设备 ONVIF 摄像头的资源属性示例

    attributes:
      service: "Device"
      getFunction: "GetDNS"
      setFunction: "SetDNS"

5.资源属性(Properties)

设备资源properties的 描述了值以及要对其执行的可选简单处理。

资源属性由以下字段组成:

The resource properties consists of the following fields:

Field NameTypeRequired?Notes
valueTypeEnumYThe data type of the value. Supported types are: Uint8, Uint16, Uint32, Uint64, Int8, Int16, Int32, Int64, Float32, Float64, Bool, String, Binary, Object, Uint8Array, Uint16Array, Uint32Array, Uint64Array, Int8Array, Int16Array, Int32Array, Int64Array, Float32Array, Float64Array, BoolArray
readWriteEnumYIndicates whether the value is readable or writable or both. R - Read only , W - Write only, RW - Read or Write
unitsStringNDeveloper defined units of value such as secs, mins, etc
minimumFloat64NMinimum value the resource value can be set to. Error if SET command value out of minimum range
maximumFloat64NMaximum value the resource value can be set to. Error if SET command value out of maximum range
defaultValueStringNDefault value to use when no value is present for a set command. If present, should be compatible with the valueType field
maskUint64NA binary mask which will be applied to an integer reading. Only valid when valueType is one of the unsigned integer types
shiftInt64NA number of bits by which an integer reading will be shifted right. Only valid when valueType is one of the unsigned integer types
scaleFloat64NA factor by which to multiply a reading before it is returned. Only valid when valueType is one of the integer or float types
offsetFloat64NA value to be added to a reading before it is returned. Only valid when valueType is one of the integer or float types
baseFloat64NA value to be raised to the power of the raw reading before it is returned. Only valid when valueType is one of the integer or float types
assertionStringNA string value to which a reading (after processing) is compared. If the reading is not the same as the assertion value, the device’s operating state will be set to disabled. This can be useful for health checks.
mediaTypeStringNA string indicating the content type of the Binary value. Required when valueType is Binary.
optionalString-Any MapNOptional mapping for developer use

6.设备命令

设备命令定义同时访问多个资源。每个命名设备命令应包含多个resource operations.具有单个资源操作的设备命令不会比 SDK 为同一设备资源创建的隐式设备命令增加任何值。

当读数在逻辑上相关时,设备命令可能很有用,例如,对于 3 轴加速度计,一起读取所有轴会很有帮助。

每个设备命令由以下字段组成:

Each device command consists of the following fields:

Field NameTypeRequired?Notes
nameStringYMust be unique in this profile.
isHiddenBoolNHide the Device Command for use via Command Service, default false
readWriteEnumYIndicates whether the command is readable or writable or both. R - Read only , W - Write only, RW - Read or Write. Resources’ readWrite included in the command must be consistent with the value chosen here.
resourceOperationsArray of ResourceOperationYsee Resource Operation below

7.资源操作

资源操作由以下字段组成:

A resource operation consists of the following fields:

Field NameTypeRequired?Notes
deviceResourceStringYMust name a Device Resource in this profile
defaultValueStringNIf present, should be compatible with the Type field of the named Device Resource
mappingsString-String MapNMap the GET resourceOperation value to another string value

8.REST 命令端点

命令端点是在服务上为设备配置文件中指定的每个设备资源和每个设备命令隐式创建的。有关更多详细信息,请参阅设备服务 API 参考中的 GET 和 SET 设备命令 API 。

9.推送事件

SDK 应实现除了收到设备 GET 请求之外生成事件的方法。 AutoEvent 机制提供以固定时间间隔生成事件的功能。异步事件队列使设备服务能够根据特定于实现的逻辑在任意时间生成事件。

自动事件

AutoEvents每个设备可以具有与其关联的多个元数据作为其定义的一部分。 AnAutoEvent具有以下字段:

  • resource:deviceResource 或 deviceCommand 的名称,指示要读取的内容。
  • Frequency:一个字符串,表示读取事件之间等待的时间,表示为整数后跟 ms、s、m 或 h 单位。
  • onchange:布尔值:如果设置为 true,则仅当自上次事件以来包含的一个或多个读数发生更改时才生成新事件。

设备 SDK 应根据这些AutoEvent定义从实现中安排设备读取。它应该使用与通过 REST 请求读数时相同的逻辑。

异步事件队列

SDK 应提供一种机制,使实现可以随时提交设备读数而不会阻塞。这可以以适合于实现语言的方式来完成,例如,Go SDK提供可以在其上推送读数的通道,C SDK提供将读数提交到工作队列的功能。

  • EdgeX Foundry
# EdgeX Foundry

https://iothub.org.cn/docs/edgex/
https://iothub.org.cn/docs/edgex/device-service/

http://www.niftyadmin.cn/n/5401980.html

相关文章

AI-数学-高中-29-样本的数字特征(标准差、方差)

原作者视频:【统计】【一数辞典】3样本的数字特征_哔哩哔哩_bilibili 标准差(s)、方差(S^2)公式:判断数据的稳定性。

Pegasus智能家居套件样例开发--软定时器

样例简介 此样例将演示如何在Pegasus Wi-Fi IoT智能家居套件上使用cmsis 2.0 接口进行定时器开发。 工程版本 系统版本/API版本:OpenHarmony 3.0 releaseIDE版本:DevEco Device Tool Release 3.0.0.401 快速上手 准备硬件环境 预装windows系统的PC…

Python反射机制在实际场景中的应用

Python 的反射机制是指在运行时动态地访问、检测和修改类和对象的属性和方法。反射为开发者提供了一种灵活的方式来处理对象和类,可以在实际场景中提供一些有用的功能和应用,下面是 Python 反射在实际场景中的一些常见应用: 插件系统&#xf…

Linux 学习笔记(7)

七、 时间管理 1 、 Linux 时间介绍: Linux 时钟分为系统时钟( System Clock )和硬件( Real Time Clock ,简称 RTC )时钟。系统时钟 是指当前 Linux Kernel 中的时钟,而硬件时钟则是主板…

Android提供了多种方式来打开特定文件夹中的视频

使用 MediaStore获取指定文件夹的视频,更优化方法: import android.content.ContentResolver; import android.content.ContentValues; import android.content.Context; import android.net.Uri; import android.os.Build; import android.os.Environme…

4.1.CVAT——目标检测的标注详细步骤

文章目录 1. 进入任务1. 创建任务2. 已创建的task3. 进入标注界面 2. 选择标注类型2.1 选择标注类型2.2 进行标注2.3 遮挡 2.快捷键3.导出标注结果 1. 进入任务 登录后会看到如下图界面,CVAT的标注最小单位是Task,每个Task为一个标注任务。点击Task按钮…

springcloud:3.1介绍雪崩和Resilience4j

灾难性雪崩效应 简介 服务与服务之间的依赖性,故障会传播,造成连锁反应,会对整个微服务系统造成灾难性的严重后果,这就是服务故障的“雪崩”效应。 原因 1.服务提供者不可用(硬件故障、程序bug、缓存击穿、用户大量请求) 2.重试加大流量(用户重试,代码逻辑重试) 3.服…

什么是端点安全以及如何保护端点

什么是端点安全 端点是指可以接收信号的任何设备,是员工使用的一种计算设备,用于保存公司数据或可以访问 Internet。端点的几个示例包括:服务器、工作站(台式机和笔记本电脑)、移动设备、虚拟机、平板电脑、物联网、可…