bacnet-device
Version:
A TypeScript library for implementing BACnet IP devices in Node.js.
101 lines • 4.05 kB
TypeScript
/**
* BACnet object implementation module
*
* This module provides the base implementation for BACnet objects,
* which are the core components of BACnet devices.
*
* @module
*/
import { BDEvented, type BDEventMap } from './evented.js';
import { type BDValue } from './value.js';
import { ObjectType } from '@innovation-system/node-bacnet';
import type { BACNetObjectID, BACNetPropertyID, BACNetReadAccess } from '@innovation-system/node-bacnet';
import type { ReadPropertyContent, ReadPropertyMultipleContent } from '@innovation-system/node-bacnet/dist/lib/EventTypes.js';
import { type BDProperty } from './properties/index.js';
/**
* Events that can be emitted by a BACnet object
*/
export interface BDObjectEvents extends BDEventMap<any> {
/** Emitted before a property value changes */
beforecov: [object: BDObject, property: BDProperty<any, any>, nextValue: BDValue | BDValue[]];
/** Emitted after a property value has changed */
aftercov: [object: BDObject, property: BDProperty<any, any>, newValue: BDValue | BDValue[]];
}
/**
* 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 BDEvented<BDObjectEvents>
*/
export declare class BDObject<EM extends BDObjectEvents = BDObjectEvents> extends BDEvented<EM> {
#private;
/** The unique identifier for this object (type and instance number) */
readonly identifier: BACNetObjectID;
/**
* Creates a new BACnet object
*
* @param type - The BACnet object type
* @param instance - The instance number for this object
* @param name - The name of this object
*/
constructor(type: ObjectType, instance: number, name: string, description?: string);
/**
* 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<T extends BDProperty<any, any>>(property: T): T;
/**
* 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: BDValue | BDValue[]): Promise<void>;
/**
* 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(req: ReadPropertyContent): Promise<BDValue | BDValue[]>;
/**
* 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<BACNetReadAccess>;
/**
* Reads multiple properties from this object
*
* This internal method is used to handle ReadPropertyMultiple operations
* from the BACnet network.
*
* @param properties - Array of property identifiers to read
* @returns An object containing the requested property values
* @internal
*/
___readPropertyMultiple(properties: ReadPropertyMultipleContent['payload']['properties'][number]['properties']): Promise<BACNetReadAccess>;
}
//# sourceMappingURL=object.d.ts.map