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'; type ExtractLevel2Key = T extends object ? T[keyof T] extends object ? { [K in keyof T]: keyof T[K]; }[keyof T] : keyof T : never; type KeyOrNever = K extends keyof T ? K : never; type BundleKeyFromVariableType = T[keyof T] extends object ? { [K2 in keyof T]: KeyOrNever 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> { tap: Tap; protected bundles: Record>; monitoring: MonitoringController; private _events; get values(): Observable; get events(): Observable; constructor(tap: Tap, bundles: Record>, monitoring?: MonitoringController); listVariables(): EditableDataStreamInterface[]; bundle(key: T): BundleDataStreamInterface; variable>(key: VK): EditableDataStreamInterface] ? DataType[BundleKeyFromVariableType][VK] : never, Uint8Array, VK>; destroy(): void; refreshValues(): Promise>; listBundles(): BundleDataStreamInterface[]; hasBundle(bundleKey: BundleKey): boolean; createConfiguredBundle>(key: KeyTypeType, config: TapBundleConfig): import("../target-variable/tap-bundle/tap-bundle").TapBundle; createConfiguredVariable(key: KeyType, config: TapVariableConfig): TapVariable; /** * 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(id: Key, options: { config: ModbusOptions; converter: EncoderDecoder; }): ModbusAccessVariable; /** * Create direct target access to variable * May/May not be available according to configured target protocol on your device * @param id * @param options */ createTargetMemoryVariable(id: Key, options: { config: MemoryInfo; converter: EncoderDecoder; }): TargetMemoryVariable; } export declare class DataManager = Record>> extends TypedDataManager { constructor(tap: Tap, bundles?: Record>, monitoring?: MonitoringController); setBundles(bundles: Record>): void; addBundle>(bundle: BundleDataStreamInterface): void; removeBundle(bundleKey: KeyTypeType): void; addVariable(bundleKey: keyof DataType, variable: AbstractVariable): void; /** * Register bundles configured in the Tap */ registerBundles(bundlesConfig: BundlesConfig): any; registerBundle(key: KeyTypeType, config: TapBundleConfig): void; clear(): void; /** * Synchronize DataManager bundles and variables with the connected Tap device * It will the current profile accessible variables/bundles */ synchronizeTapConfig(): Observable; /** * 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>; }; type Event = { type: DataManager.EventType.error; error: Error; }; enum EventType { error = "error" } } export {};