model

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2022 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aggregator

type Aggregator struct {
	Targets    []string `json:"targets"`
	Type       string   `json:"type"`
	As         string   `json:"as"`
	Expression string   `json:"expression"`
}

Aggregator 聚合器

type Alarm

type Alarm struct {
	Disabled bool `json:"disabled"`

	//条件
	Condition string `json:"condition"`

	//重复日
	DailyChecker

	//延迟报警
	DelayChecker

	//重复报警
	RepeatChecker

	//产生告警
	AlarmContent
}

Alarm 数据校验

type AlarmContent

type AlarmContent struct {
	Code    string `json:"code"`
	Level   int    `json:"level"`
	Message string `json:"message"`
}

AlarmContent 告警内容

type Any added in v1.1.0

type Any interface{}

type Calculator

type Calculator struct {
	Expression string `json:"expression"`
	As         string `json:"as"`
	// contains filtered or unexported fields
}

Calculator 计算器

func (*Calculator) Evaluate

func (c *Calculator) Evaluate(ctx map[string]interface{}) (float64, error)

Evaluate 计算

func (*Calculator) Init

func (c *Calculator) Init() (err error)

Init 初始化(编译)

type Command

type Command struct {
	Name string `json:"name"`

	Directives []Directive `json:"directives"`
}

Command 命令

type Component added in v1.1.0

type Component struct {
	Id   string `json:"id" xorm:"pk"`
	Icon string `json:"icon"` //url svg png jpg ...
	Name string `json:"name"`

	Drawer string `json:"drawer"` // "rect" | "circle" | "line" | "poly"

	//分组(默认 扩展)
	Group string `json:"group"`

	//基础配置
	Color    bool `json:"color"`    //填充色
	Stroke   bool `json:"stroke"`   //线条
	Rotation bool `json:"rotation"` //旋转
	Position bool `json:"position"` //位置

	//扩展配置项
	Properties []Hash `json:"properties"`

	//事件
	Events []HmiEvent `json:"events"`

	//监听
	Values []HmiValue `json:"values"`

	//初始化
	Create string `json:"create"`

	//写入配置
	Setup string `json:"setup"`

	//更新数据
	Update string `json:"update"`

	//产生变量 data(){return {a:1, b2}}
	Data string `json:"data"`

	Updated time.Time `json:"updated" xorm:"updated"`
	Created time.Time `json:"created" xorm:"created"`
	Deleted time.Time `json:"-" xorm:"deleted"`
}

type DailyChecker

type DailyChecker struct {
	Times    []TimeRange    `json:"times"`
	Weekdays []time.Weekday `json:"weekdays"`
}

DailyChecker 每日检查

func (*DailyChecker) Check

func (dr *DailyChecker) Check() bool

Check 检查

type DataPoint added in v1.0.1

type DataPoint struct {
	Value interface{} `json:"value"`
	Time  time.Time   `json:"time"`
}

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) (float64, error)

Decode 解码

func (*DataType) Encode

func (dt *DataType) Encode(val float64, le bool) []byte

Encode 编码

func (*DataType) MarshalJSON

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

MarshalJSON 序列化

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 DelayChecker

type DelayChecker struct {
	Delay int64 `json:"delay"`
	// contains filtered or unexported fields
}

DelayChecker 延时检查

func (*DelayChecker) Check

func (d *DelayChecker) Check(now int64) bool

Check 检查

func (*DelayChecker) Reset

func (d *DelayChecker) Reset()

Reset 重置

type Device

type Device struct {
	Id        int64  `json:"id"`
	LinkId    int64  `json:"link_id" xorm:"index"`
	ElementId string `json:"element_id"`

	Name          string `json:"name"`
	Station       int    `json:"station"`
	DeviceContent `xorm:"extends"`

	Disabled bool      `json:"disabled"`
	Updated  time.Time `json:"updated" xorm:"updated"`
	Created  time.Time `json:"created" xorm:"created"`
	Deleted  time.Time `json:"-" xorm:"deleted"`
}

Device 设备

type DeviceAlarm

type DeviceAlarm struct {
	Id           int64 `json:"id"`
	DeviceId     int64 `json:"device_id" xorm:"index"`
	AlarmContent `xorm:"extends"`
	Created      time.Time `json:"created" xorm:"created"`
}

DeviceAlarm 设备告警

