golang

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const CatsStructTemplate = `` /* 156-byte string literal not displayed */

CatsStructTemplate is template for a categories struct.

View Source
const CharStructTemplate = `` /* 785-byte string literal not displayed */

CharStructTemplate is template for a characteristic struct.

View Source
const ServiceStructTemplate = `` /* 553-byte string literal not displayed */

ServiceStructTemplate is template for a service struct.

Variables

View Source
var (
	ServiceLocalDir        = filepath.Join(libPath, "service")
	CharacteristicLocalDir = filepath.Join(libPath, "characteristic")
	ServiceDir             = "service"
	CharacteristicDir      = "characteristic"
)

Functions

func CategoriesGoCode

func CategoriesGoCode(cats []*gen.CategoryMetadata) ([]byte, error)

CategoriesGoCode returns the go code for a categories file

func CharacteristicFileName

func CharacteristicFileName(char *gen.CharacteristicMetadata) string

FileName returns the filename for a characteristic

func CharacteristicGoCode

func CharacteristicGoCode(char *gen.CharacteristicMetadata) ([]byte, error)

CharacteristicGoCode returns the o code for a characteristic file

func CharacteristicLocalFilePath

func CharacteristicLocalFilePath(char *gen.CharacteristicMetadata) string

CharacteristicLocalFilePath returns the filepath to a characteristic

func CharacteristicRelativeFilePath

func CharacteristicRelativeFilePath(char *gen.CharacteristicMetadata) string

CharacteristicRelativeFilePath returns the relative filepath to a characteristic

func ServiceFileName

func ServiceFileName(svc *gen.ServiceMetadata) string

FileName returns the filename for a characteristic

func ServiceGoCode

func ServiceGoCode(svc *gen.ServiceMetadata, chars []*gen.CharacteristicMetadata) ([]byte, error)

ServiceGoCode returns the o code for a characteristic file

func ServiceLocalFilePath

func ServiceLocalFilePath(sv *gen.ServiceMetadata) string

ServiceLocalFilePath returns the filepath to a service

func ServiceRelativeFilePath

func ServiceRelativeFilePath(sv *gen.ServiceMetadata) string

ServiceRelativeFilePath returns the relative filepath to a service

Types

type ByValue

type ByValue []ConstDecl

ByValue defines a type for sorting const declarations by value by Impelementing the sort.Interface interface

func (ByValue) Len

func (v ByValue) Len() int

func (ByValue) Less

func (v ByValue) Less(i, j int) bool

func (ByValue) Swap

func (v ByValue) Swap(i, j int)

type Categories

type Categories struct {
	Consts []*Category
}

func NewCategories

func NewCategories(cats []*gen.CategoryMetadata) *Categories

type Category

type Category struct {
	Identifier string
	TypeName   string
	Value      int
}

func NewCategory

func NewCategory(cat *gen.CategoryMetadata) *Category

type Characteristic

type Characteristic struct {
	Name               string      // Name of the characteristic
	EmbeddedStructName string      // Name of the embedded struct (e.g. Int)
	FormatTypeName     string      // Name of the format type (e.g. FormatInt32)
	StructName         string      // Name of the struct (e.g. Brightness)
	FileName           string      // Name of the file (e.g. brightness.go)
	LocalFilePath      string      // Path to the file (e.g. ~/User/Go/src/github.com/MrEhbr/hc/characteristic/brightness.go)
	RelFilePath        string      // Relative path to the file from the project root (e.g. characteristic/brightness.go)
	PermsDecl          string      // Permissions declaration (e.g. []string{PermRead, PermWrite, PermEvents})
	TypeName           string      // Name of type e.g. TypeBrightness
	TypeValue          string      // Value of the type e.g. 00000008-0000-1000-8000-0026BB765291
	DefaultValue       interface{} // e.g. 0
	MinValue           interface{} // e.g. 0
	MaxValue           interface{} // e.g. 100
	StepValue          interface{} // e.g. 1
	UnitName           string      // Name of the unit e.g. UnitPercentage

	Consts []ConstDecl
}

Characteristic holds characteristic template data

func NewCharacteristic

func NewCharacteristic(char *gen.CharacteristicMetadata) *Characteristic

func (Characteristic) HasConsts

func (d Characteristic) HasConsts() bool

HasConsts returns true if characteristic has const declarations

func (Characteristic) HasDefaultValue

func (d Characteristic) HasDefaultValue() bool

HasDefaultValue returns true if characteristic has a default value

func (Characteristic) HasMaxValue

func (d Characteristic) HasMaxValue() bool

HasMaxValue returns true if characteristic has a max value

func (Characteristic) HasMinValue

func (d Characteristic) HasMinValue() bool

HasMinValue returns true if characteristic has a min value

func (Characteristic) HasStepValue

func (d Characteristic) HasStepValue() bool

HasStepValue returns true if characteristic has a step value

type ConstDecl

type ConstDecl struct {
	Identifier string
	TypeName   string
	Value      interface{}
}

ConstDecl is a constant declaration

type Service

type Service struct {
	Name          string // Name of the service (e.g. Light bulb)
	StructName    string // Name of the struct (e.g. Lightbulb)
	FileName      string // Name of the file (e.g. lightbulb.go)
	LocalFilePath string // Path to the file (e.g. ~/User/Go/src/github.com/MrEhbr/hc/service/lightbulb.go)
	RelFilePath   string // Relative path to the file from the project root (e.g. service/lightbulb.go)
	TypeName      string // Name of type e.g. TypeLightbulb
	TypeValue     string // Value of the type e.g. 00000008-0000-1000-8000-0026BB765291

	Chars    []*Characteristic
	Optional []*Characteristic
}

Service holds service template data

func ServiceDecl

func ServiceDecl(svc *gen.ServiceMetadata, chars []*gen.CharacteristicMetadata) *Service

Jump to

Keyboard shortcuts

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