types

package
v0.0.0-...-1d4abbb Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2020 License: GPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// WhoIsAll is used when scanning a range. Using this as one of the two ranges,
	// will scan all available devices
	WhoIsAll = -1
	ArrayAll = 0xFFFFFFFF
)
View Source
const (
	AnalogInputStr       = "Analog Input"
	AnalogOutputStr      = "Analog Output"
	AnalogValueStr       = "Analog Value"
	BinaryInputStr       = "Binary Input"
	BinaryOutputStr      = "Binary Output"
	BinaryValueStr       = "Binary Value"
	DeviceTypeStr        = "Device"
	FileStr              = "File"
	NotificationClassStr = "Notification Class"
	MultiStateValueStr   = "Multi-State Value"
	MultiStateInputStr   = "Multi-State Input"
	TrendLogStr          = "Trend Log"
	CharacterStringStr   = "Character String"
)
View Source
const BVLCTypeBacnetIP = 0x81

BVLCTypeBacnetIP is the only valid type for the BVLC layer as of 2002. Additional types may be added in the future

View Source
const DefaultHopCount uint8 = 255
View Source
const MaxAPDU = MaxAPDUOverIP
View Source
const MaxAPDUOverIP = 1476
View Source
const (
	MaxInstance = 0x3FFFFF
)
View Source
const ProtocolVersion uint8 = 1
View Source
const UnspecifiedTime = 0xFF

UnspecifiedTime means that this time is triggered through out a period. An example of this is 02:FF:FF:FF will trigger all through out 2 am

Variables

This section is empty.

Functions

func GetUnits

func GetUnits(i int) string

Types

type APDU

type APDU struct {
	DataType                  PDUType
	SegmentedMessage          bool
	MoreFollows               bool
	SegmentedResponseAccepted bool
	MaxSegs                   uint
	MaxApdu                   uint
	InvokeId                  uint8
	Sequence                  uint8
	WindowNumber              uint8
	Service                   ServiceConfirmed
	UnconfirmedService        ServiceUnconfirmed
	Error                     struct {
		Class uint32
		Code  uint32
	}

	// This is the raw data passed based on the service
	RawData []byte
}

APDU - Application Protocol Data Unit

func (*APDU) IsConfirmedServiceRequest

func (a *APDU) IsConfirmedServiceRequest() bool

IsConfirmedServiceRequest checks to see if the APDU is in the list of known services

type Address

type Address struct {
	Net    uint16
	Len    uint8
	MacLen uint8
	Mac    []uint8
	Adr    []uint8
}

func UDPToAddress

func UDPToAddress(n *net.UDPAddr) Address

Address converts a given udp address into a bacnet address

func (*Address) IsBroadcast

func (a *Address) IsBroadcast() bool

IsBroadcast returns if the address is a broadcast address

func (*Address) IsSubBroadcast

func (a *Address) IsSubBroadcast() bool

IsSubBroadcast checks to see if packet is meant to be a network specific broadcast

func (*Address) IsUnicast

func (a *Address) IsUnicast() bool

IsUnicast checks to see if packet is meant to be a unicast

func (*Address) SetBroadcast

func (a *Address) SetBroadcast(b bool)

func (*Address) UDPAddr

func (a *Address) UDPAddr() (net.UDPAddr, error)

UDPAddr parses the mac address and returns an proper net.UDPAddr

type BVLC

type BVLC struct {
	Type     byte
	Function BacFunc

	// Length includes the length of Type, Function, and Length. (4 bytes) It also
	// has the length of the data field after
	Length uint16
	Data   []byte
}

type BacFunc

type BacFunc byte

Bacnet Fuction

const (
	BacFuncResult                          BacFunc = 0
	BacFuncWriteBroadcastDistributionTable BacFunc = 1
	BacFuncBroadcastDistributionTable      BacFunc = 2
	BacFuncBroadcastDistributionTableAck   BacFunc = 3
	BacFuncForwardedNPDU                   BacFunc = 4
	BacFuncUnicast                         BacFunc = 10
	BacFuncBroadcast                       BacFunc = 11
)

List of possible BACnet functions

type Date

