Documentation ¶
Index ¶
- Constants
- Variables
- func DecodeToIEDataType(dataType IEDataType, val interface{}) (interface{}, error)
- func EncodeToIEDataType(dataType IEDataType, val interface{}, buff *bytes.Buffer) (interface{}, error)
- func IsValidDataType(tp IEDataType) bool
- func NewDataRecord(id uint16) *dataRecord
- func NewTemplateRecord(count uint16, id uint16) *templateRecord
- type ContentType
- type IEDataType
- type InfoElement
- type InfoElementWithValue
- type Message
- type MsgBuffer
- type Record
- type Set
Constants ¶
View Source
const ( // TemplateRefreshTimeOut is the template refresh time out for exporting process TemplateRefreshTimeOut uint32 = 1800 // TemplateTTL is the template time to live for collecting process TemplateTTL = TemplateRefreshTimeOut * 3 // TemplateSetID is the setID for template record TemplateSetID uint16 = 2 )
View Source
const (
MaxTcpSocketMsgSize uint16 = 65535
)
View Source
const VariableLength uint16 = 65535
Variables ¶
View Source
var InfoElementLength = map[IEDataType]uint16{ OctetArray: VariableLength, Unsigned8: 1, Unsigned16: 2, Unsigned32: 4, Unsigned64: 8, Signed8: 1, Signed16: 2, Signed32: 4, Signed64: 8, Float32: 4, Float64: 8, Boolean: 1, MacAddress: 6, String: VariableLength, DateTimeSeconds: 8, DateTimeMilliseconds: 8, DateTimeMicroseconds: 8, DateTimeNanoseconds: 8, Ipv4Address: 4, Ipv6Address: 16, BasicList: VariableLength, SubTemplateList: VariableLength, SubTemplateMultiList: VariableLength, InvalidDataType: 0, }
Functions ¶
func DecodeToIEDataType ¶ added in v0.3.0
func DecodeToIEDataType(dataType IEDataType, val interface{}) (interface{}, error)
DecodeToIEDataType is to decode to specific type
func EncodeToIEDataType ¶ added in v0.3.0
func EncodeToIEDataType(dataType IEDataType, val interface{}, buff *bytes.Buffer) (interface{}, error)
EncodeToIEDataType is to encode data to specific type to the buff
func IsValidDataType ¶
func IsValidDataType(tp IEDataType) bool
func NewDataRecord ¶
func NewDataRecord(id uint16) *dataRecord
func NewTemplateRecord ¶
Types ¶
type ContentType ¶
type ContentType uint8
const ( Template ContentType = iota Data // Add OptionsTemplate too when it is supported Undefined = 255 )
type IEDataType ¶
type IEDataType uint8
const ( OctetArray IEDataType = iota Unsigned8 Unsigned16 Unsigned32 Unsigned64 Signed8 Signed16 Signed32 Signed64 Float32 Float64 Boolean MacAddress String DateTimeSeconds DateTimeMilliseconds DateTimeMicroseconds DateTimeNanoseconds Ipv4Address Ipv6Address BasicList SubTemplateList SubTemplateMultiList InvalidDataType = 255 )
func IENameToType ¶
func IENameToType(name string) IEDataType
type InfoElement ¶
type InfoElement struct { // Name of the IE Name string // Identifier for IE; follows Section 4.3 of RFC7013 ElementId uint16 // dataType follows the specification in RFC7012(section 3.1)/RFC5610(section 3.1) DataType IEDataType // Enterprise number or 0 (0 for IANA registry) EnterpriseId uint32 // Length of IE Len uint16 }
InfoElement (IE) follows the specification in Section 2.1 of RFC7012
func NewInfoElement ¶
func NewInfoElement(name string, ieID uint16, ieType IEDataType, entID uint32, len uint16) *InfoElement
type InfoElementWithValue ¶ added in v0.3.0
type InfoElementWithValue struct { Element *InfoElement Value interface{} }
InfoElementWithValue represents mapping from element to value for data records
func NewInfoElementWithValue ¶ added in v0.3.0
func NewInfoElementWithValue(element *InfoElement, value interface{}) *InfoElementWithValue
type Message ¶ added in v0.2.0
type Message struct { Version uint16 BufferLength uint16 SeqNumber uint32 ObsDomainID uint32 ExportTime uint32 ExportAddress string Set Set }
data struct of processed message
type MsgBuffer ¶
type MsgBuffer struct {
// contains filtered or unexported fields
}
func NewMsgBuffer ¶
func NewMsgBuffer() *MsgBuffer
func (*MsgBuffer) GetDataRecFlag ¶
func (*MsgBuffer) GetMsgBuffer ¶
func (*MsgBuffer) SetDataRecFlag ¶
type Record ¶
type Record interface { PrepareRecord() (uint16, error) AddInfoElement(element *InfoElementWithValue, isDecoding bool) (uint16, error) // TODO: Functions for multiple elements as well. GetBuffer() *bytes.Buffer GetTemplateID() uint16 GetFieldCount() uint16 GetOrderedElementList() []*InfoElementWithValue GetInfoElementWithValue(name string) (*InfoElementWithValue, bool) GetMinDataRecordLen() uint16 }
Click to show internal directories.
Click to hide internal directories.