@iotize/tap
Version:
IoTize Device client for Javascript
45 lines (44 loc) • 1.97 kB
TypeScript
import { EncoderDecoder } from '@iotize/common/converter/api';
import { VariableService, VariableType } from '@iotize/tap/service/impl/variable';
import { KeyTypeType } from '../../utility/editable-data-stream';
import { AbstractVariable } from '../abstract-variable-stream';
import { TapVariableConfig } from '../tap-bundle/tap-bundle';
export declare function createTapVariableFromConfig<DataType, KeyType extends KeyTypeType>(variableService: VariableService, key: KeyType, value: TapVariableConfig<DataType>): TapVariable<DataType, KeyType>;
export declare namespace TapVariable {
interface Config {
/**
* Tap configured ID
*/
id: number;
dataType?: VariableType.Data;
length?: number;
}
interface InstanceOptions<DataType> {
variableService: Pick<VariableService, 'getValue' | 'setValue'>;
config: Config;
converter?: EncoderDecoder<DataType, Uint8Array>;
/**
* Use this option if you want to extract only a subset of the data
* For exemple if your Tap variable is configured to hold 10 bytes of data but you only want bytes 4, 5, 6, and 7 use subIndex option [4,5,6,7] (index starting from 0)
*/
subIndex?: number[];
}
}
export declare class TapVariable<DataType, KeyType extends KeyTypeType> extends AbstractVariable<DataType, KeyType> {
/**
* Variable name identifier.
*/
readonly id: KeyType;
context: TapVariable.InstanceOptions<DataType>;
get variableId(): number;
get converter(): EncoderDecoder<DataType, Uint8Array>;
get config(): TapVariable.Config;
set converter(converter: EncoderDecoder<DataType, Uint8Array>);
constructor(
/**
* Variable name identifier.
*/
id: KeyType, context: TapVariable.InstanceOptions<DataType>);
readRawInner(): Promise<Uint8Array>;
writeRaw(value: Uint8Array): Promise<void>;
}