This repository has been archived by the owner on Jan 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
12ef0d4
commit feab9a2
Showing
107 changed files
with
5,107 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
|
||
evaluationDependsOn(':snobot_sim_utilities') | ||
evaluationDependsOn(':sim_adx_family') | ||
evaluationDependsOn(':sim_extension_navx') | ||
|
||
ext | ||
{ | ||
baseId = "snobot_sim_gui_javafx" | ||
} | ||
|
||
apply from: "${rootDir}/common/base_java_script.gradle" | ||
|
||
configurations { | ||
native3rdPartyDeps | ||
compile.extendsFrom(native3rdPartyDeps) | ||
} | ||
|
||
configurations.maybeCreate("wpilibNativeDeps") | ||
dependencies { | ||
|
||
compile "org.openjfx:javafx-base:11:win" | ||
compile "org.openjfx:javafx-graphics:11:win" | ||
compile "org.openjfx:javafx-controls:11:win" | ||
compile "org.openjfx:javafx-fxml:11:win" | ||
|
||
// WPILib | ||
compile 'edu.wpi.first.wpilibj:wpilibj-java:' + allwpilibVersion() | ||
compile 'edu.wpi.first.wpiutil:wpiutil-java:' + getWpiUtilVersion() | ||
compile 'edu.wpi.first.cscore:cscore-java:' + getCsCoreVersion() | ||
runtime 'edu.wpi.first.cscore:cscore-jni:' + getCsCoreVersion() + ':all' | ||
compile 'edu.wpi.first.ntcore:ntcore-java:' + getNtCoreVersion() | ||
runtime 'edu.wpi.first.ntcore:ntcore-jni:' + getNtCoreVersion() + ':all' | ||
runtime 'edu.wpi.first.hal:hal-jni:' + allwpilibVersion() + ':all' | ||
compile 'org.opencv:opencv-java:' + getWpilibOpencvVersion() | ||
runtime 'org.opencv:opencv-jni:' + getWpilibOpencvVersion() + ':all' | ||
|
||
// 3rd Party | ||
compile 'net.java.jinput:jinput:2.0.9' | ||
wpilibNativeDeps 'net.java.jinput:jinput:2.0.9:natives-all' | ||
compile 'jfree:jcommon:1.0.16' | ||
compile 'jfree:jfreechart:1.0.13' | ||
compile 'org.apache.logging.log4j:log4j-api:2.11.0' | ||
compile 'org.apache.logging.log4j:log4j-core:2.11.0' | ||
compile 'org.yaml:snakeyaml:1.18' | ||
compile 'com.miglayout:miglayout-swing:4.2' | ||
//compile 'org.python:jython:2.7.1b3' | ||
|
||
// Internal | ||
compile project(":snobot_sim_utilities") | ||
compile project(":snobot_sim_joysticks") | ||
|
||
if(build_simulator_cpp) | ||
{ | ||
compile project(":snobot_sim_jni") | ||
wpilibNativeDeps project(':snobot_sim_jni').packageNativeFiles.outputs.files | ||
} | ||
|
||
if(build_simulator_java) | ||
{ | ||
compile project(":snobot_sim_java") | ||
wpilibNativeDeps project(':sim_extension_navx').packageNativeFiles.outputs.files | ||
wpilibNativeDeps project(':sim_adx_family').packageNativeFiles.outputs.files | ||
} | ||
|
||
// Test | ||
testCompile 'org.junit.jupiter:junit-jupiter-api:5.2.0' | ||
testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.2.0' | ||
testRuntime 'org.junit.platform:junit-platform-launcher:1.2.0' | ||
runtime 'com.snobot.simulator:ctre_sim_override:' + getCtreSimVersion() + ':all' | ||
runtime 'com.snobot.simulator:rev_simulator:' + getRevRoboticsSimVersion() + ':all' | ||
} | ||
|
||
apply from: "${rootDir}/common/extract_native_libraries.gradle" | ||
test.dependsOn extract_wpilib | ||
|
||
|
||
task unzipNativeLibraries(type: Copy) { | ||
|
||
configurations.native3rdPartyDeps.each { | ||
from zipTree(it) | ||
into "build/native_libs" | ||
include "**/*.dll" | ||
include "**/*.lib" | ||
include "**/*.pdb" | ||
include "**/*.so*" | ||
include "**/*.a" | ||
include "**/*.dylib*" | ||
} | ||
|
||
includeEmptyDirs = false | ||
|
||
} | ||
|
||
eclipse.classpath.file { | ||
whenMerged { classpath -> | ||
classpath.entries.each { | ||
if(it.path.contains("jinput") && !it.path.contains("natives")) { | ||
it.setNativeLibraryLocation("snobot_sim_gui_javafx/build/native_libs") | ||
} | ||
} | ||
} | ||
} | ||
|
||
build.dependsOn unzipNativeLibraries | ||
|
||
if(build_simulator_cpp) | ||
{ | ||
compileJava.dependsOn(":snobot_sim_jni:build") | ||
} | ||
if(build_simulator_java) | ||
{ | ||
compileJava.dependsOn(":snobot_sim_java:build") | ||
} | ||
|
||
sourceSets.main.java.srcDir "${buildDir}/generated/java/" | ||
compileJava { | ||
apply from: "${rootDir}/common/create_version_file.gradle" | ||
createJavaVersion("com/snobot/simulator", "SnobotSimGuiVersion", "com.snobot.simulator", getVersionName()) | ||
} | ||
|
||
clean { | ||
delete "src/main/java/com/snobot/simulator/SnobotSimGuiVersion.java" | ||
} | ||
|
||
|
||
spotbugs { | ||
ignoreFailures = true | ||
} |
45 changes: 45 additions & 0 deletions
45
snobot_sim_gui_javafx/src/main/java/com/snobot/simulator/BaseSimulator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.snobot.simulator; | ||
|
||
import com.snobot.simulator.config.v1.SimulatorConfigReaderV1; | ||
import com.snobot.simulator.robot_container.IRobotClassContainer; | ||
|
||
/** | ||
* Base class for a custom simulator. | ||
* | ||
* @author PJ | ||
* | ||
*/ | ||
public class BaseSimulator implements ISimulatorUpdater | ||
{ | ||
private final SimulatorConfigReaderV1 mConfigReader; | ||
private String mConfigFile; | ||
|
||
protected BaseSimulator() | ||
{ | ||
mConfigReader = new SimulatorConfigReaderV1(); | ||
} | ||
|
||
public boolean loadConfig(String aConfigFile) | ||
{ | ||
mConfigFile = aConfigFile; | ||
return mConfigReader.loadConfig(mConfigFile); | ||
} | ||
|
||
|
||
@Override | ||
public void update() | ||
{ | ||
// Nothing to do | ||
} | ||
|
||
@Override | ||
public void setRobot(IRobotClassContainer aRobot) | ||
{ | ||
// Nothing to do | ||
} | ||
|
||
public String getConfigFile() | ||
{ | ||
return mConfigFile; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
snobot_sim_gui_javafx/src/main/java/com/snobot/simulator/DefaultDataAccessorFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.snobot.simulator; | ||
|
||
import com.snobot.simulator.wrapper_accessors.DataAccessorFactory; | ||
import com.snobot.simulator.wrapper_accessors.java.JavaDataAccessor; | ||
|
||
/** | ||
* Helper class that sets up the data accessor abstraction layer | ||
* | ||
* @author PJ | ||
* | ||
*/ | ||
public final class DefaultDataAccessorFactory | ||
{ | ||
private static final boolean sINITIALIZED = false; | ||
|
||
private DefaultDataAccessorFactory() | ||
{ | ||
|
||
} | ||
|
||
public static void initalize() | ||
{ | ||
if (!sINITIALIZED) | ||
{ | ||
DataAccessorFactory.setAccessor(new JavaDataAccessor()); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
snobot_sim_gui_javafx/src/main/java/com/snobot/simulator/ISimulatorUpdater.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.snobot.simulator; | ||
|
||
import com.snobot.simulator.robot_container.IRobotClassContainer; | ||
|
||
public interface ISimulatorUpdater | ||
{ | ||
|
||
public abstract void update(); | ||
|
||
public abstract void setRobot(IRobotClassContainer aRobot); | ||
} |
22 changes: 22 additions & 0 deletions
22
snobot_sim_gui_javafx/src/main/java/com/snobot/simulator/Main.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.snobot.simulator; | ||
|
||
import com.sun.javafx.application.LauncherImpl; | ||
|
||
public final class Main | ||
{ | ||
private Main() | ||
{ | ||
|
||
} | ||
|
||
public static void main(String[] aArgs) | ||
{ | ||
DefaultDataAccessorFactory.initalize(); | ||
|
||
// JavaFX 11+ uses GTK3 by default, and has problems on some display | ||
// servers | ||
// This flag forces JavaFX to use GTK2 | ||
// System.setProperty("jdk.gtk.version", "2"); | ||
LauncherImpl.launchApplication(SimulatorApplication.class, SimulatorPreloader.class, aArgs); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
snobot_sim_gui_javafx/src/main/java/com/snobot/simulator/RobotContainerFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.snobot.simulator; | ||
|
||
import java.io.File; | ||
|
||
import org.apache.logging.log4j.Level; | ||
import org.apache.logging.log4j.LogManager; | ||
|
||
import com.snobot.simulator.robot_container.CppRobotContainer; | ||
import com.snobot.simulator.robot_container.IRobotClassContainer; | ||
import com.snobot.simulator.robot_container.JavaRobotContainer; | ||
|
||
import edu.wpi.first.networktables.NetworkTableInstance; | ||
|
||
public final class RobotContainerFactory | ||
{ | ||
private RobotContainerFactory() | ||
{ | ||
|
||
} | ||
|
||
public static IRobotClassContainer createRobotContainer(File aConfigDirectory, String aRobotType, String aRobotClassName) | ||
throws ReflectiveOperationException | ||
{ | ||
LogManager.getLogger(RobotContainerFactory.class).log(Level.INFO, "Starting Robot Code"); | ||
|
||
IRobotClassContainer mRobot; | ||
|
||
if (aRobotType == null || "java".equals(aRobotType)) | ||
{ | ||
mRobot = new JavaRobotContainer(aRobotClassName); | ||
} | ||
else if ("cpp".equals(aRobotType)) | ||
{ | ||
mRobot = new CppRobotContainer(aRobotClassName); | ||
} | ||
else | ||
{ | ||
throw new RuntimeException("Unsupported robot type " + aRobotType); | ||
} | ||
|
||
mRobot.constructRobot(); | ||
|
||
// Change the network table preferences path. Need to start | ||
// the robot, stop the server and restart it | ||
NetworkTableInstance inst = NetworkTableInstance.getDefault(); | ||
inst.stopServer(); | ||
inst.startServer(aConfigDirectory.toString() + "/networktables.ini"); | ||
|
||
return mRobot; | ||
} | ||
} |
Oops, something went wrong.