Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateNoOfObjects ¶
ValidateNoOfObjects validates that the reported number of objects are equal to the actual number of objects in the decoded object.
func ValidateTimeSeriesValues ¶
ValidateTimeSeriesValues validates the number ov values are consistent and that sum og values in a time series block are equal to the sum attribute.
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder reads and decodes GS2 input. NB: year, month and day is not supported in Step attribute. Only hour, minute and seconds are used when decoding duration.
func NewDecoder ¶
func NewDecoder(r io.Reader, opt ...DecoderOption) *Decoder
NewDecoder returna a new Decoder reading from r.
type DecoderOption ¶
type DecoderOption func(*decoderOptions)
DecoderOption sets configuration for a Decoder.
func DecodeValidators ¶
func DecodeValidators(v ...Validator) DecoderOption
DecodeValidators sets the validators to be run after decoding an object. Will overwrite the default ones. So remeber to add the defaults as well if needed.
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder encodes a GS2 object and writes to an io.Writer. NB: year, month and day is not supported in Step attribute. Only hour, minute and seconds are used when encoding duration.
func NewEncoder ¶
func NewEncoder(w io.Writer, opt ...EncoderOption) *Encoder
NewEncoder returna a new Encoder writing to w.
type EncoderOption ¶
type EncoderOption func(*encoderOptions)
EncoderOption sets configuration for a Encoder.
func EncodeFloatPrecision ¶
func EncodeFloatPrecision(i int) EncoderOption
EncodeFloatPrecision sets precision when encoding floats.
func EncodeValidators ¶
func EncodeValidators(v ...Validator) EncoderOption
EncodeValidators sets the validators to be run before encoding an object. Will overwrite the default ones. So remeber to add the defaults as well if needed.
type EndMessage ¶
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"` }
EndMessage should always be the last object in any GS2-file-
type GS2 ¶
type GS2 struct { StartMessage StartMessage `gs2:"Start-message"` MeterReadings []MeterReading `gs2:"Meter-reading"` TimeSeries []TimeSeries `gs2:"Time-series"` EndMessage EndMessage `gs2:"End-message"` }
GS2 represents the data of a GS2 file.
type MeterReading ¶
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"` }
MeterReading contains a single value that is a channel reading at a given point in time.
type StartMessage ¶
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"` }
StartMessage should always be the first object in any GS2-file-
type TimeSeries ¶
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"` }
TimeSeries contains time series of metered values within the interval given by start and stop.