logging of live data structs was: data points #3614

So close...
This commit is contained in:
rusefillc 2022-04-17 17:15:05 -04:00
parent 00b3372929
commit 8f0eb676a5
2 changed files with 9 additions and 7 deletions

View File

@ -74,7 +74,7 @@ public class TsOutput {
if (configField.getState().tsCustomLine.containsKey(configField.getType())) { if (configField.getState().tsCustomLine.containsKey(configField.getType())) {
String bits = configField.getState().tsCustomLine.get(configField.getType()); String bits = configField.getState().tsCustomLine.get(configField.getType());
if (!bits.startsWith("bits")) { if (!bits.startsWith("bits")) {
bits = handleTsInfo(bits, 5); bits = handleTsInfo(configField, bits, 5);
} }
bits = bits.replaceAll("@OFFSET@", "" + tsPosition); bits = bits.replaceAll("@OFFSET@", "" + tsPosition);
@ -86,7 +86,7 @@ public class TsOutput {
tsHeader.append(nameWithPrefix + " = scalar, "); tsHeader.append(nameWithPrefix + " = scalar, ");
tsHeader.append(TypesHelper.convertToTs(configField.getType()) + ","); tsHeader.append(TypesHelper.convertToTs(configField.getType()) + ",");
tsHeader.append(" " + tsPosition + ","); tsHeader.append(" " + tsPosition + ",");
tsHeader.append(" " + handleTsInfo(configField.getTsInfo(), 1)); tsHeader.append(" " + handleTsInfo(configField, configField.getTsInfo(), 1));
if (!configField.getName().equals(next.getName())) if (!configField.getName().equals(next.getName()))
tsPosition += configField.getSize(next); tsPosition += configField.getSize(next);
} else if (configField.getSize(next) == 0) { } else if (configField.getSize(next) == 0) {
@ -106,7 +106,7 @@ public class TsOutput {
} }
tsHeader.append(size); tsHeader.append(size);
} }
tsHeader.append("], " + handleTsInfo(configField.getTsInfo(), 1)); tsHeader.append("], " + handleTsInfo(configField, configField.getTsInfo(), 1));
if (!configField.getName().equals(next.getName())) if (!configField.getName().equals(next.getName()))
tsPosition += configField.getSize(next); tsPosition += configField.getSize(next);
@ -123,8 +123,8 @@ public class TsOutput {
return sensorTsPosition; return sensorTsPosition;
} }
private String handleTsInfo(String tsInfo, int multiplierIndex) { private String handleTsInfo(ConfigField configField, String tsInfo, int multiplierIndex) {
if (tsInfo == null) { if (tsInfo == null || tsInfo.trim().isEmpty()) {
if (isConstantsSection) { if (isConstantsSection) {
throw new IllegalStateException("todo: implement default tsInfo for long form"); throw new IllegalStateException("todo: implement default tsInfo for long form");
} }
@ -162,7 +162,7 @@ public class TsOutput {
} }
return sb.toString(); return sb.toString();
} catch (Throwable e) { } catch (Throwable e) {
throw new IllegalStateException("While parsing " + tsInfo, e); throw new IllegalStateException("While parsing [" + tsInfo + "] of " + configField, e);
} }
} }
} }

View File

@ -18,6 +18,7 @@ public class OutputsTest {
"bit isForcedInduction;Does the vehicle have a turbo or supercharger?\n" + "bit isForcedInduction;Does the vehicle have a turbo or supercharger?\n" +
"bit enableFan1WithAc;+Turn on this fan when AC is on.\n" + "bit enableFan1WithAc;+Turn on this fan when AC is on.\n" +
"angle_t m_requested_pump;Computed requested pump duration in degrees (not including deadtime)\n" + "angle_t m_requested_pump;Computed requested pump duration in degrees (not including deadtime)\n" +
"float tCharge;speed density\\nRate-of-change limiter is applied to degrees, so we store both Kelvin and degrees.;\n" +
"end_struct\n"; "end_struct\n";
ReaderState state = new ReaderState(); ReaderState state = new ReaderState();
@ -61,7 +62,8 @@ public class OutputsTest {
"unusedBit_4_31 = bits, U32, 5, [31:31]\n" + "unusedBit_4_31 = bits, U32, 5, [31:31]\n" +
"alignmentFill_at_9 = array, U08, 9, [3], \"units\", 1, 0\n" + "alignmentFill_at_9 = array, U08, 9, [3], \"units\", 1, 0\n" +
"m_requested_pump = scalar, F32, 12, \"\", 1, 0\n" + "m_requested_pump = scalar, F32, 12, \"\", 1, 0\n" +
"; total TS size = 16\n", tsProjectConsumer.getContent()); "tCharge = scalar, F32, 16, \"\", 1, 0\n" +
"; total TS size = 20\n", tsProjectConsumer.getContent());
} }