generator

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateStruct

func GenerateStruct(base, defPath, tplPath, outPath string) error

func GenerateTypescript

func GenerateTypescript(base, defPath, tplPath, outPath string) error

func GenerateZdo

func GenerateZdo(base, defPath, tplPath, outPath string) error

Types

type Attr

type Attr struct {
	ID            Hex             `xml:"id,attr" toml:"id,omitempty" yaml:"id,omitempty" json:"id,omitempty"`
	Name          Name            `xml:"name,attr" toml:"name,omitempty" yaml:"name,omitempty" json:"name,omitempty"`
	ArgName       Name            `xml:"argname,attr" toml:"argname,omitempty" yaml:"argname,omitempty" json:"argname,omitempty"`
	Type          Type            `xml:"type,attr" toml:"type,omitempty" yaml:"type,omitempty" json:"type,omitempty"`
	ArrayType     Type            `xml:"arrayType,attr" toml:"arraytype,omitempty" yaml:"arraytype,omitempty" json:"arraytype,omitempty"`
	Access        string          `xml:"access,attr" toml:"access,omitempty" yaml:"access,omitempty" json:"access,omitempty"`
	Default       Hex             `xml:"default,attr" toml:"default,omitempty" yaml:"default,omitempty" json:"default,omitempty"`
	Required      string          `xml:"required,attr" toml:"required,omitempty" yaml:"required,omitempty" json:"required,omitempty"`
	Report        bool            `xml:"-" toml:"report,omitempty" yaml:"report,omitempty" json:"report,omitempty"`
	Scene         Int             `xml:"-" toml:"scene,omitempty" yaml:"scene,omitempty" json:"scene,omitempty"`
	Range         string          `xml:"range,attr" toml:"range,omitempty" yaml:"range,omitempty" json:"range,omitempty"`
	MfCode        MfCode          `xml:"mfcode,attr" toml:"mnfcode,omitempty" yaml:"mnfcode,omitempty" json:"mnfcode,omitempty"`
	ShowAs        string          `xml:"showas,attr" toml:"showas,omitempty" yaml:"showas,omitempty" json:"showas,omitempty"`
	ListSize      string          `xml:"listSize,attr" toml:"listsize,omitempty" yaml:"listsize,omitempty" json:"listsize,omitempty"`
	Enumeration   Name            `xml:"enumeration,attr" toml:"enumeration,omitempty" yaml:"enumeration,omitempty" json:"enumeration,omitempty"`
	Unit          string          `xml:"unit,attr" toml:"unit,omitempty" yaml:"unit,omitempty" json:"unit,omitempty"`
	Multiplier    Multiplier      `xml:"multiplier,attr" toml:"multiplier,omitempty" yaml:"multiplier,omitempty" json:"multiplier,omitempty"`
	Desc          Desc            `xml:"description" toml:"description,omitempty" yaml:"description,omitempty" json:"description,omitempty"`
	Values        map[string]Name `xml:"value" toml:"values,omitempty" yaml:"values,omitempty" json:"values,omitempty"`
	Bits          map[string]Name `xml:"bit" toml:"bits,omitempty" yaml:"bits,omitempty" json:"bits,omitempty"`
	Cond          []Condition     `xml:"payload>condition" toml:"cond,omitempty" yaml:"cond,omitempty" json:"cond,omitempty"`
	Marshal       string          `xml:"marshal" toml:"marshal,omitempty" yaml:"marshal,omitempty" json:"marshal,omitempty"`
	Unmarshal     string          `xml:"unmarshal" toml:"unmarshal,omitempty" yaml:"unmarshal,omitempty" json:"unmarshal,omitempty"`
	MarshalNoType bool            `xml:"marshalnotype" toml:"marshalnotype,omitempty" yaml:"marshalnotype,omitempty" json:"marshalnotype,omitempty"`
	StructAttr    []Attr          `xml:"structattr" toml:"structattr,omitempty" yaml:"structattr,omitempty" json:"structattr,omitempty"`
}

func (Attr) ArgNameFmt

func (a Attr) ArgNameFmt() string

func (Attr) CanRead

func (a Attr) CanRead() bool

func (Attr) CanWrite

func (a Attr) CanWrite() bool

func (Attr) Equal

func (a Attr) Equal(o Attr) bool

type AttrSet

type AttrSet struct {
	ID     string `xml:"id,attr"` // Not hex since most ID:s are incomplete
	Desc   Desc   `xml:"description,attr"`
	MfCode MfCode `xml:"mfcode,attr"`
	Attr   []Attr `xml:"attribute"`
}

type BufWriter

type BufWriter []byte

func (*BufWriter) Write

func (b *BufWriter) Write(bytes []byte) (int, error)

type Cluster

