mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +00:00
[wpilib] Remove Driverstation.waitForDsConnection (#8288)
Signed-off-by: Jade Turner <spacey-sooty@proton.me>
This commit is contained in:
@@ -575,20 +575,6 @@ std::optional<int> DriverStation::GetLocation() {
|
||||
}
|
||||
}
|
||||
|
||||
bool DriverStation::WaitForDsConnection(units::second_t timeout) {
|
||||
wpi::Event event{true, false};
|
||||
HAL_ProvideNewDataEventHandle(event.GetHandle());
|
||||
bool result = false;
|
||||
if (timeout == 0_s) {
|
||||
result = wpi::WaitForObject(event.GetHandle());
|
||||
} else {
|
||||
result = wpi::WaitForObject(event.GetHandle(), timeout.value(), nullptr);
|
||||
}
|
||||
|
||||
HAL_RemoveNewDataEventHandle(event.GetHandle());
|
||||
return result;
|
||||
}
|
||||
|
||||
units::second_t DriverStation::GetMatchTime() {
|
||||
int32_t status = 0;
|
||||
return units::second_t{HAL_GetMatchTime(&status)};
|
||||
|
||||
@@ -377,14 +377,6 @@ class DriverStation final {
|
||||
*/
|
||||
static std::optional<int> GetLocation();
|
||||
|
||||
/**
|
||||
* Wait for a DS connection.
|
||||
*
|
||||
* @param timeout timeout in seconds. 0 for infinite.
|
||||
* @return true if connected, false if timeout
|
||||
*/
|
||||
static bool WaitForDsConnection(units::second_t timeout);
|
||||
|
||||
/**
|
||||
* Return the approximate match time. The FMS does not send an official match
|
||||
* time to the robots, but does send an approximate match time. The value will
|
||||
|
||||
@@ -1218,33 +1218,6 @@ public final class DriverStation {
|
||||
return DriverStationJNI.getAllianceStation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for a DS connection.
|
||||
*
|
||||
* @param timeout timeout in seconds. 0 for infinite.
|
||||
* @return true if connected, false if timeout
|
||||
*/
|
||||
public static boolean waitForDsConnection(double timeout) {
|
||||
int event = WPIUtilJNI.createEvent(true, false);
|
||||
DriverStationJNI.provideNewDataEventHandle(event);
|
||||
boolean result;
|
||||
try {
|
||||
if (timeout == 0) {
|
||||
WPIUtilJNI.waitForObject(event);
|
||||
result = true;
|
||||
} else {
|
||||
result = !WPIUtilJNI.waitForObjectTimeout(event, timeout);
|
||||
}
|
||||
} catch (InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
result = false;
|
||||
} finally {
|
||||
DriverStationJNI.removeNewDataEventHandle(event);
|
||||
WPIUtilJNI.destroyEvent(event);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the approximate match time. The FMS does not send an official match time to the robots,
|
||||
* but does send an approximate match time. The value will count down the time remaining in the
|
||||
|
||||
Reference in New Issue
Block a user