@bacnet-js/device
Version:
A TypeScript library for implementing BACnet IP devices in Node.js.
112 lines • 4.84 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 { AsyncEventEmitter, type EventMap } from '../../events.js';
import { type BACNetAppData, type BACNetObjectID, 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 } from '../../properties/index.js';
import { type Task } from '../../taskqueue.js';
import { type BDObjectUID } from '../../uids.js';
/**
* Events that can be emitted by a BACnet object
*/
export interface BDObjectEvents extends EventMap {
/** Emitted after a property value has changed */
aftercov: [object: BDObject, property: BDAbstractProperty<any, any, any>, newValue: BACNetAppData | BACNetAppData[]];
}
/**
* 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<BDObjectEvents>
*/
export declare class BDObject extends AsyncEventEmitter<BDObjectEvents> {
#private;
/** The unique identifier for this object (type and instance number) */
readonly identifier: BACNetObjectID;
readonly uid: BDObjectUID;
readonly objectName: BDSingletProperty<ApplicationTag.CHARACTER_STRING>;
readonly objectType: BDSingletProperty<ApplicationTag.ENUMERATED, ObjectType>;
readonly objectIdentifier: BDSingletProperty<ApplicationTag.OBJECTIDENTIFIER>;
readonly propertyList: BDPolledArrayProperty<ApplicationTag.ENUMERATED, PropertyIdentifier>;
readonly description: BDSingletProperty<ApplicationTag.CHARACTER_STRING>;
readonly outOfService: BDSingletProperty<ApplicationTag.BOOLEAN>;
readonly statusFlags: BDSingletProperty<ApplicationTag.BIT_STRING>;
readonly eventState: BDSingletProperty<ApplicationTag.ENUMERATED, EventState>;
readonly reliability: BDSingletProperty<ApplicationTag.ENUMERATED, Reliability>;
/**
* Creates a new BACnet object
*
*/
constructor(identifier: BACNetObjectID, 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 BDAbstractProperty<any, any, any>>(property: T): T;
transaction<T>(task: Task<T>): Promise<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: BACNetAppData | BACNetAppData[]): 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(identifier: BACNetPropertyID): Promise<BACNetAppData | BACNetAppData[]>;
/**
* 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 identifiers - Array of property identifiers to read
* @returns An object containing the requested property values
* @internal
*/
___readPropertyMultiple(identifiers: ReadPropertyMultipleContent['payload']['properties'][number]['properties']): Promise<BACNetReadAccess>;
/**
*
* @internal
*/
___getPropertyOrThrow(identifier: PropertyIdentifier): BDAbstractProperty<any, any, any>;
}
//# sourceMappingURL=object.d.ts.map