Documentation
¶
Index ¶
- Constants
- func ConcatResourceName(module string, resource string) string
- func IsEvent(req models.CommandRequest) bool
- func IsProperty(req models.CommandRequest) bool
- func IsService(req models.CommandRequest) bool
- func SetResourceCategory(attributes map[string]interface{}, category ResourceCategory) map[string]interface{}
- func SplitResourceName(full string) (module string, resource string)
- type AsyncValues
- type BaseRequest
- type CallRequest
- type Device
- type NativeResult
- type OperatingState
- type ReadRequest
- type ResourceCategory
- type Result
- type SimpleResult
- func (r *SimpleResult) CommandValue(resourceName string, valueType string) (*models.CommandValue, error)
- func (r *SimpleResult) Tags() map[string]string
- func (r *SimpleResult) UnixNano() int64
- func (r *SimpleResult) Value() interface{}
- func (r *SimpleResult) WithCast(cast bool) *SimpleResult
- func (r *SimpleResult) WithTags(tags map[string]string) *SimpleResult
- func (r *SimpleResult) WithTime(origin time.Time) *SimpleResult
- type ValueType
- type WriteRequest
Constants ¶
const ( CategoryKey = "category" DefaultModule = "default" Separator = ":" )
Variables ¶
This section is empty.
Functions ¶
func ConcatResourceName ¶
ConcatResourceName will concat the module and resource defined in vei console to edgex resource name.
func IsEvent ¶
func IsEvent(req models.CommandRequest) bool
IsEvent checks whether the device resource is an event.
func IsProperty ¶
func IsProperty(req models.CommandRequest) bool
IsProperty checks whether the device resource is a property.
func IsService ¶
func IsService(req models.CommandRequest) bool
IsService checks whether the device resource is a service.
func SetResourceCategory ¶
func SetResourceCategory(attributes map[string]interface{}, category ResourceCategory) map[string]interface{}
SetResourceCategory set the resource category into attributes.
func SplitResourceName ¶
SplitResourceName will split the edgex resource name to the module and resource defined in vei console.
Types ¶
type AsyncValues ¶
type AsyncValues struct { DeviceName string SourceName string CommandValues []*models.CommandValue }
AsyncValues is the struct for sending Device readings asynchronously via ProtocolDrivers
func (*AsyncValues) Transform ¶
func (v *AsyncValues) Transform() *models.AsyncValues
type BaseRequest ¶
type BaseRequest interface { // Native returns the native command request. Native() *models.CommandRequest // Module returns the thingmodel module where the resource belongs to. Module() string // Resource returns the identifier of the thingmodel resource. Resource() string // ValueType returns the value type of the thingmodel resource. ValueType() ValueType // Attributes returns the attributes defined for the thingmodel resource. Attributes() map[string]interface{} // SetResult set the handle result of the request. SetResult(result Result) // Result get the handle result of the request. Result() Result // Failed set the error encountered when handling the request. Failed(error error) // Error returns the error encountered when handling the request. Error() error // Skip will skip the request. Skip() // Skipped indicates whether the request is skipped or not. Skipped() bool }
type CallRequest ¶
type CallRequest interface { BaseRequest // Payload returns the payload of the call request. Payload() []byte }
func NewCallRequest ¶
func NewCallRequest(req models.CommandRequest) (CallRequest, error)
type Device ¶
type Device struct { Name string Protocols map[string]models.ProtocolProperties OperatingState OperatingState Message string }
Device contains the necessary information of a device.
func WrapDevice ¶
func WrapDevice(name string, protocols map[string]models.ProtocolProperties) *Device
func (*Device) GetProtocolByName ¶
func (d *Device) GetProtocolByName(name string) (models.ProtocolProperties, bool)
GetProtocolByName returns the protocol specified by name.
func (*Device) SetOperatingState ¶
func (d *Device) SetOperatingState(state OperatingState, message string)
SetOperatingState supports to set the device state customarily.
func (*Device) SetStateDown ¶
func (d *Device) SetStateDown()
SetStateDown set the device state to DOWN.
func (*Device) SetStateReachable ¶
func (d *Device) SetStateReachable()
SetStateReachable set the device state to REACHABLE.
func (*Device) SetStateUnreachable ¶
func (d *Device) SetStateUnreachable()
SetStateUnreachable set the device state to UNREACHABLE.
type NativeResult ¶
type NativeResult struct {
// contains filtered or unexported fields
}
func NewNativeResult ¶
func NewNativeResult(native *models.CommandValue) *NativeResult
func (*NativeResult) CommandValue ¶
func (r *NativeResult) CommandValue(_ string, _ string) (*models.CommandValue, error)
func (*NativeResult) Tags ¶
func (r *NativeResult) Tags() map[string]string
func (*NativeResult) UnixNano ¶
func (r *NativeResult) UnixNano() int64
func (*NativeResult) Value ¶
func (r *NativeResult) Value() interface{}
type OperatingState ¶
type OperatingState string
OperatingState is an indication of the operations of the device.
const ( UP OperatingState = "Up" DOWN OperatingState = "Down" UNKNOWN OperatingState = "Unknown" REACHABLE OperatingState = "Reachable" UNREACHABLE OperatingState = "Unreachable" )
func (OperatingState) String ¶
func (s OperatingState) String() string
type ReadRequest ¶
type ReadRequest interface { BaseRequest }
func NewReadRequest ¶
func NewReadRequest(req models.CommandRequest) ReadRequest
type ResourceCategory ¶
type ResourceCategory string
ResourceCategory indicates the category of device resource
const ( Property ResourceCategory = "property" Service ResourceCategory = "service" Event ResourceCategory = "event" )
func GetResourceCategory ¶
func GetResourceCategory(req models.CommandRequest) ResourceCategory
GetResourceCategory get the category of resource from the request. Property is returned by default for the compatibility.
func (ResourceCategory) String ¶
func (c ResourceCategory) String() string
type Result ¶
type Result interface { // Value returns the value read by driver instance. Value() interface{} // UnixNano returns the unix nano timestamp of the result read by driver instance. UnixNano() int64 // Tags returns the custom information of the result. Tags() map[string]string // CommandValue constructs EdgeX CommandValue based on the content of the result. CommandValue(resourceName string, valueType string) (*models.CommandValue, error) }
Result defines the interface for a result of the Request.
type SimpleResult ¶
type SimpleResult struct {
// contains filtered or unexported fields
}
func NewSimpleResult ¶
func NewSimpleResult(value interface{}) *SimpleResult
func (*SimpleResult) CommandValue ¶
func (r *SimpleResult) CommandValue(resourceName string, valueType string) (*models.CommandValue, error)
func (*SimpleResult) Tags ¶
func (r *SimpleResult) Tags() map[string]string
func (*SimpleResult) UnixNano ¶
func (r *SimpleResult) UnixNano() int64
func (*SimpleResult) Value ¶
func (r *SimpleResult) Value() interface{}
func (*SimpleResult) WithCast ¶ added in v1.1.1
func (r *SimpleResult) WithCast(cast bool) *SimpleResult
func (*SimpleResult) WithTags ¶
func (r *SimpleResult) WithTags(tags map[string]string) *SimpleResult
func (*SimpleResult) WithTime ¶
func (r *SimpleResult) WithTime(origin time.Time) *SimpleResult
type ValueType ¶
type ValueType string
ValueType indicates the type of reading value
const ( Bool ValueType = "Bool" String ValueType = "String" Uint8 ValueType = "Uint8" Uint16 ValueType = "Uint16" Uint32 ValueType = "Uint32" Uint64 ValueType = "Uint64" Int8 ValueType = "Int8" Int16 ValueType = "Int16" Int32 ValueType = "Int32" Int64 ValueType = "Int64" Float32 ValueType = "Float32" Float64 ValueType = "Float64" Binary ValueType = "Binary" BoolArray ValueType = "BoolArray" StringArray ValueType = "StringArray" Uint8Array ValueType = "Uint8Array" Uint16Array ValueType = "Uint16Array" Uint32Array ValueType = "Uint32Array" Uint64Array ValueType = "Uint64Array" Int8Array ValueType = "Int8Array" Int16Array ValueType = "Int16Array" Int32Array ValueType = "Int32Array" Int64Array ValueType = "Int64Array" Float32Array ValueType = "Float32Array" Float64Array ValueType = "Float64Array" Object ValueType = "Object" )
type WriteRequest ¶
type WriteRequest interface { BaseRequest // Param returns the input parameter of the write request. Param() *models.CommandValue }
func NewWriteRequest ¶
func NewWriteRequest(req models.CommandRequest, param *models.CommandValue) WriteRequest