type Date struct {
	Year  int
	Month int
	Day   int
	// Bacnet has an option to only do operations on even or odd months
	EvenMonth      bool
	OddMonth       bool
	EvenDay        bool
	OddDay         bool
	LastDayOfMonth bool
	DayOfWeek      DayOfWeek
}

type DayOfWeek

type DayOfWeek int
const (
	None      DayOfWeek = iota
	Monday    DayOfWeek = iota
	Tuesday   DayOfWeek = iota
	Wednesday DayOfWeek = iota
	Thursday  DayOfWeek = iota
	Friday    DayOfWeek = iota
	Saturday  DayOfWeek = iota
	Sunday    DayOfWeek = iota
)

type Device

type Device struct {
	ID           ObjectID
	MaxApdu      uint32
	Segmentation Enumerated
	Vendor       uint32
	Addr         Address
	Objects      ObjectMap
}

func (Device) ObjectSlice

func (dev Device) ObjectSlice() []Object

ObjectSlice returns all the objects in the device as a slice (not thread-safe)

type Enumerated

type Enumerated uint32

type IAm

type IAm struct {
	ID           ObjectID
	MaxApdu      uint32
	Segmentation Enumerated
	Vendor       uint32
	Addr         Address
}

type NPDU

type NPDU struct {
	Version uint8

	// Destination (optional)
	Destination *Address

	// Source (optional)
	Source *Address

	VendorId uint16

	IsNetworkLayerMessage   bool
	NetworkLayerMessageType uint8
	ExpectingReply          bool
	Priority                NPDUPriority
	HopCount                uint8
}

type NPDUPriority

type NPDUPriority byte
const (
	LifeSafety        NPDUPriority = 3
	CriticalEquipment NPDUPriority = 2
	Urgent            NPDUPriority = 1
	Normal            NPDUPriority = 0
)

type Object

type Object struct {
	Name        string
	Description string
	ID          ObjectID
	Properties  []Property `json:",omitempty"`
}

type ObjectID

type ObjectID struct {
	Type     ObjectType
	Instance ObjectInstance
}

func (ObjectID) String

func (id ObjectID) String() string

String returns a pretty print of the ObjectID structure

type ObjectInstance

type ObjectInstance uint32

type ObjectMap

type ObjectMap map[ObjectType]map[ObjectInstance]Object

func (ObjectMap) Len

func (o ObjectMap) Len() int

Len returns the total number of entries within the object map.

func (ObjectMap) MarshalJSON

func (om ObjectMap) MarshalJSON() ([]byte, error)

func (ObjectMap) UnmarshalJSON

func (om ObjectMap) UnmarshalJSON(data []byte) error

type ObjectType

type ObjectType uint16
const (
	AnalogInput       ObjectType = 0
	AnalogOutput      ObjectType = 1
	AnalogValue       ObjectType = 2
	BinaryInput       ObjectType = 3
	BinaryOutput      ObjectType = 4
	BinaryValue       ObjectType = 5
	DeviceType        ObjectType = 8
	File              ObjectType = 10
	MultiStateInput   ObjectType = 13
	NotificationClass ObjectType = 15
	MultiStateValue   ObjectType = 19
	TrendLog          ObjectType = 20
	CharacterString   ObjectType = 40
)

func GetType

func GetType(s string) ObjectType

func (ObjectType) String

func (t ObjectType) String() string

type PDUType

type PDUType uint8

pduType encomposes all valid pdus.

const (
	ConfirmedServiceRequest   PDUType = 0
	UnconfirmedServiceRequest PDUType = 0x10
	ComplexAck                PDUType = 0x30
	SegmentAck                PDUType = 0x40
	Error                     PDUType = 0x50
	Reject                    PDUType = 0x60
	Abort                     PDUType = 0x70
)

pdu requests

type Property

type Property struct {
	Type       uint32
	ArrayIndex uint32
	Data       interface{}
}

type ReadMultipleProperty

type ReadMultipleProperty struct {
	Objects    []Object
	ErrorClass uint8
	ErrorCode  uint8
}

func (ReadMultipleProperty) String

func (rp ReadMultipleProperty) String() string

String returns a pretty print of the read multiple property structure

type ReadPropertyData

type ReadPropertyData struct {
	InvokeID   uint16
	Object     Object
	ErrorClass uint8
	ErrorCode  uint8
}

