Documentation ¶
Index ¶
- Constants
- func Convert(valueType string, value string) (result interface{}, err error)
- func ConvertToString(value interface{}) (string, error)
- func CreateMessageData(name string, valueType string, value string) (msg []byte, err error)
- func CreateMessageTwinUpdate(name string, valueType string, value string, expectValue string) (msg []byte, err error)
- func DecodeAnyValue(value *anypb.Any) (interface{}, error)
- type BaseMessage
- type DBConfig
- type DBMethodConfig
- type DataMetadata
- type DataMethod
- type DataModel
- type DataValue
- type DeviceData
- type DeviceInstance
- type DeviceMethod
- type DeviceModel
- type DeviceProperty
- type DeviceStatus
- type DeviceTwinDelta
- type DeviceTwinResult
- type DeviceTwinUpdate
- type DeviceUpdate
- type Metadata
- type Method
- type ModelProperty
- type MsgAttr
- type MsgTwin
- type Option
- type Parameter
- type ProtocolConfig
- type PushMethodConfig
- type Twin
- type TwinProperty
- type TwinValue
- type TwinVersion
- type TypeMetadata
- type ValueMetadata
Constants ¶
const ( DeviceStatusOK = "ok" DeviceStatusOnline = "online" DeviceStatusOffline = "offline" DeviceStatusDisCONN = "disconnected" /* Disconnected */ DeviceStatusUnhealthy = "unhealthy" /* Unhealthy status from device */ DeviceStatusUnknown = "unknown" )
Device status definition.
const ( PushMethodHTTP = "http" PushMethodMQTT = "mqtt" PushMethodOTEL = "otel" )
const ( DevInitModeRegister = "register" DevInitModeConfigmap = "configmap" )
const ( SaveFrame = "saveFrame" SaveVideo = "saveVideo" )
const ( TopicTwinUpdateDelta = "$hw/events/device/%s/twin/update/delta" TopicTwinUpdate = "$hw/events/device/%s/twin/update" TopicStateUpdate = "$hw/events/device/%s/state/update" TopicDataUpdate = "$ke/events/device/%s/data/update" )
Joint the topic like topic := fmt.Sprintf(TopicTwinUpdateDelta, deviceID)
const DefaultCollectCycle = time.Second
const DefaultReportCycle = time.Second
const (
ProtocolCustomized = "customized-protocol"
)
Variables ¶
This section is empty.
Functions ¶
func ConvertToString ¶
ConvertToString other types to string
func CreateMessageData ¶
CreateMessageData create data message.
func CreateMessageTwinUpdate ¶
func CreateMessageTwinUpdate(name string, valueType string, value string, expectValue string) (msg []byte, err error)
CreateMessageTwinUpdate create twin update message.
func DecodeAnyValue ¶
DecodeAnyValue Any to interface
Types ¶
type BaseMessage ¶
BaseMessage the base structure of event message.
type DBConfig ¶
type DBConfig struct { Influxdb2ClientConfig json.RawMessage `json:"influxdb2ClientConfig"` Influxdb2DataConfig json.RawMessage `json:"influxdb2DataConfig"` RedisClientConfig json.RawMessage `json:"redisClientConfig"` TDEngineClientConfig json.RawMessage `json:"TDEngineClientConfig"` MySQLClientConfig json.RawMessage `json:"mysqlClientConfig"` }
type DBMethodConfig ¶
type DBMethodConfig struct { DBMethodName string `json:"dbMethodName"` DBConfig DBConfig `json:"dbConfig"` }
DBMethodConfig is structure to store database config
type DataMetadata ¶
DataMetadata data metadata.
type DataMethod ¶ added in v1.19.0
type DataMethod struct {
Methods []Method
}
DataMethod defined standard model for deviceMethod
type DataModel ¶
type DataModel struct { // TODO DataModel is standardized data, need add field DeviceName string PropertyName string Namespace string Value string Type string TimeStamp int64 }
DataModel defined standard data model for transferring data between interfaces
func NewDataModel ¶
func (*DataModel) SetTimeStamp ¶
func (dm *DataModel) SetTimeStamp()
type DataValue ¶
type DataValue struct { Value string `json:"value"` Metadata DataMetadata `json:"metadata"` }
DataValue data value.
type DeviceData ¶
type DeviceData struct { BaseMessage Data map[string]*DataValue `json:"data"` }
DeviceData device data structure.
type DeviceInstance ¶
type DeviceInstance struct { ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` Namespace string `json:"namespace,omitempty"` ProtocolName string `json:"protocol,omitempty"` PProtocol ProtocolConfig Model string `json:"model,omitempty"` Twins []Twin `json:"twins,omitempty"` Properties []DeviceProperty `json:"properties,omitempty"` Methods []DeviceMethod `json:"methods,omitempty"` Status DeviceStatus `json:"status,omitempty"` }
DeviceInstance is structure to store detailed information about the device in the mapper.
type DeviceMethod ¶ added in v1.19.0
type DeviceMethod struct { // Required: The device method name to be accessed. It must be unique. Name string `json:"name,omitempty"` // Define the description of device method. // +optional Description string `json:"description,omitempty"` // PropertyNames are list of device properties that device methods can control. // Required: A device method can control multiple device properties. PropertyNames []string `json:"propertyNames,omitempty"` }
DeviceMethod is structure to store method in device.
type DeviceModel ¶
type DeviceModel struct { ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` Namespace string `json:"namespace,omitempty"` Description string `json:"description,omitempty"` Properties []ModelProperty `json:"properties,omitempty"` }
DeviceModel is structure to store detailed information about the devicemodel in the mapper.
type DeviceProperty ¶
type DeviceProperty struct { Name string `json:"name,omitempty"` PropertyName string `json:"propertyName,omitempty"` ModelName string `json:"modelName,omitempty"` Protocol string `json:"protocol,omitempty"` Visitors json.RawMessage `json:"visitorConfig"` // whether be reported to the cloud ReportToCloud bool `json:"reportToCloud,omitempty"` CollectCycle int64 `json:"collectCycle"` ReportCycle int64 `json:"reportCycle,omitempty"` PushMethod PushMethodConfig `json:"pushMethod,omitempty"` PProperty ModelProperty }
DeviceProperty is structure to store propertyVisitor in device.
type DeviceStatus ¶ added in v1.19.0
type DeviceStatus struct { // whether be reported to the cloud ReportToCloud bool `json:"reportToCloud,omitempty"` ReportCycle int64 `json:"reportCycle,omitempty"` }
DeviceStatus is structure to store parameters for device status reporting.
type DeviceTwinDelta ¶
type DeviceTwinDelta struct { BaseMessage Twin map[string]*MsgTwin `json:"twin"` Delta map[string]string `json:"delta"` }
DeviceTwinDelta twin delta.
type DeviceTwinResult ¶
type DeviceTwinResult struct { BaseMessage Twin map[string]*MsgTwin `json:"twin"` }
DeviceTwinResult device get result.
type DeviceTwinUpdate ¶
type DeviceTwinUpdate struct { BaseMessage Twin map[string]*MsgTwin `json:"twin"` }
DeviceTwinUpdate the structure of device twin update.
type DeviceUpdate ¶
type DeviceUpdate struct { BaseMessage State string `json:"state,omitempty"` Attributes map[string]*MsgAttr `json:"attributes"` }
DeviceUpdate device update.
type Metadata ¶
type Metadata struct { Timestamp string `json:"timestamp,omitempty"` Type string `json:"type,omitempty"` }
Metadata is the metadata for data.
type ModelProperty ¶
type ModelProperty struct { Name string `json:"name,omitempty"` DataType string `json:"dataType,omitempty"` Description string `json:"description,omitempty"` AccessMode string `json:"accessMode,omitempty"` Minimum string `json:"minimum,omitempty"` Maximum string `json:"maximum,omitempty"` Unit string `json:"unit,omitempty"` }
ModelProperty is structure to store deviceModel property.
type MsgAttr ¶
type MsgAttr struct { Value string `json:"value"` Optional *bool `json:"optional,omitempty"` Metadata *TypeMetadata `json:"metadata,omitempty"` }
MsgAttr the struct of device attr
type MsgTwin ¶
type MsgTwin struct { Expected *TwinValue `json:"expected,omitempty"` Actual *TwinValue `json:"actual,omitempty"` Optional *bool `json:"optional,omitempty"` Metadata *TypeMetadata `json:"metadata,omitempty"` ExpectedVersion *TwinVersion `json:"expected_version,omitempty"` ActualVersion *TwinVersion `json:"actual_version,omitempty"` }
MsgTwin the structure of device twin.
type ProtocolConfig ¶
type ProtocolConfig struct { // Unique protocol name // Required. ProtocolName string `json:"protocolName,omitempty"` // Any config data // +optional // +kubebuilder:validation:XPreserveUnknownFields ConfigData json.RawMessage `json:"configData,omitempty"` }
ProtocolConfig is structure to store protocol information in device.
type PushMethodConfig ¶
type PushMethodConfig struct { MethodName string `json:"MethodName"` MethodConfig json.RawMessage `json:"MethodConfig"` DBMethod DBMethodConfig `json:"dbMethod,omitempty"` }
PushMethodConfig is structure to store push config
type Twin ¶
type Twin struct { PropertyName string `json:"propertyName,omitempty"` Property *DeviceProperty ObservedDesired TwinProperty `json:"observedDesired,omitempty"` Reported TwinProperty `json:"reported,omitempty"` }
Twin is the set/get pair to one register.
type TwinProperty ¶
type TwinValue ¶
type TwinValue struct { Value *string `json:"value,omitempty"` Metadata ValueMetadata `json:"metadata,omitempty"` }
TwinValue the structure of twin value.
type TwinVersion ¶
TwinVersion twin version.
type TypeMetadata ¶
type TypeMetadata struct {
Type string `json:"type,omitempty"`
}
TypeMetadata the meta of value type.
type ValueMetadata ¶
type ValueMetadata struct {
Timestamp string `json:"timestamp,omitempty"`
}
ValueMetadata the meta of value.