Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi live data #518

Merged
merged 8 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions firmware/controllers/sensors/wideband_state.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
struct_no_prefix wideband_state_s
uint8_t faultCode;WBO: Fault code
uint8_t faultCode;Fault code

uint8_t heaterDuty;WBO: Heater duty;"%", 1, 0, 0, 100, 0
uint8_t pumpDuty;WBO: Pump duty;"%", 1, 0, 0, 100, 0
uint8_t heaterDuty;Heater duty;"%", 1, 0, 0, 100, 0
uint8_t pumpDuty;Pump duty;"%", 1, 0, 0, 100, 0

uint16_t tempC;WBO: Temperature;"C", 1, 0, 500, 1000, 0
uint16_t autoscale nernstVoltage;WBO: Nernst Voltage;"V", 0.001, 0, 0, 1, 3
uint16_t esr;WBO: ESR;"ohm", 1, 0, 0, 10000, 0
uint16_t tempC;Temperature;"C", 1, 0, 500, 1000, 0
uint16_t autoscale nernstVoltage;Nernst Voltage;"V", 0.001, 0, 0, 1, 3
uint16_t esr;ESR;"ohm", 1, 0, 0, 10000, 0
end_struct
2 changes: 0 additions & 2 deletions firmware/gen_config_board.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ java \
-jar ../java_tools/ConfigDefinition.jar \
-readfile OUTPUTS_SECTION_FROM_FILE generated/output_channels.ini \
-readfile DATALOG_SECTION_FROM_FILE generated/data_logs.ini \
-readfile LIVE_DATA_MENU_FROM_FILE generated/fancy_menu.ini \
-readfile LIVE_DATA_PANELS_FROM_FILE generated/fancy_content.ini \
-triggerInputFolder ../unit_tests \
-with_c_defines false \
-field_lookup_file generated/value_lookup_generated.cpp generated/value_lookup_generated.md \
Expand Down
8 changes: 4 additions & 4 deletions firmware/integration/LiveData.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Usages:

- name: fan_control
folder: controllers/modules/fan
output_name: [ "fan1", "fan2" ]
output_name: [ "Fan 1", "Fan 2" ]
constexpr: "___engine.module<FanControl1>()"
isPtr: true

Expand Down Expand Up @@ -105,7 +105,7 @@ Usages:
- name: trigger_state
folder: controllers/trigger
prepend: integration/rusefi_config_shared.txt
output_name: [ "trg", "vvt1i", "vvt1e", "vvt2i", "vvt2e" ]
# output_name: [ "trg", "vvt1i", "vvt1e", "vvt2i", "vvt2e" ]

- name: trigger_state_primary
folder: controllers/trigger
Expand All @@ -122,11 +122,11 @@ Usages:
- name: electronic_throttle
folder: controllers/actuators
prepend: integration/rusefi_config_shared.txt
output_name: [ "etb1", "etb2" ]
# output_name: [ "etb1", "etb2" ]

- name: wideband_state
folder: controllers/sensors/
output_name: [ "wb1", "wb2" ]
output_name: [ "WBO 1", "WBO 2" ]

- name: dc_motors
folder: controllers/actuators
Expand Down
36 changes: 31 additions & 5 deletions firmware/tunerstudio/tunerstudio.template.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2015,10 +2015,6 @@ menuDialog = main
menu = "Help"
subMenu = helpGeneral, "FOME Info"

menu = "&View"
@@LIVE_DATA_MENU_FROM_FILE@@


[ControllerCommands]
; commandName = command1, command2, commandn...
; command in standard ini format, a command name can be assigned to 1 to n commands that will be executed in order.
Expand Down Expand Up @@ -2182,7 +2178,37 @@ cmd_set_engine_type_8888_test = "@@TS_IO_TEST_COMMAND_char@@@@ts_command_e_TS
cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@@@ts_command_e_TS_SET_DEFAULT_ENGINE_16_hex@@\x00\x00"

[UserDefined]
@@LIVE_DATA_PANELS_FROM_FILE@@

