Java 类edu.wpi.first.wpilibj.hal.HALUtil 实例源码
项目:Frc2016FirstStronghold
文件:DriverStation.java
/**
* DriverStation constructor.
*
* The single DriverStation instance is created statically with the instance
* static member variable.
*/
protected DriverStation() {
m_dataSem = new Object();
for (int i = 0; i < kJoystickPorts; i++) {
m_joystickButtons[i] = new HALJoystickButtons();
}
m_packetDataAvailableMutex = HALUtil.initializeMutexNormal();
m_packetDataAvailableSem = HALUtil.initializeMultiWait();
FRCNetworkCommunicationsLibrary.setNewDataSem(m_packetDataAvailableSem);
m_thread = new Thread(new DriverStationTask(this), "FRCDriverStation");
m_thread.setPriority((Thread.NORM_PRIORITY + Thread.MAX_PRIORITY) / 2);
m_thread.start();
}
项目:snobot-2017
文件:RobotStateSingleton.java
public float getMatchTime()
{
if (enabled)
{
return (HALUtil.getFPGATime() - enabled_time) * 1e-6f;
}
return 0;
}
项目:snobot-2017
文件:RobotStateSingleton.java
public void setDisabled(boolean aDisabled)
{
enabled = !aDisabled;
if (enabled)
{
enabled_time = HALUtil.getFPGATime();
}
}
项目:snobot-2017
文件:RobotStateSingleton.java
public void setAutonomous(boolean aAutonomous)
{
if (autonomous != aAutonomous)
{
enabled_time = HALUtil.getFPGATime();
}
autonomous = aAutonomous;
}
项目:Frc2016FirstStronghold
文件:DriverStation.java
/**
* Provides the service routine for the DS polling thread.
*/
private void task() {
int safetyCounter = 0;
while (m_thread_keepalive) {
HALUtil.takeMultiWait(m_packetDataAvailableSem, m_packetDataAvailableMutex);
synchronized (this) {
getData();
}
synchronized (m_dataSem) {
m_dataSem.notifyAll();
}
if (++safetyCounter >= 4) {
MotorSafetyHelper.checkMotors();
safetyCounter = 0;
}
if (m_userInDisabled) {
FRCNetworkCommunicationsLibrary.FRCNetworkCommunicationObserveUserProgramDisabled();
}
if (m_userInAutonomous) {
FRCNetworkCommunicationsLibrary.FRCNetworkCommunicationObserveUserProgramAutonomous();
}
if (m_userInTeleop) {
FRCNetworkCommunicationsLibrary.FRCNetworkCommunicationObserveUserProgramTeleop();
}
if (m_userInTest) {
FRCNetworkCommunicationsLibrary.FRCNetworkCommunicationObserveUserProgramTest();
}
}
}
项目:FakeWPILib
文件:DriverStation.java
/**
* Gets a value indicating whether the FPGA outputs are enabled. The outputs may be disabled
* if the robot is disabled or e-stopped, the watdhog has expired, or if the roboRIO browns out.
*
* @return True if the FPGA outputs are enabled.
*/
public boolean isSysActive() {
ByteBuffer status = ByteBuffer.allocateDirect(4);
status.order(ByteOrder.LITTLE_ENDIAN);
boolean retVal = FRCNetworkCommunicationsLibrary.HALGetSystemActive(status.asIntBuffer());
HALUtil.checkStatus(status.asIntBuffer());
return retVal;
}
项目:FakeWPILib
文件:DriverStation.java
/**
* Check if the system is browned out.
*
* @return True if the system is browned out
*/
public boolean isBrownedOut() {
ByteBuffer status = ByteBuffer.allocateDirect(4);
status.order(ByteOrder.LITTLE_ENDIAN);
boolean retVal = FRCNetworkCommunicationsLibrary.HALGetBrownedOut(status.asIntBuffer());
HALUtil.checkStatus(status.asIntBuffer());
return retVal;
}
项目:snobot-2017
文件:Utility.java
/**
* Return the FPGA Version number. For now, expect this to be 2009.
*
* @return FPGA Version number.
*/
@SuppressWarnings("AbbreviationAsWordInName")
int getFPGAVersion() {
return HALUtil.getFPGAVersion();
}
项目:snobot-2017
文件:Utility.java
/**
* Return the FPGA Revision number. The format of the revision is 3 numbers. The 12 most
* significant bits are the Major Revision. the next 8 bits are the Minor Revision. The 12 least
* significant bits are the Build Number.
*
* @return FPGA Revision number.
*/
@SuppressWarnings("AbbreviationAsWordInName")
long getFPGARevision() {
return (long) HALUtil.getFPGARevision();
}
项目:snobot-2017
文件:Utility.java
/**
* Read the microsecond timer from the FPGA.
*
* @return The current time in microseconds according to the FPGA.
*/
public static long getFPGATime() {
return HALUtil.getFPGATime();
}
项目:snobot-2017
文件:Utility.java
/**
* Get the state of the "USER" button on the roboRIO.
*
* @return true if the button is currently pressed down
*/
public static boolean getUserButton() {
return HALUtil.getFPGAButton();
}
项目:Frc2016FirstStronghold
文件:Utility.java
/**
* Return the FPGA Version number. For now, expect this to be 2009.
*
* @return FPGA Version number.
*/
int getFPGAVersion() {
return HALUtil.getFPGAVersion();
}
项目:Frc2016FirstStronghold
文件:Utility.java
/**
* Return the FPGA Revision number. The format of the revision is 3 numbers.
* The 12 most significant bits are the Major Revision. the next 8 bits are
* the Minor Revision. The 12 least significant bits are the Build Number.
*
* @return FPGA Revision number.
*/
long getFPGARevision() {
return (long) HALUtil.getFPGARevision();
}
项目:Frc2016FirstStronghold
文件:Utility.java
/**
* Read the microsecond timer from the FPGA.
*
* @return The current time in microseconds according to the FPGA.
*/
public static long getFPGATime() {
return HALUtil.getFPGATime();
}
项目:Frc2016FirstStronghold
文件:Utility.java
/**
* Get the state of the "USER" button on the RoboRIO
*$
* @return true if the button is currently pressed down
*/
public static boolean getUserButton() {
return HALUtil.getFPGAButton();
}