config

package
v0.2024.4 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type COV

type COV struct {
	Method    COVMethod `json:"method,omitempty"`
	PollDelay Duration  `json:"pollDelay,omitempty"`
}

type COVMethod

type COVMethod string
const (
	COVMethodAuto  COVMethod = "auto"
	COVMethodPoll  COVMethod = "poll"
	COVMethodCov   COVMethod = "cov"
	COVMethodLocal COVMethod = "local"
	COVMethodNone  COVMethod = "none"
)

type Comm

type Comm struct {
	IP *netip.AddrPort `json:"ip,omitempty"`
	// the destination BACnet network
	// this is used if the target BACnet device is not IP, but being proxied through a BACnet IP router
	// see: http://www.bacnetwiki.com/wiki/index.php?title=Network_Layer_Protocol_Data_Unit
	Destination *Destination `json:"destination,omitempty"`
}

func (*Comm) ToAddress

func (c *Comm) ToAddress() (bactypes.Address, error)

type Destination

type Destination struct {
	// Network is the Destination Network 1-65534, or 65535 for broadcast
	// http://www.bacnetwiki.com/wiki/index.php?title=Destination_Network
	Network uint16 `json:"network,omitempty"`
	// Address is in dot-notation when multiple octets
	// could be upto 18, but in practice 6 or less
	// http://www.bacnetwiki.com/wiki/index.php?title=MAC_Layer_Address
	Address DestinationAddress `json:"address,omitempty"`
}

Destination representation BACnet NPDU destination settings see: http://www.bacnetwiki.com/wiki/index.php?title=Network_Layer_Protocol_Data_Unit

type DestinationAddress

type DestinationAddress string

func (DestinationAddress) Bytes

func (d DestinationAddress) Bytes() ([]byte, error)

type Device

type Device struct {
	Name  string                  `json:"name,omitempty"`
	Title string                  `json:"title,omitempty"`
	Comm  *Comm                   `json:"comm,omitempty"`
	ID    bactypes.ObjectInstance `json:"id,omitempty"`

	COV *COV `json:"cov,omitempty"`

	// Metadata applied to any traits sharing this devices name.
	Metadata *traits.Metadata `json:"metadata,omitempty"`

	DiscoverObjects      *bool    `json:"discoverObjects,omitempty"`
	Objects              []Object `json:"objects,omitempty"`
	DefaultWritePriority uint     `json:"defaultWritePriority,omitempty"`
}

type DeviceRef

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

func NewDeviceRef

func NewDeviceRef(name string) *DeviceRef

func NewDeviceRefID

func NewDeviceRefID(id bactypes.ObjectInstance) *DeviceRef

func (DeviceRef) Lookup

func (d DeviceRef) Lookup(ctx known.Context) (bactypes.Device, error)

func (DeviceRef) MarshalJSON

func (d DeviceRef) MarshalJSON() ([]byte, error)

func (*DeviceRef) UnmarshalJSON

func (d *DeviceRef) UnmarshalJSON(bytes []byte) error

type Discovery

type Discovery struct {
	Min        int      `json:"min,omitempty"`
	Max        int      `json:"max,omitempty"`
	Chunk      int      `json:"chunk,omitempty"`
	ChunkDelay Duration `json:"chunkDelay,omitempty"`
}

type Duration

type Duration struct {
	time.Duration
}

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() ([]byte, error)

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(b []byte) error

type Object

type Object struct {
	ID    ObjectID `json:"id"`
	Name  string   `json:"name,omitempty"`
	Title string   `json:"title,omitempty"`

	COV *COV `json:"COV,omitempty"`

	Trait    trait.Name       `json:"trait,omitempty"`
	Metadata *traits.Metadata `json:"metadata,omitempty"` // applied to any traits created from this object

	Priorities []Priority `json:"priorities,omitempty"`
	Properties []Property `json:"properties,omitempty"`
}

func (Object) String

func (o Object) String() string

type ObjectID

type ObjectID bactypes.ObjectID

func ObjectIDFromString

func ObjectIDFromString(str string) (ObjectID, error)

func (ObjectID) MarshalJSON

func (o ObjectID) MarshalJSON() ([]byte, error)

func (ObjectID) String

func (o ObjectID) String() string

func (*ObjectID) UnmarshalJSON

func (o *ObjectID) UnmarshalJSON(bytes []byte) error

type ObjectRef

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

func NewObjectRef

func NewObjectRef(name string) *ObjectRef

func NewObjectRefID

func NewObjectRefID(id ObjectID) *ObjectRef

func (ObjectRef) Lookup

func (o ObjectRef) Lookup(device bactypes.Device, ctx known.Context) (bactypes.Object, error)

func (ObjectRef) MarshalJSON

func (o ObjectRef) MarshalJSON() ([]byte, error)

func (*ObjectRef) UnmarshalJSON

func (o *ObjectRef) UnmarshalJSON(bytes []byte) error

type Priority

type Priority struct {
	Name  string `json:"name,omitempty"`
	Level uint8  `json:"level,omitempty"`
}

type Property

type Property struct {
	Name string     `json:"name,omitempty"`
	ID   PropertyID `json:"id,omitempty"`
}

type PropertyID

type PropertyID property.ID

func (PropertyID) MarshalJSON

func (p PropertyID) MarshalJSON() ([]byte, error)

func (PropertyID) String

func (p PropertyID) String() string

func (*PropertyID) UnmarshalJSON

func (p *PropertyID) UnmarshalJSON(bytes []byte) error

type RawTrait

type RawTrait struct {
	Trait
	Raw json.RawMessage `json:"-"`
}

func (*RawTrait) MarshalJSON

func (c *RawTrait) MarshalJSON() ([]byte, error)

func (*RawTrait) UnmarshalJSON

func (c *RawTrait) UnmarshalJSON(buf []byte) error

type Root

type Root struct {
	driver.BaseConfig

	LocalInterface string `json:"localInterface,omitempty"`
	LocalPort      uint16 `json:"localPort,omitempty"`

	MaxConcurrentTransactions uint8 `json:"maxConcurrentTransactions,omitempty"`

	Discovery                *Discovery `json:"discovery,omitempty"`
	ForceDiscovery           bool       `json:"forceDiscovery,omitempty"`
	IncludeDiscoveredDevices bool       `json:"includeDiscoveredDevices,omitempty"`

	DeviceNamePrefix string `json:"deviceNamePrefix"` // defaults to "bacnet/device/" if absent in json or using Defaults
	ObjectNamePrefix string `json:"objectNamePrefix"` // defaults to "obj/" if absent in json, or using Defaults

	DiscoverObjects bool `json:"discoverObjects,omitempty"`

	COV *COV `json:"cov,omitempty"`

	// Metadata is applied to all announced names.
	Metadata *traits.Metadata `json:"metadata,omitempty"`

	Devices []Device   `json:"devices,omitempty"`
	Traits  []RawTrait `json:"traits,omitempty"`
}

Root represents a full collection of related configuration properties

func Defaults

func Defaults() Root

func Read

func Read(r io.Reader) (Root, error)

Read decodes r into a config Root.

func ReadBytes

func ReadBytes(data []byte) (root Root, err error)

ReadBytes decodes bytes into a config Root.

func ReadFile

func ReadFile(name string) (Root, error)

ReadFile reads from the named file a config Root.

type Trait

type Trait struct {
	Name     string           `json:"name,omitempty"`
	Kind     trait.Name       `json:"kind,omitempty"`
	Metadata *traits.Metadata `json:"metadata,omitempty"`
	// poll period used to poll the objects for pull updates
	// defaults to 10s
	PollPeriod *Duration `json:"pollPeriod,omitempty"`
	// how long to wait when running a poll for it to respond. Defaults to PollPeriod.
	PollTimeout *Duration `json:"pollTimeout,omitempty"`
	// When reading multiple properties, split the properties into chunks of this size and execute in parallel.
	// 0 means do not chunk.
	ChunkSize int `json:"chunkSize,omitempty"`
}

Trait is the common configuration for bacnet device traits. Specific implementations that pull objects together into a trait should embed this type into their specific config types.

type OnOffConfig struct {
  Trait
  Value *ValueSource `json:"value,omitempty"`
}

func (*Trait) PollPeriodDuration

func (t *Trait) PollPeriodDuration() time.Duration

func (*Trait) PollTimeoutDuration

func (t *Trait) PollTimeoutDuration() time.Duration

type ValueSource

type ValueSource struct {
	Device   *DeviceRef  `json:"device,omitempty"`
	Object   *ObjectRef  `json:"object,omitempty"`
	Property *PropertyID `json:"property,omitempty"`
	// used for converting simple units like kW -> W.
	// The value from the source will be multiplied by Scale when reading, and divided when writing.
	// For example if the trait is in watts and the device is in kW then Scale should be 1000 (aka kilo).
	Scale float64 `json:"scale,omitempty"`
}

ValueSource configures a single object property as the source of some trait value.

func (ValueSource) Lookup

Lookup finds the gobacnet device, object, and property this ValueSource refers to.

func (ValueSource) Scaled

func (vs ValueSource) Scaled(v any) any

Scaled returns v scaled by the Scale factor. If vs.Scale is 0 or v is not a number then v is returned unchanged.

Jump to

Keyboard shortcuts

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