UNPKG

bacnet-device

Version:

A TypeScript library for implementing BACnet IP devices in Node.js.

96 lines 4.07 kB
/** * BACnet singlet property implementation module * * This module provides the implementation for BACnet properties * that contain a single value (as opposed to array properties). * * @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 singlet property * * This interface defines the events that can be triggered by BACnet singlet 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 BDSingletPropertyEvents<Tag extends ApplicationTag, Type extends BDApplicationTagValueType[Tag] = BDApplicationTagValueType[Tag]> { /** Emitted before a property value changes */ beforecov: [property: BDSingletProperty<Tag, Type>, value: BDValue<Tag, Type>]; /** Emitted after a property value has changed */ aftercov: [property: BDSingletProperty<Tag, Type>, value: BDValue<Tag, Type>]; } /** * Implementation of a BACnet property with a single value * * This class represents a BACnet property that contains a single value (not an array). * It manages the property's value and handles read/write operations and change notifications. * * @typeParam Tag - The BACnet application tag for the property value * @typeParam Type - The JavaScript type corresponding to the application tag * @extends BDEvented<BDSingletPropertyEvents<Tag, Type>> */ export declare class BDSingletProperty<Tag extends ApplicationTag, Type extends BDApplicationTagValueType[Tag] = BDApplicationTagValueType[Tag]> extends BDEvented<BDSingletPropertyEvents<Tag, Type>> { #private; /** Indicates this is not a list/array property */ readonly list: false; /** The BACnet application tag for this property's value */ readonly type: Tag; /** Whether this property can be written to */ readonly writable: boolean; readonly settable: boolean; /** The BACnet property identifier */ readonly identifier: PropertyIdentifier; /** * Creates a new BACnet singlet property * * @param identifier - The BACnet property identifier * @param type - The BACnet application tag for this property's value * @param writable - Whether this property can be written to * @param value - The initial value for this property */ constructor(identifier: PropertyIdentifier, type: Tag, writable: boolean, value: Type | (() => BDValue<Tag, Type>)); /** * Gets the current value of this property * * @returns The current property value */ getValue(): Type; /** * Sets a new value for this property * * This method queues the value change to ensure proper event * notification and serialization of changes. * * @param value - The new value to set * @returns A promise that resolves when the value has been set */ setValue(value: Type): Promise<void>; /** * Reads the current value of this property for BACnet operations * * This internal method is used by BACnet objects to read the property value * when handling BACnet protocol operations. * * @returns The current property value in BACnet format * @internal */ ___readValue(): BDValue<Tag, Type>; /** * Writes a new value to this property for BACnet operations * * This internal method is used by BACnet objects to write the property value * when handling BACnet protocol operations. * * @param value - The new value to write in BACnet format * @returns A promise that resolves when the value has been set * @throws BACnetError if the property is not writable or the value type is invalid * @internal */ ___writeValue(value: BDValue<Tag, Type> | BDValue<Tag, Type>[]): Promise<void>; } //# sourceMappingURL=singlet.d.ts.map