model

package
v3.2.8 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: GPL-3.0 Imports: 8 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PRIVILEGES = map[string]string{
	"ALL":          "全部权限",
	"BROKER":       "总线查看",
	"BROKER-EDIT":  "总线管理",
	"PRODUCT":      "产品查看",
	"PRODUCT-EDIT": "产品管理",
	"DEVICE":       "设备查看",
	"DEVICE-EDIT":  "设备管理",
	"ALARM":        "报警查看",
	"ALARM-EDIT":   "报警管理",
	"USER":         "用户查看",
	"USER-EDIT":    "用户管理",
	"PLUGIN":       "插件查看",
	"PLUGIN-EDIT":  "插件管理",
	"SETTING":      "系统设置",
}

Functions

This section is empty.

Types

type Aggregator added in v3.2.5

type Aggregator struct {
	Id        string    `json:"id" xorm:"pk"`
	ProductId string    `json:"product_id" xorm:"index"`
	DeviceId  string    `json:"device_id" xorm:"index"`
	Name      string    `json:"name"`     //名称
	Desc      string    `json:"desc"`     //说明
	Disabled  bool      `json:"disabled"` //禁用
	Created   time.Time `json:"created" xorm:"created"`

	ModAggregator `xorm:"extends"`
}

type Alarm

type Alarm struct {
	Id       int64     `json:"id"`
	Device   string    `json:"device" xorm:"-"`
	DeviceId string    `json:"device_id" xorm:"index"`
	Type     string    `json:"type"`
	Title    string    `json:"title"`
	Message  string    `json:"message,omitempty"`
	Level    uint      `json:"level"`
	Read     bool      `json:"read,omitempty"`
	Created  time.Time `json:"created,omitempty" xorm:"created"`
}

type App

type App struct {
	Id      string     `json:"id" xorm:"pk"`
	Name    string     `json:"name"`
	Icon    string     `json:"icon,omitempty"`
	Entries []AppEntry `json:"entries" xorm:"json"`
	Desc    string     `json:"desc,omitempty"`
	Type    string     `json:"type"` //tcp unix
	Address string     `json:"address"`
	Auth    string     `json:"auth"`             //鉴权机制,继承 无 自定义,inherit none custom
	Hidden  bool       `json:"hidden,omitempty"` //隐藏,适用于服务
}

type AppEntry

type AppEntry struct {
	Path string `json:"path"`
	Name string `json:"name"`
	Icon string `json:"icon,omitempty"`
}

type AppHistory

type AppHistory struct {
	Id      int64     `json:"id"`
	AppId   string    `json:"app_id"`
	Event   string    `json:"event"`
	Created time.Time `json:"created" xorm:"created"`
}

type Broker

type Broker struct {
	Id       string    `json:"id" xorm:"pk"`
	Name     string    `json:"name"`
	Desc     string    `json:"desc,omitempty"`
	Port     int       `json:"port,omitempty"` //TODO 添加TLS证书
	Disabled bool      `json:"disabled,omitempty"`
	Created  time.Time `json:"created,omitempty" xorm:"created"`
}

type BrokerHistory

type BrokerHistory struct {
	Id       int64     `json:"id"`
	BrokerId string    `json:"broker_id" xorm:"index"`
	Event    string    `json:"event"`
	Created  time.Time `json:"created,omitempty" xorm:"created"`
}

type DataType

type DataType int

DataType 数据类型

const (
	//TypeNONE 空类型
	TypeNONE DataType = iota
	TypeBIT
	TypeBYTE
	TypeWORD
	TypeDWORD
	TypeQWORD
	TypeSHORT
	TypeINTEGER
	TypeLONG
	TypeFLOAT
	TypeDOUBLE
)

func (*DataType) Decode

func (dt *DataType) Decode(buf []byte, le bool, precision int) (val interface{}, err error)

Decode 解码

func (*DataType) Default

func (dt *DataType) Default() interface{}

func (*DataType) Encode

func (dt *DataType) Encode(value interface{}, le bool, precision int) []byte

Encode 编码

func (*DataType) MarshalJSON

func (dt *DataType) MarshalJSON() ([]byte, error)

