Esempio n. 1
0
void DriverStation::joystickCallback(const msgs::ConstJoystickPtr &msg,
                                     int i)
{
    CRITICAL_REGION(m_joystickSemaphore)
    *(joysticks[i]) = *msg;
	END_REGION;
}
Esempio n. 2
0
void DriverStation::stateCallback(const msgs::ConstDriverStationPtr &msg)
{
    CRITICAL_REGION(m_stateSemaphore)
    *state = *msg;
	END_REGION;
    giveMultiWait(m_waitForDataSem);
}
/**
 * @brief Set the current error information associated with this sensor.
 * 
 * @param code The error code
 * @param filename Filename of the error source
 * @param lineNumber Line number of the error source
 */
void ErrorBase::SetError(Error::Code code, const char* filename, UINT32 lineNumber) const
{
    //  If there was an error
    if (code != 0) {
        //  Set the current error information for this object.
        error.Set(code, filename, lineNumber, this);
        // Update the global error if there is not one already set.
        CRITICAL_REGION(globalErrorMutex);
        if (globalError.GetCode() == 0) {
            globalError = error;
        }
        END_REGION
    }
Esempio n. 4
0
/**
 * The state of the buttons on the joystick.
 * 12 buttons (4 msb are unused) from the joystick.
 *
 * @param stick The joystick to read.
 * @return The state of the buttons on the joystick.
 */
short DriverStation::GetStickButtons(uint32_t stick)
{
    if (stick < 0 || stick >= 6)
	{
		wpi_setWPIErrorWithContext(ParameterOutOfRange, "stick must be between 0 and 5");
		return false;
	}
	short btns = 0, btnid;
	CRITICAL_REGION(m_joystickSemaphore)
	msgs::JoystickPtr joy = joysticks[stick];
	for (btnid = 0; btnid < joy->buttons().size() && btnid < 12; btnid++)
	{
		if (joysticks[stick]->buttons(btnid))
		{
			btns |= (1 << btnid);
		}
	}
	return btns;
	END_REGION
}