import { EncoderDecoder } from '@iotize/common/converter/api';
import { Tap } from '@iotize/tap';
import { DataConfig } from '@iotize/tap/config/schema/v1';
import { MemoryInfo, ModbusOptions } from '@iotize/tap/service/impl/target';
import { Observable } from 'rxjs';
import { MonitoringController } from '../monitor/monitor-engine';
import { AbstractVariable } from '../target-variable/abstract-variable-stream';
import { ModbusAccessVariable } from '../target-variable/modbus/modbus-access-variable';
import { TapBundleConfig, TapVariableConfig } from '../target-variable/tap-bundle/tap-bundle';
import { TapVariable } from '../target-variable/tap-variable/tap-variable';
import { TargetMemoryVariable } from '../target-variable/target-memory/target-memory-variable';
import { BundleDataStreamInterface, EditableDataStreamInterface, KeyTypeType } from '../utility/editable-data-stream';
import { BundlesConfig, DataManagerSync } from './create-data-manager-from-tap-config';
declare type ExtractLevel2Key<T> = T extends object ? T[keyof T] extends object ? {
    [K in keyof T]: keyof T[K];
}[keyof T] : keyof T : never;
declare type KeyOrNever<T, K> = K extends keyof T ? K : never;
declare type BundleKeyFromVariableType<T, K> = T[keyof T] extends object ? {
    [K2 in keyof T]: KeyOrNever<T[K2], K> extends never ? never : K2;
}[keyof T] : never;
/**
 * Typed data manager is usually build from Tap configuration
 *
 * It allow you to have compile time check for bundle/variable types.
 * However, you cannot add/remove/edit variables (as it would change types)
 * Use `DataManager` if you want this features
 */
export declare class TypedDataManager<DataType> {
    tap: Tap;
    protected bundles: Record<keyof DataType, BundleDataStreamInterface<DataType[keyof DataType]>>;
    monitoring: MonitoringController;
    private _events;
    get values(): Observable<DataType>;
    get events(): Observable<DataManager.Event>;
    constructor(tap: Tap, bundles: Record<keyof DataType, BundleDataStreamInterface<DataType[keyof DataType]>>, monitoring?: MonitoringController);
    listVariables(): EditableDataStreamInterface<unknown, Uint8Array, KeyTypeType>[];
    bundle<T extends keyof DataType>(key: T): BundleDataStreamInterface<DataType[T]>;
    variable<VK extends ExtractLevel2Key<DataType>>(key: VK): EditableDataStreamInterface<VK extends keyof DataType[BundleKeyFromVariableType<DataType, VK>] ? DataType[BundleKeyFromVariableType<DataType, VK>][VK] : never, Uint8Array, VK>;
    destroy(): void;
    refreshValues(): Promise<Partial<DataType>>;
    listBundles(): BundleDataStreamInterface<DataType[keyof DataType]>[];
    hasBundle<BundleKey extends KeyTypeType>(bundleKey: BundleKey): boolean;
    createConfiguredBundle<DataType>(key: KeyTypeType, config: TapBundleConfig<keyof DataType>): import("../target-variable/tap-bundle/tap-bundle").TapBundle<DataType>;
    createConfiguredVariable<DataType, KeyType extends KeyTypeType>(key: KeyType, config: TapVariableConfig<DataType>): TapVariable<DataType, KeyType>;
    /**
     * Create a variable with direct modbus access
     * May/May not be available according to the configured target protocol on your device
     *
     * @param id
     * @param options
     */
    createModbusAccessVariable<Key extends KeyTypeType, DataType>(id: Key, options: {
        config: ModbusOptions;
        converter: EncoderDecoder<DataType, Uint8Array>;
    }): ModbusAccessVariable<DataType, Key>;
    /**
     * Create direct target access to variable
     * May/May not be available according to configured target protocol on your device
     * @param id
     * @param options
     */
    createTargetMemoryVariable<Key extends KeyTypeType>(id: Key, options: {
        config: MemoryInfo;
        converter: EncoderDecoder<DataType, Uint8Array>;
    }): TargetMemoryVariable<DataType, Key>;
}
export declare class DataManager<DataType = Record<KeyTypeType, Record<string, any>>> extends TypedDataManager<DataType> {
    constructor(tap: Tap, bundles?: Record<KeyTypeType, BundleDataStreamInterface<any>>, monitoring?: MonitoringController);
    setBundles(bundles: Record<KeyTypeType, BundleDataStreamInterface<any>>): void;
    addBundle<T>(bundle: BundleDataStreamInterface<T>): void;
    removeBundle(bundleKey: KeyTypeType): void;
    addVariable<VariableDataType, VariableKeyType extends KeyTypeType>(bundleKey: keyof DataType, variable: AbstractVariable<VariableDataType, VariableKeyType>): void;
    /**
     * Register bundles configured in the Tap
     */
    registerBundles<DataType>(bundlesConfig: BundlesConfig<DataType>): any;
    registerBundle<VariableKeys extends KeyTypeType>(key: KeyTypeType, config: TapBundleConfig<VariableKeys>): void;
    clear(): void;
    /**
     * Synchronize DataManager bundles and variables with the connected Tap device
     * It will the current profile accessible variables/bundles
     */
    synchronizeTapConfig(): Observable<DataManager.SynchronizeEvent>;
    /**
     * Configure DataManager bundles and variables from a DataConfig object (found in Tap configuration files)
     * Data decoder will be dedecuced from dataType/length field.
     */
    configureWithDataConfig(config: DataConfig): void;
}
export declare namespace DataManager {
    type SynchronizeEvent = DataManagerSync.Event | {
        step: 'done';
        bundles: Record<KeyTypeType, TapBundleConfig<KeyTypeType>>;
    };
    type Event = {
        type: DataManager.EventType.error;
        error: Error;
    };
    enum EventType {
        error = "error"
    }
}
export {};
