UNPKG

@iotize/tap

Version:

IoTize Device client for Javascript

65 lines (64 loc) 2.77 kB
import { EncoderDecoder } from '@iotize/common/converter/api'; import { Observable } from 'rxjs'; import { EditableDataStreamInterface, KeyTypeType } from '../utility/editable-data-stream'; import { AbstractVariable } from './abstract-variable-stream'; /** * You should use ConverterVariableView instead */ export declare class VariableView<DataType, KeyType extends KeyTypeType = KeyTypeType> implements EditableDataStreamInterface<DataType, Uint8Array, KeyType> { readonly id: KeyType; context: { /** * The underlying variable from whiich the view will be created */ variable: AbstractVariable<any, any>; /** * Index to extract from the whole buffer (starting from 0) * Buffer size will be the array length * size of one element defined by the variable type */ indexes: number[]; /** * If set to false, Tap will read the current value before editing and writing the new index * If set to true and if Tap already know the current value, it will not perform a read before editing the value */ useLastKnownValueBeforeWrite?: boolean; /** * Defined how the extracted value should be decoded */ converter: EncoderDecoder<DataType, Uint8Array>; }; get converter(): EncoderDecoder<DataType, Uint8Array>; get indexes(): number[]; get rawValues(): Observable<Uint8Array>; get valueSnapshot(): DataType | undefined; get values(): Observable<DataType>; get rawValueSnaphot(): Uint8Array | undefined; constructor(id: KeyType, context: { /** * The underlying variable from whiich the view will be created */ variable: AbstractVariable<any, any>; /** * Index to extract from the whole buffer (starting from 0) * Buffer size will be the array length * size of one element defined by the variable type */ indexes: number[]; /** * If set to false, Tap will read the current value before editing and writing the new index * If set to true and if Tap already know the current value, it will not perform a read before editing the value */ useLastKnownValueBeforeWrite?: boolean; /** * Defined how the extracted value should be decoded */ converter: EncoderDecoder<DataType, Uint8Array>; }); notifyRawValue(newValue: Uint8Array): void; read(): Promise<DataType>; write(value: DataType): Promise<any>; readRaw(): Promise<Uint8Array>; writeRaw(value: Uint8Array): Promise<void>; private subDataView; private encodeValue; private decodeValue; }