indicatorPanel = ac_controlIndicatorPanel, 2
indicator = {acButtonState}, "acButtonState No", "acButtonState Yes"
indicator = {m_acEnabled}, "m_acEnabled No", "m_acEnabled Yes"
indicator = {engineTooSlow}, "engineTooSlow No", "engineTooSlow Yes"
indicator = {engineTooFast}, "engineTooFast No", "engineTooFast Yes"
indicator = {noClt}, "noClt No", "noClt Yes"
indicator = {engineTooHot}, "engineTooHot No", "engineTooHot Yes"
indicator = {tpsTooHigh}, "tpsTooHigh No", "tpsTooHigh Yes"
indicator = {isDisabledByLua}, "isDisabledByLua No", "isDisabledByLua Yes"
indicator = {acCompressorState}, "acCompressorState No", "acCompressorState Yes"

dialog = ac_controlDialog, "ac_control"
panel = ac_controlIndicatorPanel

indicatorPanel = launch_control_stateIndicatorPanel, 2
indicator = {combinedConditions}, "combinedConditions No", "combinedConditions Yes"
indicator = {launchActivatePinState}, "launchActivatePinState No", "launchActivatePinState Yes"
indicator = {isLaunchCondition}, "isLaunchCondition No", "isLaunchCondition Yes"
indicator = {isSwitchActivated}, "isSwitchActivated No", "isSwitchActivated Yes"
indicator = {isClutchActivated}, "isClutchActivated No", "isClutchActivated Yes"
indicator = {isValidInputPin}, "isValidInputPin No", "isValidInputPin Yes"
indicator = {activateSwitchCondition}, "activateSwitchCondition No", "activateSwitchCondition Yes"
indicator = {rpmCondition}, "rpmCondition No", "rpmCondition Yes"
indicator = {speedCondition}, "speedCondition No", "speedCondition Yes"
indicator = {tpsCondition}, "tpsCondition No", "tpsCondition Yes"

dialog = launch_control_stateDialog, "launch_control_state"
panel = launch_control_stateIndicatorPanel
liveGraph = launch_control_state_1_Graph, "Graph", South
graphLine = retardThresholdRpm

dialog = scriptTable1TblSettings, "", yAxis
field = "Name", scriptTableName1
Expand Down
Binary file modified java_tools/ConfigDefinition.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ public class LiveDataProcessor {

private final StringBuilder baseAddressCHeader = new StringBuilder();

private final StringBuilder fancyNewStuff = new StringBuilder();

private final StringBuilder fancyNewMenu = new StringBuilder();

private final StringBuilder fragmentsContent = new StringBuilder(header);

private final String extraPrepend = System.getProperty("LiveDataProcessor.extra_prepend");
Expand Down Expand Up @@ -72,14 +68,6 @@ public static void main(String[] args) throws IOException {
fw.write(header);
fw.write("#define TS_TOTAL_OUTPUT_SIZE " + sensorTsPosition);
}

try (FileWriter fw = new FileWriter(tsOutputsDestination + "fancy_content.ini")) {
fw.write(liveDataProcessor.fancyNewStuff.toString());
}

try (FileWriter fw = new FileWriter(tsOutputsDestination + "fancy_menu.ini")) {
fw.write(liveDataProcessor.fancyNewMenu.toString());
}
}