MarshalJSON 序列化

func (*DataType) Normalize

func (dt *DataType) Normalize(val interface{}) interface{}

func (*DataType) Parse

func (dt *DataType) Parse(tp string) error

Parse 解析类型

func (*DataType) Size

func (dt *DataType) Size() int

Size 宽度

func (*DataType) String

func (dt *DataType) String() string

String 转化成字符串

func (*DataType) UnmarshalJSON

func (dt *DataType) UnmarshalJSON(buf []byte) error

UnmarshalJSON 解析

type Device

type Device struct {
	Id        string `json:"id" xorm:"pk"` //ClientID
	GatewayId string `json:"gateway_id,omitempty" xorm:"index"`
	ProductId string `json:"product_id,omitempty" xorm:"index"`

	Name       string             `json:"name"`
	Desc       string             `json:"desc,omitempty"`
	Parameters map[string]float64 `json:"parameters,omitempty" xorm:"json"` //模型参数,用于报警检查
	Disabled   bool               `json:"disabled,omitempty"`
	Created    time.Time          `json:"created,omitempty" xorm:"created"`

	Online bool `json:"online,omitempty" xorm:"-"`
}

type DeviceEvent added in v3.0.3

type DeviceEvent struct {
	Id       int64          `json:"id"`
	DeviceId string         `json:"device_id" xorm:"index"`
	Name     string         `json:"name"`
	Label    string         `json:"label"`
	Output   map[string]any `json:"output" xorm:"json"`
	Created  time.Time      `json:"created" xorm:"created"`
}

type DeviceHistory

type DeviceHistory struct {
	Id       int64     `json:"id" xorm:"pk"`
	DeviceId string    `json:"device_id" xorm:"index"`
	Event    string    `json:"event"`
	Created  time.Time `json:"created" xorm:"created"`
}

type Gateway added in v3.0.3

type Gateway struct {
	Id       string    `json:"id" xorm:"pk"`
	Name     string    `json:"name"`
	Desc     string    `json:"desc,omitempty"`
	Username string    `json:"username,omitempty"`
	Password string    `json:"password,omitempty"`
	Disabled bool      `json:"disabled,omitempty"`
	Created  time.Time `json:"created,omitempty" xorm:"created"`
}

type History added in v3.2.5

type History struct {
	Id       int64     `json:"id"`
	DeviceId string    `json:"device_id" xorm:"index"`
	Device   string    `json:"device,omitempty" xorm:"-"`
	Point    string    `json:"point" xorm:"index"` //数据点
	Value    float64   `json:"value"`              //值
	Time     time.Time `json:"time"`
}

type License

type License struct {
	Id      string    `json:"id"`
	Content string    `json:"content"`
	Created time.Time `json:"created,omitempty" xorm:"created"`
}

type Me added in v3.0.1

type Me struct {
	User       `xorm:"extends"`
	Privileges []string `json:"privileges"`
}

type ModAggregator added in v3.2.5

type ModAggregator struct {
	Crontab    string `json:"crontab"`    //定时计划
	Expression string `json:"expression"` //表达式
	Type       string `json:"type"`       //聚合算法 inc dec avg count min max sum last first
	Assign     string `json:"assign"`     //赋值
}

type ModArgument

type ModArgument struct {
	Name  string `json:"name"`
	Label string `json:"label"`
	Desc  string `json:"desc,omitempty"`
	Type  string `json:"type"`
	Unit  string `json:"unit"`
}

type ModEvent

type ModEvent struct {
	Name   string        `json:"name"`
	Label  string        `json:"label"`
	Desc   string        `json:"desc,omitempty"`
	Type   string        `json:"type"` //info alert error //Level  uint8         `json:"level"`
	Output []ModArgument `json:"output"`
}

type ModFunction

type ModFunction struct {
	Name   string        `json:"name"`
	Label  string        `json:"label"`
	Desc   string        `json:"desc,omitempty"`
	Async  bool          `json:"async"`
	Input  []ModArgument `json:"input"`
	Output []ModArgument `json:"output"`
}

type ModParameter

