refactoring

This commit is contained in:
rusefi 2017-05-25 08:49:04 -04:00
parent b2203e22cb
commit 55010eda5b
3 changed files with 19 additions and 13 deletions

View File

@ -61,16 +61,6 @@ void idleDebug(const char *msg, percent_t value) {
scheduleMsg(logger, "idle debug: %s%f", msg, value);
}
static void showPidSettings(const char*msg, pid_s *pid) {
scheduleMsg(logger, "%s o=%f P=%.5f I=%.5f D=%.5f dT=%d",
msg,
pid->offset,
pid->pFactor,
pid->iFactor,
pid->dFactor,
engineConfiguration->idleDT);
}
static void showIdleInfo(void) {
const char * idleModeStr = getIdle_mode_e(engineConfiguration->idleMode);
@ -91,7 +81,7 @@ static void showIdleInfo(void) {
if (engineConfiguration->idleMode == IM_AUTO) {
showPidSettings("idle", &engineConfiguration->idleRpmPid);
idlePid.showPidStatus(logger, "idle", engineConfiguration->idleDT);
}
}
@ -172,7 +162,7 @@ static float autoIdle(float cltCorrection) {
adjustedTargetRpm = engineConfiguration->targetIdleRpm * cltCorrection;
percent_t newValue = idlePid.getValue(adjustedTargetRpm, getRpmE(engine));
percent_t newValue = idlePid.getValue(adjustedTargetRpm, getRpmE(engine), engineConfiguration->idleDT);
return newValue;
}
@ -188,6 +178,7 @@ static msg_t ivThread(int param) {
*/
while (true) {
// todo: in auto mode, speel should be taken from idleDTe
chThdSleepMilliseconds(boardConfiguration->idleThreadPeriod);
// this value is not used yet
@ -236,7 +227,7 @@ static msg_t ivThread(int param) {
}
if (engineConfiguration->isVerboseIAC && engineConfiguration->idleMode == IM_AUTO) {
showPidSettings("idle", &engineConfiguration->idleRpmPid);
idlePid.showPidStatus(logger, "idle",engineConfiguration->idleDT);
scheduleMsg(logger, "rpm=%d/%d position=%f iTerm=%.5f dTerm=%.5f",
getRpmE(engine),
adjustedTargetRpm,

View File

@ -113,3 +113,14 @@ void Pid::postState(TunerStudioOutputChannels *tsOutputChannels) {
tsOutputChannels->debugFloatField6 = dTerm;
}
#endif
void Pid::showPidStatus(Logging *logging, const char*msg, int dTime) {
// todo: dTime should be taken from pid_s
scheduleMsg(logging, "%s o=%f P=%.5f I=%.5f D=%.5f dT=%d",
msg,
pid->offset,
pid->pFactor,
pid->iFactor,
pid->dFactor,
dTime);
}

View File

@ -10,6 +10,8 @@
#include "global.h"
#include "engine_configuration_generated_structures.h"
#include "datalogging.h"
#if EFI_PROD_CODE || EFI_SIMULATOR
#include "tunerstudio_configuration.h"
#endif
@ -23,6 +25,7 @@ public:
bool isSame(pid_s *pid);
float getValue(float target, float input);
// todo: dTime should be taken from pid_s
float getValue(float target, float input, float dTime);
void updateFactors(float pFactor, float iFactor, float dFactor);
void reset(void);
@ -39,6 +42,7 @@ public:
float maxResult;
float iTerm;
float dTerm; // we are remembering this only for debugging purposes
void showPidStatus(Logging *logging, const char*msg, int dTime);
private:
pid_s *pid;