RobotCore 1.0
WPILib port to raspberry Pi
Loading...
Searching...
No Matches
DriverStation.java
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5package org.wpilib.driverstation;
6
7import java.util.concurrent.locks.Lock;
8import java.util.concurrent.locks.ReentrantLock;
9import org.wpilib.datalog.DataLog;
10import org.wpilib.driverstation.internal.DriverStationBackend;
11
13public final class DriverStation {
14 private DriverStation() {}
15
16 private static final Lock m_dsLock = new ReentrantLock();
17 private static final GenericHID[] m_hids = new GenericHID[DriverStationBackend.JOYSTICK_PORTS];
18 private static final Gamepad[] m_gamepads = new Gamepad[DriverStationBackend.JOYSTICK_PORTS];
19
20 private static GenericHID getGenericHIDUnderLock(int port) {
21 GenericHID toRet = m_hids[port];
22 if (toRet == null) {
23 toRet = new GenericHID(port);
24 m_hids[port] = toRet;
25 }
26 return toRet;
27 }
28
36 public static GenericHID getGenericHID(int port) {
37 m_dsLock.lock();
38 try {
39 return getGenericHIDUnderLock(port);
40 } finally {
41 m_dsLock.unlock();
42 }
43 }
44
52 public static Gamepad getGamepad(int port) {
53 m_dsLock.lock();
54 try {
55 Gamepad toRet = m_gamepads[port];
56 if (toRet == null) {
57 toRet = new Gamepad(getGenericHIDUnderLock(port));
58 m_gamepads[port] = toRet;
59 }
60 return toRet;
61 } finally {
62 m_dsLock.unlock();
63 }
64 }
65
72 public static void startDataLog(DataLog log) {
74 }
75
82 public static void startDataLog(DataLog log, boolean logJoysticks) {
83 DriverStationBackend.startDataLog(log, logJoysticks);
84 }
85
94
100 public static void removeRefreshedDataEventHandle(int handle) {
102 }
103}
static void provideRefreshedDataEventHandle(int handle)
static void startDataLog(DataLog log)
static void removeRefreshedDataEventHandle(int handle)
static GenericHID getGenericHID(int port)
static void startDataLog(DataLog log, boolean logJoysticks)
static void startDataLog(DataLog log, boolean logJoysticks)