element.go 1.4 KB
Newer Older
J
jason 已提交
1
package model
J
Jason 已提交
2 3 4 5

import "time"

type Element struct {
6
	ID          int    `json:"id"`
J
Jason 已提交
7
	UUID        string `json:"uuid" storm:"unique"` //唯一码,自动生成
8 9
	Name        string `json:"name"`
	Description string `json:"description"`
10 11 12 13 14
	Origin      string `json:"origin"` //来源

	Manufacturer string `json:"manufacturer"` //厂商
	Model        string `json:"model"`        //型号
	Version      string `json:"version"`      //版本
15

16 17
	Variables []ElementVariable `json:"variables"` //变量

J
修改  
Jason 已提交
18
	Created time.Time `json:"created" storm:"created"`
J
Jason 已提交
19 20
}

J
Jason 已提交
21
//Modbus
J
Jason 已提交
22 23
// coil 线圈 离散输出 (1读多个、5写单个、15写多个)
// discrete 触点 离散输入 (2读多个)
24
// hold 保持寄存器(3读多个、6写单个、16写多个,--23读写多个--)
J
Jason 已提交
25
// input 输入寄存器(4读多个)
26

J
Jason 已提交
27
type ElementVariable struct {
J
Jason 已提交
28
	Variable `storm:"inline"`
29
	Extend   uint16 `json:"extend"` //扩展长度 默认0,如果大于1,自动在别名基础上添加数字后缀,比如 s s1 s2 s3 ...
J
Jason 已提交
30 31 32
}

type Variable struct {
33 34 35 36 37 38 39
	Name   string  `json:"name"`
	Alias  string  `json:"alias"`  //默认别名,用于编程
	Code   uint8   `json:"code"`   //功能码
	Offset uint16  `json:"offset"` //偏移
	Type   string  `json:"type"`
	Unit   string  `json:"unit"`  //单位
	Scale  float32 `json:"scale"` //倍率,比如一般是 整数÷10,得到
J
Jason 已提交
40

J
Jason 已提交
41 42
	//Default  string `json:"default"`
	ReadOnly bool `json:"read_only"` //只读
J
Jason 已提交
43
}