type DeviceContent

type DeviceContent struct {
	HMI         string        `json:"hmi" xorm:"'hmi'"`
	Tags        []string      `json:"tags,omitempty"`
	Points      []*Point      `json:"points"`
	Pollers     []*Poller     `json:"pollers"`
	Calculators []*Calculator `json:"calculators"`
	Commands    []*Command    `json:"commands"`
	Alarms      []*Alarm      `json:"alarms"`
}

type DeviceEx

type DeviceEx struct {
	Device  `xorm:"extends"`
	Running bool   `json:"running"`
	Link    string `json:"link"`
	Element string `json:"element"`
}

func (*DeviceEx) TableName added in v1.2.0

func (d *DeviceEx) TableName() string

type DeviceHistory

type DeviceHistory struct {
	Device   `xorm:"extends"`
	DeviceId int64 `json:"device_id" xorm:"index"`
}

type Directive

type Directive struct {
	Point string  `json:"point"`
	Value float64 `json:"value"`
	Delay int64   `json:"delay"`

	//使用表达式
	Expression string `json:"expression,omitempty"`
}

Directive 指令

type Element

type Element struct {
	Id           string `json:"id" xorm:"pk"`
	Name         string `json:"name"`
	Manufacturer string `json:"manufacturer"` //厂家
	Version      string `json:"version"`      //SEMVER

	DeviceContent `xorm:"extends"`

	Updated time.Time `json:"updated" xorm:"updated"`
	Created time.Time `json:"created" xorm:"created"`
	Deleted time.Time `json:"-" xorm:"deleted"`
}

Element 元件

type ElementHistory

type ElementHistory struct {
	Element   `xorm:"extends"`
	ElementId string `json:"element_id" xorm:"index"`
}

type Entity added in v1.1.0

type Entity struct {
	Name       string              `json:"name"`
	Component  string              `json:"component"`
	Properties map[string]Any      `json:"properties"`
	Handlers   map[string][]Invoke `json:"handlers"`
	Bindings   map[string]string   `json:"bindings"`
}

type Event

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

type HMI added in v1.1.0

type HMI struct {
	Id       string    `json:"id" xorm:"pk"`
	Name     string    `json:"name"`
	Width    int       `json:"width"`
	Height   int       `json:"height"`
	Snap     string    `json:"snap"`
	Entities []Entity  `json:"entities"`
	Updated  time.Time `json:"updated" xorm:"updated"`
	Created  time.Time `json:"created" xorm:"created"`
	Deleted  time.Time `json:"-" xorm:"deleted"`
}

func (*HMI) TableName added in v1.2.0

func (h *HMI) TableName() string

type Hash added in v1.1.0

type Hash map[string]Any

type HeartBeatPacket

type HeartBeatPacket struct {
	Enable  bool   `json:"enable"`
	Timeout int64  `json:"timeout"`
	Regex   string `json:"regex,omitempty"`
	Hex     string `json:"hex,omitempty"`
	Text    string `json:"text,omitempty"`
	// contains filtered or unexported fields
}

HeartBeatPacket 心跳包

func (*HeartBeatPacket) Check

func (p *HeartBeatPacket) Check(buf []byte) bool

Check 检查

type HmiEvent added in v1.1.0

type HmiEvent struct {
	Name  string `json:"name"`
	Label string `json:"label"`
}

type HmiValue added in v1.1.0

type HmiValue struct {
	Name  string `json:"name"`
	Label string `json:"label"`
}

type Invoke

type Invoke struct {
	Targets   []string `json:"targets"`
	Command   string   `json:"command"`
	Arguments []string `json:"arguments"`
}

Invoke 执行

type Job

type Job struct {
	Disabled bool `json:"disabled"`

	Type string `json:"type"` //clock, crontab

	Clock    int            `json:"clock,omitempty"`
	Weekdays []time.Weekday `json:"weekdays"`

	Crontab string `json:"crontab,omitempty"`

	Invokes []Invoke `json:"invokes"`
}

Job 任务

type Link struct {
	Id       int64     `json:"id"`
	TunnelId int64     `json:"tunnel_id" xorm:"index"`
	SN       string    `json:"sn" xorm:"index 'sn'"`
	Name     string    `json:"name"`
	Remote   string    `json:"remote"`
	Disabled bool      `json:"disabled"`
	Last     time.Time `json:"last"`
	Updated  time.Time `json:"updated" xorm:"updated"`
	Created  time.Time `json:"created" xorm:"created"`
	Deleted  time.Time `json:"-" xorm:"deleted"`
}

