Documentation ¶
Overview ¶
This package defines interfaces and structs used to build an EdgeX Foundry Device Service. The interfaces provide an asbstraction layer for the device or protocol specific logic of a Device Service, and the structs represents request and response data format used by the protocol driver.
Index ¶
- Constants
- type AsyncValues
- type AutoEventManager
- type CommandRequest
- type CommandValue
- func (cv *CommandValue) BinaryValue() ([]byte, errors.EdgeX)
- func (cv *CommandValue) BoolArrayValue() ([]bool, errors.EdgeX)
- func (cv *CommandValue) BoolValue() (bool, errors.EdgeX)
- func (cv *CommandValue) Float32ArrayValue() ([]float32, errors.EdgeX)
- func (cv *CommandValue) Float32Value() (float32, errors.EdgeX)
- func (cv *CommandValue) Float64ArrayValue() ([]float64, errors.EdgeX)
- func (cv *CommandValue) Float64Value() (float64, errors.EdgeX)
- func (cv *CommandValue) Int16ArrayValue() ([]int16, errors.EdgeX)
- func (cv *CommandValue) Int16Value() (int16, errors.EdgeX)
- func (cv *CommandValue) Int32ArrayValue() ([]int32, errors.EdgeX)
- func (cv *CommandValue) Int32Value() (int32, errors.EdgeX)
- func (cv *CommandValue) Int64ArrayValue() ([]int64, errors.EdgeX)
- func (cv *CommandValue) Int64Value() (int64, errors.EdgeX)
- func (cv *CommandValue) Int8ArrayValue() ([]int8, errors.EdgeX)
- func (cv *CommandValue) Int8Value() (int8, errors.EdgeX)
- func (cv *CommandValue) String() string
- func (cv *CommandValue) StringValue() (string, errors.EdgeX)
- func (cv *CommandValue) Uint16ArrayValue() ([]uint16, errors.EdgeX)
- func (cv *CommandValue) Uint16Value() (uint16, errors.EdgeX)
- func (cv *CommandValue) Uint32ArrayValue() ([]uint32, errors.EdgeX)
- func (cv *CommandValue) Uint32Value() (uint32, errors.EdgeX)
- func (cv *CommandValue) Uint64ArrayValue() ([]uint64, errors.EdgeX)
- func (cv *CommandValue) Uint64Value() (uint64, errors.EdgeX)
- func (cv *CommandValue) Uint8ArrayValue() ([]uint8, errors.EdgeX)
- func (cv *CommandValue) Uint8Value() (uint8, errors.EdgeX)
- func (cv *CommandValue) ValueToString() string
- type DiscoveredDevice
- type Event
- type ProtocolDiscovery
- type ProtocolDriver
Constants ¶
const ( // Policy limits should be located in global config namespace // Currently assigning 16MB (binary), 16 * 2^20 bytes MaxBinaryBytes = 16777216 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AsyncValues ¶
type AsyncValues struct { DeviceName string SourceName string CommandValues []*CommandValue }
AsyncValues is the struct for sending Device readings asynchronously via ProtocolDrivers
type AutoEventManager ¶
type AutoEventManager interface { // StartAutoEvents starts all the AutoEvents of the device service StartAutoEvents() // StopAutoEvents stops all the AutoEvents of the device service StopAutoEvents() // RestartForDevice restarts all the AutoEvents of the specific device RestartForDevice(name string) // StopForDevice stops all the AutoEvents of the specific device StopForDevice(name string) }
type CommandRequest ¶
type CommandRequest struct { // DeviceResourceName is the name of Device Resource for this command DeviceResourceName string // Attributes is a key/value map to represent the attributes of the Device Resource Attributes map[string]string // Type is the data type of the Device Resource Type string }
CommandRequest is the struct for requesting a command to ProtocolDrivers
type CommandValue ¶
type CommandValue struct { // DeviceResourceName is the name of Device Resource for this command DeviceResourceName string // Type indicates what type of value was returned from the ProtocolDriver instance in // response to HandleCommand being called to handle a single ResourceOperation. Type string // Value holds value returned by a ProtocolDriver instance. // The value can be converted to its native type by referring to ValueType. Value interface{} }
CommandValue is the struct to represent the reading value of a Get command coming from ProtocolDrivers or the parameter of a Put command sending to ProtocolDrivers.
func NewCommandValue ¶
func NewCommandValue(deviceResourceName string, valueType string, value interface{}) (*CommandValue, errors.EdgeX)
NewCommandValue create a CommandValue according to the valueType supplied.
func (*CommandValue) BinaryValue ¶
func (cv *CommandValue) BinaryValue() ([]byte, errors.EdgeX)
BinaryValue returns the value in []byte data type, and returns error if the Type is not Binary.
func (*CommandValue) BoolArrayValue ¶
func (cv *CommandValue) BoolArrayValue() ([]bool, errors.EdgeX)
BoolArrayValue returns the value in an array of bool type, and returns error if the Type is not BoolArray.
func (*CommandValue) BoolValue ¶
func (cv *CommandValue) BoolValue() (bool, errors.EdgeX)
BoolValue returns the value in bool data type, and returns error if the Type is not Bool.
func (*CommandValue) Float32ArrayValue ¶
func (cv *CommandValue) Float32ArrayValue() ([]float32, errors.EdgeX)
Float32ArrayValue returns the value in an array of float32 type, and returns error if the Type is not Float32Array.
func (*CommandValue) Float32Value ¶
func (cv *CommandValue) Float32Value() (float32, errors.EdgeX)
Float32Value returns the value in float32 data type, and returns error if the Type is not Float32.
func (*CommandValue) Float64ArrayValue ¶
func (cv *CommandValue) Float64ArrayValue() ([]float64, errors.EdgeX)
Float64ArrayValue returns the value in an array of float64 type, and returns error if the Type is not Float64Array.
func (*CommandValue) Float64Value ¶
func (cv *CommandValue) Float64Value() (float64, errors.EdgeX)
Float64Value returns the value in float64 data type, and returns error if the Type is not Float64.
func (*CommandValue) Int16ArrayValue ¶
func (cv *CommandValue) Int16ArrayValue() ([]int16, errors.EdgeX)
Int16ArrayValue returns the value in an array of int16 type, and returns error if the Type is not Int16Array.
func (*CommandValue) Int16Value ¶
func (cv *CommandValue) Int16Value() (int16, errors.EdgeX)
Int16Value returns the value in int16 data type, and returns error if the Type is not Int16.
func (*CommandValue) Int32ArrayValue ¶
func (cv *CommandValue) Int32ArrayValue() ([]int32, errors.EdgeX)
Int32ArrayValue returns the value in an array of int32 type, and returns error if the Type is not Int32Array.
func (*CommandValue) Int32Value ¶
func (cv *CommandValue) Int32Value() (int32, errors.EdgeX)
Int32Value returns the value in int32 data type, and returns error if the Type is not Int32.
func (*CommandValue) Int64ArrayValue ¶
func (cv *CommandValue) Int64ArrayValue() ([]int64, errors.EdgeX)
Int64ArrayValue returns the value in an array of int64 type, and returns error if the Type is not Int64Array.
func (*CommandValue) Int64Value ¶
func (cv *CommandValue) Int64Value() (int64, errors.EdgeX)
Int64Value returns the value in int64 data type, and returns error if the Type is not Int64.
func (*CommandValue) Int8ArrayValue ¶
func (cv *CommandValue) Int8ArrayValue() ([]int8, errors.EdgeX)
Int8ArrayValue returns the value in an array of int8 type, and returns error if the Type is not Int8Array.
func (*CommandValue) Int8Value ¶
func (cv *CommandValue) Int8Value() (int8, errors.EdgeX)
Int8Value returns the value in int8 data type, and returns error if the Type is not Int8.
func (*CommandValue) String ¶
func (cv *CommandValue) String() string
String returns a string representation of a CommandValue instance.
func (*CommandValue) StringValue ¶
func (cv *CommandValue) StringValue() (string, errors.EdgeX)
StringValue returns the value in string data type, and returns error if the Type is not String.
func (*CommandValue) Uint16ArrayValue ¶
func (cv *CommandValue) Uint16ArrayValue() ([]uint16, errors.EdgeX)
Uint16ArrayValue returns the value in an array of uint16 type, and returns error if the Type is not Uint16Array.
func (*CommandValue) Uint16Value ¶
func (cv *CommandValue) Uint16Value() (uint16, errors.EdgeX)
Uint16Value returns the value in uint16 data type, and returns error if the Type is not Uint16.
func (*CommandValue) Uint32ArrayValue ¶
func (cv *CommandValue) Uint32ArrayValue() ([]uint32, errors.EdgeX)
Uint32ArrayValue returns the value in an array of uint32 type, and returns error if the Type is not Uint32Array.
func (*CommandValue) Uint32Value ¶
func (cv *CommandValue) Uint32Value() (uint32, errors.EdgeX)
Uint32Value returns the value in uint32 data type, and returns error if the Type is not Uint32.
func (*CommandValue) Uint64ArrayValue ¶
func (cv *CommandValue) Uint64ArrayValue() ([]uint64, errors.EdgeX)
Uint64ArrayValue returns the value in an array of uint64 type, and returns error if the Type is not Uint64Array.
func (*CommandValue) Uint64Value ¶
func (cv *CommandValue) Uint64Value() (uint64, errors.EdgeX)
Uint64Value returns the value in uint64 data type, and returns error if the Type is not Uint64.
func (*CommandValue) Uint8ArrayValue ¶
func (cv *CommandValue) Uint8ArrayValue() ([]uint8, errors.EdgeX)
Uint8ArrayValue returns the value in an array of uint8 type, and returns error if the Type is not Uint8Array.
func (*CommandValue) Uint8Value ¶
func (cv *CommandValue) Uint8Value() (uint8, errors.EdgeX)
Uint8Value returns the value in uint8 data type, and returns error if the Type is not Uint8.
func (*CommandValue) ValueToString ¶
func (cv *CommandValue) ValueToString() string
ValueToString returns the string format of the value.
type DiscoveredDevice ¶
type DiscoveredDevice struct { Name string Protocols map[string]models.ProtocolProperties Description string Labels []string }
DiscoveredDevice defines the required information for a found device.
type Event ¶
Event is a wrapper of contract.Event to provide more Binary related operation in Device Service.
func (Event) HasBinaryValue ¶
HasBinaryValue confirms whether an event contains one or more readings populated with a BinaryValue payload.
type ProtocolDiscovery ¶
type ProtocolDiscovery interface { // Discover triggers protocol specific device discovery, asynchronously // writes the results to the channel which is passed to the implementation // via ProtocolDriver.Initialize(). The results may be added to the device service // based on a set of acceptance criteria (i.e. Provision Watchers). Discover() }
ProtocolDiscovery is a low-level device-specific interface implemented by device services that support dynamic device discovery.
type ProtocolDriver ¶
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. The given []DiscoveredDevice channel is used to send // discovered devices that will be filtered and added to Core Metadata asynchronously. Initialize(lc logger.LoggingClient, asyncCh chan<- *AsyncValues, deviceCh chan<- []DiscoveredDevice) error // HandleReadCommands passes a slice of CommandRequest struct each representing // a ResourceOperation for a specific device resource. HandleReadCommands(deviceName string, protocols map[string]models.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]models.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]models.ProtocolProperties, adminState models.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]models.ProtocolProperties, adminState models.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]models.ProtocolProperties) error }
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.