forked from wpilibsuite/allwpilib
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[hal] Add high level way of getting systemserver NT instance (wpilibs…
- Loading branch information
Showing
16 changed files
with
169 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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,23 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
package edu.wpi.first.hal; | ||
|
||
/** | ||
* SystemServer JNI Functions. | ||
* | ||
* @see "SystemServer.h" | ||
*/ | ||
public class SystemServerJNI extends JNIWrapper { | ||
/** | ||
* Gets the system server NT handle. | ||
* | ||
* @return The system server NT handle | ||
* @see "HAL_GetSystemServerHandle" | ||
*/ | ||
public static native int getSystemServerHandle(); | ||
|
||
/** Utility class. */ | ||
private SystemServerJNI() {} | ||
} |
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,24 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
#include <jni.h> | ||
|
||
#include "edu_wpi_first_hal_SystemServerJNI.h" | ||
#include "hal/SystemServer.h" | ||
|
||
extern "C" { | ||
|
||
/* | ||
* Class: edu_wpi_first_hal_SystemServerJNI | ||
* Method: getSystemServerHandle | ||
* Signature: ()I | ||
*/ | ||
JNIEXPORT jint JNICALL | ||
Java_edu_wpi_first_hal_SystemServerJNI_getSystemServerHandle | ||
(JNIEnv*, jclass) | ||
{ | ||
return HAL_GetSystemServerHandle(); | ||
} | ||
|
||
} // extern "C" |
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,17 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
#pragma once | ||
|
||
#include <ntcore_c.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
NT_Inst HAL_GetSystemServerHandle(void); | ||
|
||
#ifdef __cplusplus | ||
} // extern "C" | ||
#endif |
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,12 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
#include "hal/SystemServer.h" | ||
|
||
extern "C" { | ||
|
||
NT_Inst HAL_GetSystemServerHandle(void) { | ||
return 0; | ||
} | ||
} // extern "C" |
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
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
File renamed without changes.
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
10 changes: 10 additions & 0 deletions
10
ntcore/src/generated/main/java/edu/wpi/first/networktables/NetworkTableInstance.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,15 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
#include "frc/SystemServer.h" | ||
|
||
#include <hal/SystemServer.h> | ||
|
||
namespace frc { | ||
|
||
nt::NetworkTableInstance SystemServer::GetSystemServer() { | ||
return nt::NetworkTableInstance{HAL_GetSystemServerHandle()}; | ||
} | ||
|
||
} // namespace frc |
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,18 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
#pragma once | ||
|
||
#include <networktables/NetworkTableInstance.h> | ||
|
||
namespace frc { | ||
|
||
class SystemServer { | ||
public: | ||
SystemServer() = delete; | ||
|
||
static nt::NetworkTableInstance GetSystemServer(); | ||
}; | ||
|
||
} // namespace frc |
23 changes: 23 additions & 0 deletions
23
wpilibj/src/main/java/edu/wpi/first/wpilibj/SystemServer.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,23 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
package edu.wpi.first.wpilibj; | ||
|
||
import edu.wpi.first.hal.SystemServerJNI; | ||
import edu.wpi.first.networktables.NetworkTableInstance; | ||
|
||
/** Class to get system server NT instance. */ | ||
public final class SystemServer { | ||
/** | ||
* Gets the system server NT Instance. | ||
* | ||
* @return NT Instance | ||
*/ | ||
public static NetworkTableInstance getSystemServer() { | ||
return NetworkTableInstance.fromNativeHandle(SystemServerJNI.getSystemServerHandle()); | ||
} | ||
|
||
/** Utility Class. */ | ||
private SystemServer() {} | ||
} |