type Cluster struct {
	TypeMap  map[string]Attr `xml:"types" toml:"types,omitempty" yaml:"types,omitempty" json:"types,omitempty"`
	ID       Hex             `xml:"id,attr" toml:"id,omitempty" yaml:"id,omitempty" json:"id,omitempty"`
	Name     Name            `xml:"name,attr" toml:"name,omitempty" yaml:"name,omitempty" json:"name,omitempty"`
	MfCode   MfCode          `xml:"mfcode,attr" toml:"mnfcode,omitempty" yaml:"mnfcode,omitempty" json:"mnfcode,omitempty"`
	Desc     Desc            `xml:"description" toml:"description,omitempty" yaml:"description,omitempty" json:"description,omitempty"`
	Server   CmdAttr         `xml:"server" toml:"server,omitempty" yaml:"server,omitempty" json:"server,omitempty"`
	Client   CmdAttr         `xml:"client" toml:"client,omitempty" yaml:"client,omitempty" json:"client,omitempty"`
	Clusters []Cluster       `xml:"clusters" toml:"clusters,omitempty" yaml:"clusters,omitempty" json:"clusters,omitempty"`
}

func (Cluster) Attr

func (c Cluster) Attr() []Attr

func (Cluster) Command

func (c Cluster) Command() []Command

func (Cluster) Types

func (c Cluster) Types() []Attr

type CmdAttr

type CmdAttr struct {
	AttrSet []AttrSet `xml:"attribute-set"`
	Attr    []Attr    `xml:"attribute" toml:"attr,omitempty" yaml:"attr,omitempty" json:"attr,omitempty"`
	Command []Command `xml:"command" toml:"cmd,omitempty" yaml:"cmd,omitempty" json:"cmd,omitempty"`
}

func (CmdAttr) SceneAttr

func (c CmdAttr) SceneAttr() []Attr

type Command

type Command struct {
	ID          Hex      `xml:"id,attr" toml:"id,omitempty" yaml:"id,omitempty" json:"id,omitempty"`
	Name        Name     `xml:"name,attr" toml:"name,omitempty" yaml:"name,omitempty" json:"name,omitempty"`
	Desc        Desc     `xml:"description" toml:"description,omitempty" yaml:"description,omitempty" json:"description,omitempty"`
	Dir         string   `xml:"dir,attr" toml:"dir,omitempty" yaml:"dir,omitempty" json:"dir,omitempty"`
	Required    Required `xml:"required,attr" toml:"required,omitempty" yaml:"required,omitempty" json:"required,omitempty"`
	Response    *Hex     `xml:"response,attr" toml:"response,omitempty" yaml:"response,omitempty" json:"response,omitempty"`
	ShowAs      string   `xml:"showas,attr" toml:"showas,omitempty" yaml:"showas,omitempty" json:"showas,omitempty"`
	Vendor      string   `xml:"vendor,attr" toml:"vendor,omitempty" yaml:"vendor,omitempty" json:"vendor,omitempty"`
	MfCode      MfCode   `xml:"mfcode,attr" toml:"mnfcode,omitempty" yaml:"mnfcode,omitempty" json:"mnfcode,omitempty"`
	PayloadAttr []Attr   `xml:"payload>attribute" toml:"payloadattr,omitempty" yaml:"payloadattr,omitempty" json:"payloadattr,omitempty"`
}

func (Command) TypeCode

func (c Command) TypeCode(mnf MfCode) uint8

type Condition

type Condition struct {
	Desc     Desc   `xml:"description" toml:"description,omitempty" yaml:"description,omitempty" json:"description,omitempty"`
	Name     Name   `xml:"name,attr" toml:"name,omitempty" yaml:"name,omitempty" json:"name,omitempty"`
	Attr     Hex    `toml:"attr,omitempty" yaml:"attr,omitempty" json:"attr,omitempty"`
	Value    Hex    `toml:"value,omitempty" yaml:"value,omitempty" json:"value,omitempty"`
	Mask     Hex    `toml:"mask,omitempty" yaml:"mask,omitempty" json:"mask,omitempty"`
	Invert   bool   `toml:"invert,omitempty" yaml:"invert,omitempty" json:"invert,omitempty"`
	Operator string `toml:"operator,omitempty" yaml:"operator,omitempty" json:"operator,omitempty"`
}

type DataType

type DataType struct {
	ID        Hex    `xml:"id,attr"`
	Name      Name   `xml:"name,attr"`
	ShortName Type   `xml:"shortname,attr"`
	Length    Length `xml:"length,attr"`
	AD        string `xml:"ad,attr"`
	Invalid   Hex    `xml:"inval,attr"`
}

func (DataType) MarshalCast

func (d DataType) MarshalCast() string

func (DataType) MarshalFn

func (d DataType) MarshalFn() string

func (DataType) Native

func (d DataType) Native() string

func (DataType) Tag

func (d DataType) Tag() string

func (DataType) UnmarshalFn

func (d DataType) UnmarshalFn() string

type Desc

type Desc string

func (Desc) Comment

func (d Desc) Comment(prefix ...string) string

func (Desc) Trim

func (d Desc) Trim() string

type Device

