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

https://iothub.org.cn/docs/edgex/
https://iothub.org.cn/docs/edgex/device-service/
  • 20
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

IoTHub - 物联网开源技术社区

支持开源技术! 传播开源文化!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值