template.go 1.8 KB
Newer Older
J
Jason 已提交
1
package models
J
Jason 已提交
2

3 4 5 6 7 8 9 10 11 12
type Template struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Version     string `json:"version"`

	Adapter    TemplateAdapter    `json:"adapter"`
	Variables  []TemplateVariable `json:"variables"`
	Batches    []TemplateBatch    `json:"batches"`
	Jobs       []TemplateJob      `json:"jobs"`
	Strategies []TemplateStrategy `json:"strategies"`
J
Jason 已提交
13 14
}

15 16 17
type TemplateBase struct {
	Name        string `json:"name"`
	Description string `json:"description"`
J
Jason 已提交
18 19
}

20 21
type TemplateAdapter struct {
	TemplateBase `xorm:"extends"`
J
Jason 已提交
22

J
Jason 已提交
23
	ProtocolName string `json:"protocol_name"`
J
Jason 已提交
24 25 26 27 28
	ProtocolOpts string `json:"protocol_opts"`

	PollingEnable   bool `json:"polling_enable"`   //轮询
	PollingInterval int  `json:"polling_interval"` //轮询间隔 ms
	PollingCycle    int  `json:"polling_cycle"`    //轮询周期 s
J
Jason 已提交
29 30
}

31 32
type TemplateVariable struct {
	TemplateBase `xorm:"extends"`
J
 
Jason 已提交
33

34 35
	Address `xorm:"extends"`

J
Jason 已提交
36
	Type string `json:"type"`
37 38
	Unit string `json:"unit"` //单位

J
Jason 已提交
39 40 41 42 43 44 45 46 47 48
	Scale    float32 `json:"scale"` //倍率,比如一般是 整数÷10,得到
	Default  string  `json:"default"`
	Writable bool    `json:"writable"` //可写,用于输出(如开关)

	//采样:无、定时、轮询
	Cron          string `json:"cron"`
	PollingEnable bool   `json:"polling_enable"` //轮询
	PollingTimes  int    `json:"polling_times"`
}

49 50
type TemplateBatch struct {
	TemplateBase `xorm:"extends"`
J
 
Jason 已提交
51

52 53 54
	Address `xorm:"extends"`

	Size int `json:"size"`
J
Jason 已提交
55 56 57 58 59 60 61

	//采样:无、定时、轮询
	Cron          string `json:"cron"`
	PollingEnable bool   `json:"polling_enable"` //轮询
	PollingTimes  int    `json:"polling_times"`
}

62 63
type TemplateJob struct {
	TemplateBase `xorm:"extends"`
J
Jason 已提交
64

J
Jason 已提交
65 66
	Cron   string `json:"cron"`
	Script string `json:"script"` //javascript
J
Jason 已提交
67 68
}

69 70
type TemplateStrategy struct {
	TemplateBase `xorm:"extends"`
J
Jason 已提交
71 72

	Script string `json:"script"` //javascript
J
Jason 已提交
73
}
74