type ServiceConfirmed

type ServiceConfirmed uint8
const (
	/* Alarm and Event Services */
	ServiceConfirmedAcknowledgeAlarm     ServiceConfirmed = 0
	ServiceConfirmedCOVNotification      ServiceConfirmed = 1
	ServiceConfirmedEventNotification    ServiceConfirmed = 2
	ServiceConfirmedGetAlarmSummary      ServiceConfirmed = 3
	ServiceConfirmedGetEnrollmentSummary ServiceConfirmed = 4
	ServiceConfirmedGetEventInformation  ServiceConfirmed = 29
	ServiceConfirmedSubscribeCOV         ServiceConfirmed = 5
	ServiceConfirmedSubscribeCOVProperty ServiceConfirmed = 28
	ServiceConfirmedLifeSafetyOperation  ServiceConfirmed = 27
	/* File Access Services */
	ServiceConfirmedAtomicReadFile  ServiceConfirmed = 6
	ServiceConfirmedAtomicWriteFile ServiceConfirmed = 7
	/* Object Access Services */
	ServiceConfirmedAddListElement      ServiceConfirmed = 8
	ServiceConfirmedRemoveListElement   ServiceConfirmed = 9
	ServiceConfirmedCreateObject        ServiceConfirmed = 10
	ServiceConfirmedDeleteObject        ServiceConfirmed = 11
	ServiceConfirmedReadProperty        ServiceConfirmed = 12
	ServiceConfirmedReadPropConditional ServiceConfirmed = 13
	ServiceConfirmedReadPropMultiple    ServiceConfirmed = 14
	ServiceConfirmedReadRange           ServiceConfirmed = 26
	ServiceConfirmedWriteProperty       ServiceConfirmed = 15
	ServiceConfirmedWritePropMultiple   ServiceConfirmed = 16
	/* Remote Device Management Services */
	ServiceConfirmedDeviceCommunicationControl ServiceConfirmed = 17
	ServiceConfirmedPrivateTransfer            ServiceConfirmed = 18
	ServiceConfirmedTextMessage                ServiceConfirmed = 19
	ServiceConfirmedReinitializeDevice         ServiceConfirmed = 20
	/* Virtual Terminal Services */
	ServiceConfirmedVTOpen  ServiceConfirmed = 21
	ServiceConfirmedVTClose ServiceConfirmed = 22
	ServiceConfirmedVTData  ServiceConfirmed = 23
	/* Security Services */
	ServiceConfirmedAuthenticate ServiceConfirmed = 24
	ServiceConfirmedRequestKey   ServiceConfirmed = 25
)

func (*ServiceConfirmed) String

func (s *ServiceConfirmed) String() string

type ServiceUnconfirmed

type ServiceUnconfirmed uint8
const (
	ServiceUnconfirmedIAm               ServiceUnconfirmed = 0
	ServiceUnconfirmedIHave             ServiceUnconfirmed = 1
	ServiceUnconfirmedCOVNotification   ServiceUnconfirmed = 2
	ServiceUnconfirmedEventNotification ServiceUnconfirmed = 3
	ServiceUnconfirmedPrivateTransfer   ServiceUnconfirmed = 4
	ServiceUnconfirmedTextMessage       ServiceUnconfirmed = 5
	ServiceUnconfirmedTimeSync          ServiceUnconfirmed = 6
	ServiceUnconfirmedWhoHas            ServiceUnconfirmed = 7
	ServiceUnconfirmedWhoIs             ServiceUnconfirmed = 8
	ServiceUnconfirmedUTCTimeSync       ServiceUnconfirmed = 9
	ServiceUnconfirmedWriteGroup        ServiceUnconfirmed = 10
	/* Other services to be added as they are defined. */
	/* All choice values in this production are reserved */
	/* for definition by ASHRAE. */
	/* Proprietary extensions are made by using the */
	/* UnconfirmedPrivateTransfer service. See Clause 23. */
	MaxServiceUnconfirmed ServiceUnconfirmed = 11
)

type Time

type Time struct {
	Hour        int
	Minute      int
	Second      int
	Millisecond int
}

Jump to

Keyboard shortcuts

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