Link 链接模型

type LinkEx

type LinkEx struct {
	Link    `xorm:"extends"`
	Running bool   `json:"running"`
	Tunnel  string `json:"tunnel"`
}

func (*LinkEx) TableName added in v1.2.0

func (link *LinkEx) TableName() string

type Password

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

Password 密码

type Pipe

type Pipe struct {
	Id       int64     `json:"id"`
	LinkId   int64     `json:"link_id"`
	Name     string    `json:"name"`
	Port     int       `json:"port"`
	Disabled bool      `json:"disabled"`
	Updated  time.Time `json:"updated" xorm:"updated"`
	Created  time.Time `json:"created" xorm:"created"`
	Deleted  time.Time `json:"-" xorm:"deleted"`
}

type PipeEx

type PipeEx struct {
	Pipe    `xorm:"extends"`
	Running bool   `json:"running"`
	Link    string `json:"link"`
}

func (*PipeEx) TableName added in v1.2.0

func (p *PipeEx) TableName() string

type Point

type Point struct {
	Name      string   `json:"name"`
	Label     string   `json:"label"`
	Unit      string   `json:"unit"`
	Type      DataType `json:"type"`
	Precision int      `json:"precision"`
	Address   string   `json:"address"`
	Default   float64  `json:"default"`

	LittleEndian bool `json:"little_endian"`
}

Point 数据点

type Poller

type Poller struct {
	Disabled bool   `json:"disabled"`
	Type     string `json:"type"` //interval, clock, crontab

	Interval int    `json:"interval,omitempty"`
	Clock    int    `json:"clock,omitempty"`
	Crontab  string `json:"crontab,omitempty"`

	Address string `json:"address"`
	Length  int    `json:"length"`
}

Poller 采集器

type Project

type Project struct {
	Id   int64  `json:"id"`
	Name string `json:"name"`

	Devices []*ProjectDevice `json:"devices"`

	TemplateId     string `json:"template_id,omitempty"`
	ProjectContent `xorm:"extends"`

	Disabled bool      `json:"disabled"`
	Updated  time.Time `json:"updated" xorm:"updated"`
	Created  time.Time `json:"created" xorm:"created"`
	Deleted  time.Time `json:"-" xorm:"deleted"`
}

Project 项目

type ProjectAlarm

type ProjectAlarm struct {
	Id           int64 `json:"id"`
	ProjectId    int64 `json:"project_id" xorm:"index"`
	AlarmContent `xorm:"extends"`
	Created      time.Time `json:"created" xorm:"created"`
}

ProjectAlarm 项目告警

type ProjectContent

type ProjectContent struct {
	HMI         string        `json:"hmi" xorm:"'hmi'"`
	Aggregators []*Aggregator `json:"aggregators"`
	Jobs        []*Job        `json:"jobs"`
	Alarms      []*Alarm      `json:"alarms"`
	Strategies  []*Strategy   `json:"strategies"`
}

type ProjectDevice

type ProjectDevice struct {
	Id   int64  `json:"id"`
	Name string `json:"name"` //编程名
}

ProjectDevice 项目的设备

type ProjectEx

type ProjectEx struct {
	Project  `xorm:"extends"`
	Running  bool   `json:"running"`
	Template string `json:"template"`
}

func (*ProjectEx) TableName added in v1.2.0

func (p *ProjectEx) TableName() string

type ProjectHistory

type ProjectHistory struct {
	Project   `xorm:"extends"`
	ProjectId int64 `json:"project_id" xorm:"index"`
}

type Protocol

type Protocol struct {
	Name    string                 `json:"name"`
	Options map[string]interface{} `json:"options"`
}

type RegisterPacket

type RegisterPacket struct {
	Enable bool   `json:"enable"`
	Regex  string `json:"regex,omitempty"`
	Length int    `json:"length,omitempty"`
	// contains filtered or unexported fields
}

RegisterPacket 注册包

func (*RegisterPacket) Check

func (p *RegisterPacket) Check(buf []byte) bool

Check 检查

type RepeatChecker