interface EntryHandler {
Expand All @@ -106,9 +94,6 @@ private int handleYaml(Map<String, Object> data) throws IOException {
state.setDefinitionInputFile(folder + File.separator + name + ".txt");
state.setWithC_Defines(withCDefines);

FragmentDialogConsumer fragmentDialogConsumer = new FragmentDialogConsumer(name);
state.addDestination(fragmentDialogConsumer);

if (extraPrepend != null)
state.addPrepend(extraPrepend);
state.addPrepend(prepend);
Expand Down Expand Up @@ -141,13 +126,13 @@ private int handleYaml(Map<String, Object> data) throws IOException {
CStructWriter cStructs = new CStructWriter();
cStructs.writeCStructs(parseState, cHeaderDestination);

// if (outputNames.length == 0) {
if (outputNames.length <= 1) {
outputChannelWriter.writeOutputChannels(parseState, null);
// } else {
// for (int i = 0; i < outputNames.length; i++) {
// outputChannelWriter.writeOutputChannels(parseState, outputNames[i]);
// }
// }
} else {
for (String outputName : outputNames) {
outputChannelWriter.writeOutputChannels(parseState, outputName);
}
}

if (constexpr != null) {
sdLogWriter.writeSdLogs(parseState, constexpr + (isPtr ? "->" : "."));
Expand All @@ -156,10 +141,6 @@ private int handleYaml(Map<String, Object> data) throws IOException {

state.doJob();

fancyNewStuff.append(fragmentDialogConsumer.getContent());

fancyNewMenu.append(fragmentDialogConsumer.menuLine());

log.info("Done with " + name + " at " + outputChannelWriter.getSize());
};

Expand Down Expand Up @@ -199,18 +180,13 @@ private int handleYaml(Map<String, Object> data) throws IOException {
String type = name + "_s"; // convention
enumContent.append(enumName + ",\n");

if (outputNamesArr.length < 2) {
if (outputNamesArr.length <= 1) {
fragmentsContent
.append("decl_frag<")
.append(type)
.append(">{},\n");
} else {
for (int i = 0; i < outputNamesArr.length; i++) {
if (i != 0) {
// TODO: remove once the rest of the handling for multiple copies of one struct is in place.
fragmentsContent.append("// ");
}

fragmentsContent
.append("decl_frag<")
.append(type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
import java.io.PrintStream;

public class DatalogVisitor extends OutputChannelVisitorBase {
private static void writeDatalogName(PrintStream ps, String name, String comment) {
public DatalogVisitor(String nameReplace) {
super(nameReplace);
}

private void writeDatalogName(PrintStream ps, String name, String comment) {
ps.print(buildDatalogName(name, comment));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
import java.io.PrintStream;

public class OutputChannelVisitor extends OutputChannelVisitorBase {
public OutputChannelVisitor(String nameReplace) {
super(nameReplace);
}

@Override
public void visit(EnumLayout e, PrintStream ps, StructNamePrefixer prefixer, int offsetAdd, int[] arrayDims) {
// Output an enum as a scalar, since there's no TS support for enum output channels
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@
import java.io.PrintStream;

public class OutputChannelVisitorBase extends ILayoutVisitor {
public static String buildDatalogName(String name, String comment) {
String text = (comment == null || comment.isEmpty()) ? name : comment;
protected final NameReplacer nameReplacer;

public OutputChannelVisitorBase(String nameReplace) {
this.nameReplacer = new NameReplacer(nameReplace);
}

public String buildDatalogName(String name, String comment) {
String text = (comment == null || comment.isEmpty()) ? name : nameReplacer.replace(comment);

// Delete anything after a newline
return text.split("\\\\n")[0];
Expand All @@ -27,4 +33,20 @@ public void visit(StructLayout struct, PrintStream ps, StructNamePrefixer prefix
throw new IllegalStateException("Output channels don't support multi dimension arrays");
}
}

protected class NameReplacer {
public final String name;

public NameReplacer(String name) {
this.name = name;
}

public String replace(String input) {
if (name == null || name.isEmpty()) {
return input;
}

return name + ": " + input;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ public void writeOutputChannels(ParseState parser, String namePrefix) {
StructNamePrefixer prefixer = new StructNamePrefixer('_');

if (namePrefix != null) {
prefixer.push(namePrefix);
prefixer.push(namePrefix.replace(" ", "_"));
}

OutputChannelVisitor v = new OutputChannelVisitor();
OutputChannelVisitor v = new OutputChannelVisitor(namePrefix);
sl.visit(v, ps, prefixer, cumulativeSize, new int[0]);

DatalogVisitor dlv = new DatalogVisitor();
DatalogVisitor dlv = new DatalogVisitor(namePrefix);
sl.visit(dlv, psDatalog, prefixer, cumulativeSize, new int[0]);

cumulativeSize += sl.getSize();
Expand Down
Loading
Loading