axdr

package
v0.0.0-...-07c0d0d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 24, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TagNull               dataTag = 0
	TagArray              dataTag = 1
	TagStructure          dataTag = 2
	TagBoolean            dataTag = 3
	TagBitString          dataTag = 4
	TagDoubleLong         dataTag = 5
	TagDoubleLongUnsigned dataTag = 6
	TagFloatingPoint      dataTag = 7
	TagOctetString        dataTag = 9
	TagVisibleString      dataTag = 10
	TagUTF8String         dataTag = 12
	TagBCD                dataTag = 13
	TagInteger            dataTag = 15
	TagLong               dataTag = 16
	TagUnsigned           dataTag = 17
	TagLongUnsigned       dataTag = 18
	TagCompactArray       dataTag = 19
	TagLong64             dataTag = 20
	TagLong64Unsigned     dataTag = 21
	TagEnum               dataTag = 22
	TagFloat32            dataTag = 23
	TagFloat64            dataTag = 24
	TagDateTime           dataTag = 25
	TagDate               dataTag = 26
	TagTime               dataTag = 27
	TagDontCare           dataTag = 255
)

Variables

View Source
var ErrLengthLess = errors.New("not enough byte length provided")
View Source
var ReversedTimeZone = false

Functions

func DecodeBCD

func DecodeBCD(src *[]byte) (outByte []byte, outVal int8, err error)

func DecodeBitString

func DecodeBitString(src *[]byte, length uint64) (outByte []byte, outVal string, err error)

func DecodeBoolean

func DecodeBoolean(src *[]byte) (outByte []byte, outVal bool, err error)

func DecodeDate

func DecodeDate(src *[]byte) (outByte []byte, outVal time.Time, err error)

Decode 5 bytes data into time.Time object year highbyte, year lowbyte, month, day of month, day of week

func DecodeDateTime

func DecodeDateTime(src *[]byte) (outByte []byte, outVal time.Time, err error)

Decode 12 bytes data into time.Time object year highbyte, year lowbyte, month, day of month, day of week, hour, minute, second, hundredths of second, deviation highbyte, -- interpreted as long in minutes of local time of UTC deviation lowbyte, clock status

func DecodeDoubleLong

func DecodeDoubleLong(src *[]byte) (outByte []byte, outVal int32, err error)

func DecodeDoubleLongUnsigned

func DecodeDoubleLongUnsigned(src *[]byte) (outByte []byte, outVal uint32, err error)

func DecodeEnum

func DecodeEnum(src *[]byte) (outByte []byte, outVal uint8, err error)

func DecodeFloat32

func DecodeFloat32(src *[]byte) (outByte []byte, outVal float32, err error)

func DecodeFloat64

func DecodeFloat64(src *[]byte) (outByte []byte, outVal float64, err error)

func DecodeInteger

func DecodeInteger(src *[]byte) (outByte []byte, outVal int8, err error)

func DecodeLength

func DecodeLength(src *[]byte) (outByte []byte, outVal uint64, err error)

func DecodeLong

func DecodeLong(src *[]byte) (outByte []byte, outVal int16, err error)

func DecodeLong64

func DecodeLong64(src *[]byte) (outByte []byte, outVal int64, err error)

func DecodeLong64Unsigned

func DecodeLong64Unsigned(src *[]byte) (outByte []byte, outVal uint64, err error)

func DecodeLongUnsigned

func DecodeLongUnsigned(src *[]byte) (outByte []byte, outVal uint16, err error)

func DecodeOctetString

func DecodeOctetString(src *[]byte, length uint64) (outByte []byte, outVal string, err error)

func DecodeTime

func DecodeTime(src *[]byte) (outByte []byte, outVal time.Time, err error)

Decode 4 bytes data into time.Time object hour, minute, second, hundredths

func DecodeUTF8String

func DecodeUTF8String(src *[]byte, length uint64) (outByte []byte, outVal string, err error)

func DecodeUnsigned

func DecodeUnsigned(src *[]byte) (outByte []byte, outVal uint8, err error)

func DecodeVisibleString

func DecodeVisibleString(src *[]byte, length uint64) (outByte []byte, outVal string, err error)

func EncodeArray

func EncodeArray(data []*DlmsData) ([]byte, error)

func EncodeBCD

func EncodeBCD(data int8) ([]byte, error)

binary coded decimal

func EncodeBCDs

func EncodeBCDs(data string) ([]byte, error)

Standard 8-4-2-1 decimal-only encoding note: this is not part of A-XDR encoder

func EncodeBitString

func EncodeBitString(data string) ([]byte, error)

Encodes string of binary into byte. If length of bitstring is not multiplication of 8 bits, the left over will be put as trailing zeros. Sample: "111"-> E0

func EncodeBoolean

func EncodeBoolean(data bool) ([]byte, error)

func EncodeDate

func EncodeDate(data time.Time) ([]byte, error)

Encodes a date of time object into 5 bytes data year highbyte, year lowbyte, month, day of month, day of week

func EncodeDateTime

func EncodeDateTime(data time.Time) ([]byte, error)

Encodes datetime of time object into 12 bytes data year highbyte, year lowbyte, month, day of month, day of week, hour, minute, second, hundredths of second, deviation highbyte, -- interpreted as long in minutes of local time of UTC deviation lowbyte, clock status -- 0x00 means ok, 0xFF means not specified

