REO progress

This commit is contained in:
rusefi 2020-05-22 13:45:11 -04:00
parent bdd0bc5c77
commit 0c6baf7743
3 changed files with 31 additions and 4 deletions

View File

@ -38,8 +38,20 @@ public class Online {
}
int responseCode = ((HttpURLConnection) connection).getResponseCode();
HttpURLConnection httpURLConnection = (HttpURLConnection) connection;
int responseCode = httpURLConnection.getResponseCode();
System.out.println(responseCode); // Should be 200
BufferedReader br;
if (responseCode >= 200 && responseCode <= 299) {
br = new BufferedReader(new InputStreamReader(httpURLConnection.getInputStream()));
} else {
br = new BufferedReader(new InputStreamReader(httpURLConnection.getErrorStream()));
}
String output;
while ((output = br.readLine()) != null) {
System.out.println(output);
}
}
private static void sendParameter(String boundary, PrintWriter writer, String parameterName, String value) {

View File

@ -92,8 +92,10 @@ public class FormulasPane {
}
enum engine_load_mode_e {
// todo: this should NOT be copy-pasted from
LM_PLAIN_MAF("Plain MAF"),
LM_ALPHA_N("Alpha-N/TPS"),
UNUSED_2("Unused value 2"),
LM_SPEED_DENSITY("Speed Density/MAP"),
LM_REAL_MAF("MAF");
@ -115,7 +117,7 @@ public class FormulasPane {
int algorithm = ConfigField.getIntValue(ci, Fields.FUELALGORITHM);
engine_load_mode_e[] values = engine_load_mode_e.values();
if (algorithm >= values.length) {
FileLog.MAIN.logLine("Invalid algorithm" + algorithm);
FileLog.MAIN.logLine("Invalid algorithm: " + algorithm);
algorithm = 0; // we are here for example in case of an invalid/incompatible configuration
}
engine_load_mode_e algo = values[algorithm];

View File

@ -3,6 +3,7 @@ package com.rusefi.ui;
import com.rusefi.io.LinkManager;
import com.rusefi.tools.online.Online;
import com.rusefi.tune.xml.Msq;
import com.rusefi.ui.util.URLLabel;
import org.putgemin.VerticalFlowLayout;
import javax.swing.*;
@ -17,6 +18,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
public class OnlineTab {
private static final String AUTH_TOKEN = "auth_token";
private static final String TOKEN_WARNING = "Please copy token from your forum profile";
private final JPanel content = new JPanel(new VerticalFlowLayout());
@ -24,7 +26,13 @@ public class OnlineTab {
JTextField textField = new JTextField();
textField.setPreferredSize(new Dimension(200, 24));
textField.setText(getConfig().getRoot().getProperty(AUTH_TOKEN));
String authToken = getConfig().getRoot().getProperty(AUTH_TOKEN);
if (authToken.trim().isEmpty())
authToken = TOKEN_WARNING;
textField.setText(authToken);
content.add(new URLLabel("rusEFI Online manual", "https://github.com/rusefi/rusefi/wiki/Online"));
content.add(textField);
@ -42,11 +50,16 @@ public class OnlineTab {
upload.addActionListener(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
String text = textField.getText();
if (text.contains(TOKEN_WARNING)) {
JOptionPane.showMessageDialog(content, "Does not work without auth token");
return;
}
Msq tune = Msq.toMsq(LinkManager.connector.getBinaryProtocol().getControllerConfiguration());
try {
tune.writeXmlFile(Msq.outputXmlFileName);
// todo: network upload should not happen on UI thread
Online.upload(new File(Msq.outputXmlFileName), textField.getText());
Online.upload(new File(Msq.outputXmlFileName), text);
} catch (JAXBException | IOException ex) {
throw new IllegalStateException(ex);
}