aboutsummaryrefslogtreecommitdiff
path: root/car-lib
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2017-02-16 03:48:54 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-02-16 03:48:54 +0000
commit2a68e45ab6964476df94df04643512cb556c91a2 (patch)
tree6a35d326fccf1b64f8bd4d4ac4a3e4bcd9f21bbb /car-lib
parent49e3b7cd5cde92f28eda36537460ec62ad100d47 (diff)
parent0b7559c7f6ea24cec679c310c7a320905222f843 (diff)
downloadCar-2a68e45ab6964476df94df04643512cb556c91a2.tar.gz
Merge "Post-O. Provide smart accessors for sensors that describe structured/enumerated data."
Diffstat (limited to 'car-lib')
-rw-r--r--car-lib/src/android/car/hardware/CarDiagnosticEvent.java495
1 files changed, 449 insertions, 46 deletions
diff --git a/car-lib/src/android/car/hardware/CarDiagnosticEvent.java b/car-lib/src/android/car/hardware/CarDiagnosticEvent.java
index c8c8ddbca1..b9c2f615fd 100644
--- a/car-lib/src/android/car/hardware/CarDiagnosticEvent.java
+++ b/car-lib/src/android/car/hardware/CarDiagnosticEvent.java
@@ -17,25 +17,24 @@
package android.car.hardware;
import android.annotation.IntDef;
+import android.annotation.Nullable;
import android.car.annotation.FutureFeature;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.SparseArray;
import android.util.SparseIntArray;
-
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Objects;
/**
* A CarDiagnosticEvent object corresponds to a single diagnostic event frame coming from the car.
+ *
* @hide
*/
@FutureFeature
public class CarDiagnosticEvent implements Parcelable {
- /**
- * This class contains the indices of the standard OBD2 sensors with an integer value
- */
+ /** This class contains the indices of the standard OBD2 sensors with an integer value */
public static final class Obd2IntegerSensorIndex {
private Obd2IntegerSensorIndex() {}
@@ -75,9 +74,7 @@ public class CarDiagnosticEvent implements Parcelable {
public static final int VENDOR_START = LAST_SYSTEM + 1;
}
- /**
- * This class contains the indices of the standard OBD2 sensors with a floating-point value
- */
+ /** This class contains the indices of the standard OBD2 sensors with a floating-point value */
public static final class Obd2FloatSensorIndex {
private Obd2FloatSensorIndex() {}
@@ -275,7 +272,7 @@ public class CarDiagnosticEvent implements Parcelable {
public @interface FloatSensorIndex {}
/** Whether this frame represents a live or a freeze frame */
- public final int frameKind;
+ public final int frameType;
/**
* When this data was acquired in car or received from car. It is elapsed real-time of data
@@ -295,13 +292,14 @@ public class CarDiagnosticEvent implements Parcelable {
*/
private final SparseArray<Float> floatValues;
- /** Diagnostic Troubleshooting Code (DTC) that was detected and caused this frame to be
- * stored (if a freeze frame). Always empty for a live frame.
+ /**
+ * Diagnostic Troubleshooting Code (DTC) that was detected and caused this frame to be stored
+ * (if a freeze frame). Always null for a live frame.
*/
public final String DTC;
public CarDiagnosticEvent(Parcel in) {
- frameKind = in.readInt();
+ frameType = in.readInt();
timestamp = in.readLong();
int len = in.readInt();
floatValues = new SparseArray<>(len);
@@ -317,7 +315,7 @@ public class CarDiagnosticEvent implements Parcelable {
int value = in.readInt();
intValues.put(key, value);
}
- DTC = in.readString();
+ DTC = (String)in.readValue(String.class.getClassLoader());
// version 1 up to here
}
@@ -328,7 +326,7 @@ public class CarDiagnosticEvent implements Parcelable {
@Override
public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(frameKind);
+ dest.writeInt(frameType);
dest.writeLong(timestamp);
dest.writeInt(floatValues.size());
for (int i = 0; i < floatValues.size(); ++i) {
@@ -342,27 +340,27 @@ public class CarDiagnosticEvent implements Parcelable {
dest.writeInt(key);
dest.writeInt(intValues.get(key));
}
- dest.writeString(DTC);
+ dest.writeValue(DTC);
}
public static final Parcelable.Creator<CarDiagnosticEvent> CREATOR =
- new Parcelable.Creator<CarDiagnosticEvent>() {
- public CarDiagnosticEvent createFromParcel(Parcel in) {
- return new CarDiagnosticEvent(in);
- }
+ new Parcelable.Creator<CarDiagnosticEvent>() {
+ public CarDiagnosticEvent createFromParcel(Parcel in) {
+ return new CarDiagnosticEvent(in);
+ }
- public CarDiagnosticEvent[] newArray(int size) {
- return new CarDiagnosticEvent[size];
- }
- };
+ public CarDiagnosticEvent[] newArray(int size) {
+ return new CarDiagnosticEvent[size];
+ }
+ };
private CarDiagnosticEvent(
- int frameKind,
- long timestamp,
- SparseArray<Float> floatValues,
- SparseIntArray intValues,
- String dtc) {
- this.frameKind = frameKind;
+ int frameType,
+ long timestamp,
+ SparseArray<Float> floatValues,
+ SparseIntArray intValues,
+ String dtc) {
+ this.frameType = frameType;
this.timestamp = timestamp;
this.floatValues = floatValues;
this.intValues = intValues;
@@ -370,21 +368,21 @@ public class CarDiagnosticEvent implements Parcelable {
}
public static class Builder {
- private int mKind = CarDiagnosticManager.FRAME_TYPE_FLAG_LIVE;
+ private int mType = CarDiagnosticManager.FRAME_TYPE_FLAG_LIVE;
private long mTimestamp = 0;
private SparseArray<Float> mFloatValues = new SparseArray<>();
private SparseIntArray mIntValues = new SparseIntArray();
- private String mDTC = "";
+ private String mDTC = null;
- private Builder(int kind) {
- mKind = kind;
+ private Builder(int type) {
+ mType = type;
}
- public static Builder liveFrame() {
+ public static Builder newLiveFrameBuilder() {
return new Builder(CarDiagnosticManager.FRAME_TYPE_FLAG_LIVE);
}
- public static Builder freezeFrame() {
+ public static Builder newFreezeFrameBuilder() {
return new Builder(CarDiagnosticManager.FRAME_TYPE_FLAG_FREEZE);
}
@@ -409,17 +407,16 @@ public class CarDiagnosticEvent implements Parcelable {
}
public CarDiagnosticEvent build() {
- return new CarDiagnosticEvent(
- mKind, mTimestamp, mFloatValues, mIntValues, mDTC);
+ return new CarDiagnosticEvent(mType, mTimestamp, mFloatValues, mIntValues, mDTC);
}
}
public boolean isLiveFrame() {
- return CarDiagnosticManager.FRAME_TYPE_FLAG_LIVE == frameKind;
+ return CarDiagnosticManager.FRAME_TYPE_FLAG_LIVE == frameType;
}
public boolean isFreezeFrame() {
- return CarDiagnosticManager.FRAME_TYPE_FLAG_FREEZE == frameKind;
+ return CarDiagnosticManager.FRAME_TYPE_FLAG_FREEZE == frameType;
}
public boolean isEmptyFrame() {
@@ -462,19 +459,425 @@ public class CarDiagnosticEvent implements Parcelable {
floatValues.toString());
}
- public int getSystemIntegerSensor(@IntegerSensorIndex int index, int defaultValue) {
- return intValues.get(index, defaultValue);
+ public int getSystemIntegerSensor(@IntegerSensorIndex int sensor, int defaultValue) {
+ return intValues.get(sensor, defaultValue);
+ }
+
+ public float getSystemFloatSensor(@FloatSensorIndex int sensor, float defaultValue) {
+ return floatValues.get(sensor, defaultValue);
+ }
+
+ public int getVendorIntegerSensor(int sensor, int defaultValue) {
+ return intValues.get(sensor, defaultValue);
+ }
+
+ public float getVendorFloatSensor(int sensor, float defaultValue) {
+ return floatValues.get(sensor, defaultValue);
+ }
+
+ public @Nullable Integer getSystemIntegerSensor(@IntegerSensorIndex int sensor) {
+ int index = intValues.indexOfKey(sensor);
+ if(index < 0) return null;
+ return intValues.valueAt(index);
+ }
+
+ public @Nullable Float getSystemFloatSensor(@FloatSensorIndex int sensor) {
+ int index = floatValues.indexOfKey(sensor);
+ if(index < 0) return null;
+ return floatValues.valueAt(index);
+ }
+
+ public @Nullable Integer getVendorIntegerSensor(int sensor) {
+ int index = intValues.indexOfKey(sensor);
+ if(index < 0) return null;
+ return intValues.valueAt(index);
+ }
+
+ public @Nullable Float getVendorFloatSensor(int sensor) {
+ int index = floatValues.indexOfKey(sensor);
+ if(index < 0) return null;
+ return floatValues.valueAt(index);
+ }
+
+ /**
+ * Represents possible states of the fuel system;
+ * see {@link Obd2IntegerSensorIndex#FUEL_SYSTEM_STATUS}
+ */
+ public static final class FuelSystemStatus {
+ private FuelSystemStatus() {}
+
+ public static final int OPEN_INSUFFICIENT_ENGINE_TEMPERATURE = 1;
+ public static final int CLOSED_LOOP = 2;
+ public static final int OPEN_ENGINE_LOAD_OR_DECELERATION = 4;
+ public static final int OPEN_SYSTEM_FAILURE = 8;
+ public static final int CLOSED_LOOP_BUT_FEEDBACK_FAULT = 16;
+
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef({
+ OPEN_INSUFFICIENT_ENGINE_TEMPERATURE,
+ CLOSED_LOOP,
+ OPEN_ENGINE_LOAD_OR_DECELERATION,
+ OPEN_SYSTEM_FAILURE,
+ CLOSED_LOOP_BUT_FEEDBACK_FAULT
+ })
+ public @interface Status {}
+ }
+
+ /**
+ * Represents possible states of the secondary air system;
+ * see {@link Obd2IntegerSensorIndex#COMMANDED_SECONDARY_AIR_STATUS}
+ */
+ public static final class SecondaryAirStatus {
+ private SecondaryAirStatus() {}
+
+ public static final int UPSTREAM = 1;
+ public static final int DOWNSTREAM_OF_CATALYCIC_CONVERTER = 2;
+ public static final int FROM_OUTSIDE_OR_OFF = 4;
+ public static final int PUMP_ON_FOR_DIAGNOSTICS = 8;
+
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef({
+ UPSTREAM,
+ DOWNSTREAM_OF_CATALYCIC_CONVERTER,
+ FROM_OUTSIDE_OR_OFF,
+ PUMP_ON_FOR_DIAGNOSTICS
+ })
+ public @interface Status {}
}
- public float getSystemFloatSensor(@FloatSensorIndex int index, float defaultValue) {
- return floatValues.get(index, defaultValue);
+ /**
+ * Represents possible types of fuel;
+ * see {@link Obd2IntegerSensorIndex#FUEL_TYPE}
+ */
+ public static final class FuelType {
+ private FuelType() {}
+
+ public static final int NOT_AVAILABLE = 0;
+ public static final int GASOLINE = 1;
+ public static final int METHANOL = 2;
+ public static final int ETHANOL = 3;
+ public static final int DIESEL = 4;
+ public static final int LPG = 5;
+ public static final int CNG = 6;
+ public static final int PROPANE = 7;
+ public static final int ELECTRIC = 8;
+ public static final int BIFUEL_RUNNING_GASOLINE = 9;
+ public static final int BIFUEL_RUNNING_METHANOL = 10;
+ public static final int BIFUEL_RUNNING_ETHANOL = 11;
+ public static final int BIFUEL_RUNNING_LPG = 12;
+ public static final int BIFUEL_RUNNING_CNG = 13;
+ public static final int BIFUEL_RUNNING_PROPANE = 14;
+ public static final int BIFUEL_RUNNING_ELECTRIC = 15;
+ public static final int BIFUEL_RUNNING_ELECTRIC_AND_COMBUSTION = 16;
+ public static final int HYBRID_GASOLINE = 17;
+ public static final int HYBRID_ETHANOL = 18;
+ public static final int HYBRID_DIESEL = 19;
+ public static final int HYBRID_ELECTRIC = 20;
+ public static final int HYBRID_RUNNING_ELECTRIC_AND_COMBUSTION = 21;
+ public static final int HYBRID_REGENERATIVE = 22;
+ public static final int BIFUEL_RUNNING_DIESEL = 23;
+
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef({
+ NOT_AVAILABLE,
+ GASOLINE,
+ METHANOL,
+ ETHANOL,
+ DIESEL,
+ LPG,
+ CNG,
+ PROPANE,
+ ELECTRIC,
+ BIFUEL_RUNNING_GASOLINE,
+ BIFUEL_RUNNING_METHANOL,
+ BIFUEL_RUNNING_ETHANOL,
+ BIFUEL_RUNNING_LPG,
+ BIFUEL_RUNNING_CNG,
+ BIFUEL_RUNNING_PROPANE,
+ BIFUEL_RUNNING_ELECTRIC,
+ BIFUEL_RUNNING_ELECTRIC_AND_COMBUSTION,
+ HYBRID_GASOLINE,
+ HYBRID_ETHANOL,
+ HYBRID_DIESEL,
+ HYBRID_ELECTRIC,
+ HYBRID_RUNNING_ELECTRIC_AND_COMBUSTION,
+ HYBRID_REGENERATIVE,
+ BIFUEL_RUNNING_DIESEL
+ })
+ public @interface Type {}
}
- public int getVendorIntegerSensor(int index, int defaultValue) {
- return intValues.get(index, defaultValue);
+ /**
+ * Represents possible states of the ignition monitors on the vehicle;
+ * see {@link Obd2IntegerSensorIndex#IGNITION_MONITORS_SUPPORTED}
+ * see {@link Obd2IntegerSensorIndex#IGNITION_SPECIFIC_MONITORS}
+ */
+ public static final class IgnitionMonitors {
+ public static final class IgnitionMonitor {
+ public final boolean mAvailable;
+ public final boolean mIncomplete;
+
+ IgnitionMonitor(boolean available, boolean incomplete) {
+ mAvailable = available;
+ mIncomplete = incomplete;
+ }
+
+ public static final class Builder {
+ private int mAvailableBitmask;
+ private int mIncompleteBitmask;
+
+ Builder() {
+ mAvailableBitmask = 0;
+ mIncompleteBitmask = 0;
+ }
+
+ public Builder withAvailableBitmask(int bitmask) {
+ mAvailableBitmask = bitmask;
+ return this;
+ }
+
+ public Builder withIncompleteBitmask(int bitmask) {
+ mIncompleteBitmask = bitmask;
+ return this;
+ }
+
+ public IgnitionMonitor buildForValue(int value) {
+ boolean available = (0 != (value & mAvailableBitmask));
+ boolean incomplete = (0 != (value & mIncompleteBitmask));
+
+ return new IgnitionMonitor(available, incomplete);
+ }
+ }
+ }
+
+ public static class CommonIgnitionMonitors {
+ public final IgnitionMonitor components;
+ public final IgnitionMonitor fuelSystem;
+ public final IgnitionMonitor misfire;
+
+ static final int COMPONENTS_AVAILABLE = 0x1 << 0;
+ static final int COMPONENTS_INCOMPLETE = 0x1 << 1;
+
+ static final int FUEL_SYSTEM_AVAILABLE = 0x1 << 2;
+ static final int FUEL_SYSTEM_INCOMPLETE = 0x1 << 3;
+
+ static final int MISFIRE_AVAILABLE = 0x1 << 4;
+ static final int MISFIRE_INCOMPLETE = 0x1 << 5;
+
+ static final IgnitionMonitor.Builder COMPONENTS_BUILDER =
+ new IgnitionMonitor.Builder()
+ .withAvailableBitmask(COMPONENTS_AVAILABLE)
+ .withIncompleteBitmask(COMPONENTS_INCOMPLETE);
+
+ static final IgnitionMonitor.Builder FUEL_SYSTEM_BUILDER =
+ new IgnitionMonitor.Builder()
+ .withAvailableBitmask(FUEL_SYSTEM_AVAILABLE)
+ .withIncompleteBitmask(FUEL_SYSTEM_INCOMPLETE);
+
+ static final IgnitionMonitor.Builder MISFIRE_BUILDER =
+ new IgnitionMonitor.Builder()
+ .withAvailableBitmask(MISFIRE_AVAILABLE)
+ .withIncompleteBitmask(MISFIRE_INCOMPLETE);
+
+ CommonIgnitionMonitors(int bitmask) {
+ components = COMPONENTS_BUILDER.buildForValue(bitmask);
+ fuelSystem = FUEL_SYSTEM_BUILDER.buildForValue(bitmask);
+ misfire = MISFIRE_BUILDER.buildForValue(bitmask);
+ }
+
+ public @Nullable SparkIgnitionMonitors asSparkIgnitionMonitors() {
+ if (this instanceof SparkIgnitionMonitors)
+ return (SparkIgnitionMonitors)this;
+ return null;
+ }
+
+ public @Nullable CompressionIgnitionMonitors asCompressionIgnitionMonitors() {
+ if (this instanceof CompressionIgnitionMonitors)
+ return (CompressionIgnitionMonitors)this;
+ return null;
+ }
+ }
+
+ public static final class SparkIgnitionMonitors extends CommonIgnitionMonitors {
+ public final IgnitionMonitor EGR;
+ public final IgnitionMonitor oxygenSensorHeater;
+ public final IgnitionMonitor oxygenSensor;
+ public final IgnitionMonitor ACRefrigerant;
+ public final IgnitionMonitor secondaryAirSystem;
+ public final IgnitionMonitor evaporativeSystem;
+ public final IgnitionMonitor heatedCatalyst;
+ public final IgnitionMonitor catalyst;
+
+ static final int EGR_AVAILABLE = 0x1 << 6;
+ static final int EGR_INCOMPLETE = 0x1 << 7;
+
+ static final int OXYGEN_SENSOR_HEATER_AVAILABLE = 0x1 << 8;
+ static final int OXYGEN_SENSOR_HEATER_INCOMPLETE = 0x1 << 9;
+
+ static final int OXYGEN_SENSOR_AVAILABLE = 0x1 << 10;
+ static final int OXYGEN_SENSOR_INCOMPLETE = 0x1 << 11;
+
+ static final int AC_REFRIGERANT_AVAILABLE = 0x1 << 12;
+ static final int AC_REFRIGERANT_INCOMPLETE = 0x1 << 13;
+
+ static final int SECONDARY_AIR_SYSTEM_AVAILABLE = 0x1 << 14;
+ static final int SECONDARY_AIR_SYSTEM_INCOMPLETE = 0x1 << 15;
+
+ static final int EVAPORATIVE_SYSTEM_AVAILABLE = 0x1 << 16;
+ static final int EVAPORATIVE_SYSTEM_INCOMPLETE = 0x1 << 17;
+
+ static final int HEATED_CATALYST_AVAILABLE = 0x1 << 18;
+ static final int HEATED_CATALYST_INCOMPLETE = 0x1 << 19;
+
+ static final int CATALYST_AVAILABLE = 0x1 << 20;
+ static final int CATALYST_INCOMPLETE = 0x1 << 21;
+
+ static final IgnitionMonitor.Builder EGR_BUILDER =
+ new IgnitionMonitor.Builder()
+ .withAvailableBitmask(EGR_AVAILABLE)
+ .withIncompleteBitmask(EGR_INCOMPLETE);
+
+ static final IgnitionMonitor.Builder OXYGEN_SENSOR_HEATER_BUILDER =
+ new IgnitionMonitor.Builder()
+ .withAvailableBitmask(OXYGEN_SENSOR_HEATER_AVAILABLE)
+ .withIncompleteBitmask(OXYGEN_SENSOR_HEATER_INCOMPLETE);
+
+ static final IgnitionMonitor.Builder OXYGEN_SENSOR_BUILDER =
+ new IgnitionMonitor.Builder()
+ .withAvailableBitmask(OXYGEN_SENSOR_AVAILABLE)
+ .withIncompleteBitmask(OXYGEN_SENSOR_INCOMPLETE);
+
+ static final IgnitionMonitor.Builder AC_REFRIGERANT_BUILDER =
+ new IgnitionMonitor.Builder()
+ .withAvailableBitmask(AC_REFRIGERANT_AVAILABLE)
+ .withIncompleteBitmask(AC_REFRIGERANT_INCOMPLETE);
+
+ static final IgnitionMonitor.Builder SECONDARY_AIR_SYSTEM_BUILDER =
+ new IgnitionMonitor.Builder()
+ .withAvailableBitmask(SECONDARY_AIR_SYSTEM_AVAILABLE)
+ .withIncompleteBitmask(SECONDARY_AIR_SYSTEM_INCOMPLETE);
+
+ static final IgnitionMonitor.Builder EVAPORATIVE_SYSTEM_BUILDER =
+ new IgnitionMonitor.Builder()
+ .withAvailableBitmask(EVAPORATIVE_SYSTEM_AVAILABLE)
+ .withIncompleteBitmask(EVAPORATIVE_SYSTEM_INCOMPLETE);
+
+ static final IgnitionMonitor.Builder HEATED_CATALYST_BUILDER =
+ new IgnitionMonitor.Builder()
+ .withAvailableBitmask(HEATED_CATALYST_AVAILABLE)
+ .withIncompleteBitmask(HEATED_CATALYST_INCOMPLETE);
+
+ static final IgnitionMonitor.Builder CATALYST_BUILDER =
+ new IgnitionMonitor.Builder()
+ .withAvailableBitmask(CATALYST_AVAILABLE)
+ .withIncompleteBitmask(CATALYST_INCOMPLETE);
+
+ SparkIgnitionMonitors(int bitmask) {
+ super(bitmask);
+ EGR = EGR_BUILDER.buildForValue(bitmask);
+ oxygenSensorHeater = OXYGEN_SENSOR_HEATER_BUILDER.buildForValue(bitmask);
+ oxygenSensor = OXYGEN_SENSOR_BUILDER.buildForValue(bitmask);
+ ACRefrigerant = AC_REFRIGERANT_BUILDER.buildForValue(bitmask);
+ secondaryAirSystem = SECONDARY_AIR_SYSTEM_BUILDER.buildForValue(bitmask);
+ evaporativeSystem = EVAPORATIVE_SYSTEM_BUILDER.buildForValue(bitmask);
+ heatedCatalyst = HEATED_CATALYST_BUILDER.buildForValue(bitmask);
+ catalyst = CATALYST_BUILDER.buildForValue(bitmask);
+ }
+ }
+
+ public static final class CompressionIgnitionMonitors extends CommonIgnitionMonitors {
+ public final IgnitionMonitor EGROrVVT;
+ public final IgnitionMonitor PMFilter;
+ public final IgnitionMonitor exhaustGasSensor;
+ public final IgnitionMonitor boostPressure;
+ public final IgnitionMonitor NOxSCR;
+ public final IgnitionMonitor NMHCCatalyst;
+
+ static final int EGR_OR_VVT_AVAILABLE = 0x1 << 6;
+ static final int EGR_OR_VVT_INCOMPLETE = 0x1 << 7;
+
+ static final int PM_FILTER_AVAILABLE = 0x1 << 8;
+ static final int PM_FILTER_INCOMPLETE = 0x1 << 9;
+
+ static final int EXHAUST_GAS_SENSOR_AVAILABLE = 0x1 << 10;
+ static final int EXHAUST_GAS_SENSOR_INCOMPLETE = 0x1 << 11;
+
+ static final int BOOST_PRESSURE_AVAILABLE = 0x1 << 12;
+ static final int BOOST_PRESSURE_INCOMPLETE = 0x1 << 13;
+
+ static final int NOx_SCR_AVAILABLE = 0x1 << 14;
+ static final int NOx_SCR_INCOMPLETE = 0x1 << 15;
+
+ static final int NMHC_CATALYST_AVAILABLE = 0x1 << 16;
+ static final int NMHC_CATALYST_INCOMPLETE = 0x1 << 17;
+
+ static final IgnitionMonitor.Builder EGR_OR_VVT_BUILDER =
+ new IgnitionMonitor.Builder()
+ .withAvailableBitmask(EGR_OR_VVT_AVAILABLE)
+ .withIncompleteBitmask(EGR_OR_VVT_INCOMPLETE);
+
+ static final IgnitionMonitor.Builder PM_FILTER_BUILDER =
+ new IgnitionMonitor.Builder()
+ .withAvailableBitmask(PM_FILTER_AVAILABLE)
+ .withIncompleteBitmask(PM_FILTER_INCOMPLETE);
+
+ static final IgnitionMonitor.Builder EXHAUST_GAS_SENSOR_BUILDER =
+ new IgnitionMonitor.Builder()
+ .withAvailableBitmask(EXHAUST_GAS_SENSOR_AVAILABLE)
+ .withIncompleteBitmask(EXHAUST_GAS_SENSOR_INCOMPLETE);
+
+ static final IgnitionMonitor.Builder BOOST_PRESSURE_BUILDER =
+ new IgnitionMonitor.Builder()
+ .withAvailableBitmask(BOOST_PRESSURE_AVAILABLE)
+ .withIncompleteBitmask(BOOST_PRESSURE_INCOMPLETE);
+
+ static final IgnitionMonitor.Builder NOx_SCR_BUILDER =
+ new IgnitionMonitor.Builder()
+ .withAvailableBitmask(NOx_SCR_AVAILABLE)
+ .withIncompleteBitmask(NOx_SCR_INCOMPLETE);
+
+ static final IgnitionMonitor.Builder NMHC_CATALYST_BUILDER =
+ new IgnitionMonitor.Builder()
+ .withAvailableBitmask(NMHC_CATALYST_AVAILABLE)
+ .withIncompleteBitmask(NMHC_CATALYST_INCOMPLETE);
+
+ CompressionIgnitionMonitors(int bitmask) {
+ super(bitmask);
+ EGROrVVT = EGR_OR_VVT_BUILDER.buildForValue(bitmask);
+ PMFilter = PM_FILTER_BUILDER.buildForValue(bitmask);
+ exhaustGasSensor = EXHAUST_GAS_SENSOR_BUILDER.buildForValue(bitmask);
+ boostPressure = BOOST_PRESSURE_BUILDER.buildForValue(bitmask);
+ NOxSCR = NOx_SCR_BUILDER.buildForValue(bitmask);
+ NMHCCatalyst = NMHC_CATALYST_BUILDER.buildForValue(bitmask);
+ }
+ }
+ }
+
+ public @Nullable @FuelSystemStatus.Status Integer getFuelSystemStatus() {
+ return getSystemIntegerSensor(Obd2IntegerSensorIndex.FUEL_SYSTEM_STATUS);
+ }
+
+ public @Nullable @SecondaryAirStatus.Status Integer getSecondaryAirStatus() {
+ return getSystemIntegerSensor(Obd2IntegerSensorIndex.COMMANDED_SECONDARY_AIR_STATUS);
+ }
+
+ public @Nullable IgnitionMonitors.CommonIgnitionMonitors getIgnitionMonitors() {
+ Integer ignitionMonitorsType = getSystemIntegerSensor(
+ Obd2IntegerSensorIndex.IGNITION_MONITORS_SUPPORTED);
+ Integer ignitionMonitorsBitmask = getSystemIntegerSensor(
+ Obd2IntegerSensorIndex.IGNITION_SPECIFIC_MONITORS);
+ if (null == ignitionMonitorsType) return null;
+ if (null == ignitionMonitorsBitmask) return null;
+ switch (ignitionMonitorsType) {
+ case 0: return new IgnitionMonitors.SparkIgnitionMonitors(
+ ignitionMonitorsBitmask);
+ case 1: return new IgnitionMonitors.CompressionIgnitionMonitors(
+ ignitionMonitorsBitmask);
+ default: return null;
+ }
}
- public float getVendorFloatSensor(int index, float defaultValue) {
- return floatValues.get(index, defaultValue);
+ public @Nullable @FuelType.Type Integer getFuelType() {
+ return getSystemIntegerSensor(Obd2IntegerSensorIndex.FUEL_TYPE);
}
}