import { JSONObject, KDocument } from "kuzzle"; import { DeviceContent } from "../device"; import { DeviceManagerPlugin } from "../plugin"; import { BaseService, Metadata } from "../shared"; import { DecodedMeasurement } from "./types/MeasureContent"; import { ApiMeasureSource } from "./types/MeasureSources"; import { ApiMeasureTarget } from "./types/MeasureTarget"; export declare class MeasureService extends BaseService { constructor(plugin: DeviceManagerPlugin); /** * Register new measures from an API, updates : * - asset * - engine measures * * This method represents the ingestion pipeline: * - trigger events `before` (measure enrichment) * - save documents (measures and asset) * - trigger events `after` */ ingestApi(source: ApiMeasureSource, target: ApiMeasureTarget, measurements: DecodedMeasurement[], payloadUuids: string[]): Promise; /** * Register new measures from a device, updates : * - admin device * - engine device * - linked asset * - engine measures * * A mutex ensure that a device can ingest one measure at a time. * * This method represents the ingestion pipeline: * - build measures documents and update digital twins (device and asset) * - trigger events `before` (measure enrichment) * - save documents (measures, device and asset) * - trigger events `after` * * @deprecated */ ingest(device: KDocument, measurements: DecodedMeasurement[], metadata: Metadata, payloadUuids: string[]): Promise; private updateDeviceMeasures; /** * Update asset with each non-null non-computed measures. * * @returns A map of each asset state by measuredAt timestamp. */ private updateAssetMeasures; /** * Build the measures document received from the API * * @param source The API data source * @param asset The target asset to build the measure for * @param measure The decoded raw measures * @param payloadUuids The uuid's of the payloads used to create the measure * * @returns A MeasurementContent builded from parameters */ private buildApiMeasures; /** * Build the measures documents to save */ private buildMeasures; /** * Find an asset by its ID and its engine ID. * * @param engineId The target index ID * @param assetId the target asset ID * @returns The asset or null if not found */ private findAsset; /** * Check if the asset measure name is associated to the asset model * * @param measureName The measure name to check * @param model The asset model the measureName should belong * * @returns True if the asset measure name belongs to the asset model, false otherwise * @throws If the model does not exists */ private isMeasureNameInModel; /** * Find the asset measure name from the device and its measure type * * @param deviceId The source device ID * @param measureType The device measure type * @param asset The asset the device is linked to * * @returns The asset measure name or null if it does not belong to the link * @throws If the device is not linked to the asset */ private findAssetMeasureNameFromDevice; private mutexUpdateAsset; /** * Create a new document in the collection asset-history, for each asset state */ private historizeAssetStates; }