generate triggers.txt from parametric test (#2186)
* add new test * comment * remove old * main cleanup Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
This commit is contained in:
parent
20a967edf1
commit
f4dcf0f397
|
@ -550,77 +550,6 @@ static void triggerShapeInfo(void) {
|
|||
#endif
|
||||
}
|
||||
|
||||
#if EFI_UNIT_TEST
|
||||
#include <stdlib.h>
|
||||
|
||||
extern trigger_type_e focusOnTrigger;
|
||||
|
||||
/**
|
||||
* This is used to generate trigger info which is later used by TriggerImage java class
|
||||
* to generate images for documentation
|
||||
*/
|
||||
extern bool printTriggerDebug;
|
||||
void exportAllTriggers() {
|
||||
|
||||
FILE * fp = fopen (TRIGGERS_FILE_NAME, "w+");
|
||||
|
||||
fprintf(fp, "# Generated by rusEfi unit test suite\n");
|
||||
fprintf(fp, "# This file is used by TriggerImage tool\n");
|
||||
fprintf(fp, "# See 'gen_trigger_images.bat'\n");
|
||||
|
||||
//printTriggerDebug = true;
|
||||
for (int triggerId = 1; triggerId < TT_UNUSED; triggerId++) {
|
||||
trigger_type_e tt = (trigger_type_e) triggerId;
|
||||
|
||||
if (focusOnTrigger != TT_UNUSED && tt != focusOnTrigger) {
|
||||
continue;
|
||||
}
|
||||
|
||||
printf("Exporting %s\r\n", getTrigger_type_e(tt));
|
||||
|
||||
persistent_config_s pc;
|
||||
Engine e(&pc);
|
||||
Engine *engine = &e;
|
||||
persistent_config_s *config = &pc;
|
||||
engine_configuration_s *engineConfiguration = &pc.engineConfiguration;
|
||||
|
||||
|
||||
engineConfiguration->trigger.type = tt;
|
||||
engineConfiguration->ambiguousOperationMode = FOUR_STROKE_CAM_SENSOR;
|
||||
|
||||
TriggerWaveform *shape = &engine->triggerCentral.triggerShape;
|
||||
TriggerFormDetails *triggerFormDetails = &engine->triggerCentral.triggerFormDetails;
|
||||
engine->initializeTriggerWaveform(NULL PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
|
||||
if (shape->shapeDefinitionError) {
|
||||
printf("Trigger shapeDefinitionError %d\r\n", triggerId);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
fprintf(fp, "TRIGGERTYPE %d %d %s %.2f\n", triggerId, shape->getLength(), getTrigger_type_e(tt), shape->tdcPosition);
|
||||
|
||||
fprintf(fp, "# duty %.2f %.2f\n", shape->expectedDutyCycle[0], shape->expectedDutyCycle[1]);
|
||||
|
||||
for (size_t i = 0; i < shape->getLength(); i++) {
|
||||
|
||||
int triggerDefinitionCoordinate = (shape->getTriggerWaveformSynchPointIndex() + i) % shape->getSize();
|
||||
|
||||
|
||||
fprintf(fp, "event %d %d %d %.2f\n",
|
||||
i,
|
||||
shape->triggerSignalIndeces[triggerDefinitionCoordinate],
|
||||
shape->triggerSignalStates[triggerDefinitionCoordinate],
|
||||
triggerFormDetails->eventAngles[i]);
|
||||
}
|
||||
|
||||
}
|
||||
fclose(fp);
|
||||
printf("All triggers exported to %s\n", TRIGGERS_FILE_NAME);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if EFI_PROD_CODE
|
||||
extern PwmConfig triggerSignal;
|
||||
#endif /* #if EFI_PROD_CODE */
|
||||
|
|
|
@ -82,11 +82,6 @@ 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);
|
||||
/**
|
||||
* 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();
|
||||
|
|
|
@ -31,25 +31,9 @@ efitick_t getTimeNowNt(void) {
|
|||
|
||||
LoggingWithStorage sharedLogger("main");
|
||||
|
||||
extern bool printTriggerDebug;
|
||||
extern bool printTriggerTrace;
|
||||
bool verboseMode = false;
|
||||
|
||||
trigger_type_e focusOnTrigger = TT_UNUSED;
|
||||
|
||||
GTEST_API_ int main(int argc, char **argv) {
|
||||
if (focusOnTrigger != TT_UNUSED) {
|
||||
printTriggerDebug = true;
|
||||
printTriggerTrace = true;
|
||||
}
|
||||
|
||||
// resizeMap();
|
||||
printf("Success 20201203\r\n");
|
||||
exportAllTriggers();
|
||||
if (focusOnTrigger != TT_UNUSED) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
// uncomment if you only want to run selected tests
|
||||
//::testing::GTEST_FLAG(filter) = "*testFasterEngineSpinningUp*";
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
#include "engine.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
||||
struct TriggerExportHelper
|
||||
{
|
||||
FILE* fp;
|
||||
|
||||
TriggerExportHelper() {
|
||||
fp = fopen (TRIGGERS_FILE_NAME, "w+");
|
||||
|
||||
fprintf(fp, "# Generated by rusEfi unit test suite\n");
|
||||
fprintf(fp, "# This file is used by TriggerImage tool\n");
|
||||
fprintf(fp, "# See 'gen_trigger_images.bat'\n");
|
||||
}
|
||||
|
||||
~TriggerExportHelper() {
|
||||
fclose(fp);
|
||||
printf("All triggers exported to %s\n", TRIGGERS_FILE_NAME);
|
||||
}
|
||||
};
|
||||
|
||||
static TriggerExportHelper exportHelper;
|
||||
|
||||
class AllTriggersFixture : public ::testing::TestWithParam<trigger_type_e> {
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
Triggers,
|
||||
AllTriggersFixture,
|
||||
// Test all triggers from the first valid trigger thru the last
|
||||
// (Skip index 0, that's custom toothed wheel which is covered by others)
|
||||
::testing::Range((trigger_type_e)1, TT_UNUSED)
|
||||
);
|
||||
|
||||
extern bool printTriggerDebug;
|
||||
extern bool printTriggerTrace;
|
||||
|
||||
TEST_P(AllTriggersFixture, TestTrigger) {
|
||||
// handy debugging options
|
||||
//printTriggerDebug = true;
|
||||
//printTriggerTrace = true;
|
||||
|
||||
auto tt = GetParam();
|
||||
auto fp = exportHelper.fp;
|
||||
|
||||
printf("Exporting %s\r\n", getTrigger_type_e(tt));
|
||||
|
||||
persistent_config_s pc;
|
||||
Engine e(&pc);
|
||||
Engine *engine = &e;
|
||||
persistent_config_s *config = &pc;
|
||||
engine_configuration_s *engineConfiguration = &pc.engineConfiguration;
|
||||
|
||||
engineConfiguration->trigger.type = tt;
|
||||
engineConfiguration->ambiguousOperationMode = FOUR_STROKE_CAM_SENSOR;
|
||||
|
||||
TriggerWaveform *shape = &engine->triggerCentral.triggerShape;
|
||||
TriggerFormDetails *triggerFormDetails = &engine->triggerCentral.triggerFormDetails;
|
||||
engine->initializeTriggerWaveform(NULL PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
|
||||
ASSERT_FALSE(shape->shapeDefinitionError) << "Trigger shapeDefinitionError";
|
||||
|
||||
fprintf(fp, "TRIGGERTYPE %d %d %s %.2f\n", tt, shape->getLength(), getTrigger_type_e(tt), shape->tdcPosition);
|
||||
|
||||
fprintf(fp, "# duty %.2f %.2f\n", shape->expectedDutyCycle[0], shape->expectedDutyCycle[1]);
|
||||
|
||||
for (size_t i = 0; i < shape->getLength(); i++) {
|
||||
int triggerDefinitionCoordinate = (shape->getTriggerWaveformSynchPointIndex() + i) % shape->getSize();
|
||||
|
||||
fprintf(fp, "event %d %d %d %.2f\n",
|
||||
i,
|
||||
shape->triggerSignalIndeces[triggerDefinitionCoordinate],
|
||||
shape->triggerSignalStates[triggerDefinitionCoordinate],
|
||||
triggerFormDetails->eventAngles[i]);
|
||||
}
|
||||
}
|
|
@ -65,4 +65,5 @@ TESTS_SRC_CPP = \
|
|||
tests/test_dynoview.cpp \
|
||||
tests/test_gpio.cpp \
|
||||
tests/test_limp.cpp \
|
||||
tests/test_all_triggers.cpp \
|
||||
|
||||
|
|
Loading…
Reference in New Issue