utils

package
v1.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParserIdentity added in v1.9.1

func ParserIdentity(identity string) (isChildDevice bool, pIdentity string, instanceId int)

ParserIdentity 解析设备的identity 把identity用-切成切片,且判断第一个元素是否childDevice (例子:childDevice-abc-4) 如果是childDevice,则是子设备,第二个元素为父设备的identity,第三个元素为在父子设备中的instanceId

func ToSnakeCase

func ToSnakeCase(str string) string

Types

type Attribute

type Attribute struct {
	ID         int
	Model      interface{}
	TypeModel  interface{}
	Name       string
	Type       string
	Tag        string
	Require    bool
	Active     bool
	Aid        uint64 // homekit aid
	Iid        uint64 // homekit iid
	Permission uint   // 控制状态: 0可控制可读(灯光控制属性),1不可控制但是可读(传感器状态),2不可控制不可读(其他属性)
}

Attribute represents a column of database

func DeepAttrs

func DeepAttrs(dest interface{}, incrAttrID int) (attrs []*Attribute)

DeepAttrs 递归获取所有属性

type Device

type Device struct {
	Model         interface{}
	Instances     []*Instance
	InstanceNames []string
	InstanceMap   map[int]*Instance
}

Device represents a table of database

func Parse

func Parse(dest interface{}) *Device

Parse a struct to a Device instance

func (*Device) GetAttribute

func (d *Device) GetAttribute(instanceID int, attr string) *Attribute

GetAttribute return Attribute by id

type DeviceName

type DeviceName interface {
	DeviceName() string
}

type Instance

type Instance struct {
	ID             int
	Model          interface{}
	Name           string
	Type           string
	Tag            string
	Attributes     []*Attribute
	AttributeNames []string
	AttributeMap   map[string]*Attribute
}

func ParseInstance

func ParseInstance(dest interface{}) *Instance

ParseInstance a instance to a Instance instance

func (*Instance) GetAttribute

func (instance *Instance) GetAttribute(name string) *Attribute

GetAttribute return instance by name

type InstanceName

type InstanceName interface {
	InstanceName() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL