bacnet

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DeviceStateOnline   = 0
	DeviceStateUnstable = 1
	DeviceStateOffline  = 2
	DeviceStateIsolated = 3
)
View Source
const ArrayAll = 0xFFFFFFFF

ArrayAll is used when reading/writing to a property to read/write the entire array

Variables

This section is empty.

Functions

func NewBACnetDriver

func NewBACnetDriver() drv.Driver

Types

type BACnetDriver

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

func (*BACnetDriver) Connect

func (d *BACnetDriver) Connect(ctx context.Context) error

func (*BACnetDriver) Disconnect

func (d *BACnetDriver) Disconnect() error

func (*BACnetDriver) GetConnectionMetrics

func (d *BACnetDriver) GetConnectionMetrics() (connectionSeconds int64, reconnectCount int64, localAddr string, remoteAddr string, lastDisconnectTime time.Time)

func (*BACnetDriver) GetMetrics

func (d *BACnetDriver) GetMetrics() model.ChannelMetrics

GetMetrics 返回BACnet驱动的详细指标

func (*BACnetDriver) Health

func (d *BACnetDriver) Health() drv.HealthStatus

func (*BACnetDriver) Init

func (d *BACnetDriver) Init(config model.DriverConfig) error

func (*BACnetDriver) ReadPoints

func (d *BACnetDriver) ReadPoints(ctx context.Context, points []model.Point) (map[string]model.Value, error)

func (*BACnetDriver) Scan

func (d *BACnetDriver) Scan(ctx context.Context, params map[string]any) (any, error)

Scan performs a device discovery (WhoIs) and optionally reads device details

func (*BACnetDriver) ScanObjects

func (d *BACnetDriver) ScanObjects(ctx context.Context, config map[string]any) (any, error)

ScanObjects implements ObjectScanner interface

func (*BACnetDriver) SetBACnetAddressNotifier added in v0.0.7

func (d *BACnetDriver) SetBACnetAddressNotifier(notifier drv.BACnetAddressNotifier)

func (*BACnetDriver) SetDeviceConfig

func (d *BACnetDriver) SetDeviceConfig(config map[string]any) error

func (*BACnetDriver) SetSlaveID

func (d *BACnetDriver) SetSlaveID(slaveID uint8) error

func (*BACnetDriver) WritePoint

func (d *BACnetDriver) WritePoint(ctx context.Context, point model.Point, value any) error

type Client

type Client interface {
	io.Closer
	IsRunning() bool
	ClientRun()
	WhoIs(wh *WhoIsOpts) ([]btypes.Device, error)
	WhatIsNetworkNumber() []*btypes.Address
	IAm(dest btypes.Address, iam btypes.IAm) error
	WhoIsRouterToNetwork() (resp *[]btypes.Address)
	Objects(dev btypes.Device) (btypes.Device, error)
	ReadProperty(dest btypes.Device, rp btypes.PropertyData) (btypes.PropertyData, error)
	ReadMultiProperty(dev btypes.Device, rp btypes.MultiplePropertyData) (btypes.MultiplePropertyData, error)
	ReadPropertyWithTimeout(dest btypes.Device, rp btypes.PropertyData, timeout time.Duration) (btypes.PropertyData, error)
	ReadMultiPropertyWithTimeout(dev btypes.Device, rp btypes.MultiplePropertyData, timeout time.Duration) (btypes.MultiplePropertyData, error)
	WriteProperty(dest btypes.Device, wp btypes.PropertyData) error
	WriteMultiProperty(dev btypes.Device, wp btypes.MultiplePropertyData) error
}

func NewClient

func NewClient(cb *ClientBuilder) (Client, error)

NewClient creates a new client with the given interface and

type ClientBuilder

type ClientBuilder struct {
	DataLink   datalink.DataLink
	Interface  string
	Ip         string
	Port       int
	SubnetCIDR int
	MaxPDU     uint16
}

type DeviceConfig

type DeviceConfig struct {
	DeviceID int
	IP       string
	Port     int
}

type DeviceContext

type DeviceContext struct {
	Device              btypes.Device
	Scheduler           *PointScheduler
	Config              DeviceConfig
	DeviceKey           string
	LastDiscovery       time.Time
	State               int
	ConsecutiveFailures int
	IsolationUntil      time.Time
	IsolationCount      int
	LastValues          map[string]model.Value
	CacheMu             sync.RWMutex
	ReadMu              sync.Mutex
	// contains filtered or unexported fields
}

type ObjectResult

type ObjectResult struct {
	Type         string `json:"type"`
	Instance     int    `json:"instance"`
	Name         string `json:"name,omitempty"`
	Description  string `json:"description,omitempty"`
	Units        string `json:"units,omitempty"`
	PresentValue any    `json:"present_value,omitempty"`
	StatusFlags  string `json:"status_flags,omitempty"`
	Reliability  string `json:"reliability,omitempty"`
	DiffStatus   string `json:"diff_status"` // new, existing, removed
}

type PointRuntime

type PointRuntime struct {
	Point         model.Point
	FailCount     int
	LastSuccess   time.Time
	State         string // OK, SKIPPED
	CooldownUntil time.Time
}

PointRuntime Runtime state of a point

type PointScheduler

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

PointScheduler implements the scheduling logic for BACnet points

func NewPointScheduler

func NewPointScheduler(client Client, targetDevice btypes.Device, groupThreshold uint16, instructionInterval time.Duration, cooldownDuration time.Duration, useDataformat bool) *PointScheduler

func (*PointScheduler) Read

func (s *PointScheduler) Read(ctx context.Context, points []model.Point) (map[string]model.Value, error)

func (*PointScheduler) Write

func (s *PointScheduler) Write(ctx context.Context, writes []PointWriteRequest) error

type PointWriteRequest

type PointWriteRequest struct {
	Point    model.Point
	Value    any
	Priority *uint8
}

PointWriteRequest represents a request to write a value to a point

type ScanResult

type ScanResult struct {
	DeviceID     int    `json:"device_id"`
	IP           string `json:"ip"`
	Port         int    `json:"port"`
	Network      uint16 `json:"network_number"`
	VendorID     uint32 `json:"vendor_id"`
	VendorName   string `json:"vendor_name"`
	ModelName    string `json:"model_name"`
	ObjectName   string `json:"object_name"`
	MaxAPDU      uint32 `json:"max_apdu"`
	Segmentation uint32 `json:"segmentation"`
	Status       string `json:"status"`
	DiffStatus   string `json:"diff_status,omitempty"` // new, existing
}

type SetBroadcastType

type SetBroadcastType struct {
	Set     bool
	BacFunc btypes.BacFunc
}

type WhoIsOpts

type WhoIsOpts struct {
	Low             int             `json:"low"`
	High            int             `json:"high"`
	GlobalBroadcast bool            `json:"global_broadcast"`
	NetworkNumber   uint16          `json:"network_number"`
	Destination     *btypes.Address `json:"-"`
}

Jump to

Keyboard shortcuts

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