UNPKG

@openhps/core

Version:

Open Hybrid Positioning System - Core component

47 lines 1.46 kB
import { Node } from '../Node'; /** * Graph shape node is a node that contains multiple nodes on itself. Other than a constructed * graph shape, this type of node should offer a collection of nodes. An example could be a "PDRProcessingNode" * that performs pedestrian dead reckoning by combining multiple internal nodes, such as an AccelerationProcessing, * VelocityProcessingNode and StepDetection. */ export class GraphShapeNode extends Node { constructor(options) { super(options); this.once('build', this._onBuild.bind(this)); this.once('destroy', this._onDestroy.bind(this)); } _onBuild() { return new Promise((resolve, reject) => { this.construct(this._builder); this._builder.build().then(graph => { this._graph = graph; this._builder = null; resolve(); }).catch(reject); }); } _onDestroy() { return this._graph.emitAsync('destroy'); } /** * Send a pull request to the node * @param {PullOptions} [options] Pull options * @returns {Promise<void>} Pull promise */ pull(options) { return this._graph.pull(options); } /** * Push data to the node * @param {DataFrame | DataFrame[]} data Data frame to push * @param {PushOptions} [options] Push options * @returns {PushPromise<void>} Push promise */ push(data, options = {}) { return this._graph.push(data, options); } get processingGraph() { return this._graph; } }