type RepeatChecker struct {
	ResetTimeout int64 `json:"reset_timeout"`
	ResetTotal   int   `json:"reset_total,omitempty"`
	// contains filtered or unexported fields
}

RepeatChecker 重复发生器

func (*RepeatChecker) Check

func (d *RepeatChecker) Check(now int64) bool

Check 检查

func (*RepeatChecker) Reset

func (d *RepeatChecker) Reset()

Reset 重置

type Retry

type Retry struct {
	Enable  bool `json:"enable"`
	Timeout int  `json:"timeout"`
	Maximum int  `json:"maximum"`
}

type SerialOptions

type SerialOptions struct {
	//PortName   string `json:"port_name"`   // /dev/tty.usb.. COM1
	BaudRate   uint `json:"baud_rate"`   //9600 ... 115200 ...
	DataBits   uint `json:"data_bits"`   //5 6 7 8
	StopBits   uint `json:"stop_bits"`   //1 2
	ParityMode uint `json:"parity_mode"` // 0:NONE 1:ODD 2:EVEN
	RS485      bool `json:"rs485"`
}

SerialOptions 串口参数

type Strategy

type Strategy struct {
	Disabled bool `json:"disabled"`

	//名称
	Name string `json:"name"`

	//条件
	Condition string `json:"condition"`

	//重复日
	DailyChecker

	//延迟报警
	DelayChecker

	//重复报警
	RepeatChecker

	//执行命令
	Invokes []*Invoke `json:"invokes,omitempty"`
}

Strategy 响应,待改名

type Template

type Template struct {
	Id      string `json:"id" xorm:"pk"`
	Name    string `json:"name"`
	Version string `json:"version"` //SEMVER

	Elements []*TemplateElement `json:"elements"`

	ProjectContent `xorm:"extends"`

	Updated time.Time `json:"updated" xorm:"updated"`
	Created time.Time `json:"created" xorm:"created"`
	Deleted time.Time `json:"-" xorm:"deleted"`
}

type TemplateElement

type TemplateElement struct {
	Id   string `json:"id"`
	Name string `json:"name"` //编程名
}

type TemplateHistory

type TemplateHistory struct {
	Template   `xorm:"extends"`
	TemplateId string `json:"template_id" xorm:"index"`
}

type TimeRange

type TimeRange struct {
	Start int `json:"start"`
	End   int `json:"end"`
}

TimeRange 时间范围

func (*TimeRange) Check

func (tr *TimeRange) Check(tm *time.Time) bool

Check 检查

type Tunnel

type Tunnel struct {
	Id        int64           `json:"id"`
	Name      string          `json:"name"`
	Type      string          `json:"type"` //serial tcp-client tcp-server udp-client udp-server
	Addr      string          `json:"addr"`
	Retry     Retry           `json:"retry" xorm:"JSON"` //重试
	Register  RegisterPacket  `json:"register" xorm:"JSON"`
	Heartbeat HeartBeatPacket `json:"heartbeat" xorm:"JSON"`
	Serial    SerialOptions   `json:"serial" xorm:"JSON"`
	Protocol  Protocol        `json:"protocol" xorm:"JSON"`
	Devices   []TunnelDevice  `json:"devices"` //默认设备
	Disabled  bool            `json:"disabled"`

	Updated time.Time `json:"updated" xorm:"updated"`
	Created time.Time `json:"created" xorm:"created"`
	Deleted time.Time `json:"-" xorm:"deleted"`
}

Tunnel 通道模型

type TunnelDevice

type TunnelDevice struct {
	Station   int    `json:"station"`
	ElementId string `json:"element_id"`
}

type TunnelEx

type TunnelEx struct {
	Tunnel  `xorm:"extends"`
	Running bool `json:"running"`
}

func (*TunnelEx) TableName added in v1.2.0

func (tunnel *TunnelEx) TableName() string

type User

type User struct {
	Id       int64     `json:"id"`
	Username string    `json:"username" xorm:"unique"`
	Nickname string    `json:"nickname,omitempty"`
	Email    string    `json:"email,omitempty"`
	Disabled bool      `json:"disabled"`
	Updated  time.Time `json:"updated" xorm:"updated"`
	Created  time.Time `json:"created" xorm:"created"`
	Deleted  time.Time `json:"-" xorm:"deleted"`
}

User 用户

Jump to

Keyboard shortcuts

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