forked from embriq-nordic/gs2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gs2.go
96 lines (88 loc) · 4.13 KB
/
gs2.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package gs2
import "time"
// GS2 - versjon 1.2
//http://hdl.handle.net/11250/2391930
// GS2 represents the data of a GS2 file.
type GS2 struct {
StartMessage StartMessage `gs2:"Start-message"`
MeterReadings []MeterReading `gs2:"Meter-reading"`
TimeSeries []TimeSeries `gs2:"Time-series"`
EndMessage EndMessage `gs2:"End-message"`
}
// StartMessage should always be the first object in any GS2-file-
type StartMessage struct {
ID string `gs2:"Id,omitempty"`
MessageType string `gs2:"Message-type,omitempty"`
Version string `gs2:"Version,omitempty"`
Time time.Time `gs2:"Time,omitempty"`
To string `gs2:"To,omitempty"`
From string `gs2:"From,omitempty"`
ReferenceTable string `gs2:"Reference-table,omitempty"`
GMTReference int `gs2:"GMT-reference,omitempty"`
NumberOfObjects int `gs2:"Number-of-objects,omitempty"`
TypeOfObjects string `gs2:"Type-of-objects,omitempty"`
ContainsObjects string `gs2:"Contains-objects,omitempty"`
RequestedAction string `gs2:"Requested-action,omitempty"`
Description string `gs2:"Description,omitempty"`
}
// EndMessage should always be the last object in any GS2-file-
type EndMessage struct {
ID string `gs2:"Id,omitempty"`
MessageType string `gs2:"Message-type,omitempty"`
Version string `gs2:"Version,omitempty"`
Time time.Time `gs2:"Time,omitempty"`
To string `gs2:"To,omitempty"`
From string `gs2:"From,omitempty"`
ReferenceTable string `gs2:"Reference-table,omitempty"`
GMTReference int `gs2:"GMT-reference,omitempty"`
NumberOfObjects int `gs2:"Number-of-objects"`
TypeOfObjects string `gs2:"Type-of-objects,omitempty"`
ContainsObjects string `gs2:"Contains-objects,omitempty"`
RequestedAction string `gs2:"Requested-action,omitempty"`
Description string `gs2:"Description,omitempty"`
}
// MeterReading contains a single value that is a channel reading at a given point in time.
type MeterReading struct {
Reference string `gs2:"Reference,omitempty"`
Time time.Time `gs2:"Time,omitempty"`
Unit string `gs2:"Unit,omitempty"`
Value Triplet `gs2:"Value"`
Installation string `gs2:"Installation,omitempty"`
Plant string `gs2:"Plant,omitempty"`
MeterLocation string `gs2:"Meter-location,omitempty"`
NetOwner string `gs2:"Net-owner,omitempty"`
Supplier string `gs2:"Supplier,omitempty"`
Customer string `gs2:"Customer,omitempty"`
Meter string `gs2:"Meter,omitempty"`
Channel string `gs2:"Channel,omitempty"`
Description string `gs2:"Description,omitempty"`
DirectionOfFlow string `gs2:"Direction-of-flow,omitempty"`
}
// TimeSeries contains time series of metered values within the interval given by start and stop.
type TimeSeries struct {
Reference string `gs2:"Reference,omitempty"`
Start time.Time `gs2:"Start,omitempty"`
Stop time.Time `gs2:"Stop,omitempty"`
Step time.Duration `gs2:"Step,omitempty"`
Unit string `gs2:"Unit,omitempty"`
TypeOfValue string `gs2:"Type-of-value,omitempty"`
DirectionOfFlow string `gs2:"Direction-of-flow,omitempty"`
Value []Triplet `gs2:"Value,omitempty"`
NoOfValues int `gs2:"No-of-values"`
Sum float64 `gs2:"Sum"`
Installation string `gs2:"Installation,omitempty"`
Plant string `gs2:"Plant,omitempty"`
MeterLocation string `gs2:"Meter-location,omitempty"`
NetOwner string `gs2:"Net-owner,omitempty"`
Supplier string `gs2:"Supplier,omitempty"`
Customer string `gs2:"Customer,omitempty"`
Meter string `gs2:"Meter,omitempty"`
Channel string `gs2:"Channel,omitempty"`
Description string `gs2:"Description,omitempty"`
}
// Triplet represents a value triplet with value, time and quality.
type Triplet struct {
Value float64
Time time.Time
Quality string
}