UNPKG

@openhps/core

Version:

Open Hybrid Positioning System - Core component

61 lines 2.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CalibrationService = void 0; const DataObjectService_1 = require("./DataObjectService"); /** * Calibration service. This service has to be used together with a [[CalibrationNode]] * that is placed behind the source node that is used for calibration. * * When a user-calibration is started, the calibration node will intercept all data frames. * * ## Usage * ```typescript * const model = await ModelBuilder.create() * .addService(new MyCalibrationService()) * .from(new MyUncalibratedSensor()) * .via(new CalibrationNode({ * service: MyCalibrationService * })) * .via(...) * .to(...).build(); * * function whenUserClicksCalibrate() { * model.findService(MyCalibrationService).calibrate(); * } * ``` */ class CalibrationService extends DataObjectService_1.DataObjectService { /** * Start the calibration interception. Make sure to enable * any passive sources. * @param {CalibrationObjectCallback} [objectCallback] Object callback * @param {CalibrationFrameCallback} [frameCallback] Frame callback */ start(objectCallback, frameCallback) { if (!this.node) { throw new Error(`Calibration node did not register itself to the calibration service!`); } this.node.start(objectCallback, frameCallback); } /** * Stop the calibration interception. */ stop() { if (!this.node) { throw new Error(`Calibration node did not register itself to the calibration service!`); } this.node.stop(); } /** * Suspend the calibration interception. This will still intercept data frames, but the * callbacks will be cleared. */ suspend() { if (!this.node) { throw new Error(`Calibration node did not register itself to the calibration service!`); } this.node.suspend(); } } exports.CalibrationService = CalibrationService; //# sourceMappingURL=CalibrationService.js.map