/
message.go
58 lines (51 loc) · 1.71 KB
/
message.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package types
import (
"time"
)
const (
GroupStatusNotReceiving = iota
GroupStatusReceiving = iota
)
const (
UpdateTypePassthru = iota
UpdateTypeInterval = iota
UpdateTypeDeadband = iota
UpdateTypeDevNull = iota
)
// Version 2 message types
type DataPoint struct {
ID int `json:"id"`
Time time.Time `json:"t"`
Name string `json:"n"`
Value interface{} `json:"v"`
Quality int `json:"q"`
}
type DataMessage struct {
Version int `json:"version"`
Group string `json:"group"`
Interval int `json:"interval"`
Sequence uint64 `json:"sequence"`
Count int `json:"count"`
Points []DataPoint `json:"points"`
}
type DataPointMeta struct {
ID uint `json:"id" gorm:"autoincrement"`
Name string `json:"name" gorm:"unique;index"`
Description string `json:"description"`
EngUnit string `json:"engunit"`
MinValue float64 `json:"min"`
MaxValue float64 `json:"max"`
Quantity string `json:"quantity"`
UpdateType int `json:"updatetype"` // 0 = pass thru, 1 = interval, 2 = integrating deadband, 3 = disabled
Interval int `json:"interval"`
IntegratingDeadband float64 `json:"integratingdeadband"`
Alias string `json:"alias"`
}
type VolatileDataPoint struct {
DataPoint *DataPoint `json:"datapoint"`
DataPointMeta DataPointMeta `json:"datapointmeta"`
StoredValue float64 `json:"storedvalue"` // only used for the integrating deadband (floating data points)
Integrator float64 `json:"integrator"`
Threshold float64 `json:"threshold"`
LastEmitted time.Time `json:"lastemitted"`
}