当前位置: 首页>>代码示例>>C++>>正文


C++ wpi_setErrorWithContext函数代码示例

本文整理汇总了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));
}
开发者ID:FRC1296,项目名称:CheezyDriver2016,代码行数:8,代码来源:PWM.cpp

示例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));
}
开发者ID:FRCTeam1967,项目名称:FRCTeam1967,代码行数:11,代码来源:InterruptableSensorBase.cpp

示例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;
}
开发者ID:Talos4757,项目名称:allwpilib,代码行数:13,代码来源:CANTalon.cpp

示例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;
}
开发者ID:FRC3238,项目名称:allwpilib,代码行数:15,代码来源:InterruptableSensorBase.cpp

示例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));
}
开发者ID:frc1678,项目名称:third-party,代码行数:13,代码来源:DigitalGlitchFilter.cpp

示例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;
}
开发者ID:frc1678,项目名称:third-party,代码行数:13,代码来源:DigitalGlitchFilter.cpp

示例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;
}
开发者ID:HiceS,项目名称:synthesis,代码行数:13,代码来源:DriverStation.cpp

示例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;
}
开发者ID:FRCTeam1967,项目名称:FRCTeam1967,代码行数:13,代码来源:CANTalon.cpp

示例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;
}
开发者ID:FRCTeam1967,项目名称:FRCTeam1967,代码行数:15,代码来源:AnalogTrigger.cpp

示例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;
}
开发者ID:Talos4757,项目名称:allwpilib,代码行数:12,代码来源:CANTalon.cpp

示例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;
}
开发者ID:FRC3238,项目名称:allwpilib,代码行数:16,代码来源:PWM.cpp

示例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
}
开发者ID:adsnaider,项目名称:Robotics-Project,代码行数:62,代码来源:Encoder.cpp


注:本文中的wpi_setErrorWithContext函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。