├── java
├── FRC-DriverStation-Android
│ ├── .gitignore
│ ├── res
│ │ ├── values
│ │ │ ├── styles.xml
│ │ │ └── strings.xml
│ │ ├── drawable-hdpi
│ │ │ └── ic_launcher.png
│ │ ├── drawable-ldpi
│ │ │ └── ic_launcher.png
│ │ ├── drawable-mdpi
│ │ │ └── ic_launcher.png
│ │ ├── drawable-xhdpi
│ │ │ └── ic_launcher.png
│ │ ├── layout
│ │ │ └── fragment_operation.xml
│ │ └── menu
│ │ │ └── activity_main.xml
│ ├── ic_launcher-web.png
│ ├── .classpath
│ ├── src
│ │ └── org
│ │ │ └── anidev
│ │ │ └── frcds
│ │ │ └── android
│ │ │ ├── OperationFragment.java
│ │ │ └── MainActivity.java
│ ├── .settings
│ │ └── org.eclipse.jdt.core.prefs
│ ├── project.properties
│ ├── proguard-project.txt
│ ├── .project
│ └── AndroidManifest.xml
├── mavenrepo
│ └── FRCDS-Libs
│ │ └── forms
│ │ ├── 1.3.0
│ │ ├── forms-1.3.0.jar.md5
│ │ ├── forms-1.3.0.pom.md5
│ │ ├── forms-1.3.0-sources.jar.md5
│ │ ├── forms-1.3.0.jar.sha1
│ │ ├── forms-1.3.0.pom.sha1
│ │ ├── forms-1.3.0-sources.jar.sha1
│ │ ├── forms-1.3.0.jar
│ │ ├── forms-1.3.0-sources.jar
│ │ └── forms-1.3.0.pom
│ │ ├── maven-metadata-local.xml.md5
│ │ ├── maven-metadata-local.xml.sha1
│ │ └── maven-metadata-local.xml
├── Utils
│ ├── .settings
│ │ ├── org.eclipse.core.resources.prefs
│ │ ├── org.eclipse.jdt.core.prefs
│ │ └── org.eclipse.m2e.core.prefs
│ ├── .project
│ ├── .classpath
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── org
│ │ └── anidev
│ │ └── utils
│ │ ├── GTKIconTheme.java
│ │ └── Utils.java
├── FRC-Netconsole-PC
│ ├── .settings
│ │ ├── org.eclipse.jdt.core.prefs
│ │ ├── org.eclipse.m2e.core.prefs
│ │ └── org.eclipse.core.resources.prefs
│ ├── src
│ │ └── main
│ │ │ ├── resources
│ │ │ ├── list.png
│ │ │ ├── pause.png
│ │ │ ├── text.png
│ │ │ ├── arrow-up.png
│ │ │ ├── delete.png
│ │ │ └── arrow-down.png
│ │ │ └── java
│ │ │ └── org
│ │ │ └── anidev
│ │ │ └── frcds
│ │ │ └── pc
│ │ │ └── nc
│ │ │ ├── NetconsoleMain.java
│ │ │ ├── NetconsoleFrame.java
│ │ │ ├── ControlBar.java
│ │ │ └── NetconsolePanel.java
│ ├── .project
│ ├── .classpath
│ └── pom.xml
├── FRCDS-Java-Comm
│ ├── .settings
│ │ ├── org.eclipse.core.resources.prefs
│ │ ├── org.eclipse.jdt.core.prefs
│ │ └── org.eclipse.m2e.core.prefs
│ ├── src
│ │ └── main
│ │ │ └── java
│ │ │ └── org
│ │ │ └── anidev
│ │ │ └── frcds
│ │ │ └── proto
│ │ │ ├── DataDir.java
│ │ │ ├── torobot
│ │ │ ├── OperationMode.java
│ │ │ ├── Alliance.java
│ │ │ ├── TeamStation.java
│ │ │ ├── DigitalInputs.java
│ │ │ ├── CRIOChecksum.java
│ │ │ ├── FPGAChecksum.java
│ │ │ ├── AnalogInputs.java
│ │ │ ├── Joystick.java
│ │ │ └── FRCCommonControl.java
│ │ │ ├── nc
│ │ │ ├── NetconsoleListener.java
│ │ │ ├── NetconsoleMessage.java
│ │ │ └── Netconsole.java
│ │ │ ├── FRCCommunicationListener.java
│ │ │ ├── CommData.java
│ │ │ ├── tods
│ │ │ ├── DigitalOutputs.java
│ │ │ ├── MacAddress.java
│ │ │ └── FRCRobotControl.java
│ │ │ ├── Version.java
│ │ │ └── ControlFlags.java
│ ├── .project
│ ├── pom.xml
│ └── .classpath
├── FRC-DriverStation-Common
│ ├── .settings
│ │ ├── org.eclipse.m2e.core.prefs
│ │ ├── org.eclipse.jdt.core.prefs
│ │ └── org.eclipse.core.resources.prefs
│ ├── src
│ │ └── main
│ │ │ └── java
│ │ │ └── org
│ │ │ └── anidev
│ │ │ └── frcds
│ │ │ └── common
│ │ │ ├── types
│ │ │ └── BatteryProvider.java
│ │ │ ├── CommonLoop.java
│ │ │ ├── EnabledLoop.java
│ │ │ └── DriverStation.java
│ ├── .project
│ ├── .classpath
│ └── pom.xml
├── FRC-DriverStation-PC
│ ├── .settings
│ │ ├── org.eclipse.m2e.core.prefs
│ │ ├── org.eclipse.core.resources.prefs
│ │ └── org.eclipse.jdt.core.prefs
│ ├── src
│ │ └── main
│ │ │ ├── resources
│ │ │ ├── status-bad.png
│ │ │ └── status-good.png
│ │ │ └── java
│ │ │ └── org
│ │ │ └── anidev
│ │ │ └── frcds
│ │ │ └── pc
│ │ │ ├── battery
│ │ │ ├── win
│ │ │ │ ├── Kernel32.java
│ │ │ │ ├── WindowsBatteryProvider.java
│ │ │ │ └── PowerStatus.java
│ │ │ └── linux
│ │ │ │ └── LinuxBatteryProvider.java
│ │ │ ├── input
│ │ │ ├── InputListener.java
│ │ │ ├── Type.java
│ │ │ ├── trans
│ │ │ │ ├── TranslationProfile.java
│ │ │ │ └── BasicTranslation.java
│ │ │ ├── InputDevice.java
│ │ │ └── InputEnvironment.java
│ │ │ ├── gui
│ │ │ ├── TeamIDPanel.java
│ │ │ ├── EnableDisablePanel.java
│ │ │ ├── EnhancedToggleButton.java
│ │ │ ├── StatusPanel.java
│ │ │ ├── OperationPanel.java
│ │ │ ├── DriverStationFrame.java
│ │ │ └── SetupPanel.java
│ │ │ ├── PCDriverStation.java
│ │ │ └── DriverStationMain.java
│ ├── .project
│ ├── .classpath
│ └── pom.xml
├── FRCDS-PacketAnalyzer
│ ├── .settings
│ │ ├── org.eclipse.jdt.core.prefs
│ │ ├── org.eclipse.m2e.core.prefs
│ │ └── org.eclipse.core.resources.prefs
│ ├── .project
│ ├── src
│ │ └── main
│ │ │ └── java
│ │ │ └── org
│ │ │ └── anidev
│ │ │ └── frcds
│ │ │ └── analyze
│ │ │ ├── AnalyzerMain.java
│ │ │ ├── FileProvider.java
│ │ │ └── AnalyzerProviderSelector.java
│ ├── .classpath
│ └── pom.xml
├── FRC-ReceiveDS
│ ├── .classpath
│ ├── .project
│ └── src
│ │ └── org
│ │ └── anidev
│ │ └── frcds
│ │ └── receiveds
│ │ └── Main.java
└── pom.xml
├── .gitignore
├── COPYING.md
└── README.md
/java/FRC-DriverStation-Android/.gitignore:
--------------------------------------------------------------------------------
1 | bin/
2 | gen/
3 | /libs
4 | /assets
5 |
--------------------------------------------------------------------------------
/java/mavenrepo/FRCDS-Libs/forms/1.3.0/forms-1.3.0.jar.md5:
--------------------------------------------------------------------------------
1 | 68153fd645ffc88efdd424bf7671f37a
--------------------------------------------------------------------------------
/java/mavenrepo/FRCDS-Libs/forms/1.3.0/forms-1.3.0.pom.md5:
--------------------------------------------------------------------------------
1 | 330a7acbe8b2bfada7efb5c759379c65
--------------------------------------------------------------------------------
/java/mavenrepo/FRCDS-Libs/forms/maven-metadata-local.xml.md5:
--------------------------------------------------------------------------------
1 | ba1bdb95b3e0fe51be20c2215e91c1cd
--------------------------------------------------------------------------------
/java/mavenrepo/FRCDS-Libs/forms/1.3.0/forms-1.3.0-sources.jar.md5:
--------------------------------------------------------------------------------
1 | 845fc4aa8639a4532b730e0347a4c81a
--------------------------------------------------------------------------------
/java/mavenrepo/FRCDS-Libs/forms/1.3.0/forms-1.3.0.jar.sha1:
--------------------------------------------------------------------------------
1 | e9003fc88e55a05be29e633ca09da9457bd3d5c4
--------------------------------------------------------------------------------
/java/mavenrepo/FRCDS-Libs/forms/1.3.0/forms-1.3.0.pom.sha1:
--------------------------------------------------------------------------------
1 | 2db43a4086c3a8bdbad865ac12b808aa015c5013
--------------------------------------------------------------------------------
/java/mavenrepo/FRCDS-Libs/forms/maven-metadata-local.xml.sha1:
--------------------------------------------------------------------------------
1 | b380ea274c10889730dfd48c3dc0c1b38c3301b3
--------------------------------------------------------------------------------
/java/mavenrepo/FRCDS-Libs/forms/1.3.0/forms-1.3.0-sources.jar.sha1:
--------------------------------------------------------------------------------
1 | 7431613fc740853af121d5354a0d5fc6de9b6c33
--------------------------------------------------------------------------------
/java/FRC-DriverStation-Android/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
--------------------------------------------------------------------------------
/java/Utils/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding//src/main/java=UTF-8
3 | encoding/=UTF-8
4 |
--------------------------------------------------------------------------------
/java/Utils/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
3 |
--------------------------------------------------------------------------------
/java/Utils/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | activeProfiles=
2 | eclipse.preferences.version=1
3 | resolveWorkspaceProjects=true
4 | version=1
5 |
--------------------------------------------------------------------------------
/java/FRC-DriverStation-Android/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anidev/frc-driverstation/HEAD/java/FRC-DriverStation-Android/ic_launcher-web.png
--------------------------------------------------------------------------------
/java/FRC-Netconsole-PC/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
3 |
--------------------------------------------------------------------------------
/java/FRC-Netconsole-PC/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | activeProfiles=
2 | eclipse.preferences.version=1
3 | resolveWorkspaceProjects=true
4 | version=1
5 |
--------------------------------------------------------------------------------
/java/FRC-Netconsole-PC/src/main/resources/list.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anidev/frc-driverstation/HEAD/java/FRC-Netconsole-PC/src/main/resources/list.png
--------------------------------------------------------------------------------
/java/FRC-Netconsole-PC/src/main/resources/pause.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anidev/frc-driverstation/HEAD/java/FRC-Netconsole-PC/src/main/resources/pause.png
--------------------------------------------------------------------------------
/java/FRC-Netconsole-PC/src/main/resources/text.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anidev/frc-driverstation/HEAD/java/FRC-Netconsole-PC/src/main/resources/text.png
--------------------------------------------------------------------------------
/java/FRCDS-Java-Comm/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding//src/main/java=UTF-8
3 | encoding/=UTF-8
4 |
--------------------------------------------------------------------------------
/java/FRCDS-Java-Comm/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
3 |
--------------------------------------------------------------------------------
/java/FRCDS-Java-Comm/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | activeProfiles=
2 | eclipse.preferences.version=1
3 | resolveWorkspaceProjects=true
4 | version=1
5 |
--------------------------------------------------------------------------------
/java/FRCDS-Java-Comm/src/main/java/org/anidev/frcds/proto/DataDir.java:
--------------------------------------------------------------------------------
1 | package org.anidev.frcds.proto;
2 |
3 | public enum DataDir {
4 | TODS,TOROBOT;
5 | }
6 |
--------------------------------------------------------------------------------
/java/FRC-DriverStation-Common/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | activeProfiles=
2 | eclipse.preferences.version=1
3 | resolveWorkspaceProjects=true
4 | version=1
5 |
--------------------------------------------------------------------------------
/java/FRC-DriverStation-PC/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | activeProfiles=
2 | eclipse.preferences.version=1
3 | resolveWorkspaceProjects=true
4 | version=1
5 |
--------------------------------------------------------------------------------
/java/FRC-Netconsole-PC/src/main/resources/arrow-up.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anidev/frc-driverstation/HEAD/java/FRC-Netconsole-PC/src/main/resources/arrow-up.png
--------------------------------------------------------------------------------
/java/FRC-Netconsole-PC/src/main/resources/delete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anidev/frc-driverstation/HEAD/java/FRC-Netconsole-PC/src/main/resources/delete.png
--------------------------------------------------------------------------------
/java/FRCDS-PacketAnalyzer/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
3 |
--------------------------------------------------------------------------------
/java/FRCDS-PacketAnalyzer/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | activeProfiles=
2 | eclipse.preferences.version=1
3 | resolveWorkspaceProjects=true
4 | version=1
5 |
--------------------------------------------------------------------------------
/java/mavenrepo/FRCDS-Libs/forms/1.3.0/forms-1.3.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anidev/frc-driverstation/HEAD/java/mavenrepo/FRCDS-Libs/forms/1.3.0/forms-1.3.0.jar
--------------------------------------------------------------------------------
/java/FRC-DriverStation-Common/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
3 |
--------------------------------------------------------------------------------
/java/FRC-Netconsole-PC/src/main/resources/arrow-down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anidev/frc-driverstation/HEAD/java/FRC-Netconsole-PC/src/main/resources/arrow-down.png
--------------------------------------------------------------------------------
/java/FRC-DriverStation-PC/src/main/resources/status-bad.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anidev/frc-driverstation/HEAD/java/FRC-DriverStation-PC/src/main/resources/status-bad.png
--------------------------------------------------------------------------------
/java/FRC-DriverStation-PC/src/main/resources/status-good.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anidev/frc-driverstation/HEAD/java/FRC-DriverStation-PC/src/main/resources/status-good.png
--------------------------------------------------------------------------------
/java/mavenrepo/FRCDS-Libs/forms/1.3.0/forms-1.3.0-sources.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anidev/frc-driverstation/HEAD/java/mavenrepo/FRCDS-Libs/forms/1.3.0/forms-1.3.0-sources.jar
--------------------------------------------------------------------------------
/java/FRC-DriverStation-Android/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anidev/frc-driverstation/HEAD/java/FRC-DriverStation-Android/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/java/FRC-DriverStation-Android/res/drawable-ldpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anidev/frc-driverstation/HEAD/java/FRC-DriverStation-Android/res/drawable-ldpi/ic_launcher.png
--------------------------------------------------------------------------------
/java/FRC-DriverStation-Android/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anidev/frc-driverstation/HEAD/java/FRC-DriverStation-Android/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/java/FRC-DriverStation-Android/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anidev/frc-driverstation/HEAD/java/FRC-DriverStation-Android/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/java/FRC-DriverStation-Common/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding//src/main/java=UTF-8
3 | encoding//src/test/java=UTF-8
4 | encoding/=UTF-8
5 |
--------------------------------------------------------------------------------
/java/FRC-Netconsole-PC/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding//src/main/java=UTF-8
3 | encoding//src/main/resources=UTF-8
4 | encoding/=UTF-8
5 |
--------------------------------------------------------------------------------
/java/FRCDS-PacketAnalyzer/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding//src/main/java=UTF-8
3 | encoding//src/test/java=UTF-8
4 | encoding/=UTF-8
5 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Eclipse files
2 | .metadata
3 | *.class
4 | bin/
5 | target/
6 | .recommenders
7 |
8 | # Package files
9 | *.jar
10 | *.war
11 | *.ear
12 | *.zip
13 |
14 | # Backup files
15 | *~
16 |
--------------------------------------------------------------------------------
/java/FRCDS-Java-Comm/src/main/java/org/anidev/frcds/proto/torobot/OperationMode.java:
--------------------------------------------------------------------------------
1 | package org.anidev.frcds.proto.torobot;
2 |
3 | public enum OperationMode {
4 | TELEOPERATED,AUTONOMOUS,TEST;//PRACTICE;
5 | }
6 |
--------------------------------------------------------------------------------
/java/FRC-DriverStation-Common/src/main/java/org/anidev/frcds/common/types/BatteryProvider.java:
--------------------------------------------------------------------------------
1 | package org.anidev.frcds.common.types;
2 |
3 | public interface BatteryProvider {
4 | public double getBatteryPercent();
5 | }
6 |
--------------------------------------------------------------------------------
/java/FRC-DriverStation-PC/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding//src/main/java=UTF-8
3 | encoding//src/main/resources=UTF-8
4 | encoding//src/test/java=UTF-8
5 | encoding/=UTF-8
6 |
--------------------------------------------------------------------------------
/java/FRC-DriverStation-PC/src/main/java/org/anidev/frcds/pc/battery/win/Kernel32.java:
--------------------------------------------------------------------------------
1 | package org.anidev.frcds.pc.battery.win;
2 |
3 | import com.sun.jna.Library;
4 |
5 | public interface Kernel32 extends Library {
6 | public boolean GetSystemPowerStatus(PowerStatus status);
7 | }
8 |
--------------------------------------------------------------------------------
/java/FRC-DriverStation-Android/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | FRC Driver Station
5 | Hello world!
6 | Settings
7 |
8 |
--------------------------------------------------------------------------------
/java/FRC-DriverStation-Android/res/layout/fragment_operation.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/java/FRC-DriverStation-Android/res/menu/activity_main.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/java/FRC-ReceiveDS/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/java/FRCDS-Java-Comm/src/main/java/org/anidev/frcds/proto/nc/NetconsoleListener.java:
--------------------------------------------------------------------------------
1 | package org.anidev.frcds.proto.nc;
2 |
3 | public abstract class NetconsoleListener {
4 | public void dataSent(NetconsoleMessage msg) {
5 | }
6 | public void receivedData(NetconsoleMessage msg) {
7 | }
8 | public void messagesCleared() {
9 | }
10 | public void pauseChanged(boolean paused) {
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/java/mavenrepo/FRCDS-Libs/forms/maven-metadata-local.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | FRCDS-Libs
4 | forms
5 |
6 | 1.3.0
7 |
8 | 1.3.0
9 |
10 | 20140107234005
11 |
12 |
13 |
--------------------------------------------------------------------------------
/java/FRC-DriverStation-PC/src/main/java/org/anidev/frcds/pc/input/InputListener.java:
--------------------------------------------------------------------------------
1 | package org.anidev.frcds.pc.input;
2 |
3 | /**
4 | * Add and remove input devices
5 | */
6 | public abstract class InputListener {
7 | /**
8 | * @param dev the input device to add
9 | */
10 | public void deviceAdded(InputDevice dev) {
11 | }
12 | /**
13 | * @param dev the input device to remove
14 | */
15 | public void deviceRemoved(InputDevice dev) {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/java/FRC-ReceiveDS/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | FRC-ReceiveDS
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/java/FRC-DriverStation-PC/src/main/java/org/anidev/frcds/pc/input/Type.java:
--------------------------------------------------------------------------------
1 | package org.anidev.frcds.pc.input;
2 |
3 | /**
4 | * Type of input device
5 | */
6 | public enum Type {
7 | // Genearlly, joysticks have 3 axes (x, y, z,
8 | // where z is rotation or throttle)
9 | // Gamepads have 4 axes (two sticks x and y),
10 | // or 6 axes (two sticks x and y, l and r triggers)
11 | // 6-axis gamepads are generally XBOX controllers
12 | JOYSTICK,GAMEPAD4,GAMEPAD6,UNKNOWN;
13 | }
14 |
--------------------------------------------------------------------------------
/java/FRC-DriverStation-Android/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/java/mavenrepo/FRCDS-Libs/forms/1.3.0/forms-1.3.0.pom:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 | FRCDS-Libs
6 | forms
7 | 1.3.0
8 | POM was created from install:install-file
9 |
10 |
--------------------------------------------------------------------------------
/java/FRC-Netconsole-PC/src/main/java/org/anidev/frcds/pc/nc/NetconsoleMain.java:
--------------------------------------------------------------------------------
1 | package org.anidev.frcds.pc.nc;
2 |
3 | import javax.swing.JFrame;
4 | import org.anidev.frcds.proto.nc.Netconsole;
5 | import org.anidev.utils.Utils;
6 |
7 | public class NetconsoleMain {
8 | public static void main(String[] args) {
9 | Utils.setLookAndFeel();
10 | Netconsole netconsole=new Netconsole();
11 | NetconsoleFrame frame=new NetconsoleFrame(netconsole);
12 | frame.setLocationByPlatform(true);
13 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
14 | frame.setVisible(true);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/java/Utils/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | Utils
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.m2e.core.maven2Builder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.m2e.core.maven2Nature
21 | org.eclipse.jdt.core.javanature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/java/FRC-Netconsole-PC/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | FRC-Netconsole-PC
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.m2e.core.maven2Builder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.m2e.core.maven2Nature
21 | org.eclipse.jdt.core.javanature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/java/FRCDS-Java-Comm/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | FRCDS-Java-Comm
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.m2e.core.maven2Builder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.m2e.core.maven2Nature
21 | org.eclipse.jdt.core.javanature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/java/FRC-DriverStation-Android/src/org/anidev/frcds/android/OperationFragment.java:
--------------------------------------------------------------------------------
1 | package org.anidev.frcds.android;
2 |
3 | import android.os.Bundle;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.support.v4.app.Fragment;
8 |
9 | public class OperationFragment extends Fragment {
10 |
11 | @Override
12 | public void onCreate(Bundle savedState) {
13 | super.onCreate(savedState);
14 | }
15 | @Override
16 | public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedState) {
17 | // return inflater.inflate(R.layout.,container,false);
18 | return null;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/java/FRC-DriverStation-PC/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | FRC-DriverStation-PC
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.m2e.core.maven2Builder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.m2e.core.maven2Nature
21 | org.eclipse.jdt.core.javanature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/java/FRCDS-PacketAnalyzer/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | FRCDS-PacketAnalyzer
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.m2e.core.maven2Builder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.m2e.core.maven2Nature
21 | org.eclipse.jdt.core.javanature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/java/FRC-DriverStation-Common/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | FRC-DriverStation-Common
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.m2e.core.maven2Builder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.m2e.core.maven2Nature
21 | org.eclipse.jdt.core.javanature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/java/FRCDS-Java-Comm/src/main/java/org/anidev/frcds/proto/torobot/Alliance.java:
--------------------------------------------------------------------------------
1 | package org.anidev.frcds.proto.torobot;
2 |
3 | public enum Alliance {
4 | RED("Red",'R'),BLUE("Blue",'B');
5 | private String name;
6 | private char id;
7 |
8 | private Alliance(String name,char id) {
9 | this.name=name;
10 | this.id=id;
11 | }
12 |
13 | public String getName() {
14 | return name;
15 | }
16 |
17 | public char getId() {
18 | return id;
19 | }
20 |
21 | public static Alliance find(char id) {
22 | switch(Character.toUpperCase(id)) {
23 | case 'R':
24 | return Alliance.RED;
25 | case 'B':
26 | return Alliance.BLUE;
27 | }
28 | return null;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/java/FRC-DriverStation-Android/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5 | org.eclipse.jdt.core.compiler.compliance=1.6
6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate
8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11 | org.eclipse.jdt.core.compiler.source=1.6
12 |
--------------------------------------------------------------------------------
/java/FRCDS-PacketAnalyzer/src/main/java/org/anidev/frcds/analyze/AnalyzerMain.java:
--------------------------------------------------------------------------------
1 | package org.anidev.frcds.analyze;
2 |
3 | import javax.swing.JFrame;
4 | import javax.swing.UIManager;
5 | import org.anidev.frcds.analyze.gui.AnalyzerFrame;
6 |
7 | public class AnalyzerMain {
8 | public static void main(String[] args) {
9 | try {
10 | UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
11 | } catch(Exception e) {
12 | System.err.println("Error while setting Nimbus L&F.");
13 | e.printStackTrace();
14 | }
15 | AnalyzerFrame frame=new AnalyzerFrame(new AnalyzerProviderSelector());
16 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
17 | frame.setVisible(true);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/java/FRC-DriverStation-Common/src/main/java/org/anidev/frcds/common/CommonLoop.java:
--------------------------------------------------------------------------------
1 | package org.anidev.frcds.common;
2 |
3 | public class CommonLoop implements Runnable {
4 | private final DriverStation ds;
5 | private double hertz;
6 | private double delayMs;
7 | public CommonLoop(DriverStation ds,double hertz) {
8 | this.ds=ds;
9 | this.hertz=hertz;
10 | this.delayMs=1000.0/this.hertz;
11 | }
12 | @Override
13 | public void run() {
14 | while(!Thread.interrupted()) {
15 | doBattery();
16 | ds.doCommonLoopImpl();
17 | try {
18 | Thread.sleep((long)delayMs);
19 | } catch(InterruptedException e) {
20 | break;
21 | }
22 | }
23 | }
24 | private void doBattery() {
25 | ds.refreshBattery();
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/java/FRCDS-Java-Comm/src/main/java/org/anidev/frcds/proto/torobot/TeamStation.java:
--------------------------------------------------------------------------------
1 | package org.anidev.frcds.proto.torobot;
2 |
3 |
4 | public enum TeamStation {
5 | RED1(Alliance.RED,1),
6 | RED2(Alliance.RED,2),
7 | RED3(Alliance.RED,3),
8 | BLUE1(Alliance.BLUE,1),
9 | BLUE2(Alliance.BLUE,2),
10 | BLUE3(Alliance.BLUE,3);
11 |
12 | private Alliance alliance;
13 | private int position;
14 |
15 | private TeamStation(Alliance alliance,int position) {
16 | this.alliance=alliance;
17 | this.position=position;
18 | }
19 |
20 | public Alliance getAlliance() {
21 | return alliance;
22 | }
23 |
24 | public int getPosition() {
25 | return position;
26 | }
27 |
28 | @Override
29 | public String toString() {
30 | return alliance.getName()+" "+position;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/java/FRC-DriverStation-Android/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-16
15 | android.library.reference.1=../../../../android/android-joystick
16 | android.library.reference.2=../../../../android/ActionBarSherlock/library
17 |
--------------------------------------------------------------------------------
/java/FRCDS-Java-Comm/src/main/java/org/anidev/frcds/proto/FRCCommunicationListener.java:
--------------------------------------------------------------------------------
1 | package org.anidev.frcds.proto;
2 |
3 | import org.anidev.frcds.proto.tods.FRCRobotControl;
4 | import org.anidev.frcds.proto.torobot.FRCCommonControl;
5 |
6 | /**
7 | * Listener interface for receiving data processed by the FRCCommunication
8 | * class. It can be used for receiving data from both the robot and the driver
9 | * station.
10 | *
11 | * @author Anirudh Bagde
12 | */
13 | public interface FRCCommunicationListener {
14 | /**
15 | * Called when data is received and deserialized.
16 | *
17 | * @param data
18 | * The parsed data object. This will probably be either
19 | * {@link FRCCommonControl} or {@link FRCRobotControl}.
20 | */
21 | public void receivedData(CommData data);
22 | }
23 |
--------------------------------------------------------------------------------
/java/FRC-Netconsole-PC/src/main/java/org/anidev/frcds/pc/nc/NetconsoleFrame.java:
--------------------------------------------------------------------------------
1 | package org.anidev.frcds.pc.nc;
2 |
3 | import java.awt.Dimension;
4 | import java.awt.event.WindowAdapter;
5 | import java.awt.event.WindowEvent;
6 | import javax.swing.JFrame;
7 | import org.anidev.frcds.proto.nc.Netconsole;
8 |
9 | public class NetconsoleFrame extends JFrame {
10 | private final Netconsole nc;
11 | private final NetconsolePanel netconsolePanel;
12 |
13 | public NetconsoleFrame(Netconsole _nc) {
14 | super("FRC Netconsole");
15 | this.nc=_nc;
16 | setSize(new Dimension(630,300));
17 | netconsolePanel=new NetconsolePanel(nc,true);
18 | setContentPane(netconsolePanel);
19 | addWindowListener(new WindowAdapter() {
20 | @Override
21 | public void windowClosing(WindowEvent e) {
22 | netconsolePanel.firePanelDestroyed();
23 | }
24 | });
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/java/FRC-DriverStation-Android/src/org/anidev/frcds/android/MainActivity.java:
--------------------------------------------------------------------------------
1 | package org.anidev.frcds.android;
2 |
3 | import android.os.Bundle;
4 | import com.actionbarsherlock.app.ActionBar;
5 | import com.actionbarsherlock.app.SherlockFragmentActivity;
6 | import com.actionbarsherlock.view.Menu;
7 |
8 | public class MainActivity extends SherlockFragmentActivity {
9 |
10 | @Override
11 | protected void onCreate(Bundle savedState) {
12 | super.onCreate(savedState);
13 | ActionBar actionBar=getSupportActionBar();
14 | actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
15 | actionBar.setDisplayOptions(0);
16 | }
17 |
18 | @Override
19 | public boolean onCreateOptionsMenu(Menu menu) {
20 | // Inflate the menu; this adds items to the action bar if it is present.
21 | getSupportMenuInflater().inflate(R.menu.activity_main,menu);
22 | return true;
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/java/FRC-DriverStation-Android/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/java/FRCDS-Java-Comm/src/main/java/org/anidev/frcds/proto/nc/NetconsoleMessage.java:
--------------------------------------------------------------------------------
1 | package org.anidev.frcds.proto.nc;
2 |
3 | import java.util.Calendar;
4 | import org.anidev.frcds.proto.DataDir;
5 |
6 | public class NetconsoleMessage {
7 | private final DataDir dir;
8 | private final String message;
9 | private final Calendar date;
10 |
11 | public NetconsoleMessage(DataDir dir,String message) {
12 | this.dir=dir;
13 | this.message=message;
14 | this.date=Calendar.getInstance();
15 | date.setTimeInMillis(System.currentTimeMillis());
16 | }
17 | public NetconsoleMessage(DataDir dir,String message,Calendar date) {
18 | this.dir=dir;
19 | this.message=message;
20 | this.date=date;
21 | }
22 |
23 | public DataDir getDirection() {
24 | return dir;
25 | }
26 |
27 | public String getMessage() {
28 | return message;
29 | }
30 |
31 | public Calendar getDate() {
32 | return date;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/java/FRC-DriverStation-Common/src/main/java/org/anidev/frcds/common/EnabledLoop.java:
--------------------------------------------------------------------------------
1 | package org.anidev.frcds.common;
2 |
3 | public class EnabledLoop implements Runnable {
4 | private final DriverStation ds;
5 | private long startTime=System.currentTimeMillis();
6 | private double hertz;
7 | private double delayMs;
8 | public EnabledLoop(DriverStation ds,double hertz) {
9 | this.ds=ds;
10 | this.hertz=hertz;
11 | this.delayMs=1000.0/this.hertz;
12 | }
13 | @Override
14 | public void run() {
15 | while(!Thread.interrupted()) {
16 | doElapsedTime();
17 | ds.doEnabledLoopImpl();
18 | doSendData();
19 | try {
20 | Thread.sleep((long)delayMs);
21 | } catch(InterruptedException e) {
22 | break;
23 | }
24 | }
25 | }
26 | private void doElapsedTime() {
27 | long elapsedTime=System.currentTimeMillis()-startTime;
28 | ds.setElapsedTime(elapsedTime);
29 | }
30 | private void doSendData() {
31 | ds.sendControlData();
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/java/FRC-DriverStation-Android/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | FRC-DriverStation-Android
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/java/FRC-DriverStation-Android/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
16 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/COPYING.md:
--------------------------------------------------------------------------------
1 | FRC Driver Station - free and open source implementation of an FRC driver station and communication protocol.
2 | Copyright (c) 2013, Anirudh Bagde
3 |
4 | This program is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | This program is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with this program. If not, see .
16 |
17 | Following is copyright information for resource files.
18 |
19 | arrow-up.png, arrow-down.png, status-bad.png, status-good.png
20 | These icons are part of Oxygen Icons, used and distributed
21 | here under the terms of the GNU LGPL.
22 |
--------------------------------------------------------------------------------
/java/FRCDS-Java-Comm/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 | FRCDS
6 | parent
7 | 0.2
8 |
9 | Java-Comm
10 | FRCDS Java Communication
11 | 1.0
12 | FRCDS network communication library, written in Java
13 |
14 |
15 |
16 | maven-compiler-plugin
17 | 3.1
18 |
19 | 1.7
20 | 1.7
21 |
22 |
23 |
24 |
25 |
26 |
27 | FRCDS
28 | Utils
29 | 2.0
30 |
31 |
32 |
--------------------------------------------------------------------------------
/java/Utils/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/java/FRCDS-Java-Comm/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/java/FRCDS-PacketAnalyzer/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/java/FRC-DriverStation-Common/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/java/FRC-DriverStation-Common/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 | FRCDS
6 | parent
7 | 0.2
8 |
9 | DriverStation-Common
10 | 0.3
11 | FRC DriverStation Common
12 | Common classes for creating a driver station program using the FRCDS communication library
13 |
14 |
15 |
16 | maven-compiler-plugin
17 | 3.1
18 |
19 | 1.7
20 | 1.7
21 |
22 |
23 |
24 |
25 |
26 |
27 | FRCDS
28 | Java-Comm
29 | 1.0
30 |
31 |
32 |
--------------------------------------------------------------------------------
/java/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 |
4 | FRCDS
5 | parent
6 | 0.2
7 | pom
8 |
9 |
10 |
11 | mavenrepo
12 | file://${project.basedir}/../mavenrepo
13 |
14 |
15 |
16 |
17 | UTF-8
18 | ${project.basedir}/../bin
19 |
20 |
21 |
22 | Utils
23 | FRCDS-Java-Comm
24 | FRCDS-PacketAnalyzer
25 | FRC-Netconsole-PC
26 | FRC-DriverStation-Common
27 | FRC-DriverStation-PC
28 |
29 |
30 |
--------------------------------------------------------------------------------
/java/FRC-DriverStation-PC/src/main/java/org/anidev/frcds/pc/battery/win/WindowsBatteryProvider.java:
--------------------------------------------------------------------------------
1 | package org.anidev.frcds.pc.battery.win;
2 |
3 | import org.anidev.frcds.common.types.BatteryProvider;
4 | import com.sun.jna.Native;
5 |
6 | public class WindowsBatteryProvider implements BatteryProvider {
7 | private Kernel32 kernel32=null;
8 |
9 | public WindowsBatteryProvider() {
10 | try {
11 | kernel32=(Kernel32)Native.loadLibrary("kernel32",Kernel32.class);
12 | } catch(UnsatisfiedLinkError e) {
13 | e.printStackTrace();
14 | System.err.println("Windows battery status will be unavailable.");
15 | }
16 | }
17 |
18 | @Override
19 | public double getBatteryPercent() {
20 | if(kernel32==null) {
21 | return -1.0;
22 | }
23 | PowerStatus status=new PowerStatus();
24 | kernel32.GetSystemPowerStatus(status);
25 | int flagByte=status.getBatteryFlag();
26 | int percentByte=status.getBatteryLifePercent();
27 | if(flagByte==128/*No battery*/||flagByte==255/*Unknown*/) {
28 | return -1.0;
29 | }
30 | if(percentByte==255/*Unknown*/) {
31 | return -1.0;
32 | }
33 | double percent=percentByte*1.0/100.0;
34 | return percent;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/java/Utils/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 | FRCDS
6 | parent
7 | 0.2
8 |
9 | Utils
10 | Utils
11 | 2.0
12 | Misc common functions used by FRCDS classes
13 |
14 |
15 |
16 | maven-compiler-plugin
17 | 3.1
18 |
19 | 1.7
20 | 1.7
21 |
22 |
23 |
24 |
25 |
26 |
27 | net.java.dev.jna
28 | jna
29 | 4.0.0
30 |
31 |
32 | com.kitfox.svg
33 | svg-salamander
34 | 1.0
35 |
36 |
37 |
--------------------------------------------------------------------------------
/java/FRCDS-Java-Comm/src/main/java/org/anidev/frcds/proto/CommData.java:
--------------------------------------------------------------------------------
1 | package org.anidev.frcds.proto;
2 |
3 | import java.nio.ByteOrder;
4 |
5 | public abstract class CommData {
6 | public static int SIZE=-1;
7 | public static final ByteOrder BYTE_ORDER=ByteOrder.BIG_ENDIAN;
8 |
9 | public abstract byte[] serialize();
10 |
11 | public abstract void deserialize(byte[] data);
12 |
13 | @Override
14 | public abstract int hashCode();
15 |
16 | @Override
17 | public abstract boolean equals(Object obj);
18 |
19 | protected int boolToInt(boolean bool) {
20 | return(bool?1:0);
21 | }
22 |
23 | protected boolean intToBool(int bool) {
24 | return(bool>0?true:false);
25 | }
26 |
27 | protected int[] bitsToInts(boolean[] bits) {
28 | int numInts=(int)Math.ceil(bits.length/8.0);
29 | int[] data=new int[numInts];
30 | for(int i=0;i>(7-b)));
43 | }
44 | }
45 | return bools;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/java/FRC-Netconsole-PC/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/java/FRCDS-PacketAnalyzer/src/main/java/org/anidev/frcds/analyze/FileProvider.java:
--------------------------------------------------------------------------------
1 | package org.anidev.frcds.analyze;
2 |
3 | import java.awt.Component;
4 | import java.io.File;
5 | import java.io.IOException;
6 | import java.util.Scanner;
7 | import javax.swing.JFileChooser;
8 |
9 | @SuppressWarnings("unused")
10 | public class FileProvider {
11 | private static final String KDIALOG="kdialog --getopenfilename ~";
12 | private static final String ZENITY="zenity --file-selection";
13 | private static Runtime runtime=null;
14 | public static File askForFile(Component parent) {
15 | // if(runtime==null) {
16 | // runtime=Runtime.getRuntime();
17 | // }
18 | // String filename=tryProcessSelection(KDIALOG);
19 | // if(filename==null) {
20 | // filename=tryProcessSelection(ZENITY);
21 | // }
22 | JFileChooser chooser=new JFileChooser();
23 | int ret=chooser.showOpenDialog(parent);
24 | if(ret==JFileChooser.APPROVE_OPTION) {
25 | return chooser.getSelectedFile();
26 | }
27 | return null;
28 | }
29 | private static String tryProcessSelection(String cmdline) {
30 | try {
31 | Process proc=runtime.exec(cmdline);
32 | if(proc.exitValue()!=0) {
33 | return null;
34 | }
35 | Scanner inputScanner=new Scanner(proc.getInputStream());
36 | String filename=inputScanner.nextLine();
37 | inputScanner.close();
38 | return filename;
39 | } catch(IOException e) {
40 | e.printStackTrace();
41 | return null;
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/java/FRC-DriverStation-PC/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/java/FRCDS-Java-Comm/src/main/java/org/anidev/frcds/proto/torobot/DigitalInputs.java:
--------------------------------------------------------------------------------
1 | package org.anidev.frcds.proto.torobot;
2 |
3 | import java.util.Arrays;
4 | import org.anidev.frcds.proto.CommData;
5 |
6 | public class DigitalInputs extends CommData {
7 | public static final int SIZE=1;
8 | private boolean[] inputs=new boolean[] {true,true,true,true,true,true,true,true};
9 |
10 | public boolean getInput(int index) {
11 | return inputs[index];
12 | }
13 |
14 | public void setInput(int index,boolean value) {
15 | inputs[index]=value;
16 | }
17 |
18 | public int getNumInputs() {
19 | return inputs.length;
20 | }
21 |
22 | @Override
23 | public byte[] serialize() {
24 | int data=bitsToInts(inputs)[0];
25 | return new byte[] {(byte)data};
26 | }
27 |
28 | @Override
29 | public void deserialize(byte[] data) {
30 | boolean[] inputBits=intsToBits(new int[] {data[0]&0xFF});
31 | this.inputs=inputBits;
32 | }
33 |
34 | @Override
35 | public int hashCode() {
36 | final int prime=31;
37 | int result=1;
38 | result=prime*result+Arrays.hashCode(inputs);
39 | return result;
40 | }
41 |
42 | @Override
43 | public boolean equals(Object obj) {
44 | if(this==obj) {
45 | return true;
46 | }
47 | if(obj==null) {
48 | return false;
49 | }
50 | if(getClass()!=obj.getClass()) {
51 | return false;
52 | }
53 | DigitalInputs other=(DigitalInputs)obj;
54 | if(!Arrays.equals(inputs,other.inputs)) {
55 | return false;
56 | }
57 | return true;
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/java/FRCDS-Java-Comm/src/main/java/org/anidev/frcds/proto/tods/DigitalOutputs.java:
--------------------------------------------------------------------------------
1 | package org.anidev.frcds.proto.tods;
2 |
3 | import java.util.Arrays;
4 | import org.anidev.frcds.proto.CommData;
5 |
6 | public class DigitalOutputs extends CommData {
7 | public static final int SIZE=1;
8 | private boolean[] outputs=new boolean[] {false,false,false,false,false,
9 | false,false,false};
10 |
11 | public boolean getInput(int index) {
12 | return outputs[index];
13 | }
14 |
15 | public void setInput(int index,boolean value) {
16 | outputs[index]=value;
17 | }
18 |
19 | public int getNumInputs() {
20 | return outputs.length;
21 | }
22 |
23 | @Override
24 | public byte[] serialize() {
25 | int data=bitsToInts(outputs)[0];
26 | return new byte[] {(byte)data};
27 | }
28 |
29 | @Override
30 | public void deserialize(byte[] data) {
31 | boolean[] inputBits=intsToBits(new int[] {data[0]&0xFF});
32 | this.outputs=inputBits;
33 | }
34 |
35 | @Override
36 | public int hashCode() {
37 | final int prime=31;
38 | int result=1;
39 | result=prime*result+Arrays.hashCode(outputs);
40 | return result;
41 | }
42 |
43 | @Override
44 | public boolean equals(Object obj) {
45 | if(this==obj) {
46 | return true;
47 | }
48 | if(obj==null) {
49 | return false;
50 | }
51 | if(getClass()!=obj.getClass()) {
52 | return false;
53 | }
54 | DigitalOutputs other=(DigitalOutputs)obj;
55 | if(!Arrays.equals(outputs,other.outputs)) {
56 | return false;
57 | }
58 | return true;
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/java/FRCDS-Java-Comm/src/main/java/org/anidev/frcds/proto/torobot/CRIOChecksum.java:
--------------------------------------------------------------------------------
1 | package org.anidev.frcds.proto.torobot;
2 |
3 | import java.nio.ByteBuffer;
4 | import java.nio.LongBuffer;
5 | import org.anidev.frcds.proto.CommData;
6 |
7 | public class CRIOChecksum extends CommData {
8 | public static final int SIZE=8;
9 | private long checksum;
10 |
11 | public long getChecksum() {
12 | return checksum;
13 | }
14 |
15 | public void setChecksum(long checksum) {
16 | this.checksum=checksum;
17 | }
18 |
19 | @Override
20 | public byte[] serialize() {
21 | ByteBuffer buffer=ByteBuffer.allocate(8);
22 | buffer.order(BYTE_ORDER);
23 | buffer.putLong(checksum);
24 | return buffer.array();
25 | }
26 |
27 | @Override
28 | public void deserialize(byte[] data) {
29 | ByteBuffer byteBuffer=ByteBuffer.wrap(data);
30 | byteBuffer.order(BYTE_ORDER);
31 | LongBuffer longBuffer=byteBuffer.asLongBuffer();
32 | checksum=longBuffer.get(0);
33 | }
34 |
35 | @Override
36 | public int hashCode() {
37 | final int prime=31;
38 | int result=1;
39 | result=prime*result+(int)(checksum^(checksum>>>32));
40 | return result;
41 | }
42 |
43 | @Override
44 | public boolean equals(Object obj) {
45 | if(this==obj) {
46 | return true;
47 | }
48 | if(obj==null) {
49 | return false;
50 | }
51 | if(getClass()!=obj.getClass()) {
52 | return false;
53 | }
54 | CRIOChecksum other=(CRIOChecksum)obj;
55 | if(checksum!=other.checksum) {
56 | return false;
57 | }
58 | return true;
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/java/FRCDS-Java-Comm/src/main/java/org/anidev/frcds/proto/tods/MacAddress.java:
--------------------------------------------------------------------------------
1 | package org.anidev.frcds.proto.tods;
2 |
3 | import java.net.NetworkInterface;
4 | import java.net.SocketException;
5 | import java.util.Arrays;
6 | import org.anidev.frcds.proto.CommData;
7 |
8 | public class MacAddress extends CommData {
9 | public static final int SIZE=6;
10 | private byte[] macAddress=new byte[] {0,0,0,0,0,0};
11 |
12 | public MacAddress() {
13 | try {
14 | macAddress=NetworkInterface.getNetworkInterfaces().nextElement()
15 | .getHardwareAddress();
16 | } catch (SocketException e) {
17 | e.printStackTrace();
18 | }
19 | }
20 |
21 | public byte[] getAddressBytes() {
22 | return macAddress;
23 | }
24 |
25 | public void setAddressBytes(byte[] macAddress) {
26 | this.macAddress=macAddress;
27 | }
28 |
29 | @Override
30 | public byte[] serialize() {
31 | return macAddress;
32 | }
33 |
34 | @Override
35 | public void deserialize(byte[] data) {
36 | macAddress=data;
37 | }
38 |
39 | @Override
40 | public int hashCode() {
41 | final int prime=31;
42 | int result=1;
43 | result=prime*result+Arrays.hashCode(macAddress);
44 | return result;
45 | }
46 |
47 | @Override
48 | public boolean equals(Object obj) {
49 | if(this==obj) {
50 | return true;
51 | }
52 | if(obj==null) {
53 | return false;
54 | }
55 | if(getClass()!=obj.getClass()) {
56 | return false;
57 | }
58 | MacAddress other=(MacAddress)obj;
59 | if(!Arrays.equals(macAddress,other.macAddress)) {
60 | return false;
61 | }
62 | return true;
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/java/FRC-DriverStation-PC/src/main/java/org/anidev/frcds/pc/battery/win/PowerStatus.java:
--------------------------------------------------------------------------------
1 | package org.anidev.frcds.pc.battery.win;
2 |
3 | import java.util.Arrays;
4 | import java.util.List;
5 | import com.sun.jna.Structure;
6 |
7 | public class PowerStatus extends Structure {
8 | public final byte ACLineStatus;
9 | public final byte BatteryFlag;
10 | public final byte BatteryLifePercent;
11 | public final byte Reserved1;
12 | public final int BatteryLifeTime;
13 | public final int BatteryFullLifeTime;
14 | private List fieldOrder=null;
15 | {
16 | ACLineStatus=0;
17 | BatteryFlag=0;
18 | BatteryLifePercent=0;
19 | Reserved1=0;
20 | BatteryLifeTime=0;
21 | BatteryFullLifeTime=0;
22 | }
23 |
24 | public PowerStatus() {
25 | }
26 |
27 | @Override
28 | protected List getFieldOrder() {
29 | if(fieldOrder==null) {
30 | String[] fields=new String[] {"ACLineStatus","BatteryFlag",
31 | "BatteryLifePercent","Reserved1","BatteryLifeTime",
32 | "BatteryFullLifeTime"};
33 | fieldOrder=Arrays.asList(fields);
34 | }
35 | return fieldOrder;
36 | }
37 |
38 | public int getACLineStatus() {
39 | return ACLineStatus&0xFF;
40 | }
41 |
42 | public int getBatteryFlag() {
43 | return BatteryFlag&0xFF;
44 | }
45 |
46 | public int getBatteryLifePercent() {
47 | return BatteryLifePercent&0xFF;
48 | }
49 |
50 | public int getReserved1() {
51 | return Reserved1&0xFF;
52 | }
53 |
54 | public long getBatteryLifeTime() {
55 | return BatteryLifeTime&(1l<<32);
56 | }
57 |
58 | public long getBatteryFullLifeTime() {
59 | return BatteryFullLifeTime&(1l<<32);
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/java/FRCDS-Java-Comm/src/main/java/org/anidev/frcds/proto/torobot/FPGAChecksum.java:
--------------------------------------------------------------------------------
1 | package org.anidev.frcds.proto.torobot;
2 |
3 | import java.nio.ByteBuffer;
4 | import java.nio.IntBuffer;
5 | import java.util.Arrays;
6 | import org.anidev.frcds.proto.CommData;
7 |
8 | public class FPGAChecksum extends CommData {
9 | public static final int SIZE=16;
10 | int[] checksum=new int[] {0,0,0,0};
11 |
12 | public int[] getChecksum() {
13 | return checksum;
14 | }
15 |
16 | public void setChecksum(int[] checksum) {
17 | this.checksum=checksum;
18 | }
19 |
20 | @Override
21 | public byte[] serialize() {
22 | ByteBuffer buffer=ByteBuffer.allocate(16);
23 | buffer.order(BYTE_ORDER);
24 | for(int i=0;i identList=Arrays.asList(idents);
67 | int total=0;
68 | for(Component component:components) {
69 | if(identList.contains(component.getIdentifier())) {
70 | total++;
71 | }
72 | }
73 | return total;
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/java/FRC-Netconsole-PC/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 | FRCDS
6 | parent
7 | 0.2
8 |
9 | Netconsole-PC
10 |
11 | FRCDS Netconsole for PC
12 | Netconsole GUI for PC driver station
13 |
14 |
15 |
16 | maven-compiler-plugin
17 | 3.1
18 |
19 | 1.7
20 | 1.7
21 |
22 |
23 |
24 | org.apache.maven.plugins
25 | maven-shade-plugin
26 | 1.6
27 |
28 |
29 | package
30 |
31 | shade
32 |
33 |
34 |
35 |
37 | org.anidev.frcds.pc.nc.NetconsoleMain
38 |
39 |
40 |
41 |
42 | *:*
43 |
44 | META-INF/*.SF
45 | META-INF/*.DSA
46 | META-INF/*.RSA
47 |
48 |
49 |
50 | ${project.bindir}/netconsole.jar
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | FRCDS
60 | Java-Comm
61 | 1.0
62 |
63 |
64 | FRCDS
65 | Utils
66 | 2.0
67 |
68 |
69 |
--------------------------------------------------------------------------------
/java/FRCDS-PacketAnalyzer/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 | FRCDS
6 | parent
7 | 0.2
8 |
9 | PacketAnalyzer
10 | FRCDS Packet Analyzer
11 | 1.0
12 | Simple Java program for analyzing FRCDS packets in realtime off the network or from a file
13 |
14 |
15 |
16 | maven-compiler-plugin
17 | 3.1
18 |
19 | 1.7
20 | 1.7
21 |
22 |
23 |
24 | org.apache.maven.plugins
25 | maven-shade-plugin
26 | 1.6
27 |
28 |
29 | package
30 |
31 | shade
32 |
33 |
34 |
35 |
37 | org.anidev.frcds.analyze.AnalyzerMain
38 |
39 |
40 |
41 |
42 | *:*
43 |
44 | META-INF/*.SF
45 | META-INF/*.DSA
46 | META-INF/*.RSA
47 |
48 |
49 |
50 | ${project.bindir}/analyzer.jar
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | FRCDS
60 | Java-Comm
61 | 1.0
62 |
63 |
64 | FRCDS-Libs
65 | forms
66 | 1.3.0
67 |
68 |
69 |
--------------------------------------------------------------------------------
/java/FRC-Netconsole-PC/src/main/java/org/anidev/frcds/pc/nc/ControlBar.java:
--------------------------------------------------------------------------------
1 | package org.anidev.frcds.pc.nc;
2 |
3 | import javax.swing.JToolBar;
4 | import javax.swing.SwingConstants;
5 | import java.awt.Dimension;
6 | import java.awt.event.ActionEvent;
7 | import java.awt.event.ActionListener;
8 | import java.awt.event.ItemEvent;
9 | import java.awt.event.ItemListener;
10 | import javax.swing.JButton;
11 | import org.anidev.frcds.proto.nc.Netconsole;
12 | import org.anidev.utils.Utils;
13 | import javax.swing.ButtonGroup;
14 | import javax.swing.JToggleButton;
15 |
16 | public class ControlBar extends JToolBar {
17 | private NetconsolePanel ncPanel;
18 | private Netconsole nc;
19 | private JToggleButton listButton;
20 | private JToggleButton textButton;
21 | private JToggleButton pauseButton;
22 |
23 | public ControlBar() {
24 | setBorder(null);
25 | setRollover(true);
26 | setSize(new Dimension(22,200));
27 | setOrientation(SwingConstants.VERTICAL);
28 |
29 | JButton clearButton=new JButton(Utils.getIcon("delete.png"));
30 | clearButton.addActionListener(new ActionListener() {
31 | @Override
32 | public void actionPerformed(ActionEvent e) {
33 | nc.clearMessages();
34 | }
35 | });
36 | add(clearButton);
37 |
38 | pauseButton=new JToggleButton(Utils.getIcon("pause.png"));
39 | pauseButton.addItemListener(new ItemListener() {
40 | @Override
41 | public void itemStateChanged(ItemEvent e) {
42 | ncPanel.setPaused(pauseButton.isSelected());
43 | }
44 | });
45 | add(pauseButton);
46 |
47 | addSeparator();
48 |
49 | listButton=new JToggleButton(Utils.getIcon("list.png"));
50 | listButton.addItemListener(new ItemListener() {
51 | @Override
52 | public void itemStateChanged(ItemEvent e) {
53 | ncPanel.setListMode(listButton.isSelected());
54 | }
55 | });
56 | add(listButton);
57 |
58 | textButton=new JToggleButton(Utils.getIcon("text.png"));
59 | add(textButton);
60 |
61 | ButtonGroup modeGroup=new ButtonGroup();
62 | modeGroup.add(listButton);
63 | modeGroup.add(textButton);
64 | }
65 |
66 | protected void setPanel(NetconsolePanel ncPanel) {
67 | this.ncPanel=ncPanel;
68 | }
69 |
70 | protected void setNetconsole(Netconsole nc) {
71 | this.nc=nc;
72 | }
73 |
74 | protected JToggleButton getListButton() {
75 | return listButton;
76 | }
77 |
78 | protected JToggleButton getTextButton() {
79 | return textButton;
80 | }
81 | protected JToggleButton getPauseButton() {
82 | return pauseButton;
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/java/FRC-DriverStation-PC/src/main/java/org/anidev/frcds/pc/input/trans/BasicTranslation.java:
--------------------------------------------------------------------------------
1 | package org.anidev.frcds.pc.input.trans;
2 |
3 | import java.util.ArrayList;
4 | import net.java.games.input.Component;
5 | import net.java.games.input.Controller;
6 |
7 | /**
8 | * @formatter:off
9 | * Translation for stuff common to all input types.
10 | * Specifically translates:
11 | * - Axes 1,2,3 (which are X,Y,RZ)
12 | * TODO testing to figure this translation stuff out
13 | */
14 | // @formatter:on
15 |
16 | // Actually, for now just present axes in the
17 | // order in which they appear?
18 | /**
19 | * Basic controller translation
20 | */
21 | public class BasicTranslation extends TranslationProfile {
22 | protected Component[] axes;
23 | protected Component[] buttons;
24 |
25 | /**
26 | * Create a translation with the axes and buttons of the controller
27 | * @param controller the controller to create translation for
28 | */
29 | public BasicTranslation(Controller controller) {
30 | this.controller=controller;
31 | Component[] components=controller.getComponents();
32 | ArrayList axesList=new ArrayList<>();
33 | ArrayList buttonList=new ArrayList<>();
34 | for(Component component:components) {
35 | Component.Identifier ident=component.getIdentifier();
36 | if(ident instanceof Component.Identifier.Axis) {
37 | axesList.add(component);
38 | } else {
39 | buttonList.add(component);
40 | }
41 | }
42 | this.axes=axesList.toArray(new Component[axesList.size()]);
43 | this.buttons=buttonList.toArray(new Component[buttonList.size()]);
44 | }
45 |
46 | /* (non-Javadoc)
47 | * @see org.anidev.frcds.pc.input.trans.TranslationProfile#getRawAxis(int)
48 | */
49 | @Override
50 | public float getRawAxis(int axis) {
51 | if(axis>=getNumSupportedAxes()) {
52 | return 0.0f;
53 | }
54 | return axes[axis].getPollData();
55 | }
56 |
57 | /* (non-Javadoc)
58 | * @see org.anidev.frcds.pc.input.trans.TranslationProfile#getButton(int)
59 | */
60 | @Override
61 | public boolean getButton(int button) {
62 | if(button>=getNumSupportedButtons()) {
63 | return false;
64 | }
65 | return buttons[button].getPollData()>0.5f;
66 | }
67 |
68 | /* (non-Javadoc)
69 | * @see org.anidev.frcds.pc.input.trans.TranslationProfile#getNumSupportedAxes()
70 | */
71 | @Override
72 | public int getNumSupportedAxes() {
73 | return axes.length;
74 | }
75 |
76 | /* (non-Javadoc)
77 | * @see org.anidev.frcds.pc.input.trans.TranslationProfile#getNumSupportedButtons()
78 | */
79 | @Override
80 | public int getNumSupportedButtons() {
81 | // TODO Auto-generated method stub
82 | return buttons.length;
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | FRC Driver Station
2 | =================
3 |
4 | Java implementation of the FRC driver station and communication protocol, initially in Java and later in other
5 | languages. Java was chosen because it can be ported easily to other platforms, with Android being the next goal.
6 | The entire project uses the Maven build system for compiling and packaging. To build the entire project from
7 | scratch and create the JAR files, run "mvn clean compile package" from the java/ subdirectory, or from an
8 | individual project directory to compile and package just that project. Everything can also be imported into
9 | Eclipse and compiled from there (with the m2eclipse plugin).
10 |
11 | Currently, FRCDS-Java-Comm is the Java library for the communication protocol. It implements classes for encapsulating
12 | data that can be sent from the driver station to the robot (FRCCommonControl), and data that can be sent from the
13 | robot to the driver station (FRCRobotControl) though that protocol hasn't been fully reversed yet. Each of these two
14 | classes contain fields for simple data and other classes for more complicated types of data, some of which are shared
15 | between the two protocols. Each of these classes including the two main classes all extend CommData and all implement
16 | methods for serializing directly to a byte array and deserializing directly from a byte array, as well as automatically
17 | generated equals and hashCode methods. Also included is a class that takes care of all the network communication that
18 | sends and receives data on dedicated threads so the main flow of the program isn't interrupted.
19 |
20 | FRC-DriverStation-Common contains a few classes for implementing a driver station on any platform. The two main classes
21 | it contains are an abstract class to encapsulate the driver station and a class that is meant to be run in a
22 | dedicated loop and performs such actions as incrementing the elapsed time counter and sending data packets at a
23 | given frequency (default 50.0Hz).
24 |
25 | FRC-DriverStation-PC is the driver station implementation for PC. It uses the classes in Common and builds a GUI
26 | around it. The GUI is powered by Swing, using the Nimbus L&F. It uses the JGoodies FormLayout for laying out certain
27 | GUI components. FormLayout is included in this repository and is automatically used by Maven when building.
28 |
29 | FRC-Netconsole-PC contains the GUI-related classes for Netconsole. It generates the standalone netconsole JAR file, and
30 | is used by FRC-DriverStation-PC to provide an embedded Netconsole panel.
31 |
32 | FRC-DriverStation-Android is the driver station implementation for Android. It also uses the classes in Common and builds
33 | an Android app around it. The app is targeted for 4.1.2 Jellybean (API 16) and has compliance down to 2.3.3 Gingerbread
34 | (API 9). It uses ActionBarSherlock to achieve a consistent look down to Gingerbread and android-joystick to provide onscreen
35 | joysticks.
36 |
--------------------------------------------------------------------------------
/java/FRC-DriverStation-PC/src/main/java/org/anidev/frcds/pc/input/InputDevice.java:
--------------------------------------------------------------------------------
1 | package org.anidev.frcds.pc.input;
2 |
3 | import net.java.games.input.Component;
4 | import net.java.games.input.Controller;
5 | import org.anidev.frcds.pc.input.trans.BasicTranslation;
6 | import org.anidev.frcds.pc.input.trans.TranslationProfile;
7 | import org.anidev.frcds.proto.torobot.Joystick;
8 |
9 | /**
10 | * Device that gives input to the driver station
11 | */
12 | public class InputDevice {
13 | private final Type type;
14 | private final Controller controller;
15 | private TranslationProfile trans;
16 |
17 | /**
18 | * @param controller the controller to pass to the super constructor
19 | */
20 | public InputDevice(Controller controller) {
21 | this(controller,null);
22 | }
23 |
24 | /**
25 | * @param controller the controller that is being used for the driver station
26 | * @param trans the translation profile for the input device
27 | */
28 | public InputDevice(Controller controller,TranslationProfile trans) {
29 | this.controller=controller;
30 | this.trans=trans;
31 | this.type=determineType(controller);
32 | if(trans==null) {
33 | this.trans=getTranslationForType(this.controller,this.type);
34 | }
35 | }
36 |
37 | /**
38 | * @return the type of input device
39 | */
40 | public Type getType() {
41 | return type;
42 | }
43 |
44 | /**
45 | * @return the controller that is being used for the driver station
46 | */
47 | public Controller getController() {
48 | return controller;
49 | }
50 |
51 | /**
52 | * @return the translation profile for the input device
53 | */
54 | public TranslationProfile getTranslation() {
55 | return trans;
56 | }
57 |
58 | /**
59 | * @param joy the joystick to populate
60 | */
61 | public void populateJoystick(Joystick joy) {
62 | trans.populateJoystick(joy);
63 | }
64 |
65 | /**
66 | * @param controller the controller to determine the type of
67 | * @return the type of the controller
68 | */
69 | public static Type determineType(Controller controller) {
70 | if(controller.getType()==Controller.Type.STICK) {
71 | return Type.JOYSTICK;
72 | }
73 | Component[] components=controller.getComponents();
74 | int numAxes=0;
75 | for(Component component:components) {
76 | Component.Identifier id=component.getIdentifier();
77 | if((id instanceof Component.Identifier.Axis)
78 | &&id!=Component.Identifier.Axis.POV) {
79 | numAxes++;
80 | }
81 | }
82 | if(numAxes==4) {
83 | return Type.GAMEPAD4;
84 | } else if(numAxes==6) {
85 | return Type.GAMEPAD6;
86 | }
87 | return Type.UNKNOWN;
88 | }
89 |
90 | /**
91 | * @param controller the controller to get a translation profile for
92 | * @param type the Type
93 | * @return a TranslationProfile for the controller
94 | */
95 | public static TranslationProfile getTranslationForType(Controller controller,Type type) {
96 | return new BasicTranslation(controller);
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/java/FRCDS-Java-Comm/src/main/java/org/anidev/frcds/proto/torobot/Joystick.java:
--------------------------------------------------------------------------------
1 | package org.anidev.frcds.proto.torobot;
2 |
3 | import java.util.Arrays;
4 | import org.anidev.frcds.proto.CommData;
5 |
6 | public class Joystick extends CommData {
7 | public static final int SIZE=8;
8 | public static final int NUM_AXES=6;
9 | public static final int NUM_BUTTONS=12;
10 | // 6 axes of motion, each a signed byte/int8
11 | byte[] axes=new byte[] {0,0,0,0,0,0};
12 | // 12 buttons max, stored in 16 bits with left 4 bits ignored
13 | boolean[] buttons=new boolean[] {false,false,false,false,false,false,false,
14 | false,false,false,false,false};
15 |
16 | public byte getAxis(int index) {
17 | return axes[index];
18 | }
19 |
20 | public void setAxis(int index,byte value) {
21 | axes[index]=value;
22 | }
23 |
24 | public int getNumAxes() {
25 | return axes.length;
26 | }
27 |
28 | public boolean getButton(int index) {
29 | return buttons[index];
30 | }
31 |
32 | public void setButton(int index,boolean value) {
33 | buttons[index]=value;
34 | }
35 |
36 | public int getNumButtons() {
37 | return buttons.length;
38 | }
39 |
40 | @Override
41 | public byte[] serialize() {
42 | byte[] data=new byte[8];
43 | for(int i=0;i>4);
51 | data[7]=(byte)bitsToInts(buttons2)[0];
52 | return data;
53 | }
54 |
55 | @Override
56 | public void deserialize(byte[] data) {
57 | for(int i=0;i<6;i++) {
58 | axes[i]=data[i];
59 | }
60 | boolean[] buttonBits=intsToBits(new int[] {(int)data[6],(int)data[7]});
61 | buttonBits=Arrays.copyOfRange(buttonBits,4,16);
62 | reverseBits(buttonBits);
63 | this.buttons=buttonBits;
64 | }
65 |
66 | @Override
67 | public int hashCode() {
68 | final int prime=31;
69 | int result=1;
70 | result=prime*result+Arrays.hashCode(axes);
71 | result=prime*result+Arrays.hashCode(buttons);
72 | return result;
73 | }
74 |
75 | @Override
76 | public boolean equals(Object obj) {
77 | if(this==obj) {
78 | return true;
79 | }
80 | if(obj==null) {
81 | return false;
82 | }
83 | if(getClass()!=obj.getClass()) {
84 | return false;
85 | }
86 | Joystick other=(Joystick)obj;
87 | if(!Arrays.equals(axes,other.axes)) {
88 | return false;
89 | }
90 | if(!Arrays.equals(buttons,other.buttons)) {
91 | return false;
92 | }
93 | return true;
94 | }
95 |
96 | private static boolean[] reverseBits(boolean[] bits) {
97 | for(int i=0;i
3 | 4.0.0
4 |
5 | FRCDS
6 | parent
7 | 0.2
8 |
9 | DriverStation-PC
10 | 0.3
11 | FRC DriverStation PC
12 | A driver station program for PC, written in Java, that uses the FRCDS communication library
13 |
14 | ${project.basedir}/targets/natives/
15 | natives/
16 |
17 |
18 |
19 |
20 | maven-compiler-plugin
21 | 3.1
22 |
23 | 1.7
24 | 1.7
25 |
26 |
27 |
28 | com.googlecode.mavennatives
29 | maven-nativedependencies-plugin
30 | 0.0.7
31 |
32 |
33 | unpacknatives
34 | generate-resources
35 |
36 | copy
37 |
38 |
39 |
40 |
41 |
42 | org.apache.maven.plugins
43 | maven-shade-plugin
44 | 1.6
45 |
46 |
47 | package
48 |
49 | shade
50 |
51 |
52 |
53 |
55 | org.anidev.frcds.pc.DriverStationMain
56 |
57 |
58 |
59 |
60 | *:*
61 |
62 | META-INF/*.SF
63 | META-INF/*.DSA
64 | META-INF/*.RSA
65 |
66 |
67 |
68 | ${project.bindir}/driverstation-pc.jar
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 | FRCDS
78 | DriverStation-Common
79 | 0.3
80 |
81 |
82 | FRCDS
83 | Netconsole-PC
84 | 0.2
85 |
86 |
87 | FRCDS
88 | Java-Comm
89 | 1.0
90 |
91 |
92 | FRCDS
93 | Utils
94 | 2.0
95 |
96 |
97 | FRCDS-Libs
98 | forms
99 | 1.3.0
100 |
101 |
102 | net.java.dev.jna
103 | jna
104 | 4.0.0
105 |
106 |
107 | net.java.jinput
108 | jinput
109 | 2.0.5
110 |
111 |
112 |
--------------------------------------------------------------------------------
/java/FRC-DriverStation-PC/src/main/java/org/anidev/frcds/pc/gui/EnhancedToggleButton.java:
--------------------------------------------------------------------------------
1 | package org.anidev.frcds.pc.gui;
2 |
3 | import java.awt.Color;
4 | import java.awt.Font;
5 | import java.awt.Graphics;
6 | import java.awt.Graphics2D;
7 | import java.awt.Paint;
8 | import java.awt.Rectangle;
9 | import java.awt.event.ItemEvent;
10 | import java.awt.event.ItemListener;
11 | import javax.swing.JToggleButton;
12 | import org.anidev.utils.Utils;
13 |
14 | /**
15 | * JToggleButton used for enable and disable
16 | */
17 | class EnhancedToggleButton extends JToggleButton implements
18 | ItemListener {
19 | private Color origColor;
20 | private Color selectedColor;
21 | private EnhancedToggleButton.BorderCollapse borderCollapse;
22 | private Paint borderColor=null;
23 | private static final int BORDER_SIZE=4;
24 | private static final int BORDER_PADDING=2;
25 | private static final int BORDER_TRANSLATE=BORDER_SIZE+BORDER_PADDING;
26 |
27 | /**
28 | * Set the appearence of the button
29 | * @param text the String displayed on the button
30 | * @param overlayColor the color of the overlay
31 | * @param selectedAlpha the alpha value
32 | * @param border BorderCollapse so the border can be put in the right place
33 | */
34 | public EnhancedToggleButton(String text,Color overlayColor,
35 | double selectedAlpha,EnhancedToggleButton.BorderCollapse border) {
36 | super(text);
37 | this.borderCollapse=border;
38 | this.origColor=getBackground();
39 | selectedColor=Utils.calcAlpha(selectedAlpha,overlayColor,origColor);
40 | setFont(new Font("Arial",Font.BOLD,12));
41 | addItemListener(this);
42 | changeState(isSelected());
43 | Object borderPref=Utils.getNimbusPref("nimbusBorder",this);
44 | if(borderPref!=null&&borderPref instanceof Paint) {
45 | borderColor=(Paint)borderPref;
46 | }
47 | }
48 |
49 | /* (non-Javadoc)
50 | * @see javax.swing.AbstractButton#setSelected(boolean)
51 | */
52 | public void setSelected(boolean selected) {
53 | super.setSelected(selected);
54 | changeState(selected);
55 | }
56 |
57 | /**
58 | * Changes the background and foreground colors
59 | * @param selected whether or not the button is selected
60 | */
61 | public void changeState(boolean selected) {
62 | if(selected) {
63 | setBackground(selectedColor);
64 | setForeground(null);
65 | } else {
66 | setBackground(null);
67 | setForeground(selectedColor);
68 | }
69 | }
70 |
71 | /* (non-Javadoc)
72 | * @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
73 | */
74 | @Override
75 | public void paintComponent(Graphics g) {
76 | Rectangle bounds=g.getClipBounds();
77 | switch(borderCollapse) {
78 | case BOTTOM:
79 | g.translate(0,BORDER_TRANSLATE);
80 | break;
81 | case TOP:
82 | g.translate(0,-BORDER_TRANSLATE);
83 | break;
84 | default:
85 | }
86 | super.paintComponent(g);
87 | g.setClip(bounds);
88 | if(borderColor!=null&&g instanceof Graphics2D) {
89 | Graphics2D g2d=(Graphics2D)g;
90 | g2d.setPaint(borderColor);
91 | int minX=bounds.x+BORDER_SIZE;
92 | int maxX=bounds.x+bounds.width-BORDER_SIZE;
93 | int minY=bounds.y+BORDER_SIZE;
94 | int maxY=bounds.y+bounds.height-BORDER_SIZE;
95 | switch(borderCollapse) {
96 | case BOTTOM:
97 | g.drawLine(minX,maxY-BORDER_PADDING,maxX,maxY
98 | -BORDER_PADDING);
99 | break;
100 | case TOP:
101 | g.drawLine(minX,minY+BORDER_PADDING,maxX,minY
102 | +BORDER_PADDING);
103 | break;
104 | case NONE:
105 | }
106 | }
107 | }
108 |
109 | /* (non-Javadoc)
110 | * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
111 | */
112 | @Override
113 | public void itemStateChanged(ItemEvent e) {
114 | if(!(e.getSource() instanceof EnhancedToggleButton)) {
115 | return;
116 | }
117 | EnhancedToggleButton button=(EnhancedToggleButton)e.getSource();
118 | button.changeState(e.getStateChange()==ItemEvent.SELECTED);
119 | }
120 |
121 | /**
122 | * Where to have a border
123 | */
124 | public static enum BorderCollapse {
125 | NONE,
126 | BOTTOM,
127 | TOP;
128 | }
129 | }
--------------------------------------------------------------------------------
/java/Utils/src/main/java/org/anidev/utils/GTKIconTheme.java:
--------------------------------------------------------------------------------
1 | package org.anidev.utils;
2 |
3 | import java.awt.Image;
4 | import java.io.File;
5 | import java.io.IOException;
6 | import java.lang.reflect.InvocationTargetException;
7 | import java.lang.reflect.Method;
8 | import java.net.URI;
9 | import java.util.HashMap;
10 | import javax.imageio.ImageIO;
11 | import javax.swing.Icon;
12 | import javax.swing.ImageIcon;
13 | import com.kitfox.svg.app.beans.SVGIcon;
14 | import com.sun.jna.Native;
15 | import com.sun.jna.Pointer;
16 |
17 | public class GTKIconTheme {
18 | private static final int GTK_ICON_LOOKUP_GENERIC_FALLBACK=1<<3;
19 | private static final HashMap ICON_MAP=new HashMap<>();
20 | private static Pointer theme=null;
21 | private static boolean initFailed=false;
22 | static {
23 | addIcon("arrow-up",",go-up",16);
24 | addIcon("arrow-down",",go-down",16);
25 | addIcon("delete","edit-delete",22);
26 | addIcon("pause","media-playback-pause",22);
27 | addIcon("list","view-list-details",22);
28 | addIcon("text","utilities-terminal",22);
29 | addIcon("status-bad","dialog-cancel",16);
30 | addIcon("status-good","dialog-ok",16);
31 | init();
32 | }
33 |
34 | private static void addIcon(String name,String id,int size) {
35 | if(id.equals("")) {
36 | id=name;
37 | } else if(id.startsWith(",")) {
38 | id=name+id;
39 | }
40 | IconInfo info=new IconInfo(id,size);
41 | ICON_MAP.put(name,info);
42 | }
43 |
44 | public static Icon findIcon(String name) {
45 | if(name==null||"".equals(name)) {
46 | return null;
47 | }
48 | int dotIndex=name.lastIndexOf('.');
49 | if(dotIndex>-1) {
50 | name=name.substring(0,dotIndex);
51 | }
52 | IconInfo info=ICON_MAP.get(name);
53 | if(info==null) {
54 | return null;
55 | }
56 | return info.cachedIcon;
57 | }
58 |
59 | private static Icon loadIcon(IconInfo info) {
60 | String[] ids=info.id.split(",");
61 | for(String id:ids) {
62 | Pointer infoPtr=gtk_icon_theme_lookup_icon(theme,id,info.size,
63 | GTK_ICON_LOOKUP_GENERIC_FALLBACK);
64 | if(infoPtr==null) {
65 | continue;
66 | }
67 | String filename=gtk_icon_info_get_filename(infoPtr);
68 | try {
69 | Icon icon=null;
70 | if(filename.toLowerCase().endsWith(".svg")) {
71 | icon=loadSVG(filename);
72 | } else {
73 | Image image=ImageIO.read(new File(filename));
74 | icon=new ImageIcon(image);
75 | }
76 | if(icon==null) {
77 | continue;
78 | }
79 | return icon;
80 | } catch(IOException e) {
81 | continue;
82 | }
83 | }
84 | System.out.println("Did not find "+info.id);
85 | return null;
86 | }
87 |
88 | private static void init() {
89 | if(initFailed) {
90 | return;
91 | }
92 | if(theme!=null) {
93 | return;
94 | }
95 | try {
96 | Class> XToolkit=Class.forName("sun.awt.X11.XToolkit");
97 | Object toolkit=XToolkit.newInstance();
98 | Method loadGTK=XToolkit.getMethod("loadGTK");
99 | loadGTK.invoke(toolkit);
100 | try {
101 | Native.register("gtk-x11-2.0");
102 | } catch(UnsatisfiedLinkError e) {
103 | initFailed=true;
104 | return;
105 | }
106 | theme=gtk_icon_theme_get_default();
107 | for(IconInfo info:ICON_MAP.values()) {
108 | info.cachedIcon=loadIcon(info);
109 | }
110 | Method unloadGTK=XToolkit.getMethod("unload_gtk");
111 | unloadGTK.invoke(toolkit);
112 | } catch(ClassNotFoundException|InstantiationException
113 | |IllegalAccessException|NoSuchMethodException|SecurityException
114 | |IllegalArgumentException|InvocationTargetException e1) {
115 | initFailed=true;
116 | return;
117 | }
118 | }
119 |
120 | private static SVGIcon loadSVG(String filename) {
121 | URI uri=new File(filename).toURI();
122 | SVGIcon icon=new SVGIcon();
123 | icon.setAntiAlias(true);
124 | icon.setSvgURI(uri);
125 | return icon;
126 | }
127 |
128 | private static native Pointer gtk_icon_theme_get_default();
129 |
130 | private static native Pointer gtk_icon_theme_lookup_icon(Pointer theme,
131 | String id,int size,int flags);
132 |
133 | private static native String gtk_icon_info_get_filename(Pointer iconInfo);
134 |
135 | private static class IconInfo {
136 | public String id;
137 | public int size;
138 | public Icon cachedIcon=null;
139 |
140 | public IconInfo(String id,int size) {
141 | this.id=id;
142 | this.size=size;
143 | }
144 | }
145 | }
146 |
--------------------------------------------------------------------------------
/java/FRCDS-Java-Comm/src/main/java/org/anidev/frcds/proto/ControlFlags.java:
--------------------------------------------------------------------------------
1 | package org.anidev.frcds.proto;
2 |
3 | import org.anidev.frcds.proto.torobot.OperationMode;
4 |
5 | public class ControlFlags extends CommData {
6 | public static final int SIZE=1;
7 | private boolean reset=false;
8 | private boolean notEStop=true;
9 | private boolean enabled=false;
10 | private boolean autonomous=false;
11 | private boolean fmsAttached=false;
12 | private boolean resync=false;
13 | private boolean test=false;
14 | private boolean checkVersions=false;
15 |
16 | public boolean isReset() {
17 | return reset;
18 | }
19 |
20 | public void setReset(boolean reset) {
21 | this.reset=reset;
22 | }
23 |
24 | public boolean isNotEStop() {
25 | return notEStop;
26 | }
27 |
28 | public void setNotEStop(boolean notEStop) {
29 | this.notEStop=notEStop;
30 | }
31 |
32 | public boolean isEnabled() {
33 | return enabled;
34 | }
35 |
36 | public void setEnabled(boolean enabled) {
37 | this.enabled=enabled;
38 | }
39 |
40 | public boolean isAutonomous() {
41 | return autonomous;
42 | }
43 |
44 | public void setAutonomous(boolean autonomous) {
45 | this.autonomous=autonomous;
46 | if(autonomous) {
47 | this.test=false;
48 | }
49 | }
50 |
51 | public boolean isFmsAttached() {
52 | return fmsAttached;
53 | }
54 |
55 | public void setFmsAttached(boolean fmsAttached) {
56 | this.fmsAttached=fmsAttached;
57 | }
58 |
59 | public boolean isResync() {
60 | return resync;
61 | }
62 |
63 | public void setResync(boolean resync) {
64 | this.resync=resync;
65 | }
66 |
67 | public boolean isTest() {
68 | return test;
69 | }
70 |
71 | public void setTest(boolean test) {
72 | this.test=test;
73 | if(test) {
74 | this.autonomous=false;
75 | }
76 | }
77 |
78 | public boolean isCheckVersions() {
79 | return checkVersions;
80 | }
81 |
82 | public void setCheckVersions(boolean checkVersions) {
83 | this.checkVersions=checkVersions;
84 | }
85 |
86 | public OperationMode getOperationMode() {
87 | if(autonomous) {
88 | return OperationMode.AUTONOMOUS;
89 | } else if(test) {
90 | return OperationMode.TEST;
91 | } else {
92 | return OperationMode.TELEOPERATED;
93 | }
94 | }
95 |
96 | public void setOperationMode(OperationMode mode) {
97 | autonomous=OperationMode.AUTONOMOUS.equals(mode);
98 | test=OperationMode.TEST.equals(mode);
99 | }
100 |
101 | @Override
102 | public byte[] serialize() {
103 | return serialize(DataDir.TOROBOT);
104 | }
105 |
106 | public byte[] serialize(DataDir dir) {
107 | int data=-1;
108 | if(dir==DataDir.TOROBOT) {
109 | data=bitsToInts(new boolean[] {reset,notEStop,enabled,
110 | autonomous,fmsAttached,resync,test,checkVersions})[0];
111 | } else {
112 | data=bitsToInts(new boolean[] {checkVersions,test,resync,
113 | fmsAttached,autonomous,enabled,notEStop,reset})[0];
114 | }
115 | return new byte[] {(byte)data};
116 | }
117 |
118 | @Override
119 | public void deserialize(byte[] data) {
120 | deserialize(data,DataDir.TOROBOT);
121 | }
122 |
123 | public void deserialize(byte[] data,DataDir dir) {
124 | boolean[] flags=intsToBits(new int[] {data[0]&0xFF});
125 | if(dir==DataDir.TOROBOT) {
126 | reset=flags[0];
127 | notEStop=flags[1];
128 | enabled=flags[2];
129 | autonomous=flags[3];
130 | fmsAttached=flags[4];
131 | resync=flags[5];
132 | test=flags[6];
133 | checkVersions=flags[7];
134 | } else {
135 | // TODO Figure out if this is accurate...
136 | // If it is, then its just the opposite of above
137 | checkVersions=flags[0];
138 | test=flags[1];
139 | resync=flags[2];
140 | fmsAttached=flags[3];
141 | autonomous=flags[4];
142 | enabled=flags[5];
143 | notEStop=flags[6];
144 | reset=flags[7];
145 | }
146 | }
147 |
148 | @Override
149 | public int hashCode() {
150 | final int prime=31;
151 | int result=1;
152 | result=prime*result+(autonomous?1231:1237);
153 | result=prime*result+(checkVersions?1231:1237);
154 | result=prime*result+(enabled?1231:1237);
155 | result=prime*result+(fmsAttached?1231:1237);
156 | result=prime*result+(notEStop?1231:1237);
157 | result=prime*result+(reset?1231:1237);
158 | result=prime*result+(resync?1231:1237);
159 | result=prime*result+(test?1231:1237);
160 | return result;
161 | }
162 |
163 | @Override
164 | public boolean equals(Object obj) {
165 | if(this==obj) {
166 | return true;
167 | }
168 | if(obj==null) {
169 | return false;
170 | }
171 | if(getClass()!=obj.getClass()) {
172 | return false;
173 | }
174 | ControlFlags other=(ControlFlags)obj;
175 | if(autonomous!=other.autonomous) {
176 | return false;
177 | }
178 | if(checkVersions!=other.checkVersions) {
179 | return false;
180 | }
181 | if(enabled!=other.enabled) {
182 | return false;
183 | }
184 | if(fmsAttached!=other.fmsAttached) {
185 | return false;
186 | }
187 | if(notEStop!=other.notEStop) {
188 | return false;
189 | }
190 | if(reset!=other.reset) {
191 | return false;
192 | }
193 | if(resync!=other.resync) {
194 | return false;
195 | }
196 | if(test!=other.test) {
197 | return false;
198 | }
199 | return true;
200 | }
201 | }
202 |
--------------------------------------------------------------------------------
/java/Utils/src/main/java/org/anidev/utils/Utils.java:
--------------------------------------------------------------------------------
1 | package org.anidev.utils;
2 |
3 | import java.awt.Color;
4 | import java.awt.Font;
5 | import java.awt.Image;
6 | import java.io.File;
7 | import java.io.FileNotFoundException;
8 | import java.io.FileOutputStream;
9 | import java.io.IOException;
10 | import java.io.InputStream;
11 | import java.io.OutputStream;
12 | import java.net.URL;
13 | import java.text.NumberFormat;
14 | import java.util.Enumeration;
15 | import java.util.prefs.Preferences;
16 | import javax.imageio.ImageIO;
17 | import javax.swing.AbstractButton;
18 | import javax.swing.ButtonGroup;
19 | import javax.swing.Icon;
20 | import javax.swing.ImageIcon;
21 | import javax.swing.JComponent;
22 | import javax.swing.UIDefaults;
23 | import javax.swing.UIManager;
24 |
25 | public class Utils {
26 | public static final String TMPDIR;
27 | static {
28 | String separator=System.getProperty("file.separator");
29 | StringBuilder tmpPathBuilder=new StringBuilder();
30 | tmpPathBuilder.append(System.getProperty("java.io.tmpdir"));
31 | tmpPathBuilder.append(separator);
32 | tmpPathBuilder.append("FRCDS-files");
33 | tmpPathBuilder.append(separator);
34 | TMPDIR=tmpPathBuilder.toString();
35 | }
36 |
37 | public static int calcAlpha(double alpha,int newColor,int oldColor) {
38 | return (int)Math.round(alpha*newColor+(1-alpha)*oldColor);
39 | }
40 |
41 | public static Color calcAlpha(double alpha,Color newColor,Color oldColor) {
42 | int calcR=calcAlpha(alpha,newColor.getRed(),oldColor.getRed());
43 | int calcG=calcAlpha(alpha,newColor.getGreen(),oldColor.getGreen());
44 | int calcB=calcAlpha(alpha,newColor.getBlue(),oldColor.getBlue());
45 | return new Color(calcR,calcG,calcB);
46 | }
47 |
48 | public static AbstractButton getSelectedButton(ButtonGroup group) {
49 | Enumeration buttons=group.getElements();
50 | while(buttons.hasMoreElements()) {
51 | AbstractButton button=buttons.nextElement();
52 | if(button.isSelected()) {
53 | return button;
54 | }
55 | }
56 | return null;
57 | }
58 |
59 | public static Icon getIcon(String name) {
60 | Icon icon=GTKIconTheme.findIcon(name);
61 | if(icon!=null) {
62 | return icon;
63 | }
64 | try {
65 | URL imageUrl=Utils.class.getResource("/"+name);
66 | if(imageUrl==null) {
67 | return null;
68 | }
69 | Image image=ImageIO.read(imageUrl);
70 | icon=new ImageIcon(image);
71 | return icon;
72 | } catch(IOException e) {
73 | e.printStackTrace();
74 | return null;
75 | }
76 | }
77 |
78 | public static Preferences getPrefs(Class> cls) {
79 | return Preferences.userNodeForPackage(cls);
80 | }
81 |
82 | public static Object getNimbusPref(String key,JComponent c) {
83 | UIDefaults uiValues=UIManager.getLookAndFeelDefaults();
84 | Object overrides=c.getClientProperty("Nimbus.Overrides");
85 | Object pref=null;
86 | if(overrides!=null&&overrides instanceof UIDefaults) {
87 | pref=((UIDefaults)overrides).get(key);
88 | }
89 | if(pref==null) {
90 | pref=uiValues.get(key);
91 | }
92 | return pref;
93 | }
94 |
95 | public static void setLookAndFeel() {
96 | String lafStr=System.getProperty("anidev.pcds.laf","");
97 | switch(lafStr) {
98 | case "":
99 | lafStr="com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel";
100 | break;
101 | case "":
102 | lafStr=UIManager.getSystemLookAndFeelClassName();
103 | break;
104 | case "":
105 | lafStr=UIManager.getCrossPlatformLookAndFeelClassName();
106 | break;
107 | }
108 | try {
109 | UIManager.setLookAndFeel(lafStr);
110 | } catch(Exception e) {
111 | System.err.println("Error while setting "+lafStr+" L&F.");
112 | e.printStackTrace();
113 | }
114 | }
115 |
116 | public static Font makeMonoFont(Font oldFont) {
117 | return new Font(Font.MONOSPACED,oldFont.getStyle(),oldFont.getSize());
118 | }
119 |
120 | public static File extractJarResource(String fileName) throws IOException {
121 | File file=new File(TMPDIR+fileName);
122 | file.getParentFile().mkdirs();
123 | if(file.exists()) {
124 | return file;
125 | }
126 | InputStream fileStream=Utils.class.getResourceAsStream("/"+fileName);
127 | System.out.println(fileName);
128 | if(fileStream==null) {
129 | return null;
130 | }
131 | OutputStream outStream=null;
132 | try {
133 | outStream=new FileOutputStream(file);
134 | } catch(FileNotFoundException e) {
135 | e.printStackTrace();
136 | fileStream.close();
137 | return null;
138 | }
139 | System.out.println("Extracting "+fileName+"...");
140 | int c=0;
141 | byte[] buf=new byte[256];
142 | try {
143 | while(true) {
144 | c=fileStream.read(buf);
145 | outStream.write(buf);
146 | if(cNo Robot Communication