Shrink output channels, now with passing CI (#1077)

* reorder fields

* temporary tle8888 fix

* comment, simplify

* hand tweak generated

* oops, those are reciprocal

* fix engineLoadAccelExtra

* aggressive priority order

* fix output size

* comments

* reorder fields, no sizes yet

* should've been signed

* simplify constructor mess, hook up scaling

* notes

* typo

* if -> switch

* rev signature

* correct map offset

* handle unsigned properly

* RPM is unsigned

* vss isn't scaled

* extract magic

* required generated for build

* de-scale rpm

* field type cases
This commit is contained in:
Matthew Kennedy 2019-12-22 05:12:45 -08:00 committed by rusefi
parent bbda0457d5
commit 9645130527
14 changed files with 543 additions and 386 deletions

View File

@ -1552,6 +1552,13 @@
#define overrideCrankingIacSetting_offset_hex 5c4
#define overrideCrankingIgnition_offset 516
#define overrideCrankingIgnition_offset_hex 204
#define PACK_MULT_AFR 1000
#define PACK_MULT_ANGLE 50
#define PACK_MULT_MS 300
#define PACK_MULT_PERCENT 100
#define PACK_MULT_PRESSURE 30
#define PACK_MULT_TEMPERATURE 100
#define PACK_MULT_VOLTAGE 1000
#define pauseEtbControl_offset 744
#define pauseEtbControl_offset_hex 2e8
#define PEDAL_TO_TPS_SIZE 8
@ -1947,8 +1954,8 @@
#define triggerSimulatorPins2_offset_hex 2e1
#define triggerSimulatorPins3_offset 738
#define triggerSimulatorPins3_offset_hex 2e2
#define TS_FILE_VERSION 20190701
#define TS_OUTPUT_SIZE 356
#define TS_FILE_VERSION 20191221
#define TS_OUTPUT_SIZE 220
#define ts_show_cj125 true
#define ts_show_egt true
#define ts_show_etb true
@ -1958,7 +1965,7 @@
#define ts_show_hip9011 true
#define ts_show_joystick true
#define ts_show_lcd true
#define TS_SIGNATURE "rusEFI v1.07"
#define TS_SIGNATURE "rusEFI v1.08"
#define tunerStudioSerialSpeed_offset 728
#define tunerStudioSerialSpeed_offset_hex 2d8
#define twoWireBatchIgnition_offset 1476

View File

@ -12,6 +12,49 @@
#define TUNERSTUDIO_CONFIGURATION_H_
#include "rusefi_types.h"
#include "rusefi_generated.h"
#include "tunerstudio_debug_struct.h"
// This class lets us transparently store something at a ratio inside an integer type
// Just use it like a float - you can read and write to it, like this:
// scaled_channel<uint8_t, 10> myVar;
// myVar = 2.4f; // converts to an int, stores 24
// float x = myVar; // converts back to float, returns 2.4f
template <typename T, int mult = 1>
class scaled_channel {
public:
scaled_channel() : m_value(static_cast<T>(0)) { }
scaled_channel(float val)
: m_value(val * mult)
{
}
// Allow reading back out as a float (note: this may be lossy!)
operator float() const {
return m_value / (float)mult;
}
private:
T m_value;
};
// We need to guarantee that scaled values containing some type are the same size
// as that underlying type. We rely on the class only having a single member for
// this trick to work.
static_assert(sizeof(scaled_channel<uint8_t>) == 1);
static_assert(sizeof(scaled_channel<uint16_t>) == 2);
static_assert(sizeof(scaled_channel<uint32_t>) == 4);
static_assert(sizeof(scaled_channel<float>) == 4);
// Common scaling options - use these if you can!
using scaled_temperature = scaled_channel<int16_t, PACK_MULT_TEMPERATURE>; // +-327 deg C at 0.01 deg resolution
using scaled_ms = scaled_channel<int16_t, PACK_MULT_MS>; // +- 100ms at 0.003ms precision
using scaled_percent = scaled_channel<int16_t, PACK_MULT_PERCENT>; // +-327% at 0.01% resolution
using scaled_pressure = scaled_channel<uint16_t, PACK_MULT_PRESSURE>; // 0-2000kPa (~300psi) at 0.03kPa resolution
using scaled_angle = scaled_channel<int16_t, PACK_MULT_ANGLE>; // +-655 degrees at 0.02 degree resolution
using scaled_voltage = scaled_channel<uint16_t, PACK_MULT_VOLTAGE>; // 0-65v at 1mV resolution
using scaled_afr = scaled_channel<uint16_t, PACK_MULT_AFR>; // 0-65afr at 0.001 resolution
#define PAGE_COUNT 1
@ -29,36 +72,7 @@ typedef struct {
*/
typedef struct {
/* see also [OutputChannels] in rusefi.input */
// primary instrument cluster gauges
int rpm; // size 4, offset 0
/**
* This value is in Celcius - UI would convert into F if needed
*/
float coolantTemperature; // size 4, offset 4
float intakeAirTemperature; // size 4, offset 8
float throttlePositon; // size 4, offset 12
float massAirFlowVoltage; // size 4, offset 16
float airFuelRatio; // size 4, offset 20
float engineLoad; // size 4, offset 24
float vBatt; // size 4, offset 28
short int tpsADC; // size 2, offset 32
short int alignment; // size 2, offset 34
float baroPressure; // size 4, offset 36
float manifoldAirPressure; // size 4, offset 40
float crankingFuelMs; // offset 44
/**
* This is the raw value we take from the fuel map or base fuel algorithm, before the corrections
*/
float fuelBase; // 48
float tCharge; // 52
float ignitionAdvance; // 56
float sparkDwell; // 60
/**
* this one contains total resulting fuel squirt time, per event
* With all corrections and injector lag. See also baseFuel
*/
float actualLastInjection; // 64
float debugFloatField1; // 68
/**
* Yes, I do not really enjoy packing bits into integers but we simply have too many boolean flags and I cannot
* water 4 bytes per traffic - I want gauges to work as fast as possible
@ -81,107 +95,139 @@ typedef struct {
unsigned int brakePedalState : 1; // bit 15. 0 - not pressed, 1 = pressed
unsigned int toothLogReady : 1; // bit 16
unsigned int acSwitchState : 1; // bit 17. 0 - not pressed, 1 = pressed
float vehicleSpeedKph; // 76
unsigned int isTpsError : 1; // bit 0, 80
unsigned int isCltError : 1; // bit 1
unsigned int isMapError : 1; // bit 2
unsigned int isIatError : 1; // bit 3
unsigned int isAcSwitchEngaged : 1; // bit 4
unsigned int isTriggerError : 1; // bit 5
unsigned int hasFatalError : 1; // bit 6
unsigned int isWarnNow : 1; // bit 7
unsigned int unused80b8 : 1; // bit 8
unsigned int isKnockChipOk : 1; // bit 9
int tsConfigVersion; // 84
egt_values_s egtValues; // 88
float rpmAcceleration; // 104
float massAirFlow; // 108
/**
* Current volumetric efficiency
*/
float veValue; // offset 112
/**
* TPS value delta within specified number of cycles
* See tpsAccelFuel
*/
float deltaTps; // offset 116
int triggerErrorsCounter; // offset 120
/**
* Engine load delta
*/
float engineLoadAccelExtra; // offset 124
float tpsAccelFuel; // offset 128
float baroCorrection; // 132
float pedalPosition; // 136
/**
* @see coilDutyCycle
*/
float injectorDutyCycle; // 140
int knockCount; // 144
float fuelTankLevel; // 148
float knockLevel; // 152
int totalTriggerErrorCounter; // 156
float wallFuelAmount; // 160
/**
* multiplier, 1 means no correction, 1.20 means 20% extra
*/
float iatCorrection; // 164
floatms_t wallFuelCorrection; // 168
float idlePosition; // 172
float currentTargetAfr; // 176
float chargeAirMass; // 180
/**
* multiplier, 1 means no correction, 1.20 means 20% extra
*/
float cltCorrection; // 184
/**
* Total fuel with CLT, IAT and TPS acceleration without injector lag corrections per cycle,
* as squirt duration.
*
* @see actualLastInjection
*/
float fuelRunning; // 188
int debugIntField1; // 192
float injectorLagMs; // 196
float debugFloatField2; // 200
float debugFloatField3; // 204
float debugFloatField4; // 208
float debugFloatField5; // 212
int debugIntField2; // 216
int debugIntField3; // 220
int timeSeconds; // 224
float engineLoadDelta; // 228
float speedToRpmRatio; // 232
int16_t warningCounter; // 236
int16_t unused_238;
int16_t lastErrorCode; // 240
int16_t unused_242;
/**
* Microcontroller own internal temperature, C
*/
float internalMcuTemperature; // 244
float vvtPosition; // 248
int engineMode; // 252
float debugFloatField6; // 256
float debugFloatField7; // 260
int firmwareVersion; // 264
float fuelPidCorrection; // 268
/**
* @see injectorDutyCycle
*/
float coilDutyCycle; // 272
int16_t accelerationX; // 276
int16_t accelerationY; // 278
float oilPressure; // 280
float fuelConsumptionPerHour; // 284
float injectionOffset; // 288
int16_t debugIntField4; // 292
int16_t debugIntField5; // 294
int16_t recentErrorCodes[8]; // 298
float etbTarget; // 312
float etb1DutyCycle; // 316
float etb1Error; // 320
int unused3[8];
unsigned int isTpsError : 1; // bit 18
unsigned int isCltError : 1; // bit 19
unsigned int isMapError : 1; // bit 20
unsigned int isIatError : 1; // bit 21
unsigned int isAcSwitchEngaged : 1; // bit 22
unsigned int isTriggerError : 1; // bit 23
unsigned int hasFatalError : 1; // bit 24
unsigned int isWarnNow : 1; // bit 25
unsigned int unused80b8 : 1; // bit 26
unsigned int isKnockChipOk : 1; // bit 27
// RPM, vss
scaled_channel<uint16_t> rpm; // 4
scaled_percent rpmAcceleration; // 6
scaled_percent speedToRpmRatio; // 8
scaled_channel<uint8_t> vehicleSpeedKph; // 10
// temperatures
scaled_channel<int8_t> internalMcuTemperature; // offset 11
scaled_temperature coolantTemperature; // offset 12
scaled_temperature intakeAirTemperature; // offset 14
scaled_temperature auxTemp1; // offset 16
scaled_temperature auxTemp2; // offset 18
// throttle, pedal
scaled_percent throttlePosition; // 20
scaled_percent pedalPosition; // 22
uint16_t tpsADC; // 24
// air flow/mass measurment
scaled_voltage massAirFlowVoltage; // 26
scaled_channel<uint16_t, 100> massAirFlow; // 28
scaled_pressure manifoldAirPressure; // 30
scaled_pressure baroPressure; // 32
scaled_afr airFuelRatio; // 34
scaled_channel<uint16_t, 100> engineLoad; // 36
// misc sensors
scaled_voltage vBatt; // 38
scaled_pressure oilPressure; // 40
scaled_angle vvtPosition; // 42
// Fuel math
scaled_channel<uint16_t, 1000> chargeAirMass; // 44
scaled_ms crankingFuelMs; // 46
scaled_afr currentTargetAfr; // 48
// This is the raw value we take from the fuel map or base fuel algorithm, before the corrections
scaled_ms fuelBase; // 50
// Total fuel with CLT, IAT and TPS acceleration without injector lag corrections per cycle, as pulse per cycle
scaled_ms fuelRunning; // 52
// Actual last injection time - including all compensation and injection mode
scaled_ms actualLastInjection; // 54
scaled_channel<uint8_t, 2> injectorDutyCycle; // 56
scaled_channel<uint8_t, 2> veValue; // 57
scaled_angle injectionOffset; // 58
scaled_temperature tCharge; // 60
// Corrections
scaled_ms injectorLagMs; // 62
scaled_percent iatCorrection; // 64
scaled_percent cltCorrection; // 66
scaled_percent baroCorrection; // 68
scaled_ms fuelPidCorrection; // 70
// Wall model AE
scaled_ms wallFuelAmount; // 72
scaled_channel<int16_t, 1000> wallFuelCorrection; // 74
// TPS/load AE
scaled_percent engineLoadDelta; // 76
scaled_percent deltaTps; // 78
scaled_percent engineLoadAccelExtra; // 80
scaled_ms tpsAccelFuel; // 82
// Ignition
scaled_angle ignitionAdvance; // 84
scaled_ms sparkDwell; // 86
scaled_percent coilDutyCycle; // 88
// Idle & ETB
scaled_percent idlePosition; // 90
scaled_percent etbTarget; // 92
scaled_percent etb1DutyCycle; // 94
scaled_percent etb1Error; // 96
// Fuel system
scaled_percent fuelTankLevel; // 98
float fuelConsumptionPerHour; // 100
// Knock
uint32_t knockCount; // 104
float knockLevel; // 108
// Mode, firmware, protocol, run time
uint32_t timeSeconds; // 112
uint32_t engineMode; // 116
uint32_t firmwareVersion; // 120
uint32_t tsConfigVersion; // 124
// Errors
int triggerErrorsCounter; // 128
int totalTriggerErrorCounter; // 132
int16_t warningCounter; // 136
int16_t lastErrorCode; // 138
int16_t recentErrorCodes[8]; // 140
// Debug
float debugFloatField1; // 156
float debugFloatField2;
float debugFloatField3;
float debugFloatField4;
float debugFloatField5;
float debugFloatField6;
float debugFloatField7;
int debugIntField1;
int debugIntField2;
int debugIntField3;
int16_t debugIntField4;
int16_t debugIntField5; // 198
// accelerometer
int16_t accelerationX; // 200
int16_t accelerationY; // 202
// EGT
egt_values_s egtValues; // 204
// Temporary - will remove soon
TsDebugChannels* getDebugChannels() {
return reinterpret_cast<TsDebugChannels*>(&debugFloatField1);
}
/* see also [OutputChannels] in rusefi.input */
} TunerStudioOutputChannels;

View File

@ -0,0 +1,16 @@
#pragma once
typedef struct {
float debugFloatField1; // 180
float debugFloatField2;
float debugFloatField3;
float debugFloatField4;
float debugFloatField5;
float debugFloatField6;
float debugFloatField7;
int debugIntField1;
int debugIntField2;
int debugIntField3;
int16_t debugIntField4;
int16_t debugIntField5;
} TsDebugChannels;

View File

@ -720,7 +720,7 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
// offset 8
tsOutputChannels->intakeAirTemperature = intake;
// offset 12
tsOutputChannels->throttlePositon = tps;
tsOutputChannels->throttlePosition = tps;
// offset 16
tsOutputChannels->massAirFlowVoltage = hasMafSensor() ? getMafVoltage(PASS_ENGINE_PARAMETER_SIGNATURE) : 0;
@ -1015,7 +1015,7 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
break;
case DBG_TLE8888:
#if (BOARD_TLE8888_COUNT > 0)
tle8888PostState(tsOutputChannels);
tle8888PostState(tsOutputChannels->getDebugChannels());
#endif /* BOARD_TLE8888_COUNT */
break;
default:

View File

@ -819,6 +819,6 @@ int getRusEfiVersion(void) {
if (initBootloader() != 0)
return 123;
#endif /* EFI_BOOTLOADER_INCLUDE_CODE */
return 20191213;
return 20191221;
}
#endif /* EFI_UNIT_TEST */

View File

@ -1552,6 +1552,13 @@
#define overrideCrankingIacSetting_offset_hex 5c4
#define overrideCrankingIgnition_offset 516
#define overrideCrankingIgnition_offset_hex 204
#define PACK_MULT_AFR 1000
#define PACK_MULT_ANGLE 50
#define PACK_MULT_MS 300
#define PACK_MULT_PERCENT 100
#define PACK_MULT_PRESSURE 30
#define PACK_MULT_TEMPERATURE 100
#define PACK_MULT_VOLTAGE 1000
#define pauseEtbControl_offset 744
#define pauseEtbControl_offset_hex 2e8
#define PEDAL_TO_TPS_SIZE 8
@ -1947,8 +1954,8 @@
#define triggerSimulatorPins2_offset_hex 2e1
#define triggerSimulatorPins3_offset 738
#define triggerSimulatorPins3_offset_hex 2e2
#define TS_FILE_VERSION 20190701
#define TS_OUTPUT_SIZE 356
#define TS_FILE_VERSION 20191221
#define TS_OUTPUT_SIZE 220
#define ts_show_cj125 true
#define ts_show_egt true
#define ts_show_etb true
@ -1958,7 +1965,7 @@
#define ts_show_hip9011 true
#define ts_show_joystick true
#define ts_show_lcd true
#define TS_SIGNATURE "rusEFI v1.07"
#define TS_SIGNATURE "rusEFI v1.08"
#define tunerStudioSerialSpeed_offset 728
#define tunerStudioSerialSpeed_offset_hex 2d8
#define twoWireBatchIgnition_offset 1476

View File

@ -145,14 +145,14 @@ static const char* tle8888_pin_names[TLE8888_OUTPUTS] = {
};
#if EFI_TUNER_STUDIO
void tle8888PostState(TunerStudioOutputChannels *tsOutputChannels) {
tsOutputChannels->debugIntField1 = tle8888SpiCounter;
tsOutputChannels->debugIntField2 = spiTxb;
tsOutputChannels->debugIntField3 = spiRxb;
tsOutputChannels->debugIntField4 = initResponsesAccumulator;
tsOutputChannels->debugIntField5 = reinitializationCounter;
tsOutputChannels->debugFloatField1 = initResponse0;
tsOutputChannels->debugFloatField2 = initResponse1;
void tle8888PostState(TsDebugChannels *debugChannels) {
debugChannels->debugIntField1 = tle8888SpiCounter;
debugChannels->debugIntField2 = spiTxb;
debugChannels->debugIntField3 = spiRxb;
debugChannels->debugIntField4 = initResponsesAccumulator;
debugChannels->debugIntField5 = reinitializationCounter;
debugChannels->debugFloatField1 = initResponse0;
debugChannels->debugFloatField2 = initResponse1;
}
#endif /* EFI_TUNER_STUDIO */

View File

@ -54,8 +54,8 @@ int tle8888_add(unsigned int index, const struct tle8888_config *cfg);
void requestTLE8888initialization(void);
#if EFI_TUNER_STUDIO
#include "tunerstudio_configuration.h"
void tle8888PostState(TunerStudioOutputChannels *tsOutputChannels);
#include "tunerstudio_debug_struct.h"
void tle8888PostState(TsDebugChannels *tsDebugChannels);
#endif /* EFI_TUNER_STUDIO */
#ifdef __cplusplus

View File

@ -23,12 +23,12 @@
! type name;comment
#define TS_SIGNATURE "rusEFI v1.07"
#define TS_SIGNATURE "rusEFI v1.08"
!
! this is used to confirm that firmware and TunerStudio are using the same rusefi.ini version
! so not forget to change fileVersion in rusefi.ini
! todo: is this not needed in light of TS_SIGNATURE?
#define TS_FILE_VERSION 20190701
#define TS_FILE_VERSION 20191221
! all the sub-structures are going to be nested within the primary structure, that's
@ -68,7 +68,7 @@ struct_no_prefix engine_configuration_s
#define ETB_BIAS_CURVE_LENGTH 8
! this is here so that rusEfi console can access it, too
#define TS_OUTPUT_SIZE 356
#define TS_OUTPUT_SIZE 220
#define MAP_ANGLE_SIZE 8
#define MAP_WINDOW_SIZE 8
@ -128,6 +128,15 @@ struct_no_prefix engine_configuration_s
#define RPM_1_BYTE_PACKING_MULT 50
#define VOLTAGE_1_BYTE_PACKING_DIV 0.02
! These are used currently only for output channels - but could be for config as well
#define PACK_MULT_PRESSURE 30
#define PACK_MULT_PERCENT 100
#define PACK_MULT_TEMPERATURE 100
#define PACK_MULT_MS 300
#define PACK_MULT_AFR 1000
#define PACK_MULT_ANGLE 50
#define PACK_MULT_VOLTAGE 1000
#define FSIO_TABLE_8 8
#define FSIO_CURVE_8 8

View File

@ -167,136 +167,172 @@ fileVersion = { 20190701 }
;
; see TunerStudioOutputChannels struct
;
RPMValue = scalar, U32, 0, "RPM", 1, 0.00000
; Bit flags
hasSdCard = bits, U32, 0, [0:0], "true", "false";
isIgnitionEnabledIndicator=bits,U32, 0, [1:1], "true", "false";
ind_injection_enabled=bits,U32, 0, [2:2], "true", "false";
isCylinderCleanupEnabled=bits,U32, 0, [3:3], "true", "false";
isCylinderCleanupActivated=bits,U32, 0, [4:4], "true", "false";
ind_fuel_pump = bits, U32, 0, [5:5], "true", "false";
ind_fan = bits, U32, 0, [6:6], "true", "false";
ind_o2_heater = bits, U32, 0, [7:7], "true", "false";
ind_check_engine= bits, U32, 0, [8:8], "true", "false";
needBurn = bits, U32, 0, [9:9], "true", "false";
ind_2nd_trigger_en=bits, U32, 0, [10:10], "true", "false";
clutchUpState =bits, U32, 0, [11:11], "true", "false";
clutchDownState =bits, U32, 0, [12:12], "true", "false";
knockEverIndicator=bits, U32, 0, [13:13], "true", "false";
knockNowIndicator=bits, U32, 0, [14:14], "true", "false";
brakePedalIndicator=bits, U32, 0, [15:15], "true", "false";
toothLogReady =bits, U32, 0, [16:16], "true", "false";
acSwitchIndicator =bits, U32, 0, [17:17], "true", "false";
ind_tps_error = bits, U32, 0, [18:18], "true", "false";
ind_clt_error = bits, U32, 0, [19:19], "true", "false";
ind_map_error = bits, U32, 0, [20:21], "true", "false";
ind_iat_error = bits, U32, 0, [21:22], "true", "false";
ind_isTriggerError = bits, U32, 0, [23:23], "true", "false";
ind_hasFatalError=bits, U32, 0, [24:24], "true", "false";
ind_isWarnNow =bits, U32, 0, [25:25], "true", "false";
; RPM, vss
RPMValue = scalar, U16, 4, "RPM", 1, 0.00000
rpmAcceleration = scalar, S16, 6, "dRpm",{1/@@PACK_MULT_PERCENT@@}, 0
speedToRpmRatio = scalar, S16, 8, "value",{1/@@PACK_MULT_PERCENT@@}, 0
vehicleSpeedKph = scalar, U08, 10, "kph", 1, 0.0
; temperatures
internalMcuTemperature = scalar,S08, 11, "deg C", 1, 0
#if CELSIUS
coolant = scalar, F32, 4, "deg C", 1, 0.0
coolant = scalar, S16, 12, "deg C",{1/@@PACK_MULT_TEMPERATURE@@}, 0.0
#else
coolant = scalar, F32, 4, "deg F", {9/5}, 17.77777
coolant = scalar, S16, 12, "deg F",{9/(5 * @@PACK_MULT_TEMPERATURE@@)}, 17.77777
#endif
#if CELSIUS
intake = scalar, F32, 8, "deg C", 1, 0.0
intake = scalar, S16, 14, "deg C",{1/@@PACK_MULT_TEMPERATURE@@}, 0.0
#else
intake = scalar, F32, 8, "deg F", {9/5}, 17.77777
intake = scalar, S16, 14, "deg F",{9/(5 * @@PACK_MULT_TEMPERATURE@@)}, 17.77777
#endif
TPSValue = scalar, F32, 12, "%", 1, 0
MAFValue = scalar, F32, 16, "V", 1, 0
AFRValue = scalar, F32, 20, "AFR", 1, 0.0
engineLoad = scalar, F32, 24, "%", 1, 0.0 ; Blend of MAP and TPS, depends on algorithm
VBatt = scalar, F32, 28, "V", 1, 0.0
; todo: aux1
; todo: aux2
; throttle, pedal
TPSValue = scalar, U16, 20, "%",{1/@@PACK_MULT_PERCENT@@}, 0
throttlePedalPosition = scalar,U16, 22, "%",{1/@@PACK_MULT_PERCENT@@}, 0
tpsADC = scalar, U16, 24, "ADC", 1, 0.0;
; air flow/mass measurments
MAFValue = scalar, U16, 26, "V",,{1/@@PACK_MULT_VOLTAGE@@},, 0
massAirFlowValue= scalar, U16, 28, "Kg/h", 0.01, 0
MAPValue = scalar, U16, 30, "kPa",{1/@@PACK_MULT_PRESSURE@@}, 0.0
baroPressure = scalar, U16, 32, "kPa",{1/@@PACK_MULT_PRESSURE@@}, 0.0
AFRValue = scalar, U16, 34, "AFR",,{1/@@PACK_MULT_AFR@@},, 0.0
engineLoad = scalar, U16, 36, "%",{1/@@PACK_MULT_PERCENT@@}, 0.0 ; Blend of MAP and TPS, depends on algorithm
; misc sensors
VBatt = scalar, U16, 38, "V",,{1/@@PACK_MULT_VOLTAGE@@},, 0.0
oilPressure = scalar, U16, 40, "kPa",{1/@@PACK_MULT_PRESSURE@@}, 0.0
vvtPosition = scalar, U16, 42, "deg",{1/@@PACK_MULT_ANGLE@@}, 0
; 10 bit TPS ADC value (from 0 to 1023 in 5v scale)
tpsADC = scalar, U16, 32, "ADC", 1, 0.0;
tpsADC2 = scalar, U16, 34, "ADC", 1, 0.0;
baroPressure = scalar, F32, 36, "pres", 1, 0.0;
MAPValue = scalar, F32, 40, "MAP", 1, 0.0;
; total fuel squirt duration (in MS) per engine cycle according to current CLT
crankingFuelMs = scalar, F32, 44, "ms", 1, 0.0;
baseFuel = scalar, F32, 48, "ms", 1, 0
tCharge = scalar, F32, 52, "T", 1, 0.0;
ignitionAdvance = scalar, F32, 56, "deg", 1, 0.0;
sparkDwellValue = scalar, F32, 60, "ms", 1, 0.0;
; actual total Ms time per engine cycle with all corrections
actualLastInjection = scalar, F32, 64, "ms", 1, 0.0;
debugFloatField1 = scalar, F32, 68, "val", 1, 0.0;
hasSdCard = bits, U32, 72, [0:0], "true", "false";
isIgnitionEnabledIndicator=bits, U32, 72, [1:1], "true", "false";
ind_injection_enabled=bits,U32, 72, [2:2], "true", "false";
isCylinderCleanupEnabled=bits, U32, 72, [3:3], "true", "false";
isCylinderCleanupActivated=bits,U32,72, [4:4], "true", "false";
ind_fuel_pump = bits, U32, 72, [5:5], "true", "false";
ind_fan = bits, U32, 72, [6:6], "true", "false";
ind_o2_heater = bits, U32, 72, [7:7], "true", "false";
ind_check_engine= bits, U32, 72, [8:8], "true", "false";
needBurn = bits, U32, 72, [9:9], "true", "false";
ind_2nd_trigger_en=bits, U32, 72, [10:10], "true", "false";
clutchUpState =bits, U32, 72, [11:11], "true", "false";
clutchDownState =bits, U32, 72, [12:12], "true", "false";
knockEverIndicator=bits, U32, 72, [13:13], "true", "false";
knockNowIndicator=bits, U32, 72, [14:14], "true", "false";
brakePedalIndicator=bits, U32, 72, [15:15], "true", "false";
toothLogReady =bits, U32, 72, [16:16], "true", "false";
acSwitchIndicator =bits, U32, 72, [17:17], "true", "false";
vehicleSpeedKph = scalar, F32, 76, "kph", 1, 0.0;
ind_tps_error = bits, U32, 80, [0:0], "true", "false";
ind_clt_error = bits, U32, 80, [1:1], "true", "false";
ind_map_error = bits, U32, 80, [2:2], "true", "false";
ind_iat_error = bits, U32, 80, [3:3], "true", "false";
ind_isTriggerError = bits, U32, 80, [5:5], "true", "false";
ind_hasFatalError=bits, U32, 80, [6:6], "true", "false";
ind_isWarnNow =bits, U32, 80, [7:7], "true", "false";
firmwareTsVersion = scalar,U32, 84, "version_p", 1, 0
egt1 = scalar, S16, 88, "deg C", 1, 0
egt2 = scalar, S16, 90, "deg C", 1, 0
egt3 = scalar, S16, 92, "deg C", 1, 0
egt4 = scalar, S16, 94, "deg C", 1, 0
egt5 = scalar, S16, 96, "deg C", 1, 0
egt6 = scalar, S16, 98, "deg C", 1, 0
egt7 = scalar, S16, 100, "deg C", 1, 0
egt8 = scalar, S16, 102, "deg C", 1, 0
rpmAcceleration = scalar, F32, 104, "dRpm", 1, 0
massAirFlowValue= scalar, F32, 108, "Kg/h", 1, 0
veValue = scalar, F32, 112, "ratio", 1, 0
deltaTps = scalar, F32, 116, "ratio", 1, 0
triggerErrorsCounter = scalar, U32,120, "counter", 1, 0
engineLoadAccelExtra = scalar,F32, 124, "value", 1, 0
tpsAccelFuel = scalar, F32, 128, "ms", 1, 0
baroCorrection = scalar, F32, 132, "%", 1, 0
throttlePedalPosition = scalar, F32, 136, "%", 1, 0
injectorDutyCycle= scalar, F32, 140, "%", 1, 0
knockCount = scalar, U32, 144, "counter", 1, 0
fuelTankLevel = scalar, F32, 148, "amount", 1, 0
knockLevel = scalar, F32, 152, "Volts", 1, 0
; totalTriggerErrorCounter 156
wallFuelAmount = scalar, F32, 160, "ms", 1, 0
iatCorrection = scalar, F32, 164, "%", 1, 0
wallFuelCorrection = scalar, F32, 168, "ms", 1, 0
idleAirValvePosition = scalar, F32, 172, "percent", 1, 0
currentTargetAfr = scalar, F32, 176, "ratio", 1, 0
chargeAirMass = scalar, F32, 180, "g", 1, 0
cltCorrection = scalar, F32, 184, "%", 1, 0
fuelRunning = scalar, F32, 188, "g", 1, 0
debugIntField1 = scalar, S32, 192, "val", 1, 0.0;
injectorLagMs = scalar, F32, 196, "ms", 1, 0.0;
debugFloatField2 = scalar, F32, 200, "val", 1, 0.0;
debugFloatField3 = scalar, F32, 204, "val", 1, 0.0;
debugFloatField4 = scalar, F32, 208, "val", 1, 0.0;
debugFloatField5 = scalar, F32, 212, "val", 1, 0.0;
debugIntField2 = scalar, S32, 216, "val", 1, 0.0;
debugIntField3 = scalar, S32, 220, "val", 1, 0.0;
timeSeconds = scalar, U32, 224, "sec", 1, 0.0;
engineLoadDelta = scalar,F32, 228, "value", 1, 0
speedToRpmRatio = scalar,F32, 232, "value", 1, 0
warningCounter = scalar,U16, 236, "count", 1, 0
lastErrorCode = scalar,U16, 240, "error", 1, 0
internalMcuTemperature = scalar,F32, 244, "C", 1, 0
vvtPosition = scalar,F32, 248, "deg", 1, 0
engineMode = scalar, U32, 252, "em", 1, 0.0;
debugFloatField6 = scalar, F32, 256, "val", 1, 0.0;
debugFloatField7 = scalar, F32, 260, "val", 1, 0.0;
firmwareVersion = scalar,U32, 264, "version_f", 1, 0
fuelPidCorrection = scalar, F32, 268, "ms", 1, 0
coilDutyCycle = scalar, F32, 272, "perc", 1, 0
accelerationX = scalar, S16, 276, "G", 0.01, 0
accelerationY = scalar, S16, 278, "G", 0.01, 0
oilPressure = scalar, F32, 280, "kPa", 1, 0.0
fuelConsumptionPerHour=scalar, F32, 284, "kPa", 1, 0.0
injectionOffset = scalar, F32, 288, "deg", 1, 0;
debugIntField4 = scalar, S16, 292, "val", 1, 0.0;
debugIntField5 = scalar, S16, 294, "val", 1, 0.0;
recentErrorCode0 = scalar,U16, 296, "error", 1, 0
recentErrorCode1 = scalar,U16, 298, "error", 1, 0
recentErrorCode2 = scalar,U16, 300, "error", 1, 0
recentErrorCode3 = scalar,U16, 302, "error", 1, 0
recentErrorCode4 = scalar,U16, 304, "error", 1, 0
recentErrorCode5 = scalar,U16, 306, "error", 1, 0
recentErrorCode6 = scalar,U16, 308, "error", 1, 0
recentErrorCode7 = scalar,U16, 310, "error", 1, 0
etbTarget = scalar,F32, 312, "%", 1, 0
etb1DutyCycle = scalar,F32, 316, "%", 1, 0
etb1Error = scalar,F32, 320, "%", 1, 0
;tpsADC2 = scalar, U16, 44, "ADC", 1, 0.0;
; fuel math
chargeAirMass = scalar, U16, 44, "g",0.001, 0
crankingFuelMs = scalar, U16, 46, "ms",{1/@@PACK_MULT_MS@@}, 0.0
currentTargetAfr= scalar, U16, 48, "ratio",,{1/@@PACK_MULT_AFR@@},, 0
baseFuel = scalar, U16, 50, "ms",{1/@@PACK_MULT_MS@@}, 0
fuelRunning = scalar, U16, 52, "ms",{1/@@PACK_MULT_MS@@}, 0
actualLastInjection=scalar,U16, 54, "ms",{1/@@PACK_MULT_MS@@}, 0.0
injectorDutyCycle=scalar, U08, 56, "%", 0.5, 0
veValue = scalar, U08, 57, "ratio", 0.5, 0
injectionOffset = scalar, S16, 58, "deg",{1/@@PACK_MULT_ANGLE@@}, 0
tCharge = scalar, U16, 60, "deg C",{1/@@PACK_MULT_TEMPERATURE@@}, 0.0
; Corrections
injectorLagMs = scalar, U16, 62, "ms",{1/@@PACK_MULT_MS@@}, 0.0
iatCorrection = scalar, U16, 64, "%",{1/@@PACK_MULT_PERCENT@@}, 0
cltCorrection = scalar, U16, 66, "%",{1/@@PACK_MULT_PERCENT@@}, 0
baroCorrection = scalar, U16, 68, "%",{1/@@PACK_MULT_PERCENT@@}, 0
fuelPidCorrection=scalar, S16, 70, "ms",{1/@@PACK_MULT_MS@@}, 0
; Wall model AE
wallFuelAmount = scalar, U16, 72, "ms",{1/@@PACK_MULT_MS@@}, 0
wallFuelCorrection=scalar, S16, 74, "ms",0.001, 0
; TPS/load AE
engineLoadDelta = scalar, S16, 76, "value",{1/@@PACK_MULT_PERCENT@@}, 0
deltaTps = scalar, S16, 78, "ratio",{1/@@PACK_MULT_PERCENT@@}, 0
engineLoadAccelExtra=scalar,S16, 80, "value",{1/@@PACK_MULT_PERCENT@@}, 0
tpsAccelFuel = scalar, U16, 82, "ms",{1/@@PACK_MULT_MS@@}, 0
; Ignition
ignitionAdvance = scalar, U16, 84, "deg",{1/@@PACK_MULT_ANGLE@@}, 0.0
sparkDwellValue = scalar, U16, 86, "ms",{1/@@PACK_MULT_MS@@}, 0.0
coilDutyCycle = scalar, U16, 88, "%",{1/@@PACK_MULT_PERCENT@@}, 0
; Idle & ETB
idleAirValvePosition=scalar,S16, 90, "%",{1/@@PACK_MULT_PERCENT@@}, 0
etbTarget = scalar, S16, 92, "%",{1/@@PACK_MULT_PERCENT@@}, 0
etb1DutyCycle = scalar, S16, 94, "%",{1/@@PACK_MULT_PERCENT@@}, 0
etb1Error = scalar, S16, 96, "%",{1/@@PACK_MULT_PERCENT@@}, 0
; Fuel system
fuelTankLevel = scalar, S16, 98, "amount",{1/@@PACK_MULT_PERCENT@@}, 0
fuelConsumptionPerHour=scalar,F32, 100, "kPa", 1, 0.0
; Knock
knockCount = scalar, U32, 104,"counter", 1, 0
knockLevel = scalar, F32, 108, "Volts", 1, 0
; Mode, firmware, protocol, run time
timeSeconds = scalar, U32, 112, "sec", 1, 0.0
engineMode = scalar, U32, 116, "em", 1, 0.0;
firmwareVersion = scalar, U32, 120,"version_f", 1, 0
firmwareTsVersion=scalar, U32, 124,"version_p", 1, 0
; Errors
triggerErrorsCounter=scalar,U32, 128,"counter", 1, 0
; totalTriggerErrorCounter 132
warningCounter = scalar, U16, 136, "count", 1, 0
lastErrorCode = scalar, U16, 138, "error", 1, 0
recentErrorCode0= scalar, U16, 140, "error", 1, 0
recentErrorCode1= scalar, U16, 142, "error", 1, 0
recentErrorCode2= scalar, U16, 144, "error", 1, 0
recentErrorCode3= scalar, U16, 146, "error", 1, 0
recentErrorCode4= scalar, U16, 148, "error", 1, 0
recentErrorCode5= scalar, U16, 150, "error", 1, 0
recentErrorCode6= scalar, U16, 152, "error", 1, 0
recentErrorCode7= scalar, U16, 154, "error", 1, 0
; Debug
debugFloatField1= scalar, F32, 156, "val", 1, 0.0
debugFloatField2= scalar, F32, 160, "val", 1, 0.0
debugFloatField3= scalar, F32, 164, "val", 1, 0.0
debugFloatField4= scalar, F32, 168, "val", 1, 0.0
debugFloatField5= scalar, F32, 172, "val", 1, 0.0
debugFloatField6= scalar, F32, 176, "val", 1, 0.0
debugFloatField7= scalar, F32, 180, "val", 1, 0.0
debugIntField1 = scalar, S32, 184, "val", 1, 0.0
debugIntField2 = scalar, S32, 188, "val", 1, 0.0
debugIntField3 = scalar, S32, 192, "val", 1, 0.0
debugIntField4 = scalar, S16, 196, "val", 1, 0.0
debugIntField5 = scalar, S16, 198, "val", 1, 0.0
; Accel
accelerationX = scalar, S16, 200, "G", 0.01, 0
accelerationY = scalar, S16, 202, "G", 0.01, 0
; egt
egt1 = scalar, S16, 204, "deg C", 1, 0
egt2 = scalar, S16, 206, "deg C", 1, 0
egt3 = scalar, S16, 208, "deg C", 1, 0
egt4 = scalar, S16, 210, "deg C", 1, 0
egt5 = scalar, S16, 212, "deg C", 1, 0
egt6 = scalar, S16, 214, "deg C", 1, 0
egt7 = scalar, S16, 216, "deg C", 1, 0
egt8 = scalar, S16, 218, "deg C", 1, 0
;

View File

@ -393,23 +393,41 @@ public class BinaryProtocol implements BinaryProtocolCommands {
currentOutputs = response;
for (Sensor sensor : Sensor.values()) {
if (sensor.getType() == null) {
// for example ETB_CONTROL_QUALITY, weird use-case
continue;
}
ByteBuffer bb = ByteBuffer.wrap(response, 1 + sensor.getOffset(), 4);
bb.order(ByteOrder.LITTLE_ENDIAN);
if (sensor.getType() == FieldType.FLOAT) {
double value = bb.getFloat();
SensorCentral.getInstance().setValue(value, sensor);
} else if (sensor.getType() == FieldType.INT) {
int value = bb.getInt();
SensorCentral.getInstance().setValue(value, sensor);
} else if (sensor.getType() == FieldType.INT16) {
short value = (short) (bb.getInt() & 0xFFFF);
SensorCentral.getInstance().setValue(value, sensor);
} else if (sensor.getType() == null) {
// do nothing for old text sensors which I am suprised are still in the code
} else
throw new UnsupportedOperationException("type " + sensor.getType());
double rawValue = getValueForChannel(bb, sensor);
double scaledValue = rawValue * sensor.getScale();
SensorCentral.getInstance().setValue(scaledValue, sensor);
}
return true;
}
private static double getValueForChannel(ByteBuffer bb, Sensor sensor) {
switch (sensor.getType()) {
case FLOAT:
return bb.getFloat();
case INT:
return bb.getInt();
case UINT16:
// no cast - we want to discard sign
return bb.getInt() & 0xFFFF;
case INT16:
// cast - we want to retain sign
return (short)(bb.getInt() & 0xFFFF);
case UINT8:
// no cast - discard sign
return bb.getInt() & 0xFF;
case INT8:
// cast - retain sign
return (byte)(bb.getInt() & 0xFF);
default:
throw new UnsupportedOperationException("type " + sensor.getType());
}
}
}

View File

@ -1,19 +1,25 @@
package com.rusefi.config;
public enum FieldType {
INT(4),
/**
* signed 16 bit type
*/
INT16(2),
// Signed
INT8(1),
INT16(2),
INT(4),
// Unsigned
UINT8(1),
UINT16(2),
BIT(/*bits are stored in 4 byte packs */4),
FLOAT(4);
public static final String INT_TYPE_STRING = "int";
public static final String FLOAT_TYPE_STRING = "float";
public static final String BYTE_TYPE_STRING = "byte";
public static final String UBYTE_TYPE_STRING = "ubyte";
public static final String SHORT_TYPE_STRING = "short";
public static final String USHORT_TYPE_STRING = "ushort";
private final int storageSize;
FieldType(int storageSize) {
@ -26,8 +32,12 @@ public enum FieldType {
return FLOAT_TYPE_STRING;
case INT16:
return SHORT_TYPE_STRING;
case UINT16:
return USHORT_TYPE_STRING;
case INT8:
return BYTE_TYPE_STRING;
case UINT8:
return UBYTE_TYPE_STRING;
case INT:
default:
return INT_TYPE_STRING;

View File

@ -1024,6 +1024,13 @@ public class Fields {
public static final int overrideCrankingIacSetting_offset = 1476;
public static final int overrideCrankingIgnition_offset = 516;
public static final int overrideCrankingIgnition_offset_hex = 204;
public static final int PACK_MULT_AFR = 1000;
public static final int PACK_MULT_ANGLE = 50;
public static final int PACK_MULT_MS = 300;
public static final int PACK_MULT_PERCENT = 100;
public static final int PACK_MULT_PRESSURE = 30;
public static final int PACK_MULT_TEMPERATURE = 100;
public static final int PACK_MULT_VOLTAGE = 1000;
public static final int pauseEtbControl_offset = 744;
public static final int PEDAL_TO_TPS_SIZE = 8;
public static final int pedalToTpsPedalBins_offset = 6464;
@ -1298,9 +1305,9 @@ public class Fields {
public static final int triggerSimulatorPins1_offset = 736;
public static final int triggerSimulatorPins2_offset = 737;
public static final int triggerSimulatorPins3_offset = 738;
public static final int TS_FILE_VERSION = 20190701;
public static final int TS_OUTPUT_SIZE = 356;
public static final String TS_SIGNATURE = "rusEFI v1.07";
public static final int TS_FILE_VERSION = 20191221;
public static final int TS_OUTPUT_SIZE = 220;
public static final String TS_SIGNATURE = "rusEFI v1.08";
public static final int tunerStudioSerialSpeed_offset = 728;
public static final int twoWireBatchIgnition_offset = 1476;
public static final int twoWireBatchInjection_offset = 1476;

View File

@ -17,93 +17,99 @@ import static com.rusefi.config.generated.Fields.*;
* 2/11/13
*/
public enum Sensor {
MAP("MAP", SensorCategory.SENSOR_INPUTS, FieldType.FLOAT, /*offset */ 40, BackgroundColor.MUD, 20, 300),
/**
* Please note that these enum names are used to make 'set_mock_XXX_voltage' commands
*/
CLT("Coolant", SensorCategory.SENSOR_INPUTS, FieldType.FLOAT, /*offset */ 4, BackgroundColor.MUD, -40, 300),
AFR("A/F ratio", SensorCategory.SENSOR_INPUTS, FieldType.FLOAT, /*offset */ 20, BackgroundColor.MUD, 0, 20),
MAF("MAF", SensorCategory.SENSOR_INPUTS, FieldType.FLOAT, /*offset */ 16, BackgroundColor.MUD, 0, 5),
// knockCount("Knock", SensorCategory.SENSOR_INPUTS, "count", 30),
// KnockValue("Knock level", SensorCategory.SENSOR_INPUTS, "v", 6),
// RPM, vss
RPM("RPM", SensorCategory.SENSOR_INPUTS, FieldType.UINT16, 4, 1, BackgroundColor.RED, 0, 8000, "/min"),
SPEED2RPM("SpeedToRpm", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 6, 1.0 / PACK_MULT_PERCENT, BackgroundColor.MUD, 0, 5, "RPM/kph"),
VSS("VSS", SensorCategory.OPERATIONS, FieldType.UINT8, 8, 1, BackgroundColor.BLUE, 0, 150, "kph"),
// ENGINE_LOAD("Engine Load", SensorCategory.SENSOR_INPUTS, "x", 300),
// Temperatures
INT_TEMP("MCU Temp", SensorCategory.OPERATIONS, FieldType.INT8, 10, 1, BackgroundColor.MUD, 0, 5, "C"),
CLT("Coolant", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 12, 1.0 / PACK_MULT_TEMPERATURE,BackgroundColor.MUD, -40, 150, "C"),
IAT("IAT", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 14, 1.0 / PACK_MULT_TEMPERATURE, BackgroundColor.WHITE, -40, 150, "C"),
// throttle, pedal
TPS("TPS", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 20, 1.0 / PACK_MULT_PERCENT, BackgroundColor.MUD, 0, 100, "%"), // throttle position sensor
PPS("Throttle Pedal", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 22, 1.0 / PACK_MULT_PERCENT, BackgroundColor.MUD, 0, 100, "%"), // pedal position sensor
// MAFR_CFM("MAFR_CFM", SensorCategory.SENSOR_INPUTS, "cub f/m", 800),
// air flow/mass measurement
MAF("MAF", SensorCategory.SENSOR_INPUTS, FieldType.UINT16, 26, 1.0 / PACK_MULT_VOLTAGE, BackgroundColor.MUD, 0, 5, "Volts"),
MAP("MAP", SensorCategory.SENSOR_INPUTS, FieldType.UINT16, 30, 1.0 / PACK_MULT_PRESSURE, BackgroundColor.MUD, 20, 300, "kPa"),
AFR("A/F ratio", SensorCategory.SENSOR_INPUTS, FieldType.UINT16, 34, 1.0 / PACK_MULT_AFR, BackgroundColor.MUD, 10, 20, "afr"),
// COOLANT_WIDTH("c w", "", 30),
// INTAKE_AIR_WIDTH("air w", "", 30),
VBATT("VBatt", SensorCategory.SENSOR_INPUTS, FieldType.UINT16, 38, 1.0 / PACK_MULT_VOLTAGE, BackgroundColor.BEIGE, 4, 18, "Volts"),
vvtPosition("vvt position", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 42, 1.0 / PACK_MULT_ANGLE, BackgroundColor.MUD, 0, 5, "deg"),
// VREF("VRef", SensorCategory.SENSOR_INPUTS, "Volts", 6),
VBATT("VBatt", SensorCategory.SENSOR_INPUTS, FieldType.FLOAT, 28, BackgroundColor.BEIGE, 4, 18, "Volts"),
// fuel math
CHARGE_AIR_MASS("airmass", SensorCategory.OPERATIONS, FieldType.UINT16, 44, 0.001, BackgroundColor.MUD, 0, 3, "g/cyl"),
crankingFuel(GAUGE_NAME_FUEL_CRANKING, SensorCategory.FUEL, FieldType.UINT16, 46, 1.0 / PACK_MULT_MS, BackgroundColor.MUD, 0, 30, "ms"),
TARGET_AFR("A/F target", SensorCategory.OPERATIONS, FieldType.INT16, 48, 1.0 / PACK_MULT_AFR, BackgroundColor.MUD, 10, 20, "afr"),
baseFuel(Fields.GAUGE_NAME_FUEL_BASE, SensorCategory.FUEL, FieldType.UINT16, 50, 1.0 / PACK_MULT_MS, BackgroundColor.MUD, 0, 30, "ms"),
runningFuel(GAUGE_NAME_FUEL_RUNNING, SensorCategory.FUEL, FieldType.UINT16, 52, 1.0 / PACK_MULT_MS, BackgroundColor.MUD, 0, 15, "ms"),
actualLastInjection(GAUGE_NAME_FUEL_LAST_INJECTION, SensorCategory.FUEL, FieldType.UINT16, 54, 1.0 / PACK_MULT_MS, BackgroundColor.MUD, 0, 30, "ms"),
injectorDutyCycle(Fields.GAUGE_NAME_FUEL_INJ_DUTY, SensorCategory.FUEL, FieldType.UINT8, 56, 0.5, BackgroundColor.MUD, 0, 100, "%"),
veValue(GAUGE_NAME_FUEL_VE, SensorCategory.FUEL, FieldType.FLOAT, 57, 0.5, BackgroundColor.MUD, 0, 100, "%"),
tCharge(GAUGE_NAME_TCHARGE, SensorCategory.FUEL, FieldType.FLOAT, 60, 1.0 / PACK_MULT_TEMPERATURE, BackgroundColor.MUD, 30, 140, "C"),
// Corrections
injectorLagMs(GAUGE_NAME_INJECTOR_LAG, SensorCategory.FUEL, FieldType.UINT16, 62, 1.0 / PACK_MULT_MS, BackgroundColor.MUD, 0, 15, "ms"),
iatCorrection(GAUGE_NAME_FUEL_IAT_CORR, SensorCategory.FUEL, FieldType.INT16, 64, 1.0 / PACK_MULT_PERCENT, BackgroundColor.MUD, 0, 5, "ratio"),
cltCorrection(GAUGE_NAME_FUEL_CLT_CORR, SensorCategory.FUEL, FieldType.INT16, 66, 1.0 / PACK_MULT_PERCENT, BackgroundColor.MUD, 0, 5, "ratio"),
fuelPidCorrection("Fuel PID", SensorCategory.FUEL, FieldType.INT16, 70, 1.0 / PACK_MULT_MS, BackgroundColor.MUD, -2, 2, "ms"),
// Wall model AE
wallFuelAmount(GAUGE_NAME_FUEL_WALL_AMOUNT, SensorCategory.FUEL, FieldType.UINT16, 72, 1.0 / PACK_MULT_MS, BackgroundColor.MUD, 0, 20, "ms"),
wallFuelCorrection(GAUGE_NAME_FUEL_WALL_CORRECTION, SensorCategory.FUEL, FieldType.INT16, 74, 0.001, BackgroundColor.MUD, -5, 5, "ms"),
// TPS/load AE
engineLoadAccelDelta("load accel delta", SensorCategory.FUEL, FieldType.INT16, 76, 1.0 / PACK_MULT_PERCENT, BackgroundColor.MUD, -5, 5, "ratio"),
deltaTps(Fields.GAUGE_NAME_FUEL_TPS_ROC, SensorCategory.FUEL, FieldType.INT16, 78, 1.0 / PACK_MULT_PERCENT, BackgroundColor.MUD, -100, 100, "%"),
tpsAccelFuel(Fields.GAUGE_NAME_FUEL_TPS_EXTRA, SensorCategory.FUEL, FieldType.INT16, 82, 1.0 / PACK_MULT_MS, BackgroundColor.MUD, 0, 200, "ms"),
// Ignition
ignitionAdvance("ignition timing", SensorCategory.OPERATIONS, FieldType.INT16, 84, 1.0 / PACK_MULT_ANGLE, BackgroundColor.MUD, 30, 140, "deg"),
DWELL(Fields.GAUGE_COIL_DWELL_TIME, SensorCategory.OPERATIONS, FieldType.UINT16, 86, 1.0 / PACK_MULT_MS, BackgroundColor.MUD, 1, 10, "ms"),
coilDutyCycle(Fields.GAUGE_NAME_DWELL_DUTY, SensorCategory.OPERATIONS, FieldType.UINT16, 88, 1.0 / PACK_MULT_PERCENT, BackgroundColor.MUD, 0, 100, "%"),
// Idle & ETB
idlePosition("Idle Position", SensorCategory.OPERATIONS, FieldType.INT16, 90, 1.0 / PACK_MULT_PERCENT, BackgroundColor.MUD, 0, 100, "%"),
etbTarget(GAUGE_NAME_ETB_TARGET, SensorCategory.OTHERS, FieldType.INT16, 92, 1.0 / PACK_MULT_PERCENT, BackgroundColor.MUD, 0, 100, "%"),
etb1DutyCycle(GAUGE_NAME_ETB_DUTY, SensorCategory.OTHERS, FieldType.INT16, 94, 1.0 / PACK_MULT_PERCENT, BackgroundColor.MUD, 0, 100, "%"),
etb1Error(GAUGE_NAME_ETB_ERROR, SensorCategory.OTHERS, FieldType.INT16, 96, 1.0 / PACK_MULT_PERCENT, BackgroundColor.MUD, 0, 100, "%"),
// Fuel system
// Knock
// Mode, firmware, protocol, run time
TIME_SECONDS("uptime", SensorCategory.OPERATIONS, FieldType.INT, 112, BackgroundColor.MUD, 0, 5),
engineMode("mode", SensorCategory.OPERATIONS, FieldType.INT, 116, BackgroundColor.MUD, 0, 5),
FIRMWARE_VERSION("FW version", SensorCategory.OPERATIONS, FieldType.INT, 120, BackgroundColor.BLUE),
// Errors
errorCodeCounter("error counter", SensorCategory.STATUS, FieldType.INT, 136, BackgroundColor.MUD, 0, 5),
lastErrorCode("last error", SensorCategory.STATUS, FieldType.INT, 138, BackgroundColor.MUD, 0, 5),
// Debug
debugFloatField1(GAUGE_NAME_DEBUG_F1, SensorCategory.DEBUG, FieldType.FLOAT, 156, BackgroundColor.MUD, 0, 5),
debugFloatField2(GAUGE_NAME_DEBUG_F2, SensorCategory.DEBUG, FieldType.FLOAT, 160, BackgroundColor.MUD, 0, 5),
debugFloatField3(GAUGE_NAME_DEBUG_F3, SensorCategory.DEBUG, FieldType.FLOAT, 164, BackgroundColor.MUD, 0, 5),
debugFloatField4(GAUGE_NAME_DEBUG_F4, SensorCategory.DEBUG, FieldType.FLOAT, 168, BackgroundColor.MUD, 0, 5),
debugFloatField5(GAUGE_NAME_DEBUG_F5, SensorCategory.DEBUG, FieldType.FLOAT, 172, BackgroundColor.MUD, 0, 5),
debugFloatField6(GAUGE_NAME_DEBUG_F6, SensorCategory.DEBUG, FieldType.FLOAT, 176, BackgroundColor.MUD, 0, 5),
debugFloatField7(GAUGE_NAME_DEBUG_F7, SensorCategory.DEBUG, FieldType.FLOAT, 180, BackgroundColor.MUD, 0, 5),
debugIntField1(GAUGE_NAME_DEBUG_I1, SensorCategory.DEBUG, FieldType.INT, 184, BackgroundColor.MUD, 0, 5),
debugIntField2(GAUGE_NAME_DEBUG_I2, SensorCategory.DEBUG, FieldType.INT, 188, BackgroundColor.MUD, 0, 5),
debugIntField3(GAUGE_NAME_DEBUG_I3, SensorCategory.DEBUG, FieldType.INT, 192, BackgroundColor.MUD, 0, 5),
debugIntField4("debug i4", SensorCategory.DEBUG, FieldType.INT16, 196, BackgroundColor.MUD, 0, 5),
debugIntField5("debug i5", SensorCategory.DEBUG, FieldType.INT16, 198, BackgroundColor.MUD, 0, 5),
// Synthetic (console only) channels
ETB_CONTROL_QUALITY("ETB metric", SensorCategory.SNIFFING, "", 100),
IAT(SensorCategory.SENSOR_INPUTS, FieldType.FLOAT, 8, BackgroundColor.WHITE, -40, 150, "C"),
TPS(SensorCategory.SENSOR_INPUTS, FieldType.FLOAT, 12, BackgroundColor.MUD, 0, 100, "%"), // throttle position sensor
crankingFuel(GAUGE_NAME_FUEL_CRANKING, SensorCategory.FUEL, FieldType.FLOAT, 44, BackgroundColor.MUD, 0, 30, "ms"),
baseFuel(Fields.GAUGE_NAME_FUEL_BASE, SensorCategory.FUEL, FieldType.FLOAT, 48, BackgroundColor.MUD, 0, 30, "ms"),
tCharge(GAUGE_NAME_TCHARGE, SensorCategory.FUEL, FieldType.FLOAT, 52, BackgroundColor.MUD, 30, 140),
// todo: unify with TIMING
ignitionAdvance(SensorCategory.OPERATIONS, FieldType.FLOAT, 56, BackgroundColor.MUD, 30, 140),
DWELL(Fields.GAUGE_COIL_DWELL_TIME, SensorCategory.OPERATIONS, FieldType.FLOAT, 60, BackgroundColor.MUD, 1, 10),
actualLastInjection(GAUGE_NAME_FUEL_LAST_INJECTION, SensorCategory.FUEL, FieldType.FLOAT, /*offset */ 64, BackgroundColor.MUD, 0, 30, "ms"),
debugFloatField1(GAUGE_NAME_DEBUG_F1, SensorCategory.DEBUG, FieldType.FLOAT, 68, BackgroundColor.MUD, 0, 5),
VSS(SensorCategory.OPERATIONS, FieldType.FLOAT, 76, BackgroundColor.BLUE),
FIRMWARE_VERSION(SensorCategory.OPERATIONS, FieldType.INT, 84, BackgroundColor.BLUE),
veValue(GAUGE_NAME_FUEL_VE, SensorCategory.FUEL, FieldType.FLOAT, 112, BackgroundColor.MUD),
deltaTps(Fields.GAUGE_NAME_FUEL_TPS_ROC, SensorCategory.FUEL, FieldType.FLOAT, 116, BackgroundColor.MUD, -100, 100, "%"),
engineLoadAccelDelta(SensorCategory.FUEL, FieldType.FLOAT, 124, BackgroundColor.MUD),
tpsAccelFuel(Fields.GAUGE_NAME_FUEL_TPS_EXTRA, SensorCategory.FUEL, FieldType.FLOAT, 128, BackgroundColor.MUD, 0, 200, "ms"),
PPS("Throttle Pedal", SensorCategory.SENSOR_INPUTS, FieldType.FLOAT, 136, BackgroundColor.MUD, 0, 100, "%"), // pedal position sensor
injectorDutyCycle(Fields.GAUGE_NAME_FUEL_INJ_DUTY, SensorCategory.FUEL, FieldType.FLOAT, 140, BackgroundColor.MUD),
wallFuelAmount(GAUGE_NAME_FUEL_WALL_AMOUNT, SensorCategory.FUEL, FieldType.FLOAT, 160, BackgroundColor.MUD),
iatCorrection(GAUGE_NAME_FUEL_IAT_CORR, SensorCategory.FUEL, FieldType.FLOAT, 164, BackgroundColor.MUD, 0, 5),
wallFuelCorrection(GAUGE_NAME_FUEL_WALL_CORRECTION, SensorCategory.FUEL, FieldType.FLOAT, 168, BackgroundColor.MUD),
idlePosition(SensorCategory.OPERATIONS, FieldType.FLOAT, 172, BackgroundColor.MUD),
TARGET_AFR(SensorCategory.OPERATIONS, FieldType.FLOAT, 176, BackgroundColor.MUD),
CHARGE_AIR_MASS(SensorCategory.OPERATIONS, FieldType.FLOAT, 180, BackgroundColor.MUD),
cltCorrection(GAUGE_NAME_FUEL_CLT_CORR, SensorCategory.FUEL, FieldType.FLOAT, 184, BackgroundColor.MUD, 0, 5),
runningFuel(GAUGE_NAME_FUEL_RUNNING, SensorCategory.FUEL, FieldType.FLOAT, 188, BackgroundColor.MUD, 0, 15, "ms"),
debugIntField1(GAUGE_NAME_DEBUG_I1, SensorCategory.DEBUG, FieldType.INT, 192, BackgroundColor.MUD, 0, 5),
injectorLagMs(GAUGE_NAME_INJECTOR_LAG, SensorCategory.FUEL, FieldType.FLOAT, 196, BackgroundColor.MUD, 0, 15, "ms"),
debugFloatField2(GAUGE_NAME_DEBUG_F2, SensorCategory.DEBUG, FieldType.FLOAT, 200, BackgroundColor.MUD, 0, 5),
debugFloatField3(GAUGE_NAME_DEBUG_F3, SensorCategory.DEBUG, FieldType.FLOAT, 204, BackgroundColor.MUD, 0, 5),
debugFloatField4(GAUGE_NAME_DEBUG_F4, SensorCategory.DEBUG, FieldType.FLOAT, 208, BackgroundColor.MUD, 0, 5),
debugFloatField5(GAUGE_NAME_DEBUG_F5, SensorCategory.DEBUG, FieldType.FLOAT, 212, BackgroundColor.MUD, 0, 5),
debugIntField2(GAUGE_NAME_DEBUG_I2, SensorCategory.DEBUG, FieldType.INT, 216, BackgroundColor.MUD, 0, 5),
debugIntField3(GAUGE_NAME_DEBUG_I3, SensorCategory.DEBUG, FieldType.INT, 220, BackgroundColor.MUD, 0, 5),
errorCodeCounter(SensorCategory.STATUS, FieldType.INT, 236, BackgroundColor.MUD, 0, 5),
lastErrorCode(SensorCategory.STATUS, FieldType.INT, 240, BackgroundColor.MUD, 0, 5),
RPM(SensorCategory.SENSOR_INPUTS, FieldType.INT, 0, BackgroundColor.RED, 0, 8000),
TIME_SECONDS(SensorCategory.OPERATIONS, FieldType.INT, 224, BackgroundColor.MUD, 0, 5),
SPEED2RPM(SensorCategory.SENSOR_INPUTS, FieldType.FLOAT, 232, BackgroundColor.MUD, 0, 5),
INT_TEMP(SensorCategory.OPERATIONS, FieldType.FLOAT, 244, BackgroundColor.MUD, 0, 5),
vvtPosition(SensorCategory.SENSOR_INPUTS, FieldType.FLOAT, 248, BackgroundColor.MUD, 0, 5),
engineMode(SensorCategory.OPERATIONS, FieldType.INT, 252, BackgroundColor.MUD, 0, 5),
debugFloatField6(GAUGE_NAME_DEBUG_F6, SensorCategory.DEBUG, FieldType.FLOAT, 256, BackgroundColor.MUD, 0, 5),
debugFloatField7(GAUGE_NAME_DEBUG_F7, SensorCategory.DEBUG, FieldType.FLOAT, 260, BackgroundColor.MUD, 0, 5),
fuelPidCorrection(SensorCategory.FUEL, FieldType.FLOAT, 268, BackgroundColor.MUD),
coilDutyCycle(Fields.GAUGE_NAME_DWELL_DUTY, SensorCategory.OPERATIONS, FieldType.FLOAT, 272, BackgroundColor.MUD),
debugIntField4("debug i4", SensorCategory.DEBUG, FieldType.INT16, 292, BackgroundColor.MUD, 0, 5),
debugIntField5("debug i5", SensorCategory.DEBUG, FieldType.INT16, 294, BackgroundColor.MUD, 0, 5),
etbTarget(GAUGE_NAME_ETB_TARGET, SensorCategory.OTHERS, FieldType.FLOAT, 312, BackgroundColor.MUD),
etb1DutyCycle(GAUGE_NAME_ETB_DUTY, SensorCategory.OTHERS, FieldType.FLOAT, 316, BackgroundColor.MUD),
etb1Error(GAUGE_NAME_ETB_ERROR, SensorCategory.OTHERS, FieldType.FLOAT, 320, BackgroundColor.MUD),
;
private final String name;
@ -115,11 +121,13 @@ public enum Sensor {
@Nullable
private final FieldType type;
private final int offset;
private final double scale;
Sensor(String name, SensorCategory category, FieldType type, int offset, BackgroundColor color, double minValue, double maxValue, String units) {
Sensor(String name, SensorCategory category, FieldType type, int offset, double scale, BackgroundColor color, double minValue, double maxValue, String units) {
this.name = name == null ? name() : name;
this.type = type;
this.offset = offset;
this.scale = scale;
this.category = category;
this.color = color;
this.units = units;
@ -127,20 +135,8 @@ public enum Sensor {
this.maxValue = maxValue;
}
Sensor(SensorCategory category, FieldType type, int offset, BackgroundColor color, double minValue, double maxValue, String units) {
this(null, category, type, offset, color, minValue, maxValue, units);
}
Sensor(String name, SensorCategory category, FieldType type, int offset, BackgroundColor color, double minValue, double maxValue) {
this(name, category, type, offset, color, minValue, maxValue, "n/a");
}
Sensor(SensorCategory category, FieldType type, int offset, BackgroundColor color, double minValue, double maxValue) {
this(null, category, type, offset, color, minValue, maxValue);
}
Sensor(SensorCategory category, FieldType type, int offset, BackgroundColor color) {
this(null, category, type, offset, color);
this(name, category, type, offset, 1.0, color, minValue, maxValue, "n/a");
}
Sensor(String name, SensorCategory category, FieldType type, int offset, BackgroundColor color) {
@ -171,6 +167,7 @@ public enum Sensor {
this.minValue = minValue;
this.maxValue = maxValue;
this.color = color;
this.scale = 1.0;
type = null;
offset = -1;
}
@ -236,6 +233,10 @@ public enum Sensor {
return offset;
}
public double getScale() {
return scale;
}
public FieldType getType() {
return type;
}