rusefi-full/win32_functional_tests/simulator/rusEfiFunctionalTest.cpp

145 lines
3.1 KiB
C++
Raw Normal View History

2014-08-29 07:52:33 -07:00
/**
* @file rusEfiFunctionalTest.cpp
*
* @date Mar 1, 2014
* @author Andrey Belomutskiy, (c) 2012-2013
*/
#include "global.h"
#include "boards.h"
#include "rusEfiFunctionalTest.h"
#include "console_io.h"
#include "eficonsole.h"
#include "engine_configuration.h"
#include "ec2.h"
#include "rusefi_enums.h"
#include "pwm_generator_logic.h"
#include "trigger_central.h"
#include "datalogging.h"
#include "algo.h"
#include "rpm_calculator.h"
#include "wave_chart.h"
#include "status_loop.h"
#include "trigger_emulator_algo.h"
#include "main_trigger_callback.h"
#include "allsensors.h"
#include "analog_chart.h"
#include "injector_central.h"
#include "engine.h"
#include "tunerstudio.h"
#include "trigger_emulator.h"
Engine engine;
extern WaveChart waveChart;
persistent_config_container_s persistentState;
static engine_configuration2_s ec2;
engine_configuration_s * engineConfiguration = &persistentState.persistentConfiguration.engineConfiguration;
board_configuration_s *boardConfiguration = &persistentState.persistentConfiguration.engineConfiguration.bc;
engine_configuration2_s *engineConfiguration2 = &ec2;
static configuration_s cfg = {engineConfiguration, engineConfiguration2};
configuration_s * configuration = &cfg;
void setOutputPinValue(io_pin_e pin, int logicValue) {
}
int isInjectionEnabled(void) {
return TRUE;
}
// todo: move this to "idle_controller.h"
extern "C" {
void idleDebug(char *msg, int value);
}
int getRemainingStack(Thread *otp) {
return 99999;
}
void idleDebug(char *msg, int value) {
}
float getMap(void) {
return getRawMap();
}
void rusEfiFunctionalTest(void) {
initializeConsole();
initFakeBoard();
initStatusLoop();
initDataStructures(engineConfiguration);
engine.engineConfiguration = engineConfiguration;
2014-09-12 18:05:24 -07:00
resetConfigurationExt(NULL, FORD_ASPIRE_1996, engineConfiguration, engineConfiguration2);
2014-08-29 07:52:33 -07:00
initThermistors();
initAlgo(engineConfiguration);
initRpmCalculator();
initAnalogChart();
2014-09-25 21:05:11 -07:00
initTriggerEmulator();
2014-08-29 07:52:33 -07:00
initMainEventListener(&engine, engineConfiguration2);
2014-09-08 15:02:52 -07:00
initTriggerCentral(&engine);
2014-08-29 07:52:33 -07:00
startStatusThreads();
startTunerStudioConnectivity();
}
void printPendingMessages(void) {
updateDevConsoleState();
2014-09-11 08:03:38 -07:00
waveChart.publishChartIfFull();
2014-08-29 07:52:33 -07:00
}
int isSerialOverTcpReady;
bool isConsoleReady(void) {
return isSerialOverTcpReady;
}
bool_t hasFirmwareError(void) {
return FALSE;
}
void onFatalError(const char *msg, const char * file, int line) {
printf("onFatalError %s %s%d", msg, file, line);
exit(-1);
}
static time_t timeOfPreviousWarning = -10;
// todo: re-use primary firmware implementation?
int warning(obd_code_e code, const char *fmt, ...) {
int now = currentTimeMillis() / 1000;
if (absI(now - timeOfPreviousWarning) < 10)
return TRUE; // we just had another warning, let's not spam
timeOfPreviousWarning = now;
printf("Warning: %s\r\n", fmt);
return FALSE;
}
void firmwareError(const char *fmt, ...) {
printf("firmwareError [%s]", fmt);
exit(-1);
}
SerialDriver * getConsoleChannel(void) {
return (SerialDriver *)EFI_CONSOLE_UART_DEVICE;
}
void chDbgPanic3(const char *msg, const char * file, int line) {
onFatalError(msg, file, line);
}