-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
73 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.