UNPKG

rxjs-obd

Version:

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

50 lines 1.59 kB
import { OBDOuterSubscriber } from '../model/OBDOuterSubscriber'; export function oxygenSensorSTFT(sensor) { return function (source) { return source.lift(new OxygenSensorSTFTOperator(sensor)); }; } class OxygenSensorSTFTOperator { constructor(sensor) { this.sensor = sensor; } call(subscriber, source) { return source.subscribe(new OxygenSensorSTFTSubscriber(subscriber, this.sensor)); } } class OxygenSensorSTFTSubscriber extends OBDOuterSubscriber { constructor(destination, sensor) { super(destination); this.sensor = sensor; } /** * 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 ${['14', '15', '16', '17', '18', '19', '1A', '1B'][this.sensor - 1]} 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 [`oxygenSensorVoltage${this.sensor}`, `oxygenSensorShortTermFuelTrim${this.sensor}`]; } /** * Parse the OBD response. * @param bytes the response read from OBD. * @returns the parsed response. */ parse(bytes) { return [parseInt(bytes[2], 16) / 200, (parseInt(bytes[3], 16) * 1.28) - 100]; } } //# sourceMappingURL=oxygenSensorSTFT.js.map