use yaml like you're supposed to (#4233)
* use yaml like you're supposed to * parse output names (but don't use it yet)
This commit is contained in:
parent
7331126721
commit
e274fba799
|
@ -13,24 +13,85 @@
|
|||
# todo: what is sequence of events in terms of 'live_data_e' code generation?
|
||||
#
|
||||
Usages:
|
||||
output_channels: ["TsOutputs.java", "console/binary", "-prepend=integration/rusefi_config.txt" ]
|
||||
knock_controller: [ "KnockController.java", "controllers/engine_cycle" ]
|
||||
high_pressure_fuel_pump: [ "HighPressureFuelPump.java", "controllers/engine_cycle" ]
|
||||
injector_model: [ "InjectorModel.java", "controllers/algo/fuel" ]
|
||||
launch_control_state: [ "LaunchControl.java", "controllers/algo" ]
|
||||
boost_control: [ "BoostControl.java", "controllers/actuators" ]
|
||||
ac_control: [ "AcControl.java", "controllers/actuators", "-prepend=integration/rusefi_config.txt" ]
|
||||
fan_control: [ "FanControl.java", "controllers/actuators" ]
|
||||
fuel_pump_control: [ "FuelPump.java", "controllers/actuators" ]
|
||||
main_relay: [ "MainRelay.java", "controllers/actuators" ]
|
||||
#todo: handle ETB pid and Idle pid which point at same pid_state.txt
|
||||
#pid_state: [ "PidState.java", "util/math" ]
|
||||
engine_state: [ "EngineState.java", "controllers/algo" ]
|
||||
tps_accel_state: [ "TpsAccelState.java", "controllers/algo" ]
|
||||
trigger_central: [ "TriggerCentral.java", "controllers/trigger", "-with_c_defines=true" ]
|
||||
trigger_state: [ "TriggerState.java", "controllers/trigger", "-prepend=integration/rusefi_config.txt" ]
|
||||
wall_fuel_state: [ "WallFuelState.java", "controllers/algo" ]
|
||||
idle_state: [ "IdleState.java", "controllers/actuators" ]
|
||||
ignition_state: [ "IgnitionState.java", "controllers/algo" ]
|
||||
electronic_throttle: [ "ElectronicThrottle.java", "controllers/actuators" ]
|
||||
- name: output_channels
|
||||
java: TsOutputs.java
|
||||
folder: console/binary
|
||||
prepend: integration/rusefi_config.txt
|
||||
|
||||
- name: knock_controller
|
||||
java: KnockController.java
|
||||
folder: controllers/engine_cycle
|
||||
|
||||
- name: high_pressure_fuel_pump
|
||||
java: HighPressureFuelPump.java
|
||||
folder: controllers/engine_cycle
|
||||
|
||||
- name: injector_model
|
||||
java: InjectorModel.java
|
||||
folder: controllers/algo/fuel
|
||||
|
||||
- name: launch_control_state
|
||||
java: LaunchControl.java
|
||||
folder: controllers/algo
|
||||
|
||||
- name: boost_control
|
||||
java: BoostControl.java
|
||||
folder: controllers/actuators
|
||||
|
||||
- name: ac_control
|
||||
java: AcControl.java
|
||||
folder: controllers/actuators
|
||||
prepend: integration/rusefi_config.txt
|
||||
|
||||
- name: fan_control
|
||||
java: FanControl.java
|
||||
folder: controllers/actuators
|
||||
|
||||
- name: fuel_pump_control
|
||||
java: FuelPump.java
|
||||
folder: controllers/actuators
|
||||
|
||||
- name: main_relay
|
||||
java: MainRelay.java
|
||||
folder: controllers/actuators
|
||||
|
||||
#todo: handle ETB pid and Idle pid which point at same pid_state.txt
|
||||
# - name: pid_state
|
||||
# java: PidState.java
|
||||
# folder: util/math
|
||||
|
||||
- name: engine_state
|
||||
java: EngineState.java
|
||||
folder: controllers/algo
|
||||
|
||||
- name: tps_accel_state
|
||||
java: TpsAccelState.java
|
||||
folder: controllers/algo
|
||||
|
||||
- name: trigger_central
|
||||
java: TriggerCentral.java
|
||||
folder: controllers/trigger
|
||||
withCDefines: true
|
||||
|
||||
- name: trigger_state
|
||||
java: TriggerState.java
|
||||
folder: controllers/trigger
|
||||
prepend: integration/rusefi_config.txt
|
||||
output_name: [ "trg", "vvt1i", "vvt1e", "vvt2i", "vvt2e" ]
|
||||
|
||||
- name: wall_fuel_state
|
||||
java: WallFuelState.java
|
||||
folder: controllers/algo
|
||||
|
||||
- name: idle_state
|
||||
java: IdleState.java
|
||||
folder: controllers/actuators
|
||||
output_name: idle
|
||||
|
||||
- name: ignition_state
|
||||
java: IgnitionState.java
|
||||
folder: controllers/algo
|
||||
|
||||
- name: electronic_throttle
|
||||
java: ElectronicThrottle.java
|
||||
folder: controllers/actuators
|
||||
|
|
Binary file not shown.
|
@ -1,8 +1,9 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="LiveDocsMetaParser" type="Application" factoryName="Application" nameIsGenerated="true">
|
||||
<option name="MAIN_CLASS_NAME" value="com.rusefi.ldmp.LiveDocsMetaParser" />
|
||||
<configuration default="false" name="UsagesReader" type="Application" factoryName="Application">
|
||||
<option name="MAIN_CLASS_NAME" value="com.rusefi.ldmp.UsagesReader" />
|
||||
<module name="configuration_definition" />
|
||||
<option name="PROGRAM_PARAMETERS" value=""../../firmware/controllers/math/speed_density.cpp" "../../"" />
|
||||
<option name="PROGRAM_PARAMETERS" value="integration/LiveData.yaml" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/../../firmware" />
|
||||
<extension name="coverage">
|
||||
<pattern>
|
||||
<option name="PATTERN" value="com.rusefi.ldmp.*" />
|
|
@ -346,7 +346,7 @@ public class ReaderState {
|
|||
}
|
||||
|
||||
public void addPrepend(String fileName) {
|
||||
if (fileName.isEmpty()) {
|
||||
if (fileName == null || fileName.isEmpty()) {
|
||||
// see UsagesReader use-case with dynamic prepend usage
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.io.File;
|
|||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -69,7 +70,7 @@ public class UsagesReader {
|
|||
}
|
||||
|
||||
interface EntryHandler {
|
||||
void onEntry(String name, List elements) throws IOException;
|
||||
void onEntry(String name, String javaName, String folder, String prepend, boolean withCDefines, String[] outputNames) throws IOException;
|
||||
}
|
||||
|
||||
private int handleYaml(Map<String, Object> data, EntryHandler _handler) throws IOException {
|
||||
|
@ -81,32 +82,13 @@ public class UsagesReader {
|
|||
ConfigurationConsumer dataLogConsumer = new DataLogConsumer(tsOutputsDestination + File.separator + "generated/data_logs.ini");
|
||||
|
||||
EntryHandler handler = new EntryHandler() {
|
||||
|
||||
@Override
|
||||
public void onEntry(String name, List elements) throws IOException {
|
||||
String javaName = (String) elements.get(0);
|
||||
String folder = (String) elements.get(1);
|
||||
public void onEntry(String name, String javaName, String folder, String prepend, boolean withCDefines, String[] outputNames) throws IOException {
|
||||
// TODO: use outputNames
|
||||
|
||||
int startingPosition = javaSensorsConsumer.sensorTsPosition;
|
||||
log.info("Starting " + name + " at " + startingPosition);
|
||||
|
||||
boolean withCDefines = false;
|
||||
String prepend = "";
|
||||
for (int i = 2; i < elements.size(); i++) {
|
||||
String keyValue = (String) elements.get(i);
|
||||
String[] pair = keyValue.trim().split("=");
|
||||
String key = pair[0];
|
||||
String value = pair[1];
|
||||
if (key.equals(ConfigDefinition.KEY_WITH_C_DEFINES)) {
|
||||
withCDefines = Boolean.parseBoolean(value);
|
||||
} else if (key.equals(ConfigDefinition.KEY_PREPEND)) {
|
||||
prepend = value;
|
||||
}
|
||||
}
|
||||
|
||||
// String macroName = elements.size() > 2 ? ((String)elements.get(2)).trim() : "";
|
||||
|
||||
|
||||
ReaderState state = new ReaderState();
|
||||
state.setDefinitionInputFile(folder + File.separator + name + ".txt");
|
||||
state.withC_Defines = withCDefines;
|
||||
|
@ -131,17 +113,34 @@ public class UsagesReader {
|
|||
}
|
||||
};
|
||||
|
||||
LinkedHashMap<?, ?> liveDocs = (LinkedHashMap) data.get("Usages");
|
||||
ArrayList<LinkedHashMap> liveDocs = (ArrayList<LinkedHashMap>)data.get("Usages");
|
||||
|
||||
fragmentsContent.append("static const FragmentEntry fragments[] = {\n");
|
||||
|
||||
for (Map.Entry entry : liveDocs.entrySet()) {
|
||||
String name = (String) entry.getKey();
|
||||
System.out.println(" " + name);
|
||||
System.out.println(" " + entry.getValue());
|
||||
List elements = (List) entry.getValue();
|
||||
for (LinkedHashMap entry : liveDocs) {
|
||||
String name = (String)entry.get("name");
|
||||
String java = (String)entry.get("java");
|
||||
String folder = (String)entry.get("folder");
|
||||
String prepend = (String)entry.get("prepend");
|
||||
Boolean withCDefines = (Boolean)entry.get("withCDefines");
|
||||
// Defaults to false if not specified
|
||||
withCDefines = withCDefines != null && withCDefines;
|
||||
|
||||
handler.onEntry(name, elements);
|
||||
Object outputNames = entry.get("output_name");
|
||||
|
||||
String[] outputNamesArr;
|
||||
if (outputNames == null) {
|
||||
outputNamesArr = new String[0];
|
||||
} else if (outputNames instanceof String) {
|
||||
outputNamesArr = new String[1];
|
||||
outputNamesArr[0] = (String)outputNames;
|
||||
} else {
|
||||
ArrayList<String> nameList = (ArrayList<String>)outputNames;
|
||||
outputNamesArr = new String[nameList.size()];
|
||||
nameList.toArray(outputNamesArr);
|
||||
}
|
||||
|
||||
handler.onEntry(name, java, folder, prepend, withCDefines, outputNamesArr);
|
||||
|
||||
String enumName = "LDS_" + name;
|
||||
String type = name + "_s"; // convention
|
||||
|
|
Loading…
Reference in New Issue