Documentation
¶
Index ¶
- Constants
- func NewBACnetDriver() drv.Driver
- type BACnetDriver
- func (d *BACnetDriver) Connect(ctx context.Context) error
- func (d *BACnetDriver) Disconnect() error
- func (d *BACnetDriver) GetConnectionMetrics() (connectionSeconds int64, reconnectCount int64, localAddr string, ...)
- func (d *BACnetDriver) GetMetrics() model.ChannelMetrics
- func (d *BACnetDriver) Health() drv.HealthStatus
- func (d *BACnetDriver) Init(config model.DriverConfig) error
- func (d *BACnetDriver) ReadPoints(ctx context.Context, points []model.Point) (map[string]model.Value, error)
- func (d *BACnetDriver) Scan(ctx context.Context, params map[string]any) (any, error)
- func (d *BACnetDriver) ScanObjects(ctx context.Context, config map[string]any) (any, error)
- func (d *BACnetDriver) ScheduleReconnect(ctx context.Context, timeout time.Duration)
- func (d *BACnetDriver) SetBACnetAddressNotifier(notifier drv.BACnetAddressNotifier)
- func (d *BACnetDriver) SetDeviceConfig(config map[string]any) error
- func (d *BACnetDriver) SetSlaveID(slaveID uint8) error
- func (d *BACnetDriver) WritePoint(ctx context.Context, point model.Point, value any) error
- type DeviceConfig
- type DeviceContext
- type ObjectResult
- type PointRuntime
- type PointScheduler
- type PointWriteRequest
- type ScanResult
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 ¶
Types ¶
type BACnetDriver ¶
type BACnetDriver struct {
// contains filtered or unexported fields
}
func (*BACnetDriver) Disconnect ¶
func (d *BACnetDriver) Disconnect() error
func (*BACnetDriver) GetConnectionMetrics ¶
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 (*BACnetDriver) Scan ¶
Scan performs BACnet device discovery using a four-strategy progressive approach aligned with the reference test report (策略1→策略4):
- 策略1: 标准广播 WhoIs (255.255.255.255:47808)
- 策略2: 子网广播 WhoIs (computed from localIP/subnetCIDR)
- 策略3: 单播探测 (target_ip + multi-port ReadProperty)
- 策略4: 最终确认 (逐设备 ReadProperty ObjectName)
Params:
- interface_ip: local NIC IP to bind UDP socket (e.g. "192.168.3.230")
- target_ip: remote target IP to scan (e.g. "192.168.3.115"); if empty, broadcast
- mode: "deep"/"full" for object scan on discovered devices
- device_id: if set, triggers ScanObjects instead of device discovery
func (*BACnetDriver) ScanObjects ¶
ScanObjects implements ObjectScanner interface ScanObjects 实现 ObjectScanner 接口,扫描设备下的 BACnet 对象
func (*BACnetDriver) ScheduleReconnect ¶ added in v0.0.9
func (d *BACnetDriver) ScheduleReconnect(ctx context.Context, timeout time.Duration)
ScheduleReconnect schedules a reconnection attempt for the BACnet driver.
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 ¶
type DeviceConfig ¶
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"`
Writable bool `json:"writable"`
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 (*PointScheduler) Write ¶
func (s *PointScheduler) Write(ctx context.Context, writes []PointWriteRequest) error
type PointWriteRequest ¶
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
Step1Verified bool `json:"step1_verified"`
Step2Discovered bool `json:"step2_discovered"`
DiscoveryPhase string `json:"discovery_phase"` // preconfigured, broadcast, both
}
Click to show internal directories.
Click to hide internal directories.