auto-sync

This commit is contained in:
rusEfi 2015-05-04 11:05:07 -04:00
parent 38aee25110
commit 72227026c9
4 changed files with 56 additions and 3 deletions

View File

@ -799,6 +799,8 @@ static void setSpiMode(int index, bool mode) {
static void enableOrDisable(const char *param, bool isEnabled) {
if (strEqualCaseInsensitive(param, "fastadc")) {
boardConfiguration->isFastAdcEnabled = isEnabled;
} else if (strEqualCaseInsensitive(param, "serial")) {
boardConfiguration->useSerialPort = isEnabled;
} else if (strEqualCaseInsensitive(param, "stepperidle")) {
boardConfiguration->useStepperIdle = isEnabled;
} else if (strEqualCaseInsensitive(param, "trigger_only_front")) {

View File

@ -290,5 +290,5 @@ int getRusEfiVersion(void) {
return 123; // this is here to make the compiler happy about the unused array
if (UNUSED_CCM_SIZE[0] * 0 != 0)
return 3211; // this is here to make the compiler happy about the unused array
return 20150503;
return 20150504;
}

View File

@ -11,6 +11,7 @@ import com.rusefi.ui.logview.LogViewer;
import com.rusefi.ui.storage.Node;
import com.rusefi.ui.util.DefaultExceptionHandler;
import com.rusefi.ui.util.FrameHelper;
import com.rusefi.ui.util.JustOneInstance;
import jssc.SerialPortList;
import javax.swing.*;
@ -31,7 +32,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
* @see com.rusefi.StartupFrame
*/
public class Launcher {
public static final int CONSOLE_VERSION = 20150503;
public static final int CONSOLE_VERSION = 20150504;
public static final boolean SHOW_STIMULATOR = false;
private static final String TAB_INDEX = "main_tab";
protected static final String PORT_KEY = "port";
@ -174,8 +175,14 @@ public class Launcher {
}
private static void awtCode(String[] args) {
if (JustOneInstance.isAlreadyRunning()) {
int result = JOptionPane.showConfirmDialog(null, "Looks like another instance is already running. Do you really want to start another instance?",
"rusEfi", JOptionPane.YES_NO_OPTION);
if (result == JOptionPane.NO_OPTION)
System.exit(-1);
}
JustOneInstance.onStart();
try {
boolean isPortDefined = args.length > 0;
if (isPortDefined) {
new Launcher(args[0]);

View File

@ -0,0 +1,44 @@
package com.rusefi.ui.util;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
/**
* (c) Andrey Belomutskiy
* 5/4/2015
*/
public class JustOneInstance {
private static final int PORT = 29212;
public static boolean isAlreadyRunning() {
try {
Socket clientSocket = new Socket("localhost", PORT);
System.out.println("*** Already running!");
return true;
} catch (IOException e) {
return false;
}
}
public static void onStart() {
Runnable runnable = new Runnable() {
@Override
public void run() {
ServerSocket serverSocket;
try {
serverSocket = new ServerSocket(PORT, 1);
while (true) {
// Wait for a connection
Socket clientSocket = serverSocket.accept();
// System.out.println("*** Got a connection! ");
clientSocket.close();
}
} catch (IOException e) {
}
}
};
new Thread(runnable).start();
}
}