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 NewBinaryValue(DeviceResourceName string, origin int64, value []byte) (cv *CommandValue, err error)
- func NewBoolArrayValue(DeviceResourceName string, origin int64, value []bool) (cv *CommandValue, err error)
- func NewBoolValue(DeviceResourceName string, origin int64, value bool) (cv *CommandValue, err error)
- func NewCommandValue(DeviceResourceName string, origin int64, value interface{}, t string) (cv *CommandValue, err error)
- func NewFloat32ArrayValue(DeviceResourceName string, origin int64, value []float32) (cv *CommandValue, err error)
- func NewFloat32Value(DeviceResourceName string, origin int64, value float32) (cv *CommandValue, err error)
- func NewFloat64ArrayValue(DeviceResourceName string, origin int64, value []float64) (cv *CommandValue, err error)
- func NewFloat64Value(DeviceResourceName string, origin int64, value float64) (cv *CommandValue, err error)
- func NewInt16ArrayValue(DeviceResourceName string, origin int64, value []int16) (cv *CommandValue, err error)
- func NewInt16Value(DeviceResourceName string, origin int64, value int16) (cv *CommandValue, err error)
- func NewInt32ArrayValue(DeviceResourceName string, origin int64, value []int32) (cv *CommandValue, err error)
- func NewInt32Value(DeviceResourceName string, origin int64, value int32) (cv *CommandValue, err error)
- func NewInt64ArrayValue(DeviceResourceName string, origin int64, value []int64) (cv *CommandValue, err error)
- func NewInt64Value(DeviceResourceName string, origin int64, value int64) (cv *CommandValue, err error)
- func NewInt8ArrayValue(DeviceResourceName string, origin int64, value []int8) (cv *CommandValue, err error)
- func NewInt8Value(DeviceResourceName string, origin int64, value int8) (cv *CommandValue, err error)
- func NewStringValue(DeviceResourceName string, origin int64, value string) (cv *CommandValue)
- func NewUint16ArrayValue(DeviceResourceName string, origin int64, value []uint16) (cv *CommandValue, err error)
- func NewUint16Value(DeviceResourceName string, origin int64, value uint16) (cv *CommandValue, err error)
- func NewUint32ArrayValue(DeviceResourceName string, origin int64, value []uint32) (cv *CommandValue, err error)
- func NewUint32Value(DeviceResourceName string, origin int64, value uint32) (cv *CommandValue, err error)
- func NewUint64ArrayValue(DeviceResourceName string, origin int64, value []uint64) (cv *CommandValue, err error)
- func NewUint64Value(DeviceResourceName string, origin int64, value uint64) (cv *CommandValue, err error)
- func NewUint8ArrayValue(DeviceResourceName string, origin int64, value []uint8) (cv *CommandValue, err error)
- func NewUint8Value(DeviceResourceName string, origin int64, value uint8) (cv *CommandValue, err error)
- func (cv *CommandValue) BinaryValue() ([]byte, error)
- func (cv *CommandValue) BoolArrayValue() ([]bool, error)
- func (cv *CommandValue) BoolValue() (bool, error)
- func (cv *CommandValue) Float32ArrayValue() ([]float32, error)
- func (cv *CommandValue) Float32Value() (float32, error)
- func (cv *CommandValue) Float64ArrayValue() ([]float64, error)
- func (cv *CommandValue) Float64Value() (float64, error)
- func (cv *CommandValue) Int16ArrayValue() ([]int16, error)
- func (cv *CommandValue) Int16Value() (int16, error)
- func (cv *CommandValue) Int32ArrayValue() ([]int32, error)
- func (cv *CommandValue) Int32Value() (int32, error)
- func (cv *CommandValue) Int64ArrayValue() ([]int64, error)
- func (cv *CommandValue) Int64Value() (int64, error)
- func (cv *CommandValue) Int8ArrayValue() ([]int8, error)
- func (cv *CommandValue) Int8Value() (int8, error)
- func (cv *CommandValue) String() (str string)
- func (cv *CommandValue) StringValue() (string, error)
- func (cv *CommandValue) Uint16ArrayValue() ([]uint16, error)
- func (cv *CommandValue) Uint16Value() (uint16, error)
- func (cv *CommandValue) Uint32ArrayValue() ([]uint32, error)
- func (cv *CommandValue) Uint32Value() (uint32, error)
- func (cv *CommandValue) Uint64ArrayValue() ([]uint64, error)
- func (cv *CommandValue) Uint64Value() (uint64, error)
- func (cv *CommandValue) Uint8ArrayValue() ([]uint8, error)
- func (cv *CommandValue) Uint8Value() (uint8, error)
- func (cv *CommandValue) ValueToString(encoding ...string) (str 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 // DefaultFoloatEncoding indicates the representation of floating value of reading. // It would be configurable in system level in the future DefaultFloatEncoding = models.Base64Encoding )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AsyncValues ¶
type AsyncValues struct { DeviceName 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 // Origin is an int64 value which indicates the time the reading // contained in the CommandValue was read by the ProtocolDriver // instance. Origin int64 // Type is a ValueType value which indicates what type of // value was returned from the ProtocolDriver instance in // response to HandleCommand being called to handle a single // ResourceOperation. Type string // NumericValue is a byte slice with a maximum capacity of // 64 bytes, used to hold a numeric value returned by a // ProtocolDriver instance. The value can be converted to // its native type by referring to the the value of ResType. NumericValue []byte // BinValue is a binary value with a maximum capacity of 16 MB, // used to hold binary values returned by a ProtocolDriver instance. BinValue []byte // contains filtered or unexported fields }
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 NewBinaryValue ¶
func NewBinaryValue(DeviceResourceName string, origin int64, value []byte) (cv *CommandValue, err error)
NewBinaryValue creates a CommandValue with binary payload and enforces the memory limit for event readings.
func NewBoolArrayValue ¶
func NewBoolArrayValue(DeviceResourceName string, origin int64, value []bool) (cv *CommandValue, err error)
NewBoolArrayValue creates a CommandValue of Type BoolArray with the given value.
func NewBoolValue ¶
func NewBoolValue(DeviceResourceName string, origin int64, value bool) (cv *CommandValue, err error)
NewBoolValue creates a CommandValue of Type Bool with the given value.
func NewCommandValue ¶
func NewCommandValue(DeviceResourceName string, origin int64, value interface{}, t string) (cv *CommandValue, err error)
NewCommandValue create a CommandValue according to the Type supplied.
func NewFloat32ArrayValue ¶
func NewFloat32ArrayValue(DeviceResourceName string, origin int64, value []float32) (cv *CommandValue, err error)
NewFloat32ArrayValue creates a CommandValue of Type Float32Array with the given value.
func NewFloat32Value ¶
func NewFloat32Value(DeviceResourceName string, origin int64, value float32) (cv *CommandValue, err error)
NewFloat32Value creates a CommandValue of Type Float32 with the given value.
func NewFloat64ArrayValue ¶
func NewFloat64ArrayValue(DeviceResourceName string, origin int64, value []float64) (cv *CommandValue, err error)
NewFloat64ArrayValue creates a CommandValue of Type Float64Array with the given value.
func NewFloat64Value ¶
func NewFloat64Value(DeviceResourceName string, origin int64, value float64) (cv *CommandValue, err error)
NewFloat64Value creates a CommandValue of Type Float64 with the given value.
func NewInt16ArrayValue ¶
func NewInt16ArrayValue(DeviceResourceName string, origin int64, value []int16) (cv *CommandValue, err error)
NewInt16ArrayValue creates a CommandValue of Type Int16Array with the given value.
func NewInt16Value ¶
func NewInt16Value(DeviceResourceName string, origin int64, value int16) (cv *CommandValue, err error)
NewInt16Value creates a CommandValue of Type Int16 with the given value.
func NewInt32ArrayValue ¶
func NewInt32ArrayValue(DeviceResourceName string, origin int64, value []int32) (cv *CommandValue, err error)
NewInt32ArrayValue creates a CommandValue of Type Int32Array with the given value.
func NewInt32Value ¶
func NewInt32Value(DeviceResourceName string, origin int64, value int32) (cv *CommandValue, err error)
NewInt32Value creates a CommandValue of Type Int32 with the given value.
func NewInt64ArrayValue ¶
func NewInt64ArrayValue(DeviceResourceName string, origin int64, value []int64) (cv *CommandValue, err error)
NewInt64ArrayValue creates a CommandValue of Type Int64Array with the given value.
func NewInt64Value ¶
func NewInt64Value(DeviceResourceName string, origin int64, value int64) (cv *CommandValue, err error)
NewInt64Value creates a CommandValue of Type Int64 with the given value.
func NewInt8ArrayValue ¶
func NewInt8ArrayValue(DeviceResourceName string, origin int64, value []int8) (cv *CommandValue, err error)
NewInt8ArrayValue creates a CommandValue of Type Int8Array with the given value.
func NewInt8Value ¶
func NewInt8Value(DeviceResourceName string, origin int64, value int8) (cv *CommandValue, err error)
NewInt8Value creates a CommandValue of Type Int8 with the given value.
func NewStringValue ¶
func NewStringValue(DeviceResourceName string, origin int64, value string) (cv *CommandValue)
NewStringValue creates a CommandValue of Type string with the given value.
func NewUint16ArrayValue ¶
func NewUint16ArrayValue(DeviceResourceName string, origin int64, value []uint16) (cv *CommandValue, err error)
NewUint16ArrayValue creates a CommandValue of Type Uint16Array with the given value.
func NewUint16Value ¶
func NewUint16Value(DeviceResourceName string, origin int64, value uint16) (cv *CommandValue, err error)
NewUint16Value creates a CommandValue of Type Uint16 with the given value.
func NewUint32ArrayValue ¶
func NewUint32ArrayValue(DeviceResourceName string, origin int64, value []uint32) (cv *CommandValue, err error)
NewUint32ArrayValue creates a CommandValue of Type Uint32Array with the given value.
func NewUint32Value ¶
func NewUint32Value(DeviceResourceName string, origin int64, value uint32) (cv *CommandValue, err error)
NewUint32Value creates a CommandValue of Type Uint32 with the given value.
func NewUint64ArrayValue ¶
func NewUint64ArrayValue(DeviceResourceName string, origin int64, value []uint64) (cv *CommandValue, err error)
NewUint64ArrayValue creates a CommandValue of Type Uint64Array with the given value.
func NewUint64Value ¶
func NewUint64Value(DeviceResourceName string, origin int64, value uint64) (cv *CommandValue, err error)
NewUint64Value creates a CommandValue of Type Uint64 with the given value.
func NewUint8ArrayValue ¶
func NewUint8ArrayValue(DeviceResourceName string, origin int64, value []uint8) (cv *CommandValue, err error)
NewUint8ArrayValue creates a CommandValue of Type Uint8Array with the given value.
func NewUint8Value ¶
func NewUint8Value(DeviceResourceName string, origin int64, value uint8) (cv *CommandValue, err error)
NewUint8Value creates a CommandValue of Type Uint8 with the given value.
func (*CommandValue) BinaryValue ¶
func (cv *CommandValue) BinaryValue() ([]byte, error)
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, error)
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, error)
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, error)
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, error)
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, error)
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, error)
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, error)
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, error)
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, error)
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, error)
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, error)
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, error)
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, error)
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, error)
Int8Value returns the value in int8 data type, and returns error if the Type is not Int8.
func (*CommandValue) String ¶
func (cv *CommandValue) String() (str string)
String returns a string representation of a CommandValue instance.
func (*CommandValue) StringValue ¶
func (cv *CommandValue) StringValue() (string, error)
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, error)
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, error)
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, error)
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, error)
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, error)
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, error)
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, error)
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, error)
Uint8Value returns the value in uint8 data type, and returns error if the Type is not Uint8.
func (*CommandValue) ValueToString ¶
func (cv *CommandValue) ValueToString(encoding ...string) (str string)
ValueToString returns the string format of the value. In EdgeX, float value has two kinds of representation, Base64, and eNotation. Users can specify the floatEncoding in the properties value of the device profile, like floatEncoding: "Base64" or floatEncoding: "eNotation".
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.