type ModParameter struct {
	Name    string  `json:"name"`
	Label   string  `json:"label"`
	Min     float64 `json:"min,omitempty"`
	Max     float64 `json:"max,omitempty"`
	Default float64 `json:"default,omitempty"`
}

type ModProperty

type ModProperty struct {
	Name  string `json:"name"`
	Label string `json:"label"`
	Desc  string `json:"desc,omitempty"`
	Type  string `json:"type"` //int float ....
	Unit  string `json:"unit"`
	Mode  string `json:"mode"`  //r w rw
	Store string `json:"store"` // save diff
}

type ModValidator added in v3.2.5

type ModValidator struct {
	Expression string `json:"expression"`
	Type       string `json:"type"`
	Title      string `json:"title"`
	Level      uint   `json:"level"`
	Template   string `json:"template"`
	Delay      uint   `json:"delay,omitempty"` //延迟时间s
	Again      uint   `json:"again,omitempty"` //再次提醒间隔s
	Total      uint   `json:"total,omitempty"` //总提醒次数
}

type Parameters

type Parameters map[string]float64

type Password

type Password struct {
	Id       string `json:"id" xorm:"pk"`
	Password string `json:"password"`
}

Password 密码

type Plugin

type Plugin struct {
	Id           string            `json:"id" xorm:"pk"`
	Name         string            `json:"name"`
	Version      string            `json:"version"`
	Command      string            `json:"command,omitempty"`
	Running      bool              `json:"running,omitempty" xorm:"-"`
	Username     string            `json:"username,omitempty"`
	Password     string            `json:"password,omitempty"`
	External     bool              `json:"external,omitempty"`
	Dependencies map[string]string `json:"dependencies,omitempty" xorm:"json"`
	Disabled     bool              `json:"disabled,omitempty"`
	Created      time.Time         `json:"created,omitempty" xorm:"created"`
}

type Privilege added in v3.0.1

type Privilege struct {
	Id   string `json:"id" xorm:"pk"`
	Name string `json:"name"`
	Desc string `json:"desc,omitempty"`
}

type Product

type Product struct {
	Id      string `json:"id" xorm:"pk"`
	Name    string `json:"name"`
	Desc    string `json:"desc,omitempty"`
	Version string `json:"version,omitempty"`

	Properties []ModProperty  `json:"properties,omitempty" xorm:"json"`
	Functions  []ModFunction  `json:"functions,omitempty" xorm:"json"`
	Events     []ModEvent     `json:"events,omitempty" xorm:"json"`
	Parameters []ModParameter `json:"parameters,omitempty" xorm:"json"`

	Validators  []ModValidator  `json:"validators,omitempty" xorm:"json"`
	Aggregators []ModAggregator `json:"aggregators,omitempty" xorm:"json"`

	Created time.Time `json:"created,omitempty" xorm:"created"`
}

type Role added in v3.0.1

type Role struct {
	Id         string    `json:"id" xorm:"pk"`
	Name       string    `json:"name"`
	Privileges []string  `json:"privileges" xorm:"json"`
	Created    time.Time `json:"created,omitempty" xorm:"created"`
}

type User

type User struct {
	Id       string    `json:"id" xorm:"pk"`
	Username string    `json:"username" xorm:"unique"`
	Name     string    `json:"name,omitempty"`
	Email    string    `json:"email,omitempty"`
	Roles    []string  `json:"roles,omitempty" xorm:"json"`
	Disabled bool      `json:"disabled,omitempty"`
	Created  time.Time `json:"created,omitempty" xorm:"created"`
}

User 用户

type UserHistory

type UserHistory struct {
	Id      int64     `json:"id"`
	UserId  string    `json:"user_id"`
	Event   string    `json:"event"`
	Created time.Time `json:"created" xorm:"created"`
}

type Validator added in v3.2.5

type Validator struct {
	Id        string    `json:"id" xorm:"pk"`
	ProductId string    `json:"product_id" xorm:"index"`
	DeviceId  string    `json:"device_id" xorm:"index"`
	Disabled  bool      `json:"disabled"`
	Created   time.Time `json:"created" xorm:"created"`

	ModValidator `xorm:"extends"`
}

type Variables

type Variables map[string]any

Jump to

Keyboard shortcuts

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