product

package
v0.2.12 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadConfig

func LoadConfig[T any](id, config string) (*T, error)

Types

type Action added in v0.1.6

type Action struct {
	Name        string      `json:"name,omitempty"`
	Description string      `json:"description,omitempty"`
	Parameters  []Parameter `json:"parameters,omitempty"`
	Returns     []Parameter `json:"returns,omitempty"`
}

type Bit added in v0.1.6

type Bit struct {
	Name string `json:"name"` //名称
	Bit  int    `json:"bit"`  //偏移
}

type Compare added in v0.2.9

type Compare struct {
	Type  string  `json:"type"` //= != > >= < <=
	Name  string  `json:"name"`
	Value float64 `json:"value"`
}

func (*Compare) Evaluate added in v0.2.9

func (c *Compare) Evaluate(ctx map[string]any) (bool, error)

type Event added in v0.1.6

type Event struct {
	Name        string      `json:"name,omitempty"`
	Description string      `json:"description,omitempty"`
	Parameters  []Parameter `json:"parameters,omitempty"`
}

type Parameter added in v0.1.6

type Parameter struct {
	Name string `json:"name,omitempty"`
	Type string `json:"type,omitempty"`
}

type Point added in v0.1.6

type Point interface {
	Encode(data any) ([]byte, error)
	Parse(address uint16, buf []byte) (any, error)
}

type PointBit added in v0.1.6

type PointBit struct {
	Name    string `json:"name"`    //名称
	Address uint16 `json:"address"` //偏移
}

func (*PointBit) Encode added in v0.1.6

func (p *PointBit) Encode(data any) ([]byte, error)

func (*PointBit) Parse added in v0.1.6

func (p *PointBit) Parse(address uint16, buf []byte) (any, error)

type PointWord added in v0.1.6

type PointWord struct {
	Name      string  `json:"name"`              //名称
	Type      string  `json:"type"`              //类型
	Address   uint16  `json:"address"`           //偏移
	BigEndian bool    `json:"be,omitempty"`      //大端模式
	Rate      float64 `json:"rate,omitempty"`    //倍率
	Correct   float64 `json:"correct,omitempty"` //纠正
	Bits      []*Bit  `json:"bits,omitempty"`    //位,1 2 3...
}

func (*PointWord) Encode added in v0.1.6

func (p *PointWord) Encode(data any) ([]byte, error)

func (*PointWord) Parse added in v0.1.6

func (p *PointWord) Parse(address uint16, buf []byte) (any, error)

func (*PointWord) Size added in v0.1.6

func (p *PointWord) Size() int

type Product added in v0.1.6

type Product struct {
	Id          string    `json:"id,omitempty" xorm:"pk"`
	Name        string    `json:"name,omitempty"`
	Description string    `json:"description,omitempty"`
	Type        string    `json:"type,omitempty"` //类型
	Version     string    `json:"version,omitempty"`
	Protocol    string    `json:"protocol,omitempty"`
	Disabled    bool      `json:"disabled,omitempty"` //禁用
	Created     time.Time `json:"created,omitempty" xorm:"created"`
}

type ProductConfig added in v0.1.6

type ProductConfig struct {
	Id      string         `json:"id" xorm:"pk"`
	Name    string         `json:"name" xorm:"pk"` //双主键
	Content map[string]any `json:"content,omitempty" xorm:"json text"`
	Updated time.Time      `json:"updated,omitempty" xorm:"updated"`
	Created time.Time      `json:"created,omitempty" xorm:"created"`
}

type ProductModel added in v0.1.6

type ProductModel struct {
	Id         string       `json:"id,omitempty" xorm:"pk"`
	Properties []*Property  `json:"properties,omitempty" xorm:"json"`
	Events     []*Event     `json:"events,omitempty" xorm:"json"`
	Actions    []*Action    `json:"actions,omitempty" xorm:"json"`
	Validators []*Validator `json:"validators,omitempty" xorm:"json"`
	Updated    time.Time    `json:"updated,omitempty" xorm:"updated"`
	Created    time.Time    `json:"created,omitempty" xorm:"created"`
}

func LoadModel added in v0.2.8

func LoadModel(id string) (*ProductModel, error)

type Property added in v0.1.6

type Property struct {
	Name      string `json:"name,omitempty"`  //变量名称
	Label     string `json:"label,omitempty"` //显示名称
	Unit      string `json:"unit,omitempty"`  //单位
	Type      string `json:"type,omitempty"`  //bool string number array object
	Precision uint8  `json:"precision,omitempty"`
	Default   any    `json:"default,omitempty"`  //默认值
	Writable  bool   `json:"writable,omitempty"` //是否可写
	History   bool   `json:"history,omitempty"`  //是否保存历史
}

Property 属性

type Validator added in v0.2.8

type Validator struct {
	Type       string  `json:"type"` //compare对比, expression表达式
	Compare    Compare `json:"compare,omitempty"`
	Expression string  `json:"expression,omitempty"`
	Title      string  `json:"title,omitempty"`
	Message    string  `json:"message,omitempty"`
	Level      int     `json:"level,omitempty"`
	Delay      int64   `json:"delay,omitempty"`
	Reset      int64   `json:"reset,omitempty"`
	ResetTimes int     `json:"reset_times,omitempty"`
	Disabled   bool    `json:"disabled,omitempty"`
}

Jump to

Keyboard shortcuts

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