Skip to content

Commit

Permalink
add empty battery frame
Browse files Browse the repository at this point in the history
  • Loading branch information
sirfoga committed Sep 4, 2018
1 parent c674156 commit 017f4cd
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 5 deletions.
60 changes: 60 additions & 0 deletions app/src/it/raceup/yolo/ui/window/BatteryFrame.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package it.raceup.yolo.ui.window;

import it.raceup.yolo.error.ExceptionType;
import it.raceup.yolo.error.YoloException;
import it.raceup.yolo.models.kvaser.message.FromKvaserMessage;

import javax.swing.*;
import java.util.Observable;
import java.util.Observer;

import static it.raceup.yolo.utils.Os.setNativeLookAndFeelOrFail;

public class BatteryFrame extends JFrame implements Observer {
private static final String TITLE = "YOLO: BMS and battery";

public BatteryFrame() {
super(TITLE);

setup();
}

public void open() {
try {
pack();
setSize(600, 500);
setLocation(625, 0); // right to motors
setResizable(false);
setNativeLookAndFeelOrFail();

// disable exit button
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
setVisible(true);
} catch (Exception e) {
new YoloException(
"cannot open BMS viewer",
e,
ExceptionType.VIEW
).print();
}
}

private void setup() {
setupLayout();
}

private void setupLayout() {
setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
}

@Override
public void update(Observable observable, Object o) {
try {
FromKvaserMessage message = new FromKvaserMessage(o);
// todo update
} catch (Exception e) {
new YoloException("cannot update BMS", e, ExceptionType.KVASER)
.print();
}
}
}
6 changes: 3 additions & 3 deletions app/src/it/raceup/yolo/ui/window/CanMessagesFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public class CanMessagesFrame extends JFrame implements Observer {
public CanMessagesFrame() {
super(TITLE);

canMessageSender = new CanMessageSender(); // todo connect to kvaser
canMessageBrowser = new CanMessageBrowser(); // todo connect to kvaser
canMessageSender = new CanMessageSender();
canMessageBrowser = new CanMessageBrowser();

setup();
}
Expand Down Expand Up @@ -70,7 +70,7 @@ public void update(Observable observable, Object o) {
canMessageBrowser.update(messages);
}
} catch (Exception e) {
new YoloException("cannot update car", e, ExceptionType.KVASER)
new YoloException("cannot update CAN", e, ExceptionType.KVASER)
.print();
}
}
Expand Down
12 changes: 10 additions & 2 deletions app/src/it/raceup/yolo/ui/window/MainFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@
import static it.raceup.yolo.utils.Os.setNativeLookAndFeelOrFail;

public class MainFrame extends JFrame {
private static final String TITLE = "YOLO: motors";
private static final String TITLE = "YOLO: AMK and inverters";
private static final String ICON_PATH = "/res/images/logo.png";
private final MotorsPanel motorPanels;
private final CanMessagesFrame canMessagesFrame;
private final BatteryFrame batteryFrame;
private Image appIcon;

public MainFrame() {
super(TITLE);

motorPanels = new MotorsPanel();
canMessagesFrame = new CanMessagesFrame();
batteryFrame = new BatteryFrame();

setup();
open();
Expand All @@ -40,7 +42,9 @@ private void open() {
setNativeLookAndFeelOrFail();
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // close app
canMessagesFrame.open();

canMessagesFrame.open(); // open rest of frames
batteryFrame.open();
} catch (Exception e) {
new YoloException(
"cannot open view",
Expand Down Expand Up @@ -130,6 +134,10 @@ public CanMessagesFrame getCanMessagesFrame() {
return canMessagesFrame;
}

public BatteryFrame getBatteryFrame() {
return batteryFrame;
}

private void loadIcon() {
try {
appIcon = Toolkit.getDefaultToolkit().getImage(
Expand Down
Binary file modified build/cmd/yolo.jar
Binary file not shown.
Binary file modified build/gui/yolo.jar
Binary file not shown.

0 comments on commit 017f4cd

Please sign in to comment.