/** * BACnet object implementation module * * This module provides the base implementation for BACnet objects, * which are the core components of BACnet devices. * * @module */ import { EventEmitter } from 'node:events'; import { type BACNetAppData, type BACNetPropertyID, type BACNetReadAccess, ObjectType, EventState, Reliability, ApplicationTag, PropertyIdentifier } from '@bacnet-js/client'; import type { ReadPropertyMultipleContent } from '@bacnet-js/client/dist/lib/EventTypes.js'; import { BDAbstractProperty, BDSingletProperty, BDPolledArrayProperty, BDPolledSingletProperty } from '../../properties/index.js'; import { type Task } from '../../taskqueue.js'; import type { BDDevice } from '../device/device.js'; export type BDObjectCoVListener = (data: BACNetAppData | BACNetAppData[], property: BDAbstractProperty, object: BDObject) => Promise; /** * Events that can be emitted by a BACnet object */ export interface BDObjectEvents extends Record { /** Emitted after a property value has changed */ aftercov: [data: BACNetAppData | BACNetAppData[], property: BDAbstractProperty, object: BDObject]; /** Emitted when the object's {@link BDObject#outOfService | Out_Of_Service} property is set to `false`, either from the network or locally */ inservice: []; /** Emitted when the object's {@link BDObject#outOfService | Out_Of_Service} property is set to `true`, either from the network or locally */ outofservice: []; } /** * Common options for all BACnet objects * * This interface defines the base configuration parameters shared by every * BACnet object type. Subclass-specific option interfaces extend this * interface with additional properties. */ export interface BDObjectOpts { /** The object's name (`Object_Name` property) */ name: string; /** An optional textual description of the object (`Description` property) */ description?: string; /** * Whether the `Out_Of_Service` property is writable from the BACnet network. * * When `true`, remote BACnet clients can set the object's `Out_Of_Service` * property to `TRUE` or `FALSE`. Changing the property causes the object to * emit an {@link BDObjectEvents.outofservice | outofservice} * or {@link BDObjectEvents.inservice | inservice} event accordingly. Default * is `false`. * * @defaultValue `false` */ writableOutOfService?: boolean; } /** * Base class for all BACnet objects * * This class implements the core functionality required by all BACnet objects * according to the BACnet specification. It manages object properties and * handles property read/write operations and CoV notifications. * * @extends AsyncEventEmitter */ export declare class BDObject extends EventEmitter { #private; readonly objectName: BDSingletProperty; readonly objectType: BDSingletProperty; readonly objectIdentifier: BDPolledSingletProperty; readonly propertyList: BDPolledArrayProperty; readonly description: BDSingletProperty; readonly outOfService: BDSingletProperty; readonly statusFlags: BDSingletProperty; readonly eventState: BDSingletProperty; readonly reliability: BDSingletProperty; /** * Creates a new BACnet object * */ constructor(type: ObjectType, opts: BDObjectOpts); get type(): ObjectType; get identifier(): BACNetAppData; get device(): BDDevice; isOutOfService(): boolean; /** * Adds a property to this object * * This method registers a new property with the object and sets up * event subscriptions for property value changes. * * @param property - The property to add * @returns The added property * @throws Error if a property with the same identifier already exists * @typeParam T - The specific BACnet property type */ addProperty>(property: T): T; transaction(task: Task): Promise; destroy(): void; addCoVListener(listener: BDObjectCoVListener): void; removeCoVListener(listener: BDObjectCoVListener): void; /** * Writes a value to a property * * This internal method is used to handle write operations from the BACnet network. * * @param identifier - The identifier of the property to write * @param value - The value to write to the property * @throws BACnetError if the property does not exist * @internal */ ___writeProperty(identifier: BACNetPropertyID, value: BACNetAppData | BACNetAppData[], priority: number): Promise; /** * Reads a value from a property * * This internal method is used to handle read operations from the BACnet network. * * @param req - The read property request * @returns The property value * @throws BACnetError if the property does not exist * @internal */ ___readProperty(identifier: BACNetPropertyID): Promise; /** * Reads all properties from this object * * This internal method is used to handle ReadPropertyMultiple operations * when the ALL property identifier is used. * * @returns An object containing all property values * @internal */ ___readPropertyMultipleAll(): Promise; /** * Reads multiple properties from this object * * This internal method is used to handle ReadPropertyMultiple operations * from the BACnet network. * * @param identifiers - Array of property identifiers to read * @returns An object containing the requested property values * @internal */ ___readPropertyMultiple(identifiers: ReadPropertyMultipleContent['payload']['properties'][number]['properties']): Promise; /** * * @internal */ ___getPropertyOrThrow(identifier: PropertyIdentifier): BDAbstractProperty; /** @internal */ ___setDevice(device: BDDevice): void; /** @internal */ ___setIdentifier(instance: number): void; } //# sourceMappingURL=object.d.ts.map