@iotile/iotile-device
Version:
A typescript library for interfacing with IOTile BLE devices
44 lines (43 loc) • 2.31 kB
TypeScript
import { WaveformSummary, AxisSummary, WaveformData, DecodedWaveformInfo, RawWaveformInfo } from "./types";
import { IOTileEvent } from "../../common/flexible-dict-report";
/**
* Calculate the maximum time that a given threshold is exceeded.
*
* @param data A list of samples along a single axis in G's
* @param threshold The threshold that we should count time above
* @param samplingRate The sampling rate of the data in Hz
*
* @returns The number of ms that data is above threshold in a single continuous
* event.
*/
export declare function timeAboveThreshold(data: number[], threshold: number, samplingRate: number): number;
export declare function calculateDeltaV(data: number[], threshold: number, samplingRate: number): number;
export declare function maxAbs(data: number[]): number;
export declare function summarizeAxis(data: number[], threshold: number, samplingRate: number): AxisSummary;
export declare function summarizeWaveform(wave: WaveformData): WaveformSummary;
/**
* Unpack an array buffer that corresponds to a list of VLE encoded integers.
*
* The function assumes that the input buffer was created from a list of integers
* in the range of -4095 to 4095 that were processed in the following way to
* create this binary buffer:
*
* - They were delta encoded, so all entries after the first were stored as
* the difference between the value and the last value.
* - They were zig-zag encoded so that all negative values became positive.
* - They were packed as variable length integers where 7-bit values are stored
* as a single byte and all other values are stored as two bytes.
*
* This function undoes all three of these packing steps
*
* @param input A list of integers that have been encoded in the following
* way: first they were delta encoded, then they were zigzag
* encoded and finally they were delta encoded.
*/
export declare function unpackVLEIntegerList(input: ArrayBuffer): number[];
export declare function decompressWaveforms(rawWaveforms: RawWaveformInfo): DecodedWaveformInfo;
export declare function tryConvertUTCTimestamp(deviceTimestamp: number): Date | null;
/**
* Create IOTileEvents for all waveforms.
*/
export declare function createWaveformEvents(waveforms: DecodedWaveformInfo): IOTileEvent[];