auto-sync
This commit is contained in:
parent
0b4118a659
commit
e6213d5454
|
@ -164,6 +164,7 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, efitime_t no
|
|||
;
|
||||
if (TRIGGER_SHAPE(gapBothDirections) && considerEventForGap()) {
|
||||
isFirstEvent = false;
|
||||
thirdPreviousDuration = durationBeforePrevious;
|
||||
durationBeforePrevious = toothed_previous_duration;
|
||||
toothed_previous_duration = currentDuration;
|
||||
toothed_previous_time = nowNt;
|
||||
|
@ -198,10 +199,14 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, efitime_t no
|
|||
/**
|
||||
* Here I prefer to have two multiplications instead of one division, that's a micro-optimization
|
||||
*/
|
||||
isSynchronizationPoint = currentDuration > toothed_previous_duration * TRIGGER_SHAPE(syncRatioFrom)
|
||||
isSynchronizationPoint =
|
||||
currentDuration > toothed_previous_duration * TRIGGER_SHAPE(syncRatioFrom)
|
||||
&& currentDuration < toothed_previous_duration * TRIGGER_SHAPE(syncRatioTo)
|
||||
&& toothed_previous_duration > durationBeforePrevious * TRIGGER_SHAPE(secondSyncRatioFrom)
|
||||
&& toothed_previous_duration < durationBeforePrevious * TRIGGER_SHAPE(secondSyncRatioTo)
|
||||
// this is getting a little out of hand, any ideas?
|
||||
&& durationBeforePrevious > thirdPreviousDuration * TRIGGER_SHAPE(thirdSyncRatioFrom)
|
||||
&& durationBeforePrevious < thirdPreviousDuration * TRIGGER_SHAPE(thirdSyncRatioTo)
|
||||
;
|
||||
|
||||
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
||||
|
@ -211,11 +216,12 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, efitime_t no
|
|||
#endif /* EFI_PROD_CODE */
|
||||
float gap = 1.0 * currentDuration / toothed_previous_duration;
|
||||
float prevGap = 1.0 * toothed_previous_duration / durationBeforePrevious;
|
||||
float gap3 = 1.0 * durationBeforePrevious / thirdPreviousDuration;
|
||||
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
||||
scheduleMsg(logger, "gap=%f/%f @ %d while expected %f/%f and %f/%f error=%d", gap, prevGap, currentCycle.current_index, TRIGGER_SHAPE(syncRatioFrom), TRIGGER_SHAPE(syncRatioTo), TRIGGER_SHAPE(secondSyncRatioFrom), TRIGGER_SHAPE(secondSyncRatioTo), someSortOfTriggerError);
|
||||
scheduleMsg(logger, "gap=%f/%f @ %d while expected %f/%f/%f and %f/%f error=%d", gap, prevGap, gap3, currentCycle.current_index, TRIGGER_SHAPE(syncRatioFrom), TRIGGER_SHAPE(syncRatioTo), TRIGGER_SHAPE(secondSyncRatioFrom), TRIGGER_SHAPE(secondSyncRatioTo), someSortOfTriggerError);
|
||||
#else
|
||||
actualSynchGap = gap;
|
||||
print("current gap %f/%f c=%d prev=%d\r\n", gap, prevGap, currentDuration, toothed_previous_duration);
|
||||
print("current gap %f/%f/%f c=%d prev=%d\r\n", gap, prevGap, gap3, currentDuration, toothed_previous_duration);
|
||||
#endif /* EFI_PROD_CODE */
|
||||
}
|
||||
|
||||
|
@ -282,6 +288,7 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, efitime_t no
|
|||
;
|
||||
}
|
||||
|
||||
thirdPreviousDuration = durationBeforePrevious;
|
||||
durationBeforePrevious = toothed_previous_duration;
|
||||
toothed_previous_duration = currentDuration;
|
||||
toothed_previous_time = nowNt;
|
||||
|
|
|
@ -62,8 +62,10 @@ public:
|
|||
*/
|
||||
bool shaft_is_synchronized;
|
||||
|
||||
uint32_t durationBeforePrevious;
|
||||
uint32_t toothed_previous_duration;
|
||||
uint32_t toothed_previous_duration; // todo: unify Camel_notation, what a mess :(
|
||||
uint32_t durationBeforePrevious; // this one is before 'toothed_previous_duration'
|
||||
uint32_t thirdPreviousDuration; // this one is before durationBeforePrevious, todo: better field names?
|
||||
|
||||
/**
|
||||
* this could be a local variable, but it's better for debugging to have it as a field
|
||||
*/
|
||||
|
|
|
@ -12,8 +12,9 @@ void initializeRoverK(TriggerShape *s) {
|
|||
|
||||
float tooth = 20;
|
||||
|
||||
// s->setTriggerSynchronizationGap(2.0);
|
||||
s->isSynchronizationNeeded = false;
|
||||
s->setTriggerSynchronizationGap(2.0);
|
||||
s->setThirdTriggerSynchronizationGap(2);
|
||||
s->isSynchronizationNeeded = true;
|
||||
|
||||
float base = 0;
|
||||
|
||||
|
|
|
@ -49,6 +49,8 @@ TriggerShape::TriggerShape() :
|
|||
syncRatioFrom = syncRatioTo = 0;
|
||||
secondSyncRatioFrom = 0.000001;
|
||||
secondSyncRatioTo = 100000;
|
||||
thirdSyncRatioFrom = 0.000001;
|
||||
thirdSyncRatioTo = 100000;
|
||||
memset(eventAngles, 0, sizeof(eventAngles));
|
||||
memset(frontOnlyIndexes, 0, sizeof(frontOnlyIndexes));
|
||||
memset(isFrontEvent, 0, sizeof(isFrontEvent));
|
||||
|
@ -161,6 +163,7 @@ void TriggerState::reset() {
|
|||
toothed_previous_time = 0;
|
||||
toothed_previous_duration = 0;
|
||||
durationBeforePrevious = 0;
|
||||
thirdPreviousDuration = 0;
|
||||
|
||||
totalRevolutionCounter = 0;
|
||||
totalTriggerErrorCounter = 0;
|
||||
|
@ -407,8 +410,8 @@ void TriggerShape::setTriggerSynchronizationGap2(float syncRatioFrom, float sync
|
|||
this->syncRatioTo = syncRatioTo;
|
||||
}
|
||||
|
||||
void TriggerShape::setTriggerSynchronizationGap(float synchRatio) {
|
||||
setTriggerSynchronizationGap2(synchRatio * 0.75f, synchRatio * 1.25f);
|
||||
void TriggerShape::setTriggerSynchronizationGap(float syncRatio) {
|
||||
setTriggerSynchronizationGap2(syncRatio * 0.75f, syncRatio * 1.25f);
|
||||
}
|
||||
|
||||
void TriggerShape::setSecondTriggerSynchronizationGap2(float syncRatioFrom, float syncRatioTo) {
|
||||
|
@ -417,8 +420,18 @@ void TriggerShape::setSecondTriggerSynchronizationGap2(float syncRatioFrom, floa
|
|||
this->secondSyncRatioTo = syncRatioTo;
|
||||
}
|
||||
|
||||
void TriggerShape::setSecondTriggerSynchronizationGap(float synchRatio) {
|
||||
setSecondTriggerSynchronizationGap2(synchRatio * 0.75f, synchRatio * 1.25f);
|
||||
void TriggerShape::setThirdTriggerSynchronizationGap(float syncRatio) {
|
||||
setThirdTriggerSynchronizationGap2(syncRatio * 0.75f, syncRatio * 1.25f);
|
||||
}
|
||||
|
||||
void TriggerShape::setThirdTriggerSynchronizationGap2(float syncRatioFrom, float syncRatioTo) {
|
||||
isSynchronizationNeeded = true;
|
||||
this->thirdSyncRatioFrom = syncRatioFrom;
|
||||
this->thirdSyncRatioTo = syncRatioTo;
|
||||
}
|
||||
|
||||
void TriggerShape::setSecondTriggerSynchronizationGap(float syncRatio) {
|
||||
setSecondTriggerSynchronizationGap2(syncRatio * 0.75f, syncRatio * 1.25f);
|
||||
}
|
||||
|
||||
#define S24 (720.0f / 24 / 2)
|
||||
|
|
|
@ -65,6 +65,10 @@ public:
|
|||
float secondSyncRatioFrom;
|
||||
float secondSyncRatioTo;
|
||||
|
||||
float thirdSyncRatioFrom;
|
||||
float thirdSyncRatioTo;
|
||||
|
||||
|
||||
/**
|
||||
* Trigger indexes within trigger cycle are counted from synchronization point, and all
|
||||
* engine processes are defined in angles from TDC.
|
||||
|
@ -134,10 +138,12 @@ public:
|
|||
operation_mode_e getOperationMode();
|
||||
|
||||
void initialize(operation_mode_e operationMode, bool needSecondTriggerInput);
|
||||
void setTriggerSynchronizationGap(float synchRatio);
|
||||
void setTriggerSynchronizationGap(float syncRatio);
|
||||
void setTriggerSynchronizationGap2(float syncRatioFrom, float syncRatioTo);
|
||||
void setSecondTriggerSynchronizationGap(float synchRatio);
|
||||
void setSecondTriggerSynchronizationGap(float syncRatio);
|
||||
void setSecondTriggerSynchronizationGap2(float syncRatioFrom, float syncRatioTo);
|
||||
void setThirdTriggerSynchronizationGap(float syncRatio);
|
||||
void setThirdTriggerSynchronizationGap2(float syncRatioFrom, float syncRatioTo);
|
||||
/**
|
||||
* this one is per CRANKshaft revolution
|
||||
*/
|
||||
|
|
|
@ -138,7 +138,7 @@ public class AutoTest {
|
|||
assertWave(true, msg, chart, EngineChart.SPARK_3, 0.13299999999999998, 0.005, EngineReport.RATIO, x, x + 360);
|
||||
assertWaveNull(msg, chart, EngineChart.SPARK_4);
|
||||
|
||||
x = 124.12;
|
||||
x = 117.0;
|
||||
assertWave(true, msg, chart, EngineChart.INJECTOR_1, 0.1553333333333329, 0.04, 0.2, x + 360);
|
||||
assertWave(true, msg, chart, EngineChart.INJECTOR_2, 0.1553333333333329, 0.04, 0.2, x + 180);
|
||||
assertWave(true, msg, chart, EngineChart.INJECTOR_3, 0.1553333333333329, 0.04, 0.2, x + 540);
|
||||
|
@ -146,7 +146,6 @@ public class AutoTest {
|
|||
|
||||
sendCommand("enable trigger_only_front");
|
||||
chart = nextChart();
|
||||
x = 124.12;
|
||||
assertWave(true, msg, chart, EngineChart.INJECTOR_1, 0.1553333333333329, 0.04, 0.2, x + 360);
|
||||
assertWave(true, msg, chart, EngineChart.INJECTOR_2, 0.1553333333333329, 0.04, 0.2, x + 180);
|
||||
assertWave(true, msg, chart, EngineChart.INJECTOR_3, 0.1553333333333329, 0.04, 0.2, x + 540);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.rusefi.ui;
|
||||
|
||||
import com.rusefi.Launcher;
|
||||
import com.rusefi.core.MessagesCentral;
|
||||
import com.rusefi.io.CommandQueue;
|
||||
import com.rusefi.io.InvocationConfirmationListener;
|
||||
|
@ -26,9 +27,17 @@ public class LogDownloader {
|
|||
*/
|
||||
private static final String LS_RESPONSE = "ls_result";
|
||||
private static final String LS_ENTRY_PREFIX = "logfile";
|
||||
private static final String DELETE = "[delete]";
|
||||
private static final String DOWNLOAD = "[download]";
|
||||
private final JPanel content = new JPanel(new BorderLayout());
|
||||
|
||||
private final JPanel logFiles = new JPanel(new VerticalFlowLayout());
|
||||
private final Timer timer = new Timer(3000, new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
listDirectory();
|
||||
}
|
||||
});
|
||||
|
||||
public LogDownloader() {
|
||||
UiUtils.showLoadingMessage(content);
|
||||
|
@ -51,6 +60,7 @@ public class LogDownloader {
|
|||
JPanel logFileEntry = createFilePanel(message.substring(colonIndex + 1), size);
|
||||
|
||||
logFiles.add(logFileEntry);
|
||||
UiUtils.trueLayout(logFiles.getParent());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -63,15 +73,29 @@ public class LogDownloader {
|
|||
JPanel logFileEntry = new JPanel(new FlowLayout());
|
||||
logFileEntry.add(label);
|
||||
|
||||
JButton removeFile = new JButton("[delete]");
|
||||
JButton removeFile = new JButton(DELETE);
|
||||
removeFile.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
int i = JOptionPane.showConfirmDialog(Launcher.getFrame(), "Do you really want to delete " + name + "?");
|
||||
if (i == JOptionPane.YES_OPTION) {
|
||||
CommandQueue.getInstance().write("del " + name);
|
||||
timer.restart();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
JButton downloadFile = new JButton(DOWNLOAD);
|
||||
downloadFile.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
CommandQueue.getInstance().write("get_file 0 " + name);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
logFileEntry.add(removeFile);
|
||||
logFileEntry.add(downloadFile);
|
||||
return logFileEntry;
|
||||
}
|
||||
|
||||
|
@ -100,7 +124,7 @@ public class LogDownloader {
|
|||
}
|
||||
|
||||
private void listDirectory() {
|
||||
// CommandQueue.getInstance().write("ls /", CommandQueue.DEFAULT_TIMEOUT, InvocationConfirmationListener.VOID,
|
||||
// false);
|
||||
CommandQueue.getInstance().write("ls /", CommandQueue.DEFAULT_TIMEOUT, InvocationConfirmationListener.VOID,
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue