diff --git a/firmware/console/binary/tunerstudio.cpp b/firmware/console/binary/tunerstudio.cpp index 6a911f854f..bf6a0b1b75 100644 --- a/firmware/console/binary/tunerstudio.cpp +++ b/firmware/console/binary/tunerstudio.cpp @@ -261,7 +261,8 @@ static const void * getStructAddr(live_data_e structId) { return static_cast(&engine->idle); case LDS_TPS_ACCEL: return static_cast(&engine->tpsAccelEnrichment); - + case LDS_MAIN_RELAY: + return static_cast(&engine->module().unmock()); default: return nullptr; } diff --git a/firmware/controllers/actuators/main_relay.cpp b/firmware/controllers/actuators/main_relay.cpp new file mode 100644 index 0000000000..d5d3bb3891 --- /dev/null +++ b/firmware/controllers/actuators/main_relay.cpp @@ -0,0 +1,17 @@ +#include "pch.h" + +#include "main_relay.h" + +void MainRelayController::onSlowCallback() { + isBenchTest = engine->isInMainRelayBench(); + +#if EFI_MAIN_RELAY_CONTROL + hasIgnitionVoltage = Sensor::getOrZero(SensorType::BatteryVoltage) > 5; + + mainRelayState = isBenchTest | hasIgnitionVoltage; +#else // not EFI_MAIN_RELAY_CONTROL + mainRelayState = !isBenchTest; +#endif + + enginePins.mainRelay.setValue(mainRelayState); +} diff --git a/firmware/controllers/actuators/main_relay.h b/firmware/controllers/actuators/main_relay.h new file mode 100644 index 0000000000..0443271cb9 --- /dev/null +++ b/firmware/controllers/actuators/main_relay.h @@ -0,0 +1,8 @@ +#pragma once + +#include "engine_module.h" +#include "main_relay_generated.h" + +struct MainRelayController : public EngineModule, public main_relay_s { + void onSlowCallback() override; +}; diff --git a/firmware/controllers/actuators/main_relay.txt b/firmware/controllers/actuators/main_relay.txt new file mode 100644 index 0000000000..73aeaa2f9f --- /dev/null +++ b/firmware/controllers/actuators/main_relay.txt @@ -0,0 +1,5 @@ +struct_no_prefix main_relay_s + bit isBenchTest + bit hasIgnitionVoltage + bit mainRelayState +end_struct diff --git a/firmware/controllers/actuators/main_relay_generated.h b/firmware/controllers/actuators/main_relay_generated.h new file mode 100644 index 0000000000..104f2d87bd --- /dev/null +++ b/firmware/controllers/actuators/main_relay_generated.h @@ -0,0 +1,108 @@ +// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/actuators/main_relay.txt Fri Nov 19 13:01:22 PST 2021 +// by class com.rusefi.output.CHeaderConsumer +// begin +#pragma once +#include "rusefi_types.h" +// start of main_relay_s +struct main_relay_s { + /** + offset 0 bit 0 */ + bool isBenchTest : 1; + /** + offset 0 bit 1 */ + bool hasIgnitionVoltage : 1; + /** + offset 0 bit 2 */ + bool mainRelayState : 1; + /** + offset 0 bit 3 */ + bool unusedBit_3_3 : 1; + /** + offset 0 bit 4 */ + bool unusedBit_3_4 : 1; + /** + offset 0 bit 5 */ + bool unusedBit_3_5 : 1; + /** + offset 0 bit 6 */ + bool unusedBit_3_6 : 1; + /** + offset 0 bit 7 */ + bool unusedBit_3_7 : 1; + /** + offset 0 bit 8 */ + bool unusedBit_3_8 : 1; + /** + offset 0 bit 9 */ + bool unusedBit_3_9 : 1; + /** + offset 0 bit 10 */ + bool unusedBit_3_10 : 1; + /** + offset 0 bit 11 */ + bool unusedBit_3_11 : 1; + /** + offset 0 bit 12 */ + bool unusedBit_3_12 : 1; + /** + offset 0 bit 13 */ + bool unusedBit_3_13 : 1; + /** + offset 0 bit 14 */ + bool unusedBit_3_14 : 1; + /** + offset 0 bit 15 */ + bool unusedBit_3_15 : 1; + /** + offset 0 bit 16 */ + bool unusedBit_3_16 : 1; + /** + offset 0 bit 17 */ + bool unusedBit_3_17 : 1; + /** + offset 0 bit 18 */ + bool unusedBit_3_18 : 1; + /** + offset 0 bit 19 */ + bool unusedBit_3_19 : 1; + /** + offset 0 bit 20 */ + bool unusedBit_3_20 : 1; + /** + offset 0 bit 21 */ + bool unusedBit_3_21 : 1; + /** + offset 0 bit 22 */ + bool unusedBit_3_22 : 1; + /** + offset 0 bit 23 */ + bool unusedBit_3_23 : 1; + /** + offset 0 bit 24 */ + bool unusedBit_3_24 : 1; + /** + offset 0 bit 25 */ + bool unusedBit_3_25 : 1; + /** + offset 0 bit 26 */ + bool unusedBit_3_26 : 1; + /** + offset 0 bit 27 */ + bool unusedBit_3_27 : 1; + /** + offset 0 bit 28 */ + bool unusedBit_3_28 : 1; + /** + offset 0 bit 29 */ + bool unusedBit_3_29 : 1; + /** + offset 0 bit 30 */ + bool unusedBit_3_30 : 1; + /** + offset 0 bit 31 */ + bool unusedBit_3_31 : 1; + /** total size 4*/ +}; + +// end +// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/actuators/main_relay.txt Fri Nov 19 13:01:22 PST 2021 diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index 49806e334d..14ceee8e9b 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -538,7 +538,7 @@ bool Engine::isInMainRelayBench() { } bool Engine::isInShutdownMode() const { -#if EFI_MAIN_RELAY_CONTROL +#if EFI_MAIN_RELAY_CONTROL && EFI_PROD_CODE // if we are in "ignition_on" mode and not in shutdown mode if (stopEngineRequestTimeNt == 0 && ignitionOnTimeNt > 0) { const float vBattThresholdOff = 5.0f; diff --git a/firmware/controllers/algo/engine.h b/firmware/controllers/algo/engine.h index 5e6e711fc6..4a4bf757f0 100644 --- a/firmware/controllers/algo/engine.h +++ b/firmware/controllers/algo/engine.h @@ -30,6 +30,7 @@ #include "launch_control.h" #include "trigger_scheduler.h" #include "fuel_pump.h" +#include "main_relay.h" #include "type_list.h" #ifndef EFI_UNIT_TEST @@ -135,6 +136,7 @@ public: #endif // EFI_HPFP && EFI_ENGINE_CONTROL FuelPumpController, + MainRelayController, EngineModule // dummy placeholder so the previous entries can all have commas > engineModules; diff --git a/firmware/controllers/algo/live_data_ids.h b/firmware/controllers/algo/live_data_ids.h index 836cf423ab..b56a4f1713 100644 --- a/firmware/controllers/algo/live_data_ids.h +++ b/firmware/controllers/algo/live_data_ids.h @@ -21,5 +21,6 @@ LDS_TRIGGER_STATE, LDS_AC_CONTROL, LDS_FUEL_PUMP, LDS_IDLE, -LDS_TPS_ACCEL +LDS_TPS_ACCEL, +LDS_MAIN_RELAY, } live_data_e; diff --git a/firmware/controllers/controllers.mk b/firmware/controllers/controllers.mk index 446b944fc2..e05fe2bd69 100644 --- a/firmware/controllers/controllers.mk +++ b/firmware/controllers/controllers.mk @@ -21,6 +21,7 @@ CONTROLLERS_SRC_CPP = \ $(CONTROLLERS_DIR)/actuators/idle_thread_io.cpp \ $(CONTROLLERS_DIR)/actuators/idle_hardware.cpp \ $(CONTROLLERS_DIR)/actuators/idle_thread.cpp \ + $(CONTROLLERS_DIR)/actuators/main_relay.cpp \ $(CONTROLLERS_DIR)/actuators/pwm_tester.cpp \ $(CONTROLLERS_DIR)/actuators/vvt.cpp \ $(CONTROLLERS_DIR)/actuators/gppwm/gppwm_channel.cpp \ diff --git a/firmware/controllers/core/fsio_core.h b/firmware/controllers/core/fsio_core.h index 61c5c12a8f..ad499a0f7c 100644 --- a/firmware/controllers/core/fsio_core.h +++ b/firmware/controllers/core/fsio_core.h @@ -33,7 +33,6 @@ typedef enum { LE_METHOD_RPM = 100, LE_METHOD_COOLANT = 101, LE_METHOD_FAN = 102, - LE_METHOD_TIME_SINCE_BOOT = 103, LE_METHOD_TPS = 106, LE_METHOD_MAF = 107, LE_METHOD_INTAKE_AIR = 108, @@ -52,7 +51,6 @@ typedef enum { LE_METHOD_FSIO_DIGITAL_INPUT = 123, LE_METHOD_FSIO_SETTING = 124, LE_METHOD_PPS = 125, - LE_METHOD_IN_MR_BENCH = 128, LE_METHOD_FUEL_FLOW_RATE = 131, LE_METHOD_OIL_PRESSURE = 132, diff --git a/firmware/controllers/core/fsio_impl.cpp b/firmware/controllers/core/fsio_impl.cpp index be4f58b227..61156de81e 100644 --- a/firmware/controllers/core/fsio_impl.cpp +++ b/firmware/controllers/core/fsio_impl.cpp @@ -55,7 +55,6 @@ static LENameOrdinalPair leOilPressure(LE_METHOD_OIL_PRESSURE, "oilp"); static LENameOrdinalPair leAcToggle(LE_METHOD_AC_TOGGLE, "ac_on_switch"); // @returns float number of seconds since last A/C toggle static LENameOrdinalPair leTimeSinceAcToggle(LE_METHOD_TIME_SINCE_AC_TOGGLE, "time_since_ac_on_switch"); -static LENameOrdinalPair leTimeSinceBoot(LE_METHOD_TIME_SINCE_BOOT, "time_since_boot"); static LENameOrdinalPair leFsioSetting(LE_METHOD_FSIO_SETTING, FSIO_METHOD_FSIO_SETTING); static LENameOrdinalPair leFsioAnalogInput(LE_METHOD_FSIO_ANALOG_INPUT, FSIO_METHOD_FSIO_ANALOG_INPUT); static LENameOrdinalPair leFsioDigitalInput(LE_METHOD_FSIO_DIGITAL_INPUT, FSIO_METHOD_FSIO_DIGITAL_INPUT); @@ -63,7 +62,6 @@ static LENameOrdinalPair leIntakeVVT(LE_METHOD_INTAKE_VVT, "ivvt"); static LENameOrdinalPair leExhaustVVT(LE_METHOD_EXHAUST_VVT, "evvt"); static LENameOrdinalPair leCrankingRpm(LE_METHOD_CRANKING_RPM, "cranking_rpm"); static LENameOrdinalPair leInShutdown(LE_METHOD_IN_SHUTDOWN, "in_shutdown"); -static LENameOrdinalPair leInMrBench(LE_METHOD_IN_MR_BENCH, "in_mr_bench"); static LENameOrdinalPair leFuelRate(LE_METHOD_FUEL_FLOW_RATE, "fuel_flow"); #include "fsio_names.def" @@ -76,10 +74,6 @@ CCM_OPTIONAL LEElementPool sysPool(sysElements, SYS_ELEMENT_POOL_SIZE); static LEElement * starterRelayDisableLogic; -#if EFI_MAIN_RELAY_CONTROL -static LEElement * mainRelayLogic; -#endif /* EFI_MAIN_RELAY_CONTROL */ - #if EFI_PROD_CODE || EFI_SIMULATOR FsioResult getEngineValue(le_action_e action) { @@ -108,20 +102,10 @@ FsioResult getEngineValue(le_action_e action) { case LE_METHOD_EXHAUST_VVT: return engine->triggerCentral.getVVTPosition(0, 1); #endif - case LE_METHOD_TIME_SINCE_BOOT: -#if EFI_MAIN_RELAY_CONTROL - // in main relay control mode, we return the number of seconds since the ignition is turned on - // (or negative if the ignition key is switched off) - return engine->getTimeIgnitionSeconds(); -#else - return getTimeNowSeconds(); -#endif /* EFI_MAIN_RELAY_CONTROL */ case LE_METHOD_CRANKING_RPM: return engineConfiguration->cranking.rpm; case LE_METHOD_IN_SHUTDOWN: return engine->isInShutdownMode(); - case LE_METHOD_IN_MR_BENCH: - return engine->isInMainRelayBench(); case LE_METHOD_VBATT: return Sensor::getOrZero(SensorType::BatteryVoltage); case LE_METHOD_TPS: @@ -159,8 +143,6 @@ static const char * action2String(le_action_e action) { return "fan"; case LE_METHOD_IN_SHUTDOWN: return leInShutdown.name; - case LE_METHOD_IN_MR_BENCH: - return leInMrBench.name; #include "fsio_strings.def" default: { @@ -198,18 +180,6 @@ static void setPinState(const char * msg, OutputPin *pin, LEElement *element) { * this method should be invoked periodically to calculate FSIO and toggle corresponding FSIO outputs */ void runFsio() { -#if EFI_MAIN_RELAY_CONTROL - if (isBrainPinValid(engineConfiguration->mainRelayPin)) - // the MAIN_RELAY_LOGIC calls engine->isInShutdownMode() - setPinState("main_relay", &enginePins.mainRelay, mainRelayLogic); -#else /* EFI_MAIN_RELAY_CONTROL */ - /** - * main relay is always on if ECU is on, that's a good enough initial implementation - */ - if (isBrainPinValid(engineConfiguration->mainRelayPin)) - enginePins.mainRelay.setValue(!engine->isInMainRelayBench()); -#endif /* EFI_MAIN_RELAY_CONTROL */ - if (isBrainPinValid(engineConfiguration->starterRelayDisablePin)) setPinState("starter_relay", &enginePins.starterRelayDisable, starterRelayDisableLogic); @@ -314,10 +284,6 @@ void initFsioImpl() { sysPool.reset(); #endif -#if EFI_MAIN_RELAY_CONTROL - if (isBrainPinValid(engineConfiguration->mainRelayPin)) - mainRelayLogic = sysPool.parseExpression(MAIN_RELAY_LOGIC); -#endif /* EFI_MAIN_RELAY_CONTROL */ if (isBrainPinValid(engineConfiguration->starterRelayDisablePin)) starterRelayDisableLogic = sysPool.parseExpression(STARTER_RELAY_LOGIC); @@ -342,10 +308,6 @@ void runHardcodedFsio() { } #endif /* EFI_PROD_CODE */ - // see MAIN_RELAY_LOGIC - if (isBrainPinValid(engineConfiguration->mainRelayPin)) { - enginePins.mainRelay.setValue((getTimeNowSeconds() < 2) || (Sensor::getOrZero(SensorType::BatteryVoltage) > LOW_VBATT) || engine->isInShutdownMode()); - } // see STARTER_RELAY_LOGIC if (isBrainPinValid(engineConfiguration->starterRelayDisablePin)) { enginePins.starterRelayDisable.setValue(engine->rpmCalculator.getRpm() < engineConfiguration->cranking.rpm); diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index 79b516f2c8..f3eb7d682b 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -750,7 +750,7 @@ void initEngineContoller() { #define RAM_UNUSED_SIZE 9000 #endif #ifndef CCM_UNUSED_SIZE -#define CCM_UNUSED_SIZE 32 +#define CCM_UNUSED_SIZE 16 #endif static char UNUSED_RAM_SIZE[RAM_UNUSED_SIZE]; static char UNUSED_CCM_SIZE[CCM_UNUSED_SIZE] CCM_OPTIONAL; diff --git a/firmware/controllers/system_fsio.h b/firmware/controllers/system_fsio.h index 30632eced4..feb2769f45 100644 --- a/firmware/controllers/system_fsio.h +++ b/firmware/controllers/system_fsio.h @@ -22,17 +22,6 @@ // Human-readable: (rpm > fsio_setting(2)) | ((coolant > fsio_setting(3)) | (vbatt < fsio_setting(4))) #define COMBINED_WARNING_LIGHT "rpm 2 fsio_setting > coolant 3 fsio_setting > vbatt 4 fsio_setting < | |" -//needed by EFI_MAIN_RELAY_CONTROL which is currently FALSE for most of the boards -// todo: make '5' a setting? -// todo: always have 'EFI_MAIN_RELAY_CONTROL'? -// at the moment microRusEFI would not be happy with vbatt > 5 since microRusEFI senses main relay output -// todo https://github.com/rusefi/rusefi/issues/2258 -//MAIN_RELAY_LOGIC=(time_since_boot >= 0 & time_since_boot < 2) | (vbatt > 5) | in_shutdown -//MAIN_RELAY_LOGIC=(!in_mr_bench) & ((vbatt > 5) | in_shutdown) - -// Human-readable: (!in_mr_bench) & (vbatt > 5) -#define MAIN_RELAY_LOGIC "in_mr_bench ! vbatt 5 > &" -// could be used for simple variable intake geometry setups or warning light or starter block // Human-readable: rpm > fsio_setting(1) #define RPM_ABOVE_USER_SETTING_1 "rpm 1 fsio_setting >" diff --git a/firmware/controllers/system_fsio.txt b/firmware/controllers/system_fsio.txt index 55ea08f03d..862fc79e0d 100644 --- a/firmware/controllers/system_fsio.txt +++ b/firmware/controllers/system_fsio.txt @@ -14,15 +14,6 @@ TOO_HOT_LOGIC=coolant > 120 # Combined RPM, CLT and VBATT warning light COMBINED_WARNING_LIGHT=(rpm > fsio_setting(2)) | ((coolant > fsio_setting(3)) | (vbatt < fsio_setting(4))) -#needed by EFI_MAIN_RELAY_CONTROL which is currently FALSE for most of the boards -# todo: make '5' a setting? -# todo: always have 'EFI_MAIN_RELAY_CONTROL'? -# at the moment microRusEFI would not be happy with vbatt > 5 since microRusEFI senses main relay output -# todo https://github.com/rusefi/rusefi/issues/2258 -#MAIN_RELAY_LOGIC=(time_since_boot >= 0 & time_since_boot < 2) | (vbatt > 5) | in_shutdown -#MAIN_RELAY_LOGIC=(!in_mr_bench) & ((vbatt > 5) | in_shutdown) -MAIN_RELAY_LOGIC=(!in_mr_bench) & (vbatt > 5) - # could be used for simple variable intake geometry setups or warning light or starter block RPM_ABOVE_USER_SETTING_1=rpm > fsio_setting(1) diff --git a/firmware/gen_live_documentation.sh b/firmware/gen_live_documentation.sh index 37ac10e41d..f92dcc616c 100755 --- a/firmware/gen_live_documentation.sh +++ b/firmware/gen_live_documentation.sh @@ -11,6 +11,9 @@ bash gen_live_documentation_one_file.sh ac_control AcControl.java controllers/ac bash gen_live_documentation_one_file.sh fuel_pump FuelPump.java controllers/actuators [ $? -eq 0 ] || { echo "ERROR generating"; exit 1; } +bash gen_live_documentation_one_file.sh main_relay MainRelay.java controllers/actuators +[ $? -eq 0 ] || { echo "ERROR generating"; exit 1; } + bash gen_live_documentation_one_file.sh pid_state PidState.java util/math [ $? -eq 0 ] || { echo "ERROR generating"; exit 1; } diff --git a/java_console/io/src/main/java/com/rusefi/enums/live_data_e.java b/java_console/io/src/main/java/com/rusefi/enums/live_data_e.java index b87d877a8e..b5a6543df1 100644 --- a/java_console/io/src/main/java/com/rusefi/enums/live_data_e.java +++ b/java_console/io/src/main/java/com/rusefi/enums/live_data_e.java @@ -16,4 +16,5 @@ public enum live_data_e { LDS_FUEL_PUMP, LDS_IDLE, LDS_TPS_ACCEL, + LDS_MAIN_RELAY, } diff --git a/java_console/models/src/main/java/com/rusefi/config/generated/MainRelay.java b/java_console/models/src/main/java/com/rusefi/config/generated/MainRelay.java new file mode 100644 index 0000000000..81cd71280c --- /dev/null +++ b/java_console/models/src/main/java/com/rusefi/config/generated/MainRelay.java @@ -0,0 +1,75 @@ +package com.rusefi.config.generated; + +// this file was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/actuators/main_relay.txt Fri Nov 19 13:01:22 PST 2021 + +// by class com.rusefi.output.FileJavaFieldsConsumer +import com.rusefi.config.*; + +public class MainRelay { + public static final Field ISBENCHTEST = Field.create("ISBENCHTEST", 0, FieldType.BIT, 0); + public static final Field HASIGNITIONVOLTAGE = Field.create("HASIGNITIONVOLTAGE", 0, FieldType.BIT, 1); + public static final Field MAINRELAYSTATE = Field.create("MAINRELAYSTATE", 0, FieldType.BIT, 2); + public static final Field UNUSEDBIT_3_3 = Field.create("UNUSEDBIT_3_3", 0, FieldType.BIT, 3); + public static final Field UNUSEDBIT_3_4 = Field.create("UNUSEDBIT_3_4", 0, FieldType.BIT, 4); + public static final Field UNUSEDBIT_3_5 = Field.create("UNUSEDBIT_3_5", 0, FieldType.BIT, 5); + public static final Field UNUSEDBIT_3_6 = Field.create("UNUSEDBIT_3_6", 0, FieldType.BIT, 6); + public static final Field UNUSEDBIT_3_7 = Field.create("UNUSEDBIT_3_7", 0, FieldType.BIT, 7); + public static final Field UNUSEDBIT_3_8 = Field.create("UNUSEDBIT_3_8", 0, FieldType.BIT, 8); + public static final Field UNUSEDBIT_3_9 = Field.create("UNUSEDBIT_3_9", 0, FieldType.BIT, 9); + public static final Field UNUSEDBIT_3_10 = Field.create("UNUSEDBIT_3_10", 0, FieldType.BIT, 10); + public static final Field UNUSEDBIT_3_11 = Field.create("UNUSEDBIT_3_11", 0, FieldType.BIT, 11); + public static final Field UNUSEDBIT_3_12 = Field.create("UNUSEDBIT_3_12", 0, FieldType.BIT, 12); + public static final Field UNUSEDBIT_3_13 = Field.create("UNUSEDBIT_3_13", 0, FieldType.BIT, 13); + public static final Field UNUSEDBIT_3_14 = Field.create("UNUSEDBIT_3_14", 0, FieldType.BIT, 14); + public static final Field UNUSEDBIT_3_15 = Field.create("UNUSEDBIT_3_15", 0, FieldType.BIT, 15); + public static final Field UNUSEDBIT_3_16 = Field.create("UNUSEDBIT_3_16", 0, FieldType.BIT, 16); + public static final Field UNUSEDBIT_3_17 = Field.create("UNUSEDBIT_3_17", 0, FieldType.BIT, 17); + public static final Field UNUSEDBIT_3_18 = Field.create("UNUSEDBIT_3_18", 0, FieldType.BIT, 18); + public static final Field UNUSEDBIT_3_19 = Field.create("UNUSEDBIT_3_19", 0, FieldType.BIT, 19); + public static final Field UNUSEDBIT_3_20 = Field.create("UNUSEDBIT_3_20", 0, FieldType.BIT, 20); + public static final Field UNUSEDBIT_3_21 = Field.create("UNUSEDBIT_3_21", 0, FieldType.BIT, 21); + public static final Field UNUSEDBIT_3_22 = Field.create("UNUSEDBIT_3_22", 0, FieldType.BIT, 22); + public static final Field UNUSEDBIT_3_23 = Field.create("UNUSEDBIT_3_23", 0, FieldType.BIT, 23); + public static final Field UNUSEDBIT_3_24 = Field.create("UNUSEDBIT_3_24", 0, FieldType.BIT, 24); + public static final Field UNUSEDBIT_3_25 = Field.create("UNUSEDBIT_3_25", 0, FieldType.BIT, 25); + public static final Field UNUSEDBIT_3_26 = Field.create("UNUSEDBIT_3_26", 0, FieldType.BIT, 26); + public static final Field UNUSEDBIT_3_27 = Field.create("UNUSEDBIT_3_27", 0, FieldType.BIT, 27); + public static final Field UNUSEDBIT_3_28 = Field.create("UNUSEDBIT_3_28", 0, FieldType.BIT, 28); + public static final Field UNUSEDBIT_3_29 = Field.create("UNUSEDBIT_3_29", 0, FieldType.BIT, 29); + public static final Field UNUSEDBIT_3_30 = Field.create("UNUSEDBIT_3_30", 0, FieldType.BIT, 30); + public static final Field UNUSEDBIT_3_31 = Field.create("UNUSEDBIT_3_31", 0, FieldType.BIT, 31); + public static final Field[] VALUES = { + ISBENCHTEST, + HASIGNITIONVOLTAGE, + MAINRELAYSTATE, + UNUSEDBIT_3_3, + UNUSEDBIT_3_4, + UNUSEDBIT_3_5, + UNUSEDBIT_3_6, + UNUSEDBIT_3_7, + UNUSEDBIT_3_8, + UNUSEDBIT_3_9, + UNUSEDBIT_3_10, + UNUSEDBIT_3_11, + UNUSEDBIT_3_12, + UNUSEDBIT_3_13, + UNUSEDBIT_3_14, + UNUSEDBIT_3_15, + UNUSEDBIT_3_16, + UNUSEDBIT_3_17, + UNUSEDBIT_3_18, + UNUSEDBIT_3_19, + UNUSEDBIT_3_20, + UNUSEDBIT_3_21, + UNUSEDBIT_3_22, + UNUSEDBIT_3_23, + UNUSEDBIT_3_24, + UNUSEDBIT_3_25, + UNUSEDBIT_3_26, + UNUSEDBIT_3_27, + UNUSEDBIT_3_28, + UNUSEDBIT_3_29, + UNUSEDBIT_3_30, + UNUSEDBIT_3_31, + }; +} diff --git a/java_console/ui/src/main/java/com/rusefi/livedata/LiveDataView.java b/java_console/ui/src/main/java/com/rusefi/livedata/LiveDataView.java index 5f3dfd1d58..5bf66764e3 100644 --- a/java_console/ui/src/main/java/com/rusefi/livedata/LiveDataView.java +++ b/java_console/ui/src/main/java/com/rusefi/livedata/LiveDataView.java @@ -7,6 +7,7 @@ import com.rusefi.enums.live_data_e; public enum LiveDataView { AC_CONTROL(live_data_e.LDS_AC_CONTROL, AcControl.VALUES, "ac_control.cpp"), FUEL_PUMP(live_data_e.LDS_FUEL_PUMP, FuelPump.VALUES, "fuel_pump.cpp"), + MAIN_RELAY(live_data_e.LDS_MAIN_RELAY, MainRelay.VALUES, "main_relay.cpp"), TPS_ACCEL(live_data_e.LDS_TPS_ACCEL, TpsAccelState.VALUES, "accel_enrichment.cpp"), ; diff --git a/unit_tests/efifeatures.h b/unit_tests/efifeatures.h index d2c30fb3b5..05ea857c2f 100644 --- a/unit_tests/efifeatures.h +++ b/unit_tests/efifeatures.h @@ -74,3 +74,5 @@ #define EFI_LUA TRUE #define EFI_HPFP TRUE + +#define EFI_MAIN_RELAY_CONTROL TRUE diff --git a/unit_tests/tests/test_logic_expression.cpp b/unit_tests/tests/test_logic_expression.cpp index 76608a6ec1..e8cc87bbf0 100644 --- a/unit_tests/tests/test_logic_expression.cpp +++ b/unit_tests/tests/test_logic_expression.cpp @@ -24,8 +24,6 @@ FsioResult getEngineValue(le_action_e action) { return engine->fsioState.mockRpm; case LE_METHOD_CRANKING_RPM: return engine->fsioState.mockCrankingRpm; - case LE_METHOD_TIME_SINCE_BOOT: - return engine->fsioState.mockTimeSinceBoot; case LE_METHOD_VBATT: return 12; case LE_METHOD_AC_TOGGLE: diff --git a/unit_tests/tests/test_main_relay.cpp b/unit_tests/tests/test_main_relay.cpp new file mode 100644 index 0000000000..542c43f69d --- /dev/null +++ b/unit_tests/tests/test_main_relay.cpp @@ -0,0 +1,19 @@ +#include "pch.h" + +#include "main_relay.h" + +TEST(MainRelay, mr) { + EngineTestHelper eth(TEST_ENGINE); + + MainRelayController dut; + + // Low battery voltage, MR is off + Sensor::setMockValue(SensorType::BatteryVoltage, 1); + dut.onSlowCallback(); + EXPECT_EQ(enginePins.mainRelay.getLogicValue(), false); + + // Ignition is now on, MR is on + Sensor::setMockValue(SensorType::BatteryVoltage, 12); + dut.onSlowCallback(); + EXPECT_EQ(enginePins.mainRelay.getLogicValue(), true); +} diff --git a/unit_tests/tests/tests.mk b/unit_tests/tests/tests.mk index abebaa04f3..dfe9a7ba81 100644 --- a/unit_tests/tests/tests.mk +++ b/unit_tests/tests/tests.mk @@ -46,6 +46,7 @@ TESTS_SRC_CPP = \ tests/test_etb.cpp \ tests/test_dc_motor.cpp \ tests/test_fan_control.cpp \ + tests/test_main_relay.cpp \ tests/test_vvt.cpp \ tests/test_launch.cpp \ tests/test_fuel_map.cpp \