func EncodeDoubleLong

func EncodeDoubleLong(data int32) ([]byte, error)

func EncodeDoubleLongUnsigned

func EncodeDoubleLongUnsigned(data uint32) ([]byte, error)

func EncodeEnum

func EncodeEnum(data uint8) ([]byte, error)

func EncodeFloat32

func EncodeFloat32(data float32) ([]byte, error)

func EncodeFloat64

func EncodeFloat64(data float64) ([]byte, error)

func EncodeInteger

func EncodeInteger(data int8) ([]byte, error)

func EncodeLength

func EncodeLength(dataLength interface{}) ([]byte, error)

Encodes a number into correct byte according to A-XDR rule high-bit of first byte (x000 0000) will determine if first byte is L-of-length or not. If it is, then the rest bits are the value of L-of-length, else is the length itself. Sample (int -> hex). 3->03, 131->81 83, 25000->82 61 A8

func EncodeLong

func EncodeLong(data int16) ([]byte, error)

func EncodeLong64

func EncodeLong64(data int64) ([]byte, error)

func EncodeLong64Unsigned

func EncodeLong64Unsigned(data uint64) ([]byte, error)

func EncodeLongUnsigned

func EncodeLongUnsigned(data uint16) ([]byte, error)

func EncodeOctetString

func EncodeOctetString(data string) ([]byte, error)

An ordered sequence of octets (8 bit bytes) Obis / Logical Name is en/decoded using TagOctetString other than that, input will be processed as hexstring

func EncodeStructure

func EncodeStructure(data []*DlmsData) ([]byte, error)

func EncodeTime

func EncodeTime(data time.Time) ([]byte, error)

Encodes a time of time object into 4 bytes data hour, minute, second, hundredths

func EncodeUTF8String

func EncodeUTF8String(data string) ([]byte, error)

An ordered sequence of characters encoded as UTF-8

func EncodeUnsigned

func EncodeUnsigned(data uint8) ([]byte, error)

func EncodeVisibleString

func EncodeVisibleString(data string) ([]byte, error)

An ordered sequence of ASCII characters

func UnmarshalData

func UnmarshalData(data DlmsData, v interface{}) error

func ValidNumberType

func ValidNumberType(k interface{}) (reflect.Kind, error)

Check if input is a valid u/int 8-64

Types

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

func NewDataDecoder

func NewDataDecoder(ori *[]byte) *Decoder

Create new decode from either supplied byte slice pointer. It will remove first byte from source

func (*Decoder) Decode

func (dec *Decoder) Decode(ori *[]byte) (r DlmsData, err error)

Decode expect byte second after tag byte.

type DlmsData

type DlmsData struct {
	Tag   dataTag
	Value interface{}
}

func CreateAxdrArray

func CreateAxdrArray(data []*DlmsData) *DlmsData

func CreateAxdrBCD

func CreateAxdrBCD(data int8) *DlmsData

func CreateAxdrBitString

func CreateAxdrBitString(data string) *DlmsData

func CreateAxdrBoolean

func CreateAxdrBoolean(data bool) *DlmsData

func CreateAxdrDate

func CreateAxdrDate(data time.Time) *DlmsData

func CreateAxdrDateTime

func CreateAxdrDateTime(data time.Time) *DlmsData

func CreateAxdrDoubleLong

func CreateAxdrDoubleLong(data int32) *DlmsData

func CreateAxdrDoubleLongUnsigned

func CreateAxdrDoubleLongUnsigned(data uint32) *DlmsData

func CreateAxdrEnum

func CreateAxdrEnum(data uint8) *DlmsData

func CreateAxdrFloat32

func CreateAxdrFloat32(data float32) *DlmsData

func CreateAxdrFloat64

func CreateAxdrFloat64(data float64) *DlmsData

func CreateAxdrFloatingPoint

func CreateAxdrFloatingPoint(data float32) *DlmsData

func CreateAxdrInteger

func CreateAxdrInteger(data int8) *DlmsData

func CreateAxdrLong

func CreateAxdrLong(data int16) *DlmsData

func CreateAxdrLong64

func CreateAxdrLong64(data int64) *DlmsData

func CreateAxdrLong64Unsigned

func CreateAxdrLong64Unsigned(data uint64) *DlmsData

func CreateAxdrLongUnsigned

func CreateAxdrLongUnsigned(data uint16) *DlmsData

func CreateAxdrOctetString

func CreateAxdrOctetString(data interface{}) *DlmsData

expect Hex string as input

func CreateAxdrStructure

func CreateAxdrStructure(data []*DlmsData) *DlmsData

func CreateAxdrTime

func CreateAxdrTime(data time.Time) *DlmsData

func CreateAxdrUTF8String

func CreateAxdrUTF8String(data string) *DlmsData

expect UTF-8 strings as input

func CreateAxdrUnsigned

func CreateAxdrUnsigned(data uint8) *DlmsData

func CreateAxdrVisibleString

func CreateAxdrVisibleString(data string) *DlmsData

expect ASCII strings as input

func MarshalData

func MarshalData(v interface{}) (*DlmsData, error)

func (*DlmsData) Encode

func (d *DlmsData) Encode() (out []byte, err error)

Encodes Value of DlmsData object according to the Tag It will panic if Value is nil, data type does not match the Tag or if failed happen in encoding length/value level.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL