model

package
v3.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2023 License: GPL-3.0 Imports: 9 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 Alarm

type Alarm struct {
	Id       int64  `json:"id"`
	DeviceId string `json:"device_id" xorm:"index"`
	Level    uint8  `json:"level"`
	Type     string `json:"type"`
	Title    string `json:"title"`
	Message  string `json:"message,omitempty"`
	Read     bool   `json:"read,omitempty"`
	Created  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"`
	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   `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   `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   `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"`

	GroupId int64 `json:"group_id,omitempty" xorm:"index"` //分组
	TypeId  int64 `json:"type_id,omitempty"`

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

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"`
	Created  Time           `json:"created" xorm:"created"`
}

type DeviceGroup added in v3.0.3

type DeviceGroup struct {
	Id      int64  `json:"id"`
	Name    string `json:"name"`
	Desc    string `json:"desc,omitempty"`
	Created 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   `json:"created" xorm:"created"`
}

type DeviceType added in v3.0.3

type DeviceType struct {
	Id      int64  `json:"id"`
	Name    string `json:"name"`
	Desc    string `json:"desc,omitempty"`
	Created Time   `json:"created,omitempty" 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   `json:"created,omitempty" xorm:"created"`
}

type License

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

type Me added in v3.0.1

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

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 ModConstraint

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

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 Parameters

type Parameters map[string]float64

type Password

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

Password 密码

type PayloadDevice

type PayloadDevice struct {
	Id         string         `json:"id"`
	Time       time.Time      `json:"time,omitempty"`
	Timestamp  int64          `json:"timestamp,omitempty"`
	Properties []PayloadValue `json:"properties"`
}

type PayloadEvent

type PayloadEvent struct {
	Id      string         `json:"id"`
	Name    string         `json:"name"`
	Title   string         `json:"title"`
	Message string         `json:"message,omitempty"`
	Output  map[string]any `json:"output"`
}

type PayloadProperties added in v3.0.3

type PayloadProperties map[string]any

type PayloadPropertyUp

type PayloadPropertyUp struct {
	PayloadDevice
	//子设备
	Devices []PayloadDevice `json:"devices,omitempty"`
}

type PayloadValue

type PayloadValue struct {
	Name      string    `json:"name"`
	Time      time.Time `json:"time,omitempty"`
	Timestamp int64     `json:"timestamp,omitempty"`
	Value     any       `json:"value"`
}

type Plugin

type Plugin struct {
	Id           string            `json:"id" xorm:"pk"`
	Name         string            `json:"name"`
	Version      string            `json:"version"`
	Command      string            `json:"command,omitempty"`
	Dependencies map[string]string `json:"dependencies,omitempty" xorm:"json"`
	Disabled     bool              `json:"disabled,omitempty"`
	Created      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"`
	Constraints []ModConstraint `json:"constraints,omitempty"`

	Created 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"`
	Created    Time     `json:"created,omitempty" xorm:"created"`
}

type Time

type Time time.Time

func (*Time) FromDB

func (t *Time) FromDB(b []byte) error

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

func (Time) MarshalText

func (t Time) MarshalText() ([]byte, error)

func (Time) Now

func (t Time) Now() Time

func (Time) ParseTime

func (t Time) ParseTime(tt time.Time) Time

func (Time) String

func (t Time) String() string

func (*Time) ToDB

func (t *Time) ToDB() ([]byte, error)

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(b []byte) error

func (*Time) Value

func (t *Time) Value() (driver.Value, error)

type User

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

User 用户

type UserHistory

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

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