本文整理汇总了C++中wpi_setErrorWithContext函数的典型用法代码示例。如果您正苦于以下问题:C++ wpi_setErrorWithContext函数的具体用法?C++ wpi_setErrorWithContext怎么用?C++ wpi_setErrorWithContext使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpi_setErrorWithContext函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: latchPWMZero
void PWM::SetZeroLatch() {
if (StatusIsFatal()) return;
int32_t status = 0;
latchPWMZero(m_pwm_ports[m_channel], &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
示例2: wpi_assert
/**
* Disable Interrupts without without deallocating structures.
*/
void InterruptableSensorBase::DisableInterrupts()
{
if (StatusIsFatal()) return;
wpi_assert(m_interrupt != NULL);
int32_t status = 0;
disableInterrupts(m_interrupt, &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
示例3: wpi_setErrorWithContext
/**
* Returns the voltage coming in from the battery.
*
* @return The input voltage in volts.
*/
float CANTalon::GetBusVoltage() const {
double voltage;
CTR_Code status = m_impl->GetBatteryV(voltage);
if (status != CTR_OKAY) {
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
return voltage;
}
示例4: wpi_assert
/**
* Return the timestamp for the falling interrupt that occurred most recently.
* This is in the same time domain as GetClock().
* The falling-edge interrupt should be enabled with
* {@link #DigitalInput.SetUpSourceEdge}
* @return Timestamp in seconds since boot.
*/
double InterruptableSensorBase::ReadFallingTimestamp() {
if (StatusIsFatal()) return 0.0;
wpi_assert(m_interrupt != nullptr);
int32_t status = 0;
double timestamp = readFallingTimestamp(m_interrupt, &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
return timestamp;
}
示例5: setFilterPeriod
/**
* Sets the number of nanoseconds that the input must not change state for.
*
* @param nanoseconds The number of nanoseconds.
*/
void DigitalGlitchFilter::SetPeriodNanoSeconds(uint64_t nanoseconds) {
int32_t status = 0;
uint32_t fpga_cycles =
nanoseconds * kSystemClockTicksPerMicrosecond / 4 / 1000;
setFilterPeriod(m_channelIndex, fpga_cycles, &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
示例6: getFilterPeriod
/**
* Gets the number of cycles that the input must not change state for.
*
* @return The number of cycles.
*/
uint32_t DigitalGlitchFilter::GetPeriodCycles() {
int32_t status = 0;
uint32_t fpga_cycles = getFilterPeriod(m_channelIndex, &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
return fpga_cycles;
}
示例7: getVinVoltage
/**
* Read the battery voltage.
*
* @return The battery voltage in Volts.
*/
float DriverStation::GetBatteryVoltage()
{
int32_t status = 0;
float voltage = getVinVoltage(&status);
wpi_setErrorWithContext(status, "getVinVoltage");
return voltage;
}
示例8: wpi_setErrorWithContext
/**
* Returns the current error in the controller.
*
* @return the difference between the setpoint and the sensor value.
*/
int CANTalon::GetClosedLoopError() {
int error;
CTR_Code status = m_impl->GetCloseLoopErr(error);
if(status != CTR_OKAY) {
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
return error;
}
示例9: getAnalogTriggerTriggerState
/**
* Return the TriggerState output of the analog trigger.
* True if above upper limit.
* False if below lower limit.
* If in Hysteresis, maintain previous state.
* @return True if above upper limit. False if below lower limit. If in Hysteresis, maintain previous state.
*/
bool AnalogTrigger::GetTriggerState()
{
if (StatusIsFatal()) return false;
int32_t status = 0;
bool result = getAnalogTriggerTriggerState(m_trigger, &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
return result;
}
示例10: GetBusVoltage
/**
* @return The voltage being output by the Talon, in Volts.
*/
float CANTalon::GetOutputVoltage() const {
int throttle11;
CTR_Code status = m_impl->GetAppliedThrottle(throttle11);
float voltage = GetBusVoltage() * (float(throttle11) / 1023.0);
if (status != CTR_OKAY) {
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
return voltage;
}
示例11: getPWM
/**
* Get the PWM value directly from the hardware.
*
* Read a raw value from a PWM channel.
*
* @return Raw PWM control value.
*/
unsigned short PWM::GetRaw() const {
if (StatusIsFatal()) return 0;
int32_t status = 0;
unsigned short value = getPWM(m_pwm_ports[m_channel], &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
return value;
}
示例12: switch
/**
* Common initialization code for Encoders.
* This code allocates resources for Encoders and is common to all constructors.
*
* The counter will start counting immediately.
*
* @param reverseDirection If true, counts down instead of up (this is all
* relative)
* @param encodingType either k1X, k2X, or k4X to indicate 1X, 2X or 4X
* decoding. If 4X is
* selected, then an encoder FPGA object is used and the returned counts will be
* 4x the encoder
* spec'd value since all rising and falling edges are counted. If 1X or 2X are
* selected then
* a counter object will be used and the returned value will either exactly
* match the spec'd count
* or be double (2x) the spec'd count.
*/
void Encoder::InitEncoder(bool reverseDirection, EncodingType encodingType) {
m_encodingType = encodingType;
switch (encodingType) {
case k4X: {
m_encodingScale = 4;
if (m_aSource->StatusIsFatal()) {
CloneError(*m_aSource);
return;
}
if (m_bSource->StatusIsFatal()) {
CloneError(*m_bSource);
return;
}
int32_t status = 0;
m_encoder = initializeEncoder(
m_aSource->GetModuleForRouting(), m_aSource->GetChannelForRouting(),
m_aSource->GetAnalogTriggerForRouting(),
m_bSource->GetModuleForRouting(), m_bSource->GetChannelForRouting(),
m_bSource->GetAnalogTriggerForRouting(), reverseDirection, &m_index,
&status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
m_counter = nullptr;
SetMaxPeriod(.5);
break;
}
case k1X:
case k2X: {
m_encodingScale = encodingType == k1X ? 1 : 2;
m_counter = std::make_unique<Counter>(m_encodingType, m_aSource,
m_bSource, reverseDirection);
m_index = m_counter->GetFPGAIndex();
break;
}
default:
wpi_setErrorWithContext(-1, "Invalid encodingType argument");
break;
}
HALReport(HALUsageReporting::kResourceType_Encoder, m_index, encodingType);
#if FULL_WPILIB
LiveWindow::GetInstance()->AddSensor("Encoder",
m_aSource->GetChannelForRouting(), this);
#endif
}