auto-sync

This commit is contained in:
rusEfi 2015-04-06 17:09:09 -05:00
parent 69138e39b9
commit e62a1573c9
2 changed files with 14 additions and 4 deletions

View File

@ -135,6 +135,10 @@ public class CommandQueue {
write(command, timeout, InvocationConfirmationListener.VOID); write(command, timeout, InvocationConfirmationListener.VOID);
} }
public void write(String command, int timeoutMs, InvocationConfirmationListener listener) {
write(command, timeoutMs, listener, true);
}
/** /**
* Non-blocking command request * Non-blocking command request
* Command is placed in the queue where it would be until it is confirmed * Command is placed in the queue where it would be until it is confirmed
@ -142,10 +146,12 @@ public class CommandQueue {
* @param command dev console command * @param command dev console command
* @param timeoutMs retry timeout * @param timeoutMs retry timeout
*/ */
public void write(String command, int timeoutMs, InvocationConfirmationListener listener) { public void write(String command, int timeoutMs, InvocationConfirmationListener listener, boolean fireEvent) {
if (fireEvent) {
for (CommandQueueListener cql : commandListeners) for (CommandQueueListener cql : commandListeners)
cql.onCommand(command); cql.onCommand(command);
}
pendingCommands.add(new MethodInvocation(command, timeoutMs, listener)); pendingCommands.add(new MethodInvocation(command, timeoutMs, listener));
} }

View File

@ -5,6 +5,7 @@ import com.rusefi.config.Field;
import com.rusefi.core.MessagesCentral; import com.rusefi.core.MessagesCentral;
import com.rusefi.core.Pair; import com.rusefi.core.Pair;
import com.rusefi.io.CommandQueue; import com.rusefi.io.CommandQueue;
import com.rusefi.io.InvocationConfirmationListener;
import com.rusefi.ui.ConnectionStatus; import com.rusefi.ui.ConnectionStatus;
import com.rusefi.ui.util.JTextFieldWithWidth; import com.rusefi.ui.util.JTextFieldWithWidth;
@ -29,7 +30,10 @@ public class ConfigField {
ConnectionStatus.INSTANCE.addListener(new ConnectionStatus.Listener() { ConnectionStatus.INSTANCE.addListener(new ConnectionStatus.Listener() {
@Override @Override
public void onConnectionStatus(boolean isConnected) { public void onConnectionStatus(boolean isConnected) {
CommandQueue.getInstance().write(field.getType().getLoadCommand() + " " + field.getOffset()); CommandQueue.getInstance().write(field.getType().getLoadCommand() + " " + field.getOffset(),
CommandQueue.DEFAULT_TIMEOUT,
InvocationConfirmationListener.VOID,
false);
} }
}); });