auto-sync

This commit is contained in:
rusEfi 2015-03-15 19:05:09 -05:00
parent 3f401c54c4
commit 1d36167a1d
7 changed files with 67 additions and 13 deletions

View File

@ -38,7 +38,8 @@ static msg_t AltCtrlThread(int param) {
currentAltDuty = altPid.getValue(14, getVBatt(engineConfiguration), 1);
if (boardConfiguration->isVerboseAlternator) {
scheduleMsg(logger, "alt duty: %f/vbatt=%f", currentAltDuty, getVBatt(engineConfiguration));
scheduleMsg(logger, "alt duty: %f/vbatt=%f/p=%f/i=%f", currentAltDuty, getVBatt(engineConfiguration),
altPid.getP(), altPid.getI());
}
alternatorControl.setSimplePwmDutyCycle(currentAltDuty / 100);

View File

@ -53,3 +53,16 @@ void Pid::reset(void) {
prevError = 0;
}
float Pid::getP(void) {
return pFactor;
}
float Pid::getI(void) {
return iFactor;
}
float Pid::getD(void) {
return dFactor;
}

View File

@ -15,6 +15,9 @@ public:
float getValue(float target, float input, float dTime);
void updateFactors(float pFactor, float iFactor, float dFactor);
void reset(void);
float getP(void);
float getI(void);
float getD(void);
private:
float pFactor;
float iFactor;

View File

@ -1,12 +1,13 @@
package com.rusefi;
import com.rusefi.binaryprotocol.BinaryProtocol;
import com.rusefi.binaryprotocol.BinaryProtocolCmd;
import com.rusefi.core.EngineState;
import com.rusefi.core.MessagesCentral;
import com.rusefi.io.LinkManager;
import com.rusefi.maintenance.VersionChecker;
import com.rusefi.ui.*;
import com.rusefi.ui.GaugesPanel;
import com.rusefi.ui.MessagesPane;
import com.rusefi.ui.RpmPanel;
import com.rusefi.ui.Wizard;
import com.rusefi.ui.engine.EngineSnifferPanel;
import com.rusefi.ui.fsio.FlexibleControls;
import com.rusefi.ui.logview.LogViewer;
@ -16,8 +17,6 @@ import com.rusefi.ui.util.FrameHelper;
import jssc.SerialPortList;
import javax.swing.*;
import javax.swing.table.TableCellEditor;
import java.awt.*;
import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
@ -34,7 +33,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
* @see com.rusefi.StartupFrame
*/
public class Launcher {
public static final int CONSOLE_VERSION = 20150313;
public static final int CONSOLE_VERSION = 20150315;
public static final boolean SHOW_STIMULATOR = false;
public static final String TAB_INDEX = "main_tab";
private final String port;

View File

@ -1,10 +1,14 @@
package com.rusefi.ui;
import ZoeloeSoft.projects.JFontChooser.JFontChooser;
import com.rusefi.Launcher;
import com.rusefi.ui.storage.Node;
import com.rusefi.ui.widgets.IdleLabel;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class MessagesPane {
private final JPanel content = new JPanel(new BorderLayout()) {
@ -14,9 +18,13 @@ public class MessagesPane {
return new Dimension(250, size.height);
}
};
private final JButton fontButton = new JButton("Font");
public MessagesPane(Node config) {
MessagesPanel messagesPanel = new MessagesPanel(config);
public MessagesPane(final Node config) {
JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 0));
final MessagesPanel messagesPanel = new MessagesPanel(config);
messagesPanel.loadFont(config);
content.setBorder(BorderFactory.createLineBorder(Color.red));
JPanel middlePanel = new JPanel(new BorderLayout());
@ -26,7 +34,9 @@ public class MessagesPane {
content.add(middlePanel, BorderLayout.CENTER);
messagesPanel.getButtonPanel().add(new RpmLabel().getContent());
content.add(messagesPanel.getButtonPanel(), BorderLayout.NORTH);
topPanel.add(messagesPanel.getButtonPanel());
topPanel.add(fontButton);
content.add(topPanel, BorderLayout.NORTH);
JPanel statsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
@ -35,6 +45,18 @@ public class MessagesPane {
statsPanel.add(new WarningPanel().getPanel());
content.add(statsPanel, BorderLayout.SOUTH);
fontButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFontChooser fc = new JFontChooser(Launcher.getFrame());
fc.setLocationRelativeTo(fontButton);
if (fc.showDialog(messagesPanel.getFont()) == JFontChooser.OK_OPTION) {
messagesPanel.setFont(fc.getFont(), config);
}
}
});
}
public JComponent getContent() {

View File

@ -4,7 +4,6 @@ import com.rusefi.core.MessagesCentral;
import com.rusefi.io.CommandQueue;
import com.rusefi.io.serial.PortHolder;
import com.rusefi.ui.storage.Node;
import com.rusefi.ui.util.LocalizedMessages;
import com.rusefi.ui.util.UiUtils;
import com.rusefi.ui.widgets.AnyCommand;
@ -31,6 +30,8 @@ import static com.rusefi.ui.util.LocalizedMessages.PAUSE;
public class MessagesPanel {
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH_mm");
private static final int MAX_SIZE = 50000;
private static final String FONT_SIZE = "font_size";
private static final String FONT_NAME = "font_name";
private final AnyCommand anyCommand;
private final JTextPane messages = new JTextPane() {
@ -132,4 +133,21 @@ public class MessagesPanel {
public JScrollPane getMessagesScroll() {
return messagesScroll;
}
public Font getFont() {
return messages.getFont();
}
public void setFont(Font font, Node config) {
messages.setFont(font);
config.setProperty(FONT_SIZE, font.getSize());
config.setProperty(FONT_NAME, font.getName());
}
public void loadFont(Node config) {
Font f = getFont();
int size = config.getIntProperty(FONT_SIZE, f.getSize());
String name = config.getProperty(FONT_NAME, f.getName());
setFont(new Font(f.getName(), f.getStyle(), size), config);
}
}

View File

@ -24,7 +24,6 @@ public class AnyCommand {
}
};
private final Node config;
private JPanel content = new JPanel(new FlowLayout(FlowLayout.LEFT));
public AnyCommand(final Node config) {
@ -32,7 +31,6 @@ public class AnyCommand {
}
public AnyCommand(final Node config, String defaultCommand) {
this.config = config;
text.setText(defaultCommand);
content.setBorder(BorderFactory.createLineBorder(Color.PINK));
content.add(new JLabel("Command: "));