bacnet-device
Version:
A TypeScript library for implementing BACnet IP devices in Node.js.
98 lines • 4.35 kB
TypeScript
/**
* BACnet array property implementation module
*
* This module provides the implementation for BACnet properties
* that contain multiple values in an array.
*
* @module
*/
import { type BDValue, type BDApplicationTagValueType } from '../value.js';
import { BDEvented } from '../evented.js';
import { PropertyIdentifier, ApplicationTag } from '@innovation-system/node-bacnet';
/**
* Events that can be emitted by a BACnet array property
*
* This interface defines the events that can be triggered by BACnet array properties
* when their values change.
*
* @typeParam Tag - The BACnet application tag for the property values
* @typeParam Type - The JavaScript type corresponding to the application tag
*/
export interface BDArrayPropertyEvents<Tag extends ApplicationTag, Type extends BDApplicationTagValueType[Tag] = BDApplicationTagValueType[Tag]> {
/** Emitted before a property value changes */
beforecov: [property: BDArrayProperty<Tag, Type>, raw: BDValue<Tag, Type>[]];
/** Emitted after a property value has changed */
aftercov: [property: BDArrayProperty<Tag, Type>, raw: BDValue<Tag, Type>[]];
}
/**
* Implementation of a BACnet property with multiple values (array)
*
* This class represents a BACnet property that contains multiple values in an array.
* It manages the property's values and handles read/write operations and change notifications.
*
* @typeParam Tag - The BACnet application tag for the property values
* @typeParam Type - The JavaScript type corresponding to the application tag
* @extends BDEvented<BDArrayPropertyEvents<Tag, Type>>
*/
export declare class BDArrayProperty<Tag extends ApplicationTag, Type extends BDApplicationTagValueType[Tag] = BDApplicationTagValueType[Tag]> extends BDEvented<BDArrayPropertyEvents<Tag, Type>> {
#private;
/** Indicates this is not a list/array property (BACnet semantic, not JavaScript array) */
readonly list: false;
/** The BACnet application tag for this property's values */
readonly type: Tag;
/** Whether this property can be written to */
readonly writable: boolean;
/** Whether this property's entire value can be set at once */
readonly settable: boolean;
/** The BACnet property identifier */
readonly identifier: PropertyIdentifier;
/**
* Creates a new BACnet array property
*
* @param identifier - The BACnet property identifier
* @param type - The BACnet application tag for this property's values
* @param writable - Whether this property can be written to
* @param value - Optional initial values for this property. If provided, the property is not settable as a whole.
*/
constructor(identifier: PropertyIdentifier, type: Tag, writable: boolean, value: BDValue<Tag, Type>[] | (() => BDValue<Tag, Type>[]));
/**
* Gets the current values of this property
*
* @returns An array of the current property values
*/
getValue(): Type[];
/**
* Sets new values for this property
*
* This method queues the value changes to ensure proper event
* notification and serialization of changes.
*
* @param value - The new values to set
* @returns A promise that resolves when the values have been set
* @throws BACnetError if the property is not settable as a whole
*/
setValue(value: Type[]): Promise<void>;
/**
* Reads the current values of this property for BACnet operations
*
* This internal method is used by BACnet objects to read the property values
* when handling BACnet protocol operations.
*
* @returns The current property values in BACnet format
* @internal
*/
___readValue(): BDValue<Tag, Type>[];
/**
* Writes new values to this property for BACnet operations
*
* This internal method is used by BACnet objects to write the property values
* when handling BACnet protocol operations.
*
* @param value - The new values to write in BACnet format (single value or array)
* @returns A promise that resolves when the values have been set
* @throws BACnetError if the property is not writable or the value types are invalid
* @internal
*/
___writeValue(value: BDValue<Tag, Type> | BDValue<Tag, Type>[]): Promise<void>;
}
//# sourceMappingURL=array.d.ts.map