type Device struct {
	ID   Hex    `xml:"id,attr"`
	Name Name   `xml:"name,attr"`
	Desc Desc   `xml:"description"`
	Icon string `xml:"icon,attr"`
}

type Dir

type Dir struct {
	// contains filtered or unexported fields
}

func (*Dir) Files

func (d *Dir) Files() (files []*File)

func (*Dir) Path

func (d *Dir) Path() string

func (*Dir) SubPath

func (d *Dir) SubPath() string

type Domain

type Domain struct {
	Package   string    `xml:"package,attr"`
	Name      Name      `xml:"name,attr"`
	UseZCL    bool      `xml:"useZcl,attr"`
	Desc      Desc      `xml:"description,attr"`
	LowBound  Hex       `xml:"low_bound,attr"`
	HighBound Hex       `xml:"high_bound,attr"`
	Cluster   []Cluster `xml:"cluster"`
	Devices   []Device  `xml:"device"`
}

type DomainRef

type DomainRef struct {
	Name     Name `xml:"name,attr"`
	LowBound Hex  `xml:"low_bound,attr"`
}

func (DomainRef) Resolve

func (d DomainRef) Resolve(r *Root) (cluster []Cluster)

type EnumValue

type EnumValue struct {
	Value Hex  `xml:"value,attr"`
	Name  Name `xml:"name,attr"`
	Desc  Desc `xml:"description"`
}

type Enumeration

type Enumeration struct {
	ID     Hex         `xml:"id,attr"`
	Name   Name        `xml:"name,attr"`
	Values []EnumValue `xml:"value"`
}

type File

type File struct {
	// contains filtered or unexported fields
}

func (*File) Path

func (f *File) Path() string

func (*File) ReadCluster

func (f *File) ReadCluster() (*Cluster, error)

func (*File) SubPath

func (f *File) SubPath() string

type Hex

type Hex string

func (Hex) AsDecimal

func (h Hex) AsDecimal() uint64

func (Hex) Bytes

func (h Hex) Bytes(size int) []byte

func (Hex) Hex

func (h Hex) Hex() string

func (Hex) Hex2

func (h Hex) Hex2() string

func (Hex) Hex4

func (h Hex) Hex4() string

func (Hex) Trim

func (h Hex) Trim() string

func (Hex) Uint

func (h Hex) Uint() uint64

func (Hex) Valid

func (h Hex) Valid(bits int) bool

type Int

type Int string

func (Int) Int

func (i Int) Int() int

func (Int) Valid

func (i Int) Valid() bool

type Length

type Length string

func (Length) FixLen

func (l Length) FixLen() bool

func (Length) Uint

func (l Length) Uint() uint

type MfCode

type MfCode string

func (MfCode) ByteStr

func (m MfCode) ByteStr() string

func (MfCode) Bytes

func (m MfCode) Bytes() []byte

func (MfCode) Name

func (m MfCode) Name() string

func (MfCode) Stn

func (m MfCode) Stn(name Name) string

func (MfCode) Trim

func (m MfCode) Trim() string

func (MfCode) Uint

func (m MfCode) Uint() uint64

func (MfCode) Valid

func (m MfCode) Valid() bool

type Multiplier

type Multiplier string

type Name

type Name string

func (Name) Fmt

func (n Name) Fmt() string

func (Name) FmtUs

func (n Name) FmtUs() string

func (Name) Pfx

func (n Name) Pfx() string

type Profile

type Profile struct {
	ID      Hex         `xml:"id,attr"`
	Name    Name        `xml:"name,attr"`
	Desc    Desc        `xml:"description,attr"`
	Version string      `xml:"version,attr"`
	Rev     string      `xml:"rev,attr"`
	Icon    string      `xml:"icon,attr"`
	Domains []DomainRef `xml:"domain-ref"`
	Devices []Device    `xml:"device"`
}

type Required

type Required string

func (Required) IsTrue

func (r Required) IsTrue() bool

type Root

type Root struct {
	// Package name
	Package string `xml:"-"`

	DataTypes []DataType    `xml:"datatypes>datatype"`
	Enum      []Enumeration `xml:"enumeration"`
	Domains   []Domain      `xml:"domain"`
	Profiles  []Profile     `xml:"profile"`
	Devices   []Device      `xml:"devices>device"`
}

type Type

type Type string

func (Type) Native

func (n Type) Native() string

func (Type) RealType

func (n Type) RealType() string

func (Type) TsType

func (n Type) TsType(path string) string

func (Type) Type

func (n Type) Type() string

type Zdo

type Zdo struct {
	TypeMap  map[string]Attr `xml:"types" toml:"types,omitempty" yaml:"types,omitempty" json:"types,omitempty"`
	Commands []Command       `xml:"commands" toml:"commands,omitempty" yaml:"commands,omitempty" json:"commands,omitempty"`
}

func (Zdo) Types

func (c Zdo) Types() []Attr

Jump to

Keyboard shortcuts

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