打印

Edge-X 设备服务开发(转)

[复制链接]
312|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
keer_zu|  楼主 | 2020-10-16 16:34 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
edge, ic, ce, vi, ev
Edge-X 设备服务开发一,设备驱动(device driver) 核心接口protocoldriver.go
/ ProtocolDriver is a low-level device-specific interface used by
// by other components of an EdgeX Device Service to interact with
// a specific class of devices.
type ProtocolDriver interface {
    // Initialize performs protocol-specific initialization for the device
    // service. The given *AsyncValues channel can be used to push asynchronous
    // events and readings to Core Data.
    Initialize(lc logger.LoggingClient, asyncCh chan<- *AsyncValues) error

    // HandleReadCommands passes a slice of CommandRequest struct each representing
    // a ResourceOperation for a specific device resource.
    HandleReadCommands(deviceName string, protocols map[string]contract.ProtocolProperties, reqs []CommandRequest) ([]*CommandValue, error)

    // HandleWriteCommands passes a slice of CommandRequest struct each representing
    // a ResourceOperation for a specific device resource.
    // Since the commands are actuation commands, params provide parameters for the individual
    // command.
    HandleWriteCommands(deviceName string, protocols map[string]contract.ProtocolProperties, reqs []CommandRequest, params []*CommandValue) error

    // Stop instructs the protocol-specific DS code to shutdown gracefully, or
    // if the force parameter is 'true', immediately. The driver is responsible
    // for closing any in-use channels, including the channel used to send async
    // readings (if supported).
    Stop(force bool) error

    // AddDevice is a callback function that is invoked
    // when a new Device associated with this Device Service is added
    AddDevice(deviceName string, protocols map[string]contract.ProtocolProperties, adminState contract.AdminState) error

    // UpdateDevice is a callback function that is invoked
    // when a Device associated with this Device Service is updated
    UpdateDevice(deviceName string, protocols map[string]contract.ProtocolProperties, adminState contract.AdminState) error

    // RemoveDevice is a callback function that is invoked
    // when a Device associated with this Device Service is removed
    RemoveDevice(deviceName string, protocols map[string]contract.ProtocolProperties) error
}

1、初始化函数:// AsyncValues : 异步通道,用来做异步事件发送
Initialize(lc logger.LoggingClient, asyncCh chan<- *AsyncValues) error

2、写函数
HandleWriteCommands(deviceName string, protocols map[string]contract.ProtocolProperties, reqs []CommandRequest, params []*CommandValue) error




入参:



使用特权

评论回复

相关帖子

沙发
keer_zu|  楼主 | 2020-10-16 16:39 | 只看该作者
在另外一个工程:github.com/edgexfoundry/go-mod-core-contracts/models/device.go





3、读函数
// HandleReadCommands passes a slice of CommandRequest struct each representing
    // a ResourceOperation for a specific device resource.
    HandleReadCommands(deviceName string, protocols map[string]contract.ProtocolProperties, reqs []CommandRequest) ([]*CommandValue, error)

4、停止函数
// Stop instructs the protocol-specific DS code to shutdown gracefully, or
    // if the force parameter is 'true', immediately. The driver is responsible
    // for closing any in-use channels, including the channel used to send async
    // readings (if supported).
    Stop(force bool) error

5、添加设备回调函数
    // AddDevice is a callback function that is invoked
    // when a new Device associated with this Device Service is added
    AddDevice(deviceName string, protocols map[string]contract.ProtocolProperties, adminState contract.AdminState) error

6、更新设备回调函数
// UpdateDevice is a callback function that is invoked
    // when a Device associated with this Device Service is updated
    UpdateDevice(deviceName string, protocols map[string]contract.ProtocolProperties, adminState contract.AdminState) error


7、移除设备回调函数
// RemoveDevice is a callback function that is invoked
    // when a Device associated with this Device Service is removed
    RemoveDevice(deviceName string, protocols map[string]contract.ProtocolProperties) error












使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:qq群:49734243 Email:zukeqiang@gmail.com

1313

主题

12256

帖子

53

粉丝