这篇教程C++ wpi_setWPIError函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中wpi_setWPIError函数的典型用法代码示例。如果您正苦于以下问题:C++ wpi_setWPIError函数的具体用法?C++ wpi_setWPIError怎么用?C++ wpi_setWPIError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了wpi_setWPIError函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: wpi_setWPIError/** * Get the value of the axis on a joystick. * This depends on the mapping of the joystick connected to the specified port. * * @param stick The joystick to read. * @param axis The analog axis value to read from the joystick. * @return The value of the axis on the joystick. */float DriverStation::GetStickAxis(uint32_t stick, uint32_t axis){ if (stick >= kJoystickPorts) { wpi_setWPIError(BadJoystickIndex); return 0; } if (axis >= m_joystickAxes[stick].count) { if (axis >= kMaxJoystickAxes) wpi_setWPIError(BadJoystickAxis); else ReportJoystickUnpluggedError("WARNING: Joystick Axis missing, check if all controllers are plugged in/n"); return 0.0f; } int8_t value = m_joystickAxes[stick].axes[axis]; if(value < 0) { return value / 128.0f; } else { return value / 127.0f; }}
开发者ID:FRCTeam1967,项目名称:FRCTeam1967,代码行数:36,
示例2: m_i2c/** * Constructor. * * @param moduleNumber The digital module that the sensor is plugged into (1 or 2). */HiTechnicColorSensor::HiTechnicColorSensor(UINT8 moduleNumber) : m_i2c (NULL){ m_table = NULL; DigitalModule *module = DigitalModule::GetInstance(moduleNumber); m_mode = kActive; if (module) { m_i2c = module->GetI2C(kAddress); // Verify Sensor const UINT8 kExpectedManufacturer[] = "HiTechnc"; const UINT8 kExpectedSensorType[] = "ColorPD "; if ( ! m_i2c->VerifySensor(kManufacturerBaseRegister, kManufacturerSize, kExpectedManufacturer) ) { wpi_setWPIError(CompassManufacturerError); return; } if ( ! m_i2c->VerifySensor(kSensorTypeBaseRegister, kSensorTypeSize, kExpectedSensorType) ) { wpi_setWPIError(CompassTypeError); } nUsageReporting::report(nUsageReporting::kResourceType_HiTechnicColorSensor, moduleNumber - 1); }}
开发者ID:FRC2539,项目名称:wpilib,代码行数:32,
示例3: sync/** * Free an allocated resource. * After a resource is no longer needed, for example a destructor is called for * a channel assignment * class, Free will release the resource value so it can be reused somewhere * else in the program. */void Resource::Free(uint32_t index) { std::unique_lock<priority_recursive_mutex> sync(m_allocateLock); if (index == std::numeric_limits<uint32_t>::max()) return; if (index >= m_isAllocated.size()) { wpi_setWPIError(NotAllocated); return; } if (!m_isAllocated[index]) { wpi_setWPIError(NotAllocated); return; } m_isAllocated[index] = false;}
开发者ID:FRC3238,项目名称:allwpilib,代码行数:20,
示例4: switch/** * Set the relay state. * * Valid values depend on which directions of the relay are controlled by the * object. * * When set to kBothDirections, the relay can be any of the four states: * 0v-0v, 0v-12v, 12v-0v, 12v-12v * * When set to kForwardOnly or kReverseOnly, you can specify the constant for * the direction or you can simply specify kOff and kOn. Using only kOff and * kOn is recommended. * * @param value The state to set the relay. */void Relay::Set(Relay::Value value) { if (StatusIsFatal()) return; int32_t status = 0; switch (value) { case kOff: if (m_direction == kBothDirections || m_direction == kForwardOnly) { HAL_SetRelay(m_forwardHandle, false, &status); } if (m_direction == kBothDirections || m_direction == kReverseOnly) { HAL_SetRelay(m_reverseHandle, false, &status); } break; case kOn: if (m_direction == kBothDirections || m_direction == kForwardOnly) { HAL_SetRelay(m_forwardHandle, true, &status); } if (m_direction == kBothDirections || m_direction == kReverseOnly) { HAL_SetRelay(m_reverseHandle, true, &status); } break; case kForward: if (m_direction == kReverseOnly) { wpi_setWPIError(IncompatibleMode); break; } if (m_direction == kBothDirections || m_direction == kForwardOnly) { HAL_SetRelay(m_forwardHandle, true, &status); } if (m_direction == kBothDirections) { HAL_SetRelay(m_reverseHandle, false, &status); } break; case kReverse: if (m_direction == kForwardOnly) { wpi_setWPIError(IncompatibleMode); break; } if (m_direction == kBothDirections) { HAL_SetRelay(m_forwardHandle, false, &status); } if (m_direction == kBothDirections || m_direction == kReverseOnly) { HAL_SetRelay(m_reverseHandle, true, &status); } break; } wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));}
开发者ID:PeterMitrano,项目名称:allwpilib,代码行数:65,
示例5: switch/** * Set the relay state. * * Valid values depend on which directions of the relay are controlled by the * object. * * When set to kBothDirections, the relay can be any of the four states: * 0v-0v, 0v-12v, 12v-0v, 12v-12v * * When set to kForwardOnly or kReverseOnly, you can specify the constant for * the * direction or you can simply specify kOff and kOn. Using only kOff and * kOn is * recommended. * * @param value The state to set the relay. */void Relay::Set(Relay::Value value) { if (StatusIsFatal()) return; int32_t status = 0; switch (value) { case kOff: if (m_direction == kBothDirections || m_direction == kForwardOnly) { setRelayForward(m_relay_ports[m_channel], false, &status); } if (m_direction == kBothDirections || m_direction == kReverseOnly) { setRelayReverse(m_relay_ports[m_channel], false, &status); } break; case kOn: if (m_direction == kBothDirections || m_direction == kForwardOnly) { setRelayForward(m_relay_ports[m_channel], true, &status); } if (m_direction == kBothDirections || m_direction == kReverseOnly) { setRelayReverse(m_relay_ports[m_channel], true, &status); } break; case kForward: if (m_direction == kReverseOnly) { wpi_setWPIError(IncompatibleMode); break; } if (m_direction == kBothDirections || m_direction == kForwardOnly) { setRelayForward(m_relay_ports[m_channel], true, &status); } if (m_direction == kBothDirections) { setRelayReverse(m_relay_ports[m_channel], false, &status); } break; case kReverse: if (m_direction == kForwardOnly) { wpi_setWPIError(IncompatibleMode); break; } if (m_direction == kBothDirections) { setRelayForward(m_relay_ports[m_channel], false, &status); } if (m_direction == kBothDirections || m_direction == kReverseOnly) { setRelayReverse(m_relay_ports[m_channel], true, &status); } break; } wpi_setErrorWithContext(status, getHALErrorMessage(status));}
开发者ID:Talos4757,项目名称:allwpilib,代码行数:67,
示例6: wpi_setWPIError/** * Validate that the data being packed will fit in the buffer. */bool Dashboard::ValidateAdd(INT32 size){ if ((m_packPtr - m_localBuffer) + size > kMaxDashboardDataSize) { wpi_setWPIError(DashboardDataOverflow); return false; } // Make sure printf is not being used at the same time. if (m_localPrintBuffer[0] != 0) { wpi_setWPIError(DashboardDataCollision); return false; } return true;}
开发者ID:FRC2539,项目名称:wpilib,代码行数:18,
示例7: wpi_setWPIError/** * Returns a boolean indicating if the controller is an xbox controller. * * @param stick The joystick port number * @return A boolean that is true if the controller is an xbox controller. */bool DriverStation::GetJoystickIsXbox(uint32_t stick) const { if (stick >= kJoystickPorts) { wpi_setWPIError(BadJoystickIndex); return false; } return (bool)m_joystickDescriptor[stick].isXbox;}
开发者ID:FRCTeam159,项目名称:MentorRepository,代码行数:13,
示例8: GetNumChannelsToActivate/** * Set the sample rate on the module. * * This is a global setting for the module and effects all channels. * * @param samplesPerSecond The number of samples per channel per second. */void AnalogModule::SetSampleRate(float samplesPerSecond){ // TODO: This will change when variable size scan lists are implemented. // TODO: Need float comparison with epsilon. //wpi_assert(!sampleRateSet || GetSampleRate() == samplesPerSecond); m_sampleRateSet = true; // Compute the convert rate UINT32 ticksPerSample = (UINT32)((float)kTimebase / samplesPerSecond); UINT32 ticksPerConversion = ticksPerSample / GetNumChannelsToActivate(); // ticksPerConversion must be at least 80 if (ticksPerConversion < 80) { wpi_setWPIError(SampleRateTooHigh); ticksPerConversion = 80; } // Atomically set the scan size and the convert rate so that the sample rate is constant tAI::tConfig config; config.ScanSize = GetNumChannelsToActivate(); config.ConvertRate = ticksPerConversion; tRioStatusCode localStatus = NiFpga_Status_Success; m_module->writeConfig(config, &localStatus); wpi_setError(localStatus); // Indicate that the scan size has been commited to hardware. SetNumChannelsToActivate(0);}
开发者ID:128keaton,项目名称:wpilib,代码行数:35,
示例9: taskNameToId/** * Start the task that is responsible for sending images to the PC. */int PCVideoServer::StartServerTask(){ if (StatusIsFatal()) { return -1; } int id = 0; m_stopServer = false; // Check for prior copy of running task int oldId = taskNameToId((char*)m_serverTask.GetName()); if(oldId != ERROR) { // TODO: Report error. You are in a bad state. taskDelete(oldId); } // spawn video server task // this is done to ensure that the task is spawned with the // floating point context save parameter. bool started = m_serverTask.Start((int)this); id = m_serverTask.GetID(); if (!started) { wpi_setWPIError(TaskError); return id; } taskDelay(1); return id;}
开发者ID:bescovedo,项目名称:becode,代码行数:34,
示例10: sync/** * Free an allocated resource. * After a resource is no longer needed, for example a destructor is called for a channel assignment * class, Free will release the resource value so it can be reused somewhere else in the program. */void Resource::Free(uint32_t index){ Synchronized sync(m_allocateLock); if (index == ~0ul) return; if (index >= m_size) { wpi_setWPIError(NotAllocated); return; } if (!m_isAllocated[index]) { wpi_setWPIError(NotAllocated); return; } m_isAllocated[index] = false;}
开发者ID:FRC2404,项目名称:year2014,代码行数:21,
示例11: wpi_setWPIError/** * Convert a voltage to a raw value for a specified channel. * * This process depends on the calibration of each channel, so the channel * must be specified. * * @todo This assumes raw values. Oversampling not supported as is. * * @param channel The channel to convert for. * @param voltage The voltage to convert. * @return The raw value for the channel. */INT32 AnalogModule::VoltsToValue(INT32 channel, float voltage){ if (voltage > 10.0) { voltage = 10.0; wpi_setWPIError(VoltageOutOfRange); } if (voltage < -10.0) { voltage = -10.0; wpi_setWPIError(VoltageOutOfRange); } UINT32 LSBWeight = GetLSBWeight(channel); INT32 offset = GetOffset(channel); INT32 value = (INT32) ((voltage + offset * 1.0e-9) / (LSBWeight * 1.0e-9)); return value;}
开发者ID:128keaton,项目名称:wpilib,代码行数:29,
示例12: wpi_setWPIError/** * Provide tank steering using the stored robot configuration. * Drive the robot using two joystick inputs. The Y-axis will be selected from * each Joystick object. * @param leftStick The joystick to control the left side of the robot. * @param rightStick The joystick to control the right side of the robot. */void RobotDrive::TankDrive(GenericHID *leftStick, GenericHID *rightStick, bool squaredInputs) { if (leftStick == nullptr || rightStick == nullptr) { wpi_setWPIError(NullParameter); return; } TankDrive(leftStick->GetY(), rightStick->GetY(), squaredInputs);}
开发者ID:FRC3238,项目名称:allwpilib,代码行数:15,
示例13: m_analogInput/** * Create a new instance of Accelerometer from an existing AnalogInput. * * Make a new instance of accelerometer given an AnalogInput. This is * particularly useful if the port is going to be read as an analog channel as * well as through the Accelerometer class. * * @param channel The existing AnalogInput object for the analog input the * accelerometer is connected to */AnalogAccelerometer::AnalogAccelerometer(AnalogInput* channel) : m_analogInput(channel, NullDeleter<AnalogInput>()) { if (channel == nullptr) { wpi_setWPIError(NullParameter); } else { InitAccelerometer(); }}
开发者ID:PeterMitrano,项目名称:allwpilib,代码行数:18,
示例14: wpi_setWPIError/** * Convert a voltage to a raw value for a specified channel. * * This process depends on the calibration of each channel, so the channel * must be specified. * * @todo This assumes raw values. Oversampling not supported as is. * * @param channel The channel to convert for. * @param voltage The voltage to convert. * @return The raw value for the channel. */int32_t AnalogModule::VoltsToValue(int32_t channel, float voltage){ if (voltage > 10.0) { voltage = 10.0; wpi_setWPIError(VoltageOutOfRange); } if (voltage < -10.0) { voltage = -10.0; wpi_setWPIError(VoltageOutOfRange); } uint32_t LSBWeight = GetLSBWeight(channel); int32_t offset = GetOffset(channel); int32_t value = (int32_t) ((voltage + offset * 1.0e-9) / (LSBWeight * 1.0e-9)); return value;}
开发者ID:HiceS,项目名称:synthesis,代码行数:29,
示例15: switch/** * Set the relay state. * * Valid values depend on which directions of the relay are controlled by the * object. * * When set to kBothDirections, the relay can be any of the four states: * 0v-0v, 0v-12v, 12v-0v, 12v-12v * * When set to kForwardOnly or kReverseOnly, you can specify the constant for * the direction or you can simply specify kOff and kOn. Using only kOff and * kOn is recommended. * * @param value The state to set the relay. */void Relay::Set(Relay::Value value) { switch (value) { case kOff: if (m_direction == kBothDirections || m_direction == kForwardOnly) { go_pos = false; } if (m_direction == kBothDirections || m_direction == kReverseOnly) { go_neg = false; } break; case kOn: if (m_direction == kBothDirections || m_direction == kForwardOnly) { go_pos = true; } if (m_direction == kBothDirections || m_direction == kReverseOnly) { go_neg = true; } break; case kForward: if (m_direction == kReverseOnly) { wpi_setWPIError(IncompatibleMode); break; } if (m_direction == kBothDirections || m_direction == kForwardOnly) { go_pos = true; } if (m_direction == kBothDirections) { go_neg = false; } break; case kReverse: if (m_direction == kForwardOnly) { wpi_setWPIError(IncompatibleMode); break; } if (m_direction == kBothDirections) { go_pos = false; } if (m_direction == kBothDirections || m_direction == kReverseOnly) { go_neg = true; } break; } impl->Set((go_pos ? 1 : 0) + (go_neg ? -1 : 0));}
开发者ID:frc1678,项目名称:third-party,代码行数:60,
示例16: setClosedLoopControl/** * Enables or disables automatically turning the compressor on when the * pressure is low. * @param on Set to true to enable closed loop control of the compressor. False * to disable. */void Compressor::SetClosedLoopControl(bool on) { int32_t status = 0; setClosedLoopControl(m_pcm_pointer, on, &status); if (status) { wpi_setWPIError(Timeout); }}
开发者ID:adsnaider,项目名称:Robotics-Project,代码行数:15,
示例17: clearAllPCMStickyFaults/** * Clear ALL sticky faults inside PCM that Compressor is wired to. * * If a sticky fault is set, then it will be persistently cleared. Compressor * drive * maybe momentarily disable while flags are being cleared. Care * should be * taken to not call this too frequently, otherwise normal * compressor * functionality may be prevented. * * If no sticky faults are set then this call will have no effect. */void Compressor::ClearAllPCMStickyFaults() { int32_t status = 0; clearAllPCMStickyFaults(m_pcm_pointer, &status); if (status) { wpi_setWPIError(Timeout); }}
开发者ID:adsnaider,项目名称:Robotics-Project,代码行数:22,
示例18: m_aSourceEncoder::Encoder(std::shared_ptr<DigitalSource> aSource, std::shared_ptr<DigitalSource> bSource, bool reverseDirection, EncodingType encodingType) : m_aSource(aSource), m_bSource(bSource) { if (m_aSource == nullptr || m_bSource == nullptr) wpi_setWPIError(NullParameter); else InitEncoder(reverseDirection, encodingType);}
开发者ID:frc1678,项目名称:third-party,代码行数:9,
示例19: m_analog/** * Gyro constructor with a precreated AnalogInput object. * Use this constructor when the analog channel needs to be shared. * This object will not clean up the AnalogInput object when using this * constructor * @param channel A pointer to the AnalogInput object that the gyro is * connected to. */AnalogGyro::AnalogGyro(std::shared_ptr<AnalogInput> channel) : m_analog(channel) { if (channel == nullptr) { wpi_setWPIError(NullParameter); } else { InitGyro(); Calibrate(); }}
开发者ID:FRC3238,项目名称:allwpilib,代码行数:17,
示例20: wpi_setWPIError/* * Invert a motor direction. * This is used when a motor should run in the opposite direction as the drive * code would normally run it. Motors that are direct drive would be inverted, the * Drive code assumes that the motors are geared with one reversal. * @param motor The motor index to invert. * @param isInverted True if the motor should be inverted when operated. */void RobotDrive::SetInvertedMotor(MotorType motor, bool isInverted){ if (motor < 0 || motor > 3) { wpi_setWPIError(InvalidMotorIndex); return; } m_invertedMotors[motor] = isInverted ? -1 : 1;}
开发者ID:0xacf,项目名称:wpilib,代码行数:17,
注:本文中的wpi_setWPIError函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ wpi_setWPIErrorWithContext函数代码示例 C++ wpi_setErrorWithContext函数代码示例 |