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
入参:
|