mirror of https://github.com/rusefi/RomRaider.git
added text replacement option to logger xml
git-svn-id: http://svn.3splooges.com/romraider-arch/trunk@631 d2e2e1cd-ba16-0410-be16-b7c4453c7c2d
This commit is contained in:
parent
d737f76b92
commit
d158757298
|
@ -25,6 +25,7 @@ import static enginuity.util.ByteUtil.asUnsignedInt;
|
|||
import static enginuity.util.JEPUtil.evaluate;
|
||||
import static enginuity.util.ParamChecker.checkNotNull;
|
||||
import static enginuity.util.ParamChecker.checkNotNullOrEmpty;
|
||||
import static enginuity.util.ParamChecker.isValidBit;
|
||||
|
||||
import static java.lang.Float.intBitsToFloat;
|
||||
import java.text.DecimalFormat;
|
||||
|
@ -35,14 +36,15 @@ public final class EcuParameterConvertorImpl implements EcuDataConvertor {
|
|||
private final String units;
|
||||
private final String expression;
|
||||
private final DecimalFormat format;
|
||||
private final int bit;
|
||||
private final boolean isFloat;
|
||||
private final Map<String, String> replaceMap;
|
||||
|
||||
public EcuParameterConvertorImpl() {
|
||||
this("Raw data", "x", "0", false, new HashMap<String, String>());
|
||||
this("Raw data", "x", "0", -1, false, new HashMap<String, String>());
|
||||
}
|
||||
|
||||
public EcuParameterConvertorImpl(String units, String expression, String format, boolean isFloat, Map<String, String> replaceMap) {
|
||||
public EcuParameterConvertorImpl(String units, String expression, String format, int bit, boolean isFloat, Map<String, String> replaceMap) {
|
||||
checkNotNullOrEmpty(units, "units");
|
||||
checkNotNullOrEmpty(expression, "expression");
|
||||
checkNotNullOrEmpty(format, "format");
|
||||
|
@ -50,14 +52,19 @@ public final class EcuParameterConvertorImpl implements EcuDataConvertor {
|
|||
this.units = units;
|
||||
this.expression = expression;
|
||||
this.format = new DecimalFormat(format);
|
||||
this.bit = bit;
|
||||
this.isFloat = isFloat;
|
||||
this.replaceMap = replaceMap;
|
||||
}
|
||||
|
||||
public double convert(byte[] bytes) {
|
||||
double value = (double) (isFloat ? intBitsToFloat(asUnsignedInt(bytes)) : asUnsignedInt(bytes));
|
||||
double result = evaluate(expression, value);
|
||||
return Double.isNaN(result) || Double.isInfinite(result) ? 0.0 : result;
|
||||
if (isValidBit(bit)) {
|
||||
return (bytes[0] & (1 << bit)) > 0 ? 1 : 0;
|
||||
} else {
|
||||
double value = (double) (isFloat ? intBitsToFloat(asUnsignedInt(bytes)) : asUnsignedInt(bytes));
|
||||
double result = evaluate(expression, value);
|
||||
return Double.isNaN(result) || Double.isInfinite(result) ? 0.0 : result;
|
||||
}
|
||||
}
|
||||
|
||||
public String getUnits() {
|
||||
|
|
|
@ -234,7 +234,7 @@ public final class LoggerDefinitionHandler extends DefaultHandler {
|
|||
convertorList.add(new EcuSwitchConvertorImpl(address.getBit()));
|
||||
} else {
|
||||
convertorList.add(new EcuParameterConvertorImpl(conversionUnits,
|
||||
conversionExpression, conversionFormat,
|
||||
conversionExpression, conversionFormat, address.getBit(),
|
||||
FLOAT.equalsIgnoreCase(conversionStorageType), replaceMap));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue