Delayed A/C compressor switch #922

unit tests skeleton
This commit is contained in:
rusefi 2019-09-12 07:31:13 -04:00
parent 21cbf1cf91
commit dfc0743e9a
4 changed files with 26 additions and 9 deletions

View File

@ -29,11 +29,6 @@
*/
#define NO_PWM 0
// see useFSIO12ForIdleOffset
#define MAGIC_OFFSET_FOR_IDLE_OFFSET 12
// see useFSIO13ForIdleMinValue
#define MAGIC_OFFSET_FOR_IDLE_MIN_VALUE 13
// see useFSIO15ForIdleRpmAdjustment
#define MAGIC_OFFSET_FOR_IDLE_TARGET_RPM 14
// see useFSIO16ForTimingAdjustment
@ -612,7 +607,7 @@ static void setFsioSetting(float humanIndexF, float value) {
#endif
}
static void setFsioExpression(const char *indexStr, const char *quotedLine) {
void setFsioExpression(const char *indexStr, const char *quotedLine) {
#if EFI_PROD_CODE || EFI_SIMULATOR
int index = atoi(indexStr) - 1;
if (index < 0 || index >= FSIO_COMMAND_COUNT) {

View File

@ -14,6 +14,11 @@
#include "table_helper.h"
#include "system_fsio.h"
// see useFSIO12ForIdleOffset
#define MAGIC_OFFSET_FOR_IDLE_OFFSET 12
// see useFSIO13ForIdleMinValue
#define MAGIC_OFFSET_FOR_IDLE_MIN_VALUE 13
typedef Map3D<FSIO_TABLE_8, FSIO_TABLE_8, float, float> fsio8_Map3D_f32t;
typedef Map3D<FSIO_TABLE_8, FSIO_TABLE_8, uint8_t, float> fsio8_Map3D_u8t;
@ -30,6 +35,7 @@ void setFsioExt(int index, brain_pin_e pin, const char * exp, int pwmFrequency D
void initFsioImpl(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX);
void runFsio(DECLARE_ENGINE_PARAMETER_SIGNATURE);
void setFsioExpression(const char *indexStr, const char *quotedLine);
float getFsioOutputValue(int index DECLARE_ENGINE_PARAMETER_SUFFIX);
void applyFsioConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE);
void onConfigurationChangeFsioCallback(engine_configuration_s *previousConfiguration DECLARE_ENGINE_PARAMETER_SUFFIX);

View File

@ -9,6 +9,18 @@
#include "advance_map.h"
#include "tps.h"
#include "pid.h"
#include "fsio_impl.h"
TEST(idle, fsioPidParameters) {
WITH_ENGINE_TEST_HELPER(TEST_ENGINE);
// todo finish this unit test!
engineConfiguration->useFSIO12ForIdleOffset = true;
setFsioExpression(MAGIC_OFFSET_FOR_IDLE_OFFSET, "\"ac_on_switch cfg_idleRpmPid_offset cfg_idleRpmPid2_offset if");
engineConfiguration->useFSIO13ForIdleMinValue = true;
setFsioExpression(MAGIC_OFFSET_FOR_IDLE_MIN_VALUE, "\"ac_on_switch cfg_idleRpmPid_minValue cfg_idleRpmPid2_minValue if");
}
TEST(idle, pid) {
print("******************************************* testPidController\r\n");

View File

@ -107,11 +107,15 @@ static void testExpression2(float selfValue, const char *line, float expected) {
testExpression2(selfValue, line, expected, engine);
}
static void testExpression(const char *line, float expected) {
testExpression2(0, line, expected);
static void testExpression(const char *line, float expectedValue) {
testExpression2(0, line, expectedValue);
}
TEST(misc, testLogicExpressions) {
TEST(fsio, testIfFunction) {
testExpression("1 22 33 if", 22);
}
TEST(fsio, testLogicExpressions) {
printf("*************************************************** testLogicExpressions\r\n");
testParsing();