From e6bfd9a2ed79f654a3d7e9b7c75301aee6d05b7c Mon Sep 17 00:00:00 2001 From: rusefillc Date: Wed, 9 Dec 2020 12:19:25 -0500 Subject: [PATCH] trigger lifecycle --- firmware/controllers/trigger/decoders/trigger_structure.h | 3 +++ firmware/controllers/trigger/trigger_central.cpp | 3 +-- firmware/controllers/trigger/trigger_central.h | 6 +++++- java_console/ui/src/main/java/com/rusefi/TriggerImage.java | 3 +-- unit_tests/main.cpp | 2 +- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/firmware/controllers/trigger/decoders/trigger_structure.h b/firmware/controllers/trigger/decoders/trigger_structure.h index 2a6a797f66..07f14a5b78 100644 --- a/firmware/controllers/trigger/decoders/trigger_structure.h +++ b/firmware/controllers/trigger/decoders/trigger_structure.h @@ -1,6 +1,9 @@ /** * @file trigger_structure.h * + * rusEFI defines trigger shape programmatically in C code + * For integration we have exportAllTriggers export + * * @date Dec 22, 2013 * @author Andrey Belomutskiy, (c) 2012-2020 */ diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 5cc4957d51..6d083e7855 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -521,14 +521,13 @@ static void triggerShapeInfo(void) { #include extern trigger_type_e focusOnTrigger; -#define TRIGGERS_FILE_NAME "triggers.txt" /** * This is used to generate trigger info which is later used by TriggerImage java class * to generate images for documentation */ extern bool printTriggerDebug; -void printAllTriggers() { +void exportAllTriggers() { FILE * fp = fopen (TRIGGERS_FILE_NAME, "w+"); diff --git a/firmware/controllers/trigger/trigger_central.h b/firmware/controllers/trigger/trigger_central.h index 1cded0e064..bac0417bce 100644 --- a/firmware/controllers/trigger/trigger_central.h +++ b/firmware/controllers/trigger/trigger_central.h @@ -82,7 +82,11 @@ void hwHandleShaftSignal(trigger_event_e signal, efitick_t timestamp); void hwHandleVvtCamSignal(trigger_value_e front, efitick_t timestamp DECLARE_ENGINE_PARAMETER_SUFFIX); void initTriggerCentral(Logging *sharedLogger); -void printAllTriggers(); +/** + * this method is invoked by 'unit tests' project on PC to write triggers.txt representation of all rusEFI triggers + * That triggers.txt is later consumed by TriggerImage.java to render trigger images + */ +void exportAllTriggers(); int isSignalDecoderError(void); void resetMaxValues(); diff --git a/java_console/ui/src/main/java/com/rusefi/TriggerImage.java b/java_console/ui/src/main/java/com/rusefi/TriggerImage.java index 9b46e0b116..c19b62710c 100644 --- a/java_console/ui/src/main/java/com/rusefi/TriggerImage.java +++ b/java_console/ui/src/main/java/com/rusefi/TriggerImage.java @@ -28,7 +28,6 @@ import java.util.List; public class TriggerImage { private static final String TRIGGERTYPE = "TRIGGERTYPE"; private static final String OUTPUT_FOLDER = "triggers"; - private static final String INPUT_FILE_NAME = "triggers.txt"; private static final String TOP_MESSAGE = StartupFrame.LINK_TEXT; private static final String DEFAULT_WORK_FOLDER = ".." + File.separator + "unit_tests"; @@ -126,7 +125,7 @@ public class TriggerImage { } private static void generateImages(String workingFolder, TriggerPanel trigger, JPanel topPanel, JPanel content) throws IOException { - String fileName = workingFolder + File.separator + INPUT_FILE_NAME; + String fileName = workingFolder + File.separator + Fields.TRIGGERS_FILE_NAME; BufferedReader br = new BufferedReader(new FileReader(fileName)); System.out.println("Reading " + fileName); diff --git a/unit_tests/main.cpp b/unit_tests/main.cpp index b3da98bc4b..d7e916b706 100644 --- a/unit_tests/main.cpp +++ b/unit_tests/main.cpp @@ -45,7 +45,7 @@ GTEST_API_ int main(int argc, char **argv) { // resizeMap(); printf("Success 20201203\r\n"); - printAllTriggers(); + exportAllTriggers(); if (focusOnTrigger != TT_UNUSED) { return -1; }