UNPKG

rxjs-obd

Version:

RxJS Implementation for OBD (On Board Diagnostics) of vehicles via ELM 327 connections.

48 lines 1.35 kB
import { OBDOuterSubscriber } from '../model/OBDOuterSubscriber'; export function engineFuelRate() { return function (source) { return source.lift(new EngineFuelRateOperator()); }; } class EngineFuelRateOperator { call(subscriber, source) { return source.subscribe(new EngineFuelRateSubscriber(subscriber)); } } class EngineFuelRateSubscriber extends OBDOuterSubscriber { constructor(destination) { super(destination); } /** * Return the frequency of execution of this command. * @return that this command must be executed every pulse. */ pulse() { return 1; } /** * Return the string representation of the OBD Read command. * @returns the string representation of the OBD Read command */ command() { return '01 5E 1\r'; } /** * Return the name of the OBD Field on OBD Data object. * @returns the name of the OBD Field on OBD Data object. */ field() { return 'engineFuelRate'; } /** * Parse the OBD response. * @param bytes the response read from OBD. * @returns the parsed response. */ parse(bytes) { const a = parseInt(bytes[2], 16) * 256; const b = parseInt(bytes[3], 16); return (a + b) / 20; } } //# sourceMappingURL=engineFuelRate.js.map